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

IAP for all flash

Hi,
I'm using LPC2468
I want to replace all the flash code in the internal flash at site.
I have an external flash that I can download the new firmware to it (using serial or ethernet) then I want to run an IAP function that replace ALL the existing code (in Internal flash) with the new firmware.
Can anyone suggest me the steps to follow. I know that while I program the flash if there will be power fail I will get into trouble - How to avoid them?

Regards,
Doron

Parents Reply Children
  • What are the steps to follow. How can I redirect the code to run into the bootloader while programing

    You have that backwards. You don't redirect into the bootloader, you have the bootloader redirect to your application. I.e. the bootloader is the primary program that runs directly out of reset. The bootloader then checks if there's a valid application program present. If there is, the bootloader jumps to it. Otherwise it just waits for a fresh program on its input channel.

  • Otherwise it just waits for a fresh program on its input channel.

    In this case it doesn't need to wait for a new download. Since the OP has an external flash for downloading the new binary, a power loss when copying from external to internal flash isn't dangerous. The boot loader can restart the copying, and leave all transfers to the application. The only way to loose the chip then is if the internal flash is broken and can't be reprogrammed (in which case the hardware has to be replaced anyway) or a seriously buggy application has been downloaded, that fools the bootloader to start the application, but where the application does not perform as expected.

  • Since the OP has an external flash for downloading the new binary, a power loss when copying from external to internal flash isn't dangerous.

    But a powerloss while filling the external flash from elsewhere, would be.

  • Not with a boot loader. It would also produce a broken copy, but the boot loader would be able to restart the copy.

    Without room for two application copies, the boot loader must wait for a new transfer in case of a power loss during the update. With room for two application copies, the boot loader do not need any transfer capabilities - just the ability to detect a partial copy.

  • Sorry, I think I missed your point.

    "But a powerloss while filling the external flash from elsewhere, would be."

    If the external flash is just used as a scratch buffer for the transfer+reprogramming cycle, a power loss during the transfer to external flash should not be dangerous.

    A working boot loader should be able to notice that it has a valid crc for the main application, but a broken crc for the new application and then just start the application in the internal flash. That application can then restart the transfer of a new application into the external flash.

    If the boot loader do find a valid image in both internal and external flash, it can compare the two images and see if a copy is needed. After a full copy is done, the boot loader may decide to erase the external flash or toggle a flag in EEPROM or similar, just to speed up following reboots.