Skip to main content
Topic: Compiling Bus Pirate firmware with MPLABX (under linux, mac, ...) (Read 62989 times) previous topic - next topic

Re: Compiling Bus Pirate firmware with MPLABX (under linux, mac, ...)

Reply #15
I can only speak from the windows point of view and I've not yet tried this new IDE, but as far as I'm aware the IDE just passes command lines to the compiler tools and they decide what to do with them, after a set time (60 days i think) they inform you in the build window the evaluation period is over and just compile with lite options, with the little fiddling I did with optimizations, the -O1 option produces smaller/faster code

Re: Compiling Bus Pirate firmware with MPLABX (under linux, mac, ...)

Reply #16
Delivering a limited gcc, what a shame

Here are some numbers just to get an idea (using MPLABX), compiling all modules
* -: does not fit
* -O1: 195924
* -O2: 214052
* -O3:  does not fit
* -O4:  does not fit
* -O5:  does not fit
* -Os: 181508

So we can live with -O1 for a while...
I still hope that new MPLABX gcc can be used more freely... at least I don't thing there is any limitation in the beta version.

Re: Compiling Bus Pirate firmware with MPLABX (under linux, mac, ...)

Reply #17
Hmm, from those numbers, it looks like -On optimization favors speed over size. Since -Os is supposed to give the best size (without making the code slower), I'm not surprised that it wins.

Did you try -O (without a number)?  That is supposed to reduce code size and execution time (in standard gcc).

Re: Compiling Bus Pirate firmware with MPLABX (under linux, mac, ...)

Reply #18
-O gives same results as -O1
And, quite obviously if it's same as -O1: -O is not an option available per se in the IDE

Re: Compiling Bus Pirate firmware with MPLABX (under linux,

Reply #19
Guyzz

I Just got 2 BusPirates , and wanted to see if i could build the firmware on Ubuntu 10.04LTS

I read about the -O1 limit on the compiler , and wanted to see if i could circumvent that :-)

I maintain the Linux avr-gcc buildscript @ AvrFreaks , so i had to try to build a pic toolchain.

I followed this recipe
http://code.google.com/p/pic30/

And ended up with a compiler , that was "almost working" ....
I just needed to make 2 symlinks , and rename a few of the binaries
See build-hints

I did a svn checkout : svn checkout http://the-bus-pirate.googlecode.com/svn/trunk/

And had to modify the makefile a little bit ...It complained about the .inc file in OpenOCD_asm.S
I had to help gcc (well AS in the end) a bit ... the -Wa part
See makefile.

Code: [Select]
CFLAGS = -v -Wall $(OPTIMIZE) $(DEFS) $(INCLUDES) -mcpu=$(CPU) -mlarge-code -mlarge-data -Wa,-I$(C30_PATH)/support/PIC24F/inc

I also added a neat makefile trick , i snipped from the net ...
Now it lists the individual size of each .o module.

Here is the result of the build

Maybe someone can check against an "official" compiler

Code: [Select]
rm -rf *.o *.coff *.hex
  CC      1wire.o
  CC      AUXpin.o
  CC      base.o
  CC      baseIO.o
  CC      baseUI.o
  CC      basic.o
  CC      binIO.o
  CC      binIOhelpers.o
  CC      binwire.o
  CC      bitbang.o
  CC      busPirateCore.o
  CC      dio.o
  CC      ee.o
  CC      eetext.S.o
  CC      HD44780.o
  CC      I2C.o
  CC      m_1wire_213.o
  CC      main.o
  CC      OpenOCD.o
  CC      OpenOCD_asm.S.o
  CC      pc_at_keyboard.o
  CC      pic.o
  CC      procMenu.o
  CC      raw2wire.o
  CC      raw3wire.o
  CC      selftest.o
  CC      SPI.o
