Skip to content

drivers: misc: ethos_u: Create the ethos_u_common for every vendor #90787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 25, 2025

Conversation

khoa-nguyen-18
Copy link
Contributor

@khoa-nguyen-18 khoa-nguyen-18 commented May 29, 2025

Some vendors require custom procedures to be executed before and after calling the ethosu_init and ethosu_irq_handler APIs from the Ethos-U core driver.

As a solution, I propose separating ethos_u_common for each vendor and ethos_u_arm for specific Arm boards, enabling vendors to self-configure the initialization flow and IRQ handler.

Building sample samples/modules/tflite-micro/tflm_ethosu log:

[307/307] Linking CXX executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       74232 B       512 KB     14.16%
             RAM:       23000 B       512 KB      4.39%
            ITCM:          0 GB       512 KB      0.00%
            SRAM:          0 GB         1 MB      0.00%
            DTCM:          0 GB       512 KB      0.00%
           ISRAM:          0 GB         2 MB      0.00%
 NULL_PTR_DETECT:          0 GB         1 KB      0.00%
            DDR4:      127270 B       256 MB      0.05%
        IDT_LIST:          0 GB        32 KB      0.00%
Generating files from /home/khoanguyen18/zephyrproject/zephyr/build/zephyr/zephyr.elf for board: mps3

Copy link
Collaborator

@ccli8 ccli8 left a comment

Choose a reason for hiding this comment

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

It can support other vendor's ethos-u npu.

@wearyzen
Copy link
Collaborator

wearyzen commented Jun 5, 2025

Some vendors require custom procedures to be executed before and after calling the ethosu_init and ethosu_irq_handler APIs from the Ethos-U core driver.

Could you provide more details on what the custom procedures are? maybe this is something that can be done in one of the CONFIG_SOC_*_HOOK

@khoa-nguyen-18
Copy link
Contributor Author

khoa-nguyen-18 commented Jun 17, 2025

Some vendors require custom procedures to be executed before and after calling the ethosu_init and ethosu_irq_handler APIs from the Ethos-U core driver.

Could you provide more details on what the custom procedures are? maybe this is something that can be done in one of the CONFIG_SOC_*_HOOK

From our Renesas MCU side, we need to clear the HW frag when the interrupt is raised, and it definitely can't be cleared in the CONFIG_SOC_*_HOOK. For other vendors, I see they have vendor-specific procedures, such as configuring the clock, enabling power to the module, or resetting the module.

Therefore, I propose this PR to clarify the init function and allow modifying the handler to clear the NPU flag for each vendor, rather than simply covering it within soc_hook_init.

Copy link
Collaborator

@ccli8 ccli8 left a comment

Choose a reason for hiding this comment

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

It helps for other vendors to add their ethos-u driver.

Copy link
Collaborator

@wearyzen wearyzen left a comment

Choose a reason for hiding this comment

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

ok I understand the reason for the change. Added a few comments to see if we can have a cleaner solution for this.

@dkalowsk
Copy link
Collaborator

@khoa-nguyen-18 just a reminder that the feature freeze for 4.2 is rapidly approaching (end of the week) and if this is needed in for 4.2 you'll need to get the reviews from the maintainers.

@khoa-nguyen-18 khoa-nguyen-18 force-pushed the support_ethos_u_common branch from 2b277d2 to a5be8fb Compare June 24, 2025 02:34
@khoa-nguyen-18 khoa-nguyen-18 requested a review from wearyzen June 24, 2025 02:41
@ccli8
Copy link
Collaborator

ccli8 commented Jun 24, 2025

Try to rebase #88941 on this reorg, and that's fine.

- Update to use ETHOS_U config instead of ARM_ETHOS_U
- Update prefix ETHOS_U_ for all configs that use ARM_ETHOS_U_

Signed-off-by: Khoa Nguyen <[email protected]>
@khoa-nguyen-18 khoa-nguyen-18 force-pushed the support_ethos_u_common branch from a5be8fb to b4f316d Compare June 24, 2025 15:54
@khoa-nguyen-18 khoa-nguyen-18 requested a review from wearyzen June 24, 2025 15:57
Seperate the ``ethos_u_common`` for every vendor and
``ethos_u_arm`` for sepcific Arm's boards. Enable vendors
to self-configure the init flow and IRQ handler.

Signed-off-by: Khoa Nguyen <[email protected]>
Update Ethos-U driver config for sample app `tflm_ethosu`

Signed-off-by: Khoa Nguyen <[email protected]>
@khoa-nguyen-18 khoa-nguyen-18 force-pushed the support_ethos_u_common branch from b4f316d to f10211d Compare June 25, 2025 04:48
Copy link

@kartben kartben merged commit 6d91064 into zephyrproject-rtos:main Jun 25, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Neural Networks area: Samples Samples platform: ARM Arm Limited Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants