ChibiOS selection in OS

Would it be possible to add a ready template for ChibiOS, simillar how its done currently with FreeRTOS?

A software engineer from a ChibiOS related company contacted us a few weeks ago saying they have added ChibiOS support for LVGL.

I’ve followed up with him to see if they are interesting in sending a PR.

That would be great. Personally I’ve nearly done it, however for now the main problem is adapting the lvgl LTDC driver.

Oh, nice! What’s the problem with LTDC?

cc @liamHowatt

The main problem is that the driver relies heavily on the STM32 HAL which in ChibiOS is not present. Prior Ive done a project with uGFX and ChibiOS, there the driver was pretty universal hence it could run pretty much standalone.

I’ve successfully implemented ChibiOS, everything seems to work fine besides the using LTDC in double buffer mode which causes the timer_handler thread to get stopped on a semaphore that doesn’t seem to be lifted, however in single buffer mode it seems to work fine.

//Edit
I’ve indentified the code causing this. As soon as flush_wait_cb() from the LTDC drivers gets called which invoked my adaption of the lv_thread_sync_wait function it causes the semaphore to not be lifted. For other functions it does work correctly.

lv_result_t lv_thread_sync_wait(lv_thread_sync_t * pxCond)
{
    lv_result_t lvRes = LV_RESULT_OK;
    prvCheckCondInit(pxCond);
    
    chMtxLock(&pxCond->xSyncMutex);
    while(pxCond->xSyncSignal == FALSE) {
        pxCond->ulWaitingThreads++;
        chMtxUnlock(&pxCond->xSyncMutex);
        chSemWait(&pxCond->xCondWaitSemaphore);
        chMtxLock(&pxCond->xSyncMutex);
    }
    /* Reset the signal after waking up */
    pxCond->xSyncSignal = FALSE;
    chMtxUnlock(&pxCond->xSyncMutex);
    return lvRes;
} 

Great news! Unfortunately I haven’t heard from my ChibiOS contact.

I don’t know ChibiOS but prvCheckCondInit(pxCond); seems to be initializing the condiation every time lv_thread_sync_wait is called. Shouldn’t it be done only once in lv_thread_sync_init?

Hello,

It has a check if its already initialized

static void prvCheckCondInit(lv_thread_sync_t *pxCond)
{
    if (!pxCond->is_initialized)
    {
        _enter_critical();
        prvCondInit(pxCond);
        _exit_critical();
    }
}