I am just writing my own bootloader for stm32f103vet6. I wanted to test jump to address of application. I have not yet written my app so I am testing that bootloader jump to its beginning (something like soft reset). I stop the OS like is described in http://www.chibios.org/dokuwiki/doku.ph ... os:stop_os , then I make a jump. Then bootloader start working from the beginning but after a while the stack overflow occurs. Chibiplugin indicates that the stack of main thread is overflow and the size of main stack is 0x000000. What is wrong in my code, that such an error occurs?
Below is a piece of code where I turn off the system and jumps.
Can somebody help me? Thank you very much in advance.
Code: Select all
void jump_to_app(void)
{
chThdTerminate(tp_error_handler); /* Requesting termination. */
chThdWait(tp_error_handler); /* Waiting for the actual termination. */
chThdTerminate(tp_led_display); /* Requesting termination. */
chThdWait(tp_led_display); /* Waiting for the actual termination. */
chThdTerminate(tp_can_parser); /* Requesting termination. */
chThdWait(tp_can_parser); /* Waiting for the actual termination. */
chThdTerminate(tp_can_tx); /* Requesting termination. */
chThdWait(tp_can_tx); /* Waiting for the actual termination. */
chThdTerminate(tp_load_bargraph); /* Requesting termination. */
chThdWait(tp_load_bargraph); /* Waiting for the actual termination. */
chThdTerminate(tp_leds_handler); /* Requesting termination. */
chThdWait(tp_leds_handler);
canStop(&CAND1);
if(!((GPTD2.state == GPT_STOP) || (GPTD2.state = GPT_READY)))
{
gptStop(&GPTD2);
}
sdStop(&SD1);
chSysDisable();
SysTick->CTRL = 0; //disable SysTick
chSysEnable();
jumpToUser(0x08000000);
}jumpToUser function code:
Code: Select all
void jumpToUser(uint32_t address) {
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
/* variable that will be loaded with the start address of the application */
vu32* JumpAddress;
const vu32* ApplicationAddress = (vu32*) address;
/* get jump address from application vector table */
JumpAddress = (vu32*) ApplicationAddress[1];
/* load this address into function pointer */
Jump_To_Application = (pFunction) JumpAddress;
/* Clear pending interrupts just to be on the safe side*/
SCB_ICSR = ICSR_PENDSVCLR;
/* Disable all interrupts */
uint8_t i;
for(i=0; i<8; i++)
NVIC->ICER[i] = NVIC->IABR[i];
/* set stack pointer as in application's vector table */
__set_MSP((u32) (ApplicationAddress[0]));
Jump_To_Application();
}