NIL without HAL / wrong PSP value

Discussions and support about ChibiOS/NIL, the almost nil RTOS.
PeterAwsmtek
Posts: 3
Joined: Sun Feb 03, 2019 11:16 am

NIL without HAL / wrong PSP value

Postby PeterAwsmtek » 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?

User avatar
Giovanni
Site Admin
Posts: 11711
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 492 times
Been thanked: 418 times
Contact:

Re: NIL without HAL / wrong PSP value

Postby Giovanni » Sun Feb 03, 2019 2:37 pm

Hi,

ChibiOS requires the dual stacks mode of the Cortex-M (both PSP and MSP are used), are your startup files initializing this mode? look at ChibiOS startup files for an example.

Giovanni

PeterAwsmtek
Posts: 3
Joined: Sun Feb 03, 2019 11:16 am

Re: NIL without HAL / wrong PSP value

Postby PeterAwsmtek » Mon Feb 04, 2019 10:27 pm

Thanks! I am starting to move from my startup to chibios startup.
In the file crt1.c there are lots of extern variables from linker. ram0, ram1 etc.
That is purpose of this? can these regions be merged, resized of rearranged? How it used in os?

User avatar
Giovanni
Site Admin
Posts: 11711
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 492 times
Been thanked: 418 times
Contact:

Re: NIL without HAL / wrong PSP value

Postby Giovanni » Tue Feb 05, 2019 8:18 am

Hi,

Our linker script defines several generic regions, flash0..7, ram0..7, the startup file initialize those regions. The OS itself does not touch those directly.

If you want to adopt the startup files then you need also to use our .ld files structure (which is quite flexible).

Giovanni

PeterAwsmtek
Posts: 3
Joined: Sun Feb 03, 2019 11:16 am

Re: NIL without HAL / wrong PSP value

Postby PeterAwsmtek » Tue Feb 05, 2019 8:37 pm

I've started adopting it and I found definition of double stack. Now I need some time to understand all relations between ld and startup.
Thank you for support!


Return to “ChibiOS/NIL”

Who is online

Users browsing this forum: No registered users and 0 guests