SPI.c: In function ‘SPIwrite’:
SPI.c:129: warning: control reaches end of non-void function
  CC      SUMP.o
  CC      uart2io.o
  CC      UART.o
  LINK    main.coff

  text   data     bss     dec     hex filename
  2952     516     224   3692     e6c ./1wire.o
  1188       0       0   1188     4a4 ./eetext.S.o
  5916     140   2256   8312   2078 ./basic.o
  1252       0       0   1252     4e4 ./raw2wire.o
  3164     80     16   3260     cbc ./UART.o
    52       0       0     52     34 ./dio.o
    988       0       4     992     3e0 ./raw3wire.o
  1916       0     36   1952     7a0 ./AUXpin.o
  1196       0     44   1240     4d8 ./SUMP.o
    560       0       0     560     230 ./baseUI.o
  1520       0       8   1528     5f8 ./binIO.o
    972     36       0   1008     3f0 ./base.o
  2548       0     20   2568     a08 ./binwire.o
  1264       4       0   1268     4f4 ./ee.o
  1040       0       4   1044     414 ./OpenOCD.o
    140       0       0     140     8c ./binIOhelpers.o
  2764       0     16   2780     adc ./I2C.o
  3844     24     12   3880     f28 ./SPI.o
  10104       0     848   10952   2ac8 ./procMenu.o
  1212       0       4   1216     4c0 ./selftest.o
      0       0       0       0       0 ./pc_at_keyboard.o
  1264       0     20   1284     504 ./bitbang.o
    264       0       0     264     108 ./OpenOCD_asm.S.o
      0       0       0       0       0 ./pic.o
    192     828       0   1020     3fc ./busPirateCore.o
  1952       0     32   1984     7c0 ./baseIO.o
  1124       0       4   1128     468 ./HD44780.o
  1236       0       8   1244     4dc ./m_1wire_213.o
    304       0       0     304     130 ./uart2io.o
    252     36   8244   8532   2154 ./main.o
  51180   1664   11800   64644   fc84 (TOTALS)

Final Size:
pic30-size main.coff
  text   data     bss     dec     hex filename
  63564   1664   11800   77028   12ce4 main.coff
  BIN2HEX main.hex

writing main.hex

section  PC address  byte address  length (w/pad)  actual length  (dec)
-------  ----------  ------------  --------------  --------------------
.reset            0              0              0x8            0x6  (6)
.text          0x200          0x400            0xa84          0x7e3  (2019)
.ivt            0x4            0x8            0x1f8          0x17a  (378)
.aivt          0x104          0x208            0x1f8          0x17a  (378)
.const        0x742          0xe84            0x6bc          0x50d  (1293)
.text          0xaa0        0x1540          0xa74c          0x7d79  (32121)
.dinit        0x5e46        0xbc8c            0x5b0          0x444  (1092)
.text        0x611e        0xc23c          0x3614          0x288f  (10383)
.isr          0x7c28        0xf850              0x4            0x3  (3)

Total program memory used (bytes):                            0xba39  (47673)

I have attached the hex & coff files in the main package.

As i don't have a PIC burner , i don't dare to upload it to the BP.

But maybe someone else can check , (if it even fits) .. Isn't there a bootloader also ?

Well it has been fun to try , and i never thought i would ever have a PIC compiler on my machine :-)

/Bingo

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #20
Thanks for the outline, it's great to hear it's compiling on MPLABX. If you have any patches against the SVN I can apply them and do a test compile.

Quote
As i don't have a PIC burner , i don't dare to upload it to the BP.

I think it will be ok. The bootloader is very well protected in the Bus Pirate.

Quote
But maybe someone else can check , (if it even fits) .. Isn't there a bootloader also ?

The bootloader source is located here in SVN:
http://code.google.com/p/the-bus-pirate ... mware-v4.3

It is all in ASM.
Got a question? Please ask in the forum for the fastest answers.

