1
Bus Pirate Development / v4 compile/bootloader v4 issues
"Program Memory"=checked Start:0 End:0xabfa
"Configuration bits"=checked
"File format"=INHX32
I then tried using pirate-loader_lnx to flash the resulting hex file. The output I get is:
root@ebuller-linux:/home/ebuller/bus-pirate/the-bus-pirate-read-only/source/output# ./pirate-loader_lnx --dev=/dev/ttyUSB1 --hex=bpv42.hex
+++++++++++++++++++++++++++++++++++++++++++
Pirate-Loader for BP with Bootloader v4+
Loader version: 1.0.1 OS: Linux
+++++++++++++++++++++++++++++++++++++++++++
Parsing HEX file [bpv42.hex]
Found 22016 words (66048 bytes)
Fixing bootloader/userprogram jumps
Opening serial device /dev/ttyUSB1...OK
Configuring serial port settings...OK
Sending Hello to the Bootloader...OK
Device ID: PIC24FJ64GA002 [d4]
Bootloader version: 1,02
Erasing page 0, 0000...OK
Writing page 0 row 0, 0000...OK
Writing page 0 row 1, 0080...OK
...
Writing page 40 row 327, a380...OK
Erasing page 41, a400...OK
Writing page 41 row 328, a400...OK
Writing page 41 row 329, a480...OK
Writing page 41 row 330, a500...OK
Writing page 41 row 331, a580...OK
Writing page 41 row 332, a600...OK
Writing page 41 row 333, a680...OK
Writing page 41 row 334, a700...OK
Writing page 41 row 335, a780...OK
Erasing page 42, a800...ERROR [50]
Error updating firmware

The bootloader on the device is the latest 4.2 bootloader. When I try flashing Ians pre-compiled firmware from v4-nightly it completes fine (stops after writing page 41). Now I'm assuming the bootloader resides in page 42 which is why the bootloader refuses to erase that page. My question is why is my compiled code (with no changes) larger that the stock firmware? I tried adding -O3 as a compile option but that didn't seem to help... Here is the MPLAB mem map:
Program Memory [Origin = 0x200, Length = 0xa5fe]
section address length (PC units) length (bytes) (dec)
------- ------- ----------------- --------------------
.text 0x200 0x3cc 0x5b2 (1458)
.const 0x5cc 0x1a8e 0x27d5 (10197)
.text 0x205a 0x4550 0x67f8 (26616)
.dinit 0x65aa 0x322 0x4b3 (1203)
.text 0x68cc 0x1516 0x1fa1 (8097)
.isr 0x7de2 0x2 0x3 (3)
Total program memory used (bytes): 0xb9d6 (47574) 74%
Data Memory [Origin = 0x800, Length = 0x2000]
section address alignment gaps total length (dec)
------- ------- -------------- -------------------
.nbss 0x800 0 0x1014 (4116)
.ndata 0x1814 0 0x344 (836)
.nbss 0x1b58 0 0x70 (112)
.ndata 0x1bc8 0 0x28 (40)
.nbss 0x1bf0 0 0x32 (50)
.ndata 0x1c22 0 0x26 (38)
.nbss 0x1c48 0 0xe (14)
.ndata 0x1c56 0 0xc (12)
.nbss 0x1c62 0 0x54 (84)
.ndata 0x1cb6 0 0x4 (4)
.nbss 0x1cba 0 0xc (12)
.ndata 0x1cc6 0 0x2 (2)
.nbss 0x1cc8 0 0x4 (4)
Total data memory used (bytes): 0x14cc (5324) 64%
Any suggestions would be greatly appreciated.
Regards,
Elliot