cancel
Showing results for 
Search instead for 
Did you mean: 

STM32C031 does not jump correctly from bootloader to application

shank
Associate II

I am using an STM32C031 and am trying to write the bootloader program and application program as a single .bin file.
However, I have designed the boot loader program to start up when the power is turned on and jump to the application program by specifying the flash memory if the specified signal has not been received for a while, but I cannot get it to jump properly. It seems to jump to the application program from the flash memory location, but the application program does not work properly.
What kind of program should I use to make the boot loader program start working correctly when it jumps to the application program?

Also attached are the documents to which we are referring.

 

The usage of flash memory is as follows.
Boot program: 0x08000000~0x080027FF
Application program: 0x08003800~0x080077FF

The program for the jump part described in the boot loader program is as follows.

void jump_main(){

HAL_TIM_Base_Stop_IT(&htim17);
huart1.Instance->CR1 &= ~0x20;

//Disable all interrupts
NVIC->ICER[0] = 0xFFFFFFFFFF;
NVIC->ICER[1] = 0xFFFFFFFFFF;
NVIC->ICER[2] = 0xFFFFFFFFFFFF;

//Clear pendings
NVIC->ICPR[0] = 0xFFFFFFFFFFFF;
NVIC->ICPR[1] = 0xFFFFFFFFFFFF;
NVIC->ICPR[2] = 0xFFFFFFFFFF;

int *user_app = (int *)(0x08003800+0x04);
__set_MSP(*(uint32_t *)0x08003800);
*(int*)0xE000ED08 = 0x08003800;
((void(*)())(*user_app))();

while(1){ };
}

 

2 REPLIES 2
Karl Yamashita
Lead III

Probably your application code with the file system_stm32c0xx.c does not have the vector offset updated to your application start address. 

If smoke escapes your device, put the smoke back in. It'll still work as a conversation piece. If you find my answers useful, click the Accept as Solution button so that way others can see the solution.

Shouldn't it be loading the CONTENT of the vector .

The vector table does not contain executable code.

Step the transition in the debug. 

Instrument and print content to understand what the MCU sees

Have a working HardFault_Handler so you can see if it ends up there.

I would setup SP and SCB->VTOR on the application side

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