Skip to content

soc: dts: drivers: add SoCs for amebadplus series#78036

Merged
fabiobaltieri merged 8 commits intozephyrproject-rtos:mainfrom
zjian-zhang:main
Dec 15, 2025
Merged

soc: dts: drivers: add SoCs for amebadplus series#78036
fabiobaltieri merged 8 commits intozephyrproject-rtos:mainfrom
zjian-zhang:main

Conversation

@zjian-zhang
Copy link
Copy Markdown
Contributor

@zjian-zhang zjian-zhang commented Sep 5, 2024

The amebadplus microcontroller (MCU) is an advanced system-on-chip (SoC) featuring an Arm® Cortex®-M55 and Cortex®-M23, large Flash and SRAM memories, and supports dual-band Wi-Fi 4(2.4GHz + 5GHz) and BLE5.0 specifications.

The initial support for the board includes GPIO, PINCTRL and Loguart(serial).

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 5, 2024

Hello @zjian-zhang, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@zephyrbot
Copy link
Copy Markdown

zephyrbot commented Sep 5, 2024

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_realtek 🆕 N/A (Added) zephyrproject-rtos/hal_realtek@c769be0 (main) N/A

DNM label due to: 1 added project

Note: This message is automatically posted and updated by the Manifest GitHub Action.

Copy link
Copy Markdown
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

Please read and follow the contribution guidelines https://docs.zephyrproject.org/latest/contribute/guidelines.html#contribute-guidelines we do not shove everything into a single commit for multiple areas, they must be distinct

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.

Comments should be e.g. # Enable UART

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.

Done!

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.

No to any of this

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.

Done!

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.

no selection on this

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.

Done!

@decsny decsny removed their request for review September 5, 2024 14:54
@jukkar jukkar removed their request for review September 10, 2024 08:29
@zephyrbot zephyrbot requested a review from de-nordic September 11, 2024 13:19
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@teburd teburd left a comment

Choose a reason for hiding this comment

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

Looked it over, many things beyond my area of maintainership so I'm going to reassign, only one comment from me.

@@ -0,0 +1,88 @@
# Copyright (c) 2024 Realtek Semiconductor Corp.
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.

Lots of 2024 copyrights here, not a big deal to me but it is 2025

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.

That's a fair observation! The 2024 reflects when the project was initially created or files were generated. While some projects update yearly and you'll see newly added files dated 2025, others keep the original year. But I appreciate the attention to detail!

Comment on lines +4423 to +4427
maintainers:
- Amb-zephyr
collaborators:
- zjian-zhang
- Derek-RTK
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hey, these have to be users, drop Amb-zephyr just move the two username as maintainers

Copy link
Copy Markdown
Contributor Author

@zjian-zhang zjian-zhang Dec 3, 2025

Choose a reason for hiding this comment

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

I've already removed Amb-zephyr and kept only the two actual usernames as maintainers.

However, the PR is currently failing the PR Metadata Check / Prevent Merging due to the DNM (manifest) label. The same issue is also present in #91933.

Comment on lines +27 to +35
#include "os_wrapper_semaphore.h"
#include "os_wrapper_critical.h"
#include "os_wrapper_memory.h"
#include "os_wrapper_mutex.h"
#include "os_wrapper_queue.h"
#include "os_wrapper_semaphore.h"
#include "os_wrapper_task.h"
#include "os_wrapper_time.h"
#include "os_wrapper_timer.h"
Copy link
Copy Markdown
Member

@fabiobaltieri fabiobaltieri Dec 3, 2025

Choose a reason for hiding this comment

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

hey just realized this is the same as f2f446c, would it be possible to move with one PR at a time, it's all very confusing, and also try to dedup as much as possible

my comments there apply here too I guess

Copy link
Copy Markdown
Contributor Author

@zjian-zhang zjian-zhang Dec 4, 2025

Choose a reason for hiding this comment

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

what's this stuff for? I checked a few functions declared in here, there's no references either in the rest of the patches or the hal, should they be left out for now? if they are for supporting code in the hal then I think they should sit somewhere else, not in soc/

To avoid confusion, I’ve already converted PR #91933 into a draft and incorporated all your feedback. Once this PR is merged, there will be no duplicate code.

The functions in question are intended to support HAL code. Currently, I’ve only retained the parts that are actually needed. As noted earlier in issue #78084:

For reference: Zephyr glue code is NOT allowed in hal repos, otherwise any change in Zephyr can become a multirepo nightmare.
I have move the os wrapper to zephyr/soc/realtek/ameba, am i right? our driver need some service from OS, and we implement the glue code to support multi OS.

If this code doesn’t belong under soc/, do you have a suggestion for a more appropriate location? Alternatively, would it be acceptable to keep it there temporarily and revisit its placement once we implement the actual function definitions?

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.

By the way, Can the DNM (manifest) label be removed now? The PR is currently failing the PR Metadata Check / Prevent Merging due to the DNM (manifest) label.

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.

