8 years ago.

MBED hangs during bootloader program jump while using rtos

Hi

i am using MBED to implement a bootloader based application on STM32F030CC controller also.

The application works correctly when i do not use RTOS in my main application. When i include RTOS in my application,after program jump the kernel hangs

If i do not perform any program jumps then RTOS works well in the bootloader application also

using GDB i found that program enters WWDG_IRQHandler () just after execution of the below function svcKernelStart () at /mnt/hgfs/repos/mbed/libraries/rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c:414

The application i was writing is a bootloader program where in program at 0x08000000 contains a bootloader which either upgrades the main application program at address 0x0800C800 or jump to that location to start executing the main application

The application address APPLICATION_ADDRESS is configured in my actual application as 0x0800c800.When i do not use RTOS calls in my application,The program runs fine,the application jumps from bootloader to the main application at 0x0800c800 and starts executing the code.

In order to debug whether the issue was due to jump to 0x0800c800 ( which would involve changes in linker script and other files) or RTOS . I set the application address as the 0x08000000 but still observed the same issue. Indicating that issue lies with the RTOS calls and not due to the

jump_application() function is responsible for setting the program counter to the new address and then start executing the code located at address specified at APPLICATION_ADDRESS

set_MSP(*(IO uint32_t*)APPLICATION_ADDRESS); Sets Main Stack Pointer. while the program jumps and starts executing code from the new flash address execute_application(); is called.

However when i configure RTOS thread then ,When program jump is triggered by calling address execute_application(); .

The main program enters the _svcKernelStart () and then enters WWDG_IRQHandler and loops indefinitely when executing the below function call

SVC_0_1(svcKernelStart, osStatus, RET_osStatus)

which is defined as

  1. define SVC_0_1(f,t,rv) \ attribute((always_inline)) \ static inline t f (void) { \ SVC_Arg0(); \ SVC_Call(f); \ return (t) rv; \ } which defines a function __svcKernelStart which calls the SVC_Call function with svcKernelStart as argument.
  1. define SVC_Call(f) \ asm volatile \ ( \ "ldr r7,="#f"\n\t" \ "mov r12,r7\n\t" \ "svc 0" \ : "=r" (r0), "=r" (r1), "=r" (r2), "=r" (r3) \ : "r" (r0), "r" (r1), "r" (r2), "r" (r3) \ : "r7", "r12", "lr", "cc" \ );

Yes The kernelStart is invoked prior to the main and it thus enters the WWDG_IRQHandler and loops indefinitely and does not enter the main program at all.This behavior occurs only after the program jump .

below is a test program to simulate the issue : i jump to the same default program address 0x08000000 in and RTOS thread

https://gist.github.com/pi19404/928e024cd8008e814357738877cfd67e

same thing happens to me but on SVC_1_1, the function calling it is osStatus osDelay (uint32_t millisec)

posted by Lauro Gama 22 Sep 2016

Did u resolve this ? If yes would you like to share some details.

posted by nilesh ladhe 28 Mar 2018

1 Answer

6 years, 8 months ago.

Did you resolve the issue. I am also facing same problem.

Thanks, Satish.