cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in programming MCU with two applications (boot + app)

RCesc.1
Associate II

Good morning,

I need to flash on a STM32F303ret6 uC a bootloader and a main Application. Application code works if I flash only this program into the uC, but when I flash both, I always have debug problems and many times the Application doesn't work.

I want to know if CubeIDE messages are "normal" or if I really have a problem.

Bootloader has this declaration about memory. Start address is standard, while length is reduced to 32Kb (bootloader is 11Kb).

0693W00000WKDfKQAX.jpg 

Application

Application's start address is 0x8008000. Application length is 64Kb, so I put a flash length of 80Kb.

0693W00000WKDgNQAX.jpgInto the Application code, Vector table is modified to start at the same address 0x8008000.

0693W00000WKDgXQAX.jpg 

Then I flash the bootloader code first, and than the Application. While I flash the Application code, I obtained always the following message. I can't understand why.

0693W00000WKDgIQAX.jpgIs it normal?

Thanks.

8 REPLIES 8
gbm
Lead III

Remove the VECTBASE setting from your application (also check/remove it from SystemInit of your app). Make the bootloader set vectbase right before starting the application. Remember to set the stack pointer for the application in the bootloader. In the bootloader, disable all the interrupts before starting the app. Finally, show the corrected code starting your app from the bootloader.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
MM..1
Chief II

How you While I flash the Application code

From your explain seems you start debug .

Normal way to flash app is use programmer utility...

-> Remove the VECTBASE setting from your application (also check/remove it from SystemInit of your app

But sorry, if I remove these information, how can Application know its starting address?

-> Remember to set the stack pointer for the application in the bootloader. In the bootloader, disable all the interrupts before starting the app. Finally, show the corrected code starting your app from the bootloader.

This is already done and it works. I am able to jump from bootloader to application during debug mode.

But always when I flash the Application code I obtain this warning.

I'm using the classic 'play' button of CubeIde to download code into the uC. Final solution will be to update Application code through CAN protocol, but I'm testing the code now.

gbm
Lead III

Then kill all the breakpoints in the debugger. Looks like there remains an old breakpoit set from some previous version of the project, maybe before you updated the linker script. VECTBASE should be set by the bootloader right before starting the App - that's the most convenient way cause you don't need to remember to change it when you move your app to a different address -> no addresses are hardcoded in the app source, only in a linker script. Of course what you did also may work... sometimes ;)

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

FYI if yuo set vect in bootloder and jump some init code can change it ... sometimes.

Normal way is set it in app define.

> some init code can change it ... sometimes

@MM..1​ Sure. So... if one wants specific (non-default) behavior of the app, the latter can be called via a custom entry point instead of the reset vector :)

Standart system code @Pavel A.​ 

/* Configure the Vector Table location add offset address ------------------*/

#ifdef

VECT_TAB_SRAM

SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */

#else

SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */

#endif