This is an automated email from the ASF dual-hosted git repository. m-gorecki pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 36abc6e55e31fb2c4f881c8a9fdb28877fb5bbe4 Author: Michal Gorecki <[email protected]> AuthorDate: Fri Sep 4 14:56:30 2026 +0200 hw/mcu/nordic: Enable crypto_nrf driver support on nrf5340_net This enables hardware AES encryption support and can be used with mbedtls alt functions to reduce flash and ram usage. --- hw/drivers/crypto/crypto_nrf/src/crypto_nrf.c | 1 + hw/mcu/nordic/nrf5340_net/pkg.yml | 3 +++ hw/mcu/nordic/nrf5340_net/src/nrf5340_net_periph.c | 22 ++++++++++++++++++++++ hw/mcu/nordic/nrf5340_net/syscfg.yml | 4 ++++ 4 files changed, 30 insertions(+) diff --git a/hw/drivers/crypto/crypto_nrf/src/crypto_nrf.c b/hw/drivers/crypto/crypto_nrf/src/crypto_nrf.c index d18f1db1f..7a2b0aa32 100644 --- a/hw/drivers/crypto/crypto_nrf/src/crypto_nrf.c +++ b/hw/drivers/crypto/crypto_nrf/src/crypto_nrf.c @@ -20,6 +20,7 @@ #include <string.h> #include "mcu/cmsis_nvic.h" #include <os/mynewt.h> +#include <nrf_ecb.h> #include "crypto/crypto.h" #include "crypto_nrf/crypto_nrf.h" diff --git a/hw/mcu/nordic/nrf5340_net/pkg.yml b/hw/mcu/nordic/nrf5340_net/pkg.yml index 8265ee094..a3c2dcaa8 100644 --- a/hw/mcu/nordic/nrf5340_net/pkg.yml +++ b/hw/mcu/nordic/nrf5340_net/pkg.yml @@ -46,6 +46,9 @@ pkg.deps.SPI_0_MASTER: pkg.deps.I2C_0: - "@apache-mynewt-core/hw/bus/drivers/i2c_nrf5340" +pkg.deps.CRYPTO: + - "@apache-mynewt-core/hw/drivers/crypto/crypto_nrf" + pkg.deps.TRNG: - "@apache-mynewt-core/hw/drivers/trng/trng_nrf52" diff --git a/hw/mcu/nordic/nrf5340_net/src/nrf5340_net_periph.c b/hw/mcu/nordic/nrf5340_net/src/nrf5340_net_periph.c index 15822e3a8..55d7f228d 100644 --- a/hw/mcu/nordic/nrf5340_net/src/nrf5340_net_periph.c +++ b/hw/mcu/nordic/nrf5340_net/src/nrf5340_net_periph.c @@ -44,6 +44,11 @@ #include "trng_nrf52/trng_nrf52.h" #endif +#if MYNEWT_VAL(CRYPTO) +#include "crypto/crypto.h" +#include "crypto_nrf/crypto_nrf.h" +#endif + #if MYNEWT_VAL(UART_0) static struct uart_dev os_bsp_uart0; static const struct nrf5340_net_uart_cfg os_bsp_uart0_cfg = { @@ -85,6 +90,10 @@ static struct bus_i2c_dev i2c0_bus; static struct trng_dev os_bsp_trng; #endif +#if MYNEWT_VAL(CRYPTO) +static struct crypto_dev os_bsp_crypto; +#endif + static void nrf5340_net_periph_create_timers(void) { @@ -177,6 +186,18 @@ nrf5340_net_periph_create_trng(void) #endif } +static void +nrf5340_net_periph_create_crypto(void) +{ +#if MYNEWT_VAL(CRYPTO) + int rc; + + rc = os_dev_create(&os_bsp_crypto.dev, "crypto", OS_DEV_INIT_PRIMARY, + OS_DEV_INIT_PRIO_DEFAULT, nrf_crypto_dev_init, NULL); + assert(rc == 0); +#endif +} + void nrf5340_net_periph_create(void) { @@ -185,4 +206,5 @@ nrf5340_net_periph_create(void) nrf5340_net_periph_create_spi(); nrf5340_net_periph_create_i2c(); nrf5340_net_periph_create_trng(); + nrf5340_net_periph_create_crypto(); } diff --git a/hw/mcu/nordic/nrf5340_net/syscfg.yml b/hw/mcu/nordic/nrf5340_net/syscfg.yml index 11a984ecd..270b078f4 100644 --- a/hw/mcu/nordic/nrf5340_net/syscfg.yml +++ b/hw/mcu/nordic/nrf5340_net/syscfg.yml @@ -92,6 +92,10 @@ syscfg.defs: description: 'Enable nRF5340 TRNG' value: 0 + CRYPTO: + description: 'Enable nRF5340 CRYPTO' + value: 0 + UART_0: description: 'Enable nRF5340 net UART0' value: 1
