Skip to content

feat(nxp/pxp): add Zephyr Support - #6298

Merged
kisvegabor merged 3 commits into
lvgl:masterfrom
faxe1008:pxp_zephyr
Jul 24, 2024
Merged

kisvegabor merged 3 commits into
lvgl:masterfrom
faxe1008:pxp_zephyr

Conversation

@faxe1008

Copy link
Copy Markdown
Contributor

Description of the feature or fix

Reopening of #6159 since it got merged and reverted the original PR does not track changes anymore (@nicusorcitu ).

Notes

@nicusorcitu

Copy link
Copy Markdown
Contributor

@cristian-stoica

@FASTSHIFT FASTSHIFT changed the title PXP Zephyr Support feat(nxp/pxp): add Zephyr Support May 30, 2024
Comment thread src/draw/nxp/pxp/lv_pxp_osa.c Resolved
Comment thread src/draw/nxp/pxp/lv_pxp_osa.c Outdated
NVIC_SetPriority(PXP_IRQ_ID, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1);
NVIC_EnableIRQ(PXP_IRQ_ID);
#elif defined(__ZEPHYR__)
IRQ_CONNECT(DT_IRQN(DT_NODELABEL(pxp)), CONFIG_LV_Z_PXP_INTERRUPT_PRIORITY, PXP_ZephyrIRQHandler, NULL, 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now, you included the ZEPHYR header just for this CONFIG_LV_Z_PXP_INTERRUPT_PRIORITY.

We should not mix any longer this with lv_osal support.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The includes are needed for the entire interrupt logic (retrieving nodes from DT, hooking up the IRQ).

Comment thread src/draw/nxp/pxp/lv_pxp_osa.c Resolved
@cristian-stoica

cristian-stoica commented Jun 10, 2024 •

Copy link
Copy Markdown
Contributor

-#if defined(SDK_OS_FREE_RTOS)
-    #include "FreeRTOS.h"
-    #include "semphr.h"
+
+#if defined(__ZEPHYR__)
+    #include <zephyr/kernel.h>
+    #include <zephyr/irq.h>
#endif

I have a problem with the code above. It is not exactly OSAL as it claims and it also breaks our build. There has to be a better way

@faxe1008

Copy link
Copy Markdown
Contributor Author

-#if defined(SDK_OS_FREE_RTOS)
-    #include "FreeRTOS.h"
-    #include "semphr.h"
+
+#if defined(__ZEPHYR__)
+    #include <zephyr/kernel.h>
+    #include <zephyr/irq.h>
#endif

I have a problem with the code above. It is not exactly OSAL as it claims and it also breaks our build. There has to be a better way

Yeah, these includes are needed for the interrupts. Personally I think that an OSAL is maybe not the right place for an abstraction for this, the OSAL should be kept as thin as possible. Maybe it would be an option somehow provide the user a way to give LVGL a setup and teardown method for any of the drawing engines so that this can be handled by each OS?

Comment thread src/draw/nxp/pxp/lv_pxp_osa.c Resolved
Add semaphore and connect IRQ.
Originally proposed by @0xFarahFl.
@faxe1008
faxe1008 force-pushed the pxp_zephyr branch 2 times, most recently from e339205 to cb4c167 Compare June 17, 2024 14:15
Comment thread src/osal/lv_freertos.c Resolved
Comment thread src/osal/lv_freertos.c Resolved
@kisvegabor

kisvegabor commented Jun 21, 2024 •

Copy link
Copy Markdown
Member

We got a lot request about updating Zephyr to LVGL v9 so I wonder if we can help to make it happen soon. @becseya is interested in Zephyr, so he can help with LVGL related issues. We also have several NXP boards so we can help with PXP as well.

@faxe1008
faxe1008 force-pushed the pxp_zephyr branch 2 times, most recently from 0f12024 to 083a95b Compare June 21, 2024 06:48
@kisvegabor

Copy link
Copy Markdown
Member

155 | lv_result_t lv_thread_sync_signal_isr(lv_thread_sync_t * sync)

Please add LV_UNUSED(sync);

@faxe1008

Copy link
Copy Markdown
Contributor Author

The function var had to be renamed to pxCond :^)

@kisvegabor

Copy link
Copy Markdown
Member

The function var had to be renamed to pxCond

Which one? 🙂

@nicusorcitu

Copy link
Copy Markdown
Contributor

image

As a general rule, inside the FreeRTOS files I have used FreeRTOS style while naming variables, functions...
Thanks for keeping it on the same manner.

@cristian-stoica