None of this is acceptable, anywhere. Your HAL is for the hardware, it should not be making threads or anything like that, if an application wants to make a thread, it will call the zephyr thread functions, it will not call some odd HAL-specific function which does something and redirects it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

By the way, Can the DNM (manifest) label be removed now? The PR is currently failing the PR Metadata Check / Prevent Merging due to the DNM (manifest) label.

The workflow adds it with every push because it detects a new module, just ignore it, we'll remove it before merging once it's ready, we can remove it now but then it'd just be added again on the next push.

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.

You're absolutely right that the HAL should focus on hardware abstraction and avoid introducing OS-specific threading or scheduling logic.

These header files aren’t actually used in the current code, so I’ve gone ahead and removed them entirely.

The original intent behind the os_wrapper_* layer was to provide a thin, unified abstraction over basic OS services (like semaphores, mutexes, malloc, etc.) to make our HAL portable across different RTOSes. However, as you pointed out, this doesn’t belong in the HAL if it’s not strictly needed — and certainly not in soc/.

That said, upcoming Wi-Fi HAL changes will require more direct use of OS primitives (e.g., memory allocation, synchronization, etc). When that time comes, we’ll carefully evaluate where such wrappers should live. Based on existing patterns in Zephyr, there seem to be three common approaches:

  • Inside modules/, for example:
    • modules/canopennode/CO_driver.c (e.g., canopen_send_lock/unlock)
    • modules/hal_nordic/nrfx/nrfx_glue.c (nrfx_busy_wait)
    • modules/nrf_wifi/os/shim.c (zep_shim_mem_zalloc)
    • modules/hal_infineon/.../cyabs_rtos_zephyr.c
    • modules/hal_afbr/platform_malloc.c (Argus_Malloc/Free)
    • modules/lvgl/lvgl_zephyr_osal.c (e.g., lv_mutex_lock)
  • Inside soc/ – as seen with STM32’s stm32_timer.c using UTIL_TIMER_* APIs.
  • Using Zephyr’s portability layer, such as subsys/portability/cmsis_rtos_v2/, though adopting this would require significant rework of our existing HAL.

We’ll follow established Zephyr conventions when reintroducing any OS-dependent code—likely placing it under zephyr/modules/ or leveraging Zephyr’s native APIs directly, rather than adding HAL-specific wrappers in soc/.

For now, all unused includes have been cleaned up. Could you please take another look? @fabiobaltieri @nordicjm

source "drivers/gpio/Kconfig.xmc4xxx"
# zephyr-keep-sorted-stop

source "drivers/gpio/Kconfig.ameba"
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.

this goes in the list

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.

Done!

Comment on lines +35 to +36
else()
message(WARNING "Missing Realtek blobs. Run: `west blobs fetch hal_realtek`")
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.

Suggested change
else()
message(WARNING "Missing Realtek blobs. Run: `west blobs fetch hal_realtek`")

Does this build and run fully on a board without any blobs at all?

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.

It can be fully built without any binary blobs, but since we have another CPU involved, running it requires binaries from those blobs.

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.

OK then your SoC and board are not acceptable to be added to zephyr, please check https://docs.zephyrproject.org/latest/contribute/bin_blobs.html#limited-scope for acceptance pass criteria

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.

OK please be very clear about that in future. And this warning needs removing

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.

Done!

zephyr_linker_sources(SECTIONS boot_section.ld)
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")

