-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
OpenThread HDLC RCP communication support #75986
base: main
Are you sure you want to change the base?
OpenThread HDLC RCP communication support #75986
Conversation
Hello @xavraz, and thank you very much for your first pull request to the Zephyr project! |
@xavraz thanks for your contribution. Also, can you explain what is the purpose of this PR? The RCP architecture is supported in zephyr. |
@canisLupus1313, thank you for your comment. OT-RCP ArchitectureThis PR corresponds to an ot-rcp host support. The existing support in Zephyr is for an ot-rcp device, as follows : Zephyr codeConcerning your question "included some of the Openthread files in the Zephyr code."
C++ code in ZephyrThere are already few files in zephyr directory as follows for example
• zephyr\modules\thrift\src\thrift\server\TServerFramework.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THe commit message titles need to follow https://docs.zephyrproject.org/latest/contribute/guidelines.html#commit-message-guidelines
drivers/hdlc_rcp_if/Kconfig.nxp
Outdated
# Openthead HDLC RCP communication Interface configuration options | ||
# Copyright 2024 NXP | ||
# All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BSD license should be changed to Apache-2.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change the licences following all your comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you can only change the license if you are the author. If you took the code from somewhere else, then you need to use the original license.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
canisLupus1313 commented 2 days ago
@xavraz thanks for your contribution.
It seems that You have included some of the Openthread files in the Zephyr code. I would say would be better to include form openthread module.
Concerning the OpenThread files included in the Zephyr code, this has been done to ensure the compatibility if the OpenThread library version is modified. This permits to go back to an older OpenThread version. Otherwise, if the source code is set in modules\lib\openthread\src\xxx, then, it is not possible to go back to an older OpenThread version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
modules/openthread/CMakeLists.txt
Outdated
${ZEPHYR_BASE}/arch/arm/include | ||
${ZEPHYR_BASE}/../modules/lib/openthread/src | ||
${ZEPHYR_BASE}/../modules/lib/openthread/src/core | ||
${ZEPHYR_BASE}/../modules/lib/openthread/third_party/mbedtls/repo/include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zephyr is using it's own mbed TLS: https://github.com/zephyrproject-rtos/mbedtls not exactly same as the on in OT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
#define OT_PLAT_DBG_LEVEL_NONE 0 | ||
#define OT_PLAT_DBG_LEVEL_ERR 1 | ||
#define OT_PLAT_DBG_LEVEL_WARNING 2 | ||
#define OT_PLAT_DBG_LEVEL_INFO 3 | ||
#define OT_PLAT_DBG_LEVEL_DEBUG 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you defining those?
It should be possible to reuse logging from https://docs.zephyrproject.org/latest/services/logging/index.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
@xavraz Thanks for clarification. |
678cee7
to
a492241
Compare
@JA-NXP Settings subsys will fetch the storage partition info from device tree, and it seems that
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to use middleware that again translates to UART/SPI? There is already UART and SPI abstraction in zephyr.
I once opened a PoC PR to support over a generic SPI interface: #47256
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since for our RW612 board we don't use SPI/UART for RCP however we use a custom interface for inter cpu communication. So we are thinking to create a generic driver interface for HDLC in order to map any interface type.
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
7f6b72f
to
bd0e312
Compare
f5e1f04
to
20acadd
Compare
#79882 updated the TSC ticket with TSC notes. There is a specific question on why we need to pull the particular files in. |
hdlc_api = (struct hdlc_api *)radio_dev->api; | ||
if (!hdlc_api) { | ||
otLogDebgPlat("Radio device initialization failed"); | ||
assert(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you mixing zephyr's __ASSERT
macros with these assert
calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree & resolved
return ret; | ||
} | ||
|
||
static struct hdlc_api hdlc_api = {.iface_api.init = hdlc_iface_init, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use a name that is the same as the struct type, also this should be const
.
I wonder why compliance doesn't complain here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree & resolved
(void)buffer; | ||
(void)len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use some macro here, OT_UNUSED_VARIABLE
or maybe even prefer ARG_UNUSED
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree & resolved
20acadd
to
4d090ab
Compare
status = PLATFORM_InitHdlcInterface(hdlc_rx_callback, param); | ||
if (status < 0) { | ||
LOG_ERR("HDLC RX callback registration failed"); | ||
ret = EIO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error return values are typically negative.
Also I don't think the do {} while (false);
makes sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree & resolved
28d957b
to
c22284e
Compare
return ret; | ||
} | ||
|
||
static struct hdlc_api nxp_hdlc_api = {.iface_api.init = hdlc_iface_init, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static struct hdlc_api nxp_hdlc_api = {.iface_api.init = hdlc_iface_init, | |
static const struct hdlc_api nxp_hdlc_api = {.iface_api.init = hdlc_iface_init, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
static struct hdlc_api nxp_hdlc_api = {.iface_api.init = hdlc_iface_init, | ||
.register_rx_cb = hdlc_register_rx_cb, | ||
.send = hdlc_send, | ||
.deinit = hdlc_deinit}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a trailing comma so it gets formatted with only 1 indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to know. Resolved.
4844f76
to
1afb64b
Compare
Add a HDLC RCP communication with its hdlc_api interface APIs and a NXP driver. Signed-off-by: Jamel Arbi <[email protected]>
Add a spinel support to an RCP design, the core of OpenThread lives on the host processor connected to an RCP radio controller over a HDLC interface. Signed-off-by: Jamel Arbi <[email protected]>
Adapt the openthread.c file to support the host RCP interface. Signed-off-by: Jamel Arbi <[email protected]>
Add OT RCP config for NXP RW612 platform Signed-off-by: Jamel Arbi <[email protected]>
Add flash partirions for NXP FRDM RW612 board Signed-off-by: Jamel Arbi <[email protected]>
Update hal_nxp to include Openthread RCP changes Signed-off-by: Jamel Arbi <[email protected]>
1afb64b
to
f51d525
Compare
This PR adds support to an RCP design, the core of OpenThread lives on the host processor connected to an RCP radio controller over a HDLC interface.
Tested on a board using NXP's RW612 component.