cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader and jumping to flash location

jdcowpland
Associate II
Posted on March 13, 2014 at 16:18

Hi guys,

I've been working on a bootloader program which is loosely based around the FW_Upgrade demo for the STM32F4 discovery board. My Bootloader so far correctly finds a file on a USB stick and downloads it to flash in the right location(0x0800C000), but I'm having issues jumping to that location to run my downloaded program once I'm done putting it in flash. The demo from ST has the MCU reset after it has downloaded to flash and then jumps to the program. Is the reset necessary or can I just jump straight to the location in flash? Also, how do I actually do the jump. I'm using the code from st which looks like this, but it doesn't seem to work:

/* Check Vector Table: Test if user code is programmed starting from address
''APPLICATION_ADDRESS'' */
if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
{
/* Jump to user application */
JumpAddress = (APPLICATION_ADDRESS + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
Jump_To_Application();
}

25 REPLIES 25
teodorstv
Associate II
Posted on May 15, 2014 at 16:50

Hi

0690X0000060MmQQAU.gif

I did all the steps you mentioned. The binary is stored on the external flash and copied by the bootloader to internal flash. I only described the part that I think is problematic..

teodorstv
Associate II
Posted on May 15, 2014 at 16:53

Actually the address is 0x08004000

Posted on May 15, 2014 at 17:06

Ok, but the origin of this app code you're quoting isn't 0x08004000 or 0x08008000, so either you are looking at the wrong code (ie the boot loader, not the app) or Atollic is bollixing up the build. You should look at the .MAP and confirm what the linker thinks it's doing, and then verify that you are looking at the right .HEX/.BIN

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 15, 2014 at 17:09

Please observe that editing your posts will break the time line of the thread, questions/answers might appear out of sequence for the preceding posts.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chen
Associate II
Posted on May 15, 2014 at 17:11

''5 When performing the jump, the verification fails:

if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)''

What do you mean?

Does it not execute the code for a true condition?

Does the verification fail?

or what?

teodorstv
Associate II
Posted on May 15, 2014 at 17:19

Thank you  for your help until now.

I found that the tool uses a different script. I modified the good one and now I can see the correct addresses on the .map files.

Memory Configuration

Name             Origin             Length             Attributes

flash            0x08004000         0x000fc000         xr

sram             0x20000000         0x0001c000         xrw

*default*        0x00000000         0xffffffff

Linker script and memory map

Also, when I write the data in little-endian, the verification is ok.

if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)''

I'll test again.