diff --git a/.github/test-spec.yml b/.github/test-spec.yml new file mode 100644 index 000000000000..7f896b3c58f9 --- /dev/null +++ b/.github/test-spec.yml @@ -0,0 +1,312 @@ +# This is the Jenkins ci variant of the .github/labler.yaml + +"CI-run-zephyr-twister": + - any: + - "!.github/**/*" + - "!doc/**/*" + - "!CODEOWNERS" + - "!LICENSE" + - "!**/*.rst" + - "!VERSION" + - "!submanifests/**/*" + - "!MAINTAINERS.yml" + - "!version.h.in" + - "!Jenkinsfile" + - "!**/*.md" + +"CI-iot-zephyr-lwm2m-test": + - "drivers/console/**/*" + - "drivers/flash/**/*" + - "subsys/dfu/boot/**/*" + - "subsys/net/ip/**/*" + - "subsys/net/lib/http/**/*" + - "subsys/net/lib/lwm2m//**/*" + - "subsys/net/**/*" + +"CI-iot-samples-test": + - "boards/nordic/nrf9160dk/**/*" + - "dts/arm/nordic/nrf9160*" + - "include/net/**/*" + - "subsys/net/lib/**/*" + +"CI-iot-libraries-test": + - "boards/nordic/nrf9160dk/**/*" + - "dts/arm/nordic/nrf9160*" + - "include/net/socket_ncs.h" + - "subsys/testsuite/ztest/**/*" + +"CI-lwm2m-test": null +# Not necessary to run tests on changes to this repo. + +"CI-boot-dfu-test": + - "subsys/mgmt/mcumgr/**/*" + - "subsys/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "include/dfu/**/*" + - "samples/subsys/mgmt/mcumgr/smp_svr/**/*" + +"CI-tfm-test": + - "boards/nordic/nrf5340dk/**/*" + - "boards/nordic/nrf9160dk/**/*" + - "drivers/entropy/*" + - "dts/arm/nordic/nrf5340*" + - "dts/arm/nordic/nrf9160*" + - "modules/trusted-firmware-m/**/*" + - "samples/tfm_integration/**/*" + +"CI-ble-test": + - any: + - "drivers/bluetooth/**/*" + - any: + - "dts/arm/nordic/nrf5*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + - any: + - "include/zephyr/bluetooth/**/*" + - "!include/zephyr/bluetooth/mesh/**/*" + - "samples/bluetooth/hci_rpc/**/*" + +"CI-ble-samples-test": + - any: + - "drivers/bluetooth/**/*" + - any: + - "dts/arm/nordic/nrf5*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + - any: + - "include/zephyr/bluetooth/**/*" + - "!include/zephyr/bluetooth/mesh/**/*" + - "samples/bluetooth/**/*" + +"CI-mesh-test": + - "subsys/bluetooth/mesh/**/*" + - "include/zephyr/bluetooth/mesh/**/*" + - "samples/bluetooth/mesh/**/*" + - "samples/bluetooth/mesh_demo/**/*" + - "samples/bluetooth/mesh_provisioner/**/*" + - "tests/bluetooth/mesh/**/*" + - "tests/bluetooth/mesh_shell/**/*" + +"CI-zigbee-test": + - "subsys/mgmt/mcumgr/**/*" + - "subsys/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "include/dfu/**/*" + +"CI-thingy91-test": + - "boards/nordic/nrf9160dk/**/*" + - "arch/x86/core/**/*" + - "arch/x86/include/**/*" + - "drivers/console/**/*" + - "drivers/ethernet/**/*" + - "drivers/flash/**/*" + - "drivers/hwinfo/**/*" + - "drivers/interrupt_controller/**/*" + - "drivers/net/**/*" + - "drivers/serial/**/*" + - "drivers/timer/**/*" + - "include/**/*" + - "kernel/**/*" + - "lib/libc/common/source/stdlib/**/*" + - "lib/libc/newlib/**/*" + - "lib/libc/picolibc/**/*" + - "lib/os/**/*" + - "lib/posix/**/*" + - "misc/**/*" + - "modules/mbedtls/**/*" + - "soc/x86/ia32/**/*" + - "subsys/fs/fcb/**/*" + - "subsys/logging/**/*" + - "subsys/net/**/*" + - "subsys/random/**/*" + - "subsys/settings/include/**/*" + - "subsys/settings/src/**/*" + - "subsys/stats/**/*" + - "subsys/storage/flash_map/**/*" + - "subsys/storage/stream/**/*" + - "subsys/tracing/**/*" + +"CI-desktop-test": + - any: + - "**/*" + - "!samples/bluetooth/**/*" + - "!tests/bluetooth/**/*" + +"CI-crypto-test": + - "boards/nordic/nrf52840dk/**/*" + - "boards/nordic/nrf5340dk/**/*" + - "boards/nordic/nrf9160dk/**/*" + - "drivers/entropy/*" + - "drivers/serial/**/*" + - "dts/arm/nordic/nrf52840*" + - "dts/arm/nordic/nrf5340*" + - "dts/arm/nordic/nrf9160*" + - "include/drivers/serial/**/*" + - "modules/mbedtls/**/*" + +"CI-fem-test": + - any: + - "**/*" + - "!samples/bluetooth/**/*" + - "!tests/bluetooth/**/*" + +"CI-rs-test": + - any: + - "**/*" + - "!samples/bluetooth/**/*" + - "!tests/bluetooth/**/*" + +"CI-thread-test": + - "include/zephyr/net/**/*" + - "modules/mbedtls/**/*" + - "modules/openthread/**/*" + - "samples/net/openthread/**/*" + - "soc/arm/nordic_nrf/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-nfc-test": + - any: + - "**/*" + - "!samples/bluetooth/**/*" + - "!tests/bluetooth/**/*" + +"CI-matter-test": + - "include/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "soc/arm/nordic_nrf/**/*" + - "subsys/dfu/**/*" + - "subsys/settings/**/*" + - "subsys/net/**/*" + - "subsys/mgmt/mcumgr/**/*" + - "drivers/net/**/*" + - "samples/bluetooth/hci_rpc/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + +"CI-find-my-test": + - any: + - "**/*" + - "!samples/bluetooth/**/*" + - "!tests/bluetooth/**/*" + +"CI-gazell-test": + - any: + - "**/*" + - "!samples/bluetooth/**/*" + - "!tests/bluetooth/**/*" + +"CI-rpc-test": + - any: + - "**/*" + - "!samples/bluetooth/**/*" + - "!tests/bluetooth/**/*" + +"CI-modemshell-test": + - "include/net/**/*" + - "include/posix/**/*" + - "include/shell/**/*" + - "drivers/net/**/*" + - "drivers/serial/**/*" + - "drivers/wifi/**/*" + - "subsys/shell/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-positioning-test": + - "include/net/**/*" + - "include/posix/**/*" + - "drivers/net/**/*" + - "drivers/wifi/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-cloud-test": + - "include/zephyr/dfu/**/*" + - "include/zephyr/net/**/*" + - "include/zephyr/posix/**/*" + - "include/zephyr/settings/**/*" + - "drivers/led/**/*" + - "drivers/net/**/*" + - "drivers/sensor/**/*" + - "drivers/serial/**/*" + - "drivers/wifi/**/*" + - "lib/posix/**/*" + - "soc/arm/nordic_nrf/**/*" + - "subsys/dfu/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-wifi": + - "subsys/net/l2/wifi/**/*" + - "subsys/net/l2/ethernet/**/*" + +"CI-sidewalk-test": + - "include/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "soc/arm/nordic_nrf/**/*" + - "subsys/dfu/**/*" + - "subsys/settings/**/*" + - "subsys/mgmt/mcumgr/**/*" + - "samples/bluetooth/hci_rpc/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + +"CI-audio-test": + - "boards/nordic/nrf5340_audio_dk/**/*" + - "drivers/flash/**/*" + - "drivers/spi/**/*" + - "drivers/gpio/**/*" + - "drivers/i2c/**/*" + - "drivers/watchdog/**/*" + - "include/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "samples/bluetooth/hci_rpc/**/*" + - "soc/arm/nordic_nrf/**/*" + - "subsys/bluetooth/audio/**/*" + - "subsys/bluetooth/host/**/*" + - "subsys/dfu/**/*" + - "subsys/fs/**/*" + - "subsys/mgmt/mcumgr/**/*" + - "subsys/sd/**/*" + - "subsys/storage/**/*" + - "subsys/task_wdt/**/*" + - "subsys/usb/**/*" + - "subsys/zbus/**/*" + +"CI-pmic-samples-test": + - "samples/shields/npm1300_ek/**/*" + - "boards/shields/npm1300_ek/**/*" + - "**/**npm1300**/**" + - "drivers/regulator/regulator_common.c" + - "drivers/regulator/regulator_shell.c" + - "drivers/gpio/gpio_shell.c" + - "drivers/sensor/sensor_shell.c" + +"CI-test-low-level": + - "dts/**/*" + - "boards/nordic/nrf54*/**/*" + - "include/zephyr/**/*" + - "tests/arch/**/*" + - "arch/**/*" + - "tests/kernel/**/*" + - "kernel/**/*" + - "tests/drivers/**/*" + - "drivers/**/*" + - "samples/subsys/settings/**/*" + - "subsys/settings/**/*" + - "samples/subsys/logging/**/*" + - "subsys/logging/**/*" + - "samples/sensor/**/*" + - "samples/hello_world/**/*" + - "samples/synchronization/**/*" + - "samples/drivers/watchdog/**/*" + - "modules/hal_nordic/**/*" diff --git a/.github/workflows/commit-tags.yml b/.github/workflows/commit-tags.yml new file mode 100644 index 000000000000..9e0323f94987 --- /dev/null +++ b/.github/workflows/commit-tags.yml @@ -0,0 +1,31 @@ +name: Commit tags + +on: pull_request + +jobs: + commit_tags: + runs-on: ubuntu-22.04 + name: Run commit tags checks on patch series (PR) + steps: + - name: Update PATH for west + run: | + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Checkout the code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Install python dependencies + run: | + pip3 install setuptools + pip3 install wheel + pip3 install gitlint + + - name: Run the commit tags + uses: nrfconnect/action-commit-tags@main + with: + target: '.' + baserev: origin/${{ github.base_ref }} + revrange: 'none' diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml index 5e6e2cff9a6f..88c98e84710f 100644 --- a/.github/workflows/compliance.yml +++ b/.github/workflows/compliance.yml @@ -38,8 +38,8 @@ jobs: git config --global user.name "Your Name" git remote -v # Ensure there's no merge commits in the PR - [[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ - (echo "::error ::Merge commits not allowed, rebase instead";false) + #[[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ + #(echo "::error ::Merge commits not allowed, rebase instead";false) git rebase origin/${BASE_REF} # debug git log --pretty=oneline | head -n 10 @@ -59,8 +59,8 @@ jobs: git log --pretty=oneline | head -n 10 # Increase rename limit to allow for large PRs git config diff.renameLimit 10000 - ./scripts/ci/check_compliance.py --annotate -e KconfigBasic \ - -c origin/${BASE_REF}.. + ./scripts/ci/check_compliance.py --annotate -e KconfigBasic -e Kconfig \ + -e KconfigBasicNoModules -e ModulesMaintainers -c origin/${BASE_REF}.. - name: upload-results uses: actions/upload-artifact@v4 diff --git a/CODEOWNERS b/CODEOWNERS index 60ce1a2533a6..84faf677d918 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -18,6 +18,7 @@ # component or code. This file is going to be deprecated and currently only had # entries that are not covered by the MAINTAINERS file. +/.github/test-spec.yml @nrfconnect/ncs-test-leads /soc/arm/aspeed/ @aspeeddylan /soc/atmel/ @nandojve /soc/arm/bcm*/ @sbranden diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000000..3b9cf0022399 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,5 @@ +@Library("CI_LIB") _ + +def pipeline = new ncs.sdk_zephyr.Main() + +pipeline.run(JOB_NAME) diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index 90097c74317d..c70147b5195d 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -851,7 +851,6 @@ Documentation: - doc/images/Zephyr-Kite-in-tree.png - doc/index-tex.rst - doc/index.rst - - doc/kconfig.rst - doc/known-warnings.txt - doc/templates/sample.tmpl - doc/templates/board.tmpl @@ -3548,7 +3547,6 @@ STM32 Platforms: - GeorgeCGV files: - boards/st/ - - drivers/*/*stm32*/ - drivers/*/*stm32*.c - drivers/*/*stm32*.h - drivers/*/*/*stm32* @@ -3675,8 +3673,7 @@ Infineon Platforms: - boards/cypress/ - boards/infineon/ - drivers/*/*ifx_cat1* - - drivers/*/*xmc*/ - - drivers/*/*xmc*.c + - drivers/*/*xmc* - drivers/sensor/infineon/ - dts/arm/infineon/ - dts/arm/cypress/ diff --git a/arch/arm/core/mpu/arm_mpu_regions.c b/arch/arm/core/mpu/arm_mpu_regions.c index 6af62f840782..cfe1230c907e 100644 --- a/arch/arm/core/mpu/arm_mpu_regions.c +++ b/arch/arm/core/mpu/arm_mpu_regions.c @@ -8,6 +8,9 @@ #include #include +#if USE_PARTITION_MANAGER +#include +#endif static const struct arm_mpu_region mpu_regions[] = { /* Region 0 */ @@ -21,6 +24,14 @@ static const struct arm_mpu_region mpu_regions[] = { #endif /* Region 1 */ MPU_REGION_ENTRY("SRAM_0", +#if USE_PARTITION_MANAGER + PM_SRAM_ADDRESS, +#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) + REGION_RAM_ATTR(PM_SRAM_ADDRESS, PM_SRAM_SIZE)), +#else + REGION_RAM_ATTR(REGION_SRAM_SIZE)), +#endif +#else CONFIG_SRAM_BASE_ADDRESS, #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) REGION_RAM_ATTR(CONFIG_SRAM_BASE_ADDRESS, \ @@ -28,6 +39,8 @@ static const struct arm_mpu_region mpu_regions[] = { #else REGION_RAM_ATTR(REGION_SRAM_SIZE)), #endif + +#endif /* USE_PARTITION_MANAGER */ }; const struct arm_mpu_config mpu_config = { diff --git a/boards/bcdevices/plt_demo_v2/Kconfig.blueclover_plt_demo_v2 b/boards/bcdevices/plt_demo_v2/Kconfig.blueclover_plt_demo_v2 index 2b69264a29cb..1abf2e23fd85 100644 --- a/boards/bcdevices/plt_demo_v2/Kconfig.blueclover_plt_demo_v2 +++ b/boards/bcdevices/plt_demo_v2/Kconfig.blueclover_plt_demo_v2 @@ -3,5 +3,5 @@ # Copyright (c) 2021 Blue Clover # SPDX-License-Identifier: Apache-2.0 -config BOARD_BLUECLOVER_PLT_DEMO_V2_NRF52832 +config BOARD_BLUECLOVER_PLT_DEMO_V2 select SOC_NRF52832_QFAA diff --git a/boards/ebyte/e73_tbb/Kconfig.ebyte_e73_tbb b/boards/ebyte/e73_tbb/Kconfig.ebyte_e73_tbb index 8a04ffd502dc..60fa87104fca 100644 --- a/boards/ebyte/e73_tbb/Kconfig.ebyte_e73_tbb +++ b/boards/ebyte/e73_tbb/Kconfig.ebyte_e73_tbb @@ -3,5 +3,5 @@ # Copyright (c) 2021 Michal Morsisko # SPDX-License-Identifier: Apache-2.0 -config BOARD_EBYTE_E73_TBB_NRF52832 +config BOARD_EBYTE_E73_TBB select SOC_NRF52832_QFAA diff --git a/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet-pinctrl.dtsi b/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet-pinctrl.dtsi index ada32e709ac3..6804c040d12d 100644 --- a/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet-pinctrl.dtsi +++ b/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet-pinctrl.dtsi @@ -26,4 +26,21 @@ }; }; + spi0_default: spi0_default { + group1 { + psels = , + , + ; + }; + }; + + spi0_sleep: spi0_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + }; diff --git a/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts b/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts index 16aa4179fa9e..22a05cac020f 100644 --- a/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts +++ b/boards/nordic/nrf5340_audio_dk/nrf5340_audio_dk_nrf5340_cpunet.dts @@ -24,6 +24,46 @@ zephyr,code-partition = &slot0_partition; watchdog0 = &wdt0; }; + + arduino_header: connector { + compatible = "arduino-header-r3"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <0 0 &gpio0 4 0>, /* A0 */ + <1 0 &gpio0 5 0>, /* A1 */ + <2 0 &gpio0 6 0>, /* A2 */ + <3 0 &gpio0 7 0>, /* A3 */ + <4 0 &gpio0 25 0>, /* A4 */ + <5 0 &gpio0 26 0>, /* A5 */ + <6 0 &gpio1 9 0>, /* D0 */ + <7 0 &gpio1 8 0>, /* D1 */ + <8 0 &gpio0 31 0>, /* D2 */ + <9 0 &gpio1 0 0>, /* D3 */ + <10 0 &gpio1 1 0>, /* D4 */ + <11 0 &gpio1 14 0>, /* D5 */ + <12 0 &gpio1 7 0>, /* D6 */ + <13 0 &gpio1 11 0>, /* D7 */ + <14 0 &gpio1 10 0>, /* D8 */ + <15 0 &gpio1 13 0>, /* D9 */ + <16 0 &gpio1 12 0>, /* D10 */ + <17 0 &gpio0 9 0>, /* D11 */ + <18 0 &gpio0 10 0>, /* D12 */ + <19 0 &gpio0 8 0>, /* D13 */ + <20 0 &gpio1 2 0>, /* D14 */ + <21 0 &gpio1 3 0>; /* D15 */ + }; + +}; + +arduino_spi: &spi0 { + compatible = "nordic,nrf-spim"; + /* Cannot be used together with uart0. */ + /* status = "okay"; */ + cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>; /* D10 */ + pinctrl-0 = <&spi0_default>; + pinctrl-1 = <&spi0_sleep>; + pinctrl-names = "default", "sleep"; }; &gpiote { diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf.dtsi index 9c3d971b9bc6..539e80d149af 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf.dtsi +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-ipc_conf.dtsi @@ -21,6 +21,7 @@ }; cpuapp_cpurad_ipc: ipc-2-3 { + compatible = "zephyr,ipc-icbmsg"; status = "disabled"; mboxes = <&cpuapp_bellboard 18>, <&cpurad_bellboard 12>; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi index 68c0d5cd9909..91899e2cf86b 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-memory_map.dtsi @@ -6,16 +6,16 @@ / { reserved-memory { - cpuapp_ram0x_region: memory@2f000000 { + cpuapp_ram0x_region: memory@2f010000 { compatible = "nordic,owned-memory"; - reg = <0x2f000000 DT_SIZE_K(260)>; + reg = <0x2f010000 DT_SIZE_K(260)>; status = "disabled"; perm-read; perm-write; perm-secure; #address-cells = <1>; #size-cells = <1>; - ranges = <0x0 0x2f000000 0x41000>; + ranges = <0x0 0x2f010000 0x41000>; cpusec_cpuapp_ipc_shm: memory@0 { reg = <0x0 DT_SIZE_K(2)>; @@ -30,16 +30,16 @@ }; }; - cpurad_ram0x_region: memory@2f041000 { + cpurad_ram0x_region: memory@2f051000 { compatible = "nordic,owned-memory"; - reg = <0x2f041000 DT_SIZE_K(4)>; + reg = <0x2f051000 DT_SIZE_K(4)>; status = "disabled"; perm-read; perm-write; perm-secure; #address-cells = <1>; #size-cells = <1>; - ranges = <0x0 0x2f041000 0x1000>; + ranges = <0x0 0x2f051000 0x1000>; cpusec_cpurad_ipc_shm: memory@0 { reg = <0x0 DT_SIZE_K(2)>; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-pinctrl.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-pinctrl.dtsi index 6c6da3fa747e..8bc02597c6d0 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-pinctrl.dtsi +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-pinctrl.dtsi @@ -50,4 +50,26 @@ ; }; }; + + /omit-if-no-ref/ pwm120_default: pwm120_default { + group1 { + psels = ; + }; + }; + + /omit-if-no-ref/ pwm120_sleep: pwm120_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; + + /omit-if-no-ref/ exmif_default: exmif_default { + group1 { + psels = , + , + ; + nordic,drive-mode = ; + }; + }; }; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts index 8c6512861e89..7f2f918b0b9f 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts @@ -22,6 +22,9 @@ zephyr,code-partition = &cpuapp_slot0_partition; zephyr,flash = &mram1x; zephyr,sram = &cpuapp_data; + zephyr,shell-uart = &uart136; + zephyr,bt-hci-ipc = &ipc0; + zephyr,entropy = &prng; }; aliases { @@ -29,6 +32,7 @@ led1 = &led1; led2 = &led2; led3 = &led3; + pwm-led0 = &pwm_led0; sw0 = &button0; sw1 = &button1; sw2 = &button2; @@ -86,34 +90,57 @@ label = "Green LED 3"; }; }; + + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm120 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + }; + }; + + prng: prng { + compatible = "nordic,entropy-prng"; + status = "okay"; + }; }; &cpuapp_ram0x_region { status = "okay"; }; +&cpuapp_cpurad_ram0x_region { + status = "okay"; +}; + &shared_ram3x_region { status = "okay"; }; &cpuapp_bellboard { + status = "okay"; interrupts = <96 NRF_DEFAULT_IRQ_PRIORITY>; interrupt-names = "irq0"; /* irq0: 0: cpuapp-cpusec, 13: cpuapp-cpuppr, 18: cpuapp-cpurad */ nordic,interrupt-mapping = <0x00042001 0>; }; +&cpurad_bellboard { + status = "okay"; +}; + &cpusec_cpuapp_ipc { mbox-names = "tx", "rx"; tx-region = <&cpuapp_cpusec_ipc_shm>; rx-region = <&cpusec_cpuapp_ipc_shm>; }; -&cpuapp_cpurad_ipc { - compatible = "zephyr,ipc-icmsg-me-initiator"; +ipc0: &cpuapp_cpurad_ipc { + status = "okay"; mbox-names = "rx", "tx"; tx-region = <&cpuapp_cpurad_ipc_shm>; rx-region = <&cpurad_cpuapp_ipc_shm>; + tx-blocks = <32>; + rx-blocks = <32>; }; &cpuapp_cpuppr_ipc { @@ -173,4 +200,41 @@ pinctrl-0 = <&uart136_default>; pinctrl-1 = <&uart136_sleep>; pinctrl-names = "default", "sleep"; + hw-flow-control; +}; + +&pwm120 { + status = "okay"; + pinctrl-0 = <&pwm120_default>; + pinctrl-1 = <&pwm120_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&gpio6 { + status = "okay"; +}; + +&exmif { + cs-gpios = <&gpio6 3 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&exmif_default>; + pinctrl-names = "default"; + status = "okay"; + mx25uw63: mx25uw6345g@0 { + compatible = "jedec,spi-nor"; + status = "disabled"; + reg = <0>; + spi-max-frequency = ; + jedec-id = [c2 84 37]; + sfdp-bfp = [ + e5 20 8a ff ff ff ff 03 00 ff 00 ff 00 ff 00 ff + ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 10 d8 + 00 ff 00 ff 87 79 01 00 84 12 00 c4 cc 04 67 46 + 30 b0 30 b0 f4 bd d5 5c 00 00 00 ff 10 10 00 20 + 00 00 00 00 00 00 7c 23 48 00 00 00 00 00 88 88 + ]; + size = <67108864>; + has-dpd; + t-enter-dpd = <10000>; + t-exit-dpd = <30000>; + }; }; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.yaml b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.yaml index 0ba6bfe3ba25..6ecde2cfdb10 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.yaml +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.yaml @@ -13,3 +13,4 @@ ram: 256 flash: 512 supported: - gpio + - pwm diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr.dts b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr.dts index edce1a8b275b..4cfad97323e5 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr.dts +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr.dts @@ -26,6 +26,7 @@ zephyr,code-partition = &cpuppr_code_partition; zephyr,flash = &mram1x; zephyr,sram = &cpuppr_code_data; + zephyr,shell-uart = &uart135; }; }; @@ -46,6 +47,7 @@ pinctrl-0 = <&uart135_default>; pinctrl-1 = <&uart135_sleep>; pinctrl-names = "default", "sleep"; + hw-flow-control; }; &uart136 { diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr.yaml b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr.yaml index b986a4566234..190d835f5809 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr.yaml +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr.yaml @@ -11,3 +11,4 @@ ram: 62 flash: 62 supported: - gpio + - pwm diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts index 3efa07f6349f..d72aa791091b 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts @@ -23,6 +23,14 @@ zephyr,code-partition = &cpurad_slot0_partition; zephyr,flash = &mram1x; zephyr,sram = &cpurad_ram0; + zephyr,shell-uart = &uart135; + zephyr,bt-hci-ipc = &ipc0; + zephyr,entropy = &prng; + }; + + prng: prng { + compatible = "nordic,entropy-prng"; + status = "okay"; }; }; @@ -30,24 +38,35 @@ status = "okay"; }; +&cpuapp_cpurad_ram0x_region { + status = "okay"; +}; + &cpurad_bellboard { + status = "okay"; interrupts = <96 NRF_DEFAULT_IRQ_PRIORITY>; interrupt-names = "irq0"; /* irq0: 0: cpurad-cpusec, 12: cpurad-cpuapp */ nordic,interrupt-mapping = <0x00001001 0>; }; +&cpuapp_bellboard { + status = "okay"; +}; + &cpusec_cpurad_ipc { mbox-names = "tx", "rx"; tx-region = <&cpurad_cpusec_ipc_shm>; rx-region = <&cpusec_cpurad_ipc_shm>; }; -&cpuapp_cpurad_ipc { - compatible = "zephyr,ipc-icmsg-me-follower"; +ipc0: &cpuapp_cpurad_ipc { + status = "okay"; mbox-names = "tx", "rx"; tx-region = <&cpurad_cpuapp_ipc_shm>; rx-region = <&cpuapp_cpurad_ipc_shm>; + tx-blocks = <32>; + rx-blocks = <32>; }; &cpurad_dma_region { @@ -69,6 +88,7 @@ pinctrl-0 = <&uart135_default>; pinctrl-1 = <&uart135_sleep>; pinctrl-names = "default", "sleep"; + hw-flow-control; }; &uart136 { diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.yaml b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.yaml index 420d854cbca3..b199f65385f3 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.yaml +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.yaml @@ -13,3 +13,4 @@ ram: 192 flash: 256 supported: - gpio + - pwm diff --git a/boards/nordic/nrf54l15pdk/Kconfig b/boards/nordic/nrf54l15pdk/Kconfig index 638ce57499dc..db822a14820e 100644 --- a/boards/nordic/nrf54l15pdk/Kconfig +++ b/boards/nordic/nrf54l15pdk/Kconfig @@ -11,3 +11,46 @@ config BOARD_ENABLE_DCDC default y endif # BOARD_NRF54L15PDK_NRF54L15_CPUAPP + +if BOARD_NRF54L15PDK_NRF54L15_CPUAPP_NS + +# TODO: Remove the options bellow when (NCSDK-25023) is done +config NRF_SPU_FLASH_REGION_SIZE + hex + default 0x4000 + # This option does not apply to 54, but we pretend the HW has this limitation + # for now for easier porting. NCSDK-25023 + help + FLASH region size for the NRF_SPU peripheral. For nrf54 the + region size is configurable per-region so this option does + not apply. + +config NRF_SPU_FLASH_REGION_ALIGNMENT + hex + default 0x4000 + # This option does not apply to 54, but we pretend the HW has this limitation + # for now for easier porting. NCSDK-25023 + help + FLASH region size for the NRF_SPU peripheral. For nrf54 the + region size is configurable per-region so this option does + not apply. + +config NRF_SPU_RAM_REGION_SIZE + hex + default 0x2000 + # This HW limitation does not apply to 54, but we pretend + # it does for now for easier porting. NCSDK-25023 + help + RAM region size for the NRF_SPU peripheral. For nrf54 the + region size is configurable per-region so this option does + not apply. + + +config NRF_SPU_RAM_REGION_ALIGNMENT + hex + default 0x1000 + help + RAM regions must be aligned to this value due to SPU HW + limitations. + +endif #BOARD_NRF54L15PDK_NRF54L15_CPUAPP_NS diff --git a/boards/nordic/nrf54l15pdk/Kconfig.defconfig b/boards/nordic/nrf54l15pdk/Kconfig.defconfig index 1c83abbb0200..87b8c1d0cc34 100644 --- a/boards/nordic/nrf54l15pdk/Kconfig.defconfig +++ b/boards/nordic/nrf54l15pdk/Kconfig.defconfig @@ -7,6 +7,25 @@ config BT_CTLR default BT config ROM_START_OFFSET + default 0 if PARTITION_MANAGER_ENABLED default 0x800 if BOOTLOADER_MCUBOOT endif # BOARD_NRF54L15PDK_NRF54L15_CPUAPP + +if BOARD_NRF54L15PDK_NRF54L15_CPUAPP_NS + +config BT_CTLR + default BT + +# By default, if we build for a Non-Secure version of the board, +# enable building with TF-M as the Secure Execution Environment. +config BUILD_WITH_TFM + default y if BOARD_NRF54L15PDK_NRF54L15_CPUAPP_NS + +# By default, if we build with TF-M, instruct build system to +# flash the combined TF-M (Secure) & Zephyr (Non Secure) image +config TFM_FLASH_MERGED_BINARY + default y + depends on BUILD_WITH_TFM + +endif #BOARD_NRF54L15PDK_NRF54L15_CPUAPP_NS diff --git a/boards/nordic/nrf54l15pdk/Kconfig.nrf54l15pdk b/boards/nordic/nrf54l15pdk/Kconfig.nrf54l15pdk index 4ec5b6ee62de..36ee21a55b61 100644 --- a/boards/nordic/nrf54l15pdk/Kconfig.nrf54l15pdk +++ b/boards/nordic/nrf54l15pdk/Kconfig.nrf54l15pdk @@ -1,5 +1,5 @@ # Copyright (c) 2024 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -config BOARD_NRF54L15PDK_NRF54L15_CPUAPP - select SOC_NRF54L15_ENGA_CPUAPP +config BOARD_NRF54L15PDK + select SOC_NRF54L15_ENGA_CPUAPP if BOARD_NRF54L15PDK_NRF54L15_CPUAPP || BOARD_NRF54L15PDK_NRF54L15_CPUAPP_NS diff --git a/boards/nordic/nrf54l15pdk/board.cmake b/boards/nordic/nrf54l15pdk/board.cmake index 2107fb5d71ed..5a1e4b3221d7 100644 --- a/boards/nordic/nrf54l15pdk/board.cmake +++ b/boards/nordic/nrf54l15pdk/board.cmake @@ -3,6 +3,14 @@ board_runner_args(jlink "--device=cortex-m33" "--speed=4000") +if(BOARD_NRF54L15PDK_NRF54L15_CPUAPP_NS) + set(TFM_PUBLIC_KEY_FORMAT "full") +endif() + +if(CONFIG_TFM_FLASH_MERGED_BINARY) + set_property(TARGET runners_yaml_props_target PROPERTY hex_file tfm_merged.hex) +endif() + include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake) include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/nordic/nrf54l15pdk/board.yml b/boards/nordic/nrf54l15pdk/board.yml index 3b0fc447385c..69b512232093 100644 --- a/boards/nordic/nrf54l15pdk/board.yml +++ b/boards/nordic/nrf54l15pdk/board.yml @@ -3,6 +3,9 @@ board: vendor: nordic socs: - name: nrf54l15 + variants: + - name: ns + cpucluster: cpuapp revision: format: major.minor.patch default: "0.2.1" diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp-pinctrl.dtsi b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp-pinctrl.dtsi index 02b02bc81715..89ad75998706 100644 --- a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp-pinctrl.dtsi +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp-pinctrl.dtsi @@ -7,14 +7,21 @@ uart20_default: uart20_default { group1 { psels = , - ; + ; + }; + group2 { + psels = , + ; + bias-pull-up; }; }; uart20_sleep: uart20_sleep { group1 { psels = , - ; + , + , + ; low-power-enable; }; }; @@ -22,14 +29,51 @@ uart30_default: uart30_default { group1 { psels = , - ; + ; + }; + group2 { + psels = , + ; + bias-pull-up; }; }; uart30_sleep: uart30_sleep { group1 { psels = , - ; + , + , + ; + low-power-enable; + }; + }; + + spi0_default: spi0_default { + group1 { + psels = , + , + ; + }; + }; + + spi0_sleep: spi0_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + /omit-if-no-ref/ pwm20_default: pwm20_default { + group1 { + psels = ; + }; + }; + + /omit-if-no-ref/ pwm20_sleep: pwm20_sleep { + group1 { + psels = ; low-power-enable; }; }; diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts index c801ddc8dc5f..395f92d638c2 100644 --- a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts @@ -43,6 +43,13 @@ }; }; + pwmleds { + compatible = "pwm-leds"; + pwm_led1: pwm_led_1 { + pwms = <&pwm20 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + }; + }; + buttons { compatible = "gpio-keys"; button0: button_0 { @@ -72,11 +79,13 @@ led1 = &led1; led2 = &led2; led3 = &led3; + pwm-led0 = &pwm_led1; watchdog0 = &wdt30; sw0 = &button0; sw1 = &button1; sw2 = &button2; sw3 = &button3; + spi-flash0 = &mx25r64; }; }; @@ -96,6 +105,7 @@ pinctrl-0 = <&uart20_default>; pinctrl-1 = <&uart20_sleep>; pinctrl-names = "default", "sleep"; + hw-flow-control; }; &uart30 { @@ -173,3 +183,40 @@ &clock { status = "okay"; }; + +&spi00 { + status = "okay"; + cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&spi0_default>; + pinctrl-1 = <&spi0_sleep>; + pinctrl-names = "default", "sleep"; + + mx25r64: mx25r6435f@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + status = "disabled"; + spi-max-frequency = <8000000>; + jedec-id = [c2 28 17]; + sfdp-bfp = [ + e5 20 f1 ff ff ff ff 03 44 eb 08 6b 08 3b 04 bb + ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52 + 10 d8 00 ff 23 72 f5 00 82 ed 04 cc 44 83 48 44 + 30 b0 30 b0 f7 c4 d5 5c 00 be 29 ff f0 d0 ff ff + ]; + size = <67108864>; + has-dpd; + t-enter-dpd = <10000>; + t-exit-dpd = <35000>; + }; +}; + +&adc { + status = "okay"; +}; + +&pwm20 { + status = "okay"; + pinctrl-0 = <&pwm20_default>; + pinctrl-1 = <&pwm20_sleep>; + pinctrl-names = "default", "sleep"; +}; diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.yaml b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.yaml index 95fc08d422ed..2858ddd35c56 100644 --- a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.yaml +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.yaml @@ -12,6 +12,7 @@ toolchain: ram: 256 flash: 1536 supported: + - adc - counter - gpio - i2c diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay index d8262dde9946..99ba6ff30628 100644 --- a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.overlay @@ -36,3 +36,18 @@ &button3 { gpios = <&gpio0 4 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; }; + +&pinctrl { + /omit-if-no-ref/ pwm20_default: pwm20_default { + group1 { + psels = ; + }; + }; + + /omit-if-no-ref/ pwm20_sleep: pwm20_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; +}; diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.yaml b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.yaml new file mode 100644 index 000000000000..a19bc8fdc8b2 --- /dev/null +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_0_3_0.yaml @@ -0,0 +1,20 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +identifier: nrf54l15pdk@0.3.0/nrf54l15/cpuapp +name: nRF54l15-PDK-nRF54l15-Application +type: mcu +arch: arm +toolchain: + - gnuarmemb + - xtools + - zephyr +ram: 256 +flash: 1536 +supported: + - counter + - gpio + - i2c + - spi + - watchdog + - i2s diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns-pinctrl.dtsi b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns-pinctrl.dtsi new file mode 100644 index 000000000000..b4b924e90ef2 --- /dev/null +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns-pinctrl.dtsi @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&pinctrl { + uart20_default: uart20_default { + group1 { + psels = , + ; + }; + }; + + uart20_sleep: uart20_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + uart30_default: uart30_default { + group1 { + psels = , + ; + }; + }; + + uart30_sleep: uart30_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + +}; diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns.dts b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns.dts new file mode 100644 index 000000000000..49fd1ac0ece4 --- /dev/null +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns.dts @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/dts-v1/; +#include +#include "nrf54l15pdk_nrf54l15_cpuapp_ns-pinctrl.dtsi" + +/ { + chosen { + zephyr,console = &uart20; + /* TODO: NCSDK-24862: We don't support configuring RRAM and SRAM + * regions in the DTS file yet. The partition manager configures + * these regions now. + */ + zephyr,shell-uart = &uart20; + zephyr,flash = &rram0; + zephyr,sram = &sram0; + zephyr,ieee802154 = &ieee802154; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; + label = "Green LED 0"; + }; + led1: led_1 { + gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>; + label = "Green LED 1"; + }; + led2: led_2 { + gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>; + label = "Green LED 2"; + }; + led3: led_3 { + gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>; + label = "Green LED 3"; + }; + }; + + buttons { + compatible = "gpio-keys"; + button0: button_0 { + gpios = <&gpio1 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Push button 0"; + zephyr,code = ; + }; + button1: button_1 { + gpios = <&gpio1 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Push button 1"; + zephyr,code = ; + }; + button2: button_2 { + gpios = <&gpio2 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Push button 2"; + zephyr,code = ; + }; + button3: button_3 { + gpios = <&gpio2 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Push button 3"; + zephyr,code = ; + }; + }; + + aliases { + led0 = &led0; + led1 = &led1; + led2 = &led2; + led3 = &led3; + sw0 = &button0; + sw1 = &button1; + sw2 = &button2; + sw3 = &button3; + }; +}; + +&uart20 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart20_default>; + pinctrl-1 = <&uart20_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&uart30 { + /* Disable so that TF-M can use this UART */ + status = "disabled"; + + current-speed = <115200>; + pinctrl-0 = <&uart30_default>; + pinctrl-1 = <&uart30_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&grtc { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpiote20 { + status = "okay"; +}; + +&gpiote30 { + status = "okay"; +}; + +&ieee802154 { + status = "okay"; +}; + +&temp { + status = "okay"; +}; + +&clock { + status = "okay"; +}; diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns.yaml b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns.yaml new file mode 100644 index 000000000000..460803eaa53d --- /dev/null +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns.yaml @@ -0,0 +1,22 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +identifier: nrf54l15pdk/nrf54l15/cpuapp/ns +name: nRF54l15-PDK-nRF54l15-Application-Non-Secure +type: mcu +arch: arm +toolchain: + - gnuarmemb + - xtools + - zephyr +ram: 256 +flash: 1524 +supported: + - adc + - gpio + - i2c + - spi + - counter + - watchdog + - adc + - i2s diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns_defconfig b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns_defconfig new file mode 100644 index 000000000000..ec01756bfd40 --- /dev/null +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp_ns_defconfig @@ -0,0 +1,37 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +CONFIG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y + +# Enable TrustZone-M +CONFIG_ARM_TRUSTZONE_M=y + +# This Board implies building Non-Secure firmware +CONFIG_TRUSTED_EXECUTION_NONSECURE=y + +# Don't enable the cache in the non-secure image as it is a +# secure-only peripheral on 54l +CONFIG_CACHE_MANAGEMENT=n +CONFIG_EXTERNAL_CACHE=n + +CONFIG_UART_CONSOLE=y +CONFIG_CONSOLE=y +CONFIG_SERIAL=y + +# Enable GPIO +CONFIG_GPIO=y + +# NCSDK-26634: Rollback protection is not supported yet +CONFIG_TFM_PS_ROLLBACK_PROTECTION=n + +# NCSDK-22600: Built-in keys are not supported yet. +CONFIG_TFM_CRYPTO_BUILTIN_KEYS=n + +# Start SYSCOUNTER on driver init +CONFIG_NRF_GRTC_START_SYSCOUNTER=y diff --git a/boards/nordic/nrf9131ek/Kconfig.defconfig b/boards/nordic/nrf9131ek/Kconfig.defconfig index b63e7ef8d34c..8e0e1d02d1d1 100644 --- a/boards/nordic/nrf9131ek/Kconfig.defconfig +++ b/boards/nordic/nrf9131ek/Kconfig.defconfig @@ -5,6 +5,21 @@ if BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS +# By default, if we build for a Non-Secure version of the board, +# enable building with TF-M as the Secure Execution Environment. +config BUILD_WITH_TFM + default y if BOARD_NRF9131EK_NRF9131_NS + +if BUILD_WITH_TFM + +# By default, if we build with TF-M, instruct build system to +# flash the combined TF-M (Secure) & Zephyr (Non Secure) image +config TFM_FLASH_MERGED_BINARY + bool + default y + +endif # BUILD_WITH_TFM + # For the secure version of the board the firmware is linked at the beginning # of the flash, or into the code-partition defined in DT if it is intended to # be loaded by MCUboot. If the secure firmware is to be combined with a non- diff --git a/boards/nordic/thingy53/Kconfig.defconfig b/boards/nordic/thingy53/Kconfig.defconfig index 701bd9be4e6f..d849fda09ed8 100644 --- a/boards/nordic/thingy53/Kconfig.defconfig +++ b/boards/nordic/thingy53/Kconfig.defconfig @@ -5,6 +5,12 @@ if BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS +config BOOTLOADER_MCUBOOT + default y if !MCUBOOT + +config BOARD_ENABLE_CPUNET + default y if !MCUBOOT + # Code Partition: # # For the secure version of the board the firmware is linked at the beginning @@ -133,6 +139,13 @@ endif # LOG endif # BOARD_SERIAL_BACKEND_CDC_ACM +# By default, a USB CDC ACM instance is already enabled in the board's DTS. +# It is not necessary for nRF Connect SDK to add another instance if MCUBoot +# bootloader is built as a child image. +config MCUBOOT_USB_SUPPORT + bool + default n + endif # BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS if BOARD_THINGY53_NRF5340_CPUNET diff --git a/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp.yml b/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp.yml new file mode 100644 index 000000000000..7a48d51ec334 --- /dev/null +++ b/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp.yml @@ -0,0 +1,55 @@ +app: + address: 0x10200 + region: flash_primary + size: 0xdfe00 +mcuboot: + address: 0x0 + region: flash_primary + size: 0x10000 +mcuboot_pad: + address: 0x10000 + region: flash_primary + size: 0x200 +mcuboot_primary: + address: 0x10000 + orig_span: &id001 + - mcuboot_pad + - app + region: flash_primary + size: 0xe0000 + span: *id001 +mcuboot_primary_app: + address: 0x10200 + orig_span: &id002 + - app + region: flash_primary + size: 0xdfe00 + span: *id002 +settings_storage: + address: 0xf0000 + region: flash_primary + size: 0x10000 +mcuboot_primary_1: + address: 0x0 + size: 0x40000 + device: flash_ctrl + region: ram_flash +mcuboot_secondary: + address: 0x00000 + size: 0xe0000 + device: MX25R64 + region: external_flash +mcuboot_secondary_1: + address: 0xe0000 + size: 0x40000 + device: MX25R64 + region: external_flash +external_flash: + address: 0x120000 + size: 0x6e0000 + device: MX25R64 + region: external_flash +pcd_sram: + address: 0x20000000 + size: 0x2000 + region: sram_primary diff --git a/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp_ns.yml b/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp_ns.yml new file mode 100644 index 000000000000..70ffe6d9c124 --- /dev/null +++ b/boards/nordic/thingy53/pm_static_thingy53_nrf5340_cpuapp_ns.yml @@ -0,0 +1,73 @@ +mcuboot: + address: 0x0 + region: flash_primary + size: 0x10000 +mcuboot_pad: + address: 0x10000 + region: flash_primary + size: 0x200 +tfm_secure: + address: 0x10000 + size: 0xc000 + span: [mcuboot_pad, tfm] +tfm_nonsecure: + address: 0x1c000 + size: 0xd4000 + span: [app] +tfm: + address: 0x10200 + region: flash_primary + size: 0xbe00 +app: + address: 0x1c000 + region: flash_primary + size: 0xd4000 +mcuboot_primary: + address: 0x10000 + orig_span: &id001 + - mcuboot_pad + - tfm + - app + region: flash_primary + size: 0xe0000 + span: *id001 +mcuboot_primary_app: + address: 0x10200 + orig_span: &id002 + - tfm + - app + region: flash_primary + size: 0xdfe00 + span: *id002 +nonsecure_storage: + address: 0xf0000 + size: 0x10000 + span: [settings_storage] +settings_storage: + address: 0xf0000 + region: flash_primary + size: 0x10000 +mcuboot_primary_1: + address: 0x0 + size: 0x40000 + device: flash_ctrl + region: ram_flash +mcuboot_secondary: + address: 0x00000 + size: 0xe0000 + device: MX25R64 + region: external_flash +mcuboot_secondary_1: + address: 0xe0000 + size: 0x40000 + device: MX25R64 + region: external_flash +external_flash: + address: 0x120000 + size: 0x6e0000 + device: MX25R64 + region: external_flash +pcd_sram: + address: 0x20000000 + size: 0x2000 + region: sram_primary diff --git a/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi b/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi index 694a6960584e..54efd588cf7a 100644 --- a/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi +++ b/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi @@ -16,6 +16,7 @@ zephyr,bt-hci-ipc = &ipc0; nordic,802154-spinel-ipc = &ipc0; zephyr,ieee802154 = &ieee802154; + nordic,pm-ext-flash = &mx25r64; }; buttons { diff --git a/boards/nxp/imx93_evk/Kconfig.imx93_evk b/boards/nxp/imx93_evk/Kconfig.imx93_evk index e3121418393c..0115518a6d25 100644 --- a/boards/nxp/imx93_evk/Kconfig.imx93_evk +++ b/boards/nxp/imx93_evk/Kconfig.imx93_evk @@ -1,6 +1,6 @@ # Copyright 2022,2024 NXP # SPDX-License-Identifier: Apache-2.0 -config BOARD_IMX93_EVK_MIMX9352_A55 - select SOC_MIMX9352_A55 +config BOARD_IMX93_EVK + select SOC_MIMX9352_A55 if BOARD_IMX93_EVK_MIMX9352_A55 select SOC_PART_NUMBER_MIMX9352CVUXK diff --git a/boards/nxp/vmu_rt1170/Kconfig.vmu_rt1170 b/boards/nxp/vmu_rt1170/Kconfig.vmu_rt1170 index cfd9ba449db9..081124dd1a82 100644 --- a/boards/nxp/vmu_rt1170/Kconfig.vmu_rt1170 +++ b/boards/nxp/vmu_rt1170/Kconfig.vmu_rt1170 @@ -1,6 +1,6 @@ # Copyright 2023 NXP # SPDX-License-Identifier: Apache-2.0 -config BOARD_VMU_RT1170_MIMXRT1176_CM7 - select SOC_MIMXRT1176_CM7 +config BOARD_VMU_RT1170 + select SOC_MIMXRT1176_CM7 if BOARD_VMU_RT1170_MIMXRT1176_CM7 select SOC_PART_NUMBER_MIMXRT1176DVMAA diff --git a/boards/rak/rak5010/Kconfig.rak5010 b/boards/rak/rak5010/Kconfig.rak5010 index ced2b62b39c4..4c5db16669d8 100644 --- a/boards/rak/rak5010/Kconfig.rak5010 +++ b/boards/rak/rak5010/Kconfig.rak5010 @@ -3,5 +3,5 @@ # Copyright (c) 2020 Guillaume Paquet # SPDX-License-Identifier: Apache-2.0 -config BOARD_RAK5010_NRF52840 +config BOARD_RAK5010 select SOC_NRF52840_QIAA diff --git a/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_reset.c b/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_reset.c index 97ae3fc1bd0e..9596b3453be2 100644 --- a/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_reset.c +++ b/boards/raytac/mdbt53_db_40/raytac_mdbt53_db_40_nrf5340_cpunet_reset.c @@ -10,6 +10,7 @@ #include #include +#include LOG_MODULE_REGISTER(raytac_mdbt53_db_40_nrf5340_cpuapp, CONFIG_LOG_DEFAULT_LEVEL); @@ -49,7 +50,7 @@ static int remoteproc_mgr_boot(const struct device *dev) */ /* Release the Network MCU, 'Release force off signal' */ - NRF_RESET->NETWORK.FORCEOFF = RESET_NETWORK_FORCEOFF_FORCEOFF_Release; + nrf_reset_network_force_off(NRF_RESET, false); LOG_DBG("Network MCU released."); #endif /* !CONFIG_TRUSTED_EXECUTION_SECURE */ diff --git a/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_reset.c b/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_reset.c index fd48ae16fd6b..31b8bf5a75e5 100644 --- a/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_reset.c +++ b/boards/raytac/mdbt53v_db_40/raytac_mdbt53v_db_40_nrf5340_cpunet_reset.c @@ -49,7 +49,7 @@ static int remoteproc_mgr_boot(const struct device *dev) */ /* Release the Network MCU, 'Release force off signal' */ - NRF_RESET->NETWORK.FORCEOFF = RESET_NETWORK_FORCEOFF_FORCEOFF_Release; + nrf_reset_network_force_off(NRF_RESET, false); LOG_DBG("Network MCU released."); #endif /* !CONFIG_TRUSTED_EXECUTION_SECURE */ diff --git a/boards/starfive/visionfive2/Kconfig.visionfive2 b/boards/starfive/visionfive2/Kconfig.visionfive2 index e451964f9797..d2988440b2d9 100644 --- a/boards/starfive/visionfive2/Kconfig.visionfive2 +++ b/boards/starfive/visionfive2/Kconfig.visionfive2 @@ -1,5 +1,5 @@ # Copyright (c) 2024 Kanak Shilledar # SPDX-License-Identifier: Apache-2.0 -config BOARD_VISIONFIVE2_JH7110 +config BOARD_VISIONFIVE2 select SOC_JH7110 diff --git a/boards/ti/sk_am62/Kconfig.sk_am62 b/boards/ti/sk_am62/Kconfig.sk_am62 index d7e83cba87ac..fab6d8845089 100644 --- a/boards/ti/sk_am62/Kconfig.sk_am62 +++ b/boards/ti/sk_am62/Kconfig.sk_am62 @@ -5,7 +5,5 @@ # # SPDX-License-Identifier: Apache-2.0 -config BOARD_SK_AM62_AM6234_M4 - select SOC_AM6234_M4 - help - TI AM62x M4 Starter Kit (SK) Evaluation Module (EVM) +config BOARD_SK_AM62 + select SOC_AM6234_M4 if BOARD_SK_AM62_AM6234_M4 diff --git a/boards/we/proteus2ev/Kconfig.we_proteus2ev b/boards/we/proteus2ev/Kconfig.we_proteus2ev index 60aa73fb142c..b18f4c4f9bbb 100644 --- a/boards/we/proteus2ev/Kconfig.we_proteus2ev +++ b/boards/we/proteus2ev/Kconfig.we_proteus2ev @@ -1,5 +1,5 @@ # Copyright (c) 2022 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -config BOARD_WE_PROTEUS2EV_NRF52832 +config BOARD_WE_PROTEUS2EV select SOC_NRF52832_CIAA diff --git a/cmake/modules/boards.cmake b/cmake/modules/boards.cmake index cb07262f1506..ec9b6579146c 100644 --- a/cmake/modules/boards.cmake +++ b/cmake/modules/boards.cmake @@ -21,13 +21,18 @@ # Outcome: # The following variables will be defined when this CMake module completes: # -# - BOARD: Board, without revision field. -# - BOARD_REVISION: Board revision -# - BOARD_DIR: Board directory with the implementation for selected board -# - ARCH_DIR: Arch dir for extracted from selected board -# - BOARD_ROOT: BOARD_ROOT with ZEPHYR_BASE appended -# - BOARD_EXTENSION_DIRS: List of board extension directories (If -# BOARD_EXTENSIONS is not explicitly disabled) +# - BOARD: Board, without revision field. +# - BOARD_REVISION: Board revision +# - BOARD_QUALIFIERS: Board qualifiers +# - NORMALIZED_BOARD_QUALIFIERS: Board qualifiers in lower-case format where slashes have been +# replaced with underscores +# - NORMALIZED_BOARD_TARGET: Board target in lower-case format where slashes have been +# replaced with underscores +# - BOARD_DIR: Board directory with the implementation for selected board +# - ARCH_DIR: Arch dir for extracted from selected board +# - BOARD_ROOT: BOARD_ROOT with ZEPHYR_BASE appended +# - BOARD_EXTENSION_DIRS: List of board extension directories (If +# BOARD_EXTENSIONS is not explicitly disabled) # # The following targets will be defined when this CMake module completes: # - board: when invoked, a list of valid boards will be printed @@ -314,7 +319,7 @@ elseif(HWMv2) unset(CACHED_BOARD CACHE) message(FATAL_ERROR "Board qualifiers `${BOARD_QUALIFIERS}` for board \ `${BOARD}` not found. Please specify a valid board target.\n" - "Valid board targets for ${BOARD_NAME} are:\n${board_targets}\n") + "Valid board targets for ${LIST_BOARD_NAME} are:\n${board_targets}\n") endif() endif() else() @@ -336,8 +341,13 @@ endif() if(DEFINED BOARD_QUALIFIERS) string(REGEX REPLACE "^/" "qualifiers: " board_message_qualifiers "${BOARD_QUALIFIERS}") set(board_message "${board_message}, ${board_message_qualifiers}") + + string(REPLACE "/" "_" NORMALIZED_BOARD_QUALIFIERS "${BOARD_QUALIFIERS}") endif() +set(NORMALIZED_BOARD_TARGET "${BOARD}${BOARD_QUALIFIERS}") +string(REPLACE "/" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}") + message(STATUS "${board_message}") add_custom_target(boards ${list_boards_commands} USES_TERMINAL) diff --git a/cmake/modules/configuration_files.cmake b/cmake/modules/configuration_files.cmake index 78e7bf2a4944..2bd843a0d8da 100644 --- a/cmake/modules/configuration_files.cmake +++ b/cmake/modules/configuration_files.cmake @@ -45,6 +45,7 @@ endif() zephyr_get(CONF_FILE SYSBUILD LOCAL) if(NOT DEFINED CONF_FILE) zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR} KCONF CONF_FILE NAMES "prj.conf" SUFFIX ${FILE_SUFFIX} REQUIRED) + zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR}/socs KCONF CONF_FILE QUALIFIERS SUFFIX ${FILE_SUFFIX}) zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR}/boards KCONF CONF_FILE SUFFIX ${FILE_SUFFIX}) else() string(CONFIGURE "${CONF_FILE}" CONF_FILE_EXPANDED) @@ -75,9 +76,10 @@ zephyr_boilerplate_watch(CONF_FILE) zephyr_get(DTC_OVERLAY_FILE SYSBUILD LOCAL) -# If DTC_OVERLAY_FILE is not set by the user, look for board-specific overlays -# in the 'boards' configuration subdirectory. +# If DTC_OVERLAY_FILE is not set by the user, look for SoC and board-specific overlays +# in the 'boards' and `soc` configuration subdirectories. if(NOT DEFINED DTC_OVERLAY_FILE) + zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR}/socs DTS DTC_OVERLAY_FILE QUALIFIERS SUFFIX ${FILE_SUFFIX}) zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR}/boards DTS DTC_OVERLAY_FILE SUFFIX ${FILE_SUFFIX}) endif() @@ -90,7 +92,6 @@ if(NOT DEFINED DTC_OVERLAY_FILE) NAMES "app.overlay" SUFFIX ${FILE_SUFFIX} ) endif() - endif() set(DTC_OVERLAY_FILE ${DTC_OVERLAY_FILE} CACHE STRING "If desired, you can \ diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 4c989e808aea..a4a33ffe1378 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -1532,11 +1532,17 @@ endfunction() # Usage: # zephyr_build_string( # BOARD +# [SHORT ] # [BOARD_QUALIFIERS ] # [BOARD_REVISION ] # [BUILD ] # [MERGE [REVERSE]] # ) +# zephyr_build_string( +# BOARD_QUALIFIERS +# [BUILD ] +# [MERGE [REVERSE]] +# ) # # : Output variable where the build string will be returned. # SHORT : Output variable where the shortened build string will be returned. @@ -1565,11 +1571,15 @@ endfunction() # `alpha_soc_bar_1_0_0;alpha_soc_bar` in `build_string` parameter. # # calling -# zephyr_build_string(build_string SHORTENED short_build_string BOARD alpha BOARD_REVISION 1.0.0 BOARD_QUALIFIERS /soc/bar MERGE) +# zephyr_build_string(build_string SHORT short_build_string BOARD alpha BOARD_REVISION 1.0.0 BOARD_QUALIFIERS /soc/bar MERGE) # will return two lists of the following strings # `alpha_soc_bar_1_0_0;alpha_soc_bar` in `build_string` parameter. # `alpha_bar_1_0_0;alpha_bar` in `short_build_string` parameter. # +# calling +# zephyr_build_string(build_string BOARD_QUALIFIERS /soc/bar/foo) +# will return the string `soc_bar_foo` in `build_string` parameter. +# function(zephyr_build_string outvar) set(options MERGE REVERSE) set(single_args BOARD BOARD_QUALIFIERS BOARD_REVISION BUILD SHORT) @@ -1589,10 +1599,17 @@ function(zephyr_build_string outvar) ) endif() - if(DEFINED BUILD_STR_BOARD_QUALIFIERS AND NOT BUILD_STR_BOARD) + if(DEFINED BUILD_STR_BOARD_REVISION AND NOT DEFINED BUILD_STR_BOARD) message(FATAL_ERROR - "zephyr_build_string(${ARGV0} BOARD_QUALIFIERS ${BUILD_STR_BOARD_QUALIFIERS} ...)" - " given without BOARD argument, please specify BOARD" + "zephyr_build_string(${ARGV0} BOARD_REVISION ${BUILD_STR_BOARD_REVISION} ...)" + " given without BOARD argument, these must be used together" + ) + endif() + + if(DEFINED BUILD_STR_SHORT AND NOT DEFINED BUILD_STR_BOARD) + message(FATAL_ERROR + "zephyr_build_string(${ARGV0} SHORT ${BUILD_STR_SHORT} ...)" + " given without BOARD argument, these must be used together" ) endif() @@ -2571,7 +2588,7 @@ Please provide one of following: APPLICATION_ROOT, CONF_FILES") if(${ARGV0} STREQUAL APPLICATION_ROOT) set(single_args APPLICATION_ROOT) elseif(${ARGV0} STREQUAL CONF_FILES) - set(options REQUIRED) + set(options QUALIFIERS REQUIRED) set(single_args BOARD BOARD_REVISION BOARD_QUALIFIERS DTS KCONF DEFCONFIG BUILD SUFFIX) set(multi_args CONF_FILES NAMES) endif() @@ -2640,14 +2657,22 @@ Relative paths are only allowed with `-D${ARGV1}=`") set(dts_filename_list ${ZFILE_NAMES}) set(kconf_filename_list ${ZFILE_NAMES}) else() - zephyr_build_string(filename_list - SHORT shortened_filename_list - BOARD ${ZFILE_BOARD} - BOARD_REVISION ${ZFILE_BOARD_REVISION} - BOARD_QUALIFIERS ${ZFILE_BOARD_QUALIFIERS} - BUILD ${ZFILE_BUILD} - MERGE REVERSE - ) + if(NOT ZFILE_QUALIFIERS) + zephyr_build_string(filename_list + SHORT shortened_filename_list + BOARD ${ZFILE_BOARD} + BOARD_REVISION ${ZFILE_BOARD_REVISION} + BOARD_QUALIFIERS ${ZFILE_BOARD_QUALIFIERS} + BUILD ${ZFILE_BUILD} + MERGE REVERSE + ) + else() + zephyr_build_string(filename_list + BOARD_QUALIFIERS ${ZFILE_BOARD_QUALIFIERS} + BUILD ${ZFILE_BUILD} + MERGE REVERSE + ) + endif() set(dts_filename_list ${filename_list}) set(dts_shortened_filename_list ${shortened_filename_list}) @@ -2865,9 +2890,9 @@ endfunction() # function(zephyr_file_suffix filename) set(single_args SUFFIX) - cmake_parse_arguments(FILE "" "${single_args}" "" ${ARGN}) + cmake_parse_arguments(SFILE "" "${single_args}" "" ${ARGN}) - if(NOT DEFINED FILE_SUFFIX OR NOT DEFINED ${filename}) + if(NOT DEFINED SFILE_SUFFIX OR NOT DEFINED ${filename}) # If the file suffix variable is not known then there is nothing to do, return early return() endif() @@ -2883,7 +2908,7 @@ function(zephyr_file_suffix filename) # Search for the full stop so we know where to add the file suffix before the file extension cmake_path(GET file EXTENSION file_ext) cmake_path(REMOVE_EXTENSION file OUTPUT_VARIABLE new_filename) - cmake_path(APPEND_STRING new_filename "_${FILE_SUFFIX}${file_ext}") + cmake_path(APPEND_STRING new_filename "_${SFILE_SUFFIX}${file_ext}") # Use the filename with the suffix if it exists, if not then fall back to the default if(EXISTS "${new_filename}") diff --git a/cmake/modules/kconfig.cmake b/cmake/modules/kconfig.cmake index 01fbdf73f3c0..b337b7a1f9b5 100644 --- a/cmake/modules/kconfig.cmake +++ b/cmake/modules/kconfig.cmake @@ -168,6 +168,7 @@ set(COMMON_KCONFIG_ENV_SETTINGS TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR} TOOLCHAIN_HAS_NEWLIB=${_local_TOOLCHAIN_HAS_NEWLIB} TOOLCHAIN_HAS_PICOLIBC=${_local_TOOLCHAIN_HAS_PICOLIBC} + HIDE_CHILD_PARENT_CONFIG=${SYSBUILD} EDT_PICKLE=${EDT_PICKLE} # Export all Zephyr modules to Kconfig ${ZEPHYR_KCONFIG_MODULES_DIR} diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index a093d46691fd..06e1642f3629 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -243,3 +243,7 @@ if("${CMAKE_EXTRA_GENERATOR}" STREQUAL "Eclipse CDT4") include(${ZEPHYR_BASE}/cmake/ide/eclipse_cdt4_generator_amendment.cmake) eclipse_cdt4_generator_amendment(1) endif() + +if(ZEPHYR_NRF_MODULE_DIR) + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/partition_manager.cmake) +endif() diff --git a/cmake/modules/snippets.cmake b/cmake/modules/snippets.cmake index 550d236a2f4a..6f8950c5f64a 100644 --- a/cmake/modules/snippets.cmake +++ b/cmake/modules/snippets.cmake @@ -59,6 +59,7 @@ function(zephyr_process_snippets) # Set SNIPPET_ROOT. list(APPEND SNIPPET_ROOT ${APPLICATION_SOURCE_DIR}) list(APPEND SNIPPET_ROOT ${ZEPHYR_BASE}) + list(APPEND SNIPPET_ROOT ${ZEPHYR_NRF_MODULE_DIR}) unset(real_snippet_root) foreach(snippet_dir ${SNIPPET_ROOT}) # The user might have put a symbolic link in here, for example. diff --git a/cmake/modules/soc_v2.cmake b/cmake/modules/soc_v2.cmake index 6a03dd2cbf0f..606ed690f77f 100644 --- a/cmake/modules/soc_v2.cmake +++ b/cmake/modules/soc_v2.cmake @@ -27,6 +27,6 @@ if(HWMv2) set(SOC_TOOLCHAIN_NAME ${CONFIG_SOC_TOOLCHAIN_NAME}) set(SOC_FAMILY ${CONFIG_SOC_FAMILY}) set(SOC_V2_DIR ${SOC_${SOC_NAME}_DIR}) - set(SOC_FULL_DIR ${SOC_V2_DIR}) + set(SOC_FULL_DIR ${SOC_V2_DIR} CACHE PATH "Path to the SoC directory." FORCE) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${SOC_V2_DIR}/soc.yml) endif() diff --git a/doc/build/dts/howtos.rst b/doc/build/dts/howtos.rst index cb556bb782d6..c6ee5a80d302 100644 --- a/doc/build/dts/howtos.rst +++ b/doc/build/dts/howtos.rst @@ -237,11 +237,10 @@ If you don't set :makevar:`DTC_OVERLAY_FILE`, the build system will follow these steps, looking for files in your application configuration directory to use as devicetree overlays: -#. If the file :file:`boards/.overlay` exists, it will be used. +#. If the file :file:`socs/_.overlay` exists, it will be used. +#. If the file :file:`boards/.overlay` exists, it will be used in addition to the above. #. If the current board has :ref:`multiple revisions ` - and :file:`boards/_.overlay` exists, it will be used. - This file will be used in addition to :file:`boards/.overlay` - if both exist. + and :file:`boards/_.overlay` exists, it will be used in addition to the above. #. If one or more files have been found in the previous steps, the build system stops looking and just uses those files. #. Otherwise, if :file:`.overlay` exists, it will be used, and the build diff --git a/doc/build/flashing/configuration.rst b/doc/build/flashing/configuration.rst new file mode 100644 index 000000000000..0611420ce173 --- /dev/null +++ b/doc/build/flashing/configuration.rst @@ -0,0 +1,106 @@ +.. _flashing-soc-board-config: + +Flashing configuration +###################### + +Zephyr supports setting up configuration for flash runners (invoked from +:ref:`west flash`) which allows for customising how commands are used when +programming boards. This configuration is used for :ref:`sysbuild` projects and allows for +configuring when commands are ran for groups of board targets. As an example: a multi-core SoC +might want to only allow the ``--erase`` argument to be used once for all of the cores in the SoC +which would prevent multiple erase tasks running in a single ``west flash`` invocation, which +could wrongly clear the memory which is used by the other images being programmed. + +Priority +******** + +Flashing configuration is singular, it will only be read from a single location, this +configuration can reside in the following files starting with the highest priority: + + * ``soc.yml`` (in soc folder) + * ``board.yml`` (in board folder) + +Configuration +************* + +Configuration is applied in the yml file by using a ``runners`` map with a single ``run_once`` +child, this then contains a map of commands as they would be provided to the flash runner e.g. +``--reset`` followed by a list which specifies the settings for each of these commands (these +are grouped by flash runner, and by qualifiers/boards). Commands have associated runners that +they apply to using a ``runners`` list value, this can contain ``all`` if it applies to all +runners, otherwise must contain each runner that it applies to using the runner-specific name. +Groups of board targets can be specified using the ``groups`` key which has a list of board +target sets. Board targets are regular expression matches, for ``soc.yml`` files each set of +board targets must be in a ``qualifiers`` key (only regular expression matches for board +qualifiers are allowed, board names must be omitted from these entries). For ``board.yml`` +files each set of board targets must be in a ``boards`` key, these are lists containing the +matches which form a singular group. A final parameter ``run`` can be set to ``first`` which +means that the command will be ran once with the first image flashing process per set of board +targets, or to ``last`` which will be ran once for the final image flash per set of board targets. + +An example flashing configuration for a ``soc.yml`` is shown below in which the ``--recover`` +command will only be used once for any board targets which used the nRF5340 SoC application or +network CPU cores, and will only reset the network or application core after all images for the +respective core have been flashed. + +.. code-block:: yaml + + runners: + run_once: + '--recover': + - run: first + runners: + - nrfjprog + groups: + - qualifiers: + - nrf5340/cpunet + - nrf5340/cpuapp + - nrf5340/cpuapp/ns + '--reset': + - run: last + runners: + - nrfjprog + - jlink + groups: + - qualifiers: + - nrf5340/cpunet + - qualifiers: + - nrf5340/cpuapp + - nrf5340/cpuapp/ns + # Made up non-real world example to show how to specify different options for different + # flash runners + - run: first + runners: + - some_other_runner + groups: + - qualifiers: + - nrf5340/cpunet + - qualifiers: + - nrf5340/cpuapp + - nrf5340/cpuapp/ns + +Usage +***** + +Commands that are supported by flash runners can be used as normal when flashing non-sysbuild +applications, the run once configuration will not be used. When flashing a sysbuild project with +multiple images, the flash runner run once configuration will be applied. + +For example, building the :zephyr:code-sample:`smp-svr` sample for the nrf5340dk which will +include MCUboot as a secondary image: + +.. code-block:: console + + cmake -GNinja -Sshare/sysbuild/ -Bbuild -DBOARD=nrf5340dk/nrf5340/cpuapp -DAPP_DIR=samples/subsys/mgmt/mcumgr/smp_svr + cmake --build build + +Once built with an nrf5340dk connected, the following command can be used to flash the board with +both applications and will only perform a single device recovery operation when programming the +first image: + +.. code-block:: console + + west flash --recover + +If the above was ran without the flashing configuration, the recovery process would be ran twice +and the device would be unbootable. diff --git a/doc/build/flashing/index.rst b/doc/build/flashing/index.rst new file mode 100644 index 000000000000..003dba418eaa --- /dev/null +++ b/doc/build/flashing/index.rst @@ -0,0 +1,9 @@ +.. _flashing: + +Flashing +######## + +.. toctree:: + :maxdepth: 1 + + configuration.rst diff --git a/doc/build/index.rst b/doc/build/index.rst index 4a3e76be3073..91bf4c6018c1 100644 --- a/doc/build/index.rst +++ b/doc/build/index.rst @@ -15,3 +15,4 @@ Build and Configuration Systems zephyr_cmake_package.rst sysbuild/index.rst version/index.rst + flashing/index.rst diff --git a/doc/build/kconfig/setting.rst b/doc/build/kconfig/setting.rst index 57dd7828978c..ba3ee33938a8 100644 --- a/doc/build/kconfig/setting.rst +++ b/doc/build/kconfig/setting.rst @@ -7,8 +7,7 @@ The :ref:`menuconfig and guiconfig interfaces ` can be used to test out configurations during application development. This page explains how to make settings permanent. -All Kconfig options can be searched in the :ref:`Kconfig search page -`. +All Kconfig options can be searched in the Kconfig search page. .. note:: @@ -115,8 +114,7 @@ Assignments in configuration files are only respected if the dependencies for the symbol are satisfied. A warning is printed otherwise. To figure out what the dependencies of a symbol are, use one of the :ref:`interactive configuration interfaces ` (you can jump directly to a symbol with -:kbd:`/`), or look up the symbol in the :ref:`Kconfig search page -`. +:kbd:`/`), or look up the symbol in the Kconfig search page. .. _initial-conf: @@ -153,7 +151,8 @@ used. form :file:`prj_.conf` and if file :file:`boards/_.conf` exists in same folder as file :file:`prj_.conf`, the result of merging :file:`prj_.conf` and - :file:`boards/_.conf` is used. + :file:`boards/_.conf` is used - note that this feature is + deprecated, :ref:`application-file-suffixes` should be used instead. #. Otherwise, :file:`prj_.conf` is used if it exists in the application configuration directory. @@ -170,6 +169,11 @@ used. #. Otherwise, :file:`prj.conf` is used from the application configuration directory. If it does not exist then a fatal error will be emitted. +Furthermore, applications can have SoC overlay configuration that is applied to +it, the file :file:`socs/_.conf` will be applied if it exists, +after the main project configuration has been applied and before any board overlay +configuration files have been applied. + All configuration files will be taken from the application's configuration directory except for files with an absolute path that are given with the ``CONF_FILE``, ``EXTRA_CONF_FILE``, ``DTC_OVERLAY_FILE``, and diff --git a/doc/connectivity/networking/api/mqtt.rst b/doc/connectivity/networking/api/mqtt.rst index b232f125333d..79da5abe57be 100644 --- a/doc/connectivity/networking/api/mqtt.rst +++ b/doc/connectivity/networking/api/mqtt.rst @@ -150,6 +150,7 @@ additional configuration information: tls_config->sec_tag_list = m_sec_tags; tls_config->sec_tag_count = ARRAY_SIZE(m_sec_tags); tls_config->hostname = MQTT_BROKER_HOSTNAME; + tls_config->set_native_tls = true; In this sample code, the ``m_sec_tags`` array holds a list of tags, referencing TLS credentials that the MQTT library should use for authentication. We do not specify @@ -162,6 +163,8 @@ Note, that TLS credentials referenced by the ``m_sec_tags`` array must be registered in the system first. For more information on how to do that, refer to :ref:`secure sockets documentation `. +Finally, ``set_native_tls`` can be optionally set to enable native TLS support instead of offloading TLS operations to the modem. + An example of how to use TLS with MQTT is also present in :zephyr:code-sample:`mqtt-publisher` sample application. diff --git a/doc/develop/application/index.rst b/doc/develop/application/index.rst index 9866a12ba4c5..560ba9519691 100644 --- a/doc/develop/application/index.rst +++ b/doc/develop/application/index.rst @@ -650,9 +650,8 @@ started. See :ref:`setting_configuration_values` for detailed documentation on setting Kconfig configuration values. The :ref:`initial-conf` section on the same page -explains how the initial configuration is derived. See :ref:`kconfig-search` -for a complete list of configuration options. -See :ref:`hardening` for security information related with Kconfig options. +explains how the initial configuration is derived. See :ref:`hardening` for +security information related with Kconfig options. The other pages in the :ref:`Kconfig section of the manual ` are also worth going through, especially if you planning to add new configuration diff --git a/doc/kconfig.rst b/doc/kconfig.rst deleted file mode 100644 index 1123de2adbd9..000000000000 --- a/doc/kconfig.rst +++ /dev/null @@ -1,8 +0,0 @@ -:orphan: - -.. _kconfig-search: - -Kconfig Search -============== - -.. kconfig:search:: diff --git a/doc/releases/release-notes-3.7.rst b/doc/releases/release-notes-3.7.rst index a98211d48acf..d362eac05983 100644 --- a/doc/releases/release-notes-3.7.rst +++ b/doc/releases/release-notes-3.7.rst @@ -178,6 +178,9 @@ Drivers and Sensors * Wi-Fi + * Added support for configuring RTS threshold. With this, users can set the RTS threshold value or + disable the RTS mechanism. + Networking ********** diff --git a/drivers/adc/adc_nrfx_saadc.c b/drivers/adc/adc_nrfx_saadc.c index 6d1973ca0aae..e5e658c893ae 100644 --- a/drivers/adc/adc_nrfx_saadc.c +++ b/drivers/adc/adc_nrfx_saadc.c @@ -6,7 +6,7 @@ #define ADC_CONTEXT_USES_KERNEL_TIMER #include "adc_context.h" -#include +#include #include #define LOG_LEVEL CONFIG_ADC_LOG_LEVEL @@ -16,6 +16,20 @@ LOG_MODULE_REGISTER(adc_nrfx_saadc); #define DT_DRV_COMPAT nordic_nrf_saadc +#if (NRF_SAADC_HAS_AIN_AS_PIN) + +static const uint8_t saadc_psels[NRF_SAADC_AIN7 + 1] = { + [NRF_SAADC_AIN0] = NRF_PIN_PORT_TO_PIN_NUMBER(4U, 1), + [NRF_SAADC_AIN1] = NRF_PIN_PORT_TO_PIN_NUMBER(5U, 1), + [NRF_SAADC_AIN2] = NRF_PIN_PORT_TO_PIN_NUMBER(6U, 1), + [NRF_SAADC_AIN3] = NRF_PIN_PORT_TO_PIN_NUMBER(7U, 1), + [NRF_SAADC_AIN4] = NRF_PIN_PORT_TO_PIN_NUMBER(11U, 1), + [NRF_SAADC_AIN5] = NRF_PIN_PORT_TO_PIN_NUMBER(12U, 1), + [NRF_SAADC_AIN6] = NRF_PIN_PORT_TO_PIN_NUMBER(13U, 1), + [NRF_SAADC_AIN7] = NRF_PIN_PORT_TO_PIN_NUMBER(14U, 1), +}; + +#else BUILD_ASSERT((NRF_SAADC_AIN0 == NRF_SAADC_INPUT_AIN0) && (NRF_SAADC_AIN1 == NRF_SAADC_INPUT_AIN1) && (NRF_SAADC_AIN2 == NRF_SAADC_INPUT_AIN2) && @@ -28,8 +42,12 @@ BUILD_ASSERT((NRF_SAADC_AIN0 == NRF_SAADC_INPUT_AIN0) && #if defined(SAADC_CH_PSELP_PSELP_VDDHDIV5) (NRF_SAADC_VDDHDIV5 == NRF_SAADC_INPUT_VDDHDIV5) && #endif - (NRF_SAADC_VDD == NRF_SAADC_INPUT_VDD), +#if defined(SAADC_CH_PSELP_PSELP_VDD) + (NRF_SAADC_VDD == NRF_SAADC_INPUT_VDD) && +#endif + 1, "Definitions from nrf-adc.h do not match those from nrf_saadc.h"); +#endif struct driver_data { struct adc_context ctx; @@ -43,85 +61,158 @@ static struct driver_data m_data = { ADC_CONTEXT_INIT_SYNC(m_data, ctx), }; +/* Helper function to convert number of samples to the byte representation. */ +static uint32_t samples_to_bytes(const struct adc_sequence *sequence, uint16_t number_of_samples) +{ + if (NRF_SAADC_8BIT_SAMPLE_WIDTH == 8 && sequence->resolution == 8) { + return number_of_samples; + } + + return number_of_samples * 2; +} + +/* Helper function to convert acquisition time to register TACQ value. */ +static int adc_convert_acq_time(uint16_t acquisition_time, nrf_saadc_acqtime_t *p_tacq_val) +{ + int result = 0; + +#if NRF_SAADC_HAS_ACQTIME_ENUM + switch (acquisition_time) { + case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 3): + *p_tacq_val = NRF_SAADC_ACQTIME_3US; + break; + case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 5): + *p_tacq_val = NRF_SAADC_ACQTIME_5US; + break; + case ADC_ACQ_TIME_DEFAULT: + case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 10): + *p_tacq_val = NRF_SAADC_ACQTIME_10US; + break; + case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 15): + *p_tacq_val = NRF_SAADC_ACQTIME_15US; + break; + case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 20): + *p_tacq_val = NRF_SAADC_ACQTIME_20US; + break; + case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40): + *p_tacq_val = NRF_SAADC_ACQTIME_40US; + break; + default: + result = -EINVAL; + } +#else +#define MINIMUM_ACQ_TIME_IN_NS 125 +#define DEFAULT_ACQ_TIME_IN_NS 10000 + + nrf_saadc_acqtime_t tacq = 0; + uint16_t acq_time = + (acquisition_time == ADC_ACQ_TIME_DEFAULT + ? DEFAULT_ACQ_TIME_IN_NS + : (ADC_ACQ_TIME_VALUE(acquisition_time) * + (ADC_ACQ_TIME_UNIT(acquisition_time) == ADC_ACQ_TIME_MICROSECONDS + ? 1000 + : 1))); + + tacq = (nrf_saadc_acqtime_t)(acq_time / MINIMUM_ACQ_TIME_IN_NS) - 1; + if ((tacq > NRF_SAADC_ACQTIME_MAX) || (acq_time < MINIMUM_ACQ_TIME_IN_NS)) { + result = -EINVAL; + } else { + *p_tacq_val = tacq; + } +#endif + + return result; +} /* Implementation of the ADC driver API function: adc_channel_setup. */ static int adc_nrfx_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { nrf_saadc_channel_config_t config = { - .resistor_p = NRF_SAADC_RESISTOR_DISABLED, - .resistor_n = NRF_SAADC_RESISTOR_DISABLED, - .burst = NRF_SAADC_BURST_DISABLED, +#if NRF_SAADC_HAS_CH_CONFIG_RES + .resistor_p = NRF_SAADC_RESISTOR_DISABLED, + .resistor_n = NRF_SAADC_RESISTOR_DISABLED, +#endif + .burst = NRF_SAADC_BURST_DISABLED, }; uint8_t channel_id = channel_cfg->channel_id; + uint32_t input_negative = channel_cfg->input_negative; if (channel_id >= SAADC_CH_NUM) { return -EINVAL; } switch (channel_cfg->gain) { +#if defined(SAADC_CH_CONFIG_GAIN_Gain1_6) case ADC_GAIN_1_6: config.gain = NRF_SAADC_GAIN1_6; break; +#endif +#if defined(SAADC_CH_CONFIG_GAIN_Gain1_5) case ADC_GAIN_1_5: config.gain = NRF_SAADC_GAIN1_5; break; +#endif +#if defined(SAADC_CH_CONFIG_GAIN_Gain1_4) case ADC_GAIN_1_4: config.gain = NRF_SAADC_GAIN1_4; break; +#endif +#if defined(SAADC_CH_CONFIG_GAIN_Gain1_3) case ADC_GAIN_1_3: config.gain = NRF_SAADC_GAIN1_3; break; +#endif +#if defined(SAADC_CH_CONFIG_GAIN_Gain1_2) case ADC_GAIN_1_2: config.gain = NRF_SAADC_GAIN1_2; break; +#endif +#if defined(SAADC_CH_CONFIG_GAIN_Gain2_3) + case ADC_GAIN_2_3: + config.gain = NRF_SAADC_GAIN2_3; + break; +#endif case ADC_GAIN_1: config.gain = NRF_SAADC_GAIN1; break; case ADC_GAIN_2: config.gain = NRF_SAADC_GAIN2; break; +#if defined(SAADC_CH_CONFIG_GAIN_Gain4) case ADC_GAIN_4: config.gain = NRF_SAADC_GAIN4; break; +#endif default: LOG_ERR("Selected ADC gain is not valid"); return -EINVAL; } switch (channel_cfg->reference) { +#if defined(SAADC_CH_CONFIG_REFSEL_Internal) case ADC_REF_INTERNAL: config.reference = NRF_SAADC_REFERENCE_INTERNAL; break; +#endif +#if defined(SAADC_CH_CONFIG_REFSEL_VDD1_4) case ADC_REF_VDD_1_4: config.reference = NRF_SAADC_REFERENCE_VDD4; break; +#endif +#if defined(SAADC_CH_CONFIG_REFSEL_External) + case ADC_REF_EXTERNAL0: + config.reference = NRF_SAADC_REFERENCE_EXTERNAL; + break; +#endif default: LOG_ERR("Selected ADC reference is not valid"); return -EINVAL; } - switch (channel_cfg->acquisition_time) { - case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 3): - config.acq_time = NRF_SAADC_ACQTIME_3US; - break; - case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 5): - config.acq_time = NRF_SAADC_ACQTIME_5US; - break; - case ADC_ACQ_TIME_DEFAULT: - case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 10): - config.acq_time = NRF_SAADC_ACQTIME_10US; - break; - case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 15): - config.acq_time = NRF_SAADC_ACQTIME_15US; - break; - case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 20): - config.acq_time = NRF_SAADC_ACQTIME_20US; - break; - case ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40): - config.acq_time = NRF_SAADC_ACQTIME_40US; - break; - default: + int ret = adc_convert_acq_time(channel_cfg->acquisition_time, &config.acq_time); + + if (ret) { LOG_ERR("Selected ADC acquisition time is not valid"); return -EINVAL; } @@ -134,17 +225,37 @@ static int adc_nrfx_channel_setup(const struct device *dev, * in a sampling sequence. */ - nrf_saadc_channel_init(NRF_SAADC, channel_id, &config); - nrf_saadc_channel_input_set(NRF_SAADC, - channel_id, - NRF_SAADC_INPUT_DISABLED, - channel_cfg->input_negative); +#if (NRF_SAADC_HAS_AIN_AS_PIN) + if ((channel_cfg->input_positive > NRF_SAADC_AIN7) || + (channel_cfg->input_positive < NRF_SAADC_AIN0)) { + return -EINVAL; + } + + if (config.mode == NRF_SAADC_MODE_DIFFERENTIAL) { + if (input_negative > NRF_SAADC_AIN7 || + input_negative < NRF_SAADC_AIN0) { + return -EINVAL; + } + + input_negative = saadc_psels[input_negative]; + } else { + input_negative = NRF_SAADC_INPUT_DISABLED; + } /* Store the positive input selection in a dedicated array, * to get it later when the channel is selected for a sampling * and to mark the channel as configured (ready to be selected). */ + m_data.positive_inputs[channel_id] = saadc_psels[channel_cfg->input_positive]; +#else m_data.positive_inputs[channel_id] = channel_cfg->input_positive; +#endif + + nrf_saadc_channel_init(NRF_SAADC, channel_id, &config); + nrf_saadc_channel_input_set(NRF_SAADC, + channel_id, + NRF_SAADC_INPUT_DISABLED, + input_negative); return 0; } @@ -168,10 +279,11 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx, ARG_UNUSED(ctx); if (!repeat) { - nrf_saadc_buffer_pointer_set( - NRF_SAADC, - (uint16_t *)nrf_saadc_buffer_pointer_get(NRF_SAADC) + - nrf_saadc_amount_get(NRF_SAADC)); + nrf_saadc_value_t *buffer = + (uint8_t *)nrf_saadc_buffer_pointer_get(NRF_SAADC) + + samples_to_bytes(&ctx->sequence, nrfy_saadc_amount_get(NRF_SAADC)); + + nrfy_saadc_buffer_pointer_set(NRF_SAADC, buffer); } } @@ -256,7 +368,8 @@ static int check_buffer_size(const struct adc_sequence *sequence, { size_t needed_buffer_size; - needed_buffer_size = active_channels * sizeof(uint16_t); + needed_buffer_size = samples_to_bytes(sequence, active_channels); + if (sequence->options) { needed_buffer_size *= (1 + sequence->options->extra_samplings); } @@ -429,7 +542,11 @@ static const struct adc_driver_api adc_nrfx_driver_api = { #ifdef CONFIG_ADC_ASYNC .read_async = adc_nrfx_read_async, #endif +#if defined(CONFIG_SOC_NRF54L15) + .ref_internal = 900, +#else .ref_internal = 600, +#endif }; /* diff --git a/drivers/bluetooth/hci/nrf53_support.c b/drivers/bluetooth/hci/nrf53_support.c index 995586eb3259..2d0f64ac4284 100644 --- a/drivers/bluetooth/hci/nrf53_support.c +++ b/drivers/bluetooth/hci/nrf53_support.c @@ -6,7 +6,7 @@ #include #include -#include +#include #if defined(CONFIG_BT_CTLR_DEBUG_PINS_CPUAPP) #include <../subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/debug.h> #else @@ -21,7 +21,7 @@ int bt_hci_transport_teardown(const struct device *dev) { ARG_UNUSED(dev); /* Put the Network MCU in Forced-OFF mode. */ - nrf_reset_network_force_off(NRF_RESET, true); + nrf53_cpunet_enable(false); LOG_DBG("Network MCU placed in Forced-OFF mode"); return 0; @@ -43,7 +43,7 @@ int bt_hci_transport_setup(const struct device *dev) #endif /* !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) */ /* Release the Network MCU, 'Release force off signal' */ - nrf_reset_network_force_off(NRF_RESET, false); + nrf53_cpunet_enable(true); return 0; } diff --git a/drivers/cache/Kconfig.nrf b/drivers/cache/Kconfig.nrf index 820445db432f..c1cfc2c8c582 100644 --- a/drivers/cache/Kconfig.nrf +++ b/drivers/cache/Kconfig.nrf @@ -7,3 +7,9 @@ config CACHE_NRF_CACHE depends on HAS_NRFX && CACHE_MANAGEMENT help Enable support for the nRF cache driver. + +config CACHE_NRF_PATCH_LINEADDR + bool "Patch lineaddr" + default y if SOC_NRF54H20 + help + Manually set 28th bit in the LINEADDR in Trustzone Secure build. diff --git a/drivers/cache/cache_nrf.c b/drivers/cache/cache_nrf.c index 63d76a47d6ef..3cf798978749 100644 --- a/drivers/cache/cache_nrf.c +++ b/drivers/cache/cache_nrf.c @@ -14,10 +14,8 @@ LOG_MODULE_REGISTER(cache_nrfx, CONFIG_CACHE_LOG_LEVEL); #define NRF_ICACHE NRF_CACHE #endif -#define CACHE_LINE_SIZE 32 #define CACHE_BUSY_RETRY_INTERVAL_US 10 -static struct k_spinlock lock; enum k_nrf_cache_op { /* @@ -55,7 +53,6 @@ static inline bool is_cache_busy(NRF_CACHE_Type *cache) static inline void wait_for_cache(NRF_CACHE_Type *cache) { while (is_cache_busy(cache)) { - k_busy_wait(CACHE_BUSY_RETRY_INTERVAL_US); } } @@ -68,14 +65,6 @@ static inline int _cache_all(NRF_CACHE_Type *cache, enum k_nrf_cache_op op) return -ENOTSUP; } - k_spinlock_key_t key = k_spin_lock(&lock); - - /* - * Invalidating the whole cache is dangerous. For good measure - * disable the cache. - */ - nrf_cache_disable(cache); - wait_for_cache(cache); switch (op) { @@ -102,66 +91,68 @@ static inline int _cache_all(NRF_CACHE_Type *cache, enum k_nrf_cache_op op) wait_for_cache(cache); - nrf_cache_enable(cache); - - k_spin_unlock(&lock, key); - return 0; } static inline void _cache_line(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, uintptr_t line_addr) { - wait_for_cache(cache); + do { + wait_for_cache(cache); - nrf_cache_lineaddr_set(cache, line_addr); + nrf_cache_lineaddr_set(cache, line_addr); - switch (op) { + switch (op) { #if NRF_CACHE_HAS_TASK_CLEAN - case K_NRF_CACHE_CLEAN: - nrf_cache_task_trigger(cache, NRF_CACHE_TASK_CLEANLINE); - break; + case K_NRF_CACHE_CLEAN: + nrf_cache_task_trigger(cache, NRF_CACHE_TASK_CLEANLINE); + break; #endif - case K_NRF_CACHE_INVD: - nrf_cache_task_trigger(cache, NRF_CACHE_TASK_INVALIDATELINE); - break; + case K_NRF_CACHE_INVD: + nrf_cache_task_trigger(cache, NRF_CACHE_TASK_INVALIDATELINE); + break; #if NRF_CACHE_HAS_TASK_FLUSH - case K_NRF_CACHE_FLUSH: - nrf_cache_task_trigger(cache, NRF_CACHE_TASK_FLUSHLINE); - break; + case K_NRF_CACHE_FLUSH: + nrf_cache_task_trigger(cache, NRF_CACHE_TASK_FLUSHLINE); + break; #endif - default: - break; - } - - wait_for_cache(cache); + default: + break; + } + } while (nrf_cache_lineaddr_get(cache) != line_addr); } static inline int _cache_range(NRF_CACHE_Type *cache, enum k_nrf_cache_op op, void *addr, size_t size) { uintptr_t line_addr = (uintptr_t)addr; - uintptr_t end_addr = line_addr + size; + uintptr_t end_addr; + + /* Some SOCs has a bug that requires to set 28th bit in the address on + * Trustzone secure builds. + */ + if (IS_ENABLED(CONFIG_CACHE_NRF_PATCH_LINEADDR) && + !IS_ENABLED(CONFIG_TRUSTED_EXECUTION_NONSECURE)) { + line_addr |= BIT(28); + } + + end_addr = line_addr + size; /* * Align address to line size */ - line_addr &= ~(CACHE_LINE_SIZE - 1); + line_addr &= ~(CONFIG_DCACHE_LINE_SIZE - 1); do { - k_spinlock_key_t key = k_spin_lock(&lock); - _cache_line(cache, op, line_addr); - - k_spin_unlock(&lock, key); - - line_addr += CACHE_LINE_SIZE; - + line_addr += CONFIG_DCACHE_LINE_SIZE; } while (line_addr < end_addr); + wait_for_cache(cache); + return 0; } @@ -192,11 +183,6 @@ void cache_data_enable(void) nrf_cache_enable(NRF_DCACHE); } -void cache_data_disable(void) -{ - nrf_cache_disable(NRF_DCACHE); -} - int cache_data_flush_all(void) { #if NRF_CACHE_HAS_TASK_CLEAN @@ -206,6 +192,14 @@ int cache_data_flush_all(void) #endif } +void cache_data_disable(void) +{ + if (nrf_cache_enable_check(NRF_DCACHE)) { + (void)cache_data_flush_all(); + } + nrf_cache_disable(NRF_DCACHE); +} + int cache_data_invd_all(void) { return _cache_checks(NRF_DCACHE, K_NRF_CACHE_INVD, NULL, 0, false); diff --git a/drivers/clock_control/Kconfig.nrf b/drivers/clock_control/Kconfig.nrf index 453aac5b5d07..725a76949869 100644 --- a/drivers/clock_control/Kconfig.nrf +++ b/drivers/clock_control/Kconfig.nrf @@ -130,7 +130,9 @@ endif # CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION choice CLOCK_CONTROL_NRF_ACCURACY_PPM prompt "32KHz clock accuracy" - default CLOCK_CONTROL_NRF_K32SRC_500PPM if CLOCK_CONTROL_NRF_K32SRC_RC + default CLOCK_CONTROL_NRF_K32SRC_500PPM if CLOCK_CONTROL_NRF_K32SRC_RC && SOC_COMPATIBLE_NRF52X + default CLOCK_CONTROL_NRF_K32SRC_250PPM if CLOCK_CONTROL_NRF_K32SRC_RC + default CLOCK_CONTROL_NRF_K32SRC_150PPM if CLOCK_CONTROL_NRF_K32SRC_XTAL && SOC_SERIES_NRF54LX default CLOCK_CONTROL_NRF_K32SRC_50PPM config CLOCK_CONTROL_NRF_K32SRC_500PPM diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index 6336ad4dfd03..3e43716c2b3c 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -420,6 +420,8 @@ static const struct disk_operations flash_disk_ops = { .ioctl = disk_flash_access_ioctl, }; +#ifndef USE_PARTITION_MANAGER +/* The non-Partition manager, DTS based generators below */ #define DT_DRV_COMPAT zephyr_flash_disk #define PARTITION_PHANDLE(n) DT_PHANDLE_BY_IDX(DT_DRV_INST(n), partition, 0) @@ -461,6 +463,82 @@ DT_INST_FOREACH_STATUS_OKAY(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY) "Devicetree node " DT_NODE_PATH(DT_DRV_INST(n)) \ " has cache size which is not a multiple of its sector size"); DT_INST_FOREACH_STATUS_OKAY(VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE) +#else /* ifndef USE_PARTITION_MANAGER */ +/* Partition Manager based generators below */ + +/* Gets the PM_..._EXTRA_PARAM_##param value */ +#define PM_FLASH_DISK_ENTRY_EXTRA_PARAM(name, param) PM_##name##_EXTRA_PARAM_disk_##param + +/* Gets the PM_..._NAME value which is originally cased, as in yaml, partition name */ +#define PM_FLASH_DISK_ENTRY_PARTITION_NAME(name) PM_##name##_NAME + +/* Generates flashdiskN_cache variable name, where N is partition ID */ +#define PM_FLASH_DISK_CACHE_VARIABLE(n) UTIL_CAT(flashdisk, UTIL_CAT(FIXED_PARTITION_ID(n), _cache)) + +/* Generate cache buffers */ +#define CACHE_SIZE(n) (COND_CODE_1(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, read_only), (0), (1)) * \ + PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size)) +#define DEFINE_FLASHDISKS_CACHE(n) \ + static uint8_t __aligned(4) PM_FLASH_DISK_CACHE_VARIABLE(n)[CACHE_SIZE(n)]; + +PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE) + +/* Generated single Flash Disk device data from Partition Manager partition. + * Partition is required to have type set to disk in partition definitions: + * type: disk + * and following extra params can be provided: + * extra_params: { + * name = "", + * cache_size = , + * sector_size = , + * read_only = + * } + * where: + * is mandatory device name that will be used by Disk Access and FAT FS to mount device; + * is cache r/w cache size, which is mandatory if read_only = 0 or not present, + * and should be multiple of ; + * is mandatory device sector size information, usually should be erase page size, + * for flash devices, for example 4096 bytes; + * read_only is optional, if not present then assumed false; can be 0(false) or 1(true). + */ +#define DEFINE_FLASHDISKS_DEVICE(n) \ +{ \ + .info = { \ + .ops = &flash_disk_ops, \ + .name = STRINGIFY(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, name)), \ + }, \ + .area_id = FIXED_PARTITION_ID(n), \ + .offset = FIXED_PARTITION_OFFSET(n), \ + .cache = PM_FLASH_DISK_CACHE_VARIABLE(n), \ + .cache_size = sizeof(PM_FLASH_DISK_CACHE_VARIABLE(n)), \ + .size = FIXED_PARTITION_SIZE(n), \ + .sector_size = PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, sector_size), \ +}, + +/* The bellow used PM_FOREACH_TYPE_disk is generated by Partition Manager foreach + * loop macro. The lower case _disk is type name for which the macro has been generated; + * partition entry can have multiple types set and foreach macro will be generated + * for every type found across partition definitions. + */ +static struct flashdisk_data flash_disks[] = { + PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE) +}; + +#define VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY(n) \ + COND_CODE_1(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, read_only), \ + (/* cache-size is not used for read-only disks */), \ + (BUILD_ASSERT(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size) != 0, \ + "Flash disk partition " STRINGIFY(PM_FLASH_DISK_ENTRY_PARTITION_NAME(n))\ + " must have non-zero cache-size");)) +PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY) + +#define VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE(n) \ + BUILD_ASSERT(PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, cache_size) % \ + PM_FLASH_DISK_ENTRY_EXTRA_PARAM(n, sector_size) == 0, \ + "Devicetree node " STRINGIFY(PM_FLASH_DISK_ENTRY_PARTITION_NAME(n)) \ + " has cache size which is not a multiple of its sector size"); +PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_MULTIPLY_OF_SECTOR_SIZE) +#endif /* USE_PARTITION_MANAGER */ static int disk_flash_init(void) { diff --git a/drivers/entropy/CMakeLists.txt b/drivers/entropy/CMakeLists.txt index c3d37e1461a0..1ea31981857a 100644 --- a/drivers/entropy/CMakeLists.txt +++ b/drivers/entropy/CMakeLists.txt @@ -34,6 +34,13 @@ zephyr_library_sources_ifdef(CONFIG_ENTROPY_GECKO_SE entropy_gecko_se. zephyr_library_sources_ifdef(CONFIG_ENTROPY_PSA_CRYPTO_RNG entropy_psa_crypto.c) zephyr_library_sources_ifdef(CONFIG_ENTROPY_NPCX_DRBG entropy_npcx_drbg.c) +if (CONFIG_FAKE_ENTROPY_NRF_PRNG) + zephyr_library_sources(fake_entropy_nrf_prng.c) + + message(WARNING "\nA nRF PRNG is used, which does not produce real random bits." + "This is not secure and should therefore never be used in a product.") +endif() + if (CONFIG_BUILD_WITH_TFM) target_include_directories(${ZEPHYR_CURRENT_LIBRARY} PRIVATE $/api_ns/interface/include diff --git a/drivers/entropy/Kconfig b/drivers/entropy/Kconfig index 34c020256bf7..b14797564608 100644 --- a/drivers/entropy/Kconfig +++ b/drivers/entropy/Kconfig @@ -36,6 +36,7 @@ source "drivers/entropy/Kconfig.neorv32" source "drivers/entropy/Kconfig.bt_hci" source "drivers/entropy/Kconfig.psa_crypto" source "drivers/entropy/Kconfig.npcx" +source "drivers/entropy/Kconfig.nrf_prng" config ENTROPY_HAS_DRIVER bool diff --git a/drivers/entropy/Kconfig.nrf_prng b/drivers/entropy/Kconfig.nrf_prng new file mode 100644 index 000000000000..e1b1a9ab4fe5 --- /dev/null +++ b/drivers/entropy/Kconfig.nrf_prng @@ -0,0 +1,19 @@ +# nRF fake entropy prng generator driver configuration + +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if ENTROPY_GENERATOR + +config FAKE_ENTROPY_NRF_PRNG + bool "A fake nRF entropy driver" + default y + depends on DT_HAS_NORDIC_ENTROPY_PRNG_ENABLED + depends on SOC_SERIES_NRF54HX + select ENTROPY_HAS_DRIVER + help + This is a super simple PRNG driver that can be used on nRF platforms that + do not have an entropy source. + This is NOT SAFE to use for cryptographic operations! + +endif diff --git a/drivers/entropy/Kconfig.psa_crypto b/drivers/entropy/Kconfig.psa_crypto index d06001225b05..18514a071d1c 100644 --- a/drivers/entropy/Kconfig.psa_crypto +++ b/drivers/entropy/Kconfig.psa_crypto @@ -7,6 +7,7 @@ config ENTROPY_PSA_CRYPTO_RNG bool "PSA Crypto Random source Entropy driver" depends on DT_HAS_ZEPHYR_PSA_CRYPTO_RNG_ENABLED select ENTROPY_HAS_DRIVER + select PSA_WANT_GENERATE_RANDOM default y help Enable the PSA Crypto source Entropy driver. diff --git a/drivers/entropy/fake_entropy_nrf_prng.c b/drivers/entropy/fake_entropy_nrf_prng.c new file mode 100644 index 000000000000..8624c8444057 --- /dev/null +++ b/drivers/entropy/fake_entropy_nrf_prng.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#define DT_DRV_COMPAT nordic_entropy_prng + +/* This file implements a pseudo-RNG + * https://vigna.di.unimi.it/xorshift/xoshiro128plus.c + */ + +static uint32_t s[4]; + +static inline uint32_t rotl(const uint32_t x, int k) +{ + return (x << k) | (x >> (32 - k)); +} + +static uint32_t rng_next(void) +{ + const uint32_t result = rotl(s[0] + s[3], 7) + s[0]; + + const uint32_t t = s[1] << 9; + + s[2] ^= s[0]; + s[3] ^= s[1]; + s[1] ^= s[2]; + s[0] ^= s[3]; + + s[2] ^= t; + + s[3] = rotl(s[3], 11); + + return result; +} + +static int entropy_prng_get_entropy(const struct device *dev, uint8_t *buffer, uint16_t length) +{ + ARG_UNUSED(dev); + + while (length) { + /* + * Note that only 1 thread (Zephyr thread or HW models), runs at + * a time, therefore there is no need to use random_r() + */ + uint32_t value = rng_next(); + + size_t to_copy = MIN(length, sizeof(long)); + + memcpy(buffer, &value, to_copy); + buffer += to_copy; + length -= to_copy; + } + + return 0; +} + +static int entropy_prng_get_entropy_isr(const struct device *dev, uint8_t *buf, uint16_t len, + uint32_t flags) +{ + ARG_UNUSED(flags); + + int err; + + /* + * entropy_prng_get_entropy() is also safe for ISRs + * and always produces data. + */ + err = entropy_prng_get_entropy(dev, buf, len); + if (err < 0) { + return err; + } else { + return len; + } +} + +static int entropy_prng_init(const struct device *dev) +{ + ARG_UNUSED(dev); + + /* Picked some arbitrary initial seed. */ + s[0] = 0xAF568BC0; + s[1] = 0xAC34307E; + s[2] = 0x9B7F6DD1; + s[3] = 0xD84319FC; + return 0; +} + +static const struct entropy_driver_api entropy_prng_api_funcs = { + .get_entropy = entropy_prng_get_entropy, .get_entropy_isr = entropy_prng_get_entropy_isr}; + +DEVICE_DT_INST_DEFINE(0, entropy_prng_init, NULL, NULL, NULL, PRE_KERNEL_1, + CONFIG_ENTROPY_INIT_PRIORITY, &entropy_prng_api_funcs); diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index cc840309264e..b5a3fefa1e53 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -37,6 +37,11 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#include +#include +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ + #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 #if defined(CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE) @@ -166,6 +171,12 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER && PM_APP_ADDRESS + if (addr < PM_APP_ADDRESS) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#endif + nrf_nvmc_buffer_read(data, (uint32_t)addr, len); return 0; diff --git a/drivers/flash/spi_nor.c b/drivers/flash/spi_nor.c index 39741df085f0..0b4ab8fba0d1 100644 --- a/drivers/flash/spi_nor.c +++ b/drivers/flash/spi_nor.c @@ -155,7 +155,6 @@ struct spi_nor_config { bool dpd_exist:1; bool dpd_wakeup_sequence_exist:1; bool mxicy_mx25r_power_mode_exist:1; - bool enter_4byte_addr_exist:1; bool reset_gpios_exist:1; bool requires_ulbpr_exist:1; bool wp_gpios_exist:1; @@ -520,10 +519,11 @@ static int exit_dpd(const struct device *const dev) const struct spi_nor_config *cfg = dev->config; if (cfg->dpd_exist) { +#if ANY_INST_HAS_DPD delay_until_exit_dpd_ok(dev); -#if ANY_INST_HAS_DPD_WAKEUP_SEQUENCE if (cfg->dpd_wakeup_sequence_exist) { +#if ANY_INST_HAS_DPD_WAKEUP_SEQUENCE /* Assert CSn and wait for tCRDP. * * Unfortunately the SPI API doesn't allow us to @@ -536,6 +536,7 @@ static int exit_dpd(const struct device *const dev) /* Deassert CSn and wait for tRDP */ k_sleep(K_MSEC(cfg->t_rdp_ms)); +#endif /* DPD_WAKEUP_SEQUENCE */ } else { ret = spi_nor_cmd_write(dev, SPI_NOR_CMD_RDPD); @@ -547,7 +548,7 @@ static int exit_dpd(const struct device *const dev) } #endif /* T_EXIT_DPD */ } -#endif /* DPD_WAKEUP_SEQUENCE */ +#endif /* ANY_INST_HAS_DPD */ } return ret; } @@ -1036,10 +1037,8 @@ static int spi_nor_read_jedec_id(const struct device *dev, static int spi_nor_set_address_mode(const struct device *dev, uint8_t enter_4byte_addr) { - const struct spi_nor_config *cfg = dev->config; - int ret = -ENOSYS; + int ret = 0; - if (cfg->enter_4byte_addr_exist) { /* Do nothing if not provided (either no bits or all bits * set). */ @@ -1074,7 +1073,6 @@ static int spi_nor_set_address_mode(const struct device *dev, } release_device(dev); - } return ret; } @@ -1664,7 +1662,6 @@ static const struct flash_driver_api spi_nor_api = { .dpd_exist = DT_INST_PROP(idx, has_dpd), \ .dpd_wakeup_sequence_exist = DT_INST_NODE_HAS_PROP(idx, dpd_wakeup_sequence), \ .mxicy_mx25r_power_mode_exist = DT_INST_NODE_HAS_PROP(idx, mxicy_mx25r_power_mode), \ - .enter_4byte_addr_exist = DT_INST_NODE_HAS_PROP(idx, enter_4byte_addr), \ .reset_gpios_exist = DT_INST_NODE_HAS_PROP(idx, reset_gpios), \ .requires_ulbpr_exist = DT_INST_PROP(idx, requires_ulbpr), \ .wp_gpios_exist = DT_INST_NODE_HAS_PROP(idx, wp_gpios), \ diff --git a/drivers/pinctrl/pinctrl_nrf.c b/drivers/pinctrl/pinctrl_nrf.c index 950037bc8ab0..0bf09e5e460e 100644 --- a/drivers/pinctrl/pinctrl_nrf.c +++ b/drivers/pinctrl/pinctrl_nrf.c @@ -355,7 +355,8 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, break; case NRF_FUN_QSPI_IO3: NRF_PSEL_QSPI(reg, IO3) = psel; - dir = NRF_GPIO_PIN_DIR_INPUT; + write = 1U; + dir = NRF_GPIO_PIN_DIR_OUTPUT; input = NRF_GPIO_PIN_INPUT_DISCONNECT; break; #endif /* defined(NRF_PSEL_QSPI) */ diff --git a/drivers/pwm/pwm_nrfx.c b/drivers/pwm/pwm_nrfx.c index 9feacb2c10b5..f6312535c7e7 100644 --- a/drivers/pwm/pwm_nrfx.c +++ b/drivers/pwm/pwm_nrfx.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -45,7 +46,6 @@ struct pwm_nrfx_config { struct pwm_nrfx_data { uint32_t period_cycles; - uint16_t seq_values[NRF_PWM_CHANNEL_COUNT]; /* Bit mask indicating channels that need the PWM generation. */ uint8_t pwm_needed; uint8_t prescaler; @@ -56,6 +56,12 @@ struct pwm_nrfx_data { #error "Current implementation supports maximum 8 channels." #endif +static uint16_t *seq_values_ptr_get(const struct device *dev) +{ + const struct pwm_nrfx_config *config = dev->config; + + return (uint16_t *)config->seq.values.p_raw; +} static bool pwm_period_check_and_set(const struct device *dev, uint32_t channel, uint32_t period_cycles) @@ -164,7 +170,7 @@ static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel, needs_pwm = true; } - data->seq_values[channel] = PWM_NRFX_CH_VALUE(compare_value, inverted); + seq_values_ptr_get(dev)[channel] = PWM_NRFX_CH_VALUE(compare_value, inverted); LOG_DBG("channel %u, pulse %u, period %u, prescaler: %u.", channel, pulse_cycles, period_cycles, data->prescaler); @@ -249,7 +255,6 @@ static const struct pwm_driver_api pwm_nrfx_drv_api_funcs = { static int pwm_nrfx_init(const struct device *dev) { const struct pwm_nrfx_config *config = dev->config; - struct pwm_nrfx_data *data = dev->data; uint8_t initially_inverted = 0; int ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); @@ -260,7 +265,7 @@ static int pwm_nrfx_init(const struct device *dev) return ret; } - for (size_t i = 0; i < ARRAY_SIZE(data->seq_values); i++) { + for (size_t i = 0; i < NRF_PWM_CHANNEL_COUNT; i++) { uint32_t psel; if (channel_psel_get(i, &psel, config)) { @@ -273,10 +278,10 @@ static int pwm_nrfx_init(const struct device *dev) } } - for (size_t i = 0; i < ARRAY_SIZE(data->seq_values); i++) { + for (size_t i = 0; i < NRF_PWM_CHANNEL_COUNT; i++) { bool inverted = initially_inverted & BIT(i); - data->seq_values[i] = PWM_NRFX_CH_VALUE(0, inverted); + seq_values_ptr_get(dev)[i] = PWM_NRFX_CH_VALUE(0, inverted); } nrfx_err_t result = nrfx_pwm_init(&config->pwm, @@ -339,10 +344,19 @@ static int pwm_nrfx_pm_action(const struct device *dev, #define PWM(dev_idx) DT_NODELABEL(pwm##dev_idx) #define PWM_PROP(dev_idx, prop) DT_PROP(PWM(dev_idx), prop) +#define PWM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(PWM(idx), prop) + +#define PWM_MEMORY_SECTION(idx) \ + COND_CODE_1(PWM_HAS_PROP(idx, memory_regions), \ + (__attribute__((__section__(LINKER_DT_NODE_REGION_NAME( \ + DT_PHANDLE(PWM(idx), memory_regions)))))), \ + ()) #define PWM_NRFX_DEVICE(idx) \ NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(PWM(idx)); \ static struct pwm_nrfx_data pwm_nrfx_##idx##_data; \ + static uint16_t pwm_##idx##_seq_values[NRF_PWM_CHANNEL_COUNT] \ + PWM_MEMORY_SECTION(idx); \ PINCTRL_DT_DEFINE(PWM(idx)); \ static const struct pwm_nrfx_config pwm_nrfx_##idx##_config = { \ .pwm = NRFX_PWM_INSTANCE(idx), \ @@ -357,7 +371,7 @@ static int pwm_nrfx_pm_action(const struct device *dev, .load_mode = NRF_PWM_LOAD_INDIVIDUAL, \ .step_mode = NRF_PWM_STEP_TRIGGERED, \ }, \ - .seq.values.p_raw = pwm_nrfx_##idx##_data.seq_values, \ + .seq.values.p_raw = pwm_##idx##_seq_values, \ .seq.length = NRF_PWM_CHANNEL_COUNT, \ .pcfg = PINCTRL_DT_DEV_CONFIG_GET(PWM(idx)), \ }; \ diff --git a/drivers/serial/Kconfig.nrfx_uart_instance b/drivers/serial/Kconfig.nrfx_uart_instance index 9e992ca9737a..b8a62084ce5f 100644 --- a/drivers/serial/Kconfig.nrfx_uart_instance +++ b/drivers/serial/Kconfig.nrfx_uart_instance @@ -87,7 +87,7 @@ config UART_$(nrfx_uart_num)_TX_CACHE_SIZE config UART_$(nrfx_uart_num)_RX_CACHE_SIZE int "RX cache buffer size" depends on !UART_NRFX_UARTE_LEGACY_SHIM - default 32 if $(dt_nodelabel_has_compat,ram3x,$(DT_COMPAT_MMIO_SRAM)) + default 32 if $(dt_nodelabel_has_compat,shared_ram3x_region,$(DT_COMPAT_NORDIC_OWNED_MEMORY)) default 5 range 5 255 help diff --git a/drivers/serial/uart_async_rx.c b/drivers/serial/uart_async_rx.c index 7c51a6cd2519..8ee3fc54af1f 100644 --- a/drivers/serial/uart_async_rx.c +++ b/drivers/serial/uart_async_rx.c @@ -126,6 +126,9 @@ void uart_async_rx_reset(struct uart_async_rx *rx_data) { rx_data->free_buf_cnt = rx_data->config->buf_cnt; rx_data->rd_idx = 0; + rx_data->rd_buf_idx = 0; + rx_data->drv_buf_idx = 0; + rx_data->pending_bytes = 0; for (uint8_t i = 0; i < rx_data->config->buf_cnt; i++) { buf_reset(get_buf(rx_data, i)); } diff --git a/drivers/serial/uart_async_to_irq.c b/drivers/serial/uart_async_to_irq.c index 59216cbc13d1..eed05e88e6d4 100644 --- a/drivers/serial/uart_async_to_irq.c +++ b/drivers/serial/uart_async_to_irq.c @@ -107,6 +107,10 @@ static void on_rx_dis(const struct device *dev, struct uart_async_to_irq_data *d if (data->flags & A2I_RX_ENABLE) { int err; + if (data->rx.async_rx.pending_bytes == 0) { + uart_async_rx_reset(&data->rx.async_rx); + } + err = try_rx_enable(dev, data); if (err == 0) { data->rx.pending_buf_req = 0; @@ -331,7 +335,6 @@ int uart_async_to_irq_rx_enable(const struct device *dev) return err; } - uart_async_rx_reset(&data->rx.async_rx); err = try_rx_enable(dev, data); if (err == 0) { @@ -355,6 +358,8 @@ int uart_async_to_irq_rx_disable(const struct device *dev) k_sem_take(&data->rx.sem, K_FOREVER); } + uart_async_rx_reset(&data->rx.async_rx); + return 0; } diff --git a/drivers/serial/uart_nrfx_uarte2.c b/drivers/serial/uart_nrfx_uarte2.c index cf109c32d8e7..ebe85448cea6 100644 --- a/drivers/serial/uart_nrfx_uarte2.c +++ b/drivers/serial/uart_nrfx_uarte2.c @@ -385,6 +385,15 @@ static int api_tx(const struct device *dev, const uint8_t *buf, size_t len, int3 nrfx_err_t err; bool hwfc; +#if CONFIG_PM_DEVICE + enum pm_device_state state; + + (void)pm_device_state_get(dev, &state); + if (state != PM_DEVICE_STATE_ACTIVE) { + return 0; + } +#endif + #if CONFIG_UART_USE_RUNTIME_CONFIGURE hwfc = data->uart_config.flow_ctrl == UART_CFG_FLOW_CTRL_RTS_CTS; #else @@ -497,6 +506,7 @@ static int api_rx_enable(const struct device *dev, uint8_t *buf, size_t len, int * flags are already known to the driver (e.g. if flushed data shall be * kept or not). */ + adata->err = 0; adata->en_rx_buf = buf; adata->en_rx_len = len; @@ -574,6 +584,15 @@ static void api_poll_out(const struct device *dev, unsigned char out_char) const nrfx_uarte_t *nrfx_dev = get_nrfx_dev(dev); nrfx_err_t err; +#if CONFIG_PM_DEVICE + enum pm_device_state state; + + (void)pm_device_state_get(dev, &state); + if (state != PM_DEVICE_STATE_ACTIVE) { + return; + } +#endif + do { /* When runtime PM is used we cannot use early return because then * we have no information when UART is actually done with the diff --git a/drivers/spi/Kconfig.dw b/drivers/spi/Kconfig.dw index 3ebdd54ee932..ed45361d8eda 100644 --- a/drivers/spi/Kconfig.dw +++ b/drivers/spi/Kconfig.dw @@ -20,4 +20,10 @@ config SPI_DW_ACCESS_WORD_ONLY DesignWare SPI only allows word access, byte access will raise exception. +config SPI_DW_HSSI + bool "Designware SPI HSSI variant" + help + Use register layout compatible with the SPI DW HSSI variant of the + peripheral. + endif # SPI_DW diff --git a/drivers/spi/spi_dw.c b/drivers/spi/spi_dw.c index 7f9d2428ae1a..b2787b73a00f 100644 --- a/drivers/spi/spi_dw.c +++ b/drivers/spi/spi_dw.c @@ -40,6 +40,10 @@ LOG_MODULE_REGISTER(spi_dw); #include #endif +#ifdef CONFIG_HAS_NRFX +#include +#endif + static inline bool spi_dw_is_slave(struct spi_dw_data *spi) { return (IS_ENABLED(CONFIG_SPI_SLAVE) && @@ -257,6 +261,7 @@ static int spi_dw_configure(const struct device *dev, /* Baud rate and Slave select, for master only */ write_baudr(dev, SPI_DW_CLK_DIVIDER(info->clock_frequency, config->frequency)); + write_ser(dev, BIT(config->slave)); } if (spi_dw_is_slave(spi)) { @@ -499,6 +504,10 @@ void spi_dw_isr(const struct device *dev) uint32_t int_status; int error; +#ifdef CONFIG_HAS_NRFX + NRF_EXMIF->EVENTS_CORE = 0; +#endif + int_status = read_isr(dev); LOG_DBG("SPI %p int_status 0x%x - (tx: %d, rx: %d)", dev, int_status, @@ -544,6 +553,11 @@ int spi_dw_init(const struct device *dev) DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); +#ifdef CONFIG_HAS_NRFX + NRF_EXMIF->INTENSET = BIT(0); + NRF_EXMIF->TASKS_START = 1; +#endif + info->config_func(); /* Masking interrupt and making sure controller is disabled */ @@ -562,6 +576,11 @@ int spi_dw_init(const struct device *dev) return 0; } +#define REG_ADDR(inst) \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), nordic_nrf_exmif), \ + (Z_DEVICE_MMIO_NAMED_ROM_INITIALIZER(core, DT_DRV_INST(inst))), \ + (DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst)))) + #define SPI_CFG_IRQS_SINGLE_ERR_LINE(inst) \ IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, rx_avail, irq), \ DT_INST_IRQ_BY_NAME(inst, rx_avail, priority), \ @@ -634,7 +653,7 @@ COND_CODE_1(IS_EQ(DT_NUM_IRQS(DT_DRV_INST(inst)), 1), \ SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(inst), ctx) \ }; \ static const struct spi_dw_config spi_dw_config_##inst = { \ - DEVICE_MMIO_ROM_INIT(DT_DRV_INST(inst)), \ + REG_ADDR(inst), \ .clock_frequency = COND_CODE_1( \ DT_NODE_HAS_PROP(DT_INST_PHANDLE(inst, clocks), clock_frequency), \ (DT_INST_PROP_BY_PHANDLE(inst, clocks, clock_frequency)), \ diff --git a/drivers/spi/spi_dw.h b/drivers/spi/spi_dw.h index d6383bc4ed2c..6c073b474716 100644 --- a/drivers/spi/spi_dw.h +++ b/drivers/spi/spi_dw.h @@ -179,19 +179,26 @@ static int reg_test_bit(uint8_t bit, mm_reg_t addr, uint32_t off) /* Common registers settings, bits etc... */ /* CTRLR0 settings */ +#if !IS_ENABLED(CONFIG_SPI_DW_HSSI) #define DW_SPI_CTRLR0_SCPH_BIT (6) #define DW_SPI_CTRLR0_SCPOL_BIT (7) +#define DW_SPI_CTRLR0_TMOD_SHIFT (8) +#define DW_SPI_CTRLR0_SLV_OE_BIT (10) #define DW_SPI_CTRLR0_SRL_BIT (11) +#else +/* The register layout is different in the HSSI variant */ +#define DW_SPI_CTRLR0_SCPH_BIT (8) +#define DW_SPI_CTRLR0_SCPOL_BIT (9) +#define DW_SPI_CTRLR0_TMOD_SHIFT (10) +#define DW_SPI_CTRLR0_SLV_OE_BIT (12) +#define DW_SPI_CTRLR0_SRL_BIT (13) +#endif #define DW_SPI_CTRLR0_SCPH BIT(DW_SPI_CTRLR0_SCPH_BIT) #define DW_SPI_CTRLR0_SCPOL BIT(DW_SPI_CTRLR0_SCPOL_BIT) #define DW_SPI_CTRLR0_SRL BIT(DW_SPI_CTRLR0_SRL_BIT) - -#define DW_SPI_CTRLR0_SLV_OE_BIT (10) #define DW_SPI_CTRLR0_SLV_OE BIT(DW_SPI_CTRLR0_SLV_OE_BIT) -#define DW_SPI_CTRLR0_TMOD_SHIFT (8) - #define DW_SPI_CTRLR0_TMOD_TX_RX (0) #define DW_SPI_CTRLR0_TMOD_TX (1 << DW_SPI_CTRLR0_TMOD_SHIFT) #define DW_SPI_CTRLR0_TMOD_RX (2 << DW_SPI_CTRLR0_TMOD_SHIFT) diff --git a/drivers/timer/Kconfig.nrf_grtc b/drivers/timer/Kconfig.nrf_grtc index 442c524fd197..444d13aab311 100644 --- a/drivers/timer/Kconfig.nrf_grtc +++ b/drivers/timer/Kconfig.nrf_grtc @@ -40,9 +40,20 @@ config NRF_GRTC_TIMER_CLOCK_MANAGEMENT the GRTC. Usually this is only needed by the processor that is starting the SYSCOUNTER, but can be shared by multiple processors in the system. -config NRF_GRTC_SLEEP_MINIMUM_LATENCY +config NRF_GRTC_SYSCOUNTER_SLEEP_MINIMUM_LATENCY int default 1000 depends on NRF_GRTC_SLEEP_ALLOWED + help + The value (in us) ensures that the wakeup event will not fire + too early. In other words, applying SYSCOUNTER sleep state for less than + NRF_GRTC_SYSCOUNTER_SLEEP_MINIMUM_LATENCY period makes no sense. + +config NRF_GRTC_TIMER_AUTO_KEEP_ALIVE + bool + default y if NRF_GRTC_START_SYSCOUNTER + help + This feature prevents the SYSCOUNTER to sleep when any core is in + active state. endif # NRF_GRTC_TIMER diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index c9e51db24697..51f00687e7e7 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -29,12 +29,6 @@ #define CHAN_COUNT NRFX_GRTC_CONFIG_NUM_OF_CC_CHANNELS #define EXT_CHAN_COUNT (CHAN_COUNT - 1) -/* The reset value of waketime is 1, which doesn't seem to work. - * It's being looked into, but for the time being use 4. - * Timeout must always be higher than waketime, so setting that to 5. - */ -#define WAKETIME (4) -#define TIMEOUT (WAKETIME + 1) #ifndef GRTC_SYSCOUNTERL_VALUE_Msk #define GRTC_SYSCOUNTERL_VALUE_Msk GRTC_SYSCOUNTER_SYSCOUNTERL_VALUE_Msk @@ -55,9 +49,6 @@ #define MAX_CYCLES (MAX_TICKS * CYC_PER_TICK) -/* The maximum SYSCOUNTERVALID settling time equals 1x32k cycles + 20x1MHz cycles. */ -#define GRTC_SYSCOUNTERVALID_SETTLE_MAX_TIME_US 51 - #if defined(CONFIG_TEST) const int32_t z_sys_timer_irq_for_test = DT_IRQN(GRTC_NODE); #endif @@ -78,36 +69,6 @@ static nrfx_grtc_channel_t system_clock_channel_data = { __ASSERT_NO_MSG((NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK & (1UL << (chan))) && \ ((chan) != system_clock_channel_data.channel)) -static inline void grtc_active_set(void) -{ -#if defined(NRF_GRTC_HAS_SYSCOUNTER_ARRAY) && (NRF_GRTC_HAS_SYSCOUNTER_ARRAY == 1) - nrfy_grtc_sys_counter_active_set(NRF_GRTC, true); - while (!nrfy_grtc_sys_conter_ready_check(NRF_GRTC)) { - } -#else - nrfy_grtc_sys_counter_active_state_request_set(NRF_GRTC, true); - k_busy_wait(GRTC_SYSCOUNTERVALID_SETTLE_MAX_TIME_US); -#endif -} - -static inline void grtc_wakeup(void) -{ - if (IS_ENABLED(CONFIG_NRF_GRTC_SLEEP_ALLOWED)) { - grtc_active_set(); - } -} - -static inline void grtc_sleep(void) -{ - if (IS_ENABLED(CONFIG_NRF_GRTC_SLEEP_ALLOWED)) { -#if defined(NRF_GRTC_HAS_SYSCOUNTER_ARRAY) && (NRF_GRTC_HAS_SYSCOUNTER_ARRAY == 1) - nrfy_grtc_sys_counter_active_set(NRF_GRTC, false); -#else - nrfy_grtc_sys_counter_active_state_request_set(NRF_GRTC, false); -#endif - } -} - static inline uint64_t counter_sub(uint64_t a, uint64_t b) { return (a - b); @@ -116,10 +77,7 @@ static inline uint64_t counter_sub(uint64_t a, uint64_t b) static inline uint64_t counter(void) { uint64_t now; - - grtc_wakeup(); nrfx_grtc_syscounter_get(&now); - grtc_sleep(); return now; } @@ -141,10 +99,8 @@ static inline uint64_t get_comparator(uint32_t chan) static void system_timeout_set(uint64_t value) { if (value <= NRF_GRTC_SYSCOUNTER_CCADD_MASK) { - grtc_wakeup(); nrfx_grtc_syscounter_cc_relative_set(&system_clock_channel_data, value, true, NRFX_GRTC_CC_RELATIVE_SYSCOUNTER); - grtc_sleep(); } else { nrfx_grtc_syscounter_cc_absolute_set(&system_clock_channel_data, value + counter(), true); @@ -319,18 +275,21 @@ uint64_t z_nrf_grtc_timer_get_ticks(k_timeout_t t) int64_t curr_tick; int64_t result; int64_t abs_ticks; + int64_t grtc_ticks; curr_time = counter(); curr_tick = sys_clock_tick_get(); + grtc_ticks = t.ticks * CYC_PER_TICK; abs_ticks = Z_TICK_ABS(t.ticks); if (abs_ticks < 0) { /* relative timeout */ - return (t.ticks > (int64_t)COUNTER_SPAN) ? -EINVAL : (curr_time + t.ticks); + return (grtc_ticks > (int64_t)COUNTER_SPAN) ? + -EINVAL : (curr_time + grtc_ticks); } /* absolute timeout */ - result = abs_ticks - curr_tick; + result = (abs_ticks - curr_tick) * CYC_PER_TICK; if (result > (int64_t)COUNTER_SPAN) { return -EINVAL; @@ -370,6 +329,7 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time) */ uint64_t capt_time; + nrfx_err_t result; IS_CHANNEL_ALLOWED_ASSERT(chan); @@ -380,8 +340,10 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time) */ return -EBUSY; } - - capt_time = nrfy_grtc_sys_counter_cc_get(NRF_GRTC, chan); + result = nrfx_grtc_syscounter_cc_value_read(chan, &capt_time); + if (result != NRFX_SUCCESS) { + return -EPERM; + } __ASSERT_NO_MSG(capt_time < COUNTER_SPAN); @@ -396,16 +358,22 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) nrfx_err_t err_code; static uint8_t systemoff_channel; uint64_t now = counter(); + nrfx_grtc_sleep_config_t sleep_cfg; /* Minimum time that ensures valid execution of system-off procedure. */ - uint32_t minimum_latency_us = nrfy_grtc_waketime_get(NRF_GRTC) + - nrfy_grtc_timeout_get(NRF_GRTC) + - CONFIG_NRF_GRTC_SLEEP_MINIMUM_LATENCY; + uint32_t minimum_latency_us; uint32_t chan; int ret; + nrfx_grtc_sleep_configuration_get(&sleep_cfg); + minimum_latency_us = (sleep_cfg.waketime + sleep_cfg.timeout) * USEC_PER_SEC / 32768 + + CONFIG_NRF_GRTC_SYSCOUNTER_SLEEP_MINIMUM_LATENCY; + sleep_cfg.auto_mode = false; + nrfx_grtc_sleep_configure(&sleep_cfg); + if (minimum_latency_us > wake_time_us) { return -EINVAL; } + k_spinlock_key_t key = k_spin_lock(&lock); err_code = nrfx_grtc_channel_alloc(&systemoff_channel); @@ -414,7 +382,9 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) return -ENOMEM; } (void)nrfx_grtc_syscounter_cc_int_disable(systemoff_channel); - ret = compare_set(systemoff_channel, now + wake_time_us, NULL, NULL); + ret = compare_set(systemoff_channel, + now + wake_time_us * sys_clock_hw_cycles_per_sec() / USEC_PER_SEC, NULL, + NULL); if (ret < 0) { k_spin_unlock(&lock, key); return ret; @@ -430,7 +400,7 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) } /* Make sure that wake_time_us was not triggered yet. */ - if (nrfy_grtc_sys_counter_compare_event_check(NRF_GRTC, systemoff_channel)) { + if (nrfx_grtc_syscounter_compare_event_check(systemoff_channel)) { k_spin_unlock(&lock, key); return -EINVAL; } @@ -441,7 +411,7 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) MAX_CC_LATCH_WAIT_TIME_US; k_busy_wait(wait_time); #if NRF_GRTC_HAS_CLKSEL - nrfy_grtc_clksel_set(NRF_GRTC, NRF_GRTC_CLKSEL_LFXO); + nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFXO); #endif k_spin_unlock(&lock, key); return 0; @@ -482,16 +452,9 @@ static int sys_clock_driver_init(void) #if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && \ (defined(NRF_GRTC_HAS_CLKSEL) && (NRF_GRTC_HAS_CLKSEL == 1)) /* Use System LFCLK as the low-frequency clock source. */ - nrfy_grtc_clksel_set(NRF_GRTC, NRF_GRTC_CLKSEL_LFCLK); + nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFCLK); #endif -#if defined(CONFIG_NRF_GRTC_START_SYSCOUNTER) - /* SYSCOUNTER needs to be turned off before initialization. */ - nrfy_grtc_sys_counter_set(NRF_GRTC, false); - nrfy_grtc_timeout_set(NRF_GRTC, TIMEOUT); - nrfy_grtc_waketime_set(NRF_GRTC, WAKETIME); -#endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */ - IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_grtc_irq_handler, 0, 0); err_code = nrfx_grtc_init(0); @@ -504,9 +467,6 @@ static int sys_clock_driver_init(void) if (err_code != NRFX_SUCCESS) { return err_code == NRFX_ERROR_NO_MEM ? -ENOMEM : -EPERM; } - if (IS_ENABLED(CONFIG_NRF_GRTC_SLEEP_ALLOWED)) { - nrfy_grtc_sys_counter_auto_mode_set(NRF_GRTC, false); - } #else err_code = nrfx_grtc_channel_alloc(&system_clock_channel_data.channel); if (err_code != NRFX_SUCCESS) { @@ -514,10 +474,6 @@ static int sys_clock_driver_init(void) } #endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */ - if (!IS_ENABLED(CONFIG_NRF_GRTC_SLEEP_ALLOWED)) { - grtc_active_set(); - } - int_mask = NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK; if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) { system_timeout_set(CYC_PER_TICK); diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index 4cfb7abc511e..c105da55c766 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -5,7 +5,7 @@ / { chosen { - zephyr,entropy = &rng; + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -547,7 +547,7 @@ reg = <0x5002a000 0x1000>, <0x5002b000 0x1000>; reg-names = "wrapper", "core"; interrupts = <42 NRF_DEFAULT_IRQ_PRIORITY>; - status = "disabled"; + status = "okay"; }; }; }; diff --git a/dts/arm/nordic/nrf5340_cpuapp.dtsi b/dts/arm/nordic/nrf5340_cpuapp.dtsi index e40f6241d911..d48f0ce62dc4 100644 --- a/dts/arm/nordic/nrf5340_cpuapp.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp.dtsi @@ -33,7 +33,7 @@ }; chosen { - zephyr,entropy = &rng_hci; + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -102,7 +102,7 @@ reg = <0x50844000 0x1000>, <0x50845000 0x1000>; reg-names = "wrapper", "core"; interrupts = <68 NRF_DEFAULT_IRQ_PRIORITY>; - status = "disabled"; + status = "okay"; }; }; diff --git a/dts/arm/nordic/nrf54l15_cpuapp_peripherals.dtsi b/dts/arm/nordic/nrf54l15_cpuapp_peripherals.dtsi index eb161844841a..3e4d36410698 100644 --- a/dts/arm/nordic/nrf54l15_cpuapp_peripherals.dtsi +++ b/dts/arm/nordic/nrf54l15_cpuapp_peripherals.dtsi @@ -24,6 +24,8 @@ spi00: spi@4a000 { interrupts = <74 NRF_DEFAULT_IRQ_PRIORITY>; max-frequency = ; easydma-maxcnt-bits = <16>; + rx-delay-supported; + rx-delay = <1>; status = "disabled"; }; @@ -124,6 +126,8 @@ spi20: spi@c6000 { interrupts = <198 NRF_DEFAULT_IRQ_PRIORITY>; max-frequency = ; easydma-maxcnt-bits = <16>; + rx-delay-supported; + rx-delay = <1>; status = "disabled"; }; @@ -159,6 +163,8 @@ spi21: spi@c7000 { interrupts = <199 NRF_DEFAULT_IRQ_PRIORITY>; max-frequency = ; easydma-maxcnt-bits = <16>; + rx-delay-supported; + rx-delay = <1>; status = "disabled"; }; @@ -194,6 +200,8 @@ spi22: spi@c8000 { interrupts = <200 NRF_DEFAULT_IRQ_PRIORITY>; max-frequency = ; easydma-maxcnt-bits = <16>; + rx-delay-supported; + rx-delay = <1>; status = "disabled"; }; @@ -391,6 +399,8 @@ spi30: spi@104000 { interrupts = <260 NRF_DEFAULT_IRQ_PRIORITY>; max-frequency = ; easydma-maxcnt-bits = <16>; + rx-delay-supported; + rx-delay = <1>; status = "disabled"; }; diff --git a/dts/arm/nordic/nrf54l_common.dtsi b/dts/arm/nordic/nrf54l_common.dtsi index 1c5345afc934..c537554b05bb 100644 --- a/dts/arm/nordic/nrf54l_common.dtsi +++ b/dts/arm/nordic/nrf54l_common.dtsi @@ -25,6 +25,12 @@ chosen { zephyr,flash-controller = &rram_controller; + zephyr,entropy = &psa_rng; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; }; sw_pwm: sw-pwm { diff --git a/dts/arm/nordic/nrf91.dtsi b/dts/arm/nordic/nrf91.dtsi index 78502d3f0863..0fb4c4addf4a 100644 --- a/dts/arm/nordic/nrf91.dtsi +++ b/dts/arm/nordic/nrf91.dtsi @@ -27,6 +27,7 @@ }; chosen { + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -50,7 +51,7 @@ reg = <0x50840000 0x1000>, <0x50841000 0x1000>; reg-names = "wrapper", "core"; interrupts = <64 NRF_DEFAULT_IRQ_PRIORITY>; - status = "disabled"; + status = "okay"; }; ctrlap: ctrlap@50006000 { diff --git a/dts/bindings/pwm/nordic,nrf-pwm.yaml b/dts/bindings/pwm/nordic,nrf-pwm.yaml index 9f2c21d2b353..e634cdee6d02 100644 --- a/dts/bindings/pwm/nordic,nrf-pwm.yaml +++ b/dts/bindings/pwm/nordic,nrf-pwm.yaml @@ -2,7 +2,7 @@ description: nRF PWM compatible: "nordic,nrf-pwm" -include: [pwm-controller.yaml, base.yaml, pinctrl-device.yaml] +include: [pwm-controller.yaml, base.yaml, pinctrl-device.yaml, memory-region.yaml] properties: reg: diff --git a/dts/bindings/rng/nordic,nrf-prng.yaml b/dts/bindings/rng/nordic,nrf-prng.yaml new file mode 100644 index 000000000000..8936393a0b65 --- /dev/null +++ b/dts/bindings/rng/nordic,nrf-prng.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +description: This is a super simple PRNG + +compatible: "nordic,entropy-prng" + +include: base.yaml diff --git a/dts/bindings/spi/nordic,nrf-exmif.yaml b/dts/bindings/spi/nordic,nrf-exmif.yaml new file mode 100644 index 000000000000..d2b8815046b5 --- /dev/null +++ b/dts/bindings/spi/nordic,nrf-exmif.yaml @@ -0,0 +1,12 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic External Memory Interface (EXMIF) + +compatible: "nordic,nrf-exmif" + +include: snps,designware-spi.yaml + +properties: + reg: + required: true diff --git a/dts/common/nordic/nrf54h20.dtsi b/dts/common/nordic/nrf54h20.dtsi index b8456d719c0e..92f2576e733b 100644 --- a/dts/common/nordic/nrf54h20.dtsi +++ b/dts/common/nordic/nrf54h20.dtsi @@ -300,6 +300,19 @@ #size-cells = <1>; ranges = <0x0 0x5f000000 0x1000000>; + exmif: spi@95000 { + compatible = "nordic,nrf-exmif", "snps,designware-spi"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x95000 0x500 0x95500 0xb00>; + reg-names = "wrapper", "core"; + interrupts = <149 NRF_DEFAULT_IRQ_PRIORITY>; + clock-frequency = ; + fifo-depth = <32>; + max-xfer-size = <16>; + status = "disabled"; + }; + cpusec_bellboard: mailbox@99000 { reg = <0x99000 0x1000>; status = "disabled"; @@ -369,6 +382,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart120: uart@8e6000 { @@ -387,6 +402,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; cpuppr_vpr: vpr@908000 { @@ -644,6 +661,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart130: uart@9a5000 { @@ -672,6 +691,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart131: uart@9a6000 { @@ -734,6 +755,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart132: uart@9b5000 { @@ -762,6 +785,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart133: uart@9b6000 { @@ -824,6 +849,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart134: uart@9c5000 { @@ -852,6 +879,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart135: uart@9c6000 { @@ -914,6 +943,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart136: uart@9d5000 { @@ -942,6 +973,8 @@ max-frequency = ; #address-cells = <1>; #size-cells = <0>; + rx-delay-supported; + rx-delay = <1>; }; uart137: uart@9d6000 { diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index d061468d2ac1..14eb78f3e705 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -26,6 +26,35 @@ #endif #define RAMABLE_REGION RAM +#if USE_PARTITION_MANAGER + +#include + +#if CONFIG_NCS_IS_VARIANT_IMAGE && defined(PM_S0_ID) +/* We are linking against S1, create symbol containing the flash ID of S0. + * This is used when writing code operating on the "other" slot. + */ +_image_1_primary_slot_id = PM_S0_ID; + +#else /* ! CONFIG_NCS_IS_VARIANT_IMAGE */ + +#ifdef PM_S1_ID +/* We are linking against S0, create symbol containing the flash ID of S1. + * This is used when writing code operating on the "other" slot. + */ +_image_1_primary_slot_id = PM_S1_ID; +#endif /* PM_S1_ID */ + +#endif /* CONFIG_NCS_IS_VARIANT_IMAGE */ + +#define ROM_ADDR PM_ADDRESS +#define ROM_SIZE PM_SIZE + +#define RAM_SIZE PM_SRAM_SIZE +#define RAM_ADDR PM_SRAM_ADDRESS + +#else /* ! USE_PARTITION_MANAGER */ + #if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) #define ROM_ADDR RAM_ADDR #else @@ -58,6 +87,23 @@ #define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS #endif +#endif /* USE_PARTITION_MANAGER */ + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_ccm), okay) +#define CCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ccm)) +#define CCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ccm)) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_itcm), okay) +#define ITCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_itcm)) +#define ITCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_itcm)) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay) +#define DTCM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_dtcm)) +#define DTCM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_dtcm)) +#endif + #if defined(CONFIG_CUSTOM_SECTION_ALIGN) _region_min_align = CONFIG_CUSTOM_SECTION_MIN_ALIGN_SIZE; #else diff --git a/include/zephyr/drivers/timer/nrf_grtc_timer.h b/include/zephyr/drivers/timer/nrf_grtc_timer.h index 172a904fdef9..76fa7b703463 100644 --- a/include/zephyr/drivers/timer/nrf_grtc_timer.h +++ b/include/zephyr/drivers/timer/nrf_grtc_timer.h @@ -111,7 +111,7 @@ uint64_t z_nrf_grtc_timer_compare_read(int32_t chan); * * @param chan Channel ID. * - * @param target_time Absolute target time in ticks. + * @param target_time Absolute target time in GRTC ticks. * * @param handler User function called in the context of the GRTC interrupt. * diff --git a/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h index 9d7f8c2312fe..a50233ab38c7 100644 --- a/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h +++ b/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h @@ -126,6 +126,28 @@ #define NRF_FUN_QSPI_IO2 33U /** QSPI IO3 */ #define NRF_FUN_QSPI_IO3 34U +/** EXMIF CK */ +#define NRF_FUN_EXMIF_CK 35U +/** EXMIF DQ0 */ +#define NRF_FUN_EXMIF_DQ0 36U +/** EXMIF DQ1 */ +#define NRF_FUN_EXMIF_DQ1 37U +/** EXMIF DQ2 */ +#define NRF_FUN_EXMIF_DQ2 38U +/** EXMIF DQ3 */ +#define NRF_FUN_EXMIF_DQ3 39U +/** EXMIF DQ4 */ +#define NRF_FUN_EXMIF_DQ4 40U +/** EXMIF DQ5 */ +#define NRF_FUN_EXMIF_DQ5 41U +/** EXMIF DQ6 */ +#define NRF_FUN_EXMIF_DQ6 42U +/** EXMIF DQ7 */ +#define NRF_FUN_EXMIF_DQ7 43U +/** EXMIF CS0 */ +#define NRF_FUN_EXMIF_CS0 44U +/** EXMIF CS1 */ +#define NRF_FUN_EXMIF_CS1 45U /** @} */ diff --git a/include/zephyr/net/ethernet.h b/include/zephyr/net/ethernet.h index e39fa7d170e7..9ecc7340d03e 100644 --- a/include/zephyr/net/ethernet.h +++ b/include/zephyr/net/ethernet.h @@ -971,6 +971,24 @@ static inline bool net_eth_get_vlan_status(struct net_if *iface) } #endif +/** + * @brief Check if the given interface is a VLAN interface. + * + * @param iface Network interface + * + * @return True if this network interface is VLAN one, false if not. + */ +#if defined(CONFIG_NET_VLAN) +bool net_eth_is_vlan_interface(struct net_if *iface); +#else +static inline bool net_eth_is_vlan_interface(struct net_if *iface) +{ + ARG_UNUSED(iface); + + return false; +} +#endif + #if !defined(CONFIG_ETH_DRIVER_RAW_MODE) #define Z_ETH_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, instance, \ diff --git a/include/zephyr/net/mqtt.h b/include/zephyr/net/mqtt.h index 987b3726cafc..54b2532f0fae 100644 --- a/include/zephyr/net/mqtt.h +++ b/include/zephyr/net/mqtt.h @@ -371,6 +371,9 @@ struct mqtt_sec_config { uint32_t alpn_protocol_name_count; #endif + /** Indicates the preference for enabling TLS session caching. */ + int session_cache; + /** Peer hostname for ceritificate verification. * May be NULL to skip hostname verification. */ @@ -378,6 +381,9 @@ struct mqtt_sec_config { /** Indicates the preference for copying certificates to the heap. */ int cert_nocopy; + + /** Set socket to native TLS */ + bool set_native_tls; }; /** @brief MQTT transport type. */ diff --git a/include/zephyr/net/net_stats.h b/include/zephyr/net/net_stats.h index ddaa8d1180f0..f5a567fcdbc4 100644 --- a/include/zephyr/net/net_stats.h +++ b/include/zephyr/net/net_stats.h @@ -494,6 +494,7 @@ struct net_stats_wifi { struct net_stats_pkts broadcast; struct net_stats_pkts multicast; struct net_stats_pkts errors; + struct net_stats_pkts unicast; }; #if defined(CONFIG_NET_STATISTICS_USER_API) diff --git a/include/zephyr/net/socket.h b/include/zephyr/net/socket.h index 1800533a2506..79eb8f324557 100644 --- a/include/zephyr/net/socket.h +++ b/include/zephyr/net/socket.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #ifdef __cplusplus diff --git a/include/zephyr/net/socket_ncs.h b/include/zephyr/net/socket_ncs.h new file mode 100644 index 000000000000..0023cd9bd489 --- /dev/null +++ b/include/zephyr/net/socket_ncs.h @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_NET_SOCKET_NCS_H_ +#define ZEPHYR_INCLUDE_NET_SOCKET_NCS_H_ + +/** + * @file + * @brief NCS specific additions to the BSD sockets API definitions + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* When CONFIG_NET_SOCKETS_OFFLOAD is enabled, offloaded sockets take precedence + * when creating a new socket. Combine this flag with a socket type when + * creating a socket, to enforce native socket creation (e. g. SOCK_STREAM | SOCK_NATIVE). + * If it's desired to create a native TLS socket, but still offload the + * underlying TCP/UDP socket, use e. g. SOCK_STREAM | SOCK_NATIVE_TLS. + */ +#define SOCK_NATIVE 0x80000000 +#define SOCK_NATIVE_TLS 0x40000000 + +/* NCS specific TLS level socket options */ + +/** Socket option to set DTLS handshake timeout, specifically for nRF sockets. + * The option accepts an integer, indicating the total handshake timeout, + * including retransmissions, in seconds. + * Accepted values for the option are: 1, 3, 7, 15, 31, 63, 123. + */ +#define TLS_DTLS_HANDSHAKE_TIMEO 18 + +/** Socket option to save DTLS connection, specifically for nRF sockets. + */ +#define TLS_DTLS_CONN_SAVE 19 + +/** Socket option to load DTLS connection, specifically for nRF sockets. + */ +#define TLS_DTLS_CONN_LOAD 20 + +/** Socket option to get result of latest TLS/DTLS completed handshakes end status, + * specifically for nRF sockets. + * The option accepts an integer, indicating the setting. + * Accepted vaules for the option are: 0 and 1. + */ +#define TLS_DTLS_HANDSHAKE_STATUS 21 + +/* Valid values for TLS_SESSION_CACHE option */ +#define TLS_SESSION_CACHE_DISABLED 0 /**< Disable TLS session caching. */ +#define TLS_SESSION_CACHE_ENABLED 1 /**< Enable TLS session caching. */ + +/* Valid values for TLS_DTLS_HANDSHAKE_TIMEO option */ +#define TLS_DTLS_HANDSHAKE_TIMEO_NONE 0 /**< No timeout */ +#define TLS_DTLS_HANDSHAKE_TIMEO_1S 1 /**< 1 second */ +#define TLS_DTLS_HANDSHAKE_TIMEO_3S 3 /**< 1s + 2s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_7S 7 /**< 1s + 2s + 4s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_15S 15 /**< 1s + 2s + 4s + 8s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_31S 31 /**< 1s + 2s + 4s + 8s + 16s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_63S 63 /**< 1s + 2s + 4s + 8s + 16s + 32s */ +#define TLS_DTLS_HANDSHAKE_TIMEO_123S 123 /**< 1s + 2s + 4s + 8s + 16s + 32s + 60s */ + +/* Valid values for TLS_DTLS_HANDSHAKE_STATUS option */ +#define TLS_DTLS_HANDSHAKE_STATUS_FULL 0 +#define TLS_DTLS_HANDSHAKE_STATUS_CACHED 1 + +/* NCS specific socket options */ + +/** sockopt: enable sending data as part of exceptional events */ +#define SO_EXCEPTIONAL_DATA 33 +/** sockopt: Keep socket open when its PDN connection is lost + * or the device is put into flight mode. + */ +#define SO_KEEPOPEN 34 +/** sockopt: bind to PDN */ +#define SO_BINDTOPDN 40 +/** sockopt: Release Assistance Indication feature: This will indicate that the + * application will not send any more data. + * + * @note This socket option requires the socket to be connected. + * + * @deprecated use @ref SO_RAI with value @ref RAI_NO_DATA instead. + */ +#define SO_RAI_NO_DATA 50 +/** sockopt: Release Assistance Indication feature: This will indicate that the + * next call to send/sendto will be the last one for some time. + * + * @deprecated use @ref SO_RAI with value @ref RAI_LAST instead. + */ +#define SO_RAI_LAST 51 +/** sockopt: Release Assistance Indication feature: This will indicate that + * after the next call to send/sendto, the application is expecting to receive + * one more data packet before this socket will not be used again for some time. + * + * @deprecated use @ref SO_RAI with value @ref RAI_ONE_RESP instead. + */ +#define SO_RAI_ONE_RESP 52 +/** sockopt: Release Assistance Indication feature: If a client application + * expects to use the socket more it can indicate that by setting this socket + * option before the next send call which will keep the network up longer. + * + * @deprecated use @ref SO_RAI with value @ref RAI_ONGOING instead. + */ +#define SO_RAI_ONGOING 53 +/** sockopt: Release Assistance Indication feature: If a server application + * expects to use the socket more it can indicate that by setting this socket + * option before the next send call. + * + * @deprecated use @ref SO_RAI with value @ref RAI_WAIT_MORE instead. + */ +#define SO_RAI_WAIT_MORE 54 + +/** sockopt: Release assistance indication (RAI). + * The option accepts an integer, indicating the type of RAI. + * Accepted values for the option are: @ref RAI_NO_DATA, @ref RAI_LAST, @ref RAI_ONE_RESP, + * @ref RAI_ONGOING, @ref RAI_WAIT_MORE. + */ +#define SO_RAI 61 + +/** Release assistance indication (RAI). + * Indicate that the application does not intend to send more data. + * This applies immediately and lets the modem exit connected mode more + * quickly. + * + * @note This requires the socket to be connected. + */ +#define RAI_NO_DATA 1 +/** Release assistance indication (RAI). + * Indicate that the application does not intend to send more data + * after the next call to send() or sendto(). + * This lets the modem exit connected mode more quickly after sending the data. + */ +#define RAI_LAST 2 +/** Release assistance indication (RAI). + * Indicate that the application is expecting to receive just one data packet + * after the next call to send() or sendto(). + * This lets the modem exit connected mode more quickly after having received the data. + */ +#define RAI_ONE_RESP 3 +/** Release assistance indication (RAI). + * Indicate that the socket is in active use by a client application. + * This lets the modem stay in connected mode longer. + */ +#define RAI_ONGOING 4 +/** Release assistance indication (RAI). + * Indicate that the socket is in active use by a server application. + * This lets the modem stay in connected mode longer. + */ +#define RAI_WAIT_MORE 5 + +/* NCS specific IPPROTO_ALL level socket options */ + +/** IPv4 and IPv6 protocol level (pseudo-val) for nRF sockets. */ +#define IPPROTO_ALL 512 +/** sockopt: disable all replies to unexpected traffics */ +#define SO_SILENCE_ALL 30 + +/* NCS specific IPPROTO_IP level socket options */ + +/** sockopt: enable IPv4 ICMP replies */ +#define SO_IP_ECHO_REPLY 31 + +/* NCS specific IPPROTO_IPV6 level socket options */ + +/** sockopt: enable IPv6 ICMP replies */ +#define SO_IPV6_ECHO_REPLY 32 + +/* NCS specific TCP level socket options */ + +/** sockopt: Configurable TCP server session timeout in minutes. + * Range is 0 to 135. 0 is no timeout and 135 is 2 h 15 min. Default is 0 (no timeout). + */ +#define SO_TCP_SRV_SESSTIMEO 55 + +/* NCS specific gettaddrinfo() flags */ + +/** Assume `service` contains a Packet Data Network (PDN) ID. + * When specified together with the AI_NUMERICSERV flag, + * `service` shall be formatted as follows: "port:pdn_id" + * where "port" is the port number and "pdn_id" is the PDN ID. + * Example: "8080:1", port 8080 PDN ID 1. + * Example: "42:0", port 42 PDN ID 0. + */ +#define AI_PDNSERV 0x1000 + +/* NCS specific send() and sendto() flags */ + +/** Request a blocking send operation until the request is acknowledged. + * When used in send() or sendto(), the request will not return until the + * send operation is completed by lower layers, or until the timeout, given by the SO_SNDTIMEO + * socket option, is reached. Valid timeout values are 1 to 600 seconds. + */ +#define MSG_WAITACK 0x200 + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_NET_SOCKET_NCS_H_ */ diff --git a/include/zephyr/net/wifi.h b/include/zephyr/net/wifi.h index a0840a2319a0..ebfc76d2192d 100644 --- a/include/zephyr/net/wifi.h +++ b/include/zephyr/net/wifi.h @@ -49,6 +49,8 @@ enum wifi_security_type { WIFI_SECURITY_TYPE_WEP, /** WPA-PSK security. */ WIFI_SECURITY_TYPE_WPA_PSK, + /** WPA/WPA2/WPA3 PSK security. */ + WIFI_SECURITY_TYPE_WPA_AUTO_PERSONAL, __WIFI_SECURITY_TYPE_AFTER_LAST, WIFI_SECURITY_TYPE_MAX = __WIFI_SECURITY_TYPE_AFTER_LAST - 1, diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index ea3cbf8961cb..70fd5978fba6 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -66,16 +66,12 @@ enum net_request_wifi_cmd { NET_REQUEST_WIFI_CMD_IFACE_STATUS, /** Set power save status */ NET_REQUEST_WIFI_CMD_PS, - /** Set power save mode */ - NET_REQUEST_WIFI_CMD_PS_MODE, /** Setup or teardown TWT flow */ NET_REQUEST_WIFI_CMD_TWT, /** Get power save config */ NET_REQUEST_WIFI_CMD_PS_CONFIG, /** Set or get regulatory domain */ NET_REQUEST_WIFI_CMD_REG_DOMAIN, - /** Set power save timeout */ - NET_REQUEST_WIFI_CMD_PS_TIMEOUT, /** Set or get Mode of operation */ NET_REQUEST_WIFI_CMD_MODE, /** Set or get packet filter setting for current mode */ @@ -86,6 +82,8 @@ enum net_request_wifi_cmd { NET_REQUEST_WIFI_CMD_AP_STA_DISCONNECT, /** Get Wi-Fi driver and Firmware versions */ NET_REQUEST_WIFI_CMD_VERSION, + /** Set RTS threshold */ + NET_REQUEST_WIFI_CMD_RTS_THRESHOLD, NET_REQUEST_WIFI_CMD_MAX }; @@ -124,11 +122,6 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_IFACE_STATUS); NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_PS); -#define NET_REQUEST_WIFI_PS_MODE \ - (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PS_MODE) - -NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_PS_MODE); - #define NET_REQUEST_WIFI_TWT \ (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_TWT) @@ -143,11 +136,6 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_PS_CONFIG); NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_REG_DOMAIN); -#define NET_REQUEST_WIFI_PS_TIMEOUT \ - (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PS_TIMEOUT) - -NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_PS_TIMEOUT); - #define NET_REQUEST_WIFI_MODE \ (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_MODE) @@ -173,6 +161,10 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_STA_DISCONNECT); NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION); +#define NET_REQUEST_WIFI_RTS_THRESHOLD \ + (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_RTS_THRESHOLD) + +NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD); /** Wi-Fi management events */ enum net_event_wifi_cmd { /** Scan results available */ @@ -866,6 +858,15 @@ struct wifi_mgmt_ops { * @return 0 if ok, < 0 if error */ int (*get_version)(const struct device *dev, struct wifi_version *params); + /** Set RTS threshold value + * + * @param dev Pointer to the device structure for the driver instance. + * @param RTS threshold value + * + * @return 0 if ok, < 0 if error + */ + int (*set_rts_threshold)(const struct device *dev, unsigned int rts_threshold); + }; /** Wi-Fi management offload API */ diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index 37b7c7f32233..c53cbef89574 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -273,6 +273,10 @@ const char *flash_area_label(const struct flash_area *fa); */ uint8_t flash_area_erased_val(const struct flash_area *fa); +#if USE_PARTITION_MANAGER +#include +#else + /** * Returns non-0 value if fixed-partition of given DTS node label exists. * @@ -330,6 +334,8 @@ uint8_t flash_area_erased_val(const struct flash_area *fa); #define FIXED_PARTITION_DEVICE(label) \ DEVICE_DT_GET(DT_MTD_FROM_FIXED_PARTITION(DT_NODELABEL(label))) +#endif /* USE_PARTITION_MANAGER */ + #ifdef __cplusplus } #endif diff --git a/kernel/banner.c b/kernel/banner.c index dc2506fb9b15..061e57048d18 100644 --- a/kernel/banner.c +++ b/kernel/banner.c @@ -24,7 +24,7 @@ #endif /* BUILD_VERSION */ #endif /* !BANNER_VERSION */ -void boot_banner(void) +__weak void boot_banner(void) { #if defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0) printk("***** delaying boot " DELAY_STR "ms (per build configuration) *****\n"); diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index 7f01b280b3b5..68476eb735cd 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -68,7 +68,7 @@ config HEAP_LISTENER choice prompt "Supported heap sizes" depends on !64BIT - default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) + default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) && !PARTITION_MANAGER_ENABLED default SYS_HEAP_AUTO help Heaps using reduced-size chunk headers can accommodate so called diff --git a/lib/libc/common/source/stdlib/malloc.c b/lib/libc/common/source/stdlib/malloc.c index e3a5db6f7d53..2f469d673e4b 100644 --- a/lib/libc/common/source/stdlib/malloc.c +++ b/lib/libc/common/source/stdlib/malloc.c @@ -25,6 +25,20 @@ #include LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); +#if USE_PARTITION_MANAGER + +#include + +#define RAM_SIZE PM_SRAM_SIZE +#define RAM_ADDR PM_SRAM_ADDRESS + +#else /* ! USE_PARTITION_MANAGER */ + +#define RAM_SIZE (KB((size_t) CONFIG_SRAM_SIZE)) +#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS + +#endif /* USE_PARTITION_MANAGER */ + #ifdef CONFIG_COMMON_LIBC_MALLOC #if (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0) @@ -106,8 +120,8 @@ static POOL_SECTION unsigned char __aligned(HEAP_ALIGN) malloc_arena[HEAP_SIZE]; extern char _heap_sentry[]; # define HEAP_SIZE ROUND_DOWN((POINTER_TO_UINT(_heap_sentry) - HEAP_BASE), HEAP_ALIGN) # else -# define HEAP_SIZE ROUND_DOWN((KB((size_t) CONFIG_SRAM_SIZE) - \ - ((size_t) HEAP_BASE - (size_t) CONFIG_SRAM_BASE_ADDRESS)), HEAP_ALIGN) +# define HEAP_SIZE ROUND_DOWN((RAM_SIZE - \ + ((size_t) HEAP_BASE - (size_t) RAM_ADDR)), HEAP_ALIGN) # endif /* else CONFIG_XTENSA */ # endif /* else CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE > 0 */ diff --git a/modules/hal_nordic/CMakeLists.txt b/modules/hal_nordic/CMakeLists.txt index c4a7134935cd..7f46997c6974 100644 --- a/modules/hal_nordic/CMakeLists.txt +++ b/modules/hal_nordic/CMakeLists.txt @@ -11,7 +11,7 @@ if(CONFIG_NRF_REGTOOL_GENERATE_UICR) list(APPEND nrf_regtool_components GENERATE:UICR) endif() if(DEFINED nrf_regtool_components) - find_package(nrf-regtool 5.1.0 + find_package(nrf-regtool 5.1.0 REQUIRED COMPONENTS ${nrf_regtool_components} PATHS ${CMAKE_CURRENT_LIST_DIR}/nrf-regtool NO_CMAKE_PATH diff --git a/modules/hal_nordic/nrf_802154/serialization/platform/nrf_802154_spinel_backend_ipc.c b/modules/hal_nordic/nrf_802154/serialization/platform/nrf_802154_spinel_backend_ipc.c index b2629eef67b7..6df811f6badb 100644 --- a/modules/hal_nordic/nrf_802154/serialization/platform/nrf_802154_spinel_backend_ipc.c +++ b/modules/hal_nordic/nrf_802154/serialization/platform/nrf_802154_spinel_backend_ipc.c @@ -15,6 +15,10 @@ #include "../../spinel_base/spinel.h" #include "../../src/include/nrf_802154_spinel.h" +#if defined(CONFIG_SOC_NRF5340_CPUAPP) +#include +#endif + #define LOG_LEVEL LOG_LEVEL_INFO #define LOG_MODULE_NAME spinel_ipc_backend LOG_MODULE_REGISTER(LOG_MODULE_NAME); @@ -50,6 +54,10 @@ nrf_802154_ser_err_t nrf_802154_backend_init(void) DEVICE_DT_GET(DT_CHOSEN(nordic_802154_spinel_ipc)); int err; +#if defined(CONFIG_SOC_NRF5340_CPUAPP) + nrf53_cpunet_enable(true); +#endif + err = ipc_service_open_instance(ipc_instance); if (err < 0 && err != -EALREADY) { LOG_ERR("Failed to open IPC instance: %d", err); diff --git a/modules/hal_nordic/nrfx/CMakeLists.txt b/modules/hal_nordic/nrfx/CMakeLists.txt index 463c47907437..adce870fc3a9 100644 --- a/modules/hal_nordic/nrfx/CMakeLists.txt +++ b/modules/hal_nordic/nrfx/CMakeLists.txt @@ -127,8 +127,19 @@ if(CONFIG_NRFX_TWI OR CONFIG_NRFX_TWIM) zephyr_library_sources(${SRC_DIR}/nrfx_twi_twim.c) endif() -if (CONFIG_NRF_GRTC_TIMER AND CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) - zephyr_library_compile_definitions(NRF_GRTC_HAS_EXTENDED=1) +if (CONFIG_NRF_GRTC_TIMER) + if (CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) + zephyr_library_compile_definitions(NRF_GRTC_HAS_EXTENDED=1) + endif() + if (CONFIG_NRF_GRTC_SLEEP_ALLOWED) + zephyr_compile_definitions(NRFX_GRTC_CONFIG_SLEEP_ALLOWED=1) + endif() + if (CONFIG_NRF_GRTC_TIMER_AUTO_KEEP_ALIVE) + zephyr_compile_definitions(NRFX_GRTC_CONFIG_AUTOEN=1) + endif() + if (CONFIG_NRF_GRTC_START_SYSCOUNTER) + zephyr_compile_definitions(NRFX_GRTC_CONFIG_AUTOSTART=1) + endif() endif() # Inject HAL "CONFIG_NFCT_PINS_AS_GPIOS" definition if user requests to diff --git a/modules/hal_nordic/nrfx/Kconfig b/modules/hal_nordic/nrfx/Kconfig index 541d9fac5e76..32386d54274d 100644 --- a/modules/hal_nordic/nrfx/Kconfig +++ b/modules/hal_nordic/nrfx/Kconfig @@ -771,6 +771,66 @@ config NRFX_TWIS3 depends on $(dt_nodelabel_has_compat,i2c3,$(DT_COMPAT_NORDIC_NRF_TWIS)) select NRFX_TWIS +config NRFX_TWIS20 + bool "TWIS20 driver instance" + depends on $(dt_nodelabel_has_compat,i2c20,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS21 + bool "TWIS21 driver instance" + depends on $(dt_nodelabel_has_compat,i2c21,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS22 + bool "TWIS22 driver instance" + depends on $(dt_nodelabel_has_compat,i2c22,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS30 + bool "TWIS30 driver instance" + depends on $(dt_nodelabel_has_compat,i2c30,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS130 + bool "TWIS130 driver instance" + depends on $(dt_nodelabel_has_compat,i2c130,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS131 + bool "TWIS131 driver instance" + depends on $(dt_nodelabel_has_compat,i2c131,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS132 + bool "TWIS132 driver instance" + depends on $(dt_nodelabel_has_compat,i2c132,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS133 + bool "TWIS133 driver instance" + depends on $(dt_nodelabel_has_compat,i2c133,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS134 + bool "TWIS134 driver instance" + depends on $(dt_nodelabel_has_compat,i2c134,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS135 + bool "TWIS135 driver instance" + depends on $(dt_nodelabel_has_compat,i2c135,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS136 + bool "TWIS136 driver instance" + depends on $(dt_nodelabel_has_compat,i2c136,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + +config NRFX_TWIS137 + bool "TWIS137 driver instance" + depends on $(dt_nodelabel_has_compat,i2c137,$(DT_COMPAT_NORDIC_NRF_TWIS)) + select NRFX_TWIS + config NRFX_UART bool @@ -886,7 +946,7 @@ config NRFX_UARTE_CONFIG_TX_LINK config NRFX_UARTE_CONFIG_RX_CACHE_ENABLED bool "UARTE RX caching support" - default y if $(dt_nodelabel_has_compat,ram3x,$(DT_COMPAT_MMIO_SRAM)) + default y if $(dt_nodelabel_has_compat,shared_ram3x_region,$(DT_COMPAT_NORDIC_OWNED_MEMORY)) depends on NRFX_UARTE help Feature might be enabled on platforms which has limitations regarding addresses diff --git a/modules/hal_nordic/nrfx/nrfx_config.h b/modules/hal_nordic/nrfx/nrfx_config.h index 60fcd276ea49..e7120b54ab77 100644 --- a/modules/hal_nordic/nrfx/nrfx_config.h +++ b/modules/hal_nordic/nrfx/nrfx_config.h @@ -381,8 +381,10 @@ #ifdef CONFIG_NRFX_SPIM4 #define NRFX_SPIM4_ENABLED 1 #endif -#if (DT_PROP(DT_NODELABEL(spi3), rx_delay_supported) || \ - DT_PROP(DT_NODELABEL(spi4), rx_delay_supported)) + +#define NRFX_SPIM_DT_HAS_RX_DELAY(node) DT_PROP(node, rx_delay_supported) + + +#if DT_FOREACH_STATUS_OKAY(nordic_nrf_spim, NRFX_SPIM_DT_HAS_RX_DELAY) 0 #define NRFX_SPIM_EXTENDED_ENABLED 1 #endif #ifdef CONFIG_NRFX_SPIM00 @@ -677,6 +679,42 @@ #ifdef CONFIG_NRFX_TWIS3 #define NRFX_TWIS3_ENABLED 1 #endif +#ifdef CONFIG_NRFX_TWIS20 +#define NRFX_TWIS20_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS21 +#define NRFX_TWIS21_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS22 +#define NRFX_TWIS22_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS30 +#define NRFX_TWIS30_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS130 +#define NRFX_TWIS130_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS131 +#define NRFX_TWIS131_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS132 +#define NRFX_TWIS132_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS133 +#define NRFX_TWIS133_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS134 +#define NRFX_TWIS134_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS135 +#define NRFX_TWIS135_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS136 +#define NRFX_TWIS136_ENABLED 1 +#endif +#ifdef CONFIG_NRFX_TWIS137 +#define NRFX_TWIS137_ENABLED 1 +#endif #ifdef CONFIG_NRFX_UART #define NRFX_UART_ENABLED 1 diff --git a/modules/mbedtls/CMakeLists.txt b/modules/mbedtls/CMakeLists.txt index 929ea17eceae..a6277f654b52 100644 --- a/modules/mbedtls/CMakeLists.txt +++ b/modules/mbedtls/CMakeLists.txt @@ -25,6 +25,8 @@ zephyr_interface_library_named(mbedTLS) # Add regular includes target_include_directories(mbedTLS INTERFACE ${ZEPHYR_CURRENT_MODULE_DIR}/include + ${ZEPHYR_CURRENT_MODULE_DIR}/include/library + ${ZEPHYR_CURRENT_MODULE_DIR}/library configs include ) diff --git a/modules/mbedtls/Kconfig b/modules/mbedtls/Kconfig index daaee438a38c..99eb3bcf859f 100644 --- a/modules/mbedtls/Kconfig +++ b/modules/mbedtls/Kconfig @@ -5,6 +5,7 @@ config ZEPHYR_MBEDTLS_MODULE bool + config MBEDTLS_PROMPTLESS bool help @@ -13,7 +14,6 @@ config MBEDTLS_PROMPTLESS mbed TLS menu prompt and instead handle the selection of MBEDTLS from dependent sub-configurations and thus prevent stuck symbol behavior. - menuconfig MBEDTLS bool "mbed TLS Support" if !MBEDTLS_PROMPTLESS help @@ -27,6 +27,7 @@ choice MBEDTLS_IMPLEMENTATION config MBEDTLS_BUILTIN bool "Use Zephyr in-tree mbedTLS version" + depends on ! DISABLE_MBEDTLS_BUILTIN help Link with mbedTLS sources included with Zephyr distribution. Included mbedTLS version is well integrated with and supported @@ -40,6 +41,12 @@ config MBEDTLS_LIBRARY endchoice +config DISABLE_MBEDTLS_BUILTIN + bool + help + Subsystems cannot deselect MBEDTLS_BUILTIN, but they can select + DISABLE_MBEDTLS_BUILTIN. + config CUSTOM_MBEDTLS_CFG_FILE bool "Custom mbed TLS configuration file" help @@ -239,3 +246,6 @@ config APP_LINK_WITH_MBEDTLS issues for 'app'. endif # MBEDTLS + +# Add PSA configurations +rsource "Kconfig.psa" diff --git a/modules/mbedtls/Kconfig.psa b/modules/mbedtls/Kconfig.psa new file mode 100644 index 000000000000..27e503817794 --- /dev/null +++ b/modules/mbedtls/Kconfig.psa @@ -0,0 +1,881 @@ +# +# Copyright (c) 2022 Nordic Semiconductor +# +# SPDX-License-Identifier: Apache-2.0 +# +menu "PSA RNG support" + +config PSA_WANT_GENERATE_RANDOM + bool + prompt "PSA RNG support" + help + Provide random number generator (RNG) support. + +config PSA_WANT_ALG_CTR_DRBG + bool + prompt "PSA RNG using CTR-DRBG as PRNG" + help + Provide random number generator (RNG) using CTR-DRBG as the + pseudo-random number generator (PRNG), seeded by a true random + number generator (TRNG). + +config PSA_WANT_ALG_HMAC_DRBG + bool + prompt "PSA RNG using HMAC-DRBG as PRNG" + help + Provide random number generator (RNG) using HMAC-DRBG as the + pseudo-random number generator (PRNG), seeded by a true random + number generator (TRNG). + +endmenu # RNG support + +menu "PSA key type support" + +config PSA_HAS_KEY_SUPPORT + bool + default y + depends on PSA_WANT_KEY_TYPE_DERIVE || \ + PSA_WANT_KEY_TYPE_HMAC || \ + PSA_WANT_KEY_TYPE_RAW_DATA || \ + PSA_WANT_KEY_TYPE_PASSWORD || \ + PSA_WANT_KEY_TYPE_PASSWORD_HASH || \ + PSA_WANT_KEY_TYPE_PEPPER || \ + PSA_WANT_KEY_TYPE_AES || \ + PSA_WANT_KEY_TYPE_ARIA || \ + PSA_WANT_KEY_TYPE_DES || \ + PSA_WANT_KEY_TYPE_CAMELLIA || \ + PSA_WANT_KEY_TYPE_SM4 || \ + PSA_WANT_KEY_TYPE_ARC4 || \ + PSA_WANT_KEY_TYPE_CHACHA20 || \ + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE || \ + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT || \ + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT || \ + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE || \ + PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY || \ + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR || \ + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY || \ + PSA_WANT_KEY_TYPE_DH_KEY_PAIR || \ + PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY + +config PSA_WANT_KEY_TYPE_DERIVE + bool "PSA derive key type support" + help + This key type is for high-entropy secrets only. + For low-entropy secrets, password key type should be used instead. + +config PSA_WANT_KEY_TYPE_RAW_DATA + bool "PSA raw data key type support" + help + A "key" of this type cannot be used for any cryptographic operation. + Applications can use this type to store arbitrary data in the keystore. + +config PSA_WANT_KEY_TYPE_HMAC + bool "PSA HMAC key type support" + help + HMAC key. + +config PSA_WANT_KEY_TYPE_PASSWORD + bool "PSA password key type support" + help + A low-entropy secret for password hashing or key derivation. + +config PSA_WANT_KEY_TYPE_PASSWORD_HASH + bool "PSA password hash key type support" + help + A secret value that can be used to verify a password hash. + +config PSA_WANT_KEY_TYPE_PEPPER + bool "PSA pepper key type support" + help + A secret value that can be used when computing a password hash. + +config PSA_WANT_KEY_TYPE_AES + bool "PSA AES key type support" + help + Key for cipher, AEAD or MAC algorithm based on the AES block cipher. + +config PSA_WANT_KEY_TYPE_ARIA + bool "PSA ARIA key type support" + +config PSA_WANT_KEY_TYPE_DES + bool "PSA DES key type support (weak)" + help + Warning: Single DES and 2-key 3DES are weak and strongly deprecated + and are only recommended for decrypting legacy data. + 3-key 3DES is weak and deprecated and is only recommended for use in + legacy protocols. + +config PSA_WANT_KEY_TYPE_CAMELLIA + bool "PSA CAMELLIA key type support" + +config PSA_WANT_KEY_TYPE_SM4 + bool "PSA SM4 key type support" + +config PSA_WANT_KEY_TYPE_ARC4 + bool "PSA ARC4 key type support (weak)" + help + Warning: The ARC4 cipher is weak and deprecated and is only + recommended for use in legacy protocols. + +config PSA_WANT_KEY_TYPE_CHACHA20 + bool "PSA ChaCha20 key type support" + default y + depends on PSA_WANT_ALG_CHACHA20_POLY1305 || \ + PSA_WANT_ALG_STREAM_CIPHER + help + Key for the ChaCha20 stream cipher or the ChaCha20-Poly1305 AEAD algorithm. + + +config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR + bool "PSA ECC key pair support" + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + select PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT + select PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT + select PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE + select PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE + select DEPRECATED + help + DEPRECATED: This configuration will be removed in a future release, + please use the individual options for import, export, generate, + derive and public key instead. + + Elliptic curve key pair: both the private and public key. + + +config PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + bool "PSA ECC public key support" + help + Elliptic curve public key. + + +config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT + bool "PSA ECC import key pair support" + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + help + Elliptic curve key pair: import for both the private and public key. + +config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT + bool "PSA ECC export key pair support" + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + help + Elliptic curve key pair: export for both the private and public key. + +config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE + bool "PSA ECC generate key pair support" + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + help + Elliptic curve key pair: generate for both the private and public key. + +config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE + bool "PSA ECC derive key pair support" + select PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + help + Elliptic curve key pair: key derivation support. + +config PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC + bool + default y + depends on PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT || \ + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT || \ + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE || \ + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE + +config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR + bool "PSA RSA key pair type support" + select PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + help + RSA key pair: both the private and public key. + +config PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + bool "PSA RSA public key support" + help + RSA public key. + +config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT + bool "PSA RSA key pair import key" + default y if PSA_WANT_KEY_TYPE_RSA_KEY_PAIR + select PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + help + RSA key pair: import key for both the private and public key. + +config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT + bool "PSA RSA key pair export key" + default y if PSA_WANT_KEY_TYPE_RSA_KEY_PAIR + select PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + help + RSA key pair: export key for both the private and public key. + +config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE + bool "PSA RSA key pair generate key" + default y if PSA_WANT_KEY_TYPE_RSA_KEY_PAIR + select PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + help + RSA key pair: key generation for both the private and public key. + +config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC + bool + default y + depends on PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT || \ + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT || \ + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE + +config PSA_WANT_KEY_TYPE_DH_KEY_PAIR + bool "PSA DH key pair type support" + select PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY + help + Finite-field Diffie-Hellman key pair: both the private key and public key. + +config PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY + bool "PSA DH public key support" + help + Finite-field Diffie-Hellman public key. + +config PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR_IMPORT + bool "SPAKE2P key pair import support" + default y if PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR + select PSA_WANT_KEY_TYPE_SPAKE2P_PUBLIC_KEY + help + SPAKE2P key pair: import key for both the private and public key. + +config PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR_EXPORT + bool "SPAKE2P key pair export support" + default y if PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR + select PSA_WANT_KEY_TYPE_SPAKE2P_PUBLIC_KEY + help + SPAKE2P key pair: export key for both the private and public key. + +config PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR_DERIVE + bool "SPAKE2P key pair derive support" + default y if PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR + select PSA_WANT_KEY_TYPE_SPAKE2P_PUBLIC_KEY + help + SPAKE2P key pair: derive key for both the private and public key. + +config PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR_BASIC + bool + default y + depends on PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR_IMPORT || \ + PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR_EXPORT || \ + PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR_DERIVE + +config PSA_WANT_KEY_TYPE_SPAKE2P_KEY_PAIR + bool "SPAKE2P key pair support" + select PSA_WANT_KEY_TYPE_SPAKE2P_PUBLIC_KEY + help + SPAKE2P key pair: both the private and public key. + +config PSA_WANT_KEY_TYPE_SPAKE2P_PUBLIC_KEY + bool "SPAKE2P public key support" + help + SPAKE2P public key. + +config PSA_WANT_KEY_TYPE_SRP_KEY_PAIR_IMPORT + bool "SRP key pair import support" + default y if PSA_WANT_KEY_TYPE_SRP_KEY_PAIR + select PSA_WANT_KEY_TYPE_SRP_PUBLIC_KEY + help + SRP key pair: import key for both the private and public key. + +config PSA_WANT_KEY_TYPE_SRP_KEY_PAIR_EXPORT + bool "SRP key pair export support" + default y if PSA_WANT_KEY_TYPE_SRP_KEY_PAIR + select PSA_WANT_KEY_TYPE_SRP_PUBLIC_KEY + help + SRP key pair: export key for both the private and public key. + +config PSA_WANT_KEY_TYPE_SRP_KEY_PAIR_DERIVE + bool "SRP key pair derive support" + default y if PSA_WANT_KEY_TYPE_SRP_KEY_PAIR + select PSA_WANT_KEY_TYPE_SRP_PUBLIC_KEY + help + SRP key pair: derive key for both the private and public key. + +config PSA_WANT_KEY_TYPE_SRP_KEY_PAIR_BASIC + bool + default y + depends on PSA_WANT_KEY_TYPE_SRP_KEY_PAIR_IMPORT || \ + PSA_WANT_KEY_TYPE_SRP_KEY_PAIR_EXPORT || \ + PSA_WANT_KEY_TYPE_SRP_KEY_PAIR_DERIVE + +config PSA_WANT_KEY_TYPE_SRP_PUBLIC_KEY + bool "SRP public key support" + help + SRP public key. + +config PSA_WANT_KEY_TYPE_SRP_KEY_PAIR + bool "SRP public key support" + help + SRP public key. + +endmenu # PSA Key type support + +menu "PSA AEAD support" + +config PSA_HAS_AEAD_SUPPORT + bool + default y + depends on PSA_WANT_ALG_CCM || \ + PSA_WANT_ALG_GCM || \ + PSA_WANT_ALG_CHACHA20_POLY1305 + help + Prompt-less configuration that states that AEAD is supported. + +config PSA_WANT_ALG_CCM + bool + prompt "PSA CCM support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_GCM + bool + prompt "PSA GCM support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_CHACHA20_POLY1305 + bool + prompt "PSA ChaCha20-Poly1305 support" if !PSA_PROMPTLESS + +endmenu # PSA AEAD support + + +menu "PSA MAC support" + +config PSA_HAS_MAC_SUPPORT + bool + default y + depends on PSA_WANT_ALG_CBC_MAC || \ + PSA_WANT_ALG_CMAC || \ + PSA_WANT_ALG_HMAC + help + Prompt-less configuration that states that MAC is supported. + +config PSA_WANT_ALG_CBC_MAC + bool + prompt "PSA CBC-MAC support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_CMAC + bool + prompt "PSA CMAC support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_HMAC + bool + prompt "PSA HMAC support" if !PSA_PROMPTLESS + +endmenu # PSA MAC support + + +menu "PSA Hash support" + +config PSA_HAS_HASH_SUPPORT + bool + default y + depends on PSA_WANT_ALG_SHA_1 || \ + PSA_WANT_ALG_SHA_224 || \ + PSA_WANT_ALG_SHA_256 || \ + PSA_WANT_ALG_SHA_384 || \ + PSA_WANT_ALG_SHA_512 || \ + PSA_WANT_ALG_SHA_512_224 || \ + PSA_WANT_ALG_SHA_512_256 || \ + PSA_WANT_ALG_SHA3_224 || \ + PSA_WANT_ALG_SHA3_256 || \ + PSA_WANT_ALG_SHA3_384 || \ + PSA_WANT_ALG_SHA3_512 || \ + PSA_WANT_ALG_SM3 || \ + PSA_WANT_ALG_SHAKE256_512 || \ + PSA_WANT_ALG_RIPEMD160 || \ + PSA_WANT_ALG_MD2 || \ + PSA_WANT_ALG_MD4 || \ + PSA_WANT_ALG_MD5 + help + Prompt-less configuration that states that hash is supported. + +config PSA_WANT_ALG_SHA_1 + bool + prompt "PSA SHA-1 support (weak)" if !PSA_PROMPTLESS + help + Warning: The SHA-1 hash is weak and deprecated and is only recommended + for use in legacy protocols. + +config PSA_WANT_ALG_SHA_224 + bool + prompt "PSA SHA-224 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA_256 + bool + prompt "PSA SHA-256 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA_384 + bool + prompt "PSA SHA-384 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA_512 + bool + prompt "PSA SHA-512 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA_512_224 + bool + prompt "PSA SHA-512/224 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA_512_256 + bool + prompt "PSA SHA-512/256 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA3_224 + bool + prompt "PSA SHA3-224 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA3_256 + bool + prompt "PSA SHA3-256 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA3_384 + bool + prompt "PSA SHA3-384 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHA3_512 + bool + prompt "PSA SHA3-512 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SM3 + bool + prompt "PSA SM3 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SHAKE256_512 + bool + prompt "PSA SHAKE256 512 bits support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_RIPEMD160 + bool + prompt "PSA RIPEMD-160 support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_MD2 + bool + prompt "PSA MD2 support (weak)" if !PSA_PROMPTLESS + help + Warning: The MD2 hash is weak and deprecated and is only recommended + for use in legacy protocols. + +config PSA_WANT_ALG_MD4 + bool + prompt "PSA MD4 support (weak)" if !PSA_PROMPTLESS + help + Warning: The MD4 hash is weak and deprecated and is only recommended + for use in legacy protocols. + +config PSA_WANT_ALG_MD5 + bool + prompt "PSA MD5 support (weak)" if !PSA_PROMPTLESS + help + Warning: The MD5 hash is weak and deprecated and is only recommended + for use in legacy protocols. + +endmenu # PSA Hash support + +menu "PSA Cipher support" + +config PSA_HAS_CIPHER_SUPPORT + bool + default y + depends on PSA_WANT_ALG_ECB_NO_PADDING || \ + PSA_WANT_ALG_CBC_NO_PADDING || \ + PSA_WANT_ALG_CBC_PKCS7 || \ + PSA_WANT_ALG_CCM_STAR_NO_TAG || \ + PSA_WANT_ALG_CFB || \ + PSA_WANT_ALG_CTR || \ + PSA_WANT_ALG_OFB || \ + PSA_WANT_ALG_XTS || \ + PSA_WANT_ALG_STREAM_CIPHER + help + Prompt-less configuration that states that cipher is supported. + +config PSA_WANT_ALG_ECB_NO_PADDING + bool + prompt "PSA ECB block cipher mode support (with no padding)" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_CBC_NO_PADDING + bool + prompt "PSA CBC block cipher mode support (with no padding)" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_CBC_PKCS7 + bool + prompt "PSA CBC block cipher mode support (with PKCS#7 padding)" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_CFB + bool + prompt "PSA stream cipher using CFB block cipher mode support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_CTR + bool + prompt "PSA stream cipher using CTR block cipher mode support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_OFB + bool + prompt "PSA stream cipher using OFB block cipher mode support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_XTS + bool + prompt "PSA XTS block cipher mode support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_CCM_STAR_NO_TAG + bool + prompt "PSA CCM* with no tag support" if !PSA_PROMPTLESS + help + Unauthenticated version of CCM. Uses the cipher API instead of the AEAD API. + +config PSA_WANT_ALG_STREAM_CIPHER + bool + prompt "PSA stream cipher support" if !PSA_PROMPTLESS + +endmenu # PSA Cipher Support + +menu "PSA Key agreement support" + +config PSA_HAS_KEY_AGREEMENT + bool + default y + depends on PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH + help + Promt-less configuration that states that key agreement is supported. + +config PSA_WANT_ALG_ECDH + bool + prompt "PSA ECDH support" if !PSA_PROMPTLESS + + +config PSA_WANT_ALG_FFDH + bool + prompt "PSA FFDH support" if !PSA_PROMPTLESS + +endmenu # PSA Key agreement support + +menu "PSA Key derivation support" + +config PSA_HAS_KEY_DERIVATION + bool + default y + depends on PSA_WANT_ALG_HKDF || \ + PSA_WANT_ALG_HKDF_EXPAND || \ + PSA_WANT_ALG_HKDF_EXTRACT || \ + PSA_WANT_ALG_PBKDF2_HMAC || \ + PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128 || \ + PSA_WANT_ALG_TLS12_PRF || \ + PSA_WANT_ALG_TLS12_PSK_TO_MS || \ + PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS + help + Prompt-less configuration that states that key derivation is supported. + +config PSA_WANT_ALG_HKDF + bool + prompt "PSA HKDF support" if !PSA_PROMPTLESS + depends on PSA_WANT_ALG_HMAC + +config PSA_WANT_ALG_HKDF_EXTRACT + bool + prompt "PSA HKDF extract support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_HKDF_EXPAND + bool + prompt "PSA HKDF expand support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_PBKDF2_HMAC + bool + prompt "PSA PBKDF2 HMAC support" if !PSA_PROMPTLESS + depends on PSA_WANT_ALG_HMAC + +config PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128 + bool + prompt "PSA PBKDF2-AES-CMAC-PRF-128 support" if !PSA_PROMPTLESS + depends on PSA_WANT_ALG_CMAC + +config PSA_WANT_ALG_SP800_108_COUNTER_HMAC + bool + prompt "Add PSA SP800-108r1 CTR HMAC KBKDF support" + depends on PSA_WANT_ALG_HMAC + +config PSA_WANT_ALG_SP800_108_COUNTER_CMAC + bool + prompt "Add PSA SP800-108r1 CTR CMAC KBKDF support" + depends on PSA_WANT_ALG_CMAC + +config PSA_WANT_ALG_TLS12_PRF + bool + prompt "PSA PRF support (TLS1.2)" if !PSA_PROMPTLESS + depends on PSA_WANT_ALG_HMAC + +config PSA_WANT_ALG_TLS12_PSK_TO_MS + bool + prompt "PSA TLS 1.2 PSK to MS support" if !PSA_PROMPTLESS + depends on PSA_WANT_ALG_HMAC + +config PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS + bool + prompt "PSA TLS 1.2 EC J-PAKE to PMS support" if !PSA_PROMPTLESS + depends on PSA_WANT_ALG_SHA_256 + +endmenu # PSA Key derivation support + + +menu "PSA Asymmetric support" + +config PSA_HAS_ASYM_ENCRYPT_SUPPORT + bool + default y + depends on PSA_WANT_ALG_RSA_OAEP || \ + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + help + Prompt-less configuration that states that asymmetric encryption + is supported. + + +config PSA_HAS_ASYM_SIGN_SUPPORT + bool + default y + depends on PSA_WANT_ALG_DETERMINISTIC_ECDSA || \ + PSA_WANT_ALG_ECDSA || \ + PSA_WANT_ALG_ECDSA_ANY || \ + PSA_WANT_ALG_PURE_EDDSA || \ + PSA_WANT_ALG_ED25519PH || \ + PSA_WANT_ALG_ED448PH || \ + PSA_WANT_ALG_RSA_PKCS1V15_SIGN || \ + PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW || \ + PSA_WANT_ALG_RSA_PSS || \ + PSA_WANT_ALG_RSA_PSS_ANY_SALT + help + Prompt-less configuration that states that asymmetric signing + is supported. + +config PSA_WANT_ALG_ECDSA + bool + prompt "PSA ECDSA support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_ECDSA_ANY + bool + prompt "PSA ECDSA support, without hashing" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_DETERMINISTIC_ECDSA + bool + prompt "PSA ECDSA support (deterministic mode)" if !PSA_PROMPTLESS + +menu "Elliptic Curve type support" + +config PSA_WANT_ECC_BRAINPOOL_P_R1_160 + bool + prompt "PSA ECC BrainpoolP160r1 support (weak)" if !PSA_PROMPTLESS + help + Warning: The 160-bit curve brainpoolP160r1 is weak and deprecated and + is only recommended for use in legacy protocols. + +config PSA_WANT_ECC_BRAINPOOL_P_R1_192 + bool + prompt "PSA ECC BrainpoolP192r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_BRAINPOOL_P_R1_224 + bool + prompt "PSA ECC BrainpoolP224r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_BRAINPOOL_P_R1_256 + bool + prompt "PSA ECC BrainpoolP256r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_BRAINPOOL_P_R1_320 + bool + prompt "PSA ECC BrainpoolP320r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_BRAINPOOL_P_R1_384 + bool + prompt "PSA ECC BrainpoolP384r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_BRAINPOOL_P_R1_512 + bool + prompt "PSA ECC BrainpoolP512r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_MONTGOMERY_255 + bool + prompt "PSA ECC Curve25519 (X25519) support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_MONTGOMERY_448 + bool + prompt "PSA ECC Curve448 (X448) support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_TWISTED_EDWARDS_255 + bool + prompt "PSA ECC Edwards25519 (Ed25519) support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_TWISTED_EDWARDS_448 + bool + prompt "PSA ECC Edwards448 (Ed448) support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_K1_192 + bool + prompt "PSA ECC secp192k1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_K1_224 + bool + prompt "PSA ECC secp224k1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_K1_256 + bool + prompt "PSA ECC secp256k1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_R1_192 + bool + prompt "PSA ECC secp192r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_R1_224 + bool + prompt "PSA ECC secp224r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_R1_256 + bool + prompt "PSA ECC secp256r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_R1_384 + bool + prompt "PSA ECC secp384r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_R1_521 + bool + prompt "PSA ECC secp521r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECP_R2_160 + bool + prompt "PSA ECC secp160r2 support (weak)" if !PSA_PROMPTLESS + help + Warning: his family of curves is weak and deprecated. + +config PSA_WANT_ECC_SECT_K1_163 + bool + prompt "PSA ECC sect163k1 support (weak)" if !PSA_PROMPTLESS + help + Warning: The 163-bit curve sect163k1 is weak and deprecated and is + only recommended for use in legacy protocols. + +config PSA_WANT_ECC_SECT_K1_233 + bool + prompt "PSA ECC sect233k1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_K1_239 + bool + prompt "PSA ECC sect239k1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_K1_283 + bool + prompt "PSA ECC sect283k1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_K1_409 + bool + prompt "PSA ECC sect409k1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_K1_571 + bool + prompt "PSA ECC sect571k1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_R1_163 + bool + prompt "PSA ECC sect163r1 support (weak)" if !PSA_PROMPTLESS + help + Warning: The 163-bit curve sect163r1 is weak and deprecated and is + only recommended for use in legacy protocols. + +config PSA_WANT_ECC_SECT_R1_233 + bool + prompt "PSA ECC sect233r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_R1_283 + bool + prompt "PSA ECC sect283r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_R1_409 + bool + prompt "PSA ECC sect409r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_R1_571 + bool + prompt "PSA ECC sect571r1 support" if !PSA_PROMPTLESS + +config PSA_WANT_ECC_SECT_R2_163 + bool + prompt "PSA ECC sect163r2 support (weak)" if !PSA_PROMPTLESS + help + Warning: The 163-bit curve sect163r2 is weak and deprecated and is + only recommended for use in legacy protocols. + +config PSA_WANT_ECC_FRP_V1_256 + bool + prompt "PSA ECC FRP256v1 support" if !PSA_PROMPTLESS + +endmenu # Elliptic Curve type support + +config PSA_WANT_ALG_RSA_OAEP + bool + prompt "PSA RSA OAEP asymmetric encryption support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + bool + prompt "PSA RSA PKCS#1 v1.5 asymmetric encryption support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_RSA_PKCS1V15_SIGN + bool + prompt "PSA RSA PKCS#1 v1.5 message signature support, with hashing" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW + bool + prompt "PSA RSA raw PKCS#1 v1.5 message signature support, without hashing)" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_RSA_PSS + bool + prompt "PSA RSA PSS message signature support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_RSA_PSS_ANY_SALT + bool + prompt "PSA RSA PSS message signature support, any salt length" if !PSA_PROMPTLESS + +endmenu # PSA Asymmetric support + +config PSA_WANT_ALG_JPAKE + bool + prompt "PSA EC J-PAKE support" if !PSA_PROMPTLESS + select EXPERIMENTAL if !NET_L2_OPENTHREAD + +config PSA_WANT_ALG_SPAKE2P_HMAC + bool + prompt "PSA SPAKE2+ HMAC support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SPAKE2P_CMAC + bool + prompt "PSA SPAKE2+ CMAC support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SPAKE2P_MATTER + bool + prompt "PSA SPAKE2+ MATTER support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_SRP_6 + bool + prompt "PSA SRP-6 support" if !PSA_PROMPTLESS + select EXPERIMENTAL + +config PSA_WANT_ALG_SRP_PASSWORD_HASH + bool + prompt "PSA SRP password hash support" if !PSA_PROMPTLESS + select EXPERIMENTAL + +config PSA_HAS_PAKE_SUPPORT + bool + default y + depends on PSA_WANT_ALG_JPAKE || \ + PSA_WANT_ALG_SPAKE2P_HMAC || \ + PSA_WANT_ALG_SPAKE2P_CMAC || \ + PSA_WANT_ALG_SPAKE2P_MATTER || \ + PSA_WANT_ALG_SRP_6 || \ + PSA_WANT_ALG_SRP_PASSWORD_HASH + help + Prompt-less configuration that states that PAKE is supported. + +config PSA_WANT_ALG_PURE_EDDSA + bool + prompt "PSA PURE_EDDSA support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_ED25519PH + bool + prompt "PSA ED25519PH support" if !PSA_PROMPTLESS + +config PSA_WANT_ALG_ED448PH + bool + prompt "PSA ED448PH support" if !PSA_PROMPTLESS diff --git a/modules/mbedtls/Kconfig.tls-generic b/modules/mbedtls/Kconfig.tls-generic index 3c0e17c0fe35..d629c1b1d2a0 100644 --- a/modules/mbedtls/Kconfig.tls-generic +++ b/modules/mbedtls/Kconfig.tls-generic @@ -9,6 +9,8 @@ menu "TLS configuration" menu "Supported TLS version" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_TLS_VERSION_1_0 bool "Support for TLS 1.0" select MBEDTLS_CIPHER @@ -33,6 +35,8 @@ config MBEDTLS_DTLS bool "Support for DTLS" depends on MBEDTLS_TLS_VERSION_1_1 || MBEDTLS_TLS_VERSION_1_2 +endif + config MBEDTLS_SSL_EXPORT_KEYS bool "Support for exporting SSL key block and master secret" depends on MBEDTLS_TLS_VERSION_1_0 || MBEDTLS_TLS_VERSION_1_1 || MBEDTLS_TLS_VERSION_1_2 @@ -47,6 +51,8 @@ menu "Ciphersuite configuration" comment "Supported key exchange modes" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_KEY_EXCHANGE_ALL_ENABLED bool "All available ciphersuite modes" select MBEDTLS_KEY_EXCHANGE_PSK_ENABLED @@ -81,6 +87,8 @@ config MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED || \ MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED +endif + config MBEDTLS_PSK_MAX_LEN int "Max size of TLS pre-shared keys" default 32 @@ -88,6 +96,8 @@ config MBEDTLS_PSK_MAX_LEN help Max size of TLS pre-shared keys, in bytes. +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_KEY_EXCHANGE_RSA_ENABLED bool "RSA-only based ciphersuite modes" default y if !NET_L2_OPENTHREAD @@ -202,6 +212,7 @@ config MBEDTLS_ECP_NIST_OPTIM bool "NSIT curves optimization" endif +endif # !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) comment "Supported hash" @@ -226,6 +237,8 @@ config MBEDTLS_HASH_SHA512_ENABLED comment "Supported cipher modes" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_CIPHER_ALL_ENABLED bool "All available ciphers" select MBEDTLS_CIPHER_AES_ENABLED @@ -299,8 +312,12 @@ config MBEDTLS_CHACHAPOLY_AEAD_ENABLED bool "ChaCha20-Poly1305 AEAD algorithm" depends on MBEDTLS_CIPHER_CHACHA20_ENABLED || MBEDTLS_MAC_POLY1305_ENABLED +endif + comment "Supported message authentication methods" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_MAC_ALL_ENABLED bool "All available MAC methods" select MBEDTLS_MAC_MD4_ENABLED @@ -349,10 +366,14 @@ config MBEDTLS_MAC_CMAC_ENABLED bool "CMAC (Cipher-based Message Authentication Code) mode for block ciphers." depends on MBEDTLS_CIPHER_AES_ENABLED || MBEDTLS_CIPHER_DES_ENABLED +endif + endmenu comment "Random number generators" +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_CTR_DRBG_ENABLED bool "CTR_DRBG AES-256-based random generator" depends on MBEDTLS_CIPHER_AES_ENABLED @@ -362,14 +383,20 @@ config MBEDTLS_HMAC_DRBG_ENABLED bool "HMAC_DRBG random generator" select MBEDTLS_MD +endif + comment "Other configurations" config MBEDTLS_CIPHER bool "generic cipher layer." +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_MD bool "generic message digest layer." +endif + config MBEDTLS_GENPRIME_ENABLED bool "prime-number generation code." @@ -387,11 +414,15 @@ config MBEDTLS_HAVE_ASM of asymmetric cryptography, however this might have an impact on the code size. +if !(NRF_SECURITY || NORDIC_SECURITY_BACKEND) + config MBEDTLS_ENTROPY_ENABLED bool "MbedTLS generic entropy pool" depends on MBEDTLS_MAC_SHA256_ENABLED || MBEDTLS_MAC_SHA384_ENABLED || MBEDTLS_MAC_SHA512_ENABLED default y if MBEDTLS_ZEPHYR_ENTROPY +endif + config MBEDTLS_OPENTHREAD_OPTIMIZATIONS_ENABLED bool "MbedTLS optimizations for OpenThread" depends on NET_L2_OPENTHREAD diff --git a/modules/mbedtls/zephyr_init.c b/modules/mbedtls/zephyr_init.c index 28a6a40fdc54..49c9ffc8aff1 100644 --- a/modules/mbedtls/zephyr_init.c +++ b/modules/mbedtls/zephyr_init.c @@ -47,7 +47,7 @@ static void init_heap(void) #define init_heap(...) #endif /* CONFIG_MBEDTLS_ENABLE_HEAP && MBEDTLS_MEMORY_BUFFER_ALLOC_C */ -#if defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) +#if defined(CONFIG_MBEDTLS_ZEPHYR_ENTROPY) && !defined(CONFIG_NRF_CC3XX_PLATFORM) static const struct device *const entropy_dev = DEVICE_DT_GET_OR_NULL(DT_CHOSEN(zephyr_entropy)); diff --git a/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules b/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules index 1d70a2c44d29..9604319ca012 100644 --- a/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules +++ b/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules @@ -10,6 +10,7 @@ if TFM_PARTITION_CRYPTO config TFM_CRYPTO_RNG_MODULE_ENABLED bool "Random number generator crypto module" default y + depends on PSA_WANT_GENERATE_RANDOM && NRF_SECURITY help Enables the random number generator module within the crypto partition. Unset this option if 'psa_generate_random' is not used. @@ -17,6 +18,7 @@ config TFM_CRYPTO_RNG_MODULE_ENABLED config TFM_CRYPTO_KEY_MODULE_ENABLED bool "KEY crypto module" default y + depends on PSA_HAS_KEY_SUPPORT && NRF_SECURITY help Enables the KEY crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_key_management.c' @@ -25,6 +27,7 @@ config TFM_CRYPTO_KEY_MODULE_ENABLED config TFM_CRYPTO_AEAD_MODULE_ENABLED bool "AEAD crypto module" default y + depends on PSA_HAS_AEAD_SUPPORT && NRF_SECURITY help Enables the AEAD crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_aead.c' @@ -33,6 +36,7 @@ config TFM_CRYPTO_AEAD_MODULE_ENABLED config TFM_CRYPTO_MAC_MODULE_ENABLED bool "MAC crypto module" default y + depends on PSA_HAS_MAC_SUPPORT && NRF_SECURITY help Enables the MAC crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_mac.c' @@ -41,6 +45,7 @@ config TFM_CRYPTO_MAC_MODULE_ENABLED config TFM_CRYPTO_HASH_MODULE_ENABLED bool "HASH crypto module" default y + depends on PSA_HAS_HASH_SUPPORT && NRF_SECURITY help Enables the HASH crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_hash.c' @@ -49,6 +54,7 @@ config TFM_CRYPTO_HASH_MODULE_ENABLED config TFM_CRYPTO_CIPHER_MODULE_ENABLED bool "CIPHER crypto module" default y + depends on PSA_HAS_CIPHER_SUPPORT && NRF_SECURITY help Enables the CIPHER crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_cipher.c' @@ -57,6 +63,7 @@ config TFM_CRYPTO_CIPHER_MODULE_ENABLED config TFM_CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED bool "ASYM ENCRYPT crypto module" default y + depends on PSA_HAS_ASYM_ENCRYPT_SUPPORT && NRF_SECURITY help Enables the ASYM ENCRYPT crypto module within the crypto partition. Unset this option if the encrypt functionality provided by 'crypto_asymmetric.c' @@ -65,6 +72,7 @@ config TFM_CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED config TFM_CRYPTO_ASYM_SIGN_MODULE_ENABLED bool "ASYM SIGN crypto module" default y + depends on PSA_HAS_ASYM_SIGN_SUPPORT && NRF_SECURITY help Enables the ASYM SIGN crypto module within the crypto partition. Unset this option if the sign functionality provided by 'crypto_asymmetric.c' @@ -73,10 +81,23 @@ config TFM_CRYPTO_ASYM_SIGN_MODULE_ENABLED config TFM_CRYPTO_KEY_DERIVATION_MODULE_ENABLED bool "KEY DERIVATION crypto module" default y + depends on (PSA_HAS_KEY_DERIVATION || PSA_HAS_KEY_AGREEMENT) && NRF_SECURITY help Enables the KEY_DERIVATION crypto module within the crypto partition. Unset this option if the functionality provided by 'crypto_key_derivation.c' is not used. + Note that key agreement is under key derivation in the current implementation. + +config TFM_CRYPTO_PAKE_MODULE_ENABLED + bool "PAKE crypto module" + default y + depends on PSA_HAS_PAKE_SUPPORT + depends on NRF_SECURITY + depends on PSA_CRYPTO_DRIVER_OBERON || PSA_CRYPTO_DRIVER_CRACEN + help + Enables the PAKE crypto module within the crypto partition. + Unset this option if the functionality provided by 'crypto_pake.c' + is not used. endif # TFM_PARTITION_CRYPTO diff --git a/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay deleted file mode 100644 index 02db7c39272b..000000000000 --- a/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2024 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/ { - chosen { - zephyr,bt-hci-ipc = &ipc0; - }; -}; - -ipc0: &cpuapp_cpurad_ipc { - status = "okay"; -}; - -&cpuapp_cpurad_ram0x_region { - status = "okay"; -}; - -&cpurad_bellboard { - status = "okay"; -}; - -&cpuapp_bellboard { - status = "okay"; -}; diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf index f0a22f760f9b..6b407a208f72 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf @@ -24,12 +24,6 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host features CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf index 7fab285f3bed..6dd49214caa6 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf @@ -24,12 +24,6 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host features CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=n diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf index 21d4a042ad75..ab87866b19a2 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf @@ -24,12 +24,6 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host features CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf index f80f324be53e..0bb34dfa7903 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf @@ -25,12 +25,6 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host features CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf index 74dc735c076c..12f3b8a11478 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf @@ -16,12 +16,6 @@ CONFIG_BT_HCI_RAW_RESERVE=1 # Host number of completed commands does not follow normal flow control. CONFIG_BT_BUF_CMD_TX_COUNT=10 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host CONFIG_BT_BROADCASTER=y CONFIG_BT_PERIPHERAL=n diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf index f29917aaf935..e7ec0c140d6e 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf @@ -21,12 +21,6 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host CONFIG_BT_BROADCASTER=n CONFIG_BT_PERIPHERAL=n diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf index ddd7d7e7b317..fa3d303604ed 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf @@ -21,12 +21,6 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host CONFIG_BT_BROADCASTER=y CONFIG_BT_PERIPHERAL=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf index d88aa87f8aa4..d139e83996a7 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf @@ -16,12 +16,6 @@ CONFIG_BT_HCI_RAW_RESERVE=1 # Host number of completed commands does not follow normal flow control. CONFIG_BT_BUF_CMD_TX_COUNT=10 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host CONFIG_BT_BROADCASTER=n CONFIG_BT_PERIPHERAL=n diff --git a/samples/bluetooth/hci_pwr_ctrl/child_image/hci_rpmsg.conf b/samples/bluetooth/hci_pwr_ctrl/child_image/hci_rpmsg.conf new file mode 100644 index 000000000000..e6749ae63990 --- /dev/null +++ b/samples/bluetooth/hci_pwr_ctrl/child_image/hci_rpmsg.conf @@ -0,0 +1 @@ +CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y diff --git a/samples/bluetooth/hci_pwr_ctrl/sysbuild/hci_rpmsg.conf b/samples/bluetooth/hci_pwr_ctrl/sysbuild/hci_rpmsg.conf new file mode 100644 index 000000000000..e6749ae63990 --- /dev/null +++ b/samples/bluetooth/hci_pwr_ctrl/sysbuild/hci_rpmsg.conf @@ -0,0 +1 @@ +CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y diff --git a/samples/bluetooth/peripheral_hr/prj_minimal.conf b/samples/bluetooth/peripheral_hr/prj_minimal.conf index 888c75d8a5d5..a9feeb48cb00 100644 --- a/samples/bluetooth/peripheral_hr/prj_minimal.conf +++ b/samples/bluetooth/peripheral_hr/prj_minimal.conf @@ -69,7 +69,6 @@ CONFIG_ARM_MPU=n # idle 00 : STACK: unused 208 usage 48 / 256 (18 %); CPU: 97 % # main : STACK: unused 576 usage 448 / 1024 (43 %); CPU: 0 % CONFIG_BT_RX_STACK_SIZE=1024 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y CONFIG_BT_HCI_TX_STACK_SIZE=640 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 diff --git a/samples/boards/nrf/nrf53_sync_rtc/sysbuild.conf b/samples/boards/nrf/nrf53_sync_rtc/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/boards/nrf/nrf53_sync_rtc/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/drivers/adc/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/samples/drivers/adc/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..f185624f9b93 --- /dev/null +++ b/samples/drivers/adc/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -0,0 +1,45 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2024 Nordic Semiconductor ASA + */ + +/ { + zephyr,user { + io-channels = <&adc 0>, <&adc 1>, <&adc 7>; + }; +}; + +&adc { + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; /* P1.11 */ + zephyr,resolution = <10>; + }; + + channel@1 { + reg = <1>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; /* P1.06 */ + zephyr,resolution = <12>; + zephyr,oversampling = <8>; + }; + + channel@7 { + reg = <7>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; /* P1.13 */ + zephyr,input-negative = ; /* P1.14 */ + zephyr,resolution = <12>; + }; +}; diff --git a/samples/drivers/jesd216/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/samples/drivers/jesd216/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..b8f138ad2b2e --- /dev/null +++ b/samples/drivers/jesd216/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&mx25uw63 { + status = "okay"; +}; diff --git a/samples/drivers/mbox/sysbuild.conf b/samples/drivers/mbox/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/drivers/mbox/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/net/dhcpv4_client/overlay-nrf700x.conf b/samples/net/dhcpv4_client/overlay-nrf700x.conf new file mode 100644 index 000000000000..2d552e9c6231 --- /dev/null +++ b/samples/net/dhcpv4_client/overlay-nrf700x.conf @@ -0,0 +1,14 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/dns_resolve/overlay-nrf700x.conf b/samples/net/dns_resolve/overlay-nrf700x.conf new file mode 100644 index 000000000000..aa59e5d5ea2d --- /dev/null +++ b/samples/net/dns_resolve/overlay-nrf700x.conf @@ -0,0 +1,18 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/ipv4_autoconf/overlay-nrf700x.conf b/samples/net/ipv4_autoconf/overlay-nrf700x.conf new file mode 100644 index 000000000000..2d552e9c6231 --- /dev/null +++ b/samples/net/ipv4_autoconf/overlay-nrf700x.conf @@ -0,0 +1,14 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/lwm2m_client/overlay-nrf700x.conf b/samples/net/lwm2m_client/overlay-nrf700x.conf new file mode 100644 index 000000000000..2409886fe420 --- /dev/null +++ b/samples/net/lwm2m_client/overlay-nrf700x.conf @@ -0,0 +1,68 @@ +# General +CONFIG_MAIN_STACK_SIZE=4096 +CONFIG_ENTROPY_GENERATOR=y +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 + +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WIFI_MGMT_EXT=y +CONFIG_NRF_WIFI_IF_AUTO_START=n + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" + +# WPA +CONFIG_WPA_SUPP=y +CONFIG_WPA_SUPP_LOG_LEVEL_ERR=y + +CONFIG_NET_NATIVE=y +CONFIG_NET_L2_ETHERNET=y +CONFIG_NET_UDP=y +CONFIG_NET_SOCKETS=y +CONFIG_NET_SOCKETS_OFFLOAD=n +CONFIG_NET_BUF_RX_COUNT=18 +CONFIG_NET_BUF_TX_COUNT=18 +CONFIG_NET_DEFAULT_IF_WIFI=y + +# DNS +CONFIG_DNS_RESOLVER=y + +# DHCPv4 +CONFIG_NET_DHCPV4=y +CONFIG_NET_CONFIG_AUTO_INIT=n +CONFIG_NET_CONFIG_NEED_IPV6=n +CONFIG_NET_CONFIG_NEED_IPV4=n + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Zephyr NET Connection Manager Connectivity layer. +CONFIG_L2_WIFI_CONNECTIVITY=y +CONFIG_L2_WIFI_CONNECTIVITY_AUTO_DOWN=n +CONFIG_L2_WIFI_CONNECTIVITY_AUTO_CONNECT=n + +CONFIG_LWM2M_APP_ID="nrf700x" +CONFIG_LWM2M_APP_SERVER="coaps://leshan.eclipseprojects.io:5684" +CONFIG_LWM2M_DNS_SUPPORT=y + +# Enable DTLS support +CONFIG_LWM2M_DTLS_SUPPORT=y +CONFIG_LWM2M_TLS_SESSION_CACHING=y + +# TLS networking +CONFIG_NET_SOCKETS_ENABLE_DTLS=y +CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4 +CONFIG_NET_SOCKETS_SOCKOPT_TLS=y + +# nRF Security +CONFIG_NRF_SECURITY=y + +# mbedTLS +CONFIG_MBEDTLS=y +CONFIG_MBEDTLS_ENABLE_HEAP=y +CONFIG_MBEDTLS_HEAP_SIZE=120000 +CONFIG_MBEDTLS_RSA_C=y diff --git a/samples/net/lwm2m_client/overlay-nrf91x.conf b/samples/net/lwm2m_client/overlay-nrf91x.conf new file mode 100644 index 000000000000..9597791c10ee --- /dev/null +++ b/samples/net/lwm2m_client/overlay-nrf91x.conf @@ -0,0 +1,53 @@ +# Configuration file for nRF91x +# This file is merged with prj.conf in the application folder, and options +# set here will take precedence if they are present in both files. + +# General +CONFIG_MAIN_STACK_SIZE=4096 + +CONFIG_NET_SOCKETS=y +CONFIG_NET_NATIVE=y +CONFIG_NET_SOCKETS_OFFLOAD=y + +CONFIG_NET_CONFIG_MY_IPV6_ADDR="" +CONFIG_NET_CONFIG_PEER_IPV6_ADDR="" +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_CONFIG_MY_IPV4_GW="" + +CONFIG_NET_CONFIG_NEED_IPV6=n +CONFIG_NET_CONFIG_NEED_IPV4=n +CONFIG_NET_CONFIG_AUTO_INIT=n + +# Modem related configurations +CONFIG_NRF_MODEM_LIB_NET_IF=y +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN=n +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT=n +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START=n +CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y + +CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=n +CONFIG_NRF_MODEM_LIB_NET_IF_LOG_LEVEL_DBG=n + +# Disable Duplicate Address Detection (DAD) +# due to not being properly implemented for offloaded interfaces. +CONFIG_NET_IPV6_NBR_CACHE=n +CONFIG_NET_IPV6_MLD=n + +# Zephyr NET Connection Manager and Connectivity layer. +CONFIG_NET_CONNECTION_MANAGER=y +CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024 + +CONFIG_LWM2M_APP_ID="nrf91x" +CONFIG_LWM2M_APP_SERVER="coaps://leshan.eclipseprojects.io:5684" +CONFIG_LWM2M_DNS_SUPPORT=y + +## Enable DTLS support +CONFIG_LWM2M_DTLS_SUPPORT=y +CONFIG_LWM2M_TLS_SESSION_CACHING=y +CONFIG_LWM2M_DTLS_CID=y +CONFIG_TLS_CREDENTIALS=y + +## Crypto +CONFIG_OBERON_BACKEND=y +CONFIG_NORDIC_SECURITY_BACKEND=y +CONFIG_MBEDTLS_SHA256_C=y diff --git a/samples/net/mdns_responder/overlay-nrf700x.conf b/samples/net/mdns_responder/overlay-nrf700x.conf new file mode 100644 index 000000000000..aa59e5d5ea2d --- /dev/null +++ b/samples/net/mdns_responder/overlay-nrf700x.conf @@ -0,0 +1,18 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/mqtt_publisher/overlay-nrf700x.conf b/samples/net/mqtt_publisher/overlay-nrf700x.conf new file mode 100644 index 000000000000..a812c7896f62 --- /dev/null +++ b/samples/net/mqtt_publisher/overlay-nrf700x.conf @@ -0,0 +1,19 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_CONFIG_NEED_IPV4=y +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/mqtt_sn_publisher/overlay-nrf700x.conf b/samples/net/mqtt_sn_publisher/overlay-nrf700x.conf new file mode 100644 index 000000000000..cbc47b965727 --- /dev/null +++ b/samples/net/mqtt_sn_publisher/overlay-nrf700x.conf @@ -0,0 +1,20 @@ +CONFIG_POSIX_MAX_FDS=16 + +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/can/sample.yaml b/samples/net/sockets/can/sample.yaml index 4e1d9d1c9fa2..a9dff7079d36 100644 --- a/samples/net/sockets/can/sample.yaml +++ b/samples/net/sockets/can/sample.yaml @@ -8,6 +8,10 @@ common: filter: dt_chosen_enabled("zephyr,canbus") and not dt_compat_enabled("kvaser,pcican") depends_on: can harness: console + # native_posix does not work with CONFIG_POSIX_API + platform_exclude: + - native_posix + - native_posix/native/64 tests: sample.net.sockets.can.one_socket: extra_configs: diff --git a/samples/net/sockets/coap_client/overlay-nrf700x.conf b/samples/net/sockets/coap_client/overlay-nrf700x.conf new file mode 100644 index 000000000000..a0e436e3537d --- /dev/null +++ b/samples/net/sockets/coap_client/overlay-nrf700x.conf @@ -0,0 +1,16 @@ +CONFIG_HEAP_MEM_POOL_SIZE=153000 + +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/coap_server/overlay-nrf700x.conf b/samples/net/sockets/coap_server/overlay-nrf700x.conf new file mode 100644 index 000000000000..4817a4f73ba6 --- /dev/null +++ b/samples/net/sockets/coap_server/overlay-nrf700x.conf @@ -0,0 +1,26 @@ +CONFIG_HEAP_MEM_POOL_SIZE=153000 + +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# The sample can run either IPv4 or IPv6, not both +CONFIG_NET_IPV6=n +CONFIG_NET_CONFIG_NEED_IPV6=n +CONFIG_NET_IPV4=y +CONFIG_NET_CONFIG_NEED_IPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/dumb_http_server_mt/sample.yaml b/samples/net/sockets/dumb_http_server_mt/sample.yaml index fa69fea8c977..dc0c81822468 100644 --- a/samples/net/sockets/dumb_http_server_mt/sample.yaml +++ b/samples/net/sockets/dumb_http_server_mt/sample.yaml @@ -9,6 +9,10 @@ common: - net - socket - http + # native_posix does not work with CONFIG_POSIX_API + platform_exclude: + - native_posix + - native_posix/native/64 tests: sample.net.sockets.dumb_http_server_mt: extra_configs: diff --git a/samples/net/sockets/echo/overlay-nrf700x.conf b/samples/net/sockets/echo/overlay-nrf700x.conf new file mode 100644 index 000000000000..aa59e5d5ea2d --- /dev/null +++ b/samples/net/sockets/echo/overlay-nrf700x.conf @@ -0,0 +1,18 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/echo_async/overlay-nrf700x.conf b/samples/net/sockets/echo_async/overlay-nrf700x.conf new file mode 100644 index 000000000000..aa59e5d5ea2d --- /dev/null +++ b/samples/net/sockets/echo_async/overlay-nrf700x.conf @@ -0,0 +1,18 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/echo_client/overlay-nrf700x.conf b/samples/net/sockets/echo_client/overlay-nrf700x.conf new file mode 100644 index 000000000000..cbc47b965727 --- /dev/null +++ b/samples/net/sockets/echo_client/overlay-nrf700x.conf @@ -0,0 +1,20 @@ +CONFIG_POSIX_MAX_FDS=16 + +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/echo_server/overlay-nrf700x.conf b/samples/net/sockets/echo_server/overlay-nrf700x.conf new file mode 100644 index 000000000000..cbc47b965727 --- /dev/null +++ b/samples/net/sockets/echo_server/overlay-nrf700x.conf @@ -0,0 +1,20 @@ +CONFIG_POSIX_MAX_FDS=16 + +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/http_client/sample.yaml b/samples/net/sockets/http_client/sample.yaml index 271f61b94ec0..afd14a1a255d 100644 --- a/samples/net/sockets/http_client/sample.yaml +++ b/samples/net/sockets/http_client/sample.yaml @@ -5,6 +5,10 @@ common: - http_client min_ram: 32 depends_on: netif + # native_posix does not work with CONFIG_POSIX_API + platform_exclude: + - native_posix + - native_posix/native/64 sample: description: HTTP client sample name: http_client diff --git a/samples/net/sockets/http_get/overlay-nrf700x.conf b/samples/net/sockets/http_get/overlay-nrf700x.conf new file mode 100644 index 000000000000..aa59e5d5ea2d --- /dev/null +++ b/samples/net/sockets/http_get/overlay-nrf700x.conf @@ -0,0 +1,18 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/packet/sample.yaml b/samples/net/sockets/packet/sample.yaml index dc816ac52e82..723978b5de84 100644 --- a/samples/net/sockets/packet/sample.yaml +++ b/samples/net/sockets/packet/sample.yaml @@ -5,8 +5,6 @@ tests: sample.net.sockets.packet: harness: net platform_allow: - - native_posix - - native_posix/native/64 - native_sim - native_sim/native/64 integration_platforms: diff --git a/samples/net/sockets/sntp_client/overlay-nrf700x.conf b/samples/net/sockets/sntp_client/overlay-nrf700x.conf new file mode 100644 index 000000000000..aa59e5d5ea2d --- /dev/null +++ b/samples/net/sockets/sntp_client/overlay-nrf700x.conf @@ -0,0 +1,18 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/sockets/txtime/sample.yaml b/samples/net/sockets/txtime/sample.yaml index feb099bd63bf..18613f4b87a3 100644 --- a/samples/net/sockets/txtime/sample.yaml +++ b/samples/net/sockets/txtime/sample.yaml @@ -3,8 +3,6 @@ common: depends_on: netif # We can only run this in platforms that support PTP clock and TXTIME platform_allow: - - native_posix - - native_posix/native/64 - native_sim - native_sim/native/64 - qemu_x86 diff --git a/samples/net/sockets/websocket_client/sample.yaml b/samples/net/sockets/websocket_client/sample.yaml index a0472b856f96..df7603cf1a16 100644 --- a/samples/net/sockets/websocket_client/sample.yaml +++ b/samples/net/sockets/websocket_client/sample.yaml @@ -7,6 +7,10 @@ common: - websocket min_ram: 35 depends_on: netif + # native_posix does not work with CONFIG_POSIX_API + platform_exclude: + - native_posix + - native_posix/native/64 sample: description: Websocket client sample name: websocket_client diff --git a/samples/net/syslog_net/overlay-nrf700x.conf b/samples/net/syslog_net/overlay-nrf700x.conf new file mode 100644 index 000000000000..aa59e5d5ea2d --- /dev/null +++ b/samples/net/syslog_net/overlay-nrf700x.conf @@ -0,0 +1,18 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/telnet/overlay-nrf700x.conf b/samples/net/telnet/overlay-nrf700x.conf new file mode 100644 index 000000000000..aa59e5d5ea2d --- /dev/null +++ b/samples/net/telnet/overlay-nrf700x.conf @@ -0,0 +1,18 @@ +# Wi-Fi +CONFIG_WIFI=y +CONFIG_WIFI_NRF700X=y +CONFIG_WPA_SUPP=y +CONFIG_NET_L2_ETHERNET=y + +# DHCPv4 +CONFIG_NET_CONFIG_MY_IPV4_ADDR="" +CONFIG_NET_DHCPV4=y + +# Connection manager +CONFIG_NET_CONNECTION_MANAGER=y + +# Credentials +CONFIG_WIFI_CREDENTIALS=y +CONFIG_WIFI_CREDENTIALS_STATIC=y +CONFIG_WIFI_CREDENTIALS_STATIC_SSID="" +CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="" diff --git a/samples/net/tftp_client/sample.yaml b/samples/net/tftp_client/sample.yaml index 3ccedecafe99..6e53b0f18817 100644 --- a/samples/net/tftp_client/sample.yaml +++ b/samples/net/tftp_client/sample.yaml @@ -6,7 +6,6 @@ tests: harness: net depends_on: netif platform_allow: - - native_posix - native_sim integration_platforms: - native_sim diff --git a/samples/subsys/ipc/ipc_service/icmsg/src/main.c b/samples/subsys/ipc/ipc_service/icmsg/src/main.c index 3500b472e7d7..d10fa6c8bf6b 100644 --- a/samples/subsys/ipc/ipc_service/icmsg/src/main.c +++ b/samples/subsys/ipc/ipc_service/icmsg/src/main.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include "common.h" @@ -130,7 +130,7 @@ int main(void) k_msleep(500); LOG_INF("Stop network core"); - nrf_reset_network_force_off(NRF_RESET, true); + nrf53_cpunet_enable(false); LOG_INF("Reset IPC service"); @@ -158,7 +158,7 @@ int main(void) } LOG_INF("Run network core"); - nrf_reset_network_force_off(NRF_RESET, false); + nrf53_cpunet_enable(true); k_sem_take(&bound_sem, K_FOREVER); diff --git a/samples/subsys/ipc/ipc_service/icmsg/sysbuild.conf b/samples/subsys/ipc/ipc_service/icmsg/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/ipc/ipc_service/icmsg/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/subsys/ipc/ipc_service/multi_endpoint/sysbuild.conf b/samples/subsys/ipc/ipc_service/multi_endpoint/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/subsys/ipc/ipc_service/static_vrings/sysbuild.conf b/samples/subsys/ipc/ipc_service/static_vrings/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/ipc/ipc_service/static_vrings/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/subsys/logging/multidomain/sysbuild.conf b/samples/subsys/logging/multidomain/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/logging/multidomain/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54l15pdk_nrf54l15_cpuapp_ext_flash.overlay b/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54l15pdk_nrf54l15_cpuapp_ext_flash.overlay new file mode 100644 index 000000000000..410388bfa6d3 --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/boards/nrf54l15pdk_nrf54l15_cpuapp_ext_flash.overlay @@ -0,0 +1,9 @@ +/ { + chosen { + nordic,pm-ext-flash = &mx25r64; + }; +}; + +&mx25r64 { + status = "okay"; +}; diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/child_image/hci_rpmsg.conf b/samples/subsys/mgmt/mcumgr/smp_svr/child_image/hci_rpmsg.conf new file mode 100644 index 000000000000..98260877332f --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/child_image/hci_rpmsg.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2022 Nordic Semiconductor +# +# SPDX-License-Identifier: Apache-2.0 +# + +CONFIG_BT_MAX_CONN=2 +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=502 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml b/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml index 6a3669b24380..81b06ca5634a 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sample.yaml @@ -12,9 +12,11 @@ tests: - nrf52840dk/nrf52840 - pinnacle_100_dvk - mg100 + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf52dk/nrf52832 - nrf52840dk/nrf52840 + - nrf54l15pdk/nrf54l15/cpuapp sample.mcumgr.smp_svr.bt_static_svc: extra_args: OVERLAY_CONFIG="overlay-bt.conf" extra_configs: @@ -102,3 +104,15 @@ tests: - mg100 integration_platforms: - nrf52840dk/nrf52840 + sample.mcumgr.smp_svr.bt.nrf54l15pdk.ext_flash: + extra_args: + - OVERLAY_CONFIG="overlay-bt.conf" + - DTC_OVERLAY_FILE="boards/nrf54l15pdk_nrf54l15_cpuapp_ext_flash.overlay" + - mcuboot_CONF_FILE="boards/nrf54l15pdk_nrf54l15_cpuapp_ext_flash.conf" + - mcuboot_EXTRA_DTC_OVERLAY_FILE="boards/nrf54l15pdk_nrf54l15_cpuapp_ext_flash.overlay" + extra_configs: + - CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y + platform_allow: + - nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf54l15pdk/nrf54l15/cpuapp diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/hci_rpmsg.conf b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/hci_rpmsg.conf new file mode 100644 index 000000000000..98260877332f --- /dev/null +++ b/samples/subsys/mgmt/mcumgr/smp_svr/sysbuild/hci_rpmsg.conf @@ -0,0 +1,10 @@ +# +# Copyright (c) 2022 Nordic Semiconductor +# +# SPDX-License-Identifier: Apache-2.0 +# + +CONFIG_BT_MAX_CONN=2 +CONFIG_BT_BUF_ACL_RX_SIZE=502 +CONFIG_BT_BUF_ACL_TX_SIZE=502 +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 diff --git a/samples/tfm_integration/psa_crypto/sample.yaml b/samples/tfm_integration/psa_crypto/sample.yaml index 3f25acf88f33..ec0a1f8dd3f9 100644 --- a/samples/tfm_integration/psa_crypto/sample.yaml +++ b/samples/tfm_integration/psa_crypto/sample.yaml @@ -12,7 +12,6 @@ tests: - csr - mcuboot platform_allow: mps2/an521/cpu0/ns v2m_musca_s1/musca_s1/ns - nrf5340dk/nrf5340/cpuapp/ns nrf9160dk/nrf9160/ns stm32l562e_dk/stm32l562xx/ns bl5340_dvk/nrf5340/cpuapp/ns harness: console harness_config: diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index 55430f9cfe3e..ba44e084e6de 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -352,6 +352,13 @@ def get_modules(self, modules_file, settings_file): modules = [name for name in os.listdir(modules_dir) if os.path.exists(os.path.join(modules_dir, name, 'Kconfig'))] + nrf_modules_dir = ZEPHYR_BASE + '/../nrf/modules' + nrf_modules = [] + if os.path.exists(nrf_modules_dir): + nrf_modules = [name for name in os.listdir(nrf_modules_dir) if + os.path.exists(os.path.join(nrf_modules_dir, name, + 'Kconfig'))] + with open(modules_file, 'r') as fp_module_file: content = fp_module_file.read() @@ -361,9 +368,18 @@ def get_modules(self, modules_file, settings_file): re.sub('[^a-zA-Z0-9]', '_', module).upper(), modules_dir + '/' + module + '/Kconfig' )) + for module in nrf_modules: + fp_module_file.write("ZEPHYR_{}_KCONFIG = {}\n".format( + re.sub('[^a-zA-Z0-9]', '_', module).upper(), + nrf_modules_dir + '/' + module + '/Kconfig' + )) + fp_module_file.write("NCS_{}_KCONFIG = {}\n".format( + re.sub('[^a-zA-Z0-9]', '_', module).upper(), + modules_dir + '/' + module + '/Kconfig' + )) fp_module_file.write(content) - def get_kconfig_dts(self, kconfig_dts_file, settings_file): + def get_module_setting_root(self, root, settings_file): """ Generate the Kconfig.dts using dts/bindings as the source. @@ -372,10 +388,7 @@ def get_kconfig_dts(self, kconfig_dts_file, settings_file): """ # Invoke the script directly using the Python executable since this is # not a module nor a pip-installed Python utility - zephyr_drv_kconfig_path = os.path.join(ZEPHYR_BASE, "scripts", "dts", - "gen_driver_kconfig_dts.py") - binding_paths = [] - binding_paths.append(os.path.join(ZEPHYR_BASE, "dts", "bindings")) + root_paths = [] if os.path.exists(settings_file): with open(settings_file, 'r') as fp_setting_file: @@ -383,9 +396,29 @@ def get_kconfig_dts(self, kconfig_dts_file, settings_file): lines = content.strip().split('\n') for line in lines: - if line.startswith('"DTS_ROOT":'): - _, dts_root_path = line.split(":", 1) - binding_paths.append(os.path.join(dts_root_path.strip('"'), "dts", "bindings")) + root = root.upper() + if line.startswith(f'"{root}_ROOT":'): + _, root_path = line.split(":", 1) + root_paths.append(Path(root_path.strip('"'))) + return root_paths + + def get_kconfig_dts(self, kconfig_dts_file, settings_file): + """ + Generate the Kconfig.dts using dts/bindings as the source. + + This is needed to complete Kconfig compliance tests. + + """ + # Invoke the script directly using the Python executable since this is + # not a module nor a pip-installed Python utility + zephyr_drv_kconfig_path = os.path.join(ZEPHYR_BASE, "scripts", "dts", + "gen_driver_kconfig_dts.py") + binding_paths = [] + binding_paths.append(os.path.join(ZEPHYR_BASE, "dts", "bindings")) + + dts_root_paths = self.get_module_setting_root('dts', settings_file) + for p in dts_root_paths: + binding_paths.append(p / "dts" / "bindings") cmd = [sys.executable, zephyr_drv_kconfig_path, '--kconfig-out', kconfig_dts_file, '--bindings-dirs'] @@ -423,7 +456,7 @@ def get_v1_model_syms(self, kconfig_v1_file, kconfig_v1_syms_file): fp_kconfig_v1_syms_file.write('\n\t' + kconfiglib.TYPE_TO_STR[s.type]) fp_kconfig_v1_syms_file.write('\n\n') - def get_v2_model(self, kconfig_dir): + def get_v2_model(self, kconfig_dir, settings_file): """ Get lists of v2 boards and SoCs and put them in a file that is parsed by Kconfig @@ -435,8 +468,12 @@ def get_v2_model(self, kconfig_dir): kconfig_boards_file = os.path.join(kconfig_dir, 'boards', 'Kconfig.boards') kconfig_defconfig_file = os.path.join(kconfig_dir, 'boards', 'Kconfig.defconfig') - root_args = argparse.Namespace(**{'board_roots': [Path(ZEPHYR_BASE)], - 'soc_roots': [Path(ZEPHYR_BASE)], 'board': None}) + board_roots = self.get_module_setting_root('board', settings_file) + board_roots.insert(0, Path(ZEPHYR_BASE)) + soc_roots = self.get_module_setting_root('soc', settings_file) + soc_roots.insert(0, Path(ZEPHYR_BASE)) + root_args = argparse.Namespace(**{'board_roots': board_roots, + 'soc_roots': soc_roots, 'board': None}) v2_boards = list_boards.find_v2_boards(root_args) with open(kconfig_defconfig_file, 'w') as fp: @@ -542,7 +579,7 @@ def parse_kconfig(self, filename="Kconfig", hwm=None): os.makedirs(os.path.join(kconfiglib_dir, 'arch'), exist_ok=True) os.environ["BOARD_DIR"] = kconfiglib_boards_dir - self.get_v2_model(kconfiglib_dir) + self.get_v2_model(kconfiglib_dir, os.path.join(kconfiglib_dir, "settings_file.txt")) # Tells Kconfiglib to generate warnings for all references to undefined # symbols within Kconfig files diff --git a/scripts/ci/test_plan.py b/scripts/ci/test_plan.py index 26787496a7cc..625d47a78050 100755 --- a/scripts/ci/test_plan.py +++ b/scripts/ci/test_plan.py @@ -95,7 +95,7 @@ def __repr__(self): class Filters: def __init__(self, modified_files, ignore_path, alt_tags, testsuite_root, - pull_request=False, platforms=[], detailed_test_id=True): + pull_request=False, platforms=[], detailed_test_id=True, quarantine_list=None): self.modified_files = modified_files self.testsuite_root = testsuite_root self.resolved_files = [] @@ -108,6 +108,7 @@ def __init__(self, modified_files, ignore_path, alt_tags, testsuite_root, self.detailed_test_id = detailed_test_id self.ignore_path = ignore_path self.tag_cfg_file = alt_tags + self.quarantine_list = quarantine_list def process(self): self.find_modules() @@ -128,6 +129,9 @@ def get_plan(self, options, integration=False, use_testsuite_root=True): cmd+=["-T", root] if integration: cmd.append("--integration") + if self.quarantine_list: + for q in self.quarantine_list: + cmd += ["--quarantine-list", q] logging.info(" ".join(cmd)) _ = subprocess.call(cmd) @@ -410,6 +414,12 @@ def parse_args(): "testcase.yaml files under here will be processed. May be " "called multiple times. Defaults to the 'samples/' and " "'tests/' directories at the base of the Zephyr tree.") + parser.add_argument( + "--quarantine-list", action="append", metavar="FILENAME", + help="Load list of test scenarios under quarantine. The entries in " + "the file need to correspond to the test scenarios names as in " + "corresponding tests .yaml files. These scenarios " + "will be skipped with quarantine as the reason.") # Include paths in names by default. parser.set_defaults(detailed_test_id=True) @@ -438,7 +448,7 @@ def parse_args(): print("=========") f = Filters(files, args.ignore_path, args.alt_tags, args.testsuite_root, - args.pull_request, args.platform, args.detailed_test_id) + args.pull_request, args.platform, args.detailed_test_id, args.quarantine_list) f.process() # remove dupes and filtered cases diff --git a/scripts/gitlint/zephyr_commit_rules.py b/scripts/gitlint/zephyr_commit_rules.py index a2c9cd3cb7fe..ef317e22684c 100644 --- a/scripts/gitlint/zephyr_commit_rules.py +++ b/scripts/gitlint/zephyr_commit_rules.py @@ -78,7 +78,7 @@ class TitleMaxLengthRevert(LineRule): name = "title-max-length-no-revert" id = "UC5" target = CommitMessageTitle - options_spec = [IntOption('line-length', 75, "Max line length")] + options_spec = [IntOption('line-length', 120, "Max line length")] violation_message = "Commit title exceeds max length ({0}>{1})" def validate(self, line, _commit): @@ -103,7 +103,7 @@ class MaxLineLengthExceptions(LineRule): name = "max-line-length-with-exceptions" id = "UC4" target = CommitMessageBody - options_spec = [IntOption('line-length', 75, "Max line length")] + options_spec = [IntOption('line-length', 120, "Max line length")] violation_message = "Commit message body line exceeds max length ({0}>{1})" def validate(self, line, _commit): diff --git a/scripts/list_hardware.py b/scripts/list_hardware.py index 2fa7c2a3638b..d1f31a4712e1 100755 --- a/scripts/list_hardware.py +++ b/scripts/list_hardware.py @@ -10,6 +10,7 @@ import sys from typing import List import yaml +import re SOC_SCHEMA_PATH = str(Path(__file__).parent / 'schemas' / 'soc-schema.yml') @@ -40,6 +41,40 @@ def __init__(self, folder='', soc_yaml=None): except (yaml.YAMLError, pykwalify.errors.SchemaError) as e: sys.exit(f'ERROR: Malformed yaml {soc_yaml.as_posix()}', e) + # Ensure that any runner configuration matches socs and cpuclusters declared in the same + # soc.yml file + if 'runners' in data and 'run_once' in data['runners']: + for grp in data['runners']['run_once']: + for item_data in data['runners']['run_once'][grp]: + for group in item_data['groups']: + for qualifiers in group['qualifiers']: + components = qualifiers.split('/') + soc = components.pop(0) + found_match = False + + # Allow 'ns' as final qualifier until "virtual" CPUs are ported to soc.yml + # https://github.com/zephyrproject-rtos/zephyr/issues/70721 + if len(components) > 0 and components[len(components)-1] == 'ns': + components.pop(len(components)-1) + + for f in data.get('family', []): + for s in f.get('series', []): + for socs in s.get('socs', []): + if re.match(fr'^{soc}$', socs.get('name')) is not None: + if 'cpuclusters' in socs and len(components) > 0: + check_string = '/'.join(components) + for cpucluster in socs.get('cpuclusters', []): + if re.match(fr'^{check_string}$', cpucluster.get('name')) is not None: + found_match = True + break + elif 'cpuclusters' not in socs and len(components) == 0: + found_match = True + break + + + if found_match is False: + sys.exit(f'ERROR: SoC qualifier match unresolved: {qualifiers}') + for f in data.get('family', []): family = Family(f['name'], folder, [], []) for s in f.get('series', []): diff --git a/scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py b/scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py index 4a6967b6372a..5a5a845c3a11 100644 --- a/scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py +++ b/scripts/pylib/pytest-twister-harness/src/twister_harness/device/hardware_adapter.py @@ -70,7 +70,7 @@ def _prepare_runner_args(self) -> tuple[list[str], list[str]]: if runner == 'pyocd': extra_args.append('--board-id') extra_args.append(board_id) - elif runner == 'nrfjprog': + elif runner in ('nrfjprog', 'nrfutil'): extra_args.append('--dev-id') extra_args.append(board_id) elif runner == 'openocd' and self.device_config.product in ['STM32 STLink', 'STLINK-V3']: diff --git a/scripts/pylib/twister/twisterlib/coverage.py b/scripts/pylib/twister/twisterlib/coverage.py index 556f5b359baa..90d523e793ac 100644 --- a/scripts/pylib/twister/twisterlib/coverage.py +++ b/scripts/pylib/twister/twisterlib/coverage.py @@ -92,8 +92,9 @@ def create_gcda_files(extracted_coverage_info): continue try: + hex_bytes = bytes.fromhex(hexdump_val) with open(filename, 'wb') as fp: - fp.write(bytes.fromhex(hexdump_val)) + fp.write(hex_bytes) except ValueError: logger.exception("Unable to convert hex data for file: {}".format(filename)) gcda_created = False diff --git a/scripts/pylib/twister/twisterlib/hardwaremap.py b/scripts/pylib/twister/twisterlib/hardwaremap.py index 2ef780c3838b..12f3c97ac0d0 100644 --- a/scripts/pylib/twister/twisterlib/hardwaremap.py +++ b/scripts/pylib/twister/twisterlib/hardwaremap.py @@ -13,7 +13,6 @@ import scl import logging from pathlib import Path -from natsort import natsorted from twisterlib.environment import ZEPHYR_BASE @@ -330,7 +329,7 @@ def readlink(link): def save(self, hwm_file): # use existing map - self.detected = natsorted(self.detected, key=lambda x: x.serial or '') + self.detected.sort(key=lambda x: x.serial or '') if os.path.exists(hwm_file): with open(hwm_file, 'r') as yaml_file: hwm = yaml.load(yaml_file, Loader=SafeLoader) diff --git a/scripts/quarantine.yaml b/scripts/quarantine.yaml new file mode 100644 index 000000000000..20c4f9248ea9 --- /dev/null +++ b/scripts/quarantine.yaml @@ -0,0 +1,88 @@ +# The configurations resulting as a product of scenarios and platforms +# will be skipped if quarantine is used. More details here: +# https://docs.zephyrproject.org/latest/guides/test/twister.html#quarantine + +- scenarios: + - testing.ztest.busy_sim + - testing.ztest.busy_sim_nrf52840dk_pin + platforms: + - nrf52840dk_nrf52840 + +# Already reported, but will not be fixed (look at the discussion): +# https://github.com/zephyrproject-rtos/zephyr/issues/44947 +- scenarios: + - libraries.cmsis_dsp.matrix.unary_f64 + platforms: + - nrf5340dk_nrf5340_cpunet + - qemu_cortex_m3 + comment: "Flash overflows" + +# Already reported, but will not be fixed (look at the discussion): +# https://github.com/zephyrproject-rtos/zephyr/issues/44947 +- scenarios: + - libraries.cmsis_dsp.matrix.binary_f16 + - libraries.cmsis_dsp.matrix.binary_f16.fpu + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + comment: "Flash overflows" + +# Already reported, but will not be fixed (look at the discussion): +# https://github.com/zephyrproject-rtos/zephyr/issues/44947 +- scenarios: + - libraries.cmsis_dsp.matrix.binary_q15 + - libraries.cmsis_dsp.matrix.binary_q15.fpu + - libraries.cmsis_dsp.matrix.unary_f32 + - libraries.cmsis_dsp.matrix.unary_f32.fpu + - libraries.cmsis_dsp.matrix.unary_f64 + - libraries.cmsis_dsp.matrix.unary_f64.fpu + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + - nrf9160dk_nrf9160_ns + comment: "Flash overflows" + +# libsdl2-dev package should be added into docker image +- scenarios: + - sample.boards.nrf.nrf_led_matrix + - sample.display.lvgl.gui + platforms: + - native_posix + comment: "libsdl2-dev package not available" + +- scenarios: + - sample.net.sockets.echo_server.usbnet + - sample.net.sockets.echo_server.usbnet_composite + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + comment: "Ram/flash overflows, also in the upstream" + +- scenarios: + - sample.net.zperf.netusb_ecm + - sample.net.zperf.netusb_eem + - sample.net.zperf.netusb_rndis + platforms: + - nrf52833dk_nrf52833 + - nrf5340dk_nrf5340_cpuapp_ns + comment: "Ram/flash overflows, also in the upstream" + +- scenarios: + - net.mqtt.tls + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + - nrf9160dk_nrf9160_ns + comment: "Ram/flash overflows, also in the upstream" + +- scenarios: + - kernel.common.picolibc + - libraries.picolibc + - libraries.libc.picolibc.mem_alloc + - libraries.picolibc.sprintf_new + platforms: + - nrf52dk_nrf52832 + comment: "Ram overflows, also in the upstream" + +- scenarios: + - sample.psa_crypto + platforms: + - nrf5340dk_nrf5340_cpuapp_ns + - nrf9160dk_nrf9160_ns + comment: "Due to using sdk-zephyr manifest instead of nrf. Should be fixed after the change" diff --git a/scripts/requirements-run-test.txt b/scripts/requirements-run-test.txt index a710eb962a5f..f064c8bd5f3d 100644 --- a/scripts/requirements-run-test.txt +++ b/scripts/requirements-run-test.txt @@ -7,7 +7,6 @@ pyocd>=0.35.0 # used by twister for board/hardware map tabulate -natsort # used by mcuboot cbor>=1.0.0 diff --git a/scripts/schemas/board-schema.yml b/scripts/schemas/board-schema.yml index 6a9262bf8f5e..56ee4eab0344 100644 --- a/scripts/schemas/board-schema.yml +++ b/scripts/schemas/board-schema.yml @@ -78,3 +78,54 @@ mapping: type: seq sequence: - include: board-schema + runners: + type: map + mapping: + run_once: + type: map + desc: | + Allows for restricting west flash commands when using sysbuild to run once per given + grouping of board targets. This is to allow for future image program cycles to not + erase the flash of a device which has just been programmed by another image. + mapping: + regex;(.*): + type: seq + desc: | + A dictionary of commands which should be limited to running once per invocation + of west flash for a given set of flash runners and board targets. + sequence: + - type: map + mapping: + run: + required: true + type: str + enum: ['first', 'last'] + desc: | + If first, will run this command once when the first image is flashed, if + last, will run this command once when the final image is flashed. + runners: + required: true + type: seq + sequence: + - type: str + desc: | + A list of flash runners that this applies to, can use `all` to apply + to all runners. + groups: + required: true + type: seq + sequence: + - type: map + desc: | + A grouping of board targets which the command should apply to. Can + be used multiple times to have multiple groups. + mapping: + boards: + required: true + type: seq + sequence: + - type: str + desc: | + A board target to match against in regex. Must be one entry + per board target, a single regex entry will not match two + board targets even if they both match. diff --git a/scripts/schemas/soc-schema.yml b/scripts/schemas/soc-schema.yml index dd62ee3c17dc..c13b4a4f7e05 100644 --- a/scripts/schemas/soc-schema.yml +++ b/scripts/schemas/soc-schema.yml @@ -70,3 +70,54 @@ mapping: required: false type: str desc: Free form comment with extra information regarding the SoC. + runners: + type: map + mapping: + run_once: + type: map + desc: | + Allows for restricting west flash commands when using sysbuild to run once per given + grouping of board targets. This is to allow for future image program cycles to not + erase the flash of a device which has just been programmed by another image. + mapping: + regex;(.*): + type: seq + desc: | + A dictionary of commands which should be limited to running once per invocation + of west flash for a given set of flash runners and board targets. + sequence: + - type: map + mapping: + run: + required: true + type: str + enum: ['first', 'last'] + desc: | + If first, will run this command once when the first image is flashed, if + last, will run this command once when the final image is flashed. + runners: + required: true + type: seq + sequence: + - type: str + desc: | + A list of flash runners that this applies to, can use `all` to apply + to all runners. + groups: + required: true + type: seq + sequence: + - type: map + desc: | + A grouping of board targets which the command should apply to. Can + be used multiple times to have multiple groups. + mapping: + qualifiers: + required: true + type: seq + sequence: + - type: str + desc: | + A board qualifier to match against in regex form. Must be one + entry per board target, a single regex entry will not match + two board targets even if they both match. diff --git a/scripts/west_commands/run_common.py b/scripts/west_commands/run_common.py index 43d736f2b682..8656d0907679 100644 --- a/scripts/west_commands/run_common.py +++ b/scripts/west_commands/run_common.py @@ -1,12 +1,15 @@ # Copyright (c) 2018 Open Source Foundries Limited. +# Copyright (c) 2023 Nordic Semiconductor ASA # # SPDX-License-Identifier: Apache-2.0 '''Common code used by commands which execute runners. ''' +import re import argparse import logging +from collections import defaultdict from os import close, getcwd, path, fspath from pathlib import Path from subprocess import CalledProcessError @@ -15,12 +18,14 @@ import textwrap import traceback +from dataclasses import dataclass from west import log from build_helpers import find_build_dir, is_zephyr_build, load_domains, \ FIND_BUILD_DIR_DESCRIPTION from west.commands import CommandError from west.configuration import config from runners.core import FileType +from runners.core import BuildConfiguration import yaml from zephyr_ext_common import ZEPHYR_SCRIPTS @@ -78,6 +83,19 @@ def emit(self, record): else: log.dbg(fmt, level=log.VERBOSE_EXTREME) +@dataclass +class UsedFlashCommand: + command: str + boards: list + runners: list + first: bool + ran: bool = False + +@dataclass +class ImagesFlashed: + flashed: int = 0 + total: int = 0 + def command_verb(command): return "flash" if command.name == "flash" else "debug" @@ -147,6 +165,19 @@ def do_run_common(command, user_args, user_runner_args, domains=None): # This is the main routine for all the "west flash", "west debug", # etc. commands. + # Holds a list of run once commands, this is useful for sysbuild images + # whereby there are multiple images per board with flash commands that can + # interfere with other images if they run one per time an image is flashed. + used_cmds = [] + + # Holds a set of processed board names for flash running information. + processed_boards = set() + + # Holds a dictionary of board image flash counts, the first element is + # number of images flashed so far and second element is total number of + # images for a given board. + board_image_count = defaultdict(ImagesFlashed) + if user_args.context: dump_context(command, user_args, user_runner_args) return @@ -165,20 +196,108 @@ def do_run_common(command, user_args, user_runner_args, domains=None): # Get the user specified domains. domains = load_domains(build_dir).get_domains(user_args.domain) - if len(domains) > 1 and len(user_runner_args) > 0: - log.wrn("Specifying runner options for multiple domains is experimental.\n" - "If problems are experienced, please specify a single domain " - "using '--domain '") + if len(domains) > 1: + if len(user_runner_args) > 0: + log.wrn("Specifying runner options for multiple domains is experimental.\n" + "If problems are experienced, please specify a single domain " + "using '--domain '") + + # Process all domains to load board names and populate flash runner + # parameters. + board_names = set() + for d in domains: + if d.build_dir is None: + build_dir = get_build_dir(user_args) + else: + build_dir = d.build_dir + + cache = load_cmake_cache(build_dir, user_args) + build_conf = BuildConfiguration(build_dir) + board = build_conf.get('CONFIG_BOARD_TARGET') + board_names.add(board) + board_image_count[board].total += 1 + + # Load board flash runner configuration (if it exists) and store + # single-use commands in a dictionary so that they get executed + # once per unique board name. + if cache['BOARD_DIR'] not in processed_boards and 'SOC_FULL_DIR' in cache: + soc_yaml_file = Path(cache['SOC_FULL_DIR']) / 'soc.yml' + board_yaml_file = Path(cache['BOARD_DIR']) / 'board.yml' + group_type = 'boards' + + # Search for flash runner configuration, board takes priority over SoC + try: + with open(board_yaml_file, 'r') as f: + data_yaml = yaml.safe_load(f.read()) + + except FileNotFoundError: + continue + + if 'runners' not in data_yaml: + # Check SoC file + group_type = 'qualifiers' + try: + with open(soc_yaml_file, 'r') as f: + data_yaml = yaml.safe_load(f.read()) + + except FileNotFoundError: + continue + + processed_boards.add(cache['BOARD_DIR']) + + if 'runners' not in data_yaml or 'run_once' not in data_yaml['runners']: + continue + + for cmd in data_yaml['runners']['run_once']: + for data in data_yaml['runners']['run_once'][cmd]: + for group in data['groups']: + run_first = bool(data['run'] == 'first') + if group_type == 'qualifiers': + targets = [] + for target in group[group_type]: + # For SoC-based qualifiers, prepend to the beginning of the + # match to allow for matching any board name + targets.append('([^/]+)/' + target) + else: + targets = group[group_type] + + used_cmds.append(UsedFlashCommand(cmd, targets, data['runners'], run_first)) + + # Reduce entries to only those having matching board names (either exact or with regex) and + # remove any entries with empty board lists + for i, entry in enumerate(used_cmds): + for l, match in enumerate(entry.boards): + match_found = False + + # Check if there is a matching board for this regex + for check in board_names: + if re.match(fr'^{match}$', check) is not None: + match_found = True + break + + if not match_found: + del entry.boards[l] + + if len(entry.boards) == 0: + del used_cmds[i] for d in domains: - do_run_common_image(command, user_args, user_runner_args, d.build_dir) + do_run_common_image(command, user_args, user_runner_args, + used_cmds, board_image_count, d.build_dir) + -def do_run_common_image(command, user_args, user_runner_args, build_dir=None): +def do_run_common_image(command, user_args, user_runner_args, used_cmds, + board_image_count, build_dir=None,): + global re command_name = command.name if build_dir is None: build_dir = get_build_dir(user_args) cache = load_cmake_cache(build_dir, user_args) - board = cache['CACHED_BOARD'] + build_conf = BuildConfiguration(build_dir) + board = build_conf.get('CONFIG_BOARD_TARGET') + + if board_image_count is not None and board in board_image_count: + board_image_count[board].flashed += 1 # Load runners.yaml. yaml_path = runners_yaml_path(build_dir, board) @@ -201,6 +320,93 @@ def do_run_common_image(command, user_args, user_runner_args, build_dir=None): # parsing, it will show up here, and needs to be filtered out. runner_args = [arg for arg in user_runner_args if arg != '--'] + # Check if there are any commands that should only be ran once per board + # and if so, remove them for all but the first iteration of the flash + # runner per unique board name. + if len(used_cmds) > 0 and len(runner_args) > 0: + i = len(runner_args) - 1 + while i >= 0: + for cmd in used_cmds: + if cmd.command == runner_args[i] and (runner_name in cmd.runners or 'all' in cmd.runners): + # Check if board is here + match_found = False + + for match in cmd.boards: + # Check if there is a matching board for this regex + if re.match(fr'^{match}$', board) is not None: + match_found = True + break + + if not match_found: + continue + + # Check if this is a first or last run + if not cmd.first: + # For last run instances, we need to check that this really is the last + # image of all boards being flashed + for check in cmd.boards: + can_continue = False + + for match in board_image_count: + if re.match(fr'^{check}$', match) is not None: + if board_image_count[match].flashed == board_image_count[match].total: + can_continue = True + break + + if not can_continue: + continue + + if not cmd.ran: + cmd.ran = True + else: + runner_args.pop(i) + + break + + i = i - 1 + + # If flashing multiple images, the runner supports reset after flashing and + # the board has enabled this functionality, check if the board should be + # reset or not. If this is not specified in the board/soc file, leave it up to + # the runner's default configuration to decide if a reset should occur. + if runner_cls.capabilities().reset: + if board_image_count is not None: + reset = True + + for cmd in used_cmds: + if cmd.command == '--reset' and (runner_name in cmd.runners or 'all' in cmd.runners): + # Check if board is here + match_found = False + + for match in cmd.boards: + if re.match(fr'^{match}$', board) is not None: + match_found = True + break + + if not match_found: + continue + + # Check if this is a first or last run + if cmd.first and cmd.ran: + reset = False + break + elif not cmd.first and not cmd.ran: + # For last run instances, we need to check that this really is the last + # image of all boards being flashed + for check in cmd.boards: + can_continue = False + + for match in board_image_count: + if re.match(fr'^{check}$', match) is not None: + if board_image_count[match].flashed != board_image_count[match].total: + reset = False + break + + if reset: + runner_args.append('--reset') + else: + runner_args.append('--no-reset') + # Arguments in this order to allow specific to override general: # # - runner-specific runners.yaml arguments @@ -439,8 +645,8 @@ def dump_context(command, args, unknown_args): log.wrn('no --build-dir given or found; output will be limited') runners_yaml = None else: - cache = load_cmake_cache(build_dir, args) - board = cache['CACHED_BOARD'] + build_conf = BuildConfiguration(build_dir) + board = build_conf.get('CONFIG_BOARD_TARGET') yaml_path = runners_yaml_path(build_dir, board) runners_yaml = load_runners_yaml(yaml_path) diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py index ab27eaa57063..b5b257ed712c 100755 --- a/scripts/zephyr_module.py +++ b/scripts/zephyr_module.py @@ -370,14 +370,15 @@ def process_sysbuildkconfig(module, meta): 'not point to a valid Kconfig file.' .format(module_yml, kconfig_setting)) - if kconfig_setting is None: - return "" + if kconfig_setting is not None: + kconfig_file = os.path.join(module, kconfig_setting) + if os.path.isfile(kconfig_file): + return kconfig_snippet(meta, module_path, Path(kconfig_file)) - kconfig_file = os.path.join(module, kconfig_setting) - if os.path.isfile(kconfig_file): - return kconfig_snippet(meta, module_path, Path(kconfig_file)) - else: - return "" + name_sanitized = meta['name-sanitized'] + return (f'config ZEPHYR_{name_sanitized.upper()}_MODULE\n' + f' bool\n' + f' default y\n') def process_twister(module, meta): diff --git a/soc/nordic/CMakeLists.txt b/soc/nordic/CMakeLists.txt index 6dae6e97fb26..9797d2e717a3 100644 --- a/soc/nordic/CMakeLists.txt +++ b/soc/nordic/CMakeLists.txt @@ -2,7 +2,9 @@ zephyr_library() -set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "SoC Linker script") +if(CONFIG_ARM) + set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "SoC Linker script") +endif() zephyr_library_sources( validate_base_addresses.c diff --git a/soc/nordic/common/CMakeLists.txt b/soc/nordic/common/CMakeLists.txt index b574cafc0c73..805113f53d6d 100644 --- a/soc/nordic/common/CMakeLists.txt +++ b/soc/nordic/common/CMakeLists.txt @@ -3,6 +3,8 @@ add_subdirectory_ifdef(CONFIG_RISCV_CORE_NORDIC_VPR vpr) +zephyr_linker_sources_ifdef(CONFIG_ARM SECTIONS arm_platform_init.ld) + zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c) zephyr_include_directories(.) diff --git a/soc/nordic/common/Kconfig.peripherals b/soc/nordic/common/Kconfig.peripherals index 0c8f958eb389..f0adc82d44ac 100644 --- a/soc/nordic/common/Kconfig.peripherals +++ b/soc/nordic/common/Kconfig.peripherals @@ -13,10 +13,12 @@ config HAS_HW_NRF_BPROT def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_BPROT)) config HAS_HW_NRF_CC310 - def_bool $(dt_compat_enabled,$(DT_COMPAT_ARM_CRYPTOCELL_310)) + def_bool $(dt_compat_enabled,$(DT_COMPAT_ARM_CRYPTOCELL_310)) || \ + ($(dt_nodelabel_enabled,psa_rng) && SOC_SERIES_NRF91X) config HAS_HW_NRF_CC312 - def_bool $(dt_compat_enabled,$(DT_COMPAT_ARM_CRYPTOCELL_312)) + def_bool $(dt_compat_enabled,$(DT_COMPAT_ARM_CRYPTOCELL_312)) || \ + ($(dt_nodelabel_enabled,psa_rng) && SOC_NRF5340_CPUAPP) config HAS_HW_NRF_CCM def_bool $(dt_compat_enabled,$(DT_COMPAT_NORDIC_NRF_CCM)) @@ -72,6 +74,9 @@ config HAS_HW_NRF_GPIO0 config HAS_HW_NRF_GPIO1 def_bool $(dt_nodelabel_enabled_with_compat,gpio1,$(DT_COMPAT_NORDIC_NRF_GPIO)) +config HAS_HW_NRF_GPIO2 + def_bool $(dt_nodelabel_enabled_with_compat,gpio2,$(DT_COMPAT_NORDIC_NRF_GPIO)) + config HAS_HW_NRF_GPIOTE0 def_bool $(dt_nodelabel_enabled_with_compat,gpiote0,$(DT_COMPAT_NORDIC_NRF_GPIOTE)) @@ -525,6 +530,42 @@ config HAS_HW_NRF_TWIS2 config HAS_HW_NRF_TWIS3 def_bool $(dt_nodelabel_enabled_with_compat,i2c3,$(DT_COMPAT_NORDIC_NRF_TWIS)) +config HAS_HW_NRF_TWIS20 + def_bool $(dt_nodelabel_enabled_with_compat,i2c20,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS21 + def_bool $(dt_nodelabel_enabled_with_compat,i2c21,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS22 + def_bool $(dt_nodelabel_enabled_with_compat,i2c22,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS30 + def_bool $(dt_nodelabel_enabled_with_compat,i2c30,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS130 + def_bool $(dt_nodelabel_enabled_with_compat,i2c130,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS131 + def_bool $(dt_nodelabel_enabled_with_compat,i2c131,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS132 + def_bool $(dt_nodelabel_enabled_with_compat,i2c132,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS133 + def_bool $(dt_nodelabel_enabled_with_compat,i2c133,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS134 + def_bool $(dt_nodelabel_enabled_with_compat,i2c134,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS135 + def_bool $(dt_nodelabel_enabled_with_compat,i2c135,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS136 + def_bool $(dt_nodelabel_enabled_with_compat,i2c136,$(DT_COMPAT_NORDIC_NRF_TWIS)) + +config HAS_HW_NRF_TWIS137 + def_bool $(dt_nodelabel_enabled_with_compat,i2c137,$(DT_COMPAT_NORDIC_NRF_TWIS)) + config HAS_HW_NRF_UART0 def_bool $(dt_nodelabel_enabled_with_compat,uart0,$(DT_COMPAT_NORDIC_NRF_UART)) diff --git a/soc/nordic/linker.ld b/soc/nordic/common/arm_platform_init.ld similarity index 52% rename from soc/nordic/linker.ld rename to soc/nordic/common/arm_platform_init.ld index c8dbb4265923..9773ada3dcfe 100644 --- a/soc/nordic/linker.ld +++ b/soc/nordic/common/arm_platform_init.ld @@ -4,16 +4,5 @@ * SPDX-License-Identifier: Apache-2.0 */ -#if defined(CONFIG_ARM) -#include - /* Let SystemInit() be called in place of z_arm_platform_init() by default. */ PROVIDE(z_arm_platform_init = SystemInit); - -#elif defined(CONFIG_RISCV) -#include - -#else -#error Unsupported architecture - -#endif diff --git a/soc/nordic/common/vpr/CMakeLists.txt b/soc/nordic/common/vpr/CMakeLists.txt index 3849a3fdc943..d418954eebc4 100644 --- a/soc/nordic/common/vpr/CMakeLists.txt +++ b/soc/nordic/common/vpr/CMakeLists.txt @@ -4,3 +4,5 @@ zephyr_include_directories(.) zephyr_library_sources(soc_idle.c soc_irq.S soc_irq.c vector.S) + +set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/riscv/common/linker.ld CACHE INTERNAL "") diff --git a/soc/nordic/nrf53/CMakeLists.txt b/soc/nordic/nrf53/CMakeLists.txt index 0e8b1e69a29d..145a425e55ac 100644 --- a/soc/nordic/nrf53/CMakeLists.txt +++ b/soc/nordic/nrf53/CMakeLists.txt @@ -3,6 +3,7 @@ zephyr_library_sources(soc.c) zephyr_include_directories(.) +zephyr_library_sources_ifdef(CONFIG_SOC_NRF53_CPUNET_MGMT nrf53_cpunet_mgmt.c) zephyr_library_sources_ifdef(CONFIG_NRF53_SYNC_RTC sync_rtc.c) if (CONFIG_SOC_NRF53_ANOMALY_160_WORKAROUND_NEEDED AND diff --git a/soc/nordic/nrf53/Kconfig b/soc/nordic/nrf53/Kconfig index 7ef9546058d9..5f0d5b123267 100644 --- a/soc/nordic/nrf53/Kconfig +++ b/soc/nordic/nrf53/Kconfig @@ -24,6 +24,7 @@ config SOC_NRF5340_CPUAPP select ARMV8_M_DSP select HAS_POWEROFF select SOC_COMPATIBLE_NRF5340_CPUAPP + select SOC_NRF53_CPUNET_MGMT imply SOC_NRF53_RTC_PRETICK imply SOC_NRF53_ANOMALY_168_WORKAROUND @@ -126,18 +127,38 @@ config NRF_SPU_FLASH_REGION_SIZE help FLASH region size for the NRF_SPU peripheral +config NRF_SPU_FLASH_REGION_ALIGNMENT + hex + default 0x4000 + help + FLASH regions must be aligned to this value due to SPU HW + limitations. + config NRF_SPU_RAM_REGION_SIZE hex default 0x2000 help RAM region size for the NRF_SPU peripheral +config NRF_SPU_RAM_REGION_ALIGNMENT + hex + default 0x2000 + help + RAM regions must be aligned to this value due to SPU HW + limitations. + config SOC_NRF_GPIO_FORWARDER_FOR_NRF5340 bool depends on NRF_SOC_SECURE_SUPPORTED help hidden option for including the nRF GPIO pin forwarding +config SOC_NRF53_CPUNET_MGMT + bool + select ONOFF + help + hidden option for including the nRF53 network CPU management + if !TRUSTED_EXECUTION_NONSECURE || BUILD_WITH_TFM config SOC_ENABLE_LFXO diff --git a/soc/nordic/nrf53/nrf53_cpunet_mgmt.c b/soc/nordic/nrf53/nrf53_cpunet_mgmt.c new file mode 100644 index 000000000000..57a23d29bb8c --- /dev/null +++ b/soc/nordic/nrf53/nrf53_cpunet_mgmt.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file Nordic Semiconductor nRF53 processors family management helper for the network CPU. + */ + +#include + +#include +#include +#include +#include +#include + +#include + +static struct onoff_manager cpunet_mgr; + +static void onoff_start(struct onoff_manager *mgr, onoff_notify_fn notify) +{ + nrf_reset_network_force_off(NRF_RESET, false); + + notify(mgr, 0); +} + +static void onoff_stop(struct onoff_manager *mgr, onoff_notify_fn notify) +{ + nrf_reset_network_force_off(NRF_RESET, true); + + notify(mgr, 0); +} + +static int nrf53_cpunet_mgmt_init(void) +{ + static const struct onoff_transitions transitions = { + .start = onoff_start, + .stop = onoff_stop + }; + + return onoff_manager_init(&cpunet_mgr, &transitions); +} + +SYS_INIT(nrf53_cpunet_mgmt_init, PRE_KERNEL_1, 0); + +void nrf53_cpunet_enable(bool on) +{ + int ret; + int ignored; + struct onoff_client cli; + + if (on) { + sys_notify_init_spinwait(&cli.notify); + + ret = onoff_request(&cpunet_mgr, &cli); + __ASSERT_NO_MSG(ret >= 0); + + /* The transition is synchronous and shall take effect immediately. */ + ret = sys_notify_fetch_result(&cli.notify, &ignored); + } else { + ret = onoff_release(&cpunet_mgr); + } + + __ASSERT_NO_MSG(ret >= 0); +} diff --git a/soc/nordic/nrf53/nrf53_cpunet_mgmt.h b/soc/nordic/nrf53/nrf53_cpunet_mgmt.h new file mode 100644 index 000000000000..0273061c20cd --- /dev/null +++ b/soc/nordic/nrf53/nrf53_cpunet_mgmt.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file Nordic Semiconductor nRF53 processors family management helper for the network CPU. + */ + +#ifndef NRF53_CPUNET_MGMT_H__ +#define NRF53_CPUNET_MGMT_H__ + +#include + +/** + * @brief Enables or disables nRF53 network CPU. + * + * This function shall be used to control the network CPU exclusively. Internally, it keeps track of + * the requests to enable or disable nRF53 network CPU. It guarantees to enable the network CPU if + * at least one user requests it and to keep it enabled until all users release it. + * + * In conseqeuence, if @p on equals @c true then the network CPU is guaranteed to be enabled when + * this function returns. If @p on equals @c false then nothing can be inferred about the state of + * the network CPU when the function returns. + * + * @param on indicates whether the network CPU shall be powered on or off. + */ +void nrf53_cpunet_enable(bool on); + +#endif /* NRF53_CPUNET_MGMT_H__ */ diff --git a/soc/nordic/nrf54h/Kconfig b/soc/nordic/nrf54h/Kconfig index 2b967bece7ce..8925669ae0db 100644 --- a/soc/nordic/nrf54h/Kconfig +++ b/soc/nordic/nrf54h/Kconfig @@ -31,11 +31,3 @@ config SOC_NRF54H20_CPURAD config SOC_NRF54H20_CPUPPR depends on RISCV_CORE_NORDIC_VPR - -if SOC_NRF54H20 - -config NRF_ENABLE_ICACHE - bool "Instruction cache (I-Cache)" - default y - -endif # SOC_NRF54H20 diff --git a/soc/nordic/nrf54h/Kconfig.defconfig b/soc/nordic/nrf54h/Kconfig.defconfig index 72ba234e883b..b09b24e5e704 100644 --- a/soc/nordic/nrf54h/Kconfig.defconfig +++ b/soc/nordic/nrf54h/Kconfig.defconfig @@ -33,4 +33,10 @@ config SYS_CLOCK_HW_CYCLES_PER_SEC endif # RISCV +config SPI_DW_HSSI + default y if SPI_DW + +config SPI_DW_ACCESS_WORD_ONLY + default y if SPI_DW + endif # SOC_SERIES_NRF54HX diff --git a/soc/nordic/nrf54h/soc.c b/soc/nordic/nrf54h/soc.c index 1d071f96b20b..df72cdb977b0 100644 --- a/soc/nordic/nrf54h/soc.c +++ b/soc/nordic/nrf54h/soc.c @@ -82,9 +82,8 @@ static int trim_hsfll(void) static int nordicsemi_nrf54h_init(void) { -#if defined(CONFIG_NRF_ENABLE_ICACHE) sys_cache_instr_enable(); -#endif + sys_cache_data_enable(); power_domain_init(); diff --git a/soc/nordic/nrf91/Kconfig b/soc/nordic/nrf91/Kconfig index ed38eff73a2d..8001f3aca3a2 100644 --- a/soc/nordic/nrf91/Kconfig +++ b/soc/nordic/nrf91/Kconfig @@ -24,6 +24,13 @@ config NRF_SPU_FLASH_REGION_SIZE help FLASH region size for the NRF_SPU peripheral +config NRF_SPU_FLASH_REGION_ALIGNMENT + hex + default 0x8000 + help + FLASH regions must be aligned to this value due to SPU HW + limitations. + config NRF_SPU_RAM_REGION_SIZE hex default 0x2000 @@ -34,4 +41,11 @@ config NRF_ENABLE_ICACHE bool "Instruction cache (I-Cache)" default y +config NRF_SPU_RAM_REGION_ALIGNMENT + hex + default 0x2000 + help + RAM regions must be aligned to this value due to SPU HW + limitations. + endif # SOC_SERIES_NRF91X diff --git a/soc/nordic/soc.yml b/soc/nordic/soc.yml index 87f35a465584..f7fb6bfec71c 100644 --- a/soc/nordic/soc.yml +++ b/soc/nordic/soc.yml @@ -1,39 +1,98 @@ family: -- name: nordic_nrf - series: - - name: nrf51 - socs: - - name: nrf51822 - - name: nrf52 - socs: - - name: nrf52805 - - name: nrf52810 - - name: nrf52811 - - name: nrf52820 - - name: nrf52832 - - name: nrf52833 - - name: nrf52840 - - name: nrf53 - socs: - - name: nrf5340 - cpuclusters: - - name: cpuapp - - name: cpunet - - name: nrf54l - socs: - - name: nrf54l15 - cpuclusters: - - name: cpuapp - - name: nrf54h - socs: - - name: nrf54h20 - cpuclusters: - - name: cpuapp - - name: cpurad - - name: cpuppr - - name: nrf91 - socs: - - name: nrf9131 - - name: nrf9151 - - name: nrf9160 - - name: nrf9161 + - name: nordic_nrf + series: + - name: nrf51 + socs: + - name: nrf51822 + - name: nrf52 + socs: + - name: nrf52805 + - name: nrf52810 + - name: nrf52811 + - name: nrf52820 + - name: nrf52832 + - name: nrf52833 + - name: nrf52840 + - name: nrf53 + socs: + - name: nrf5340 + cpuclusters: + - name: cpuapp + - name: cpunet + - name: nrf54l + socs: + - name: nrf54l15 + cpuclusters: + - name: cpuapp + - name: nrf54h + socs: + - name: nrf54h20 + cpuclusters: + - name: cpuapp + - name: cpurad + - name: cpuppr + - name: nrf91 + socs: + - name: nrf9131 + - name: nrf9151 + - name: nrf9160 + - name: nrf9161 + +# Recovery/erase is only needed once per core. Prevent resetting the cores whilst flashing +# multiple images until all images for each core have been flashed, this allows security +# bits to be set during programming without them interfering with additional flashing +# operations. +runners: + run_once: + '--recover': + - runners: + - nrfjprog + run: first + groups: + - qualifiers: + - nrf51([0-9]{3})((.+)?) + - qualifiers: + - nrf52([0-9]{3})((.+)?) + - qualifiers: + - nrf5340/cpunet + - nrf5340/cpuapp + - nrf5340/cpuapp/ns + - qualifiers: + - nrf9160 + - nrf9160/ns + '--erase': + - runners: + - nrfjprog + - jlink + run: first + groups: + - qualifiers: + - nrf51([0-9]{3})((.+)?) + - qualifiers: + - nrf52([0-9]{3})((.+)?) + - qualifiers: + - nrf5340/cpunet + - qualifiers: + - nrf5340/cpuapp + - nrf5340/cpuapp/ns + - qualifiers: + - nrf9160 + - nrf9160/ns + '--reset': + - runners: + - nrfjprog + - jlink + run: last + groups: + - qualifiers: + - nrf51([0-9]{3})((.+)?) + - qualifiers: + - nrf52([0-9]{3})((.+)?) + - qualifiers: + - nrf5340/cpunet + - qualifiers: + - nrf5340/cpuapp + - nrf5340/cpuapp/ns + - qualifiers: + - nrf9160 + - nrf9160/ns diff --git a/subsys/bluetooth/controller/Kconfig b/subsys/bluetooth/controller/Kconfig index 4d97152f2d35..d0a863f41cf8 100644 --- a/subsys/bluetooth/controller/Kconfig +++ b/subsys/bluetooth/controller/Kconfig @@ -117,7 +117,8 @@ choice BT_LL_CHOICE Select the Bluetooth Link Layer to compile. config BT_LL_SW_SPLIT - bool "Software-based BLE Link Layer" + bool "Software-based BLE Link Layer [EXPERIMENTAL]" + select EXPERIMENTAL select ENTROPY_GENERATOR help Use Zephyr software BLE Link Layer ULL LLL split implementation. diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index ba43622604a8..bce9b76186f4 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -99,10 +99,15 @@ config BT_CTLR_ULL_LLL_PRIO_SUPPORT bool config BT_CTLR_RX_PRIO_STACK_SIZE - # Controller's Co-Operative high priority Rx thread stack size. - int "High priority Rx thread stack size" + # Hidden, Controller's Co-Operative high priority Rx thread stack size. + int default 448 +config BT_CTLR_RX_STACK_SIZE + # Hidden, Controller's Co-Operative Rx thread stack size. + int + default 768 + config BT_CTLR_SETTINGS bool "Settings System" depends on SETTINGS diff --git a/subsys/bluetooth/controller/hci/hci_driver.c b/subsys/bluetooth/controller/hci/hci_driver.c index cc315a99df6b..9c66594bcda6 100644 --- a/subsys/bluetooth/controller/hci/hci_driver.c +++ b/subsys/bluetooth/controller/hci/hci_driver.c @@ -73,7 +73,7 @@ struct k_thread prio_recv_thread_data; static K_KERNEL_STACK_DEFINE(prio_recv_thread_stack, CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE); struct k_thread recv_thread_data; -static K_KERNEL_STACK_DEFINE(recv_thread_stack, CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE); +static K_KERNEL_STACK_DEFINE(recv_thread_stack, CONFIG_BT_CTLR_RX_STACK_SIZE); #if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL) static struct k_poll_signal hbuf_signal; diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index 0be375007ca4..1753c7a2d6aa 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -48,7 +48,7 @@ config BT_HCI_TX_STACK_SIZE default 512 if BT_H4 default 512 if BT_H5 default 416 if BT_SPI - default 940 if BT_CTLR && BT_LL_SW_SPLIT && (NO_OPTIMIZATIONS || BT_ISO_BROADCAST) + default 1152 if BT_CTLR && BT_LL_SW_SPLIT && (NO_OPTIMIZATIONS || BT_ISO_BROADCAST) default 1024 if BT_CTLR && BT_LL_SW_SPLIT && BT_CENTRAL default 768 if BT_CTLR && BT_LL_SW_SPLIT default 512 if BT_USERCHAN diff --git a/subsys/bluetooth/host/Kconfig.l2cap b/subsys/bluetooth/host/Kconfig.l2cap index 401079f71c61..52a21e2d87d9 100644 --- a/subsys/bluetooth/host/Kconfig.l2cap +++ b/subsys/bluetooth/host/Kconfig.l2cap @@ -66,7 +66,7 @@ config BT_L2CAP_DYNAMIC_CHANNEL allowing the creation of dynamic L2CAP Channels. config BT_L2CAP_ECRED - bool "L2CAP Enhanced Credit Based Flow Control support" + bool "L2CAP Enhanced Credit Based Flow Control support [EXPERIMENTAL]" depends on BT_L2CAP_DYNAMIC_CHANNEL help This option enables support for LE Connection oriented Channels with diff --git a/subsys/bluetooth/mesh/Kconfig b/subsys/bluetooth/mesh/Kconfig index 88fccf0961cf..a79e0e4d4e95 100644 --- a/subsys/bluetooth/mesh/Kconfig +++ b/subsys/bluetooth/mesh/Kconfig @@ -1560,7 +1560,7 @@ config BT_MESH_LPN_INIT_POLL_TIMEOUT config BT_MESH_LPN_SCAN_LATENCY int "Latency for enabling scanning" range 0 50 - default 15 + default 2 help Latency in milliseconds that it takes to enable scanning. This is in practice how much time in advance before the Receive Window diff --git a/subsys/bluetooth/mesh/adv_ext.c b/subsys/bluetooth/mesh/adv_ext.c index f6367a052581..c4d3e335748d 100644 --- a/subsys/bluetooth/mesh/adv_ext.c +++ b/subsys/bluetooth/mesh/adv_ext.c @@ -13,6 +13,9 @@ #include #include #include +#if defined(CONFIG_BT_LL_SOFTDEVICE) +#include +#endif #include "common/bt_str.h" @@ -136,6 +139,28 @@ static inline struct bt_mesh_ext_adv *gatt_adv_get(void) } } +static int set_adv_randomness(uint8_t handle, int rand_us) +{ +#if defined(CONFIG_BT_LL_SOFTDEVICE) + struct net_buf *buf; + sdc_hci_cmd_vs_set_adv_randomness_t *cmd_params; + + buf = bt_hci_cmd_create(SDC_HCI_OPCODE_CMD_VS_SET_ADV_RANDOMNESS, sizeof(*cmd_params)); + if (!buf) { + LOG_ERR("Could not allocate command buffer"); + return -ENOMEM; + } + + cmd_params = net_buf_add(buf, sizeof(*cmd_params)); + cmd_params->adv_handle = handle; + cmd_params->rand_us = rand_us; + + return bt_hci_cmd_send_sync(SDC_HCI_OPCODE_CMD_VS_SET_ADV_RANDOMNESS, buf, NULL); +#else + return 0; +#endif /* defined(CONFIG_BT_LL_SOFTDEVICE) */ +} + static int adv_start(struct bt_mesh_ext_adv *ext_adv, const struct bt_le_adv_param *param, struct bt_le_ext_adv_start_param *start, @@ -490,6 +515,15 @@ int bt_mesh_adv_enable(void) if (err) { return err; } + + if (IS_ENABLED(CONFIG_BT_LL_SOFTDEVICE) && + IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_FRIEND_SEPARATE) && + advs[i].tags == BT_MESH_ADV_TAG_BIT_FRIEND) { + err = set_adv_randomness(advs[i].instance->handle, 0); + if (err) { + LOG_ERR("Failed to set zero randomness: %d", err); + } + } } return 0; diff --git a/subsys/bluetooth/mesh/blob_io_flash.c b/subsys/bluetooth/mesh/blob_io_flash.c index 8090416ab122..b82a7d20f7f7 100644 --- a/subsys/bluetooth/mesh/blob_io_flash.c +++ b/subsys/bluetooth/mesh/blob_io_flash.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Noioic Semiconductor ASA + * Copyright (c) 2020 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,7 +12,7 @@ #include "net.h" #include "transport.h" -#define WRITE_BLOCK_SIZE 4 +#define WRITE_BLOCK_SIZE DT_PROP(DT_INST(0, soc_nv_flash), write_block_size) #define FLASH_IO(_io) CONTAINER_OF(_io, struct bt_mesh_blob_io_flash, io) @@ -110,6 +110,13 @@ static int wr_chunk(const struct bt_mesh_blob_io *io, const struct bt_mesh_blob_chunk *chunk) { struct bt_mesh_blob_io_flash *flash = FLASH_IO(io); + + if (IS_ENABLED(CONFIG_SOC_FLASH_NRF_RRAM)) { + return flash_area_write(flash->area, + flash->offset + block->offset + chunk->offset, + chunk->data, chunk->size); + } + uint8_t buf[ROUND_UP(BLOB_CHUNK_SIZE_MAX(BT_MESH_RX_SDU_MAX), WRITE_BLOCK_SIZE)]; off_t area_offset = flash->offset + block->offset + chunk->offset; diff --git a/subsys/dfu/boot/mcuboot.c b/subsys/dfu/boot/mcuboot.c index 4f03c7c9e24c..1be8f8194427 100644 --- a/subsys/dfu/boot/mcuboot.c +++ b/subsys/dfu/boot/mcuboot.c @@ -34,8 +34,34 @@ #define BOOT_HEADER_MAGIC_V1 0x96f3b83d #define BOOT_HEADER_SIZE_V1 32 +#if USE_PARTITION_MANAGER +#include + +#if CONFIG_BUILD_WITH_TFM + #define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE) +#else + #define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE) +#endif + +#ifdef CONFIG_MCUBOOT + /* lib is part of MCUboot -> operate on the primart application slot */ + #define ACTIVE_SLOT_ID PM_MCUBOOT_PRIMARY_ID +#else + /* lib is part of the App -> operate on active slot */ +#if (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_PRIMARY_ADDRESS + #define ACTIVE_SLOT_ID PM_MCUBOOT_PRIMARY_ID +#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS + #define ACTIVE_SLOT_ID PM_MCUBOOT_SECONDARY_ID +#else + #error Missing partition definitions. +#endif +#endif /* CONFIG_MCUBOOT */ + +#define ACTIVE_SLOT_FLASH_AREA_ID ACTIVE_SLOT_ID +#else /* Get active partition. zephyr,code-partition chosen node must be defined */ #define ACTIVE_SLOT_FLASH_AREA_ID DT_FIXED_PARTITION_ID(DT_CHOSEN(zephyr_code_partition)) +#endif /* USE_PARTITION_MANAGER */ /* * Raw (on-flash) representation of the v1 image header. diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index b373ca92ba8e..3fc84c2922db 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1054,7 +1054,12 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(inst)) = { \ .type = FS_LITTLEFS, \ .mnt_point = DT_INST_PROP(inst, mount_point), \ .fs_data = &fs_data_##inst, \ - .storage_dev = (void *)DT_FIXED_PARTITION_ID(FS_PARTITION(inst)), \ + .storage_dev = (void *) \ + COND_CODE_1(USE_PARTITION_MANAGER, \ + (COND_CODE_1(FIXED_PARTITION_EXISTS(littlefs_storage), \ + (FIXED_PARTITION_ID(littlefs_storage)), \ + (FIXED_PARTITION_ID(storage)))), \ + (DT_FIXED_PARTITION_ID(FS_PARTITION(inst)))), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/fs/nvs/Kconfig b/subsys/fs/nvs/Kconfig index 209e2ad29a6b..2ecf632723ef 100644 --- a/subsys/fs/nvs/Kconfig +++ b/subsys/fs/nvs/Kconfig @@ -29,6 +29,15 @@ config NVS_LOOKUP_CACHE_SIZE Number of entries in Non-volatile Storage lookup cache. It is recommended that it be a power of 2. +config NVS_LOOKUP_CACHE_FOR_SETTINGS + bool "Non-volatile Storage lookup cache optimized for settings" + depends on NVS_LOOKUP_CACHE + help + Use the lookup cache hash function that results in the least number of + collissions and, in turn, the best NVS performance provided that the NVS + is used as the settings backend only. This option should NOT be enabled + if the NVS is also written to directly, outside the settings layer. + module = NVS module-str = nvs source "subsys/logging/Kconfig.template.log_config" diff --git a/subsys/fs/nvs/nvs.c b/subsys/fs/nvs/nvs.c index ef35e677710e..5ff0274c7302 100644 --- a/subsys/fs/nvs/nvs.c +++ b/subsys/fs/nvs/nvs.c @@ -13,6 +13,11 @@ #include #include "nvs_priv.h" +#ifdef CONFIG_NVS_LOOKUP_CACHE_FOR_SETTINGS +#include +#include +#endif + #include LOG_MODULE_REGISTER(fs_nvs, CONFIG_NVS_LOG_LEVEL); @@ -21,6 +26,45 @@ static int nvs_ate_valid(struct nvs_fs *fs, const struct nvs_ate *entry); #ifdef CONFIG_NVS_LOOKUP_CACHE +#ifdef CONFIG_NVS_LOOKUP_CACHE_FOR_SETTINGS + +static inline size_t nvs_lookup_cache_pos(uint16_t id) +{ + /* + * 1. The NVS settings backend uses up to (NVS_NAME_ID_OFFSET - 1) NVS IDs to + store keys and equal number of NVS IDs to store values. + * 2. For each key-value pair, the value is stored at NVS ID greater by exactly + * NVS_NAME_ID_OFFSET than NVS ID that holds the key. + * 3. The backend tries to minimize the range of NVS IDs used to store keys. + * That is, NVS IDs are allocated sequentially, and freed NVS IDs are reused + * before allocating new ones. + * + * Therefore, to assure the least number of collisions in the lookup cache, + * the least significant bit of the hash indicates whether the given NVS ID + * represents a key or a value, and remaining bits of the hash are set to + * the ordinal number of the key-value pair. Consequently, the hash function + * provides the following mapping: + * + * 1st settings key => hash 0 + * 1st settings value => hash 1 + * 2nd settings key => hash 2 + * 2nd settings value => hash 3 + * ... + */ + BUILD_ASSERT(IS_POWER_OF_TWO(NVS_NAMECNT_ID), "NVS_NAMECNT_ID is not power of 2"); + BUILD_ASSERT(IS_POWER_OF_TWO(NVS_NAME_ID_OFFSET), "NVS_NAME_ID_OFFSET is not power of 2"); + + uint16_t key_value_bit; + uint16_t key_value_ord; + + key_value_bit = (id >> LOG2(NVS_NAME_ID_OFFSET)) & 1; + key_value_ord = id & (NVS_NAME_ID_OFFSET - 1); + + return ((key_value_ord << 1) | key_value_bit) % CONFIG_NVS_LOOKUP_CACHE_SIZE; +} + +#else /* CONFIG_NVS_LOOKUP_CACHE_FOR_SETTINGS */ + static inline size_t nvs_lookup_cache_pos(uint16_t id) { uint16_t hash; @@ -36,6 +80,8 @@ static inline size_t nvs_lookup_cache_pos(uint16_t id) return hash % CONFIG_NVS_LOOKUP_CACHE_SIZE; } +#endif /* CONFIG_NVS_LOOKUP_CACHE_FOR_SETTINGS */ + static int nvs_lookup_cache_rebuild(struct nvs_fs *fs) { int rc; diff --git a/subsys/ipc/ipc_service/backends/ipc_icbmsg.c b/subsys/ipc/ipc_service/backends/ipc_icbmsg.c index da2db4ccbc8e..c7127888b185 100644 --- a/subsys/ipc/ipc_service/backends/ipc_icbmsg.c +++ b/subsys/ipc/ipc_service/backends/ipc_icbmsg.c @@ -75,6 +75,9 @@ * data messages, it calls bound endpoint and it is ready to send data. */ +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L /* For strnlen() */ + #include #include @@ -107,6 +110,12 @@ LOG_MODULE_REGISTER(ipc_icbmsg, /** Registered endpoints count mask in flags. */ #define FLAG_EPT_COUNT_MASK 0xFFFF +/** Workqueue stack size for bounding processing (this configuration is not optimized). */ +#define EP_BOUND_WORK_Q_STACK_SIZE (512U) + +/** Workqueue priority for bounding processing. */ +#define EP_BOUND_WORK_Q_PRIORITY (CONFIG_SYSTEM_WORKQUEUE_PRIORITY) + enum msg_type { MSG_DATA = 0, /* Data message. */ MSG_RELEASE_DATA, /* Release data buffer message. */ @@ -191,6 +200,9 @@ struct control_message { BUILD_ASSERT(NUM_EPT <= EPT_ADDR_INVALID, "Too many endpoints"); +/* Work queue for bounding processing. */ +static struct k_work_q ep_bound_work_q; + /** * Calculate pointer to block from its index and channel configuration (RX or TX). * No validation is performed. @@ -669,7 +681,7 @@ static int send_bound_message(struct backend_data *dev_data, struct ept_data *ep */ static void schedule_ept_bound_process(struct backend_data *dev_data) { - k_work_submit(&dev_data->ep_bound_work); + k_work_submit_to_queue(&ep_bound_work_q, &dev_data->ep_bound_work); } /** @@ -1114,6 +1126,17 @@ static int backend_init(const struct device *instance) { const struct icbmsg_config *conf = instance->config; struct backend_data *dev_data = instance->data; + static K_THREAD_STACK_DEFINE(ep_bound_work_q_stack, EP_BOUND_WORK_Q_STACK_SIZE); + static bool is_work_q_started; + + if (!is_work_q_started) { + k_work_queue_init(&ep_bound_work_q); + k_work_queue_start(&ep_bound_work_q, ep_bound_work_q_stack, + K_THREAD_STACK_SIZEOF(ep_bound_work_q_stack), + EP_BOUND_WORK_Q_PRIORITY, NULL); + + is_work_q_started = true; + } dev_data->conf = conf; dev_data->is_initiator = (conf->rx.blocks_ptr < conf->tx.blocks_ptr); diff --git a/subsys/ipc/rpmsg_service/rpmsg_backend.h b/subsys/ipc/rpmsg_service/rpmsg_backend.h index a74e46b85207..9996e1d74d9b 100644 --- a/subsys/ipc/rpmsg_service/rpmsg_backend.h +++ b/subsys/ipc/rpmsg_service/rpmsg_backend.h @@ -13,8 +13,35 @@ extern "C" { #endif +#if CONFIG_PARTITION_MANAGER_ENABLED + +#include "pm_config.h" + +#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) + +#if defined(PM_RPMSG_NRF53_SRAM_ADDRESS) +#define VDEV_START_ADDR PM_RPMSG_NRF53_SRAM_ADDRESS +#define VDEV_SIZE PM_RPMSG_NRF53_SRAM_SIZE +#else +/* The current image is a child image in a different domain than the image + * which defined the required values. To reach the values of the parent domain + * we use the 'PM__' variant of the define. + */ +#define VDEV_START_ADDR PM__RPMSG_NRF53_SRAM_ADDRESS +#define VDEV_SIZE PM__RPMSG_NRF53_SRAM_SIZE +#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) */ + +#else #define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) #define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) +#endif /* defined(PM_RPMSG_NRF53_SRAM_ADDRESS) || defined(PM__RPMSG_NRF53_SRAM_ADDRESS) */ + +#else + +#define VDEV_START_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_ipc_shm)) +#define VDEV_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_ipc_shm)) + +#endif /* CONFIG_PARTITION_MANAGER_ENABLED */ #define VDEV_STATUS_ADDR VDEV_START_ADDR #define VDEV_STATUS_SIZE 0x400 diff --git a/subsys/mgmt/mcumgr/CMakeLists.txt b/subsys/mgmt/mcumgr/CMakeLists.txt index 39d4a4ca8ce0..ad088eca0677 100644 --- a/subsys/mgmt/mcumgr/CMakeLists.txt +++ b/subsys/mgmt/mcumgr/CMakeLists.txt @@ -16,3 +16,11 @@ add_subdirectory(transport) add_subdirectory_ifdef(CONFIG_SMP_CLIENT smp_client) zephyr_library_link_libraries(mgmt_mcumgr) + +if (CONFIG_BOOT_IMAGE_ACCESS_HOOKS) + zephyr_include_directories( + ${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/bootutil/include + ${ZEPHYR_MCUBOOT_MODULE_DIR}/boot/zephyr/include + ) + zephyr_library_sources(bootutil_hooks/nrf53_hooks.c) +endif() diff --git a/subsys/mgmt/mcumgr/Kconfig b/subsys/mgmt/mcumgr/Kconfig index 49bd17f46691..1c6a3a2a5162 100644 --- a/subsys/mgmt/mcumgr/Kconfig +++ b/subsys/mgmt/mcumgr/Kconfig @@ -6,6 +6,7 @@ menuconfig MCUMGR bool "mcumgr Support" depends on NET_BUF depends on ZCBOR + imply BOOT_IMAGE_ACCESS_HOOKS if (SOC_NRF5340_CPUAPP_QKAA && MCUMGR_GRP_IMG) help This option enables the mcumgr management library. diff --git a/subsys/mgmt/mcumgr/bootutil_hooks/nrf53_hooks.c b/subsys/mgmt/mcumgr/bootutil_hooks/nrf53_hooks.c new file mode 100644 index 000000000000..9971a4e08431 --- /dev/null +++ b/subsys/mgmt/mcumgr/bootutil_hooks/nrf53_hooks.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include "bootutil/bootutil_public.h" + +int boot_read_swap_state_primary_slot_hook(int image_index, + struct boot_swap_state *state) +{ + if (image_index == 1) { + /* Pretend that primary slot of image 1 unpopulated */ + state->magic = BOOT_MAGIC_UNSET; + state->swap_type = BOOT_SWAP_TYPE_NONE; + state->image_num = image_index; + state->copy_done = BOOT_FLAG_UNSET; + state->image_ok = BOOT_FLAG_UNSET; + + /* Prevent bootutil from trying to obtain true info */ + return 0; + } + + return BOOT_HOOK_REGULAR; +} diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c index 300948d5c88c..305cad41c445 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c @@ -33,6 +33,23 @@ #include #endif +#if USE_PARTITION_MANAGER +#include + +#ifdef PM_MCUBOOT_SECONDARY_PAD_SIZE +BUILD_ASSERT(PM_MCUBOOT_PAD_SIZE == PM_MCUBOOT_SECONDARY_PAD_SIZE); +#endif + +#if CONFIG_BUILD_WITH_TFM + #define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE) +#else + #define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE) +#endif + +#define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ + (FIXED_PARTITION_OFFSET(label) == (PM_ADDRESS - PM_ADDRESS_OFFSET)) + +#else /* ! USE_PARTITION_MANAGER */ #ifndef CONFIG_FLASH_LOAD_OFFSET #error MCUmgr requires application to be built with CONFIG_FLASH_LOAD_OFFSET set \ to be able to figure out application running slot. @@ -40,6 +57,7 @@ #define FIXED_PARTITION_IS_RUNNING_APP_PARTITION(label) \ (FIXED_PARTITION_OFFSET(label) == CONFIG_FLASH_LOAD_OFFSET) +#endif /* USE_PARTITION_MANAGER */ BUILD_ASSERT(sizeof(struct image_header) == IMAGE_HEADER_SIZE, "struct image_header not required size"); diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c index c54fbd4d0c65..edfe26e452fd 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c @@ -290,13 +290,14 @@ int img_mgmt_get_next_boot_slot(int image, enum img_mgmt_next_boot_type *type) return_slot = other_slot; } } +out: + #else if (rcs == 0 && rca == 0 && img_mgmt_vercmp(&aver, &over) < 0) { return_slot = other_slot; } #endif /* defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_DIRECT_XIP_WITH_REVERT) */ -out: if (type != NULL) { *type = lt; } diff --git a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c index 29e222d1de95..9fc02f81661a 100644 --- a/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c @@ -469,9 +469,9 @@ os_mgmt_bootloader_info(struct smp_streamer *ctxt) ok = zcbor_tstr_put_lit(zse, "mode") && zcbor_int32_put(zse, BOOTLOADER_MODE); -#if IS_ENABLED(CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE) - ok = zcbor_tstr_put_lit(zse, "no-downgrade") && - zcbor_bool_encode(zse, true); +#ifdef CONFIG_MCUBOOT_BOOTLOADER_NO_DOWNGRADE + ok = ok && zcbor_tstr_put_lit(zse, "no-downgrade") && + zcbor_bool_encode(zse, &(bool){true}); #endif } else { return OS_MGMT_ERR_QUERY_YIELDS_NO_ANSWER; diff --git a/subsys/net/conn_mgr/Kconfig b/subsys/net/conn_mgr/Kconfig index 683634de9875..541edf0e63ec 100644 --- a/subsys/net/conn_mgr/Kconfig +++ b/subsys/net/conn_mgr/Kconfig @@ -24,6 +24,7 @@ source "subsys/net/Kconfig.template.log_config.net" config NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE int "Size of the stack allocated for the conn_mgr_monitor thread" + default 8192 if WPA_SUPP default 512 help Sets the stack size which will be used by the connection manager for connectivity monitoring. diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index a72470a434de..15a66af477c9 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -4633,6 +4633,18 @@ bool net_if_is_offloaded(struct net_if *iface) net_if_is_socket_offloaded(iface)); } +static void rejoin_multicast_groups(struct net_if *iface) +{ +#if defined(CONFIG_NET_NATIVE_IPV6) + rejoin_ipv6_mcast_groups(iface); + if (l2_flags_get(iface) & NET_L2_MULTICAST) { + join_mcast_allnodes(iface); + } +#else + ARG_UNUSED(iface); +#endif +} + static void notify_iface_up(struct net_if *iface) { /* In many places it's assumed that link address was set with @@ -4659,6 +4671,10 @@ static void notify_iface_up(struct net_if *iface) */ if (!net_if_is_offloaded(iface) && !(l2_flags_get(iface) & NET_L2_POINT_TO_POINT)) { + /* Make sure that we update the IPv6 addresses and join the + * multicast groups. + */ + rejoin_multicast_groups(iface); iface_ipv6_start(iface); net_ipv4_autoconf_start(iface); } @@ -4780,13 +4796,6 @@ static void init_igmp(struct net_if *iface) #endif } -static void rejoin_multicast_groups(struct net_if *iface) -{ -#if defined(CONFIG_NET_NATIVE_IPV6) - rejoin_ipv6_mcast_groups(iface); -#endif -} - int net_if_up(struct net_if *iface) { int status = 0; @@ -4844,14 +4853,6 @@ int net_if_up(struct net_if *iface) net_mgmt_event_notify(NET_EVENT_IF_ADMIN_UP, iface); update_operational_state(iface); - if (!net_if_is_offloaded(iface)) { - /* Make sure that we update the IPv6 addresses and join the - * multicast groups. - */ - rejoin_multicast_groups(iface); - net_if_start_dad(iface); - } - out: net_if_unlock(iface); diff --git a/subsys/net/l2/ethernet/Kconfig b/subsys/net/l2/ethernet/Kconfig index 17588b17fd1f..e6fd07e47e28 100644 --- a/subsys/net/l2/ethernet/Kconfig +++ b/subsys/net/l2/ethernet/Kconfig @@ -73,6 +73,19 @@ config NET_ARP_GRATUITOUS ff:ff:ff:ff:ff:ff. Ordinarily, no reply packet will occur. A gratuitous ARP reply is a reply to which no request has been made. +config NET_ARP_GRATUITOUS_TRANSMISSION + bool "Transmit gratuitous ARP requests" + depends on NET_ARP_GRATUITOUS + depends on NET_MGMT_EVENT + depends on NET_MGMT_EVENT_INFO + help + Transmit gratuitous ARP requests, as defined in RFC 5227. + +config NET_ARP_GRATUITOUS_INTERVAL + int "Time interval (in seconds) between sending gratuitous ARP requests" + depends on NET_ARP_GRATUITOUS_TRANSMISSION + default 60 + if NET_ARP module = NET_ARP module-dep = NET_LOG diff --git a/subsys/net/l2/ethernet/arp.c b/subsys/net/l2/ethernet/arp.c index 7c0a2ba74f25..85eafd0eedb3 100644 --- a/subsys/net/l2/ethernet/arp.c +++ b/subsys/net/l2/ethernet/arp.c @@ -16,6 +16,7 @@ LOG_MODULE_REGISTER(net_arp, CONFIG_NET_ARP_LOG_LEVEL); #include #include #include +#include #include "arp.h" #include "net_private.h" @@ -34,6 +35,12 @@ static struct k_work_delayable arp_request_timer; static struct k_mutex arp_mutex; +#if defined(CONFIG_NET_ARP_GRATUITOUS_TRANSMISSION) +static struct net_mgmt_event_callback iface_event_cb; +static struct net_mgmt_event_callback ipv4_event_cb; +static struct k_work_delayable arp_gratuitous_work; +#endif /* defined(CONFIG_NET_ARP_GRATUITOUS_TRANSMISSION) */ + static void arp_entry_cleanup(struct arp_entry *entry, bool pending) { NET_DBG("entry %p", entry); @@ -466,6 +473,141 @@ static void arp_gratuitous(struct net_if *iface, } } +#if defined(CONFIG_NET_ARP_GRATUITOUS_TRANSMISSION) +static void arp_gratuitous_send(struct net_if *iface, + struct in_addr *ipaddr) +{ + struct net_arp_hdr *hdr; + struct net_pkt *pkt; + + pkt = net_pkt_alloc_with_buffer(iface, sizeof(struct net_arp_hdr), + AF_UNSPEC, 0, NET_BUF_TIMEOUT); + if (!pkt) { + return; + } + + net_buf_add(pkt->buffer, sizeof(struct net_arp_hdr)); + net_pkt_set_vlan_tag(pkt, net_eth_get_vlan_tag(iface)); + + hdr = NET_ARP_HDR(pkt); + + hdr->hwtype = htons(NET_ARP_HTYPE_ETH); + hdr->protocol = htons(NET_ETH_PTYPE_IP); + hdr->hwlen = sizeof(struct net_eth_addr); + hdr->protolen = sizeof(struct in_addr); + hdr->opcode = htons(NET_ARP_REQUEST); + + memcpy(&hdr->dst_hwaddr.addr, net_eth_broadcast_addr(), + sizeof(struct net_eth_addr)); + memcpy(&hdr->src_hwaddr.addr, net_if_get_link_addr(iface)->addr, + sizeof(struct net_eth_addr)); + + net_ipv4_addr_copy_raw(hdr->dst_ipaddr, (uint8_t *)ipaddr); + net_ipv4_addr_copy_raw(hdr->src_ipaddr, (uint8_t *)ipaddr); + + net_pkt_lladdr_src(pkt)->addr = net_if_get_link_addr(iface)->addr; + net_pkt_lladdr_src(pkt)->len = sizeof(struct net_eth_addr); + + net_pkt_lladdr_dst(pkt)->addr = (uint8_t *)net_eth_broadcast_addr(); + net_pkt_lladdr_dst(pkt)->len = sizeof(struct net_eth_addr); + + NET_DBG("Sending gratuitous ARP pkt %p", pkt); + + if (net_if_send_data(iface, pkt) == NET_DROP) { + net_pkt_unref(pkt); + } +} + +static void notify_all_ipv4_addr(struct net_if *iface) +{ + struct net_if_ipv4 *ipv4 = iface->config.ip.ipv4; + int i; + + if (!ipv4) { + return; + } + + for (i = 0; i < NET_IF_MAX_IPV4_ADDR; i++) { + if (ipv4->unicast[i].ipv4.is_used && + ipv4->unicast[i].ipv4.address.family == AF_INET && + ipv4->unicast[i].ipv4.addr_state == NET_ADDR_PREFERRED) { + arp_gratuitous_send(iface, + &ipv4->unicast[i].ipv4.address.in_addr); + } + } +} + +static void iface_event_handler(struct net_mgmt_event_callback *cb, + uint32_t mgmt_event, struct net_if *iface) +{ + ARG_UNUSED(cb); + + if (!(net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET) || + net_eth_is_vlan_interface(iface))) { + return; + } + + if (mgmt_event != NET_EVENT_IF_UP) { + return; + } + + notify_all_ipv4_addr(iface); +} + +static void ipv4_event_handler(struct net_mgmt_event_callback *cb, + uint32_t mgmt_event, struct net_if *iface) +{ + struct in_addr *ipaddr; + + if (!(net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET) || + net_eth_is_vlan_interface(iface))) { + return; + } + + if (!net_if_is_up(iface)) { + return; + } + + if (mgmt_event != NET_EVENT_IPV4_ADDR_ADD) { + return; + } + + if (cb->info_length != sizeof(struct in_addr)) { + return; + } + + ipaddr = (struct in_addr *)cb->info; + + arp_gratuitous_send(iface, ipaddr); +} + +static void iface_cb(struct net_if *iface, void *user_data) +{ + ARG_UNUSED(user_data); + + if (!(net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET) || + net_eth_is_vlan_interface(iface))) { + return; + } + + if (!net_if_is_up(iface)) { + return; + } + + notify_all_ipv4_addr(iface); +} + +static void arp_gratuitous_work_handler(struct k_work *work) +{ + ARG_UNUSED(work); + + net_if_foreach(iface_cb, NULL); + + k_work_reschedule(&arp_gratuitous_work, + K_SECONDS(CONFIG_NET_ARP_GRATUITOUS_INTERVAL)); +} +#endif /* defined(CONFIG_NET_ARP_GRATUITOUS_TRANSMISSION) */ + void net_arp_update(struct net_if *iface, struct in_addr *src, struct net_eth_addr *hwaddr, @@ -837,4 +979,19 @@ void net_arp_init(void) k_mutex_init(&arp_mutex); arp_cache_initialized = true; + +#if defined(CONFIG_NET_ARP_GRATUITOUS_TRANSMISSION) + net_mgmt_init_event_callback(&iface_event_cb, iface_event_handler, + NET_EVENT_IF_UP); + net_mgmt_init_event_callback(&ipv4_event_cb, ipv4_event_handler, + NET_EVENT_IPV4_ADDR_ADD); + + net_mgmt_add_event_callback(&iface_event_cb); + net_mgmt_add_event_callback(&ipv4_event_cb); + + k_work_init_delayable(&arp_gratuitous_work, + arp_gratuitous_work_handler); + k_work_reschedule(&arp_gratuitous_work, + K_SECONDS(CONFIG_NET_ARP_GRATUITOUS_INTERVAL)); +#endif /* defined(CONFIG_NET_ARP_GRATUITOUS_TRANSMISSION) */ } diff --git a/subsys/net/l2/ethernet/vlan.c b/subsys/net/l2/ethernet/vlan.c index 844a6bbd2ef9..f8e21efbbb07 100644 --- a/subsys/net/l2/ethernet/vlan.c +++ b/subsys/net/l2/ethernet/vlan.c @@ -317,18 +317,17 @@ bool net_eth_is_vlan_enabled(struct ethernet_context *ctx, uint16_t net_eth_get_vlan_tag(struct net_if *iface) { uint16_t tag = NET_VLAN_TAG_UNSPEC; - struct vlan_context *ctx; k_mutex_lock(&lock, K_FOREVER); - ctx = get_vlan_ctx(iface, tag, true); - if (ctx != NULL) { - /* The Ethernet interface does not have a tag so if user - * tried to use the main interface, then do not return - * the tag. - */ - if (ctx->attached_to != iface) { - tag = ctx->tag; + ARRAY_FOR_EACH(vlan_ctx, i) { + if (vlan_ctx[i] == NULL || !vlan_ctx[i]->is_used) { + continue; + } + + if (vlan_ctx[i]->iface == iface) { + tag = vlan_ctx[i]->tag; + break; } } @@ -337,6 +336,22 @@ uint16_t net_eth_get_vlan_tag(struct net_if *iface) return tag; } +bool net_eth_is_vlan_interface(struct net_if *iface) +{ + enum virtual_interface_caps caps; + + if (net_if_l2(iface) != &NET_L2_GET_NAME(VIRTUAL)) { + return false; + } + + caps = net_virtual_get_iface_capabilities(iface); + if (!(caps & VIRTUAL_INTERFACE_VLAN)) { + return false; + } + + return true; +} + bool net_eth_get_vlan_status(struct net_if *iface) { bool status = false; diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index 5ef047e6c72b..51e76aec5fbe 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -275,7 +275,8 @@ static int wifi_connect(uint32_t mgmt_request, struct net_if *iface, (params->ssid_length == 0U) || ((params->security == WIFI_SECURITY_TYPE_PSK || params->security == WIFI_SECURITY_TYPE_WPA_PSK || - params->security == WIFI_SECURITY_TYPE_PSK_SHA256) && + params->security == WIFI_SECURITY_TYPE_PSK_SHA256 || + params->security == WIFI_SECURITY_TYPE_WPA_AUTO_PERSONAL) && ((params->psk_length < 8) || (params->psk_length > 64) || (params->psk_length == 0U) || !params->psk)) || ((params->security == WIFI_SECURITY_TYPE_SAE) && @@ -719,6 +720,26 @@ static int wifi_get_version(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION, wifi_get_version); +static int wifi_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface, + void *data, size_t len) +{ + const struct device *dev = net_if_get_device(iface); + const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface); + unsigned int *rts_threshold = data; + + if (wifi_mgmt_api == NULL || wifi_mgmt_api->set_rts_threshold == NULL) { + return -ENOTSUP; + } + + if (!data || len != sizeof(*rts_threshold)) { + return -EINVAL; + } + + return wifi_mgmt_api->set_rts_threshold(dev, *rts_threshold); +} + +NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD, wifi_set_rts_threshold); + #ifdef CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS void wifi_mgmt_raise_raw_scan_result_event(struct net_if *iface, struct wifi_raw_scan_result *raw_scan_result) diff --git a/subsys/net/l2/wifi/wifi_nm.c b/subsys/net/l2/wifi/wifi_nm.c index 4f3e2d239a1a..588992634bf2 100644 --- a/subsys/net/l2/wifi/wifi_nm.c +++ b/subsys/net/l2/wifi/wifi_nm.c @@ -10,6 +10,9 @@ LOG_MODULE_REGISTER(wifi_nm, CONFIG_WIFI_NM_LOG_LEVEL); #include #include +/* Used to protect nm data */ +static K_MUTEX_DEFINE(wifi_nm_lock); + struct wifi_nm_instance *wifi_nm_get_instance(const char *name) { STRUCT_SECTION_FOREACH(wifi_nm_instance, nm) { @@ -24,16 +27,19 @@ struct wifi_nm_instance *wifi_nm_get_instance(const char *name) struct wifi_nm_instance *wifi_nm_get_instance_iface(struct net_if *iface) { if (!iface || !net_if_is_wifi(iface)) { - return false; + return NULL; } + k_mutex_lock(&wifi_nm_lock, K_FOREVER); STRUCT_SECTION_FOREACH(wifi_nm_instance, nm) { for (int i = 0; i < CONFIG_WIFI_NM_MAX_MANAGED_INTERFACES; i++) { if (nm->mgd_ifaces[i] == iface) { + k_mutex_unlock(&wifi_nm_lock); return nm; } } } + k_mutex_unlock(&wifi_nm_lock); return NULL; } @@ -48,12 +54,15 @@ int wifi_nm_register_mgd_iface(struct wifi_nm_instance *nm, struct net_if *iface return -ENOTSUP; } + k_mutex_lock(&wifi_nm_lock, K_FOREVER); for (int i = 0; i < CONFIG_WIFI_NM_MAX_MANAGED_INTERFACES; i++) { if (!nm->mgd_ifaces[i]) { nm->mgd_ifaces[i] = iface; + k_mutex_unlock(&wifi_nm_lock); return 0; } } + k_mutex_unlock(&wifi_nm_lock); return -ENOMEM; } @@ -64,12 +73,15 @@ int wifi_nm_unregister_mgd_iface(struct wifi_nm_instance *nm, struct net_if *ifa return -EINVAL; } + k_mutex_lock(&wifi_nm_lock, K_FOREVER); for (int i = 0; i < CONFIG_WIFI_NM_MAX_MANAGED_INTERFACES; i++) { if (nm->mgd_ifaces[i] == iface) { nm->mgd_ifaces[i] = NULL; + k_mutex_unlock(&wifi_nm_lock); return 0; } } + k_mutex_unlock(&wifi_nm_lock); return -ENOENT; } diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 3eb4dac5dddf..954b6aecc077 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -496,12 +496,8 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv } break; case 'p': - if (secure_connection) { - params->psk = optarg; - params->psk_length = strlen(params->psk); - } else { - PR_WARNING("Passphrase provided without security configuration\n"); - } + params->psk = optarg; + params->psk_length = strlen(params->psk); break; case 'c': channel = strtol(optarg, &endptr, 10); @@ -568,15 +564,16 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv ¶ms->bssid[4], ¶ms->bssid[5]); break; case 'h': - shell_help(sh); - break; + return -ENOEXEC; default: PR_ERROR("Invalid option %c\n", opt); shell_help(sh); return -EINVAL; } } - + if (params->psk && !secure_connection) { + PR_WARNING("Passphrase provided without security configuration\n"); + } return 0; } @@ -849,6 +846,8 @@ static void print_wifi_stats(struct net_if *iface, struct net_stats_wifi *data, PR("Mcast sent : %u\n", data->multicast.tx); PR("Beacons received : %u\n", data->sta_mgmt.beacons_rx); PR("Beacons missed : %u\n", data->sta_mgmt.beacons_miss); + PR("Unicast received : %u\n", data->unicast.rx); + PR("Unicast sent : %u\n", data->unicast.tx); } #endif /* CONFIG_NET_STATISTICS_WIFI && CONFIG_NET_STATISTICS_USER_API */ @@ -1242,7 +1241,7 @@ static int cmd_wifi_ap_enable(const struct shell *sh, size_t argc, int ret; context.sh = sh; - if (__wifi_args_to_params(sh, argc - 1, &argv[1], &cnx_params, WIFI_MODE_AP)) { + if (__wifi_args_to_params(sh, argc, &argv[0], &cnx_params, WIFI_MODE_AP)) { shell_help(sh); return -ENOEXEC; } @@ -1479,6 +1478,40 @@ static int cmd_wifi_ps_wakeup_mode(const struct shell *sh, size_t argc, char *ar return 0; } +static int cmd_wifi_set_rts_threshold(const struct shell *sh, size_t argc, char *argv[]) +{ + struct net_if *iface = net_if_get_first_wifi(); + unsigned int rts_threshold = -1; /* Default value if user supplies "off" argument */ + int err = 0; + + context.sh = sh; + + if (strcmp(argv[1], "off") != 0) { + long rts_val = shell_strtol(argv[1], 10, &err); + + if (err) { + shell_error(sh, "Unable to parse input (err %d)", err); + return err; + } + + rts_threshold = (unsigned int)rts_val; + } + + if (net_mgmt(NET_REQUEST_WIFI_RTS_THRESHOLD, iface, + &rts_threshold, sizeof(rts_threshold))) { + shell_fprintf(sh, SHELL_WARNING, + "Setting RTS threshold failed.\n"); + return -ENOEXEC; + } + + if ((int)rts_threshold >= 0) + shell_fprintf(sh, SHELL_NORMAL, "RTS threshold: %d\n", rts_threshold); + else + shell_fprintf(sh, SHELL_NORMAL, "RTS threshold is off\n"); + + return 0; +} + void parse_mode_args_to_params(const struct shell *sh, int argc, char *argv[], struct wifi_mode_info *mode, bool *do_mode_oper) @@ -1811,15 +1844,18 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap, cmd_wifi_ap_disable, 1, 0), SHELL_CMD_ARG(enable, NULL, - "\"\"\n" - "\n" - "[PSK: valid only for secure SSIDs]\n" - "[Security type: valid only for secure SSIDs]\n" + "-s --ssid=\n" + "-c --channel=\n" + "-p --passphrase= (valid only for secure SSIDs)\n" + "-k --key-mgmt= (valid only for secure SSIDs)\n" "0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE, 4:WAPI, 5:EAP, 6:WEP, 7: WPA-PSK\n" - "[MFP (optional: needs security type to be specified)]\n" - ": 0:Disable, 1:Optional, 2:Required.\n", + "-w --ieee-80211w= (optional: needs security type to be specified)\n" + "0:Disable, 1:Optional, 2:Required\n" + "-b --band= (2 -2.6GHz, 5 - 5Ghz, 6 - 6GHz)\n" + "-m --bssid=\n" + "-h --help (prints help)", cmd_wifi_ap_enable, - 3, 3), + 2, 13), SHELL_CMD_ARG(stations, NULL, "List stations connected to the AP", cmd_wifi_ap_stations, @@ -1869,7 +1905,8 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, "[-b, --band] 0: any band (2:2.4GHz, 5:5GHz, 6:6GHz]\n" "[-p, --psk]: Passphrase (valid only for secure SSIDs)\n" "[-k, --key-mgmt]: Key Management type (valid only for secure SSIDs)\n" - "0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE, 4:WAPI, 5:EAP, 6:WEP, 7: WPA-PSK\n" + "0:None, 1:WPA2-PSK, 2:WPA2-PSK-256, 3:SAE, 4:WAPI, 5:EAP, 6:WEP," + " 7: WPA-PSK, 8: WPA-Auto-Personal\n" "[-w, --ieee-80211w]: MFP (optional: needs security type to be specified)\n" ": 0:Disable, 1:Optional, 2:Required.\n" "[-m, --bssid]: MAC address of the AP (BSSID).\n" @@ -1976,6 +2013,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, cmd_wifi_ps_wakeup_mode, 2, 0), + SHELL_CMD_ARG(rts_threshold, + NULL, + ".\n", + cmd_wifi_set_rts_threshold, + 2, + 0), SHELL_SUBCMD_SET_END ); diff --git a/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c b/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c index a33cee5aecfd..c3816e5949fb 100644 --- a/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c +++ b/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c @@ -22,10 +22,15 @@ int mqtt_client_tls_connect(struct mqtt_client *client) { const struct sockaddr *broker = client->broker; struct mqtt_sec_config *tls_config = &client->transport.tls.config; + int type = SOCK_STREAM; int ret; + if (tls_config->set_native_tls) { + type |= SOCK_NATIVE_TLS; + } + client->transport.tls.sock = zsock_socket(broker->sa_family, - SOCK_STREAM, IPPROTO_TLS_1_2); + type, IPPROTO_TLS_1_2); if (client->transport.tls.sock < 0) { return -errno; } @@ -91,6 +96,16 @@ int mqtt_client_tls_connect(struct mqtt_client *client) } } + if (tls_config->session_cache == TLS_SESSION_CACHE_ENABLED) { + ret = zsock_setsockopt(client->transport.tls.sock, SOL_TLS, + TLS_SESSION_CACHE, + &tls_config->session_cache, + sizeof(tls_config->session_cache)); + if (ret < 0) { + goto error; + } + } + if (tls_config->cert_nocopy != TLS_CERT_NOCOPY_NONE) { ret = zsock_setsockopt(client->transport.tls.sock, SOL_TLS, TLS_CERT_NOCOPY, &tls_config->cert_nocopy, diff --git a/tests/boards/nrf/i2c/i2c_slave/CMakeLists.txt b/tests/boards/nrf/i2c/i2c_slave/CMakeLists.txt new file mode 100644 index 000000000000..43130d6a07df --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(i2c_slave) + +FILE(GLOB app_sources src/*.c) + +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.conf b/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.conf new file mode 100644 index 000000000000..e79ad7a81266 --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.conf @@ -0,0 +1 @@ +CONFIG_NRFX_TWIS1=y diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.overlay b/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 000000000000..8628731faf41 --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,60 @@ +/ { + aliases { + i2c-slave = &i2c1; + }; +}; + +&pinctrl { + i2c0_default_alt: i2c0_default_alt { + group1 { + psels = , + ; + }; + }; + + i2c0_sleep_alt: i2c0_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + i2c1_default_alt: i2c1_default_alt { + group1 { +/* Temporary workaround as it is currently not possible + * to configure pins for TWIS with pinctrl. */ + psels = , + ; + bias-pull-up; + }; + }; + + i2c1_sleep_alt: i2c1_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +&i2c0 { + compatible = "nordic,nrf-twim"; + status = "okay"; + pinctrl-0 = <&i2c0_default_alt>; + pinctrl-1 = <&i2c0_sleep_alt>; + pinctrl-names = "default", "sleep"; + sensor: sensor@54 { + reg = <0x54>; + }; +}; + + +&i2c1 { + compatible = "nordic,nrf-twis"; + status = "okay"; + pinctrl-0 = <&i2c1_default_alt>; + pinctrl-1 = <&i2c1_sleep_alt>; + pinctrl-names = "default", "sleep"; +}; diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.conf b/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 000000000000..a7bedf1f04b1 --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1 @@ +CONFIG_NRFX_TWIS2=y diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.overlay b/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.overlay new file mode 100644 index 000000000000..d473a04f85c9 --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -0,0 +1,58 @@ +/ { + aliases { + i2c-slave = &i2c2; + }; +}; + +&pinctrl { + i2c1_default_alt: i2c1_default_alt { + group1 { + psels = , + ; + }; + }; + + i2c1_sleep_alt: i2c1_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + i2c2_default_alt: i2c2_default_alt { + group1 { +/* Temporary workaround as it is currently not possible + * to configure pins for TWIS with pinctrl. */ + psels = , + ; + bias-pull-up; + }; + }; + + i2c2_sleep_alt: i2c2_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +&i2c1 { + compatible = "nordic,nrf-twim"; + status = "okay"; + pinctrl-0 = <&i2c1_default_alt>; + pinctrl-1 = <&i2c1_sleep_alt>; + pinctrl-names = "default", "sleep"; + sensor: sensor@54 { + reg = <0x54>; + }; +}; + +&i2c2 { + compatible = "nordic,nrf-twis"; + pinctrl-0 = <&i2c2_default_alt>; + pinctrl-1 = <&i2c2_sleep_alt>; + pinctrl-names = "default", "sleep"; +}; diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf54h20dk_nrf54h20_cpuapp.conf b/tests/boards/nrf/i2c/i2c_slave/boards/nrf54h20dk_nrf54h20_cpuapp.conf new file mode 100644 index 000000000000..157e0a11f728 --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf54h20dk_nrf54h20_cpuapp.conf @@ -0,0 +1 @@ +CONFIG_NRFX_TWIS131=y diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/boards/nrf/i2c/i2c_slave/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..73d1d85cf453 --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,63 @@ +/ { + aliases { + i2c-slave = &i2c131; + }; +}; + +&pinctrl { + i2c130_default_alt: i2c130_default_alt { + group1 { + psels = , + ; + }; + }; + + i2c130_sleep_alt: i2c130_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + i2c131_default_alt: i2c131_default_alt { + group1 { +/* Temporary workaround as it is currently not possible + * to configure pins for TWIS with pinctrl. */ + psels = , + ; + bias-pull-up; + }; + }; + + i2c131_sleep_alt: i2c131_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +&i2c130 { + compatible = "nordic,nrf-twim"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c130_default_alt>; + pinctrl-1 = <&i2c130_sleep_alt>; + pinctrl-names = "default", "sleep"; + memory-regions = <&cpuapp_dma_region>; + sensor: sensor@54 { + reg = <0x54>; + }; +}; + +&i2c131 { + compatible = "nordic,nrf-twis"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c131_default_alt>; + pinctrl-1 = <&i2c131_sleep_alt>; + pinctrl-names = "default", "sleep"; + memory-regions = <&cpuapp_dma_region>; +}; diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.conf b/tests/boards/nrf/i2c/i2c_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.conf new file mode 100644 index 000000000000..b01af3b36a7b --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.conf @@ -0,0 +1 @@ +CONFIG_NRFX_TWIS22=y diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/tests/boards/nrf/i2c/i2c_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..d60e42659eec --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -0,0 +1,59 @@ +/ { + aliases { + i2c-slave = &i2c22; + }; +}; + +&pinctrl { + i2c21_default_alt: i2c21_default_alt { + group1 { + psels = , + ; + }; + }; + + i2c21_sleep_alt: i2c21_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + i2c22_default_alt: i2c22_default_alt { + group1 { +/* Temporary workaround as it is currently not possible + * to configure pins for TWIS with pinctrl. */ + psels = , + ; + bias-pull-up; + }; + }; + + i2c22_sleep_alt: i2c22_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +&i2c21 { + compatible = "nordic,nrf-twim"; + status = "okay"; + pinctrl-0 = <&i2c21_default_alt>; + pinctrl-1 = <&i2c21_sleep_alt>; + pinctrl-names = "default", "sleep"; + sensor: sensor@54 { + reg = <0x54>; + }; +}; + +&i2c22 { + compatible = "nordic,nrf-twis"; + status = "okay"; + pinctrl-0 = <&i2c22_default_alt>; + pinctrl-1 = <&i2c22_sleep_alt>; + pinctrl-names = "default", "sleep"; +}; diff --git a/tests/boards/nrf/i2c/i2c_slave/prj.conf b/tests/boards/nrf/i2c/i2c_slave/prj.conf new file mode 100644 index 000000000000..4b19609ecfbd --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/prj.conf @@ -0,0 +1,2 @@ +CONFIG_I2C=y +CONFIG_ZTEST=y diff --git a/tests/boards/nrf/i2c/i2c_slave/src/main.c b/tests/boards/nrf/i2c/i2c_slave/src/main.c new file mode 100644 index 000000000000..1de4b16bc2c6 --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/src/main.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#if CONFIG_NRFX_TWIS1 +#define I2C_S_INSTANCE 1 +#elif CONFIG_NRFX_TWIS2 +#define I2C_S_INSTANCE 2 +#elif CONFIG_NRFX_TWIS22 +#define I2C_S_INSTANCE 22 +#elif CONFIG_NRFX_TWIS131 +#define I2C_S_INSTANCE 131 +#else +#error "TWIS instance not enabled or not supported" +#endif + +#define NODE_SENSOR DT_NODELABEL(sensor) +#define NODE_TWIS DT_ALIAS(i2c_slave) + +#define TWIS_MEMORY_SECTION \ + COND_CODE_1(DT_NODE_HAS_PROP(NODE_TWIS, memory_regions), \ + (__attribute__((__section__( \ + LINKER_DT_NODE_REGION_NAME(DT_PHANDLE(NODE_TWIS, memory_regions)))))), \ + ()) + +#define TEST_DATA_SIZE 6 +static const uint8_t msg[TEST_DATA_SIZE] = "Nordic"; +static const nrfx_twis_t twis = NRFX_TWIS_INSTANCE(I2C_S_INSTANCE); + +static uint8_t i2c_slave_buffer[TEST_DATA_SIZE] TWIS_MEMORY_SECTION; +static uint8_t i2c_master_buffer[TEST_DATA_SIZE]; +struct i2c_api_twis_fixture { + const struct device *dev; + uint8_t addr; + uint8_t *const master_buffer; + uint8_t *const slave_buffer; +}; + +void i2s_slave_handler(nrfx_twis_evt_t const *p_event) +{ + switch (p_event->type) { + case NRFX_TWIS_EVT_READ_REQ: + nrfx_twis_tx_prepare(&twis, i2c_slave_buffer, TEST_DATA_SIZE); + TC_PRINT("TWIS event: read request\n"); + break; + case NRFX_TWIS_EVT_READ_DONE: + TC_PRINT("TWIS event: read done\n"); + break; + case NRFX_TWIS_EVT_WRITE_REQ: + nrfx_twis_rx_prepare(&twis, i2c_slave_buffer, TEST_DATA_SIZE); + TC_PRINT("TWIS event: write request\n"); + break; + case NRFX_TWIS_EVT_WRITE_DONE: + zassert_mem_equal(i2c_slave_buffer, msg, TEST_DATA_SIZE); + TC_PRINT("TWIS event: write done\n"); + break; + default: + TC_PRINT("TWIS event: %d\n", p_event->type); + break; + } +} + +static void *test_setup(void) +{ + static struct i2c_api_twis_fixture fixture = { + .dev = DEVICE_DT_GET(DT_BUS(NODE_SENSOR)), + .addr = DT_REG_ADDR(NODE_SENSOR), + .master_buffer = i2c_master_buffer, + .slave_buffer = i2c_slave_buffer, + }; + const nrfx_twis_config_t config = { + .addr = {fixture.addr, 0}, + .skip_gpio_cfg = true, + .skip_psel_cfg = true, + }; + int ret; + + zassert_equal(NRFX_SUCCESS, nrfx_twis_init(&twis, &config, i2s_slave_handler), + "TWIS initialization failed"); + + PINCTRL_DT_DEFINE(NODE_TWIS); + ret = pinctrl_apply_state(PINCTRL_DT_DEV_CONFIG_GET(NODE_TWIS), PINCTRL_STATE_DEFAULT); + zassert_ok(ret); + + IRQ_CONNECT(DT_IRQN(NODE_TWIS), DT_IRQ(NODE_TWIS, priority), + NRFX_TWIS_INST_HANDLER_GET(I2C_S_INSTANCE), NULL, 0); + + nrfx_twis_enable(&twis); + + return &fixture; +} + +static void cleanup_buffers(void *argc) +{ + struct i2c_api_twis_fixture *fixture = (struct i2c_api_twis_fixture *)argc; + + memset(fixture->slave_buffer, 0, TEST_DATA_SIZE); + memset(fixture->master_buffer, 0, TEST_DATA_SIZE); +} + +ZTEST_USER_F(i2c_api_twis, test_i2c_read_write) +{ + int ret = i2c_write_read(fixture->dev, fixture->addr, msg, TEST_DATA_SIZE, + fixture->master_buffer, TEST_DATA_SIZE); + + zassert_ok(ret); + zassert_mem_equal(fixture->master_buffer, msg, TEST_DATA_SIZE); +} + +ZTEST_USER_F(i2c_api_twis, test_i2c_read) +{ + /* Prepare slave data */ + strncpy(fixture->slave_buffer, msg, TEST_DATA_SIZE); + zassert_mem_equal(fixture->slave_buffer, msg, TEST_DATA_SIZE); + + int ret = i2c_read(fixture->dev, fixture->master_buffer, TEST_DATA_SIZE, fixture->addr); + + zassert_ok(ret); + zassert_mem_equal(fixture->master_buffer, msg, TEST_DATA_SIZE); +} + +ZTEST_USER_F(i2c_api_twis, test_i2c_write) +{ + int ret = i2c_write(fixture->dev, msg, TEST_DATA_SIZE, fixture->addr); + + zassert_ok(ret); + zassert_mem_equal(fixture->slave_buffer, msg, TEST_DATA_SIZE); +} + +ZTEST_SUITE(i2c_api_twis, NULL, test_setup, NULL, cleanup_buffers, NULL); diff --git a/tests/boards/nrf/i2c/i2c_slave/testcase.yaml b/tests/boards/nrf/i2c/i2c_slave/testcase.yaml new file mode 100644 index 000000000000..1309b60146ec --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/testcase.yaml @@ -0,0 +1,12 @@ +tests: + boards.nrf.i2c.i2c_slave: + depends_on: i2c + tags: drivers i2c + harness: ztest + harness_config: + fixture: i2c_loopback + platform_allow: nrf52840dk/nrf52840 nrf5340dk/nrf5340/cpuapp nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf52840dk/nrf52840 + - nrf5340dk/nrf5340/cpuapp + - nrf54l15pdk/nrf54l15/cpuapp diff --git a/tests/boot/mcuboot_recovery_retention/sysbuild.conf b/tests/boot/mcuboot_recovery_retention/sysbuild.conf index 47f00ff3cff8..3b5b3c963800 100644 --- a/tests/boot/mcuboot_recovery_retention/sysbuild.conf +++ b/tests/boot/mcuboot_recovery_retention/sysbuild.conf @@ -1 +1,2 @@ SB_CONFIG_BOOTLOADER_MCUBOOT=y +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/boot/test_mcuboot/sysbuild.conf b/tests/boot/test_mcuboot/sysbuild.conf index 47f00ff3cff8..3b5b3c963800 100644 --- a/tests/boot/test_mcuboot/sysbuild.conf +++ b/tests/boot/test_mcuboot/sysbuild.conf @@ -1 +1,2 @@ SB_CONFIG_BOOTLOADER_MCUBOOT=y +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/bsim/bluetooth/ll/cis/sysbuild/hci_ipc/nrf5340_cpunet_iso_acl_group-bt_ll_sw_split.conf b/tests/bsim/bluetooth/ll/cis/sysbuild/hci_ipc/nrf5340_cpunet_iso_acl_group-bt_ll_sw_split.conf index a3c8f43c71f7..4a53b153a5cc 100644 --- a/tests/bsim/bluetooth/ll/cis/sysbuild/hci_ipc/nrf5340_cpunet_iso_acl_group-bt_ll_sw_split.conf +++ b/tests/bsim/bluetooth/ll/cis/sysbuild/hci_ipc/nrf5340_cpunet_iso_acl_group-bt_ll_sw_split.conf @@ -25,12 +25,6 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Tx/Rx Thread Stack Sizes -CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y -CONFIG_BT_HCI_TX_STACK_SIZE=1152 -CONFIG_BT_RX_STACK_SIZE=640 -CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=448 - # Host features CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y diff --git a/tests/cmake/overlays/soc_folder_kconfig/CMakeLists.txt b/tests/cmake/overlays/soc_folder_kconfig/CMakeLists.txt new file mode 100644 index 000000000000..db78c7333ef1 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(overlays_soc_folder_kconfig) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/cmake/overlays/soc_folder_kconfig/Kconfig b/tests/cmake/overlays/soc_folder_kconfig/Kconfig new file mode 100644 index 000000000000..fcc64e50e5cd --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/Kconfig @@ -0,0 +1,32 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config SOC_FOLDER_TEST_STRING + string "Test string" + default "one" + +config SOC_FOLDER_TEST_INCLUDE_BOARD + bool "Included board Kconfig fragment" + +config SOC_FOLDER_TEST_INCLUDE_BOARD_SUFFIX + bool "Included board Kconfig fragment with suffix" + +config SOC_FOLDER_TEST_INCLUDE_BOARD_QUALIFIERS + bool "Included board with qualifiers Kconfig fragment" + +config SOC_FOLDER_TEST_INCLUDE_BOARD_OTHER + bool "Included other board Kconfig fragment" + +config SOC_FOLDER_TEST_INCLUDE_SOC + bool "Included soc Kconfig fragment" + +config SOC_FOLDER_TEST_INCLUDE_SOC_SUFFIX + bool "Included soc overlay Kconfig fragment" + +config SOC_FOLDER_TEST_INCLUDE_SOC_OTHER + bool "Included other soc overlay Kconfig fragment" + +config TEST_TYPE + int "Test type" + +source "Kconfig.zephyr" diff --git a/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native.conf b/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native.conf new file mode 100644 index 000000000000..4e5465df6982 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD=y +CONFIG_SOC_FOLDER_TEST_STRING="two" diff --git a/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_64.conf b/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_64.conf new file mode 100644 index 000000000000..f14979567c00 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_64.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_QUALIFIERS=y +CONFIG_SOC_FOLDER_TEST_STRING="five" diff --git a/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_64_somesuffix.conf b/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_64_somesuffix.conf new file mode 100644 index 000000000000..c77f9d10a7ee --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_64_somesuffix.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_SUFFIX=y +CONFIG_SOC_FOLDER_TEST_STRING="four" diff --git a/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_somesuffix.conf b/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_somesuffix.conf new file mode 100644 index 000000000000..c77f9d10a7ee --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/boards/native_sim_native_somesuffix.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_SUFFIX=y +CONFIG_SOC_FOLDER_TEST_STRING="four" diff --git a/tests/cmake/overlays/soc_folder_kconfig/boards/other.conf b/tests/cmake/overlays/soc_folder_kconfig/boards/other.conf new file mode 100644 index 000000000000..4a8bc05df976 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/boards/other.conf @@ -0,0 +1,3 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_OTHER=y +CONFIG_SOC_FOLDER_TEST_STRING="three" +CONFIG_ZTEST=y diff --git a/tests/cmake/overlays/soc_folder_kconfig/prj.conf b/tests/cmake/overlays/soc_folder_kconfig/prj.conf new file mode 100644 index 000000000000..9467c2926896 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/prj.conf @@ -0,0 +1 @@ +CONFIG_ZTEST=y diff --git a/tests/cmake/overlays/soc_folder_kconfig/socs/native.conf b/tests/cmake/overlays/soc_folder_kconfig/socs/native.conf new file mode 100644 index 000000000000..ad2c3bb4ab6f --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/socs/native.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC=y +CONFIG_SOC_FOLDER_TEST_STRING="seven" diff --git a/tests/cmake/overlays/soc_folder_kconfig/socs/native_64.conf b/tests/cmake/overlays/soc_folder_kconfig/socs/native_64.conf new file mode 100644 index 000000000000..5b99d60a0cc7 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/socs/native_64.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC=y +CONFIG_SOC_FOLDER_TEST_STRING="six" diff --git a/tests/cmake/overlays/soc_folder_kconfig/socs/native_64_somesuffix.conf b/tests/cmake/overlays/soc_folder_kconfig/socs/native_64_somesuffix.conf new file mode 100644 index 000000000000..3eac9628cecb --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/socs/native_64_somesuffix.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC_SUFFIX=y +CONFIG_SOC_FOLDER_TEST_STRING="eight" diff --git a/tests/cmake/overlays/soc_folder_kconfig/socs/native_somesuffix.conf b/tests/cmake/overlays/soc_folder_kconfig/socs/native_somesuffix.conf new file mode 100644 index 000000000000..3eac9628cecb --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/socs/native_somesuffix.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC_SUFFIX=y +CONFIG_SOC_FOLDER_TEST_STRING="eight" diff --git a/tests/cmake/overlays/soc_folder_kconfig/socs/other.conf b/tests/cmake/overlays/soc_folder_kconfig/socs/other.conf new file mode 100644 index 000000000000..aff49c6a9751 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/socs/other.conf @@ -0,0 +1,2 @@ +CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC_OTHER=y +CONFIG_SOC_FOLDER_TEST_STRING="nine" diff --git a/tests/cmake/overlays/soc_folder_kconfig/src/main.c b/tests/cmake/overlays/soc_folder_kconfig/src/main.c new file mode 100644 index 000000000000..2a3c69c02b51 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/src/main.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#ifdef CONFIG_SOC_FOLDER_TEST_STRING +#define STRING_OUTPUT CONFIG_SOC_FOLDER_TEST_STRING +#else +#error "Invalid test configuration" +#endif + +#ifndef CONFIG_TEST_TYPE +#error "Invalid test configuration" +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD +#define INCLUDED_BOARD 1 +#else +#define INCLUDED_BOARD 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_SUFFIX +#define INCLUDED_BOARD_SUFFIX 1 +#else +#define INCLUDED_BOARD_SUFFIX 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_QUALIFIERS +#define INCLUDED_BOARD_QUALIFIERS 1 +#else +#define INCLUDED_BOARD_QUALIFIERS 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_OTHER +#define INCLUDED_BOARD_OTHER 1 +#else +#define INCLUDED_BOARD_OTHER 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC +#define INCLUDED_SOC 1 +#else +#define INCLUDED_SOC 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC_SUFFIX +#define INCLUDED_SOC_SUFFIX 1 +#else +#define INCLUDED_SOC_SUFFIX 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC_OTHER +#define INCLUDED_SOC_OTHER 1 +#else +#define INCLUDED_SOC_OTHER 0 +#endif + +#if CONFIG_TEST_TYPE == 0 +/* Default test */ +ZTEST(soc_folder_kconfig, test_default) +{ + zassert_false(INCLUDED_BOARD_SUFFIX, "Did not expect board suffix config to be present"); + +#ifdef CONFIG_BOARD_NATIVE_SIM_NATIVE_64 + zassert_false(INCLUDED_BOARD, "Did not expect board config to be present"); + zassert_true(INCLUDED_BOARD_QUALIFIERS, "Expected board qualifier config to be present"); + zassert_mem_equal(STRING_OUTPUT, "five", strlen("five"), "Expected string to match"); +#else + zassert_true(INCLUDED_BOARD, "Expected board config to be present"); + zassert_false(INCLUDED_BOARD_QUALIFIERS, + "Did not expect board qualifier config to be present"); + zassert_mem_equal(STRING_OUTPUT, "two", strlen("two"), "Expected string to match"); +#endif + + zassert_false(INCLUDED_BOARD_OTHER, "Did not expect board other config to be present"); + zassert_true(INCLUDED_SOC, "Expect soc config to be present"); + zassert_false(INCLUDED_SOC_SUFFIX, "Did not expect soc suffix config to be present"); + zassert_false(INCLUDED_SOC_OTHER, "Did not expect soc other config to be present"); +} +#elif CONFIG_TEST_TYPE == 1 +/* File suffix test */ +ZTEST(soc_folder_kconfig, test_suffix) +{ + zassert_true(INCLUDED_BOARD_SUFFIX, "Expected board suffix config to be present"); + + zassert_false(INCLUDED_BOARD, "Did not expect board config to be present"); + zassert_false(INCLUDED_BOARD_QUALIFIERS, + "Did not expect board qualifier config to be present"); + zassert_mem_equal(STRING_OUTPUT, "four", strlen("four"), "Expected string to match"); + zassert_false(INCLUDED_BOARD_OTHER, "Did not expect board other config to be present"); + zassert_false(INCLUDED_SOC, "Did not expect soc config to be present"); + zassert_true(INCLUDED_SOC_SUFFIX, "Expected soc suffix config to be present"); + zassert_false(INCLUDED_SOC_OTHER, "Did not expect soc other config to be present"); +} +#elif CONFIG_TEST_TYPE == 2 +/* Conf file test */ +ZTEST(soc_folder_kconfig, test_conf) +{ + zassert_false(INCLUDED_BOARD_SUFFIX, "Did not expect board suffix config to be present"); + +#ifdef CONFIG_BOARD_NATIVE_SIM_NATIVE_64 + zassert_false(INCLUDED_BOARD, "Did not expect board config to be present"); + zassert_true(INCLUDED_BOARD_QUALIFIERS, + "Expected board qualifier config to be present"); +#else + zassert_true(INCLUDED_BOARD, "Expected board config to be present"); + zassert_false(INCLUDED_BOARD_QUALIFIERS, + "Did not expect board qualifier config to be present"); +#endif + + zassert_mem_equal(STRING_OUTPUT, "three", strlen("three"), "Expected string to match"); + + zassert_true(INCLUDED_BOARD_OTHER, "Expected board other config to be present"); + zassert_true(INCLUDED_SOC, "Expected soc config to be present"); + zassert_false(INCLUDED_SOC_SUFFIX, "Did not expect soc suffix config to be present"); + zassert_false(INCLUDED_SOC_OTHER, "Did not expect soc other config to be present"); +} +#elif CONFIG_TEST_TYPE == 3 +/* File suffix and conf file test */ +ZTEST(soc_folder_kconfig, test_suffix_conf) +{ + zassert_true(INCLUDED_BOARD_SUFFIX, "Expected board suffix config to be present"); + zassert_false(INCLUDED_BOARD, "Did not expect board config to be present"); + zassert_false(INCLUDED_BOARD_QUALIFIERS, + "Did not expect board qualifier config to be present"); + zassert_mem_equal(STRING_OUTPUT, "three", strlen("three"), "Expected string to match"); + zassert_true(INCLUDED_BOARD_OTHER, "Expected board other config to be present"); + zassert_false(INCLUDED_SOC, "Did not expect soc config to be present"); + zassert_true(INCLUDED_SOC_SUFFIX, "Expected soc suffix config to be present"); + zassert_false(INCLUDED_SOC_OTHER, "Did not expect soc other config to be present"); +} +#else +#error "Invalid test type" +#endif + +ZTEST_SUITE(soc_folder_kconfig, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/cmake/overlays/soc_folder_kconfig/testcase.yaml b/tests/cmake/overlays/soc_folder_kconfig/testcase.yaml new file mode 100644 index 000000000000..32b8e5487b3b --- /dev/null +++ b/tests/cmake/overlays/soc_folder_kconfig/testcase.yaml @@ -0,0 +1,26 @@ +common: + tags: + - cmake + platform_allow: + - native_sim + - native_sim/native/64 + integration_platforms: + - native_sim + - native_sim/native/64 +tests: + cmake.overlays.soc_folder_kconfig.default: + extra_args: + - CONFIG_TEST_TYPE=0 + cmake.overlays.soc_folder_kconfig.suffix: + extra_args: + - CONFIG_TEST_TYPE=1 + - FILE_SUFFIX=somesuffix + cmake.overlays.soc_folder_kconfig.conf: + extra_args: + - CONFIG_TEST_TYPE=2 + - EXTRA_CONF_FILE=boards/other.conf + cmake.overlays.soc_folder_kconfig.suffix.conf: + extra_args: + - CONFIG_TEST_TYPE=3 + - FILE_SUFFIX=somesuffix + - EXTRA_CONF_FILE=boards/other.conf diff --git a/tests/cmake/overlays/soc_folder_overlay/CMakeLists.txt b/tests/cmake/overlays/soc_folder_overlay/CMakeLists.txt new file mode 100644 index 000000000000..dbd1fab670dc --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(overlays_soc_folder_overlay) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/cmake/overlays/soc_folder_overlay/Kconfig b/tests/cmake/overlays/soc_folder_overlay/Kconfig new file mode 100644 index 000000000000..a49375710f30 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/Kconfig @@ -0,0 +1,31 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config SOC_FOLDER_TEST_INCLUDE_APP + bool + default "$(dt_alias_enabled,test-app)" + +config SOC_FOLDER_TEST_INCLUDE_BOARD + bool + default "$(dt_alias_enabled,test-board)" + +config SOC_FOLDER_TEST_INCLUDE_BOARD_SUFFIX + bool + default "$(dt_alias_enabled,test-board-suffix)" + +config SOC_FOLDER_TEST_INCLUDE_BOARD_QUALIFIERS + bool + default "$(dt_alias_enabled,test-board-qualifiers)" + +config SOC_FOLDER_TEST_INCLUDE_SOC + bool + default "$(dt_alias_enabled,test-soc)" + +config SOC_FOLDER_TEST_INCLUDE_SOC_SUFFIX + bool + default "$(dt_alias_enabled,test-soc-suffix)" + +config TEST_TYPE + int "Test type" + +source "Kconfig.zephyr" diff --git a/tests/cmake/overlays/soc_folder_overlay/app.overlay b/tests/cmake/overlays/soc_folder_overlay/app.overlay new file mode 100644 index 000000000000..ad861b3e4629 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/app.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-app = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native.overlay b/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native.overlay new file mode 100644 index 000000000000..126168af1152 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-board = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_64.overlay b/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_64.overlay new file mode 100644 index 000000000000..5db22cfdfc4d --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_64.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-board-qualifiers = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_64_somesuffix.overlay b/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_64_somesuffix.overlay new file mode 100644 index 000000000000..79d904a717e9 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_64_somesuffix.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-board-suffix = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_somesuffix.overlay b/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_somesuffix.overlay new file mode 100644 index 000000000000..79d904a717e9 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/boards/native_sim_native_somesuffix.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-board-suffix = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/prj.conf b/tests/cmake/overlays/soc_folder_overlay/prj.conf new file mode 100644 index 000000000000..9467c2926896 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/prj.conf @@ -0,0 +1 @@ +CONFIG_ZTEST=y diff --git a/tests/cmake/overlays/soc_folder_overlay/socs/native.overlay b/tests/cmake/overlays/soc_folder_overlay/socs/native.overlay new file mode 100644 index 000000000000..240f4f97800d --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/socs/native.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-soc = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/socs/native_64.overlay b/tests/cmake/overlays/soc_folder_overlay/socs/native_64.overlay new file mode 100644 index 000000000000..240f4f97800d --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/socs/native_64.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-soc = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/socs/native_64_somesuffix.overlay b/tests/cmake/overlays/soc_folder_overlay/socs/native_64_somesuffix.overlay new file mode 100644 index 000000000000..be46f6867508 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/socs/native_64_somesuffix.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-soc-suffix = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/socs/native_somesuffix.overlay b/tests/cmake/overlays/soc_folder_overlay/socs/native_somesuffix.overlay new file mode 100644 index 000000000000..be46f6867508 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/socs/native_somesuffix.overlay @@ -0,0 +1,5 @@ +/ { + aliases { + test-soc-suffix = &uart0; + }; +}; diff --git a/tests/cmake/overlays/soc_folder_overlay/src/main.c b/tests/cmake/overlays/soc_folder_overlay/src/main.c new file mode 100644 index 000000000000..b4e1f22b6ae3 --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/src/main.c @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#ifndef CONFIG_TEST_TYPE +#error "Invalid test configuration" +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_APP +#define INCLUDED_APP 1 +#else +#define INCLUDED_APP 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD +#define INCLUDED_BOARD 1 +#else +#define INCLUDED_BOARD 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_SUFFIX +#define INCLUDED_BOARD_SUFFIX 1 +#else +#define INCLUDED_BOARD_SUFFIX 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_BOARD_QUALIFIERS +#define INCLUDED_BOARD_QUALIFIERS 1 +#else +#define INCLUDED_BOARD_QUALIFIERS 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC +#define INCLUDED_SOC 1 +#else +#define INCLUDED_SOC 0 +#endif + +#ifdef CONFIG_SOC_FOLDER_TEST_INCLUDE_SOC_SUFFIX +#define INCLUDED_SOC_SUFFIX 1 +#else +#define INCLUDED_SOC_SUFFIX 0 +#endif + +#if CONFIG_TEST_TYPE == 0 +/* Default test */ +ZTEST(soc_folder_overlay, test_default) +{ + zassert_false(INCLUDED_APP, "Did not expect app overlay to be present"); + zassert_false(INCLUDED_BOARD_SUFFIX, "Did not expect board suffix overlay to be present"); + +#ifdef CONFIG_BOARD_NATIVE_SIM_NATIVE_64 + zassert_false(INCLUDED_BOARD, "Did not expect board overlay to be present"); + zassert_true(INCLUDED_BOARD_QUALIFIERS, "Expected board qualifier overlay to be present"); +#else + zassert_true(INCLUDED_BOARD, "Expected board overlay to be present"); + zassert_false(INCLUDED_BOARD_QUALIFIERS, + "Did not expect board qualifier overlay to be present"); +#endif + + zassert_true(INCLUDED_SOC, "Expect soc overlay to be present"); + zassert_false(INCLUDED_SOC_SUFFIX, "Did not expect soc suffix overlay to be present"); +} +#elif CONFIG_TEST_TYPE == 1 +/* File suffix test */ +ZTEST(soc_folder_overlay, test_suffix) +{ + zassert_false(INCLUDED_APP, "Did not expect app overlay to be present"); + zassert_true(INCLUDED_BOARD_SUFFIX, "Expected board suffix overlay to be present"); + zassert_false(INCLUDED_BOARD, "Did not expect board overlay to be present"); + zassert_false(INCLUDED_BOARD_QUALIFIERS, + "Did not expect board qualifier overlay to be present"); + zassert_false(INCLUDED_SOC, "Did not expect soc overlay to be present"); + zassert_true(INCLUDED_SOC_SUFFIX, "Expected soc suffix overlay to be present"); +} +#elif CONFIG_TEST_TYPE == 2 +/* App overlay test */ +ZTEST(soc_folder_overlay, test_app) +{ + zassert_true(INCLUDED_APP, "Expected app overlay to be present"); + zassert_false(INCLUDED_BOARD_SUFFIX, "Did not expect board suffix overlay to be present"); + zassert_false(INCLUDED_BOARD, "Did not expect board overlay to be present"); + zassert_false(INCLUDED_BOARD_QUALIFIERS, + "Did not expect board qualifier overlay to be present"); + zassert_false(INCLUDED_SOC, "Did not expect soc overlay to be present"); + zassert_false(INCLUDED_SOC_SUFFIX, "Did not epect soc suffix overlay to be present"); +} +#else +#error "Invalid test type" +#endif + +ZTEST_SUITE(soc_folder_overlay, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/cmake/overlays/soc_folder_overlay/testcase.yaml b/tests/cmake/overlays/soc_folder_overlay/testcase.yaml new file mode 100644 index 000000000000..659560cf836e --- /dev/null +++ b/tests/cmake/overlays/soc_folder_overlay/testcase.yaml @@ -0,0 +1,30 @@ +common: + tags: + - cmake +tests: + cmake.overlays.soc_folder_overlay.default: + platform_allow: + - native_sim + - native_sim/native/64 + integration_platforms: + - native_sim + - native_sim/native/64 + extra_args: + - CONFIG_TEST_TYPE=0 + cmake.overlays.soc_folder_overlay.suffix: + platform_allow: + - native_sim + - native_sim/native/64 + integration_platforms: + - native_sim + - native_sim/native/64 + extra_args: + - CONFIG_TEST_TYPE=1 + - FILE_SUFFIX=somesuffix + cmake.overlays.soc_folder_overlay.app: + platform_allow: + - qemu_cortex_m3 + integration_platforms: + - qemu_cortex_m3 + extra_args: + - CONFIG_TEST_TYPE=2 diff --git a/tests/drivers/adc/adc_api/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/tests/drivers/adc/adc_api/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..e10ddc543282 --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -0,0 +1,34 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2024 Nordic Semiconductor ASA + */ + +/ { + zephyr,user { + io-channels = <&adc 0>, <&adc 2>; + }; +}; + +&adc { + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <10>; + }; + + channel@2 { + reg = <2>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <10>; + }; +}; diff --git a/tests/drivers/build_all/regulator/testcase.yaml b/tests/drivers/build_all/regulator/testcase.yaml index 58fc0851981d..8214a2ca33a6 100644 --- a/tests/drivers/build_all/regulator/testcase.yaml +++ b/tests/drivers/build_all/regulator/testcase.yaml @@ -3,9 +3,7 @@ tests: drivers.regulator.build: - tags: - - drivers - - regulator + tags: drivers regulator build_only: true platform_allow: - native_posix diff --git a/tests/drivers/clock_control/clock_control_api/testcase.yaml b/tests/drivers/clock_control/clock_control_api/testcase.yaml index 7a3552fd4e7d..356893f400f8 100644 --- a/tests/drivers/clock_control/clock_control_api/testcase.yaml +++ b/tests/drivers/clock_control/clock_control_api/testcase.yaml @@ -8,6 +8,7 @@ tests: - nrf52dk/nrf52832 - nrf52840dk/nrf52840 - nrf9160dk/nrf9160 + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 drivers.clock.clock_control_nrf5_lfclk_rc: @@ -18,6 +19,7 @@ tests: - nrf51dk/nrf51822 - nrf52dk/nrf52832 - nrf52840dk/nrf52840 + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 extra_args: CONF_FILE="nrf_lfclk_rc.conf" diff --git a/tests/drivers/clock_control/nrf_clock_calibration/testcase.yaml b/tests/drivers/clock_control/nrf_clock_calibration/testcase.yaml index 2e2934b33eac..e5f1248f5ec5 100644 --- a/tests/drivers/clock_control/nrf_clock_calibration/testcase.yaml +++ b/tests/drivers/clock_control/nrf_clock_calibration/testcase.yaml @@ -7,5 +7,6 @@ tests: - nrf51dk/nrf51822 - nrf52dk/nrf52832 - nrf52840dk/nrf52840 + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 diff --git a/tests/drivers/clock_control/nrf_lf_clock_start/testcase.yaml b/tests/drivers/clock_control/nrf_lf_clock_start/testcase.yaml index a5716326ab9b..c35d4529722a 100644 --- a/tests/drivers/clock_control/nrf_lf_clock_start/testcase.yaml +++ b/tests/drivers/clock_control/nrf_lf_clock_start/testcase.yaml @@ -13,6 +13,7 @@ tests: - nrf9160dk/nrf9160 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp extra_configs: - CONFIG_SYSTEM_CLOCK_WAIT_FOR_STABILITY=y - CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y @@ -27,6 +28,7 @@ tests: - nrf9160dk/nrf9160 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp extra_configs: - CONFIG_SYSTEM_CLOCK_WAIT_FOR_AVAILABILITY=y - CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y @@ -41,6 +43,7 @@ tests: - nrf9160dk/nrf9160 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 extra_configs: @@ -54,6 +57,7 @@ tests: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 extra_configs: @@ -67,6 +71,7 @@ tests: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 extra_configs: @@ -80,6 +85,7 @@ tests: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 extra_configs: @@ -93,6 +99,7 @@ tests: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 extra_configs: @@ -106,6 +113,7 @@ tests: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 extra_configs: @@ -119,6 +127,7 @@ tests: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp - nrf5340dk/nrf5340/cpunet + - nrf54l15pdk/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 extra_configs: diff --git a/tests/drivers/clock_control/onoff/testcase.yaml b/tests/drivers/clock_control/onoff/testcase.yaml index 91239e3b5382..867ae2dce402 100644 --- a/tests/drivers/clock_control/onoff/testcase.yaml +++ b/tests/drivers/clock_control/onoff/testcase.yaml @@ -7,6 +7,7 @@ tests: - nrf51dk/nrf51822 - nrf52dk/nrf52832 - nrf52840dk/nrf52840 + - nrf54l15pdk/nrf54l15/cpuapp - nrf9160dk/nrf9160 integration_platforms: - nrf51dk/nrf51822 diff --git a/tests/drivers/counter/counter_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/counter/counter_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..8cabf100ae27 --- /dev/null +++ b/tests/drivers/counter/counter_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,58 @@ +&timer120 { + status = "okay"; + prescaler = <7>; +}; + +&timer121 { + status = "okay"; + prescaler = <7>; +}; + +&timer130 { + status = "okay"; + prescaler = <4>; +}; + +&timer131 { + status = "okay"; + prescaler = <4>; +}; + +&timer132 { + status = "okay"; + prescaler = <4>; +}; + +&timer133 { + status = "okay"; + prescaler = <4>; +}; + +&timer134 { + status = "okay"; + prescaler = <4>; +}; + +&timer135 { + status = "okay"; + prescaler = <4>; +}; + +&timer136 { + status = "okay"; + prescaler = <4>; +}; + +&timer137 { + status = "okay"; + prescaler = <4>; +}; + +&rtc130 { + status = "okay"; + ppi-wrap; +}; + +&rtc131 { + status = "okay"; +}; diff --git a/tests/drivers/counter/counter_basic_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/drivers/counter/counter_basic_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay new file mode 100644 index 000000000000..7cacbc5d7ec8 --- /dev/null +++ b/tests/drivers/counter/counter_basic_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -0,0 +1,77 @@ +&timer020 { + status = "okay"; + prescaler = <7>; +}; + +&timer021 { + status = "okay"; + prescaler = <7>; +}; + +&timer022 { + status = "okay"; + prescaler = <7>; +}; + +&timer120 { + status = "okay"; + prescaler = <7>; +}; + +&timer121 { + status = "okay"; + prescaler = <7>; +}; + +&timer130 { + status = "okay"; + prescaler = <4>; +}; + +&timer131 { + status = "okay"; + prescaler = <4>; +}; + +&timer132 { + status = "okay"; + prescaler = <4>; +}; + +&timer133 { + status = "okay"; + prescaler = <4>; +}; + +&timer134 { + status = "okay"; + prescaler = <4>; +}; + +&timer135 { + status = "okay"; + prescaler = <4>; +}; + +&timer136 { + status = "okay"; + prescaler = <4>; +}; + +&timer137 { + status = "okay"; + prescaler = <4>; +}; + +&rtc130 { + status = "okay"; + ppi-wrap; +}; + +&rtc131 { + status = "okay"; +}; + +&rtc { + status = "okay"; +}; diff --git a/tests/drivers/gpio/gpio_nrf/CMakeLists.txt b/tests/drivers/gpio/gpio_nrf/CMakeLists.txt new file mode 100644 index 000000000000..2af607d11645 --- /dev/null +++ b/tests/drivers/gpio/gpio_nrf/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(gpio_nrf_specific) + +target_sources(app PRIVATE + src/main.c + ) diff --git a/tests/drivers/gpio/gpio_nrf/README.txt b/tests/drivers/gpio/gpio_nrf/README.txt new file mode 100644 index 000000000000..6a5927b725f0 --- /dev/null +++ b/tests/drivers/gpio/gpio_nrf/README.txt @@ -0,0 +1,4 @@ +Nordic Semiconductor specific GPIO functions +############################################ +The suite specified here tests NRF specific +GPIO pin drive strength settings. diff --git a/tests/drivers/gpio/gpio_nrf/prj.conf b/tests/drivers/gpio/gpio_nrf/prj.conf new file mode 100644 index 000000000000..0e799280f514 --- /dev/null +++ b/tests/drivers/gpio/gpio_nrf/prj.conf @@ -0,0 +1,2 @@ +CONFIG_ZTEST=y +CONFIG_GPIO=y diff --git a/tests/drivers/gpio/gpio_nrf/src/main.c b/tests/drivers/gpio/gpio_nrf/src/main.c new file mode 100644 index 000000000000..8627e9bab1d9 --- /dev/null +++ b/tests/drivers/gpio/gpio_nrf/src/main.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) +#define TEST_NODE DT_GPIO_CTLR(DT_ALIAS(led0), gpios) +#define TEST_PIN DT_GPIO_PIN(DT_ALIAS(led0), gpios) +#else +#error Unsupported board +#endif + +/* + * Nordic Semiconductor specific pin drive configurations + */ +ZTEST(gpio_nrf, test_gpio_high_drive_strength) +{ + int err; + const struct device *port; + + port = DEVICE_DT_GET(TEST_NODE); + zassert_true(device_is_ready(port), "GPIO dev is not ready"); + + err = gpio_pin_configure(port, TEST_PIN, GPIO_PUSH_PULL | NRF_GPIO_DRIVE_S0H1); + zassert_equal( + err, 0, + "Failed to configure the pin as an P-P output with drive: NRF_GPIO_DRIVE_S0H1, err=%d", + err); + + err = gpio_pin_configure(port, TEST_PIN, GPIO_PUSH_PULL | NRF_GPIO_DRIVE_H0S1); + zassert_equal( + err, 0, + "Failed to configure the pin as an P-P output with drive: NRF_GPIO_DRIVE_H0S1, err=%d", + err); + + err = gpio_pin_configure(port, TEST_PIN, GPIO_PUSH_PULL | NRF_GPIO_DRIVE_H0H1); + zassert_equal( + err, 0, + "Failed to configure the pin as an P-P output with drive: NRF_GPIO_DRIVE_H0H1, err=%d", + err); + + err = gpio_pin_configure(port, TEST_PIN, GPIO_OPEN_DRAIN | NRF_GPIO_DRIVE_H0S1); + zassert_equal( + err, 0, + "Failed to configure the pin as an O-D output with drive: NRF_GPIO_DRIVE_H0S1, err=%d", + err); + + err = gpio_pin_configure(port, TEST_PIN, GPIO_OPEN_SOURCE | NRF_GPIO_DRIVE_S0H1); + zassert_equal( + err, 0, + "Failed to configure the pin as an O-S output with drive: NRF_GPIO_DRIVE_S0H1, err=%d", + err); +} + +ZTEST_SUITE(gpio_nrf, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/drivers/gpio/gpio_nrf/testcase.yaml b/tests/drivers/gpio/gpio_nrf/testcase.yaml new file mode 100644 index 000000000000..9c911ac378fe --- /dev/null +++ b/tests/drivers/gpio/gpio_nrf/testcase.yaml @@ -0,0 +1,7 @@ +common: + tags: drivers gpio + depends_on: gpio + harness: ztest +tests: + drivers.gpio.gpio_nrf: + filter: dt_compat_enabled("nordic,nrf-gpio") and dt_nodelabel_enabled("led0") diff --git a/tests/drivers/i2s/i2s_api/src/main.c b/tests/drivers/i2s/i2s_api/src/main.c index 82a4dba5f9cc..febb721932dc 100644 --- a/tests/drivers/i2s/i2s_api/src/main.c +++ b/tests/drivers/i2s/i2s_api/src/main.c @@ -78,3 +78,4 @@ ZTEST_SUITE(i2s_loopback, NULL, setup, before, NULL, NULL); ZTEST_SUITE(i2s_states, NULL, setup, before, NULL, NULL); ZTEST_SUITE(i2s_dir_both_states, NULL, setup, before_dir_both, NULL, NULL); ZTEST_SUITE(i2s_dir_both_loopback, NULL, setup, before_dir_both, NULL, NULL); +ZTEST_SUITE(i2s_errors, NULL, setup, before, NULL, NULL); diff --git a/tests/drivers/i2s/i2s_api/src/test_i2s_errors.c b/tests/drivers/i2s/i2s_api/src/test_i2s_errors.c new file mode 100644 index 000000000000..477292d84c26 --- /dev/null +++ b/tests/drivers/i2s/i2s_api/src/test_i2s_errors.c @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include "i2s_api_test.h" + +#define INVALID_TRIGGER_SETTING 7 + +ZTEST_USER(i2s_errors, test_i2s_improper_configuration) +{ + int err; + struct i2s_config invalid_config = { .word_size = 16U, + .channels = 2U, + .format = I2S_FMT_DATA_FORMAT_I2S, + .frame_clk_freq = FRAME_CLK_FREQ, + .block_size = BLOCK_SIZE, + .timeout = TIMEOUT, + .options = I2S_OPT_FRAME_CLK_MASTER | + I2S_OPT_BIT_CLK_MASTER, + .mem_slab = &tx_mem_slab }; + + + invalid_config.format = + I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED | I2S_FMT_DATA_FORMAT_RIGHT_JUSTIFIED; + + err = i2s_configure(dev_i2s, I2S_DIR_TX, &invalid_config); + zassert_not_equal( + err, 0, + "I2S configuration did not detect improper data format (I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED | I2S_FMT_DATA_FORMAT_RIGHT_JUSTIFIED)"); + + invalid_config.format = I2S_FMT_DATA_FORMAT_I2S | I2S_FMT_DATA_ORDER_LSB; + + err = i2s_configure(dev_i2s, I2S_DIR_TX, &invalid_config); + zassert_not_equal( + err, 0, + "I2S configuration did not detect improper stream format (I2S_FMT_DATA_ORDER_LSB)"); + + invalid_config.format = I2S_FMT_DATA_FORMAT_I2S; + invalid_config.channels = 3U; + err = i2s_configure(dev_i2s, I2S_DIR_TX, &invalid_config); + zassert_not_equal(err, 0, + "I2S configuration did not detect improper channels configuration (3)"); +} + +ZTEST_USER(i2s_errors, test_i2s_config_attempt_in_wrong_state) +{ + int err; + int config_err; + char tx_data[BLOCK_SIZE] = {0}; + struct i2s_config inactive_config = { .word_size = 16U, + .channels = 2U, + .format = I2S_FMT_DATA_FORMAT_I2S, + .frame_clk_freq = FRAME_CLK_FREQ, + .block_size = BLOCK_SIZE, + .timeout = TIMEOUT, + .options = I2S_OPT_FRAME_CLK_MASTER | + I2S_OPT_BIT_CLK_MASTER, + .mem_slab = &tx_mem_slab }; + + err = i2s_configure(dev_i2s, I2S_DIR_TX, &inactive_config); + zassert_equal(err, 0, "I2S interface configuration failed, err=%d", err); + + err = i2s_buf_write(dev_i2s, tx_data, BLOCK_SIZE); + zassert_equal(err, 0, "I2S buffer write unexpected error: %d", err); + + err = i2s_trigger(dev_i2s, I2S_DIR_TX, I2S_TRIGGER_START); + zassert_equal(err, 0, "I2S_TRIGGER_START unexpected error: %d", err); + + config_err = i2s_configure(dev_i2s, I2S_DIR_TX, &inactive_config); + + err = i2s_trigger(dev_i2s, I2S_DIR_TX, I2S_TRIGGER_STOP); + zassert_equal(err, 0, "I2S_TRIGGER_STOP unexpected error: %d", err); + + zassert_not_equal( + config_err, 0, + "I2S configuration should not be possible in states other than I2S_STATE_READY"); +} + +ZTEST_USER(i2s_errors, test_i2s_incorrect_trigger) +{ + int err; + char tx_data[BLOCK_SIZE] = {0}; + struct i2s_config test_config = { .word_size = 16U, + .channels = 2U, + .format = I2S_FMT_DATA_FORMAT_I2S, + .frame_clk_freq = FRAME_CLK_FREQ, + .block_size = BLOCK_SIZE, + .timeout = TIMEOUT, + .options = + I2S_OPT_FRAME_CLK_MASTER | I2S_OPT_BIT_CLK_MASTER, + .mem_slab = &tx_mem_slab }; + + err = i2s_configure(dev_i2s, I2S_DIR_TX, &test_config); + zassert_equal(err, 0, "CFG err=%d", err); + + err = i2s_buf_write(dev_i2s, tx_data, BLOCK_SIZE); + zassert_equal(err, 0, "I2S buffer write unexpected error: %d", err); + + err = i2s_trigger(dev_i2s, I2S_DIR_TX, INVALID_TRIGGER_SETTING); + zassert_equal(err, -EINVAL, "I2S invalid trigger setting not detected: err=%d", err); +} + +ZTEST_USER(i2s_errors, test_i2s_unconfigured_access) +{ + int err; + char tx_data[BLOCK_SIZE] = {0}; + struct i2s_config inactive_config = { .word_size = 16U, + .channels = 2U, + .format = I2S_FMT_DATA_FORMAT_I2S, + .frame_clk_freq = 0, + .block_size = BLOCK_SIZE, + .timeout = TIMEOUT, + .options = I2S_OPT_FRAME_CLK_MASTER | + I2S_OPT_BIT_CLK_MASTER, + .mem_slab = &tx_mem_slab }; + + err = i2s_configure(dev_i2s, I2S_DIR_TX, &inactive_config); + zassert_equal(err, 0, "I2S interface NOT_READY state transition failed. err=%d", err); + + err = i2s_buf_write(dev_i2s, tx_data, BLOCK_SIZE); + zassert_equal( + err, -EIO, + "I2S attempting unconfigured interface access did not raise I/O error, err=%d", + err); +} + +ZTEST_USER(i2s_errors, test_i2s_improper_block_size_write) +{ + int err; + char tx_data[BLOCK_SIZE] = {0}; + struct i2s_config test_config = { .word_size = 16U, + .channels = 2U, + .format = I2S_FMT_DATA_FORMAT_I2S, + .frame_clk_freq = FRAME_CLK_FREQ, + .block_size = BLOCK_SIZE, + .timeout = TIMEOUT, + .options = + I2S_OPT_FRAME_CLK_MASTER | I2S_OPT_BIT_CLK_MASTER, + .mem_slab = &tx_mem_slab }; + + err = i2s_configure(dev_i2s, I2S_DIR_TX, &test_config); + zassert_equal(err, 0, "Unexpected error when configuring I2S interface: %d", err); + + err = i2s_buf_write(dev_i2s, tx_data, sizeof(uint16_t) + BLOCK_SIZE); + zassert_not_equal( + err, 0, + "I2S attempting write with incorrect block size did not raise error, err=%d", err); +} diff --git a/tests/drivers/pwm/pwm_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/pwm/pwm_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index c483d27f569a..6944718f64d6 100644 --- a/tests/drivers/pwm/pwm_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/drivers/pwm/pwm_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -17,4 +17,5 @@ pinctrl-0 = <&pwm_default>; pinctrl-1 = <&pwm_sleep>; pinctrl-names = "default", "sleep"; + memory-regions = <&cpuapp_dma_region>; }; diff --git a/tests/drivers/spi/spi_error_cases/CMakeLists.txt b/tests/drivers/spi/spi_error_cases/CMakeLists.txt new file mode 100644 index 000000000000..2ac4bdbef4d4 --- /dev/null +++ b/tests/drivers/spi/spi_error_cases/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(spi_error_cases) + +FILE(GLOB app_sources src/*.c) + +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/drivers/spi/spi_error_cases/boards/nrf52840dk_nrf52840.overlay b/tests/drivers/spi/spi_error_cases/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 000000000000..183d6da9967f --- /dev/null +++ b/tests/drivers/spi/spi_error_cases/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + spi3_default_alt: spi3_default_alt { + group1 { + psels = , + , + ; + }; + }; + + spi3_sleep_alt: spi3_sleep_alt { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + spi1_default_alt: spi1_default_alt { + group1 { + psels = , + , + , + ; + }; + }; + + spi1_sleep_alt: spi1_sleep_alt { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; + +}; + +dut_spi: &spi3 { + status = "okay"; + pinctrl-0 = <&spi3_default_alt>; + pinctrl-1 = <&spi3_sleep_alt>; + pinctrl-names = "default", "sleep"; + overrun-character = <0x00>; + cs-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>; + dut_spi_dt: test-spi-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = <200000>; + }; +}; + +dut_spis: &spi1 { + compatible = "nordic,nrf-spis"; + status = "okay"; + def-char = <0x00>; + pinctrl-0 = <&spi1_default_alt>; + pinctrl-1 = <&spi1_sleep_alt>; + pinctrl-names = "default", "sleep"; + dut_spis_dt: test-spis-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = <200000>; + }; +}; diff --git a/tests/drivers/spi/spi_error_cases/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/tests/drivers/spi/spi_error_cases/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..2a0394c3f604 --- /dev/null +++ b/tests/drivers/spi/spi_error_cases/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + spi22_default_alt: spi22_default_alt { + group1 { + psels = , + , + ; + }; + }; + + spi22_sleep_alt: spi22_sleep_alt { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + spi21_default_alt: spi21_default_alt { + group1 { + psels = , + , + , + ; + }; + }; + + spi21_sleep_alt: spi21_sleep_alt { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; + +}; + +&gpio2 { + status = "okay"; +}; + +dut_spi: &spi22 { + status = "okay"; + pinctrl-0 = <&spi22_default_alt>; + pinctrl-1 = <&spi22_sleep_alt>; + pinctrl-names = "default", "sleep"; + overrun-character = <0x00>; + cs-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>; + dut_spi_dt: test-spi-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = <200000>; + }; +}; + +dut_spis: &spi21 { + compatible = "nordic,nrf-spis"; + status = "okay"; + def-char = <0x00>; + pinctrl-0 = <&spi21_default_alt>; + pinctrl-1 = <&spi21_sleep_alt>; + pinctrl-names = "default", "sleep"; + dut_spis_dt: test-spis-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = <200000>; + }; + /delete-property/rx-delay-supported; + /delete-property/rx-delay; +}; diff --git a/tests/drivers/spi/spi_error_cases/prj.conf b/tests/drivers/spi/spi_error_cases/prj.conf new file mode 100644 index 000000000000..1161e03f477a --- /dev/null +++ b/tests/drivers/spi/spi_error_cases/prj.conf @@ -0,0 +1,7 @@ +CONFIG_SPI=y +CONFIG_SPI_SLAVE=y +CONFIG_GPIO=y +CONFIG_POLL=y +CONFIG_SPI_ASYNC=y +CONFIG_SPI_EXTENDED_MODES=y +CONFIG_ZTEST=y diff --git a/tests/drivers/spi/spi_error_cases/src/main.c b/tests/drivers/spi/spi_error_cases/src/main.c new file mode 100644 index 000000000000..0b44812db84f --- /dev/null +++ b/tests/drivers/spi/spi_error_cases/src/main.c @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +#define SPI_MODE (SPI_MODE_CPOL | SPI_WORD_SET(8) | SPI_LINES_SINGLE) +#define SPIM_OP (SPI_OP_MODE_MASTER | SPI_MODE) +#define SPIS_OP (SPI_OP_MODE_SLAVE | SPI_MODE) + +static struct spi_dt_spec spim = SPI_DT_SPEC_GET(DT_NODELABEL(dut_spi_dt), SPIM_OP, 0); +static struct spi_dt_spec spis = SPI_DT_SPEC_GET(DT_NODELABEL(dut_spis_dt), SPIS_OP, 0); + +#define MEMORY_SECTION(node) \ + COND_CODE_1(DT_NODE_HAS_PROP(node, memory_regions), \ + (__attribute__((__section__( \ + LINKER_DT_NODE_REGION_NAME(DT_PHANDLE(node, memory_regions)))))), \ + ()) + +static uint8_t spim_buffer[32] MEMORY_SECTION(DT_NODELABEL(dut_spi)); +static uint8_t spis_buffer[32] MEMORY_SECTION(DT_NODELABEL(dut_spis)); + +struct test_data { + int spim_alloc_idx; + int spis_alloc_idx; + struct spi_buf_set sets[4]; + struct spi_buf_set *mtx_set; + struct spi_buf_set *mrx_set; + struct spi_buf_set *stx_set; + struct spi_buf_set *srx_set; + struct spi_buf bufs[4]; +}; + +static struct test_data tdata; + +/* Allocate buffer from spim or spis space. */ +static uint8_t *buf_alloc(size_t len, bool spim) +{ + int *idx = spim ? &tdata.spim_alloc_idx : &tdata.spis_alloc_idx; + uint8_t *buf = spim ? spim_buffer : spis_buffer; + size_t total = spim ? sizeof(spim_buffer) : sizeof(spis_buffer); + uint8_t *rv; + + if (*idx + len > total) { + zassert_false(true); + + return NULL; + } + + rv = &buf[*idx]; + *idx += len; + + return rv; +} + +ZTEST(spi_error_cases, test_SPI_HALF_DUPLEX_not_supported) +{ + int rv; + int slave_rv; + struct spi_dt_spec spim_invalid = spim; + struct spi_dt_spec spis_invalid = spis; + + spim_invalid.config.operation |= SPI_HALF_DUPLEX; + spis_invalid.config.operation |= SPI_HALF_DUPLEX; + + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -ENOTSUP, "Got %d instead", rv); + slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_SPI_OP_MODE_invalid) +{ + int rv; + int slave_rv; + struct spi_dt_spec spim_invalid = spim; + struct spi_dt_spec spis_invalid = spis; + + spim_invalid.config.operation |= SPI_OP_MODE_SLAVE; + spis_invalid.config.operation &= !SPI_OP_MODE_SLAVE; + + /* Check that Operation Mode Slave on spim is not supported */ + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -EINVAL, "Got %d instead", rv); + /* Check that Operation Mode Master on spis is not supported */ + slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_SPI_MODE_LOOP_not_supported) +{ + int rv; + int slave_rv; + struct spi_dt_spec spim_invalid = spim; + struct spi_dt_spec spis_invalid = spis; + + spim_invalid.config.operation |= SPI_MODE_LOOP; + spis_invalid.config.operation |= SPI_MODE_LOOP; + + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -EINVAL, "Got %d instead", rv); + slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_only_SPI_LINES_SINGLE_supported) +{ + int rv; + int slave_rv; + struct spi_dt_spec spim_invalid = spim; + struct spi_dt_spec spis_invalid = spis; + + spim_invalid.config.operation |= SPI_LINES_DUAL; + spis_invalid.config.operation |= SPI_LINES_DUAL; + + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -EINVAL, "Got %d instead", rv); + slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); + + spim_invalid = spim; + spis_invalid = spis; + spim_invalid.config.operation |= SPI_LINES_QUAD; + spis_invalid.config.operation |= SPI_LINES_QUAD; + + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -EINVAL, "Got %d instead", rv); + slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); + + spim_invalid = spim; + spis_invalid = spis; + spim_invalid.config.operation |= SPI_LINES_OCTAL; + spis_invalid.config.operation |= SPI_LINES_OCTAL; + + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -EINVAL, "Got %d instead", rv); + slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_only_8BIT_supported) +{ + int rv; + int slave_rv; + struct spi_dt_spec spim_invalid = spim; + struct spi_dt_spec spis_invalid = spis; + + spim_invalid.config.operation |= SPI_WORD_SET(16); + spis_invalid.config.operation |= SPI_WORD_SET(16); + + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -EINVAL, "Got %d instead", rv); + slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_unsupported_frequency) +{ + int rv; + struct spi_dt_spec spim_invalid = spim; + + spim_invalid.config.frequency = 124999; + + rv = spi_transceive_dt(&spim_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(rv, -EINVAL, "Got %d instead", rv); +} + +ZTEST(spi_error_cases, test_CS_unsupported_on_slave) +{ + int slave_rv; + struct spi_dt_spec spis_invalid = spis; + struct gpio_dt_spec test_gpio = { DEVICE_DT_GET(DT_NODELABEL(gpio1)), 10, GPIO_ACTIVE_LOW }; + + spis_invalid.config.cs.gpio = test_gpio; + + slave_rv = spi_transceive_dt(&spis_invalid, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_spis_scattered_tx_buf_not_supported) +{ + int slave_rv; + + tdata.sets[2].count = 2; + slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_spis_scattered_rx_buf_not_supported) +{ + int slave_rv; + + tdata.sets[3].count = 2; + slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_spis_tx_buf_too_big) +{ + int slave_rv; + + tdata.bufs[2].len = (size_t)65536; + slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_spis_rx_buf_too_big) +{ + int slave_rv; + + tdata.bufs[3].len = (size_t)65536; + slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -EINVAL, "Got %d instead", slave_rv); +} + +ZTEST(spi_error_cases, test_spis_tx_buf_not_in_ram) +{ + int slave_rv; + + tdata.bufs[2].buf = (void *)0x12345678; + slave_rv = spi_transceive_dt(&spis, tdata.stx_set, tdata.srx_set); + zassert_equal(slave_rv, -ENOTSUP, "Got %d instead", slave_rv); +} + +static void before(void *not_used) +{ + ARG_UNUSED(not_used); + size_t len = 16; + + memset(&tdata, 0, sizeof(tdata)); + for (size_t i = 0; i < sizeof(spim_buffer); i++) { + spim_buffer[i] = (uint8_t)i; + } + for (size_t i = 0; i < sizeof(spis_buffer); i++) { + spis_buffer[i] = (uint8_t)i; + } + + for (int i = 0; i < 4; i++) { + tdata.bufs[i].buf = buf_alloc(len, i < 2); + tdata.bufs[i].len = len; + tdata.sets[i].buffers = &tdata.bufs[i]; + tdata.sets[i].count = 1; + } + + tdata.mtx_set = &tdata.sets[0]; + tdata.mrx_set = &tdata.sets[1]; + tdata.stx_set = &tdata.sets[2]; + tdata.srx_set = &tdata.sets[3]; +} + +static void *suite_setup(void) +{ + return NULL; +} + +ZTEST_SUITE(spi_error_cases, NULL, suite_setup, before, NULL, NULL); diff --git a/tests/drivers/spi/spi_error_cases/testcase.yaml b/tests/drivers/spi/spi_error_cases/testcase.yaml new file mode 100644 index 000000000000..9c7e40167e7c --- /dev/null +++ b/tests/drivers/spi/spi_error_cases/testcase.yaml @@ -0,0 +1,12 @@ +tests: + drivers.spi.spi_error_cases: + depends_on: spi + tags: drivers spi + harness: ztest + harness_config: + fixture: gpio_spi_loopback + platform_allow: + - nrf52840dk/nrf52840 + - nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf52840dk/nrf52840 diff --git a/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..5ab0e84eeaa8 --- /dev/null +++ b/tests/drivers/spi/spi_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + spi130_default: spi130_default { + group1 { + psels = , + , + ; + }; + }; + + spi130_sleep: spi130_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + +&spi130 { + status = "okay"; + pinctrl-0 = <&spi130_default>; + pinctrl-1 = <&spi130_sleep>; + pinctrl-names = "default", "sleep"; + overrun-character = <0x00>; + memory-regions = <&cpuapp_dma_region>; + slow@0 { + compatible = "test-spi-loopback-slow"; + reg = <0>; + spi-max-frequency = ; + }; + fast@0 { + compatible = "test-spi-loopback-fast"; + reg = <0>; + spi-max-frequency = ; + }; +}; diff --git a/tests/drivers/spi/spi_slave/CMakeLists.txt b/tests/drivers/spi/spi_slave/CMakeLists.txt new file mode 100644 index 000000000000..f9f7a6bdae4b --- /dev/null +++ b/tests/drivers/spi/spi_slave/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(spi_slave) + +FILE(GLOB app_sources src/*.c) + +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/drivers/spi/spi_slave/boards/nrf52840dk_nrf52840.overlay b/tests/drivers/spi/spi_slave/boards/nrf52840dk_nrf52840.overlay new file mode 100644 index 000000000000..477917e0ca74 --- /dev/null +++ b/tests/drivers/spi/spi_slave/boards/nrf52840dk_nrf52840.overlay @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + spi3_default_alt: spi3_default_alt { + group1 { + psels = , + , + ; + }; + }; + + spi3_sleep_alt: spi3_sleep_alt { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + spi1_default_alt: spi1_default_alt { + group1 { + psels = , + , + , + ; + }; + }; + + spi1_sleep_alt: spi1_sleep_alt { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; + +}; + +&spi3 { + status = "okay"; + pinctrl-0 = <&spi3_default_alt>; + pinctrl-1 = <&spi3_sleep_alt>; + pinctrl-names = "default", "sleep"; + overrun-character = <0x00>; + cs-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>; + dut_spi_dt: test-spi-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = <4000000>; + }; +}; + +dut_spis: &spi1 { + compatible = "nordic,nrf-spis"; + status = "okay"; + def-char = <0x00>; + pinctrl-0 = <&spi1_default_alt>; + pinctrl-1 = <&spi1_sleep_alt>; + pinctrl-names = "default", "sleep"; +}; diff --git a/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_common.dtsi b/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_common.dtsi new file mode 100644 index 000000000000..0a9425cc2f9d --- /dev/null +++ b/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_common.dtsi @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + spi130_default_alt: spi130_default_alt { + group1 { + psels = , + , + ; + }; + }; + + spi130_sleep_alt: spi130_sleep_alt { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + spis131_default_alt: spis131_default_alt { + group1 { + psels = , + , + , + ; + }; + }; + + spis131_sleep_alt: spis131_sleep_alt { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; + +}; + +&gpio0 { + status = "okay"; +}; + +&gpiote130 { + status = "okay"; + owned-channels = <7>; +}; + +dut_spi: &spi130 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi130_default_alt>; + pinctrl-1 = <&spi130_sleep_alt>; + pinctrl-names = "default", "sleep"; + overrun-character = <0x00>; + cs-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>; + dut_spi_dt: test-spi-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = <500000>; + }; +}; + +dut_spis: &spi131 { + compatible = "nordic,nrf-spis"; + status = "okay"; + def-char = <0x00>; + pinctrl-0 = <&spis131_default_alt>; + pinctrl-1 = <&spis131_sleep_alt>; + pinctrl-names = "default", "sleep"; + /delete-property/rx-delay-supported; + /delete-property/rx-delay; +}; diff --git a/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..ff337ebdec48 --- /dev/null +++ b/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "nrf54h20dk_nrf54h20_common.dtsi" + +&dut_spi { + memory-regions = <&cpuapp_dma_region>; +}; + +&dut_spis { + memory-regions = <&cpuapp_dma_region>; +}; diff --git a/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_cpurad.overlay new file mode 100644 index 000000000000..936bd5b15d54 --- /dev/null +++ b/tests/drivers/spi/spi_slave/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "nrf54h20dk_nrf54h20_common.dtsi" + +&dut_spi { + memory-regions = <&cpurad_dma_region>; +}; + +&dut_spis { + memory-regions = <&cpurad_dma_region>; +}; diff --git a/tests/drivers/spi/spi_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/tests/drivers/spi/spi_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..d431f2783373 --- /dev/null +++ b/tests/drivers/spi/spi_slave/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + spi22_default_alt: spi22_default_alt { + group1 { + psels = , + , + ; + }; + }; + + spi22_sleep_alt: spi22_sleep_alt { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + spi21_default_alt: spi21_default_alt { + group1 { + psels = , + , + , + ; + }; + }; + + spi21_sleep_alt: spi21_sleep_alt { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; + +}; + +&gpio2 { + status = "okay"; +}; + +&spi22 { + status = "okay"; + pinctrl-0 = <&spi22_default_alt>; + pinctrl-1 = <&spi22_sleep_alt>; + pinctrl-names = "default", "sleep"; + overrun-character = <0x00>; + cs-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>; + dut_spi_dt: test-spi-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = <4000000>; + }; +}; + +dut_spis: &spi21 { + compatible = "nordic,nrf-spis"; + status = "okay"; + def-char = <0x00>; + pinctrl-0 = <&spi21_default_alt>; + pinctrl-1 = <&spi21_sleep_alt>; + pinctrl-names = "default", "sleep"; + /delete-property/rx-delay-supported; + /delete-property/rx-delay; +}; diff --git a/tests/drivers/spi/spi_slave/prj.conf b/tests/drivers/spi/spi_slave/prj.conf new file mode 100644 index 000000000000..840a8f87d9a9 --- /dev/null +++ b/tests/drivers/spi/spi_slave/prj.conf @@ -0,0 +1,6 @@ +CONFIG_SPI=y +CONFIG_SPI_SLAVE=y +CONFIG_GPIO=y +CONFIG_POLL=y +CONFIG_SPI_ASYNC=y +CONFIG_ZTEST=y diff --git a/tests/drivers/spi/spi_slave/src/main.c b/tests/drivers/spi/spi_slave/src/main.c new file mode 100644 index 000000000000..5f441480c12f --- /dev/null +++ b/tests/drivers/spi/spi_slave/src/main.c @@ -0,0 +1,453 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include + +#define SPI_MODE (SPI_MODE_CPOL | SPI_MODE_CPHA | SPI_WORD_SET(8) | SPI_LINES_SINGLE) +#define SPIM_OP (SPI_OP_MODE_MASTER | SPI_MODE) +#define SPIS_OP (SPI_OP_MODE_SLAVE | SPI_MODE) + +static struct spi_dt_spec spim = SPI_DT_SPEC_GET(DT_NODELABEL(dut_spi_dt), SPIM_OP, 0); +static const struct device *spis_dev = DEVICE_DT_GET(DT_NODELABEL(dut_spis)); +static const struct spi_config spis_config = { + .operation = SPIS_OP +}; + +static struct k_poll_signal async_sig = K_POLL_SIGNAL_INITIALIZER(async_sig); +static struct k_poll_event async_evt = + K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &async_sig); + +#define MEMORY_SECTION(node) \ + COND_CODE_1(DT_NODE_HAS_PROP(node, memory_regions), \ + (__attribute__((__section__( \ + LINKER_DT_NODE_REGION_NAME(DT_PHANDLE(node, memory_regions)))))), \ + ()) + +static uint8_t spim_buffer[32] MEMORY_SECTION(DT_BUS(DT_NODELABEL(dut_spi_dt))); +static uint8_t spis_buffer[32] MEMORY_SECTION(DT_NODELABEL(dut_spis)); + +struct test_data { + struct k_work_delayable test_work; + struct k_sem sem; + int spim_alloc_idx; + int spis_alloc_idx; + struct spi_buf_set sets[4]; + struct spi_buf_set *mtx_set; + struct spi_buf_set *mrx_set; + struct spi_buf_set *stx_set; + struct spi_buf_set *srx_set; + struct spi_buf bufs[8]; +}; + +static struct test_data tdata; + +/* Allocate buffer from spim or spis space. */ +static uint8_t *buf_alloc(size_t len, bool spim) +{ + int *idx = spim ? &tdata.spim_alloc_idx : &tdata.spis_alloc_idx; + uint8_t *buf = spim ? spim_buffer : spis_buffer; + size_t total = spim ? sizeof(spim_buffer) : sizeof(spis_buffer); + uint8_t *rv; + + if (*idx + len > total) { + zassert_false(true); + + return NULL; + } + + rv = &buf[*idx]; + *idx += len; + + return rv; +} + +static void work_handler(struct k_work *work) +{ + struct k_work_delayable *dwork = k_work_delayable_from_work(work); + struct test_data *td = CONTAINER_OF(dwork, struct test_data, test_work); + int rv; + + rv = spi_transceive_dt(&spim, td->mtx_set, td->mrx_set); + if (rv == 0) { + k_sem_give(&td->sem); + } +} + +/** Copies data from buffers in the set to a single buffer which makes it easier + * to compare transmitted and received data. + * + * @param buf Output buffer. + * @param len Buffer length. + * @param set Set of buffers. + * + * @return Number of bytes copied. + */ +static int cpy_data(uint8_t *buf, size_t len, struct spi_buf_set *set) +{ + int idx = 0; + + for (size_t i = 0; i < set->count; i++) { + size_t l = set->buffers[i].len; + + if (len - idx >= l) { + memcpy(&buf[idx], set->buffers[i].buf, l); + idx += l; + } else { + return -1; + } + } + + return idx; +} + +/** Compare two sets. + * + * @param tx_set TX set. + * @param rx_set RX set. + * @param same_size True if it is expected to have the same amount of data in both sets. + * + * @return 0 if data is the same and other value indicate that check failed. + */ +static int check_buffers(struct spi_buf_set *tx_set, struct spi_buf_set *rx_set, bool same_size) +{ + static uint8_t tx_data[256]; + static uint8_t rx_data[256]; + int rx_len; + int tx_len; + + if (!tx_set || !rx_set) { + return 0; + } + + rx_len = cpy_data(rx_data, sizeof(rx_data), rx_set); + tx_len = cpy_data(tx_data, sizeof(tx_data), tx_set); + if (same_size && (rx_len != tx_len)) { + return -1; + } + + return memcmp(tx_data, rx_data, rx_len); +} + +/** Calculate expected number of received bytes by the slave. + * + * It is used to check if SPI API call for slave returns correct value. + * @param tx_set TX set. + * @param rx_set RX set. + * + * @return Expected amount of received bytes. + */ +static int slave_rx_len(struct spi_buf_set *tx_set, struct spi_buf_set *rx_set) +{ + size_t tx_len = 0; + size_t rx_len = 0; + + if (!tx_set || !rx_set) { + return 0; + } + + for (size_t i = 0; i < tx_set->count; i++) { + tx_len += tx_set->buffers[i].len; + } + + for (size_t i = 0; i < rx_set->count; i++) { + rx_len += rx_set->buffers[i].len; + } + + return MIN(rx_len, tx_len); +} + +/** Generic function which runs the test with sets prepared in the test data structure. */ +static void run_test(bool m_same_size, bool s_same_size, bool async) +{ + int rv; + int slave_rv; + int srx_len; + + rv = k_work_schedule(&tdata.test_work, K_MSEC(10)); + zassert_equal(rv, 1); + + if (!async) { + slave_rv = spi_transceive(spis_dev, &spis_config, tdata.stx_set, tdata.srx_set); + if (slave_rv == -ENOTSUP) { + ztest_test_skip(); + } + } else { + rv = spi_transceive_signal(spis_dev, &spis_config, tdata.stx_set, tdata.srx_set, + &async_sig); + if (rv == -ENOTSUP) { + ztest_test_skip(); + } + zassert_equal(rv, 0); + + /* Transfer not finished yet */ + rv = k_sem_take(&tdata.sem, K_NO_WAIT); + zassert_equal(rv, -EBUSY); + + rv = k_poll(&async_evt, 1, K_MSEC(200)); + zassert_false(rv, "one or more events are not ready"); + + slave_rv = async_evt.signal->result; + + /* Reinitializing for next call */ + async_evt.signal->signaled = 0U; + async_evt.state = K_POLL_STATE_NOT_READY; + } + + rv = k_sem_take(&tdata.sem, K_MSEC(100)); + zassert_equal(rv, 0); + + srx_len = slave_rx_len(tdata.mtx_set, tdata.srx_set); + + zassert_equal(slave_rv, srx_len, "Got: %d but expected:%d", slave_rv, srx_len); + + rv = check_buffers(tdata.mtx_set, tdata.srx_set, m_same_size); + zassert_equal(rv, 0); + + rv = check_buffers(tdata.stx_set, tdata.mrx_set, s_same_size); + zassert_equal(rv, 0); +} + +/** Basic test where slave and master have RX and TX sets which contains only one + * same size buffer. + */ +static void test_basic(bool async) +{ + size_t len = 16; + + for (int i = 0; i < 4; i++) { + tdata.bufs[i].buf = buf_alloc(len, i < 2); + tdata.bufs[i].len = len; + tdata.sets[i].buffers = &tdata.bufs[i]; + tdata.sets[i].count = 1; + } + + tdata.mtx_set = &tdata.sets[0]; + tdata.mrx_set = &tdata.sets[1]; + tdata.stx_set = &tdata.sets[2]; + tdata.srx_set = &tdata.sets[3]; + + run_test(true, true, async); +} + +ZTEST(spi_slave, test_basic) +{ + test_basic(false); +} + +ZTEST(spi_slave, test_basic_async) +{ + test_basic(true); +} + +/** Setup a transfer where RX buffer on master and slave are shorter than + * TX buffers. RX buffers shall contain beginning of TX data and last TX + * bytes that did not fit in the RX buffers shall be lost. + */ +static void test_short_rx(bool async) +{ + size_t len = 16; + + tdata.bufs[0].buf = buf_alloc(len, true); + tdata.bufs[0].len = len; + tdata.bufs[1].buf = buf_alloc(len, true); + tdata.bufs[1].len = len - 3; /* RX buffer */ + tdata.bufs[2].buf = buf_alloc(len, false); + tdata.bufs[2].len = len; + tdata.bufs[3].buf = buf_alloc(len, false); + tdata.bufs[3].len = len - 4; /* RX buffer */ + + for (int i = 0; i < 4; i++) { + tdata.sets[i].buffers = &tdata.bufs[i]; + tdata.sets[i].count = 1; + } + + tdata.mtx_set = &tdata.sets[0]; + tdata.mrx_set = &tdata.sets[1]; + tdata.stx_set = &tdata.sets[2]; + tdata.srx_set = &tdata.sets[3]; + + run_test(false, false, async); +} + +ZTEST(spi_slave, test_short_rx) +{ + test_short_rx(false); +} + +ZTEST(spi_slave, test_short_rx_async) +{ + test_short_rx(true); +} + +/** Test where only master transmits. */ +static void test_only_tx(bool async) +{ + size_t len = 16; + + /* MTX buffer */ + tdata.bufs[0].buf = buf_alloc(len, true); + tdata.bufs[0].len = len; + tdata.sets[0].buffers = &tdata.bufs[0]; + tdata.sets[0].count = 1; + tdata.mtx_set = &tdata.sets[0]; + tdata.mrx_set = NULL; + + /* STX buffer */ + tdata.bufs[1].buf = buf_alloc(len, false); + tdata.bufs[1].len = len; + tdata.sets[1].buffers = &tdata.bufs[1]; + tdata.sets[1].count = 1; + tdata.srx_set = &tdata.sets[1]; + tdata.stx_set = NULL; + + run_test(true, true, async); +} + +ZTEST(spi_slave, test_only_tx) +{ + test_only_tx(false); +} + +ZTEST(spi_slave, test_only_tx_async) +{ + test_only_tx(true); +} + +/** Test where only master transmits and slave receives in chunks. */ +static void test_only_tx_in_chunks(bool async) +{ + size_t len1 = 7; + size_t len2 = 8; + + /* MTX buffer */ + tdata.bufs[0].buf = buf_alloc(len1 + len2, true); + tdata.bufs[0].len = len1 + len2; + tdata.sets[0].buffers = &tdata.bufs[0]; + tdata.sets[0].count = 1; + tdata.mtx_set = &tdata.sets[0]; + tdata.mrx_set = NULL; + + /* STX buffer */ + tdata.bufs[1].buf = buf_alloc(len1, false); + tdata.bufs[1].len = len1; + tdata.bufs[2].buf = buf_alloc(len2, false); + tdata.bufs[2].len = len2; + tdata.sets[1].buffers = &tdata.bufs[1]; + tdata.sets[1].count = 2; + tdata.srx_set = &tdata.sets[1]; + tdata.stx_set = NULL; + + run_test(true, true, async); +} + +ZTEST(spi_slave, test_only_tx_in_chunks) +{ + test_only_tx_in_chunks(false); +} + +ZTEST(spi_slave, test_only_tx_in_chunks_async) +{ + test_only_tx_in_chunks(true); +} + +/** Test where only slave transmits. */ +static void test_only_rx(bool async) +{ + size_t len = 16; + + /* MTX buffer */ + tdata.bufs[0].buf = buf_alloc(len, true); + tdata.bufs[0].len = len; + tdata.sets[0].buffers = &tdata.bufs[0]; + tdata.sets[0].count = 1; + tdata.mrx_set = &tdata.sets[0]; + tdata.mtx_set = NULL; + + /* STX buffer */ + tdata.bufs[1].buf = buf_alloc(len, false); + tdata.bufs[1].len = len; + tdata.sets[1].buffers = &tdata.bufs[1]; + tdata.sets[1].count = 1; + tdata.stx_set = &tdata.sets[1]; + tdata.srx_set = NULL; + + run_test(true, true, async); +} + +ZTEST(spi_slave, test_only_rx) +{ + test_only_rx(false); +} + +ZTEST(spi_slave, test_only_rx_async) +{ + test_only_rx(true); +} + +/** Test where only slave transmits in chunks. */ +static void test_only_rx_in_chunks(bool async) +{ + size_t len1 = 7; + size_t len2 = 9; + + /* MTX buffer */ + tdata.bufs[0].buf = buf_alloc(len1 + len2, true); + tdata.bufs[0].len = len1 + len2; + tdata.sets[0].buffers = &tdata.bufs[0]; + tdata.sets[0].count = 1; + tdata.mrx_set = &tdata.sets[0]; + tdata.mtx_set = NULL; + + /* STX buffer */ + tdata.bufs[1].buf = buf_alloc(len1, false); + tdata.bufs[1].len = len1; + tdata.bufs[2].buf = buf_alloc(len2, false); + tdata.bufs[2].len = len2; + tdata.sets[1].buffers = &tdata.bufs[1]; + tdata.sets[1].count = 2; + tdata.stx_set = &tdata.sets[1]; + tdata.srx_set = NULL; + + run_test(true, true, async); +} + +ZTEST(spi_slave, test_only_rx_in_chunks) +{ + test_only_rx_in_chunks(false); +} + +ZTEST(spi_slave, test_only_rx_in_chunks_async) +{ + test_only_rx_in_chunks(true); +} + +static void before(void *not_used) +{ + ARG_UNUSED(not_used); + + memset(&tdata, 0, sizeof(tdata)); + for (size_t i = 0; i < sizeof(spim_buffer); i++) { + spim_buffer[i] = (uint8_t)i; + } + for (size_t i = 0; i < sizeof(spis_buffer); i++) { + spis_buffer[i] = (uint8_t)(i + 0x80); + } + + k_work_init_delayable(&tdata.test_work, work_handler); + k_sem_init(&tdata.sem, 0, 1); +} + +static void *suite_setup(void) +{ + return NULL; +} + +ZTEST_SUITE(spi_slave, NULL, suite_setup, before, NULL, NULL); diff --git a/tests/drivers/spi/spi_slave/testcase.yaml b/tests/drivers/spi/spi_slave/testcase.yaml new file mode 100644 index 000000000000..c38b3e729521 --- /dev/null +++ b/tests/drivers/spi/spi_slave/testcase.yaml @@ -0,0 +1,12 @@ +tests: + drivers.spi_slave.api: + depends_on: spi + tags: drivers spi + harness: ztest + harness_config: + fixture: gpio_spi_loopback + platform_allow: | + nrf52840dk/nrf52840 nrf54l15pdk/nrf54l15/cpuapp nrf54h20dk/nrf54h20/cpuapp + nrf54h20dk/nrf54h20/cpurad + integration_platforms: + - nrf52840dk/nrf52840 diff --git a/tests/drivers/timer/nrf_grtc_timer/testcase.yaml b/tests/drivers/timer/nrf_grtc_timer/testcase.yaml index f611a518a701..00ac1ed584b1 100644 --- a/tests/drivers/timer/nrf_grtc_timer/testcase.yaml +++ b/tests/drivers/timer/nrf_grtc_timer/testcase.yaml @@ -1,4 +1,7 @@ tests: drivers.timer.nrf_grtc_timer: tags: drivers - platform_allow: nrf54l15pdk/nrf54l15/cpuapp + platform_allow: + - nrf54l15pdk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp + - nrf54h20dk/nrf54h20/cpurad diff --git a/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_common.dtsi b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_common.dtsi new file mode 100644 index 000000000000..172d75904e47 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_common.dtsi @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +&pinctrl { + uart135_default_alt: uart135_default_alt { + group1 { + psels = , + ; + }; + }; + + uart135_sleep_alt: uart135_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +dut: &uart135 { + status = "okay"; + pinctrl-0 = <&uart135_default_alt>; + pinctrl-1 = <&uart135_sleep_alt>; + pinctrl-names = "default", "sleep"; +}; diff --git a/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..a8fe36d37bb1 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include "nrf54h20dk_nrf54h20_common.dtsi" + +&cpuapp_dma_region { + status = "okay"; +}; + +&dut { + memory-regions = <&cpuapp_dma_region>; +}; diff --git a/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay new file mode 100644 index 000000000000..32f956252012 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include "nrf54h20dk_nrf54h20_common.dtsi" + +&cpurad_dma_region { + status = "okay"; +}; + +&dut { + memory-regions = <&cpurad_dma_region>; +}; diff --git a/tests/drivers/uart/uart_elementary/CMakeLists.txt b/tests/drivers/uart/uart_elementary/CMakeLists.txt new file mode 100644 index 000000000000..59b31ee68a9b --- /dev/null +++ b/tests/drivers/uart/uart_elementary/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(uart_high_level_api) + +target_sources(app PRIVATE + src/main.c + ) diff --git a/tests/drivers/uart/uart_elementary/Kconfig b/tests/drivers/uart/uart_elementary/Kconfig new file mode 100644 index 000000000000..aed523c58322 --- /dev/null +++ b/tests/drivers/uart/uart_elementary/Kconfig @@ -0,0 +1,11 @@ +# UART test configuration options +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config DUAL_UART_TEST + bool "Enable dual UART test" + +config SETUP_MISMATCH_TEST + bool "Enable mismatched configuration in dual UART test" + +source "Kconfig.zephyr" diff --git a/tests/drivers/uart/uart_elementary/README.txt b/tests/drivers/uart/uart_elementary/README.txt new file mode 100644 index 000000000000..5af85beff46d --- /dev/null +++ b/tests/drivers/uart/uart_elementary/README.txt @@ -0,0 +1,13 @@ +The purpose of this test is to validate basic UART driver functions, +that are not tested elsewhere. +UART interrupt mode is used for the tests purpose. + +Hardware setup required for these tests: +For single uart conviguration - UART0 TX connected to RX and CTS to RTS +For dual uart configuratiom - UART0 and UART1 TXs and RXs cross-connected + +These test cases cover: +- UART configuration, +- UART error check, +- UART callback setup, +- Dual UART transmission with matched and mismatched configurations diff --git a/tests/drivers/uart/uart_elementary/boards/nrf5340dk_nrf5340_cpuapp.conf b/tests/drivers/uart/uart_elementary/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 000000000000..064e78b6f74b --- /dev/null +++ b/tests/drivers/uart/uart_elementary/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1 @@ +CONFIG_UART_NRFX_UARTE_LEGACY_SHIM=n diff --git a/tests/drivers/uart/uart_elementary/boards/nrf5340dk_nrf5340_cpuapp.overlay b/tests/drivers/uart/uart_elementary/boards/nrf5340dk_nrf5340_cpuapp.overlay new file mode 100644 index 000000000000..f98f3657f138 --- /dev/null +++ b/tests/drivers/uart/uart_elementary/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +&pinctrl { + uart1_default_alt: uart1_default_alt { + group1 { + psels = , + , + , + ; + }; + }; + + uart1_sleep_alt: uart1_sleep_alt { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; +}; + +dut: &uart1 { + current-speed = <115200>; + compatible = "nordic,nrf-uarte"; + status = "okay"; + pinctrl-0 = <&uart1_default_alt>; + pinctrl-1 = <&uart1_sleep_alt>; + pinctrl-names = "default", "sleep"; + hw-flow-control; +}; diff --git a/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_common.dtsi b/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_common.dtsi new file mode 100644 index 000000000000..22d8378937c2 --- /dev/null +++ b/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_common.dtsi @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +&cpuapp_dma_region { + status="okay"; +}; + +&pinctrl { + uart135_default_alt: uart135_default_alt { + group1 { + psels = , + , + , + ; + }; + }; + + uart135_sleep_alt: uart135_sleep_alt { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; +}; + +dut: &uart135 { + status = "okay"; + memory-regions = <&cpuapp_dma_region>; + pinctrl-0 = <&uart135_default_alt>; + pinctrl-1 = <&uart135_sleep_alt>; + pinctrl-names = "default", "sleep"; + current-speed = <115200>; + hw-flow-control; + +}; diff --git a/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..f65b4dd3b0ba --- /dev/null +++ b/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include "nrf54h20dk_nrf54h20_common.dtsi" diff --git a/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_cpuapp_dual_uart.overlay b/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_cpuapp_dual_uart.overlay new file mode 100644 index 000000000000..23c36ee89744 --- /dev/null +++ b/tests/drivers/uart/uart_elementary/boards/nrf54h20dk_nrf54h20_cpuapp_dual_uart.overlay @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include "nrf54h20dk_nrf54h20_common.dtsi" + + +&pinctrl { + uart135_default_alt: uart135_default_alt { + group1 { + psels = , + ; + }; + }; + + uart135_sleep_alt: uart135_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +dut: &uart135 { + status = "okay"; + memory-regions = <&cpuapp_dma_region>; + pinctrl-0 = <&uart135_default_alt>; + pinctrl-1 = <&uart135_sleep_alt>; + pinctrl-names = "default", "sleep"; + current-speed = <115200>; +}; + +&pinctrl { + uart137_default_alt: uart137_default_alt { + group1 { + psels = , + ; + }; + }; + + uart137_sleep_alt: uart137_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +dut_aux: &uart137 { + status = "okay"; + memory-regions = <&cpuapp_dma_region>; + pinctrl-0 = <&uart137_default_alt>; + pinctrl-1 = <&uart137_sleep_alt>; + pinctrl-names = "default", "sleep"; + current-speed = <115200>; +}; diff --git a/tests/drivers/uart/uart_elementary/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/tests/drivers/uart/uart_elementary/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..cf481b7a1614 --- /dev/null +++ b/tests/drivers/uart/uart_elementary/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +&pinctrl { + uart21_default: uart21_default { + group1 { + psels = , + , + , + ; + }; + }; + + uart21_sleep: uart21_sleep { + group1 { + psels = , + , + , + ; + low-power-enable; + }; + }; +}; + +dut: &uart21 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart21_default>; + pinctrl-1 = <&uart21_sleep>; + pinctrl-names = "default", "sleep"; + hw-flow-control; +}; diff --git a/tests/drivers/uart/uart_elementary/boards/nrf54l15pdk_nrf54l15_cpuapp_dual_uart.overlay b/tests/drivers/uart/uart_elementary/boards/nrf54l15pdk_nrf54l15_cpuapp_dual_uart.overlay new file mode 100644 index 000000000000..2031f7a24441 --- /dev/null +++ b/tests/drivers/uart/uart_elementary/boards/nrf54l15pdk_nrf54l15_cpuapp_dual_uart.overlay @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +&pinctrl { + uart21_default: uart21_default { + group1 { + psels = , + ; + bias-pull-up; + }; + }; + + uart21_sleep: uart21_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + uart22_default: uart22_default { + group1 { + psels = , + ; + bias-pull-up; + }; + }; + + uart22_sleep: uart22_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +dut: &uart21 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart21_default>; + pinctrl-1 = <&uart21_sleep>; + pinctrl-names = "default", "sleep"; +}; + +dut_aux: &uart22 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart22_default>; + pinctrl-1 = <&uart22_sleep>; + pinctrl-names = "default", "sleep"; +}; diff --git a/tests/drivers/uart/uart_elementary/prj.conf b/tests/drivers/uart/uart_elementary/prj.conf new file mode 100644 index 000000000000..26c93d320a73 --- /dev/null +++ b/tests/drivers/uart/uart_elementary/prj.conf @@ -0,0 +1,6 @@ +CONFIG_SERIAL=y +CONFIG_ZTEST=y +CONFIG_TEST_USERSPACE=y +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_UART_USE_RUNTIME_CONFIGURE=y +CONFIG_UART_INTERRUPT_DRIVEN=y diff --git a/tests/drivers/uart/uart_elementary/src/main.c b/tests/drivers/uart/uart_elementary/src/main.c new file mode 100644 index 000000000000..df8c7b54b102 --- /dev/null +++ b/tests/drivers/uart/uart_elementary/src/main.c @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @addtogroup t_driver_uart + * @{ + * @defgroup t_uart_elementary test_uart_elementary + * @} + */ + +#include +#include + +#if DT_NODE_EXISTS(DT_NODELABEL(dut)) +#define UART_NODE DT_NODELABEL(dut) +#else +#define UART_NODE DT_CHOSEN(zephyr_console) +#endif + +#if DT_NODE_EXISTS(DT_NODELABEL(dut_aux)) +#define UART_NODE_AUX DT_NODELABEL(dut_aux) +#else +#define UART_NODE_AUX DT_CHOSEN(zephyr_console) +#endif + +#define SLEEP_TIME_US 1000 +#define TEST_BUFFER_LEN 10 + +static const struct device *const uart_dev = DEVICE_DT_GET(UART_NODE); + +const uint8_t test_pattern[TEST_BUFFER_LEN] = { 0x11, 0x12, 0x13, 0x14, 0x15, + 0x16, 0x17, 0x18, 0x19, 0x20 }; +static uint8_t test_buffer[TEST_BUFFER_LEN]; +static volatile uint8_t uart_error_counter; + +#if defined(CONFIG_DUAL_UART_TEST) +static const struct device *const uart_dev_aux = DEVICE_DT_GET(UART_NODE_AUX); +static uint8_t test_buffer_aux[TEST_BUFFER_LEN]; +static volatile uint8_t aux_uart_error; +static volatile uint8_t aux_uart_error_counter; +#endif + +/* + * ISR for UART TX action + */ +static void uart_tx_interrupt_service(const struct device *dev, int *tx_byte_offset) +{ + uint8_t bytes_sent = 0; + uint8_t *tx_data_pointer = (uint8_t *)(test_pattern + *tx_byte_offset); + + if (*tx_byte_offset < TEST_BUFFER_LEN) { + bytes_sent = uart_fifo_fill(dev, tx_data_pointer, 1); + *tx_byte_offset += bytes_sent; + } else { + *tx_byte_offset = 0; + uart_irq_tx_disable(dev); + } +} + +/* + * ISR for UART RX action + */ +static void uart_rx_interrupt_service(const struct device *dev, uint8_t *receive_buffer_pointer, + int *rx_byte_offset) +{ + int rx_data_length = 0; + + do { + rx_data_length = uart_fifo_read(dev, receive_buffer_pointer + *rx_byte_offset, + TEST_BUFFER_LEN); + *rx_byte_offset += rx_data_length; + } while (rx_data_length); +} + +/* + * Callback function for MAIN UART interrupt based transmission test + */ +static void interrupt_driven_uart_callback_main_uart(const struct device *dev, void *user_data) +{ + int err; + static int tx_byte_offset; + static int rx_byte_offset; + + uart_irq_update(dev); + err = uart_err_check(dev); + if (err != 0) { + uart_error_counter++; + } + while (uart_irq_is_pending(dev)) { + if (uart_irq_rx_ready(dev)) { + uart_rx_interrupt_service(dev, (uint8_t *)user_data, &rx_byte_offset); + } + if (uart_irq_tx_ready(dev)) { + uart_tx_interrupt_service(dev, &tx_byte_offset); + } + } +} + +#if defined(CONFIG_DUAL_UART_TEST) +/* + * Callback function for AUX UART interrupt based transmission test + */ +static void interrupt_driven_uart_callback_aux_uart(const struct device *dev, void *user_data) +{ + int err; + static int tx_byte_offset_aux; + static int rx_byte_offset_aux; + + uart_irq_update(dev); + err = uart_err_check(dev); + if (err != 0) { + aux_uart_error_counter++; + } + while (uart_irq_is_pending(dev)) { + if (uart_irq_rx_ready(dev)) { + uart_rx_interrupt_service(dev, (uint8_t *)user_data, &rx_byte_offset_aux); + } + if (uart_irq_tx_ready(dev)) { + uart_tx_interrupt_service(dev, &tx_byte_offset_aux); + } + } +} +#endif /* CONFIG_DUAL_UART_TEST */ + +/* + * Test UART proper configuration call + */ +ZTEST(uart_elementary, test_uart_proper_configuration) +{ + Z_TEST_SKIP_IFDEF(CONFIG_DUAL_UART_TEST); + + int err; + struct uart_config test_expected_uart_config; + struct uart_config test_uart_config = { .baudrate = 115200, + .parity = UART_CFG_PARITY_NONE, + .stop_bits = UART_CFG_STOP_BITS_1, + .data_bits = UART_CFG_DATA_BITS_8, + .flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS }; + + err = uart_configure(uart_dev, &test_uart_config); + zassert_equal(err, 0, "'uart_configure' api call - unexpected error: %d", err); + + err = uart_config_get(uart_dev, &test_expected_uart_config); + zassert_equal(err, 0, "'uart_config_get' api call - unexpected error raised : %d", err); + + zassert_equal(test_uart_config.baudrate, test_expected_uart_config.baudrate, + "Set and actual UART config baudrate mismatch: %d != %d", + test_uart_config.baudrate, test_expected_uart_config.baudrate); + + zassert_equal(test_uart_config.parity, test_expected_uart_config.parity, + "Set and actual UART config parity mismatch: %d != %d", + test_uart_config.parity, test_expected_uart_config.parity); + + zassert_equal(test_uart_config.stop_bits, test_expected_uart_config.stop_bits, + "Set and actual UART config stop_bits mismatch: %d != %d", + test_uart_config.stop_bits, test_expected_uart_config.stop_bits); + + zassert_equal(test_uart_config.data_bits, test_expected_uart_config.data_bits, + "Set and actual UART config data_bits mismatch: %d != %d", + test_uart_config.data_bits, test_expected_uart_config.data_bits); + + zassert_equal(test_uart_config.flow_ctrl, test_expected_uart_config.flow_ctrl, + "Set and actual UART config flow_ctrl mismatch: %d != %d", + test_uart_config.flow_ctrl, test_expected_uart_config.flow_ctrl); +} + +/* + * Test UART improper configuration call + */ +ZTEST(uart_elementary, test_uart_improper_configuration) +{ + Z_TEST_SKIP_IFDEF(CONFIG_DUAL_UART_TEST); + + int err; + struct uart_config test_uart_config = { .baudrate = 115200, + .parity = 7, + .stop_bits = UART_CFG_STOP_BITS_1, + .data_bits = UART_CFG_DATA_BITS_8, + .flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS }; + + err = uart_configure(uart_dev, &test_uart_config); + zassert_not_equal( + err, 0, + "'uart_configure' with incorrect configuration havent't raised an error, err=%d", + err); +} + +#if !defined(CONFIG_DUAL_UART_TEST) +/* + * Test UART basic interrupt based transmission (with loopback) + */ +ZTEST(uart_elementary, test_uart_basic_transmission) +{ + int err; + struct uart_config test_uart_config = { .baudrate = 115200, + .parity = UART_CFG_PARITY_ODD, + .stop_bits = UART_CFG_STOP_BITS_1, + .data_bits = UART_CFG_DATA_BITS_8, + .flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS }; + + err = uart_configure(uart_dev, &test_uart_config); + zassert_equal(err, 0, "Unexpected error when configuring UART0: %d", err); + + err = uart_irq_callback_set(uart_dev, interrupt_driven_uart_callback_main_uart); + zassert_equal(err, 0, "Unexpected error when setting callback %d", err); + err = uart_irq_callback_user_data_set(uart_dev, interrupt_driven_uart_callback_main_uart, + (void *)test_buffer); + zassert_equal(err, 0, "Unexpected error when setting user data for callback %d", err); + uart_irq_err_enable(uart_dev); + uart_irq_rx_enable(uart_dev); + uart_irq_tx_enable(uart_dev); + + /* wait for the tramission to finish (no polling is intentional) */ + k_sleep(K_USEC(100 * SLEEP_TIME_US)); + + uart_irq_tx_disable(uart_dev); + uart_irq_rx_disable(uart_dev); + uart_irq_err_disable(uart_dev); + for (int index = 0; index < TEST_BUFFER_LEN; index++) { + zassert_equal(test_buffer[index], test_pattern[index], + "Recieived data byte %d does not match pattern 0x%x != 0x%x", index, + test_buffer[index], test_pattern[index]); + } +} +#else +/* + * Test UART interrupt based transmission between two ports + */ +ZTEST(uart_elementary, test_uart_dual_port_transmission) +{ + int err; + struct uart_config test_uart_config = { .baudrate = 115200, + .parity = UART_CFG_PARITY_NONE, + .stop_bits = UART_CFG_STOP_BITS_1, + .data_bits = UART_CFG_DATA_BITS_8, + .flow_ctrl = UART_CFG_FLOW_CTRL_NONE }; + +#if defined(CONFIG_SETUP_MISMATCH_TEST) + struct uart_config test_uart_config_aux = { .baudrate = 9600, + .parity = UART_CFG_PARITY_NONE, + .stop_bits = UART_CFG_STOP_BITS_1, + .data_bits = UART_CFG_DATA_BITS_8, + .flow_ctrl = UART_CFG_FLOW_CTRL_NONE }; +#endif + err = uart_configure(uart_dev, &test_uart_config); + zassert_equal(err, 0, "Unexpected error when configuring UART0: %d", err); + +#if defined(CONFIG_SETUP_MISMATCH_TEST) + err = uart_configure(uart_dev_aux, &test_uart_config_aux); +#else + err = uart_configure(uart_dev_aux, &test_uart_config); +#endif + + zassert_equal(err, 0, "Unexpected error when configuring UART1: %d", err); + + err = uart_irq_callback_set(uart_dev, interrupt_driven_uart_callback_main_uart); + zassert_equal(err, 0, "Unexpected error when setting callback for UART0 %d", err); + err = uart_irq_callback_user_data_set(uart_dev, interrupt_driven_uart_callback_main_uart, + (void *)test_buffer); + zassert_equal(err, 0, "Unexpected error when setting user data for UART0 callback %d", err); + + err = uart_irq_callback_set(uart_dev_aux, interrupt_driven_uart_callback_aux_uart); + zassert_equal(err, 0, "Unexpected error when setting callback for UART1 %d", err); + err = uart_irq_callback_user_data_set(uart_dev_aux, interrupt_driven_uart_callback_aux_uart, + (void *)test_buffer_aux); + zassert_equal(err, 0, "Unexpected error when setting user data for UART1 callback %d", err); + + uart_irq_err_enable(uart_dev); + uart_irq_err_enable(uart_dev_aux); + + uart_irq_tx_enable(uart_dev); + uart_irq_tx_enable(uart_dev_aux); + + uart_irq_rx_enable(uart_dev); + uart_irq_rx_enable(uart_dev_aux); + + /* wait for the tramission to finish (no polling is intentional) */ + k_sleep(K_USEC(100 * SLEEP_TIME_US)); + + uart_irq_tx_disable(uart_dev); + uart_irq_tx_disable(uart_dev_aux); + uart_irq_rx_disable(uart_dev); + uart_irq_rx_disable(uart_dev_aux); + uart_irq_err_disable(uart_dev); + uart_irq_err_disable(uart_dev_aux); + +#if defined(CONFIG_SETUP_MISMATCH_TEST) + TC_PRINT("Mismatched configuration test\n"); + zassert_not_equal(uart_error_counter + aux_uart_error_counter, 0, + "UART configuration mismatch error not detected"); + +#else + for (int index = 0; index < TEST_BUFFER_LEN; index++) { + zassert_equal(test_buffer[index], test_pattern[index], + "UART0 recieived data byte %d does not match pattern 0x%x != 0x%x", + index, test_buffer[index], test_pattern[index]); + zassert_equal(test_buffer_aux[index], test_pattern[index], + "UART1 recieived data byte %d does not match pattern 0x%x != 0x%x", + index, test_buffer_aux[index], test_pattern[index]); + } +#endif /* CONFIG_SETUP_MISMATCH_TEST */ +} +#endif /* CONFIG_DUAL_UART_TEST */ + +/* + * Test setup + */ +void *test_setup(void) +{ + zassert_true(device_is_ready(uart_dev), "UART0 device is not ready"); +#if defined(CONFIG_DUAL_UART_TEST) + zassert_true(device_is_ready(uart_dev_aux), "UART1 device is not ready"); +#endif + + return NULL; +} + +ZTEST_SUITE(uart_elementary, NULL, test_setup, NULL, NULL, NULL); diff --git a/tests/drivers/uart/uart_elementary/testcase.yaml b/tests/drivers/uart/uart_elementary/testcase.yaml new file mode 100644 index 000000000000..d8aa90d0536a --- /dev/null +++ b/tests/drivers/uart/uart_elementary/testcase.yaml @@ -0,0 +1,43 @@ +common: + tags: drivers uart + depends_on: gpio + harness: ztest + harness_config: + fixture: gpio_loopback +tests: + drivers.uart.uart_elementary: + filter: CONFIG_SERIAL_SUPPORT_INTERRUPT + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + - nrf54l15pdk/nrf54l15/cpuapp + - nrf5340dk/nrf5340/cpuapp + drivers.uart.uart_elementary_dual_nrf54h: + filter: CONFIG_SERIAL_SUPPORT_INTERRUPT + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + extra_args: DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_dual_uart.overlay" + extra_configs: + - CONFIG_DUAL_UART_TEST=y + drivers.uart.uart_elementary_dual_setup_mismatch_nrf54h: + filter: CONFIG_SERIAL_SUPPORT_INTERRUPT + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + extra_args: DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_dual_uart.overlay" + extra_configs: + - CONFIG_DUAL_UART_TEST=y + - CONFIG_SETUP_MISMATCH_TEST=y + drivers.uart.uart_elementary_dual_nrf54l: + filter: CONFIG_SERIAL_SUPPORT_INTERRUPT + platform_allow: + - nrf54l15pdk/nrf54l15/cpuapp + extra_args: DTC_OVERLAY_FILE="boards/nrf54l15pdk_nrf54l15_cpuapp_dual_uart.overlay" + extra_configs: + - CONFIG_DUAL_UART_TEST=y + drivers.uart.uart_elementary_dual_setup_mismatch_nrf54l: + filter: CONFIG_SERIAL_SUPPORT_INTERRUPT + platform_allow: + - nrf54l15pdk/nrf54l15/cpuapp + extra_args: DTC_OVERLAY_FILE="boards/nrf54l15pdk_nrf54l15_cpuapp_dual_uart.overlay" + extra_configs: + - CONFIG_DUAL_UART_TEST=y + - CONFIG_SETUP_MISMATCH_TEST=y diff --git a/tests/drivers/uart/uart_pm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/uart/uart_pm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..d01ebce4c8af --- /dev/null +++ b/tests/drivers/uart/uart_pm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + uart135_default_alt: uart135_default_alt { + group1 { + psels = , + ; + }; + }; + + uart135_sleep_alt: uart135_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +dut: &uart135 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart135_default_alt>; + pinctrl-1 = <&uart135_sleep_alt>; + pinctrl-names = "default", "sleep"; + memory-regions = <&cpuapp_dma_region>; +}; diff --git a/tests/drivers/uart/uart_pm/src/main.c b/tests/drivers/uart/uart_pm/src/main.c index 7f3782ee615e..07e75ec8dd65 100644 --- a/tests/drivers/uart/uart_pm/src/main.c +++ b/tests/drivers/uart/uart_pm/src/main.c @@ -34,7 +34,10 @@ static void polling_verify(const struct device *dev, bool is_async, bool active) for (int i = 0; i < ARRAY_SIZE(outs); i++) { uart_poll_out(dev, outs[i]); - k_busy_wait(1000); + /* We need to wait until receiver gets the data. Receiver may have + * RX timeout so data is not received instantly. + */ + k_busy_wait(5000); if (active) { err = uart_poll_in(dev, &c); @@ -78,6 +81,12 @@ static bool async_verify(const struct device *dev, bool active) zassert_equal(err, 0, "Unexpected err: %d", err); + /* Wait a bit to ensure that polling transfer is already finished otherwise + * receiver might be enabled when there is an ongoing transfer and bytes + * will get corrupted. + */ + k_busy_wait(1000); + if (!DISABLED_RX) { err = uart_rx_enable(dev, rxbuf, sizeof(rxbuf), 1 * USEC_PER_MSEC); zassert_equal(err, 0, "Unexpected err: %d", err); @@ -90,7 +99,7 @@ static bool async_verify(const struct device *dev, bool active) if (!DISABLED_RX) { err = uart_rx_disable(dev); - zassert_equal(err, 0, "Unexpected err: %d", err); + zassert_true((err == 0) || (err == -EFAULT)); k_busy_wait(10000); @@ -203,36 +212,36 @@ ZTEST(uart_pm, test_uart_pm_poll_tx) communication_verify(dev, true); } -static void timeout(struct k_timer *timer) +static void work_handler(struct k_work *work) { - const struct device *uart = k_timer_user_data_get(timer); + const struct device *dev = DEVICE_DT_GET(UART_NODE); - action_run(uart, PM_DEVICE_ACTION_SUSPEND, 0); + action_run(dev, PM_DEVICE_ACTION_SUSPEND, 0); } -static K_TIMER_DEFINE(pm_timer, timeout, NULL); - /* Test going into low power state after interrupting poll out. Use various * delays to test interruption at multiple places. */ ZTEST(uart_pm, test_uart_pm_poll_tx_interrupted) { + static struct k_work_delayable dwork; + static struct k_work_sync sync; const struct device *dev; char str[] = "test"; dev = DEVICE_DT_GET(UART_NODE); zassert_true(device_is_ready(dev), "uart device is not ready"); - k_timer_user_data_set(&pm_timer, (void *)dev); + k_work_init_delayable(&dwork, work_handler); for (int i = 1; i < 100; i++) { - k_timer_start(&pm_timer, K_USEC(i * 10), K_NO_WAIT); + k_work_schedule(&dwork, K_USEC(i * 10)); for (int j = 0; j < sizeof(str); j++) { uart_poll_out(dev, str[j]); } - k_timer_status_sync(&pm_timer); + k_work_flush_delayable(&dwork, &sync); action_run(dev, PM_DEVICE_ACTION_RESUME, 0); diff --git a/tests/drivers/uart/uart_pm/testcase.yaml b/tests/drivers/uart/uart_pm/testcase.yaml index f90eed739499..c7c7b803442e 100644 --- a/tests/drivers/uart/uart_pm/testcase.yaml +++ b/tests/drivers/uart/uart_pm/testcase.yaml @@ -5,6 +5,8 @@ common: harness: ztest platform_allow: - nrf52840dk/nrf52840 + - nrf54l15pdk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp - nrf52_bsim harness_config: fixture: gpio_loopback @@ -24,6 +26,9 @@ tests: - CONFIG_UART_0_ENHANCED_POLL_OUT=n - CONFIG_UART_NRFX_UARTE_LEGACY_SHIM=y extra_args: DTC_OVERLAY_FILE="boards/nrf52840dk_nrf52840.overlay;nrf_rx_disable.overlay" + platform_exclude: + - nrf54l15pdk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp drivers.uart.pm.enhanced_poll: extra_configs: @@ -31,6 +36,9 @@ tests: - CONFIG_UART_ASYNC_API=n - CONFIG_UART_0_ENHANCED_POLL_OUT=y - CONFIG_UART_NRFX_UARTE_LEGACY_SHIM=y + platform_exclude: + - nrf54l15pdk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp drivers.uart.pm.int_driven: extra_configs: @@ -47,6 +55,9 @@ tests: - CONFIG_UART_ASYNC_API=n - CONFIG_UART_0_ENHANCED_POLL_OUT=y - CONFIG_UART_NRFX_UARTE_LEGACY_SHIM=y + platform_exclude: + - nrf54l15pdk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp drivers.uart.pm.async: extra_configs: @@ -69,3 +80,6 @@ tests: - CONFIG_NRFX_TIMER2=y - CONFIG_UART_0_ENHANCED_POLL_OUT=y - CONFIG_UART_NRFX_UARTE_LEGACY_SHIM=y + platform_exclude: + - nrf54l15pdk/nrf54l15/cpuapp + - nrf54h20dk/nrf54h20/cpuapp diff --git a/tests/drivers/watchdog/wdt_error_cases/CMakeLists.txt b/tests/drivers/watchdog/wdt_error_cases/CMakeLists.txt new file mode 100644 index 000000000000..12c8c39535d7 --- /dev/null +++ b/tests/drivers/watchdog/wdt_error_cases/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(wdt_error_cases) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/drivers/watchdog/wdt_error_cases/README.txt b/tests/drivers/watchdog/wdt_error_cases/README.txt new file mode 100644 index 000000000000..fcf9173ee93f --- /dev/null +++ b/tests/drivers/watchdog/wdt_error_cases/README.txt @@ -0,0 +1,79 @@ +This test suite contains negative test cases for the Watchdog driver. +Test scenarios validate that invalid use of the watchdog driver +returns error code as described in the API documentation +(or Assertion Fail as explained below). + +Ideally, the driver shall be fully compliant with the documentation. +However, it may happen that invalid function call results in +Assertion Fail instead of error code. +Since, main goal is to detect (and report) invalid use of the driver, +both error code and assertion fail set test result as passed. +See for example test_02_wdt_setup_before_setting_timeouts where +ztest_set_assert_valid(true); +is used to catch assertion fail. + +These tests were written to increase test coverage for the Watchdog driver. +Since, coverage data is stored in the RAM, it is lost when watchdog fires. +Therefore, in all test cases watchdog shall NOT expire. +Use other sample to verify positive scenario for the watchdog driver. + +These tests were prepared on a target that had a bug in the wdt_disable() +implementation. As a temporary remedy, order of tests was imposed. +Since, tests are executed alphabetically, order was set by starting +each test name with f.e. 'test_08b_...'. + + +Tests are based on the watchdog API documentation available here: +https://docs.zephyrproject.org/latest/hardware/peripherals/watchdog.html + + +Follow these guidelines when enabling test execution on a new target. + +1. Although, code defines WDT_DISABLE_SUPPORTED but it was tested on a + target that supports disabling the watchdog. + Multiple tests call wdt_setup() which starts the watchdog. + Every test assumes that watchdog is disabled at startup. + As a result, executing this test suite on a target that doesn't + support wdt_disable() may require changes to the code. + When target supports wdt_disable() then extend WDT_TEST_FLAGS with: + #define WDT_TEST_FLAGS (... | WDT_DISABLE_SUPPORTED) + +2. There are three watchdog flags that can be passed to wdt_install_timeout(): + - WDT_FLAG_RESET_NONE - when watchdog expires, it's callback is serviced but + reset doesn't occur. + - WDT_FLAG_RESET_CPU_CORE - when watchdog expires, only one core is reset, while + other cores are not affected. + - WDT_FLAG_RESET_SOC - when watchdog expires, target as "a whole" is reset. + Support for these flags varies between vendors and products. + a) List all supported flags in + #define WDT_TEST_FLAGS (... | WDT_FLAG_RESET_NONE_SUPPORTED | + WDT_FLAG_RESET_CPU_CORE_SUPPORTED | + WDT_FLAG_RESET_SOC_SUPPORTED) + b) Set supported flag in + #define DEFAULT_FLAGS (WDT_FLAG_RESET_SOC) + This define will be used in wdt_install_timeout() "correct" test step. + +3. These tests assume that watchdog driver supports multiple timeouts. Set + #define MAX_INSTALLABLE_TIMEOUTS (8) + +4. When all watchdog timeouts must have exactly the same watchdog timeout value + then extend WDT_TEST_FLAGS with: + #define WDT_TEST_FLAGS (... | WDT_FLAG_ONLY_ONE_TIMEOUT_VALUE_SUPPORTED) + +5. Set maximal allowed watchdog timeout value, f.e.: + #define WDT_WINDOW_MAX_ALLOWED (0xFFFFFFFFU) + Also, test assumes that minimal allowed watchdog timeout value must be zero. + +6. There are two watchdog options that can be passed to wdt_setup(): + - WDT_OPT_PAUSE_IN_SLEEP; + - WDT_OPT_PAUSE_HALTED_BY_DBG. + Support for these options varies between vendors and products. + a) List all supported options in + #define WDT_TEST_FLAGS (... | WDT_OPT_PAUSE_IN_SLEEP_SUPPORTED | + WDT_OPT_PAUSE_HALTED_BY_DBG_SUPPORTED) + b) Set supported option(s) in + #define DEFAULT_OPTIONS (WDT_OPT_PAUSE_IN_SLEEP | WDT_OPT_PAUSE_HALTED_BY_DBG) + This define will be used in wdt_setup() "correct" test step. + +7. When wdt_feed() can stall, extend WDT_TEST_FLAGS with: + #define WDT_TEST_FLAGS (... | WDT_FEED_CAN_STALL) diff --git a/tests/drivers/watchdog/wdt_error_cases/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/tests/drivers/watchdog/wdt_error_cases/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay new file mode 100644 index 000000000000..8d3dce3b3800 --- /dev/null +++ b/tests/drivers/watchdog/wdt_error_cases/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&wdt31 { + status = "okay"; +}; diff --git a/tests/drivers/watchdog/wdt_error_cases/prj.conf b/tests/drivers/watchdog/wdt_error_cases/prj.conf new file mode 100644 index 000000000000..be8069f78b46 --- /dev/null +++ b/tests/drivers/watchdog/wdt_error_cases/prj.conf @@ -0,0 +1,3 @@ +CONFIG_ZTEST=y +CONFIG_ZTEST_ASSERT_HOOK=y +CONFIG_WATCHDOG=y diff --git a/tests/drivers/watchdog/wdt_error_cases/src/main.c b/tests/drivers/watchdog/wdt_error_cases/src/main.c new file mode 100644 index 000000000000..fc453ba3b321 --- /dev/null +++ b/tests/drivers/watchdog/wdt_error_cases/src/main.c @@ -0,0 +1,960 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +/* + * To use this test, either the devicetree's /aliases must have a + * 'watchdog0' property, or one of the following watchdog compatibles + * must have an enabled node. + */ +#if DT_NODE_HAS_STATUS(DT_ALIAS(watchdog0), okay) +#define WDT_NODE DT_ALIAS(watchdog0) +#elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_wdt) +#define WDT_NODE DT_INST(0, nordic_nrf_wdt) +#elif DT_HAS_COMPAT_STATUS_OKAY(zephyr_counter_watchdog) +#define WDT_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(zephyr_counter_watchdog) +#endif + +#if DT_NODE_HAS_STATUS(DT_CHOSEN(zephyr_dtcm), okay) +#define NOINIT_SECTION ".dtcm_noinit.test_wdt" +#else +#define NOINIT_SECTION ".noinit.test_wdt" +#endif + +/* Bit fields used to select tests to be run on the target */ +#define WDT_DISABLE_SUPPORTED BIT(0) +#define WDT_FLAG_RESET_NONE_SUPPORTED BIT(1) +#define WDT_FLAG_RESET_CPU_CORE_SUPPORTED BIT(2) +#define WDT_FLAG_RESET_SOC_SUPPORTED BIT(3) +#define WDT_FLAG_ONLY_ONE_TIMEOUT_VALUE_SUPPORTED BIT(4) +#define WDT_OPT_PAUSE_IN_SLEEP_SUPPORTED BIT(5) +#define WDT_OPT_PAUSE_HALTED_BY_DBG_SUPPORTED BIT(6) +#define WDT_FEED_CAN_STALL BIT(7) + +/* Common for all targets: */ +#define DEFAULT_WINDOW_MAX (500U) +#define DEFAULT_WINDOW_MIN (0U) + +/* Align tests to the specific target: */ +#if defined(CONFIG_SOC_NRF54L15) +#define WDT_TEST_FLAGS \ + (WDT_DISABLE_SUPPORTED | WDT_FLAG_RESET_SOC_SUPPORTED | \ + WDT_FLAG_ONLY_ONE_TIMEOUT_VALUE_SUPPORTED | WDT_OPT_PAUSE_IN_SLEEP_SUPPORTED | \ + WDT_OPT_PAUSE_HALTED_BY_DBG_SUPPORTED) +#define DEFAULT_FLAGS (WDT_FLAG_RESET_SOC) +#define MAX_INSTALLABLE_TIMEOUTS (8) +#define WDT_WINDOW_MAX_ALLOWED (0x07CFFFFFU) +#define DEFAULT_OPTIONS (WDT_OPT_PAUSE_IN_SLEEP | WDT_OPT_PAUSE_HALTED_BY_DBG) +#else +/* By default run most of the error checks. + * See Readme.txt on how to align test scope for the specific target. + */ +#define WDT_TEST_FLAGS \ + (WDT_DISABLE_SUPPORTED | WDT_FLAG_RESET_SOC_SUPPORTED | \ + WDT_FLAG_ONLY_ONE_TIMEOUT_VALUE_SUPPORTED) +#define DEFAULT_FLAGS (WDT_FLAG_RESET_SOC) +#define MAX_INSTALLABLE_TIMEOUTS (8) +#define WDT_WINDOW_MAX_ALLOWED (0xFFFFFFFFU) +#define DEFAULT_OPTIONS (WDT_OPT_PAUSE_IN_SLEEP) +#endif + +static const struct device *const wdt = DEVICE_DT_GET(WDT_NODE); +static struct wdt_timeout_cfg m_cfg_wdt0; + +/* Following variables are incremented in WDT callbacks + * to indicate whether interrupt was fired or not. + */ +volatile uint32_t m_test_06b_value __attribute__((section(NOINIT_SECTION))); +#define TEST_06B_TAG (0x12345678U) +volatile uint32_t m_test_08b_value __attribute__((section(NOINIT_SECTION))); +#define TEST_08B_TAG (0x23456789U) +volatile uint32_t m_test_08d_A_value __attribute__((section(NOINIT_SECTION))); +#define TEST_08D_A_TAG (0x3456789AU) +volatile uint32_t m_test_08d_B_value __attribute__((section(NOINIT_SECTION))); +#define TEST_08D_B_TAG (0x456789ABU) + +static void wdt_test_06b_cb(const struct device *wdt_dev, int channel_id) +{ + ARG_UNUSED(wdt_dev); + ARG_UNUSED(channel_id); + m_test_06b_value = TEST_06B_TAG; +} + +static void wdt_test_08b_cb(const struct device *wdt_dev, int channel_id) +{ + ARG_UNUSED(wdt_dev); + ARG_UNUSED(channel_id); + m_test_08b_value = TEST_08B_TAG; +} + +static void wdt_test_08d_A_cb(const struct device *wdt_dev, int channel_id) +{ + ARG_UNUSED(wdt_dev); + ARG_UNUSED(channel_id); + m_test_08d_A_value = TEST_08D_A_TAG; +} + +static void wdt_test_08d_B_cb(const struct device *wdt_dev, int channel_id) +{ + ARG_UNUSED(wdt_dev); + ARG_UNUSED(channel_id); + m_test_08d_B_value = TEST_08D_B_TAG; +} + +/** + * @brief wdt_disable() negative test + * + * Confirm that wdt_disable() returns + * -EFAULT when watchdog instance is not enabled. + * + */ +ZTEST(wdt_coverage, test_01_wdt_disable_before_wdt_setup) +{ + int ret; + + if (!(WDT_TEST_FLAGS & WDT_DISABLE_SUPPORTED)) { + /* Skip this test because wdt_disable() is NOT supported. */ + ztest_test_skip(); + } + + /* Call wdt_disable before enabling wdt */ + ret = wdt_disable(wdt); + zassert_true(ret == -EFAULT, + "Calling wdt_disable before watchdog was started should return -EFAULT (-14), " + "got unexpected value of %d", + ret); +} + +/** + * @brief wdt_setup() negative test + * + * Confirm that wdt_setup() returns error value or ASSERTION FAIL + * when it's called before wdt_install_timeouts(). + * + */ +ZTEST(wdt_coverage, test_02_wdt_setup_before_setting_timeouts) +{ + int ret; + + /* Call wdt_setup before wdt_install_timeouts() */ + ztest_set_assert_valid(true); + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret < 0, + "Calling wdt_setup before installing timeouts should fail, got unexpected " + "value of %d", + ret); +} + +/** + * @brief wdt_feed() negative test + * + * Confirm that wdt_feed() returns error value + * when it's called before wdt_setup(). + * Test scenario where none of timeout channels is configured. + * + */ +ZTEST(wdt_coverage, test_03_wdt_feed_before_wdt_setup_channel_not_configured) +{ + int ret; + + /* Call wdt_feed() before wdt_setup() (channel wasn't configured) */ + ret = wdt_feed(wdt, 0); + zassert_true(ret == -EINVAL, + "wdt_feed() shall return error value when called before wdt_setup(), got " + "unexpected value of %d", + ret); +} + +/** + * @brief wdt_install_timeout() negative test + * + * Confirm that wdt_install_timeout() returns + * -ENOTSUP when flag WDT_FLAG_RESET_NONE is not supported + * + */ +ZTEST(wdt_coverage, test_04a_wdt_install_timeout_WDT_FLAG_RESET_NONE_not_supported) +{ + int ret; + + if (WDT_TEST_FLAGS & WDT_FLAG_RESET_NONE_SUPPORTED) { + /* Skip this test because WDT_FLAG_RESET_NONE is supported. */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = WDT_FLAG_RESET_NONE; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -ENOTSUP, + "WDT_FLAG_RESET_NONE is not supported on this target and should fail, got " + "unexpected value of %d", + ret); +} + +/** + * @brief wdt_install_timeout() negative test + * + * Confirm that wdt_install_timeout() returns + * -ENOTSUP when flag WDT_FLAG_RESET_CPU_CORE is not supported + * + */ +ZTEST(wdt_coverage, test_04b_wdt_install_timeout_WDT_FLAG_RESET_CPU_CORE_not_supported) +{ + int ret; + + if (WDT_TEST_FLAGS & WDT_FLAG_RESET_CPU_CORE_SUPPORTED) { + /* Skip this test because WDT_FLAG_RESET_CPU_CORE is supported. */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = WDT_FLAG_RESET_CPU_CORE; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -ENOTSUP, + "WDT_FLAG_RESET_CPU_CORE is not supported on this target and should fail, got " + "unexpected value of %d", + ret); +} + +/** + * @brief wdt_install_timeout() negative test + * + * Confirm that wdt_install_timeout() returns + * -ENOTSUP when flag WDT_FLAG_RESET_SOC is not supported + * + */ +ZTEST(wdt_coverage, test_04c_wdt_install_timeout_WDT_FLAG_RESET_SOC_not_supported) +{ + int ret; + + if (WDT_TEST_FLAGS & WDT_FLAG_RESET_SOC_SUPPORTED) { + /* Skip this test because WDT_FLAG_RESET_SOC is supported. */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = WDT_FLAG_RESET_SOC; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -ENOTSUP, + "WDT_FLAG_RESET_SOC is not supported on this target and should fail, got " + "unexpected value of %d", + ret); +} + +/** + * @brief wdt_install_timeout() negative test + * + * Confirm that wdt_install_timeout() returns + * -EINVAL when window timeout is out of possible range + * + */ +ZTEST(wdt_coverage, test_04w_wdt_install_timeout_with_invalid_window) +{ + int ret; + + /* set defaults */ + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + /* ----------------- window.min + * Check that window.min can't be different than 0 + */ + m_cfg_wdt0.window.min = 1U; + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -EINVAL, + "Calling wdt_install_timeout with window.min = 1 should return -EINVAL (-22), " + "got unexpected value of %d", + ret); + + /* Set default window.min */ + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + /* ----------------- window.max + * Check that window.max can't be equal to 0 + */ + m_cfg_wdt0.window.max = 0U; + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -EINVAL, + "Calling wdt_install_timeout with window.max = 0 should return -EINVAL (-22), " + "got unexpected value of %d", + ret); + + /* Check that window.max can't exceed maximum allowed value */ + m_cfg_wdt0.window.max = WDT_WINDOW_MAX_ALLOWED + 1; + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -EINVAL, + "Calling wdt_install_timeout with window.max = %d should return -EINVAL " + "(-22), got unexpected value of %d", + WDT_WINDOW_MAX_ALLOWED + 1, ret); +} + +/** + * @brief wdt_install_timeout() negative test + * + * Confirm that wdt_install_timeout() returns + * -EINVAL when watchdog supports only one timeout value + * for all timeouts and the supplied timeout window differs + * from windows for alarms installed so far. + * + */ +ZTEST(wdt_coverage, test_04wm_wdt_install_timeout_with_multiple_timeout_values) +{ + int ret; + + if (!(WDT_TEST_FLAGS & WDT_FLAG_ONLY_ONE_TIMEOUT_VALUE_SUPPORTED)) { + /* Skip this test because timeouts with different values are supported */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + /* Call wdt_install_timeout again with different window */ + m_cfg_wdt0.window.max = WDT_WINDOW_MAX_ALLOWED >> 1; + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -EINVAL, + "wdt_install_timeout should return -EINVAL (-22), got unexpected value of %d", + ret); +} + +/** + * @brief wdt_install_timeout() negative test + * + * Confirm that wdt_install_timeout() returns ASSERTION FAIL or + * -EBUSY when called after the watchdog instance has been already setup. + * + */ +ZTEST(wdt_coverage, test_05_wdt_install_timeout_after_wdt_setup) +{ + int ret; + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + + /* Call wdt_install_timeout again to test invalid use */ + ztest_set_assert_valid(true); + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -EBUSY, + "Calling wdt_install_timeout after wdt_setup should return -EBUSY (-16), got " + "unexpected value of %d", + ret); + + /* Assumption: wdt_disable() is called after this test */ +} + +/** + * @brief wdt_setup() negative test + * + * Confirm that wdt_setup() returns + * -ENOTSUP when option WDT_OPT_PAUSE_IN_SLEEP is not supported + * + */ +ZTEST(wdt_coverage, test_06a_wdt_setup_WDT_OPT_PAUSE_IN_SLEEP_not_supported) +{ + int ret; + + if (WDT_TEST_FLAGS & WDT_OPT_PAUSE_IN_SLEEP_SUPPORTED) { + /* Skip this test because WDT_OPT_PAUSE_IN_SLEEP is supported. */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + ret = wdt_setup(wdt, WDT_OPT_PAUSE_IN_SLEEP); + zassert_true(ret == -ENOTSUP, + "WDT_OPT_PAUSE_IN_SLEEP is not supported on this target and should fail, got " + "unexpected value of %d", + ret); + + ret = wdt_setup(wdt, WDT_OPT_PAUSE_IN_SLEEP | WDT_OPT_PAUSE_HALTED_BY_DBG); + zassert_true(ret == -ENOTSUP, + "WDT_OPT_PAUSE_IN_SLEEP is not supported on this target and should fail, got " + "unexpected value of %d", + ret); +} + +/** + * @brief Test that wdt_setup(device, WDT_OPT_PAUSE_IN_SLEEP) works as expected + * + * Confirm that when WDT_OPT_PAUSE_IN_SLEEP is set, + * watchdog will not fire when thread is sleeping. + * + */ +ZTEST(wdt_coverage, test_06b_wdt_setup_WDT_OPT_PAUSE_IN_SLEEP_functional) +{ + int ret; + + if (!(WDT_TEST_FLAGS & WDT_OPT_PAUSE_IN_SLEEP_SUPPORTED)) { + /* Skip this test because WDT_OPT_PAUSE_IN_SLEEP can NOT be used. */ + ztest_test_skip(); + } + + /* When test fails, watchdog sets m_test_06b_value to TEST_06B_TAG in WDT callback + * wdt_test_06b_cb. Then, target is reset. Check value of m_test_06b_value to prevent reset + * loop on this test. + */ + if (m_test_06b_value == TEST_06B_TAG) { + m_test_06b_value = 0U; + zassert_true(false, "Watchod has fired while it shouldn't"); + } + + /* Clear flag that is set when the watchdog fires */ + m_test_06b_value = 0U; + + m_cfg_wdt0.callback = wdt_test_06b_cb; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + /* Set timeout window to ~500 ms */ + m_cfg_wdt0.window.max = 500U; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + ret = wdt_setup(wdt, WDT_OPT_PAUSE_IN_SLEEP); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + TC_PRINT("Test has failed if there is reset after this line\n"); + + /* Sleep for longer time than watchdog timeout */ + k_sleep(K_SECONDS(1)); + + /* m_test_06b_value is set to TEST_06B_TAG in WDT callback */ + zassert_equal(m_test_06b_value, 0, "Watchod has fired while it shouldn't"); + + /* Assumption: wdt_disable() is called after each test */ +} + +/** + * @brief wdt_setup() negative test + * + * Confirm that wdt_setup() returns + * -ENOTSUP when option WDT_OPT_PAUSE_HALTED_BY_DBG is not supported + * + */ +ZTEST(wdt_coverage, test_06c_wdt_setup_WDT_OPT_PAUSE_HALTED_BY_DBG_not_supported) +{ + int ret; + + if (WDT_TEST_FLAGS & WDT_OPT_PAUSE_HALTED_BY_DBG_SUPPORTED) { + /* Skip this test because WDT_OPT_PAUSE_HALTED_BY_DBG is supported. */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + ret = wdt_setup(wdt, WDT_OPT_PAUSE_HALTED_BY_DBG); + zassert_true(ret == -ENOTSUP, + "WDT_OPT_PAUSE_HALTED_BY_DBG is not supported on this target and should fail, " + "got unexpected value of %d", + ret); + + ret = wdt_setup(wdt, WDT_OPT_PAUSE_IN_SLEEP | WDT_OPT_PAUSE_HALTED_BY_DBG); + zassert_true(ret == -ENOTSUP, + "WDT_OPT_PAUSE_HALTED_BY_DBG is not supported on this target and should fail, " + "got unexpected value of %d", + ret); +} + +/** + * @brief wdt_setup() corner case + * + * Confirm that wdt_setup() returns + * 0 - success, when no option is provided + * + */ +ZTEST(wdt_coverage, test_06d_wdt_setup_without_any_OPT) +{ + int ret; + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + ret = wdt_setup(wdt, 0x0); + zassert_true(ret == 0, "Got unexpected value of %d, while expected is 0", ret); +} + +/** + * @brief wdt_setup() negative test + * + * Confirm that wdt_setup() returns + * -EBUSY when watchdog instance has been already setup. + * + */ +ZTEST(wdt_coverage, test_07_wdt_setup_already_done) +{ + int ret; + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + + /* Call wdt_setup again to test invalid use */ + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == -EBUSY, + "Calling wdt_setup for the second time should return -EBUSY (-16), got " + "unexpected value of %d", + ret); + + /* Assumption: wdt_disable() is called after this test */ +} + +/** + * @brief wdt_setup() negative test + * + * Confirm that wdt_disable() returns + * -EPERM when watchdog can not be disabled directly by application code. + * + */ +ZTEST(wdt_coverage, test_08a_wdt_disable_not_supported) +{ + int ret; + + if (WDT_TEST_FLAGS & WDT_DISABLE_SUPPORTED) { + /* Skip this test because wdt_disable() is supported. */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + /* Assumption - test suite execution finishes before WDT timeout will fire */ + m_cfg_wdt0.window.max = WDT_WINDOW_MAX_ALLOWED; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + + /* Call wdt_disable to test not allowed use */ + ret = wdt_disable(wdt); + zassert_true(ret == -EPERM, + "Disabling WDT is not supported on this target and should return -EPERM (-1), " + "got unexpected value of %d", + ret); +} + +/** + * @brief Test that wdt_disable() stops watchdog + * + * Confirm that wdt_disable() prevents previously configured + * watchdog from resetting the core. + * + */ +ZTEST(wdt_coverage, test_08b_wdt_disable_check_not_firing) +{ + int ret; + + if (!(WDT_TEST_FLAGS & WDT_DISABLE_SUPPORTED)) { + /* Skip this test because wdt_disable() is NOT supported. */ + ztest_test_skip(); + } + + /* When test fails, watchdog sets m_test_08b_value to TEST_08B_TAG in WDT callback + * wdt_test_08b_cb. Then, target is reset. Check value of m_test_08b_value to prevent reset + * loop on this test. + */ + if (m_test_08b_value == TEST_08B_TAG) { + m_test_08b_value = 0U; + zassert_true(false, "Watchod has fired while it shouldn't"); + } + + /* Clear flag that is set when the watchdog fires */ + m_test_08b_value = 0U; + + m_cfg_wdt0.callback = wdt_test_08b_cb; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + /* Set timeout window to ~500 ms */ + m_cfg_wdt0.window.max = 500U; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret >= 0, "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + TC_PRINT("Test has failed if there is reset after this line\n"); + + /* Wait for 450 ms, then disable the watchdog + * Don't change to k_sleep() because use of WDT_OPT_PAUSE_IN_SLEEP + * will break test scenario. + */ + k_busy_wait(450000); + ret = wdt_disable(wdt); + zassert_true(ret == 0, "Watchdog disable error, got unexpected value of %d", ret); + + /* Wait a bit more to see if watchdog fires + * Don't change to k_sleep() because use of WDT_OPT_PAUSE_IN_SLEEP + * will break test scenario. + */ + k_busy_wait(300000); + + /* m_test_08b_value is set to TEST_08B_TAG in WDT callback */ + zassert_equal(m_test_08b_value, 0, "Watchod has fired while it shouldn't"); +} + +/** + * @brief Test that after wdt_disable() timeouts can be reconfigured + * + * Confirm that after wdt_disable() it is possible to configure + * timeout channel that was configured previously. + * + */ +ZTEST(wdt_coverage, test_08c_wdt_disable_check_timeouts_reusable) +{ + int ret, id1, id2; + + if (!(WDT_TEST_FLAGS & WDT_DISABLE_SUPPORTED)) { + /* Skip this test because wdt_disable() is NOT supported. */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + id1 = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(id1 >= 0, "Watchdog install error, got unexpected value of %d", id1); + TC_PRINT("Configured WDT channel %d\n", id1); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + + ret = wdt_disable(wdt); + zassert_true(ret == 0, "Watchdog disable error, got unexpected value of %d", ret); + + id2 = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(id2 >= 0, "Watchdog install error, got unexpected value of %d", id2); + TC_PRINT("Configured WDT channel %d\n", id2); + + /* test that timeout channel id2 is NOT greater than previously returned channel id1 */ + zassert_true(id2 <= id1, + "First usable timeout channel after wdt_disable() is %d, expected number no " + "greater than %d", + id2, id1); +} + +/** + * @brief Test that after wdt_disable() uninstalled timeouts don't have to be feed + * + * Confirm that wdt_disable() uninstalls all timeouts. + * When new timeout is configured, only this one has to be feed. + * + */ +ZTEST(wdt_coverage, test_08d_wdt_disable_check_timeouts_uninstalled) +{ + int ret, id_A, id_B, i; + + if (!(WDT_TEST_FLAGS & WDT_DISABLE_SUPPORTED)) { + /* Skip this test because wdt_disable() is NOT supported. */ + ztest_test_skip(); + } + + /* m_test_08d_A_value is set to TEST_08D_A_TAG in callback wdt_test_08d_A_cb */ + if (m_test_08d_A_value == TEST_08D_A_TAG) { + m_test_08d_A_value = 0U; + zassert_true(false, "Timeout A has fired while it shouldn't"); + } + + /* m_test_08d_B_value is set to TEST_08D_B_TAG in callback wdt_test_08d_B_cb */ + if (m_test_08d_B_value == TEST_08D_B_TAG) { + m_test_08d_B_value = 0U; + zassert_true(false, "Timeout B has fired while it shouldn't"); + } + + /* Clear flags that are set when the watchdog fires */ + m_test_08d_A_value = 0U; + m_test_08d_B_value = 0U; + + /* Configure Timeout A */ + m_cfg_wdt0.callback = wdt_test_08d_A_cb; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + /* Set timeout window to ~500 ms */ + m_cfg_wdt0.window.max = 500U; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + id_A = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(id_A >= 0, "Watchdog install error, got unexpected value of %d", id_A); + TC_PRINT("Configured WDT channel %d\n", id_A); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + + ret = wdt_disable(wdt); + zassert_true(ret == 0, "Watchdog disable error, got unexpected value of %d", ret); + + /* Configure Timeout B */ + m_cfg_wdt0.callback = wdt_test_08d_B_cb; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + /* Set timeout window to ~500 ms */ + m_cfg_wdt0.window.max = 500U; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + id_B = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(id_B >= 0, "Watchdog install error, got unexpected value of %d", id_B); + TC_PRINT("Configured WDT channel %d\n", id_B); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + TC_PRINT("Test has failed if there is reset after this line\n"); + + /* Confirm that only Timeout B has to be feed */ + for (i = 0; i < 4; i++) { + k_busy_wait(450000); + wdt_feed(wdt, id_B); + } + + ret = wdt_disable(wdt); + zassert_true(ret == 0, "Watchdog disable error, got unexpected value of %d", ret); + + /* m_test_08d_A_value is set to TEST_08D_A_TAG in callback wdt_test_08d_A_cb */ + zassert_equal(m_test_08d_A_value, 0, "Timeout A has fired while it shouldn't"); + + /* m_test_08d_B_value is set to TEST_08D_B_TAG in callback wdt_test_08d_B_cb */ + zassert_equal(m_test_08d_B_value, 0, "Timeout B has fired while it shouldn't"); +} + +/** + * @brief wdt_feed() negative test + * + * Confirm that wdt_feed() returns error or ASSERTION FAIL + * when it's called before wdt_setup(). + * Test scenario where timeout channel is configured. + * + */ +ZTEST(wdt_coverage, test_09a_wdt_feed_before_wdt_setup_channel_configured) +{ + int ret, ch_id; + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ch_id = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ch_id >= 0, "Watchdog install error, got unexpected value of %d", ch_id); + TC_PRINT("Configured WDT channel %d\n", ch_id); + + /* Call wdt_feed() before wdt_setup() (channel was configured) */ + ztest_set_assert_valid(true); + ret = wdt_feed(wdt, ch_id); + zassert_true(ret < 0, + "wdt_feed() shall return error value when called before wdt_setup(), got " + "unexpected value of %d", + ret); +} + +/** + * @brief wdt_feed() negative test + * + * Confirm that wdt_feed() returns + * -EINVAL when there is no installed timeout for supplied channel. + * + */ +ZTEST(wdt_coverage, test_09b_wdt_feed_invalid_channel) +{ + int ret, ch_id, ch_invalid; + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ch_id = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ch_id >= 0, "Watchdog install error, got unexpected value of %d", ch_id); + TC_PRINT("Configured WDT channel %d\n", ch_id); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + TC_PRINT("Test has failed if there is reset after this line\n"); + + /* Call wdt_feed() on not configured channel */ + ch_invalid = ch_id + 2; + ret = wdt_feed(wdt, ch_invalid); + zassert_true(ret == -EINVAL, + "wdt_feed(%d) shall return -EINVAL (-22), got unexpected value of %d", + ch_invalid, ret); + + /* Call wdt_feed() on not configured channel */ + ch_invalid = ch_id + 1; + ret = wdt_feed(wdt, ch_invalid); + zassert_true(ret == -EINVAL, + "wdt_feed(%d) shall return -EINVAL (-22), got unexpected value of %d", + ch_invalid, ret); + + /* Call wdt_feed() on invalid channel (no such channel) */ + ret = wdt_feed(wdt, -1); + zassert_true(ret == -EINVAL, + "wdt_feed(-1) shall return -EINVAL (-22), got unexpected value of %d", ret); + + /* Call wdt_feed() on invalid channel (no such channel) */ + ret = wdt_feed(wdt, MAX_INSTALLABLE_TIMEOUTS); + zassert_true(ret == -EINVAL, + "wdt_feed(%d) shall return -EINVAL (-22), got unexpected value of %d", + MAX_INSTALLABLE_TIMEOUTS, ret); + + /* Assumption: wdt_disable() is called after each test */ +} + +/** + * @brief wdt_feed() negative test + * + * Confirm that wdt_feed() returns + * -EAGAIN when completing the feed operation would stall the caller, for example + * due to an in-progress watchdog operation such as a previous wdt_feed() call. + * + */ +ZTEST(wdt_coverage, test_09c_wdt_feed_stall) +{ + int ret, ch_id, i; + + if (!(WDT_TEST_FLAGS & WDT_FEED_CAN_STALL)) { + /* Skip this test because wdt_feed() can NOT stall. */ + ztest_test_skip(); + } + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + ch_id = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ch_id >= 0, "Watchdog install error, got unexpected value of %d", ch_id); + TC_PRINT("Configured WDT channel %d\n", ch_id); + + ret = wdt_setup(wdt, DEFAULT_OPTIONS); + zassert_true(ret == 0, "Watchdog setup error, got unexpected value of %d", ret); + TC_PRINT("Test has failed if there is reset after this line\n"); + + for (i = 0; i < 5; i++) { + ret = wdt_feed(wdt, ch_id); + if (i == 0) { + zassert_true(ret == 0, "wdt_feed error, got unexpected value of %d", ret); + } else { + zassert_true( + ret == -EAGAIN, + "wdt_feed shall return -EAGAIN (-11), got unexpected value of %d", + ret); + } + } +} + +/** + * @brief wdt_install_timeout() negative test + * + * Confirm that wdt_install_timeout() returns + * -ENOMEM when no more timeouts can be installed. + * + */ +ZTEST(wdt_coverage, test_10_wdt_install_timeout_max_number_of_timeouts) +{ + int i, ret; + + m_cfg_wdt0.callback = NULL; + m_cfg_wdt0.flags = DEFAULT_FLAGS; + m_cfg_wdt0.window.max = DEFAULT_WINDOW_MAX; + m_cfg_wdt0.window.min = DEFAULT_WINDOW_MIN; + + for (i = 0; i < MAX_INSTALLABLE_TIMEOUTS; i++) { + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + /* Assumption - timeouts are counted from 0 to (MAX_INSTALLABLE_TIMEOUTS - 1) */ + zassert_true(ret < MAX_INSTALLABLE_TIMEOUTS, + "Watchdog install error, got unexpected value of %d", ret); + TC_PRINT("Configured WDT channel %d\n", ret); + } + + /* Call wdt_install_timeout again to test if error value is returned */ + ret = wdt_install_timeout(wdt, &m_cfg_wdt0); + zassert_true(ret == -ENOMEM, + "wdt_install_timeout shall return -ENOMEM (-12), got unexpected value of %d", + ret); +} + +static void *suite_setup(void) +{ + TC_PRINT("Test executed on %s\n", CONFIG_BOARD_TARGET); + TC_PRINT("===================================================================\n"); + + return NULL; +} + +static void before_test(void *not_used) +{ + ARG_UNUSED(not_used); + int ret_val; + + ret_val = device_is_ready(wdt); + zassert_true(ret_val, "WDT device is not ready, got unexpected value of %d", ret_val); +} + +static void cleanup_after_test(void *f) +{ + if (WDT_TEST_FLAGS & WDT_DISABLE_SUPPORTED) { + /* Disable watchdog so it doesn't break other tests */ + wdt_disable(wdt); + } +} + +ZTEST_SUITE(wdt_coverage, NULL, suite_setup, before_test, cleanup_after_test, NULL); diff --git a/tests/drivers/watchdog/wdt_error_cases/testcase.yaml b/tests/drivers/watchdog/wdt_error_cases/testcase.yaml new file mode 100644 index 000000000000..c408d2f8f1d2 --- /dev/null +++ b/tests/drivers/watchdog/wdt_error_cases/testcase.yaml @@ -0,0 +1,13 @@ +common: + tags: + - drivers + - watchdog + depends_on: watchdog + harness: ztest + +tests: + drivers.watchdog.wdt_error_cases: + platform_allow: + - nrf54l15pdk/nrf54l15/cpuapp + integration_platforms: + - nrf54l15pdk/nrf54l15/cpuapp diff --git a/tests/kernel/sched/schedule_api/prj.conf b/tests/kernel/sched/schedule_api/prj.conf index fe5125047e32..785e9a3987ba 100644 --- a/tests/kernel/sched/schedule_api/prj.conf +++ b/tests/kernel/sched/schedule_api/prj.conf @@ -7,3 +7,4 @@ CONFIG_MAX_THREAD_BYTES=5 CONFIG_TEST_USERSPACE=y CONFIG_MP_MAX_NUM_CPUS=1 CONFIG_ZTEST_FATAL_HOOK=y +CONFIG_MINIMAL_LIBC=y diff --git a/tests/kernel/sched/schedule_api/prj_dumb.conf b/tests/kernel/sched/schedule_api/prj_dumb.conf index c0ddfbd7c3fe..a1d0cf6dced3 100644 --- a/tests/kernel/sched/schedule_api/prj_dumb.conf +++ b/tests/kernel/sched/schedule_api/prj_dumb.conf @@ -5,3 +5,4 @@ CONFIG_SCHED_DUMB=y CONFIG_MAX_THREAD_BYTES=5 CONFIG_MP_MAX_NUM_CPUS=1 CONFIG_ZTEST_FATAL_HOOK=y +CONFIG_MINIMAL_LIBC=y diff --git a/tests/kernel/sched/schedule_api/prj_multiq.conf b/tests/kernel/sched/schedule_api/prj_multiq.conf index 6b28a1f39b2d..cfe09fbce476 100644 --- a/tests/kernel/sched/schedule_api/prj_multiq.conf +++ b/tests/kernel/sched/schedule_api/prj_multiq.conf @@ -7,3 +7,4 @@ CONFIG_MP_MAX_NUM_CPUS=1 CONFIG_ZTEST_FATAL_HOOK=y CONFIG_NUM_COOP_PRIORITIES=30 CONFIG_NUM_PREEMPT_PRIORITIES=40 +CONFIG_MINIMAL_LIBC=y diff --git a/tests/lib/newlib/heap_listener/prj.conf b/tests/lib/newlib/heap_listener/prj.conf index e5a5dc6df4c1..7282777ff1ca 100644 --- a/tests/lib/newlib/heap_listener/prj.conf +++ b/tests/lib/newlib/heap_listener/prj.conf @@ -1,3 +1,4 @@ CONFIG_ZTEST=y CONFIG_NEWLIB_LIBC=y +CONFIG_NEWLIB_LIBC_NANO=n CONFIG_NEWLIB_LIBC_HEAP_LISTENER=y diff --git a/tests/net/vlan/src/main.c b/tests/net/vlan/src/main.c index e739af7dd12c..a7851cc2fc6f 100644 --- a/tests/net/vlan/src/main.c +++ b/tests/net/vlan/src/main.c @@ -574,6 +574,28 @@ static void test_vlan_enable(void) ret = net_eth_vlan_enable(iface, VLAN_TAG_1); zassert_equal(ret, -EALREADY, "VLAN tag %d enabled for iface 1 (%d)", VLAN_TAG_1, ret); + + for (int i = VLAN_TAG_1; i <= VLAN_TAG_5; i += 100) { + iface = net_eth_get_vlan_iface(NULL, i); + + ARRAY_FOR_EACH_PTR(vlan_interfaces, vlan_iface) { + uint16_t tag; + + ret = net_eth_is_vlan_interface(*vlan_iface); + zassert_equal(ret, true, + "Not identified as VLAN interface %d", + net_if_get_by_iface(*vlan_iface)); + + if (*vlan_iface == iface) { + tag = net_eth_get_vlan_tag(*vlan_iface); + + zassert_equal(tag, i, + "Could not get the VLAN interface (%d)", + net_if_get_by_iface(*vlan_iface)); + break; + } + } + } } static void test_vlan_disable(void) @@ -628,13 +650,13 @@ static void test_vlan_enable_all(void) int ret; ret = net_eth_vlan_enable(eth_interfaces[0], VLAN_TAG_1); - zassert_equal(ret, 0, "Cannot enable %d", VLAN_TAG_1); + zassert_true(ret == 0 || ret == -EALREADY, "Cannot enable %d", VLAN_TAG_1); ret = net_eth_vlan_enable(eth_interfaces[0], VLAN_TAG_2); - zassert_equal(ret, 0, "Cannot enable %d", VLAN_TAG_2); + zassert_true(ret == 0 || ret == -EALREADY, "Cannot enable %d", VLAN_TAG_2); ret = net_eth_vlan_enable(eth_interfaces[0], VLAN_TAG_3); - zassert_equal(ret, 0, "Cannot enable %d", VLAN_TAG_3); + zassert_true(ret == 0 || ret == -EALREADY, "Cannot enable %d", VLAN_TAG_3); ret = net_eth_vlan_enable(eth_interfaces[0], VLAN_TAG_4); - zassert_equal(ret, 0, "Cannot enable %d", VLAN_TAG_4); + zassert_true(ret == 0 || ret == -EALREADY, "Cannot enable %d", VLAN_TAG_4); eth_ctx = net_if_l2_data(eth_interfaces[0]); diff --git a/west.yml b/west.yml index 9fdaa6b2be84..a81bbc3e666c 100644 --- a/west.yml +++ b/west.yml @@ -183,7 +183,7 @@ manifest: groups: - hal - name: hal_nordic - revision: fc2bab706f195c64d40016c9855b8acd7c235ded + revision: bdef8b66d5f59d95c09889918a04ddaecce322c8 path: modules/hal/nordic groups: - hal