Having stepped further in my IAP firmware update project I now want to flash sectors on a LPC1343. I decided to use the flash source code delivered with the KEIL MDK V4.23 (C:\Keil\ARM\Flash\LPC_IAP\FlashPrg.c). I'm wondering about a function 'Init()' which switches the processors clock to the internal oscillator. As my bootloader app has already executed its startup code, my processsor is running from an external oscillator. So, why to switch to the internal osc before flashing? Best regards, Juergen.
Projects in Keil\ARM\Flash folder are made for uVision Flash programmer. They contain functions required for programming/erasing (including "Init") required by the toolchain.
The same code can be used also for IAP but sometimes requires minor modifications to fit the standalone projects.
Ok, used the (modified) flash routines successfully.
Now a strategic problem: Have the loader at 0x00000000 and the application at 0x00003000. Initial both are flashed by UV4.
After power up the loader checks if the CRC of the application is correct and jumps to the application by setting VTOR and jumping to applications reset vector like this: SCB->VTOR = (0x00003000 & 0x1FFFFF80); p = (unsigned *)(0x00003000 + 4); mainapp_entry = (void *) *p; mainapp_entry();
Problem is the check that the applications CRC is ok (e.g. that further IAP flashing went ok).
Therefore want to move the application to 0x00003010 (or higher), to get (at least) 16 bytes room (0x00003000..0x0000300F) for - uint32_t BIN filesize - uint32_t CRC - uint32_t Inv CRC - uint32_t Reserve So I have these info at same (fixed) addresses.
This way my IAP master can extend the bin file by these four dwords and the loader starts flashing at a sector boundary (0x00003000).
Question: Is it ok to locate the application at a 16 byte boundary (0x00003010), set VTOR to a 16 byte boundary (0x00003010) and jump to 0x00003010+4?
It's quite common to do the reverse - place CRC and other information last.
'last'... But where in memory is 'last'? The bin filesize varies.
So i decided to put crc and size information in front of the application program, at fixed addresses, where the loader can find it.
Maybe you have a hint or link to some doc, how to IAP the firmware of a target?
Last would be last in flash - your processor will not get bigger/smaller flash size just because the binary file changes in size.