Bootloader in bank A: Self-Update - anything special? (LPC4357)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bootloader in bank A: Self-Update - anything special? (LPC4357)

647 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mysepp on Wed Dec 02 15:15:43 MST 2015
Hi,

I have a bootloader which is stored in bank A. The bootloader shall be able to update itself.
I collect my new bootloader in RAM. When everything is transmitted to RAM
and verified to be correct by a checksum, I replace the existing bootloader.

Theoretically it seems to be working, I get no errors when using IAP commands.
Addressses where I store the bootloader and which I take data from RAM, used length paramers
seem to be correct.
Nevertheless it seems (at least part of it) is the old bootloader???

Is there something special to pay attention? Perhaps are some flash areas remapped during start-up,
which I must un-remap first or put the sector to the mapped address?

I think to remember that such a thing was used in old LPC176x (or was it even earlier with LPC21xx?),
where vector table was replaced (or replaceable) by RAM...

Or is there perhaps some example of a bootloader which can replace itself?

BTW: Is it correct to call "activate flash bank" (of bank A) every time or is it only needed once,
when bootloader is installed the first time?

Many thanks!

Best regards,

Martin


Labels (1)
0 Kudos
Reply
1 Reply

584 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by michele sponchiado on Fri Jan 15 03:12:22 MST 2016
Hi,this is the sequence which works for me:
[list]
  [*]call the Chip_IAP_Init() routine
  [*]to program the flash I followed this sequence
[list=1]
  [*]loop for every flash sector involved
  [*]disable the IRQs!
  [*]call the Chip_IAP_PreSectorForReadWrite, check for errors in the return code
  [*]call the Chip_IAP_Chip_IAP_EraseSector, check for errors in the return code
  [*]loop into the current sector: for every 512 bytes (I think it works also with other bytes size, e.g. 1024, but never tried), I call the Chip_IAP_PreSectorForReadWrite then the Chip_IAP_CopyRamToFlash using a buffer in the internal RAM (I dunno if it works also using external SDRAM), always checking the return code
  [*]enable the IRQs!
  [*]loop next flash sector
[/list]
  [*]if I need to call the Chip_IAP_SetBootFlashBank, but this is really needed if the boot bank has been changed, I call again the  Chip_IAP_Init, but I really don't know if it is needed
[/list]
0 Kudos
Reply