cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F411 IAP

daniele2399
Associate II
Posted on November 18, 2015 at 11:37

Hello all,

I'm currently working on an STM32F411VEH6 MCU and I'm trying to launch an application located at the flash address 0x08004000 with a bootloader at the flash base address (0x08000000). I've read a bunch of threads on the forum about this topic, but I've not understood well what are the steps to complete this task successfully. So far, I've been able to upload the app binary properly. What should I do next?

As far as I've understood, linker file of the app should be modified accordingly.

I've put in the following the code used to load the app from the bootloader (which should be the one commonly used).

        if (((*(__IO uint32_t*) MCU_FLASH_GetAddress(APPLICATION_SECTOR))

                & 0x2FFE0000) == 0x20000000) {

        /* Jump to user application */

        JumpAddress = *(__IO uint32_t*) (MCU_FLASH_GetAddress(

        APPLICATION_SECTOR) + 4);

        JumpToApplication = (pFunction) JumpAddress;

        /* Initialize user application's Stack Pointer */

        __set_MSP(*(__IO uint32_t*) MCU_FLASH_GetAddress(APPLICATION_SECTOR));

        JumpToApplication();

        }

Finally, in the boot  loader I deal with some interrupts and with the UART DMA. Since in the app I'm making use of interrupts and DMA as well, should I do something more to manage this?

Thanks a lot,

Daniele

5 REPLIES 5
Posted on November 18, 2015 at 11:56

Ok, but if you use a debugger and step through the code and the transition, what's actually happening?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
daniele2399
Associate II
Posted on November 18, 2015 at 18:08

Thank you for the quick reply.

I omitted to say that I commented the conditional expression for *(__IO uint32_t*) MCU_FLASH_GetAddress(APPLICATION_SECTOR) gives  0x20020000 as result and the expression wouldn't result true.

Then, during debug I get JumpAddress corresponding to 0x8005255. Finally, executing the call to JumpToApplication() seems to have some kind of effect. Currently I'm trying to launch a blinking LED app. What happens is that the LED is lit up, but then remains still. Of course I can't debug anymore once JumpToApplication() is executed.

My IDE is Atollic Truestudio PRO.

The only change I've done on the  STM32F411VE_FLASH.ld file is the following:

FLASH (rx)      : ORIGIN = 0x08004000, LENGTH = 496K

which at the beginning was:

FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 512K

Thank you in advance,

Daniele

Posted on November 18, 2015 at 18:43

Of course I can't debug anymore once JumpToApplication() is executed.

I'm not sure that's true, you won't have C source to look at, but you should still be able to navigate through the code that the CPU is running. Use the .MAP file as a guide. It's important to understand how far it's getting and where it's choking up. If you have DMA and IRQs actually running in the Boot Loader, you're going to have to think about how that impacts the App. Consider you're changing drivers in a car doing 84 KPH down the motorway, and you've just woken up the new driver.

I've addressed these issues over, and over in other threads. You're going to need to present the problem better, as I don't want to have to keyhole debug this.

Make sure your code in SystemInit() is setting up the Vector Table address correctly for the new location. SCB->VTOR

What exactly is your LED code doing, is it using interrupts? Are you calling the App from an interrupt in the Boot Loader?

I'm pretty sure the transition code isn't the main problem here, so you'll need to expand your perspective a bit. Use the USART or SWV to provide diagnostic information if that helps.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
daniele2399
Associate II
Posted on November 18, 2015 at 21:42

Sorry if I wasn't clear enough, probably it's my understanding of the point which is missing. I'll be back with some updates soon...

Thank you,

Daniele

daniele2399
Associate II
Posted on November 20, 2015 at 11:55

Thanks for your suggestion, I succeeded in running the app after setting the vector table address as well as the flash base address correctly.

Ciao,

Daniele