Integrating ChibiOS to STM32Cube via CMSIS-OS on Nucle F411

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
swiedjaja
Posts: 2
Joined: Mon Sep 28, 2015 4:11 am

Integrating ChibiOS to STM32Cube via CMSIS-OS on Nucle F411

Post by swiedjaja »

Hi Giovanni and ChibiOS users,
I'm trying to integrating ChibiOS in STM32CubeMX on NucleF411RE board. STM32Cube software enable us to integrate RTOS via CMSIS interface, and they included FreeRTOS on that.
I think it will be nice if I can have ChibiOS instead FreeRTOS on my STM32Cube, so I try to use simple SysTick to generate timer event, I configure CH_CFG_ST_TIMEDELTA 0 in chconf.h, and call chibios scheduler from SysTickCallback, but I got chSysHalt with reason "SV#6".
I suppose the error is on my wrong SysTick implementation, and the other is the linker script, cube linker script quite different from chibios script.

This is my SysTick ISR: (cube style ISR callback funtion)
void HAL_SYSTICK_Callback(void)
{
// CH_IRQ_PROLOGUE();
chSysLockFromISR();
chSysTimerHandlerI();
chSysUnlockFromISR();
// CH_IRQ_EPILOGUE();
}

I also attach my debugger screen, I'm using openstm32 ide and I put chibios project code on https://github.com/swiedjaja/Cube-F411RE-ChibiOS

thanks for let me participate on this very interesting rtos software!
Attachments
openstm32-chibios_NucleoF411.PNG
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Integrating ChibiOS to STM32Cube via CMSIS-OS on Nucle F

Post by Giovanni »

Hi,

You need those prologue/epilogue macros or reschedule will not happen.

SV#6 means that you are calling ISR code without those macros.

Code: Select all

 *            - SV#1, misplaced @p chSysDisable().
 *              - Called from an ISR.
 *              - Called from a critical zone.
 *              .
 *            - SV#2, misplaced @p chSysSuspend()
 *              - Called from an ISR.
 *              - Called from a critical zone.
 *              .
 *            - SV#3, misplaced @p chSysEnable().
 *              - Called from an ISR.
 *              - Called from a critical zone.
 *              .
 *            - SV#4, misplaced @p chSysLock().
 *              - Called from an ISR.
 *              - Called from a critical zone.
 *              .
 *            - SV#5, misplaced @p chSysUnlock().
 *              - Called from an ISR.
 *              - Not called from a critical zone.
 *              .
 *            - SV#6, misplaced @p chSysLockFromISR().
 *              - Not called from an ISR.
 *              - Called from a critical zone.
 *              .
 *            - SV#7, misplaced @p chSysUnlockFromISR().
 *              - Not called from an ISR.
 *              - Not called from a critical zone.
 *              .
 *            - SV#8, misplaced @p CH_IRQ_PROLOGUE().
 *              - Not called at ISR begin.
 *              - Called from a critical zone.
 *              .
 *            - SV#9, misplaced @p CH_IRQ_EPILOGUE().
 *              - @p CH_IRQ_PROLOGUE() missing.
 *              - Not called at ISR end.
 *              - Called from a critical zone.
 *              .
 *            - SV#10, misplaced I-class function.
 *              - I-class function not called from within a critical zone.
 *              .
 *            - SV#11, misplaced S-class function.
 *              - S-class function not called from within a critical zone.
 *              - Called from an ISR.
 *            .


In the distribution there are some demos without HAL, you may start from those then add the ST library code. See \demos\various\RT-ARMCM4-GENERIC

I suggest to not use the tickless mode initially, make it work first then go for the complex stuff.

Also, please use the latest code from the subversion repository, a couple of problems have been fixed in the CMSIS RTOS layer that will be released in 3.0.3.

Giovanni
swiedjaja
Posts: 2
Joined: Mon Sep 28, 2015 4:11 am

Re: Integrating ChibiOS to STM32Cube via CMSIS-OS on Nucle F

Post by swiedjaja »

Thanks for your reply Giovanni, I already try using CH_IRQ_PROLOGUE() and CH_IRQ_EPILOGUE(), but the system halt, it's seem the stm32cube startup code not compatible, and If I used chibios gcc startup code, the cube library complaining.
Hope some day I will see this stuff working together in harmony ;)
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Integrating ChibiOS to STM32Cube via CMSIS-OS on Nucle F

Post by Giovanni »

Hi,

ChibiOS requires a dual stack setup and several other requirements (FPU, caches, various initializations). As soon they start providing code usable in real world we would gladly stop doing extra work.

Giovanni
User avatar
Chudik
Posts: 152
Joined: Fri Jan 16, 2015 7:51 am
Has thanked: 7 times
Been thanked: 1 time

Re: Integrating ChibiOS to STM32Cube via CMSIS-OS on Nucle F411

Post by Chudik »

swiedjaja
Did you get any further than your first code on github?
Post Reply