NIL without HAL / wrong PSP value
Posted: Sun Feb 03, 2019 11:57 am
Hello!
I have the baremetal project in which I want to add ChibiOS.
For test I created empty project with same MCU, startup, vector table and ldscript.
As well I use LL library provided by manufacturer.
Startup used is CMSIS startup.
Ldscripts and early init used are provided my GNU ARM Embedded project.
MCU is STM32F103
OSless test project has been built and runned successfully.
Then I added ChibiOS/NIL, looking at NIL-ARMCM0-GENERIC demo.
I know that my MCU is CM3, but I think thereis no difference in project itself.
Steps to add RTOS:
1 - Ensure I have the same initializing code for SysTick Timer;
2 - Added ch.h headers and copied chconf.h to project;
3 - Added ChibiOS handling code to SysTick ISR Handler;
4 - Added chSysInit() as last step in program init section (in main());
5 - Implemented 2 tasks, added it ot THD_TABLE and set CH_CFG_NUM_THREADS to 2
6 - Changed variable name for defining heap in ldscript
After that I could build project and run debug session on target.
The issue I have is I have wrong (as I thing) PSP value at start of program. The value is 0x0.
So this value is used to switch context in epilog of systick ISR and causes HardFault exception.
Should I make some changes in ldscript or/and startup code to make ChibiOS working?
I have the baremetal project in which I want to add ChibiOS.
For test I created empty project with same MCU, startup, vector table and ldscript.
As well I use LL library provided by manufacturer.
Startup used is CMSIS startup.
Ldscripts and early init used are provided my GNU ARM Embedded project.
MCU is STM32F103
OSless test project has been built and runned successfully.
Then I added ChibiOS/NIL, looking at NIL-ARMCM0-GENERIC demo.
I know that my MCU is CM3, but I think thereis no difference in project itself.
Steps to add RTOS:
1 - Ensure I have the same initializing code for SysTick Timer;
2 - Added ch.h headers and copied chconf.h to project;
3 - Added ChibiOS handling code to SysTick ISR Handler;
4 - Added chSysInit() as last step in program init section (in main());
5 - Implemented 2 tasks, added it ot THD_TABLE and set CH_CFG_NUM_THREADS to 2
6 - Changed variable name for defining heap in ldscript
After that I could build project and run debug session on target.
The issue I have is I have wrong (as I thing) PSP value at start of program. The value is 0x0.
So this value is used to switch context in epilog of systick ISR and causes HardFault exception.
Should I make some changes in ldscript or/and startup code to make ChibiOS working?