This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Secondary Bootloader IAP Flash Write

Hi everyone, I hope someone can help me with my problem.

I'm writing a secondary bootloader for an lpc2388 that reads the new firmware from external I2C EEPROM (separated into 128byte pages) and writes it to the internal flash using IAP commands. The bootloader starts at 0x0000 in flash and the main application (RTX) starts at 0x2000.

Currently the program flow is:
1. Check if user code doesn't exist or a flag has been set (set at a flash address by the main application). If not it executes the code. If so it continues.
2. Inits the system IO (UART for debugging and I2C for EEPROM access)
3. Goes through the eeprom and calculates a checksum and compares to the checksum received from the main application
4. Erases the current firmware using IAP commands
5. using IAP commands the new firmware is written by preparing, writing, and validating the flash in 512byte chunks
6. Once the new firmware is written I do another pass through comparing what is in the EEPROM with what is in the Flash
7. I then use the internal WDT to reset and run the new firmware

I'm seeing a couple problems.
1. Sometimes the IAP validate fails after writing a 512byte chunk. When this happens I retry the chunk and it usually works the second try, but I can't explain why it fails the first time.
2. Sometimes the new firmware get written without any errors generated by the IAP commands, but when I do the final pass to validate the new firmware in flash, sometimes I get a byte mismatch where only a single bit is flipped. Could this have something to do with ECC?
3. The third problem I'm having is that when the new firmware is flashed without any problems and we start running the new firmware, sometimes I will get some strange errors related to RTX timing. It seems the os_time_get command is returning very large values.

I don't really know how to explain the above errors. I played around doing IAP writes with different chunk sizes (4096) but to no avail. Does anyone have any ideas?

0