set(PYTHON_SCRIPT_ARGS
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 cmake UPPER CASE means GLOBAL, and lower case means local, fix, and move this inside of the if()

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.

Done.

Comment on lines +21 to +31
typedef void *rtos_sema_t;
int rtos_sema_create_binary(rtos_sema_t *pp_handle);
int rtos_sema_give(rtos_sema_t p_handle);
int rtos_sema_take(rtos_sema_t p_handle, uint32_t timeout_ms);

/**
* @brief General macro definition
*/
#define RTOS_MAX_DELAY 0xFFFFFFFFUL
#define RTOS_MAX_TIMEOUT 0xFFFFFFFFUL
#define RTOS_TICK_RATE_HZ 1000UL
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.

Suggested change
typedef void *rtos_sema_t;
int rtos_sema_create_binary(rtos_sema_t *pp_handle);
int rtos_sema_give(rtos_sema_t p_handle);
int rtos_sema_take(rtos_sema_t p_handle, uint32_t timeout_ms);
/**
* @brief General macro definition
*/
#define RTOS_MAX_DELAY 0xFFFFFFFFUL
#define RTOS_MAX_TIMEOUT 0xFFFFFFFFUL
#define RTOS_TICK_RATE_HZ 1000UL

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.

Done!

#include <string.h>
#include <stdint.h>

#include "platform_autoconf.h"
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.

actually whole file to go

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.

As mentioned in #78036 (comment), I have currently retained only the following HAL-layer functions that are strictly necessary; otherwise, the build would fail:

typedef void *rtos_sema_t;
#define rtos_sema_create_binary(pp_handle)
#define rtos_sema_give(p_handle)
#define rtos_sema_take(p_handle, timeout_ms) 0
#define RTOS_TICK_RATE_HZ 1000UL

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 would the build fail? There is no reference to these in this PR or the hal PR

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.

I have already removed os_wrapper.h. However, this requires corresponding changes in hal_realtek; see zephyrproject-rtos/hal_realtek#1, Since maintainers for hal_realtek have not yet been added (which will only happen after this PR is approved), I kindly request administrator assistance to help merge that change into the hal_realtek repository.
In the meantime, since the driver code in the current PR does not actually use any functionality from os_wrapper, I have simply commented out its compilation in the CMakeLists.txt file, as mentioned in the earlier comment: #78036 (comment), We will revisit and properly address how to implement this functionality in a future update.

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.

you need to make the changes now and an admin will merge them to the repo, before this PR will be approved

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.

Thanks! The required changes have been submitted in zephyrproject-rtos/hal_realtek#1.
This PR depends on that change being merged into hal_realtek first. Could you please help merge PR #1? Thank you! @fabiobaltieri @nashif

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.

Done. And zephyrproject-rtos/hal_realtek#1 has been merged.

Copy link
Copy Markdown
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

SoC does not work without binary blobs as per #78036 (comment) therefore SoC is not acceptable in zephyr clarified below

@zjian-zhang
Copy link
Copy Markdown
Contributor Author

SoC does not work without binary blobs as per #78036 (comment) therefore SoC is not acceptable in zephyr

Perhaps my previous description wasn't clear enough. As stated in boards/realtek/rtl872xda_evb/doc/index.rst, this SoC contains two distinct CPU cores:

  • Dual cores: Real-M300 and Real-M200

The Real-M300 core runs Zephyr OS and can be fully built and executed without requiring any binary blobs at all. The Real-M200 core, however, is not intended to run Zephyr OS; instead, it is provided as a precompiled binary (bin file). Of course, you can choose not to run the Real-M200 core—but in that case, certain low-power features that depend on it will not be available.

Comment on lines +35 to +36
else()
message(WARNING "Missing Realtek blobs. Run: `west blobs fetch hal_realtek`")
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.

OK please be very clear about that in future. And this warning needs removing

#define __OS_WRAPPER_H__

typedef void *rtos_sema_t;
#define rtos_sema_create_binary(pp_handle)
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.

file needs deleting

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.

Done!

source "drivers/gpio/Kconfig.xmc4xxx"
# zephyr-keep-sorted-stop


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.

Suggested change

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.

Done!

Realtek HAL (Hardware Abstraction Layer) provides
a low level peripheral configuration function.

Signed-off-by: zjian zhang <zjian_zhang@realsil.com.cn>
add initial version of devicetree for amebadplus SOC.
amebadplus devicetree file is main platform dtsi file, which should
be included from board dts (e.g rtl872xda_evb.dts)

Signed-off-by: zjian zhang <zjian_zhang@realsil.com.cn>
Add initial version of Amebadplus Soc integration

Signed-off-by: zjian zhang <zjian_zhang@realsil.com.cn>
add amebadplus pin controller driver

Signed-off-by: zjian zhang <zjian_zhang@realsil.com.cn>
loguart driver for amebadplus

Signed-off-by: zjian zhang <zjian_zhang@realsil.com.cn>
GPIO driver for amebadplus

Signed-off-by: zjian zhang <zjian_zhang@realsil.com.cn>
add initial version of rtl872xda_evb board

Signed-off-by: zjian zhang <zjian_zhang@realsil.com.cn>
This commit adds maintainers for hal_realtek repository

Signed-off-by: zjian zhang <zjian_zhang@realsil.com.cn>
@zjian-zhang
Copy link
Copy Markdown
Contributor Author

It's not just the USB support. You need to split this up into multiple PRs, one for adding the basic support including GPIO and UART - the rest needs to go into separate PRs, as the different areas require reviews from different maintainers.

The earlier feedback on the first commit has been addressed. Thanks!

@zjian-zhang
Copy link
Copy Markdown
Contributor Author

Not looking part first commit if previous comments in that commit have not been addressed

Sorry for the confusion — I’ve already addressed all the feedback from the first commit in the latest changes, but I forgot to reply to the individual comments.

@sonarqubecloud
Copy link
Copy Markdown

@zjian-zhang
Copy link
Copy Markdown
Contributor Author

@nordicjm @stephanosio @jfischer-no Hi! I’ve addressed all your feedback—could you please take another look when you have a moment?

@github-actions
Copy link
Copy Markdown

Hi @zjian-zhang!
Congratulations on getting your very first Zephyr pull request merged 🎉🥳. This is a fantastic achievement, and we're thrilled to have you as part of our community!

To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge.

Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁

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.