I am stuck at booting keil RTX with a boot-loader jumping. When the RTX application is loading but it goes into hard fault from svc2_3 message get keil rtx. I didn't write explicitly define SVC handler, Since it's defined inside RTX. All the remaining things like vector table remapping and systick clock are configured correctly. The jumping is possible when using a non rtx application. Any help appreciated
Hello Yeyidogan,
for RTX4 we have a description here on how to write custom SVC handlers: http://arm-software.github.io/CMSIS_5/RTOS/html/svcFunctions.html
Hope this helps!
Kind regards,
Christopher
Hello Christopher,
Firstly, thank you very much. I use SVC functions for my application functions except SVC_0. Because SVC function 0 is reserved by RTX Kernel. This is okay for my application functions. Because my application runs with RTOS support.
But bootloader region doesnt have rtos support. Until jumping to application address, bootloader must work without any rtos code. So, because of auto link of Keil library to SVC Handler, hard fault is caused.
By the way, sector 0 is used by bootloader for in application programming. Other sectors are used for application software. Both booloader and application software have different (own) interrupt vector table and interrupts. SVC handler interrupt is different too.
Maybe I could give a directive to Keil that use this SVC Handler interupt function, don't use the other. But I don't know how.
Thanks in advance.
Yilmaz Eyidogan.
Hello Yilmaz,when you jump from a boot-loader to your application, some things need to be taken care of, no matter if the boot-loader and/or the application uses a CMSIS RTOS or not.
We have summarized this in the knowledgebase article: http://www.keil.com/support/docs/3913.htm
I assume that there is any interrupt still eneabled or anything else when you jump to your application. I hope this knowledgebase article helps you.
Regards,
Hans
Hello Hans,
Thanks a lot for this very detailed document.
These document recommends two seperate uVision projects which are bootloader and user application. But I am developing a single project that includes bootloader and user-application together because of some advantages. I placed each source to its ROM region with Scatter File.
If I give same SVC Handler function to both bootloader and application vector tables, software works properly. In this case, bootloader's SVC Handler interrupt will be depend to application. Any update may corrupt error in future. In this case, I decided to write two seperate SVC Handler functions. First one is placed to bootloader region and second one is placed to application region as other interrupt functions. RTX will be linked to only second SVC Handler.
When I debug my software, while running bootloader software, after reset interrupt, program jumps to osKernelStart function then return back to bootloaders SVC Handler function.
If I cannot find a suitable solution for a single uVision project, I will have to write two seperate uVision projects.
Yilmaz Eyidogan
Hello Yilmaz,
usually it is better to have two separate projects which are linked independently. Only this way, you can exchange the application without any dependency on the bootloader. With your design, you must keep the code AND the data of both applications separate. Where do you locate the standard library (printf etc.)? Every version of the application will probably only work with one version of the bootloader.
You wrote:
yeyidogan said:When I debug my software, while running bootloader software, after reset interrupt, program jumps to osKernelStart function then return back to bootloaders SVC Handler function.
Unfortunately, I do not fully understand this. After a reset, all interrupts should be disabled and the VTOR register should point to the interrupt vectors of your bootloader. How can an interrupt then jump into the application?
We can locate all libraries to user application region. Because bootloader have no any library, will work with very basic codes for serial update. There is no any location problem. By the way we have a single project developed with a non-arm microcontroller and works properly.
Secondly, after any reset, program jumps to Reset Handler. Before branching to __main function, it jumps to osKernelStart then return to bootloaders SVC Handler. This interrupt is not disabled. It is working before main function. If it could be disabled, bootloader would not use SVC Handler.
Yilmaz.
Hello,
Problem is solved. Firstly, I changed startup fle. bootloader() function is placed to reset vector of bootloader; and then SystemInit and __main functions are placed to reset vector of user-application. Interrupts must be enabled in SystemInit not in main() function. Because RTX require SVC 0 interrupt before jumping to main() function.
There is another point. RTX adds some initialization codes at __main function. It resets all memory. So interrupt vector table at start of RAM is cleared. I changed start of RAM block to 0x200000C0. so RTX didn't clear vector table at RAM.