cancel
Showing results for 
Search instead for 
Did you mean: 

Issues jumping to app from custom bootloader

mh.ferris9
Associate II
Posted on February 25, 2016 at 15:20

Hi all,

I've done a couple of bootloaders in my days on the STM32F3 and F1's, but I can't seem to get this one to work for some reason. STM32F411RE (512KB Flash, 128KB RAM) IDE: SW4STM32 Memory map is as follows: Sector 0 (0x08000000-0x08003FFF 16KB) for the bootloader Sector 1 (0x08004000-0x08007FFF 16KB) for non-vol memory Sectors 2-4 (0x08008000-0x0801FFFF 96KB) for my app I do check the CRCs after copying the fw into the correct spaces and it all seems to check out. When I jump to the app its not entering properly, and my LCD (regular 2x16 parallel) doesn't work, but UART comms works. Its as though its half initialised and running regular code but not quite. In my bootloader after copying and checking CRC's, I jump using this code: APP_START is 0x08008000


/* Jump to user application */

 HAL_DeInit();

JumpAddress = *(__IO u32*) (APP_START + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO u32*) APP_START);
Jump_To_Application();

In my main app, the linker moves the fw:

/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08008000, LENGTH = 512K-0x8000
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
}

In system_stm32f4xx.c I also move the Vectors (MAKE_BOOTLOADABLE is defined):

/*!< Uncomment the following line if you need to relocate your vector Table in
Internal SRAM. */
/* #define VECT_TAB_SRAM */
#ifdef MAKE_BOOTLOADABLE
#define VECT_TAB_OFFSET 0x8000 /*!< Vector Table base offset field. 
This value must be a multiple of 0x */
#else
#define VECT_TAB_OFFSET 0x00
#endif

I'm not sure what else I'm meant to be doing? #stm32 #bootloader
1 REPLY 1
mh.ferris9
Associate II
Posted on February 25, 2016 at 15:49

This often happens to me, I struggle for an hour or two on a problem convinced I can't figure it out, so post it on a forum...only to figure out the issue a few minutes later.

I was developing using debug build settings.  But for my app that was loaded, I had built it using release settings (to generate the appropriate hex files, calculate crc's etc), with max optimisation.  As such that messed with some crude timing code I had done to speed up my LCD routine.

So it is jumping into the app just fine, just the untested optimisation release had broken it.