Skip to content
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

add ieee802154 and entropy mcux driver and necessary changes #83195

Merged
merged 8 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 58 additions & 12 deletions boards/nxp/frdm_mcxw71/doc/index.rst
andrei-menzopol marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ The ``frdm_mcxw71`` board target in Zephyr currently supports the following feat
+-----------+------------+-------------------------------------+
| LPADC | on-chip | adc |
+-----------+------------+-------------------------------------+
| ELE | on-chip | entropy |
+-----------+------------+-------------------------------------+
| PHY | on-chip | ieee802154 |
+-----------+------------+-------------------------------------+

Fetch Binary Blobs
******************
Expand Down Expand Up @@ -130,8 +134,26 @@ Connect a USB cable from your PC to J10, and use the serial terminal of your cho
- Parity: None
- Stop bits: 1

Flashing
========
Application Building
====================

Openthread applications
-----------------------

.. zephyr-app-commands::
:zephyr-app: samples/net/sockets/echo_server
:board: frdm_mcxw71
:goals: build
:west-args: -- -DEXTRA_CONF_FILE=overlay-ot.conf

.. zephyr-app-commands::
:zephyr-app: samples/net/sockets/echo_client
:board: frdm_mcxw71
:goals: build
:west-args: -- -DEXTRA_CONF_FILE=overlay-ot.conf

Application Flashing
====================

Here is an example for the :zephyr:code-sample:`hello_world` application.

Expand Down Expand Up @@ -166,15 +188,17 @@ should see the following message in the terminal:
*** Booting Zephyr OS build v3.7.0-xxx-xxxx ***
Hello World! frdm_mcxw71/mcxw716c

Bluetooth
=========
NBU Flashing
============

BLE functionality requires to fetch binary blobs, so make sure to follow
the ``Fetch Binary Blobs`` section first.

Two images must be written to the board: one for the host (CM33) and one for the NBU (CM3).
- To flash the application (CM33) refer to the ``Flashing`` section above.
- To flash the NBU, follow the instructions below:

- To flash the application (CM33) refer to the ``Application Flashing`` section above.

- To flash the ``NBU Flashing``, follow the instructions below:

* Install ``blhost`` from NXP's website. This is the tool that will allow you to flash the NBU.
* Enter ISP mode. To boot the MCU in ISP mode, follow these steps:
Expand All @@ -184,17 +208,39 @@ Two images must be written to the board: one for the host (CM33) and one for the
- Reconnect any external power supply, if needed.
* Use the following command to flash NBU file:

.. code-block:: console
.. tabs::

.. group-tab:: BLE NBU - Windows

.. code-block:: console
:caption: Flash BLE only NBU on Windows

blhost.exe -p COMxx -- receive-sb-file mcxw71_nbu_ble.sb3

.. group-tab:: BLE NBU - Linux

.. code-block:: console
:caption: Flash BLE only NBU on Linux

./blhost -p /dev/ttyxx -- receive-sb-file mcxw71_nbu_ble.sb3

.. group-tab:: DYN NBU - Windows

.. code-block:: console
:caption: Flash Dynamic NBU (BLE + 15.4) on Windows

blhost.exe -p COMxx -- receive-sb-file mcxw71_nbu_ble_15_4_dyn.sb3

.. group-tab:: DYN NBU - Linux

# On Windows
blhost.exe -p COMxx -- receive-sb-file mcxw71_nbu_ble.sb3
.. code-block:: console
:caption: Flash Dynamic NBU (BLE + 15.4) on Linux

# On Linux
./blhost -p /dev/ttyxx -- receive-sb-file mcxw71_nbu_ble.sb3
./blhost -p /dev/ttyxx -- receive-sb-file mcxw71_nbu_ble_15_4_dyn.sb3

Please consider changing ``COMxx`` on Windows or ``ttyxx`` on Linux to the serial port used by your board.

The NBU file can be found in : ``<zephyr workspace>/modules/hal/nxp/zephyr/blobs/mcxw71/mcxw71_nbu_ble.sb3``
The NBU files can be found in : ``<zephyr workspace>/modules/hal/nxp/zephyr/blobs/mcxw71/`` folder.

For more details:

