We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello !
I am working on bootloader application using RTX on mdk 5.
The bootloader load the user application using Ethernet communication and proceed to the jump after a reset.
When i use an simple blinky example and modify the BCA, the jump WORKS WELL !
BUT If I use an RTX application, the jump don't works.
I used the bootloader's vendor (without RTX) the jump to my RTX application works..
I suspect that RTX application erased some thing at initialization
Some one already seen that before
Board used : FRDM K64F
IDE : mdk 5
I try this piece of code, but I always can't jump..
Here is my code :
__asm void boot_jump( uint32_t address ){ LDR SP, [R0] LDR PC, [R0, #4]}
void execute_user_code(void){ /* Change the Vector Table to the USER_FLASH_START in case the user application uses interrupts */
//__disable_irq(); SysTick->CTRL &= ~0x00000002; SCB->VTOR = (uint32_t)USER_FLASH_START; boot_jump(USER_FLASH_START);
}
/*---------------------------------------------------------------------------- Main Thread 'main': Run Network *---------------------------------------------------------------------------*/int main (void) { if(Flash_ReadFW()==0) { execute_user_code(); } osKernelInitialize (); // initialize RTOS kernel hardware_init(); LED_Initialize (); Buttons_Initialize (); debug_printf("\r\n\r\nBootloader by - GB\r\n"); // ne pas oublier de cocher MicroLIB dans les options du projet !!! osThreadNew(blinky_Thread, NULL, NULL); // Create application main thread osThreadNew(LAN_Thread, NULL, NULL); // Create application main thread osKernelStart (); // start kernel with job2 execution while(1);}
bootloader RTX is placed at 0x0
User RTX APP is placed at 0x00080000 => don't jump
Blinky LED placed at 0x00080000 too => jump
I need some help
ScottH gave you the code you need, you left out the:
__set_CONTROL(0x00000000);
This is needed if you are jumping from a thread in your bootloader. If your in a thread, the process stack will be used. This instructions sets the main stack as the active stack which is needed when you jump to the reset vector of the application as you want to use the main stack in the Reset Handler.
Thank you for your answer
I understand this is needed if i am in a thread. But the processor is reseted before jumping to the application, so i am not in a thread.
In the debug viewer the processor is running from the msp.
What should verify before the jump?
Are you using OS2? If so, I think the main loop is a special thread. I had the same issue. My older bootloader ran fine with the older OS but as soon as I transitioned to OS2 it stopped working. That is why the __set_CONTROL(0x00000000); was key to fixing the issue. I was stuck in the mud until Jim got me out. Try the change.
I use os2
I will try again with __set_CONTROL(0x00000000);
My question is why the jump works with a simple blind LED firmware but not with a rtx firmware,
I will keep you informed
I try __set_CONTROL(0x00000000); but this is the same issue
In attachment, the screen shot of the debug bootloader after jump.
also, i show:
I am lost..
You seem to be in Handler Mode. You need to be in Thread Mode.
MSP, Prividged, Thread Mode.
__set_control(0x00000000); est the privileged mode, i dis but drill in handler mode
Sorry. You are in a Hard Fault so obviously you are in Handler Mode. Maybe see what state you are in just before the jump to the application.
To correct jumping you also will need disable interrupts and clear pending interrupts. Also don`t forget initialize stack/vectors and etc in user app.
for example:
void bootloader_run_application()
{
// Stopping active threads, RTOS etc..
// Disabling CPU interrupts
cpu_irq_disable();
// Clear Pending interrupts
cpu_pending_irq_clear();
// Execute your application
execute_app();
// infinite loop
while(1);
void execute_app(void){ void (*user_code_entry)(void) = (void (*)(void))(USER_APP_ADDR); user_code_entry();}