cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader Jump to Application Fails on STM32F769I-DISCO

Dimitrios Bako
Associate II
Posted on July 24, 2017 at 11:04

Hello,

I am working on a project based on the STM32F769i-Discovery board.

What I am trying to accomplish is start a bootloader application and then jump from it to an offset of the flash memory where my main application is located.

The bootloader application does the following:

  1. Reads from the SD card the main application which is stored as a binary.
  2. Stores the main application binary at the 0x8020000 offset of the flash memory.
  3. Finally makes the jump to the 0x8020000 offset to run the main application.

According to ST code examples and forums in order for the bootloader to jump to the main application I used the following code:

if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)

{

/* Jump to user application */

JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);

Jump_To_Application = (pFunction) JumpAddress;

/* Initialize user application's Stack Pointer */

__set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);

Jump_To_Application();

}

where USER_FLASH_FIRST_PAGE_ADDRESS is the 0x8020000 offset of the flash memory.

The main application just makes two user leds blink.

According, again, to what is suggested by forums I made the following changes to the main application:

  • In the system_stm32f7xx.c I set the VECT_TAB_OFFSET with 0x20000 offset value.
  • I set the linker script as follows:

MEMORY

{

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K

FLASH (rx) : ORIGIN = 0x8020000, LENGTH = 2048K - 128K

}

Considering that everything is set correctly I run the bootloader application which executes normally and when it makes the jump nothing happens.

Something that is worth noting is that when I use the ST-Link Utility to store the main application binary at the 0x8020000 offset of the flash (instead of reading from the SD card) then when the bootloader makes the jump the main application seems to start (the red led lights up) and then hangs.

What could I be missing?

Is there any STM32F769-specific constraint that I should take into consideration?

#stm32f769i-disco #firmware #bootloader #iap
3 REPLIES 3
Posted on July 24, 2017 at 14:22

Consider using a debugger to understand what is happening and where the code execution goes.

Stop in the debugger, where is it?

Have a Hard Fault Handler that does something useful.

Make sure you don't have random interrupts enabled, and firing. SysTick? HAL_Delay()

Instrument infinite spin loops.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
JongOk Baek
Associate III
Posted on April 24, 2018 at 17:50

Did you solve your problem?

I used to added below code.

But, I don't know cause.

__asm('CPSID I');

// this code is same '__disable_irq'.

I added this code before jump command.

refer to below site.

https://www.freertos.org/FreeRTOS_Support_Forum_Archive/September_2013/freertos_Hardfault_when_jumping_to_app_from_bootloader_8665585.html

 

https://www.iar.com/support/tech-notes/general/creating-a-bootloader-for-cortex-m/

 
Posted on April 24, 2018 at 18:02

And what do you expect will re-enable them?

Turn off the interrupts at the source (peripherals), not blanket disable them on the processor, that's just taking no responsibility for the mess you leave the system in.

The System Loader expects to enter at near reset conditions, unwind your initialization until you get there, or jump to the loader at reset before you muddle it up.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..