Skip to main content
Topic: v4 compile/bootloader v4 issues (Read 3732 times) previous topic - next topic

v4 compile/bootloader v4 issues

I just pulled down the latest source from svn to add support for ISO 7816-3 ATR for async cards (T=0, T=1). The first thing I did was to compile the source (unchanged) using MPLAB and C30. Compilation went fine. I then exported it using the settings:
"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.


Re: v4 compile/bootloader v4 issues

Reply #1
try exporting to a7fe (or a7fd). THe bootloader lives in the region after 0xa800 and it throws an error if you try to bootload over it.
Got a question? Please ask in the forum for the fastest answers.

Re: v4 compile/bootloader v4 issues

Reply #2
You don't need to export the progmem to .hex. I know it is documented in the howto, but with the new bootloader it isn't necessary. The generated hex will just program fine. If you insist on exporting export only to 0xa7ff.

The reason is the loader protects the bootloader which lives from 0xa800 and up and thus refuses to erase that portion of memory.

Edit: like ian says :D but there is still no need to export ;)

Re: v4 compile/bootloader v4 issues

Reply #3
Thanks for the quick response!

I tried exporting from 0 to 0xa7fe, 0xa7fd, 0xa4fe, 0xa4fd, etc. No matter what I try it continues to try and erase the page at 0xa800. When I try to bootload the generated busPirate.hex from the compile I get a bootloader error:

Parsing HEX file [busPirate.hex]
Checksum does not match, line 4

I have a suspicion this may be related to running MPLAB under wine... although line endings on the hex file look right (x0d x0a) for windows. Would this mess up pirate-loader_lnx in any way? I tried converting the hex file to unix style line endings but that didn't help. I guess I'll try and install MPLAB on my windows box and see if that helps.

Thanks for the help,

Re: v4 compile/bootloader v4 issues

Reply #4
do you have the config bits checked or not? Those are also in the last page (Oxa800 and up)

Could you try the generated hex? It should be in the directory itself or the output subdir.

Re: v4 compile/bootloader v4 issues

Reply #5
That was it. I unchecked the configuration bit in export and changed the export range and it works fine now. I tried the generated hex in the output subdirectory but I get the checksum error mentioned above. Haven't figured out why that is but as long as one method works I'm happy :) Also, as an FYI MPLAB/C30 works pretty well under wine. No real big issues. Thanks for the help!

Re: v4 compile/bootloader v4 issues

Reply #6
>Parsing HEX file [busPirate.hex]
>Checksum does not match, line 4

Ah, Checksum error... Could it be a case of  "Lower case hexfile?" ... opic=437.0

Re: v4 compile/bootloader v4 issues

Reply #7
Could you perhaps copy&paste the first 10 lines of the .hex file?