Skip to content

drivers: misc: ethos_u: support nuvoton numaker m55m1x #88941

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ccli8
Copy link
Contributor

@ccli8 ccli8 commented Apr 23, 2025

This supports Nuvoton's M55M1 Ethos-U NPU. Besides, the tflm_ethosu sample is refined for this target's verification, including:

  1. Fix undefined _fini symbol on invoking exit() for newlib libc
  2. Add missing inclusion of stdint.h for e.g. uint8_t type
  3. Fix unsafe thread stack allocation. Use canonical K_THREAD_STACK_DEFINE or friends instead of raw buffer
  4. Refactor Vela-compiled models which must match target Ethos-U RTL config
  5. Add non-Vela-compiled model for evaluation of no-Ethos-U platform
  6. Add support for numaker_m55m1 board

NOTE: This PR covers #88218.

Comment on lines +303 to +321
/* Address undefined _fini for the exit call
*
* With gcc command-line options -nostartfiles or -nostdlib, the gcc
* built-in object files crti.o/crtn.o which implement _init/_fini
* won't get linked in automatically and will cause undefined reference
* to _fini error when exit is invoked.
*
* This is fixed by providing one dummey _fini to let linker pass.
*/
__weak void _fini(void)
{
}
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator

@wearyzen wearyzen Jun 19, 2025

Choose a reason for hiding this comment

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

@ccli8 maybe I missed something but how is this change related to this PR? did you face this issue while running the new samples?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This sample modules/tflite-micro/tflm_ethosu uses newlib and invokes exit(), but meets compile failure with _fini undefined.

@khoa-nguyen-18
Copy link
Contributor

Hi @ccli8, could you share your output log when running the tflite-micro/tflm_ethosu sample on the M55M1 board?

@ccli8
Copy link
Contributor Author

ccli8 commented May 28, 2025

Log of tflite-micro/tflm_ethosu on numaker_m55m1 board:

*** Booting Zephyr OS build v4.1.0-4815-g794bbb7d8013 ***
sender 0: Sending inference. job=0x20117518, name=keyword_spotting_cnn_small_int8
runner 0: Received inference job. job=0x20117518
runner 0: Sending inference response. job=0x20117518
sender 0: Sending inference. job=0x20117564, name=keyword_spotting_cnn_small_int8
runner 0: Received inference job. job=0x20117564
runner 0: Sending inference response. job=0x20117564
sender 0: Received job response. job=0x20117518, status=0
sender 0: Received job response. job=0x20117564, status=0
sender 1: Sending inference. job=0x20117d18, name=keyword_spotting_cnn_small_int8
runner 0: Received inference job. job=0x20117d18
runner 0: Sending inference response. job=0x20117d18
sender 1: Sending inference. job=0x20117d64, name=keyword_spotting_cnn_small_int8
runner 0: Received inference job. job=0x20117d64
runner 0: Sending inference response. job=0x20117d64
sender 1: Received job response. job=0x20117d18, status=0
sender 1: Received job response. job=0x20117d64, status=0
exit

@khoa-nguyen-18
Copy link
Contributor

Hi @ccli8, I believe the content of PR #90787 might be related to your work. Could you please take a look?

@@ -0,0 +1,13 @@
# Copyright (c) 2025
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, updated copyright


if ARM_ETHOS_U

config ETHOS_U_NUMAKER
Copy link
Collaborator

Choose a reason for hiding this comment

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

the discussion here could influence this change so I would appreciate your feedback there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Besides, this PR will update according to result of #90787.

@wearyzen
Copy link
Collaborator

Hi @ccli8 could you also add yourself as a collaborator here so that you would be added for future reviews of this driver?

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 20, 2025

ould you also add yourself as a collaborator here so that you would be added for future reviews of this driver?

Added as collaborator of hal_ethos_u

ccli8 added 4 commits June 25, 2025 17:10
Add Chun-Chieh Li "ccli8" as collaborator for hal_ethos_u driver

Signed-off-by: Chun-Chieh Li <[email protected]>
With gcc command-line options -nostartfiles or -nostdlib, the gcc
built-in object files crti.o/crtn.o which implement _init/_fini
won't get linked in automatically and will cause undefined reference
to _fini error when exit is invoked.

This is fixed by providing one dummey _fini to let linker pass.

Signed-off-by: Chun-Chieh Li <[email protected]>
It is unsafe to pass raw buffer as thread stack. Instead, use canonical
K_THREAD_STACK_DEFINE or friends to define thread stack.

Signed-off-by: Chun-Chieh Li <[email protected]>
This addes frontend of arm ethos-u core driver for nuvoton numaker m55m1x.
Special notes include:
1. Leaving application overriding dcache flush/invalidate weak functions
   for cacheable NPU buffer
2. Configuring macs_per_cc to 256 in arm ethos-u core driver to match
   m55m1x ethos-u RTL config

Signed-off-by: Chun-Chieh Li <[email protected]>
@ccli8
Copy link
Contributor Author

ccli8 commented Jun 25, 2025

Rebase on #90787 to integrate with ethos_u_common

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 25, 2025

Added as collaborator of hal_ethos_u

CI test failure for not having needed access level

@fabiobaltieri
Copy link
Member

fabiobaltieri commented Jun 25, 2025

CI test failure for not having needed access level

Can you file a nomination for yourself? https://github.com/zephyrproject-rtos/zephyr/issues (New Issue -> Contributor Nomination)

And there's an actual failure too https://github.com/zephyrproject-rtos/zephyr/actions/runs/15872619304/job/44753082706?pr=88941

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 26, 2025

Can you file a nomination for yourself? https://github.com/zephyrproject-rtos/zephyr/issues (New Issue -> Contributor Nomination)

Nominate for myself: #92205

This supports nuvoton numaker_m55m1 board, including:
1. Choosing NPU buffer as cacheable or non-cacheable, dependent on
   CONFIG_NOCACHE_MEMORY. When cachealbe is chosen, data cache flush/
   invalidate weak functions (ethos-u core driver) are also overridden.
2. Add Vela-compiled model which matches this targets's NPU, Ethos-U55
   with 256 macs_per_cc

Besides, re-organize for new board support, including:
1. Refactor Vela-compiled models which must match target Ethos-U RTL config
2. Add non-Vela-compiled model for evaluation of no-Ethos-U platform

Signed-off-by: Chun-Chieh Li <[email protected]>
Copy link

@ccli8
Copy link
Contributor Author

ccli8 commented Jun 26, 2025

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

Successfully merging this pull request may close these issues.

6 participants