cancel
Showing results for 
Search instead for 
Did you mean: 

Are there any custome bootloader sample codes available for STM32f030CC

PB.4
Associate II

Hello Team,

Are there any sample codes available for suctome bootloader for STM32F0C0 or for the any of the M0 series contoller, the reason for asking this the vector table reloactaion during the bootloader is quite not clear me, even gone through the some of the other posts couldn't able to get the sample codes for M0 STM32 uC. Thanks in advance!!!

4 REPLIES 4

Look for the IAP examples

The CM0+ devices allow for the table remapping via SCB->VTOR

The CM0 need more hardware level shadow/remapping techniques.

The BASE of FLASH, RAM or ROM can be remapped at ZERO to allow different boot options.

The deal with a vector table at 0x08008000 for example you'd copy the words from the vector table into the base of RAM at 0x20000000, and then remap RAM at ZERO.

You'd hide the base of RAM from the linker, ie start at 0x200000C0 (or whatever the vectors need) , use memcpy((void *)0x20000000, (void *)0x08008000, 192); enable the SYSCFG clock, and modify the REMAP register

 /* Enable the SYSCFG peripheral clock*/

 __HAL_RCC_SYSCFG_CLK_ENABLE();

 /* Remap SRAM at 0x00000000 */

 __HAL_SYSCFG_REMAPMEMORY_SRAM();

Repository\STM32Cube_FW_F0_V1.10.0\Projects\STM32091C_EVAL\Applications\IAP

Repository\STM32Cube_FW_F0_V1.10.0\Projects\STM32091C_EVAL\Applications\IAP\IAP_Binary_Template\Src\main.c

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

Hi @Community member​  Thanks for your reply. I have downloaded the firmware package and trying to understand the file

Repository\STM32Cube_FW_F0_V1.10.0\Projects\STM32091C_EVAL\Applications\IAP\IAP_Binary_Template\Src\main.c

but with this reference I couldn't clear with how to write the bootloader, have the below thoughts

1) With this refernce code the Vector table is moved to the SRAM location and the flash start address the bootloader code can be stored

2) In the application code linkerd file the code store loaction in the flash memory to be changed after the bootloader code memory

3) After flashing the bootloader code there could some delay to be introduced in order to wait and ensure there is a new application code required to be flashed.

4) Every power on reset the code should wait for the mimium interval and the start execute the application code.

Please correct me if any thing need to be modified, also if any bootloader sample codes available means please share.

Since I'm new to the bootloader implmenation I suppose need some more clarity, and thanks for youe support in advance!!!

Piranha
Chief II

The linker script/scatter file for the Loader and App will be different. On some ST architectures you also have to fiddle around necessarily with defines and SystemInit() code to establish understandings for each.

The vector table location has some very specific requirements, the linker script can carve out specific locations so other things aren't placed there.

I don't understand the need for a delay. You can check the application image for validity before jumping to it via a checksum, CRC or other signing method. This can be done immediately from the Reset_Handler as some of the first things the MCU does, You can also decide contractually what the Loader and Application are responsible for, ie bringing up clocks, pll, memories, etc, and then not repeat that work/effort.

The IAP example should have code for both components. Some solid understanding of the Cortex-M0 might help significantly, as well a control transfer methods, which aren't unique to CM0 or STM32. The concept of shadowing or remapping ROM/RAM memories in MCU boards goes back many decades.

Making Embedded Systems by Elecia White covers boot loaders.

Contextually Joseph Yiu's book(s) on the Cortex-M0 and others, might also be useful.

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