Expand Down
1 change: 1 addition & 0 deletions drivers/entropy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ zephyr_library_sources_ifdef(CONFIG_ENTROPY_MCUX_RNG entropy_mcux_rng.
zephyr_library_sources_ifdef(CONFIG_ENTROPY_MCUX_RNGA entropy_mcux_rnga.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_MCUX_TRNG entropy_mcux_trng.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_MCUX_CAAM entropy_mcux_caam.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_NXP_ELE_TRNG entropy_nxp_ele.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_NRF5_RNG entropy_nrf5.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_NRF_CRACEN_CTR_DRBG entropy_nrf_cracen.c)
zephyr_library_sources_ifdef(CONFIG_ENTROPY_SAM_RNG entropy_sam.c)
Expand Down
1 change: 1 addition & 0 deletions drivers/entropy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ config ENTROPY_INIT_PRIORITY
source "drivers/entropy/Kconfig.b91"
source "drivers/entropy/Kconfig.cc13xx_cc26xx"
source "drivers/entropy/Kconfig.mcux"
source "drivers/entropy/Kconfig.nxp"
source "drivers/entropy/Kconfig.stm32"
source "drivers/entropy/Kconfig.esp32"
source "drivers/entropy/Kconfig.nrf5"
Expand Down
12 changes: 12 additions & 0 deletions drivers/entropy/Kconfig.nxp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# NXP ELE entropy configuration options

# Copyright 2025 NXP
# SPDX-License-Identifier: Apache-2.0

config ENTROPY_NXP_ELE_TRNG
bool "NXP ELE TRNG driver"
default y
depends on DT_HAS_NXP_ELE_TRNG_ENABLED
select ENTROPY_HAS_DRIVER
help
This option enables the ELE true random number generator (TRNG)
71 changes: 71 additions & 0 deletions drivers/entropy/entropy_nxp_ele.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* entropy_nxp_ele.c - NXP ELE entropy driver */

/*
* Copyright 2025 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/

#define DT_DRV_COMPAT nxp_ele_trng

#include <zephyr/logging/log.h>
#include <zephyr/drivers/entropy.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/sys/util.h>
#include <soc.h>

#include "sss_crypto.h"

struct entropy_ele_data_str {
struct k_sem sem_lock;
};

static struct entropy_ele_data_str entropy_ele_data;

static int entropy_ele_get_entropy(const struct device *dev, uint8_t *buf, uint16_t len)
{
sss_sscp_rng_t ctx;
int result = -EIO;

__ASSERT_NO_MSG(buf != NULL);
__ASSERT_NO_MSG(&entropy_ele_data == dev->data);

k_sem_take(&entropy_ele_data.sem_lock, K_FOREVER);

if (CRYPTO_InitHardware() != kStatus_Success) {
goto exit;
}

if (sss_sscp_rng_context_init(&g_sssSession, &ctx, 0u) != kStatus_SSS_Success) {
goto exit;
}

if (sss_sscp_rng_get_random(&ctx, buf, len) != kStatus_SSS_Success) {
goto exit;
}

if (sss_sscp_rng_free(&ctx) != kStatus_SSS_Success) {
goto exit;
}

result = 0;

exit:
k_sem_give(&entropy_ele_data.sem_lock);
return result;
}

static int entropy_ele_init(const struct device *dev)
{
__ASSERT_NO_MSG(&entropy_ele_data == dev->data);

k_sem_init(&entropy_ele_data.sem_lock, 1, 1);

return 0;
}

static DEVICE_API(entropy, entropy_ele_api_funcs) = {.get_entropy = entropy_ele_get_entropy};

DEVICE_DT_INST_DEFINE(0, entropy_ele_init, NULL, &entropy_ele_data, NULL, PRE_KERNEL_1,
CONFIG_ENTROPY_INIT_PRIORITY, &entropy_ele_api_funcs);
1 change: 1 addition & 0 deletions drivers/ieee802154/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ zephyr_library_sources_ifdef(CONFIG_IEEE802154_CC2520 ieee802154_cc2520.c)
zephyr_library_sources_ifdef(CONFIG_IEEE802154_DW1000 ieee802154_dw1000.c)
zephyr_library_sources_ifdef(CONFIG_IEEE802154_KW41Z ieee802154_kw41z.c)
zephyr_library_sources_ifdef(CONFIG_IEEE802154_MCR20A ieee802154_mcr20a.c)
zephyr_library_sources_ifdef(CONFIG_IEEE802154_MCXW ieee802154_mcxw.c ieee802154_mcxw_utils.c)
zephyr_library_sources_ifdef(CONFIG_IEEE802154_NRF5 ieee802154_nrf5.c)
zephyr_library_sources_ifdef(CONFIG_IEEE802154_RF2XX ieee802154_rf2xx.c)
zephyr_library_sources_ifdef(CONFIG_IEEE802154_RF2XX ieee802154_rf2xx_iface.c)
Expand Down
2 changes: 2 additions & 0 deletions drivers/ieee802154/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ source "drivers/ieee802154/Kconfig.kw41z"

source "drivers/ieee802154/Kconfig.mcr20a"

source "drivers/ieee802154/Kconfig.mcxw"

source "drivers/ieee802154/Kconfig.nrf5"

source "drivers/ieee802154/Kconfig.cc1200"
Expand Down
28 changes: 28 additions & 0 deletions drivers/ieee802154/Kconfig.mcxw
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# NXP MCXW 802.15.4 configuration options

# Copyright 2025 NXP
# SPDX-License-Identifier: Apache-2.0

menuconfig IEEE802154_MCXW
bool "NXP MCXW series IEEE 802.15.4 Driver"
default y
andrei-menzopol marked this conversation as resolved.
Show resolved Hide resolved
depends on DT_HAS_NXP_MCXW_IEEE802154_ENABLED
depends on COUNTER

if IEEE802154_MCXW

config IEEE802154_MCXW_INIT_PRIO
int "Initial priority for the IEEE802154 driver"
default 80

config IEEE802154_MCXW_RX_STACK_SIZE
int "Driver's internal RX thread stack size"
default 800


config IEEE802154_MCXW_CSL_ACCURACY
int "Csl accuracy for delayed operations"
default 100


endif
Loading
Loading