Custom Bootloader query

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

Custom Bootloader query

482 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Scribe on Mon Sep 10 05:19:27 MST 2012
Hi guys,

I'm currently writing the code for a custom bootloader and am tripping over myself a little with memory allocation.
From what I gather with the ARM compiler, globals and statics head into RW CODE space, not on the stack.

In my situation, I have a two stage bootloader and application code.

I'm guessing I'll have to reserve space for any globals so that the second stage doesn't overwrite anything in the first stage, my question then is, when branching from my first stage to the second stage, what's the best way to deal with the stack pointer? I'll still be using the main stack at this point.

Does anyone have any recommendations or suggestions of approaches that they've tried before and gotten along with?

Many thanks
Labels (1)
0 Kudos
2 Replies

458 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Daniel Widyanto on Wed Sep 26 23:19:42 MST 2012
Hi Scribe,

The question is why would you like to keep the bootloader's data (globals and static vars) after booting is done ?

Normally, once the bootloader is done, and the application taking over, the app won't need bootloader data anymore. Hence, the app can just reinit the stack into the top of the SRAM.

Btw, there's app note in NXP website for designing your own custom bootloader (See http://www.nxp.com/documents/application_note/AN10995.zip)
0 Kudos

458 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Scribe on Mon Sep 10 05:31:57 MST 2012
To elaborate a little further, right now it's feeling simplest to reserve some space in RAM and then assign the same stack details to each bootloader and use only stack memory and link into the reserved memory through pointers.

It would be ideal for maintainence/clarity if there was a way to use standard globals and statics as opposed to having to leave RAM free to tie into later on, whilst not having the two bootloader stages step on each other's toes.
0 Kudos