Copy link
Copy Markdown
Contributor

The last version of these patches fix the build regression I was looking at (PXP = 1 , OS_NONE on MCUXpresso SDK projects that always define SDK_OS_FREE_RTOS). There are other improvements that could be made but they can be addressed later.
I'm OK with this for now modulo other issues discussed in different threads.

@kisvegabor

Copy link
Copy Markdown
Member

Please add lv_thread_sync_signal_isr to lv_os_none.c too.

@faxe1008
faxe1008 force-pushed the pxp_zephyr branch 2 times, most recently from 3ac2d39 to 7ac33bc Compare June 28, 2024 14:51
kisvegabor
kisvegabor previously approved these changes Jun 29, 2024
liamHowatt
liamHowatt previously approved these changes Jun 30, 2024

@liamHowatt liamHowatt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Comment thread src/draw/nxp/pxp/lv_pxp_osa.c Outdated
**********************/

void PXP_IRQHandler(void)
#if defined(__ZEPHYR__)

@nicusorcitu nicusorcitu Jul 1, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not remove the PXP_IRQHandler(). @faxe1008

@faxe1008 faxe1008 Jul 1, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within LVGL this is not used outside of the osa file - is this something that needs to be callable from the outside?

@nicusorcitu nicusorcitu Jul 1, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PXP_IRQHandler() is what the name suggest - the handler of the PXP IRQ.

It is similar to what you already added PXP_ZephyrIRQHandler except that in case of our platform (w/ or w/o FreeRTOS) the PXP handler is mapped in the vector table outside of the lvgl code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so that function is called from outside? I wasn't clear on that.

Even though it wasn't perfect, I approved yesterday because it was harmless and close enough. But the naming is still confusing because PXP_IRQHandler is actually called from outside and the name is important, because it maps to something in the symbol table as you say, while PXP_ZephyrIRQHandler is not special yet has a name that makes it seem like it maps to something in the symbol table.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we can rename the PXP_ZephyrIRQHandler as this is a static function.
But PXP_IRQHandler need to stay in place with exactly the same name.

Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted this part of the change moved the zephyr handler to the static section.

Comment thread src/draw/nxp/pxp/lv_pxp_osa.c Resolved
Changes the PXP osal to use the thread_sync to signal PXP readyness from
the ISR.
Comment thread src/draw/nxp/pxp/lv_pxp_osa.c Resolved
Comment thread src/draw/nxp/pxp/lv_pxp_osa.c Resolved
@@ -112,24 +114,45 @@ pxp_cfg_t * pxp_get_default_cfg(void)
* STATIC FUNCTIONS
**********************/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you ever need the static _pxp_zephyr_irq_handler? You can use directly PXP_IRQHandler() for zephyr as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lvgl-bot

Copy link
Copy Markdown

We need some feedback on this pull request.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

@lvgl-bot lvgl-bot added the stale label Jul 19, 2024
@kisvegabor

Copy link
Copy Markdown
Member

Hi,

What is missing to finalize this PR and for LVGL v9 Zephyr support in general? I'd like to be sure all are added before releasing v9.2.

@faxe1008

Copy link
Copy Markdown
Contributor Author

@kisvegabor at least from my side there are no more blockers to this PR. I guess some testing from the other RTOSes might be helpful to avoid regressions.

As for the requirements of updating zephyr to v9.2 the only thing left for me is to figure out what to do about STM32 DMA2D support, as we have added it in 8.4 but I am unsure if it can be used in 9.1.

@nicusorcitu

Copy link
Copy Markdown
Contributor

I have already approved, no more issues from my side.

@kisvegabor

Copy link
Copy Markdown
Member

Great! Is the missing DMA2D is blocking to have LVGL v9.2 in Zephyr? We got closer to ST, so now we can add DMA2D support but it might take some time.

@kisvegabor
kisvegabor merged commit 03e8d80 into lvgl:master Jul 24, 2024
@faxe1008

Copy link
Copy Markdown
Contributor Author

Great! Is the missing DMA2D is blocking to have LVGL v9.2 in Zephyr? We got closer to ST, so now we can add DMA2D support but it might take some time.

People using the new version on STM32 boards will experience a performance hit, but imo that should be accetable to some degree. Btw. I started drafting this implementation over here:
faxe1008@6497837
There is still a lot of stuff missing, I used the old implementation as a kind of guide line and some datasheets, but I am by no means an expert on ChromArt.

@kisvegabor

Copy link
Copy Markdown
Member

@liamHowatt is also looking into it now. I'd like to have at least something basic in v9.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants