lpcware

Boot loader and Flash address

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by ahp on Thu Oct 20 00:39:23 MST 2011
I am developing an application which must be able to update the running program, without using the built in ISP.

I have solved this by writing an IAP (In Application Programming) which resides inside my application and writes the new program to an unused section of the Flash.

The problem is how to switch between the two applications.

The way I have solved this is to write a tiny application which should simply jump to the newest application, where the age may be determined by reading two predefined flash addresses (set as part of the application load).

I am using an LPC1768, which has 512kb Flash, so I have reserved the first 4k for the switching application, the next 220kb for the application and the next 32kb for configuration and application age. In the upper 256kb Flash the first 224kb is reserved for the application and the last 32kb for configuration and application age.

---------------------
32kb config and age
- - - - - - - - - - -
224kb applciation
---------------------
32kb config and age
- - - - - - - - - - -
220kb applciation
- - - - - - - - - - -
4kb switching app
---------------------

My problem is that I am unsure how to flash the code to the LPC1768.

Can I specify where the application should be written to the flash? (e.g. start at address 0x4000, instead of 0x0).

In order to get the code working I would have to write the switching app and the first application to the flash. Naturally I can write the switching app the flash using LPCXpresso, Red Suite or FlashMagic, but as far as I can tell all these application insist on writing to address 0x0. Is there a way to write to another address? FlashMagic can avoid erasing certain sectors, which is great for avoiding erasing the switching app when flashing the application, but how do I specify where to flash the application?

Outcomes