View previous topic :: View next topic |
Author |
Message |
russk2txb
Joined: 30 Mar 2008 Posts: 109 Location: New Jersey
|
Bootloader problem |
Posted: Wed Jul 11, 2018 6:53 am |
|
|
Hi All. I have had a working bootloader for several years, but I just discovered it no longer works. I upgraded the compiler to version 5.071 a while ago so I am wondering if there might be a problem with it. The bootload program hangs the PIC when it tries to write to eeprom. Here is the relevant code: Code: |
if (Bd.addr >= 0xF00000) {
for (i=0; i < Bd.len; ++i)
write_eeprom (Bd.addr + i, Bd.data [i]);
}
|
I should explain that my bootloader does not send the hex file. Instead it converts it to binary and then sends checksummed binary packets. The packets are received into a BootData structure (Bd). After checking the checksum the data is written to the address contained in the structure.
For the PIC4680, EEPROM starts at address 0xF000. All the program code is successfully transferred and written but the loader hangs when it tries to write EEPROM. If the PIC is reset the newly program will run but with the old EEPROM values.
Has there been some change in the way this works - like maybe some need to disable/re-enable some data protection bit. (I think that bit is set automatically when calling the write_eeprom function.)
I should note that the CCSLoad program has no problem writing the EEPROM data.
Thanks for any insight on this,
Regards, Russ |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Wed Jul 11, 2018 6:56 am |
|
|
Remove the #nolist at the top of the processor header file and compile. Do the same for a compiler version that worked, and compare the .lst files. Whatever changed should become apparent. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Wed Jul 11, 2018 7:38 am |
|
|
The syntax is 'worrying'. The write_eeprom, function expects an address from 0 to the size of the eeprom, not a value of 0xF00000. That is the address required when using the write_program_memory function to talk to the eeprom....
From the manual:
Quote: |
address is the 0 based starting location of the EEPROM write
|
To work, it'd need:
Code: |
if (Bd.addr >= 0xF00000) {
for (i=0; i < Bd.len; ++i)
write_eeprom (i, Bd.data [i]);
}
|
I'd suspect the old function trimmed the address value to an 8bit variable, so was only taking the low byte. The new version may well be using a larger type (is needed for many chips that have larger EEPRROM's). |
|
|
russk2txb
Joined: 30 Mar 2008 Posts: 109 Location: New Jersey
|
Bootloader problem |
Posted: Wed Jul 11, 2018 10:37 am |
|
|
Thanks for the ideas guys. I never noticed that I was sending a 32 bit address to the write_eeprom function. However that was not the problem. To be sure I did change the code to and the address with 0x3FF, but that made no difference. The reason is that the address parameter to the write_eeprom function is 16 bits and so it automatically chopped off those extra bits.
It turns out the problem was not in the boot loader at all. I made a wrong assumption when the Boot host reported a no response error. In fact the problem was that the timeout for the RS232 handler in the PC program had gotten changed (to 100 ms) and that was just too short of a time to write up to 64 bytes to eeprom.
So, thanks again for showing me my error...
Regards, Russ |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Wed Jul 11, 2018 11:28 am |
|
|
Timeouts.
If I had a cent for every time one has caused me problems I might be worth a few dollars....
The EEPROM is the worst memory here, since while the primary flash does one erase per page, this does erases on a per byte basis.
Glad you found it. |
|
|
|