Re: Compiling Bus Pirate firmware with MPLABX (under linux,

Reply #21
@Ian

I haven't used MPLABX yet ...

I have just build a PIC toolchain , with -Os support "forever" , and tested it with the "Makefile" included in svn (well the adapted one i attached)

Will prob. try MPLABX later on ...

For now i'm just fooling around with the "homemade" toolchain  on an Ubuntu 10.04LTS 32-bit machine.

I'm trying to build the above script on an x64 machine but i'm having some trouble.
The linker complains about some files are build in 32-bit mode.

Will look into it.

/Bingo

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #22
Would I still need a PICKIT 2 or Sureelectronics PICKIT 2 mini to update the firmware on Bus Pirate 3.5b with MPLABX?

I have several OS's Mac OSX 10.7, Mac OSX 10.6, MAc OSX 10.5.8, Fedora Linux 15 64 bit, Fedora 13 32bit, windows 7 64 bit and two vmware OS's windows XP 32 bit and windows 7 64 bit.

I would like to get MPLABX running on MAc OSX 10.5.8 and Fedora Linux 15 64 bit and windows 7 64 bit right now.  Will it run on all 3 OS's and support firmware upgrade on the BP 3.5b without the PICKIT 2?

Thanks

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #23
That bus pirate has a usb bootloader. If you can get it compiled, you should be able to load it with the bootloader and no programmer.,
Got a question? Please ask in the forum for the fastest answers.

Re: Compiling Bus Pirate firmware with MPLABX (under linux,

Reply #24
I got MPLABX running on a 32 bit linux. It does work reasonable well.. You can import a mplab8x project using a wizard. Why don't you give it a try?

If you have bought your BP commercially it is equipped with a bootloader so you don't need a PICKIT to programm it. The bootloader should withstand lots of abuse and still survive. You still need MPLAB(X) to compile the sourcecode.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #25
I just execute $ in xterm and it flashes BOOTLOADER.  In OSX 10.5.8

Then what is the procedure to burn the new firmware onto the BP in MPLABX?  DO I need to cnvert the HEX file as said here then go from there?  Is there a short protocol on the procedure to upload the new firmware to the BP?

I want to try Firmware version 5.9 but cannot find the firmware files inbetween my currently installed version 5.10 and the latest 5.9 version.

It has to be on SVN correct?  I just could not find them.

Anyhow what is the procedure after I install MPLABX?


Thanks

Re: Compiling Bus Pirate firmware with MPLABX (under linux,

Reply #26
[quote author="pcfr33k"]Then what is the procedure to burn the new firmware onto the BP in MPLABX? DO I need to cnvert the HEX file as said here then go from there? Is there a short protocol on the procedure to upload the new firmware to the BP?
[/quote]
To upload a new firmware here are the direction in our wiki: http://dangerousprototypes.com/docs/Pir ... c,_Windows)

[quote author="pcfr33k"]
I want to try Firmware version 5.9 but cannot find the firmware files inbetween my currently installed version 5.10 and the latest 5.9 version.

It has to be on SVN correct? I just could not find them.
[/quote]

The latest version in our svn, but you can get an older revision. Version 5.9 was svn version 540 i guess. http://code.google.com/p/the-bus-pirate ... tail?r=540

[quote author="pcfr33k"]
Anyhow what is the procedure after I install MPLABX?
[/quote]

I guess you should write PIC code :)

If you want to compile your own buspirate firmware, get the code from the svn, import a mplab8 project into it and start your own fantasy. You can upload your fimrware with a pickit directly from mplabx or get the .hex from the build directory and upload it with the ds30 upload utility.

[SOLVED] Compiling Bus Pirate firmware with MPLABX (under l

Reply #27
I should have mentioned I am in OSX 10.5.8 right now. 

For now I want to upload the stock firmware not my own.

I cannot get ds30 to work in OSX 10.5.8 using mono so I have to try another method.

I tried to use pirate-loader_mac  and it is also not working I left a post on the message I get when I launch it.

sh-3.2# ./pirate-loader_mac
dyld: unknown required load command 0x80000022
Trace/BPT trap
sh-3.2#

Also that link you posted is not working below

To upload a new firmware here are the direction in our wiki: http://dangerousprototypes.com/docs/Pir ... c,_Windows)


EDITED ABOUT AN HOUR LATER:

I figured out the link missing a ")".  Anyhow I followed that tutorial the I get the message above.  I will try this in OSX 10.6 to see if the Pirate-Loader_Mac application was written for 64 bit or Snow Leopard rather than Leopard.

If not I suppose I could try it in Fedora Linux 64 bit.

I have to assume that I cannot upload the STOCK firmware in MPLABX which is what I was asking before.

Thanks


EDITED ABOUT ANOTHER HOUR LATER:

Well all my issues had to do with OSX 10.5.8.  Got everything working in OSX 10.6.8.  By everything I mean Bus Pirate Gui,  Pirate-loader_mac to upload the stock firmware.  So now its time to learn coding etc which I have little experience just some MSSQL and Power Builder.

After the firmware upgrade I was a bit confused on how to verify?  After the firmware upgrade do I need to disconnect the BP then do the verify or do the verify right after the update and exactly what is the exact script below gives me a blank screen.


Firmware updated successfully :)!
Use screen /dev/tty.usbserial-A900F57B 115200 to verify

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #28
After upgrading you should unplug the buspirate to be sure it got properly reset. Use the'i' command to verify the current firmware.

Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin

Reply #29
Yes and it displays the new firmware properly.  So I cannot run any verify command before reseting the BP I assume?  That message about use screen what is that all about?  Thanks