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();
}
}
I was rereading your previous post and noticed this:
Do you call flush_wait_cb
manually? It should be called by LVGL automatically. -
- Where do you call it now?
- Usually we use a mutex in the
flush_wait_cb
. Does it work for you? - How does you
flush_cb
look like now and which rendring mode do you use?
Thanks for the anwser. Ive spent some good days to get it working.
Currently everything seems to be working fine with double buffering besides small flickering on certain widgets but that prolly my lack of knowledge about LVGL in a RTOS environment, I will create a separate thread for it.
My issues were caused by a mix of issues with the LVGL LTDC implementation that was adapted by me and the ChibiOS LTDC driver which required a fair bit of work to get working.
I will create a PR with my ChibiOS implementation, its a bit hacky but someone with great coding knowledge will probably be able to improve it.
@kisvegabor In case You didn’t heard from the previously mentioned company.
I’ve created a PR with my implementation: _Ready_ Support for ChibiOS by dynfer · Pull Request #8198 · lvgl/lvgl · GitHub