diff --git a/.github/test-spec.yml b/.github/test-spec.yml new file mode 100644 index 000000000000..4934d8f243ff --- /dev/null +++ b/.github/test-spec.yml @@ -0,0 +1,480 @@ +# 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-test": + - "boards/nordic/nrf52840dk*" + - "boards/nordic/nrf5340dk*" + - "boards/nordic/nrf54h20dk*" + - "boards/nordic/nrf54l*" + - "boards/nordic/nrf9160dk*" + - "subsys/mgmt/mcumgr/**/*" + - "subsys/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "include/dfu/**/*" + - "samples/subsys/mgmt/mcumgr/smp_svr/**/*" + - "tests/boot/**/*" + - "tests/subsys/dfu/**/*" + - "tests/subsys/mgmt/mcumgr/**/*" + +"CI-dfu-test": + - "boards/nordic/nrf54h20dk*" + - "boards/nordic/nrf54l*" + - "drivers/bluetooth/**/*" + - "drivers/console/**/*" + - "drivers/flash/**/*" + - "drivers/mbox/**/*" + - "drivers/serial/**/*" + - "drivers/spi/**/*" + - "dts/arm/nordic/nrf54h*" + - "dts/common/nordic/*" + - "dts/riscv/nordic/nrf54h*" + - "include/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - "include/zephyr/**/*" + - "samples/subsys/mgmt/mcumgr/smp_svr/**/*" + - "scripts/west_commands/build.py" + - "scripts/west_commands/flash.py" + - "scripts/west_commands/runners/core.py" + - "scripts/west_commands/runners/nrf_common.py" + - "scripts/west_commands/runners/nrfutil.py" + - "soc/nordic/nrf54h/**/*" + - "subsys/bluetooth/**/*" + - "subsys/dfu/**/*" + - "subsys/logging/**/*" + - "subsys/mgmt/mcumgr/**/*" + - "subsys/tracing/**/*" + +"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: + - "arch/arm/**/*" + - any: + - "drivers/bluetooth/**/*" + - "drivers/clock_control/**/*" + - any: + - "dts/arm/nordic/nrf5*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + - any: + - "include/zephyr/bluetooth/**/*" + - "!include/zephyr/bluetooth/mesh/**/*" + - any: + - "boards/nordic/nrf5*" + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf9*" + - any: + - "subsys/pm/**/*" + +"CI-ble-samples-test": + - any: + - "drivers/bluetooth/**/*" + - any: + - "dts/arm/nordic/nrf52*" + - "dts/arm/nordic/nrf53*" + - "dts/arm/nordic/nrf54*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + - any: + - "include/zephyr/bluetooth/**/*" + - "!include/zephyr/bluetooth/mesh/**/*" + +"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-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/**/*" + - "lib/libc/common/source/stdlib/**/*" + - "lib/libc/newlib/**/*" + - "lib/libc/picolibc/**/*" + - "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": + - "drivers/bluetooth/*" + - "subsys/bluetooth/*" + - "include/zephyr/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": + - "boards/nordic/nrf21540dk*" + - "boards/nordic/nrf52833dk*" + - "boards/nordic/nrf52840dk*" + - "boards/nordic/nrf5340dk*" + - "boards/nordic/nrf54l*" + - "drivers/bluetooth/hci/**/*" + - "drivers/entropy/**/*" + - "dts/bindings/**/*" + - "include/zephyr/net/**/*" + - "include/zephyr/arch/**/*" + - "lib/libc/**/*" + - "lib/open-amp/**/*" + - "modules/hal_nordic/**/*" + - "modules/mbedtls/**/*" + - "modules/openthread/**/*" + - "modules/trusted-firmware-m/**/*" + - "samples/net/sockets/echo_*/**/*" + - "share/**/*" + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf54h*" + - "!soc/nordic/nrf9*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + - "subsys/bluetooth/shell/**/*" + - "subsys/ipc/**/*" + - "Kconfig" + - "CMakeLists.txt" + +"CI-rs-test": + - "boards/nordic/nrf21540dk*" + - "boards/nordic/nrf52833dk*" + - "boards/nordic/nrf52840dk*" + - "boards/nordic/nrf5340dk*" + - "boards/nordic/nrf54l*" + - "drivers/bluetooth/hci/**/*" + - "drivers/entropy/**/*" + - "dts/bindings/**/*" + - "include/zephyr/net/**/*" + - "include/zephyr/arch/**/*" + - "lib/libc/**/*" + - "lib/open-amp/**/*" + - "modules/hal_nordic/**/*" + - "modules/mbedtls/**/*" + - "modules/openthread/**/*" + - "modules/trusted-firmware-m/**/*" + - "samples/net/sockets/echo_*/**/*" + - "share/**/*" + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf54h*" + - "!soc/nordic/nrf9*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + - "subsys/bluetooth/shell/**/*" + - "subsys/ipc/**/*" + - "Kconfig" + - "CMakeLists.txt" + +"CI-thread-test": + - "include/zephyr/net/**/*" + - "modules/mbedtls/**/*" + - "modules/openthread/**/*" + - "samples/net/openthread/**/*" + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf54h*" + - "!soc/nordic/nrf9*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-nfc-test": + - "drivers/bluetooth/hci/**/*" + - "drivers/entropy/**/*" + - "drivers/flash/**/*" + - "drivers/mbox/**/*" + - "drivers/spi/**/*" + - "lib/crc/**/*" + - "modules/hal_nordic/**/*" + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf9*" + - "subsys/ipc/ipc_service/**/*" + - "subsys/fs/**/*" + - "subsys/mem_mgmt/**/*" + - "subsys/net/**/*" + - "subsys/random/**/*" + - "subsys/settings/**/*" + - "subsys/shell/**/*" + - "subsys/storage/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + +"CI-matter-test": + - "include/dfu/**/*" + - "include/mgmt/mcumgr/**/*" + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf52*" + - "!soc/nordic/nrf54h*" + - "!soc/nordic/nrf9*" + - "subsys/dfu/**/*" + - "subsys/settings/**/*" + - "subsys/net/**/*" + - "subsys/mgmt/mcumgr/**/*" + - "drivers/net/**/*" + - "samples/bluetooth/hci_ipc/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + - "!subsys/bluetooth/audio/**/*" + +"CI-find-my-test": + - "boards/nordic/nrf52840dk/**/*" + - "boards/nordic/nrf5340dk/**/*" + - "boards/nordic/nrf54l15dk/**/*" + - "drivers/bluetooth/**/*" + - "drivers/entropy/**/*" + - "drivers/flash/**/*" + - "drivers/usb/**/*" + - "drivers/regulator/**/*" + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf54h*" + - "!soc/nordic/nrf9*" + - "subsys/dfu/**/*" + - "subsys/fs/**/*" + - "subsys/ipc/**/*" + - "subsys/net/**/*" + - "subsys/random/**/*" + - "subsys/settings/**/*" + - "subsys/storage/**/*" + - "subsys/tracing/**/*" + - "subsys/usb/device/**/*" + - any: + - "subsys/bluetooth/**/*" + - "!subsys/bluetooth/mesh/**/*" + +"CI-rpc-test": + - "subsys/ipc/ipc_service/**/*" + - "subsys/random/**/*" + - "soc/nordic/nrf53/**/*" + +"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/nordic/nrf9*/*" + - "subsys/dfu/**/*" + - "subsys/net/**/*" + - "subsys/settings/**/*" + +"CI-wifi": + - "subsys/net/l2/wifi/**/*" + - "subsys/net/l2/ethernet/**/*" + +"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_ipc/**/*" + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf52*" + - "!soc/nordic/nrf54*" + - "!soc/nordic/nrf9*" + - "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": + - any: + - "soc/nordic/**/*" + - "!soc/nordic/nrf51*" + - "!soc/nordic/nrf52*" + - "!soc/nordic/nrf53*" + - "!soc/nordic/nrf9*" + - "arch/arm/**/*" + - "arch/riscv/**/*" + - "boards/nordic/nrf54*/**/*" + - "drivers/adc/**/*" + - "drivers/cache/**/*" + - "drivers/clock_control/**/*" + - "drivers/comparator/**/*" + - "drivers/counter/**/*" + - "drivers/flash/**/*" + - "drivers/gpio/**/*" + - "drivers/hwinfo/**/*" + - "drivers/i2c/**/*" + - "drivers/i2s/**/*" + - "drivers/interrupt_controller/**/*" + - "drivers/mbox/**/*" + - "drivers/mspi/**/*" + - "drivers/pinctrl/**/*" + - "drivers/power_domain/**/*" + - "drivers/pwm/**/*" + - "drivers/retained_mem/**/*" + - "drivers/rtc/**/*" + - "drivers/serial/**/*" + - "drivers/spi/**/*" + - "drivers/timer/**/*" + - "drivers/usb/**/*" + - "drivers/watchdog/**/*" + - any: + - "dts/vendor/nordic/**/*" + - "!dts/vendor/nordic/nrf52*" + - "!dts/vendor/nordic/nrf53*" + - "!dts/vendor/nordic/nrf9*" + - "modules/hal_nordic/**/*" + - "samples/boards/nordic/**/*" + - "tests/arch/arm/**/*" + - "tests/boards/nrf/**/*" + - "tests/drivers/adc/**/*" + - "tests/drivers/clock_control/**/*" + - "tests/drivers/comparator/**/*" + - "tests/drivers/counter/**/*" + - "tests/drivers/flash/**/*" + - "tests/drivers/gpio/**/*" + - "tests/drivers/hwinfo/**/*" + - "tests/drivers/i2c/**/*" + - "tests/drivers/i2s/**/*" + - "tests/drivers/interrupt_controller/**/*" + - "tests/drivers/mbox/**/*" + - "tests/drivers/mspi/**/*" + - "tests/drivers/pinctrl/**/*" + - "tests/drivers/pwm/**/*" + - "tests/drivers/retained_mem/**/*" + - "tests/drivers/rtc/**/*" + - "tests/drivers/spi/**/*" + - "tests/drivers/timer/**/*" + - "tests/drivers/uart/**/*" + - "tests/drivers/watchdog/**/*" + - "tests/kernel/common/**/*" + - "tests/kernel/context/**/*" + - "tests/kernel/fatal/**/*" + - "tests/kernel/fpu_sharing/**/*" + - "tests/kernel/gen_isr_table/**/*" + - "tests/kernel/interrupt/**/*" + - "tests/kernel/sched/preempt/**/*" diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 3ecf66b17da9..402341a9c389 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -33,6 +33,6 @@ jobs: - name: Backport uses: zephyrproject-rtos/action-backport@7e74f601d11eaca577742445e87775b5651a965f # v2.0.3-3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.NCS_GITHUB_TOKEN }} issue_labels: Backport labels_template: '["Backport"]' diff --git a/.github/workflows/commit-tags.yml b/.github/workflows/commit-tags.yml new file mode 100644 index 000000000000..61fc3a6c5bd3 --- /dev/null +++ b/.github/workflows/commit-tags.yml @@ -0,0 +1,31 @@ +name: Commit tags + +on: + pull_request: + types: [synchronize, opened, reopened, edited, labeled, unlabeled, + milestoned, demilestoned, assigned, unassigned, ready_for_review, + review_requested] + +permissions: + contents: read + +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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Run the commit tags + uses: nrfconnect/action-commit-tags@main + with: + target: . + upstream: zephyrproject-rtos/zephyr/main diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml index 8b7a8a2fb5fe..b25f65ac76b0 100644 --- a/.github/workflows/compliance.yml +++ b/.github/workflows/compliance.yml @@ -34,8 +34,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) rm -fr ".git/rebase-apply" rm -fr ".git/rebase-merge" git rebase origin/${BASE_REF} @@ -83,12 +83,9 @@ jobs: git log --pretty=oneline | head -n 10 # Increase rename limit to allow for large PRs git config diff.renameLimit 10000 - excludes="-e KconfigBasic -e SysbuildKconfigBasic -e ClangFormat" - # The signed-off-by check for dependabot should be skipped - if [ "${{ github.actor }}" == "dependabot[bot]" ]; then - excludes="$excludes -e Identity" - fi - ./scripts/ci/check_compliance.py --annotate $excludes -c origin/${BASE_REF}.. + ./scripts/ci/check_compliance.py --annotate -e KconfigBasic -e SysbuildKconfigBasic \ + -e Kconfig -e SysbuildKconfig -e KconfigBasicNoModules -e SysbuildKconfigBasicNoModules \ + -e ModulesMaintainers -c origin/${BASE_REF}.. - name: upload-results uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 diff --git a/.github/workflows/manifest-PR.yml b/.github/workflows/manifest-PR.yml new file mode 100644 index 000000000000..6e2430ec901e --- /dev/null +++ b/.github/workflows/manifest-PR.yml @@ -0,0 +1,39 @@ +name: handle manifest PR +on: + pull_request_target: + types: [opened, synchronize, closed, reopened] + branches: + - main + - ncs-v*-branch + +permissions: + contents: read + +jobs: + call-manifest-pr-action: + runs-on: ubuntu-latest + outputs: + base-branch: ${{ steps.set-base-branch.outputs.base_branch }} + steps: + # Determine the base branch: + # * sdk-zephyr/main -> sdk-nrf/main + # * sdk-zephyr/ncs-vX.Y-branch -> sdk-nrf/vX.Y-branch + - name: Set base branch + id: set-base-branch + run: | + if [[ "${{ github.event.pull_request.base.ref }}" == "main" ]]; then + echo "base_branch=main" >> "$GITHUB_OUTPUT" + elif [[ "${{ github.event.pull_request.base.ref }}" =~ ^ncs-(v[0-9]+\.[0-9]+-branch)$ ]]; then + branch_name="${{ github.event.pull_request.base.ref }}" + branch_name="${branch_name#ncs-}" + echo "base_branch=${branch_name}" >> "$GITHUB_OUTPUT" + else + echo "Error: Unsupported base branch: ${{ github.event.pull_request.base.ref }}" >&2 + exit 1 + fi + - name: handle manifest PR + uses: nrfconnect/action-manifest-pr@main + with: + token: ${{ secrets.NCS_GITHUB_TOKEN }} + manifest-pr-title-details: ${{ github.event.pull_request.title }} + base-branch: ${{ steps.set-base-branch.outputs.base_branch }} diff --git a/.github/workflows/stale_issue.yml b/.github/workflows/stale_issue.yml index 23e10d494f5e..efa4d0992b7c 100644 --- a/.github/workflows/stale_issue.yml +++ b/.github/workflows/stale_issue.yml @@ -10,7 +10,7 @@ jobs: stale: name: Find Stale issues and PRs runs-on: ubuntu-24.04 - if: github.repository == 'zephyrproject-rtos/zephyr' + if: github.repository == 'nrfconnect/sdk-zephyr' permissions: pull-requests: write # to comment on stale pull requests issues: write # to comment on stale issues diff --git a/CMakeLists.txt b/CMakeLists.txt index c0cbd8e59898..4bb3dc1fbcda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1880,12 +1880,27 @@ if(CONFIG_BUILD_OUTPUT_BIN AND CONFIG_BUILD_OUTPUT_UF2) # are typically loaded to RAM if(NOT CONFIG_XIP) if(CONFIG_BUILD_OUTPUT_ADJUST_LMA) - math(EXPR code_address + if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + math(EXPR code_address "${CONFIG_SRAM_BASE_ADDRESS} + ${CONFIG_BUILD_OUTPUT_ADJUST_LMA} + 0" OUTPUT_FORMAT HEXADECIMAL - ) + ) + else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(ram_addr PATH "${chosen_sram_path}") + + math(EXPR code_address + "${ram_addr} + ${CONFIG_BUILD_OUTPUT_ADJUST_LMA} + 0" + OUTPUT_FORMAT HEXADECIMAL + ) + endif() else() - set(code_address "${CONFIG_SRAM_BASE_ADDRESS}") + if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + set(code_address ${CONFIG_SRAM_BASE_ADDRESS}) + else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(code_address PATH "${chosen_sram_path}") + endif() endif() endif() 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 c45bd07c555c..065806f804d0 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -1286,7 +1286,6 @@ Documentation: - doc/index-tex.rst - doc/index.html - doc/index.rst - - doc/kconfig.rst - doc/templates/sample.tmpl - doc/templates/board.tmpl - boards/index.rst diff --git a/arch/Kconfig b/arch/Kconfig index 7f99dd01fbc7..b4b668489a4d 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -223,24 +223,37 @@ config 64BIT soc/**/Kconfig, or boards/**/Kconfig and the user should generally avoid modifying it. +config SRAM_DEPRECATED_KCONFIG_SET + bool + default y if SRAM_SIZE != $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) + default y if SRAM_BASE_ADDRESS != $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM)) + default n + select DEPRECATED + help + Indicates that either `CONFIG_SRAM_SIZE` or `CONFIG_SRAM_BASE_ADDRESS` have been + manually set, these Kconfigs are now deprecated and should be replaced by referencing + the devicetree `zephyr,sram` chosen node instead. + # Workaround for not being able to have commas in macro arguments DT_CHOSEN_Z_SRAM := zephyr,sram config SRAM_SIZE - int "SRAM Size in kB" + int "SRAM Size in kB [DEPRECATED]" default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) help The SRAM size in kB. The default value comes from /chosen/zephyr,sram in devicetree. The user should generally avoid changing it via menuconfig or - in configuration files. + in configuration files. This option is now deprecated and must be replaced by referencing + the devicetree `zephyr,sram` chosen node instead. config SRAM_BASE_ADDRESS - hex "SRAM Base Address" + hex "SRAM Base Address [DEPRECATED]" default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_SRAM)) help The SRAM base address. The default value comes from /chosen/zephyr,sram in devicetree. The user should generally avoid - changing it via menuconfig or in configuration files. + changing it via menuconfig or in configuration files. This option is now deprecated and + must be replaced by referencing the devicetree `zephyr,sram` chosen node instead. config XIP bool "Execute in place" @@ -599,9 +612,36 @@ config GEN_SW_ISR_TABLE depends on GEN_ISR_TABLES help This option controls whether a platform using gen_isr_tables - needs a software ISR table table created. This is an array of struct - _isr_table_entry containing the interrupt service routine and supplied - parameter. + needs a software ISR table created. + It can be generated as either an array or a switch-case. + See CONFIG_GEN_SW_ISR_TABLE_TYPE. + +choice GEN_SW_ISR_TABLE_TYPE + prompt "Allows to chose how ISR table is implemented" + depends on GEN_SW_ISR_TABLE + default GEN_SW_ISR_TABLE_ARRAY + help + CONFIG_GEN_SW_ISR_TABLE_ARRAY is a default option. + It should be used when in doubt. + GEN_SW_ISR_TABLE_SWITCH allows for binary size optimization + in certain scenarios, but may also increase latency, to execution of ISR with higher number, if there is significant number of ISR assigned in your system. + +config GEN_SW_ISR_TABLE_ARRAY + bool "Generate an array of ISR entries" + help + This is an array of struct _isr_table_entry containing + the interrupt service routine and supplied parameter. + All interrupts have their own entry. + +config GEN_SW_ISR_TABLE_SWITCH + bool "Generate a function with a switch-case" + help + Use a switch-case instead of an array. + This helps to limit binary size when most of the IRQs are not used. + In such case common, duplicated entries are grouped in a single default block + while few used interrupts have their own case blocks. + +endchoice config ARCH_SW_ISR_TABLE_ALIGN int "Alignment size of a software ISR table" diff --git a/arch/arm/core/cortex_a_r/reboot.c b/arch/arm/core/cortex_a_r/reboot.c index e5e44e13cfd0..afe272cec20e 100644 --- a/arch/arm/core/cortex_a_r/reboot.c +++ b/arch/arm/core/cortex_a_r/reboot.c @@ -44,7 +44,7 @@ TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_NONNULL) void __weak relocate_vector_table(void) { #if defined(CONFIG_XIP) && (CONFIG_FLASH_BASE_ADDRESS != 0) || \ - !defined(CONFIG_XIP) && (CONFIG_SRAM_BASE_ADDRESS != 0) + !defined(CONFIG_XIP) && (DT_CHOSEN_SRAM_ADDR != 0) write_sctlr(read_sctlr() & ~HIVECS); size_t vector_size = (size_t)_vector_end - (size_t)_vector_start; (void)arch_early_memcpy(VECTOR_ADDRESS, _vector_start, vector_size); diff --git a/arch/arm/core/cortex_m/isr_wrapper.c b/arch/arm/core/cortex_m/isr_wrapper.c index c9f6b1db21cb..2cd691c1f1a7 100644 --- a/arch/arm/core/cortex_m/isr_wrapper.c +++ b/arch/arm/core/cortex_m/isr_wrapper.c @@ -76,8 +76,15 @@ void _isr_wrapper(void) */ irq_number -= 16; +#if defined(CONFIG_GEN_SW_ISR_TABLE_ARRAY) const struct _isr_table_entry *entry = &_sw_isr_table[irq_number]; (entry->isr)(entry->arg); +#elif defined(CONFIG_GEN_SW_ISR_TABLE_SWITCH) + struct _isr_table_entry entry; + + get_isr_entry(irq_number, &entry); + (entry.isr)(entry.arg); +#endif /* CONFIG_GEN_SW_ISR_TABLE_ARRAY */ #if defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER) z_soc_irq_eoi(irq_number); diff --git a/arch/arm/core/cortex_m/prep_c.c b/arch/arm/core/cortex_m/prep_c.c index 6daa0ae250e0..5f5fde43f44d 100644 --- a/arch/arm/core/cortex_m/prep_c.c +++ b/arch/arm/core/cortex_m/prep_c.c @@ -74,7 +74,7 @@ void __weak relocate_vector_table(void) void __weak relocate_vector_table(void) { #if defined(CONFIG_XIP) && (CONFIG_FLASH_BASE_ADDRESS != 0) || \ - !defined(CONFIG_XIP) && (CONFIG_SRAM_BASE_ADDRESS != 0) + !defined(CONFIG_XIP) && (DT_CHOSEN_SRAM_ADDR != 0) size_t vector_size = (size_t)_vector_end - (size_t)_vector_start; (void)memcpy(VECTOR_ADDRESS, _vector_start, vector_size); #elif defined(CONFIG_SW_VECTOR_RELAY) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT) diff --git a/arch/arm/core/mpu/arm_mpu_regions.c b/arch/arm/core/mpu/arm_mpu_regions.c index 4771c5914ce6..113b47ebcde9 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 #ifdef CONFIG_ARM_MPU_SRAM_WRITE_THROUGH #define ARM_MPU_SRAM_REGION_ATTR REGION_RAM_WT_ATTR @@ -30,13 +33,23 @@ static const struct arm_mpu_region mpu_regions[] = { /* Region 1 */ MPU_REGION_ENTRY("SRAM_0", - CONFIG_SRAM_BASE_ADDRESS, +#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 + DT_CHOSEN_SRAM_ADDR, #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) - ARM_MPU_SRAM_REGION_ATTR(CONFIG_SRAM_BASE_ADDRESS, - CONFIG_SRAM_SIZE * 1024)), + ARM_MPU_SRAM_REGION_ATTR(DT_CHOSEN_SRAM_ADDR, + DT_CHOSEN_SRAM_SIZE)), #else ARM_MPU_SRAM_REGION_ATTR(REGION_SRAM_SIZE)), #endif + +#endif /* USE_PARTITION_MANAGER */ }; const struct arm_mpu_config mpu_config = { diff --git a/arch/arm64/core/CMakeLists.txt b/arch/arm64/core/CMakeLists.txt index d93cf61d88a8..4044de905cd4 100644 --- a/arch/arm64/core/CMakeLists.txt +++ b/arch/arm64/core/CMakeLists.txt @@ -22,7 +22,13 @@ zephyr_library_sources( # simple numeric comparison because these values may be # beyond the numeric range of integers for cmake. -string(LENGTH "x${CONFIG_SRAM_BASE_ADDRESS}" SRAM_LENGTH) +if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + string(LENGTH "x${CONFIG_SRAM_BASE_ADDRESS}" SRAM_LENGTH) +else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(ram_addr PATH "${chosen_sram_path}") + string(LENGTH "x${ram_addr}" SRAM_LENGTH) +endif() string(LENGTH "x${CONFIG_KERNEL_VM_BASE}" KERNEL_VM_LENGTH) if(${SRAM_LENGTH} GREATER 11 OR ${KERNEL_VM_LENGTH} GREATER 11) diff --git a/arch/arm64/core/Kconfig b/arch/arm64/core/Kconfig index 61021a9e35b7..d4d40fe86864 100644 --- a/arch/arm64/core/Kconfig +++ b/arch/arm64/core/Kconfig @@ -382,7 +382,7 @@ config ARM64_PA_BITS config MAX_XLAT_TABLES int "Maximum numbers of translation tables" default 32 if USERSPACE && TEST && SMP - default 24 if USERSPACE && TEST + default 28 if USERSPACE && TEST default 20 if USERSPACE && (ARM64_VA_BITS >= 40) default 16 if USERSPACE default 12 if (ARM64_VA_BITS >= 40) diff --git a/arch/common/isr_tables.c b/arch/common/isr_tables.c index ea9ac3331a86..8e5c093e6aff 100644 --- a/arch/common/isr_tables.c +++ b/arch/common/isr_tables.c @@ -87,15 +87,20 @@ const uintptr_t __irq_vector_table _irq_vector_table[IRQ_TABLE_SIZE] = { /* If there are no interrupts at all, or all interrupts are of the 'direct' * type and bypass the _sw_isr_table, then do not generate one. */ -#ifdef CONFIG_GEN_SW_ISR_TABLE +#if defined(CONFIG_GEN_SW_ISR_TABLE_ARRAY) #ifndef CONFIG_DYNAMIC_INTERRUPTS const -#endif -struct _isr_table_entry __sw_isr_table _sw_isr_table[IRQ_TABLE_SIZE] = { - [0 ...(IRQ_TABLE_SIZE - 1)] = {(const void *)0x42, - &z_irq_spurious}, +#endif /* CONFIG_DYNAMIC_INTERRUPTS */ + struct _isr_table_entry __sw_isr_table _sw_isr_table[IRQ_TABLE_SIZE] = { + [0 ...(IRQ_TABLE_SIZE - 1)] = {(const void *)0x42, &z_irq_spurious}, }; -#endif +#elif defined(CONFIG_GEN_SW_ISR_TABLE_SWITCH) +void __sw_isr_table get_isr_entry(int irq_number, struct _isr_table_entry *entry) +{ + entry->arg = (const void *)0x0; + entry->isr = z_irq_spurious; +} +#endif /* CONFIG_GEN_SW_ISR_TABLE_ARRAY */ #ifdef CONFIG_SHARED_INTERRUPTS #ifndef CONFIG_DYNAMIC_INTERRUPTS diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 0cf427b67180..0fcbb7f82208 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -67,10 +67,13 @@ config RISCV_ALWAYS_SWITCH_THROUGH_ECALL and most people should say n here to minimize context switching overhead. +DT_CHOSEN_Z_SRAM = zephyr,sram + choice RISCV_CMODEL prompt "RISC-V Code Model" - default RISCV_CMODEL_LARGE if (SRAM_BASE_ADDRESS > 0xffffffff) || \ - (KERNEL_VM_BASE > 0xffffffff) + default RISCV_CMODEL_LARGE if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_BASE_ADDRESS > 0xffffffff) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_addr_int,$(DT_CHOSEN_Z_SRAM),0) > 0xffffffff) || \ + (KERNEL_VM_BASE > 0xffffffff) default RISCV_CMODEL_MEDANY if 64BIT default RISCV_CMODEL_MEDLOW diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index e014766f6344..a4bac28ec959 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -356,9 +356,12 @@ config X86_MAX_ADDITIONAL_MEM_DOMAINS Zephyr test cases assume 3 additional domains can be instantiated. +DT_CHOSEN_Z_SRAM = zephyr,sram + config X86_EXTRA_PAGE_TABLE_PAGES int "Reserve extra pages in page table" - default 1 if X86_PAE && (KERNEL_VM_BASE != SRAM_BASE_ADDRESS) + default 1 if X86_PAE && ((SRAM_DEPRECATED_KCONFIG_SET && KERNEL_VM_BASE != SRAM_BASE_ADDRESS) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && KERNEL_VM_BASE != $(dt_chosen_reg_addr_int,$(DT_CHOSEN_Z_SRAM),0))) default 0 depends on X86_MMU help diff --git a/arch/x86/core/x86_mmu.c b/arch/x86/core/x86_mmu.c index 9bece5dd9f5c..eff5bdef4072 100644 --- a/arch/x86/core/x86_mmu.c +++ b/arch/x86/core/x86_mmu.c @@ -1325,8 +1325,8 @@ static void identity_map_remove(uint32_t level) pentry_t *entry_ptr; k_mem_region_align((uintptr_t *)&pos, &size, - (uintptr_t)CONFIG_SRAM_BASE_ADDRESS, - (size_t)CONFIG_SRAM_SIZE * 1024U, scope); + (uintptr_t)DT_CHOSEN_SRAM_ADDR, + (size_t)DT_CHOSEN_SRAM_SIZE, scope); while (size != 0U) { /* Need to get to the correct table */ diff --git a/arch/x86/gen_mmu.py b/arch/x86/gen_mmu.py index 827cfa9c38ca..444c9dfc9bdf 100755 --- a/arch/x86/gen_mmu.py +++ b/arch/x86/gen_mmu.py @@ -69,16 +69,21 @@ import array import ctypes import os +import pickle import re import struct import sys import textwrap +from pathlib import Path import elftools from elftools.elf.elffile import ELFFile from elftools.elf.sections import SymbolTableSection from packaging import version +sys.path.append(str(Path(__file__).parents[2] / "scripts" / "dts" / "python-devicetree" / "src")) +from devicetree import edtlib # noqa: F401 + if version.parse(elftools.__version__) < version.parse('0.24'): sys.exit("pyelftools is out of date, need version 0.24 or later") @@ -784,8 +789,17 @@ def main(): vm_size = syms["CONFIG_KERNEL_VM_SIZE"] vm_offset = syms["CONFIG_KERNEL_VM_OFFSET"] - sram_base = syms["CONFIG_SRAM_BASE_ADDRESS"] - sram_size = syms["CONFIG_SRAM_SIZE"] * 1024 + if isdef("CONFIG_SRAM_DEPRECATED_KCONFIG_SET"): + sram_base = syms["CONFIG_SRAM_BASE_ADDRESS"] + sram_size = syms["CONFIG_SRAM_SIZE"] * 1024 + else: + edt_pickle_path = str(Path(args.kernel).parents[1] / "zephyr" / 'edt.pickle') + with open(edt_pickle_path, "rb") as f: + edt = pickle.load(f) + chosen_sram = edt.chosen_node("zephyr,sram") + + sram_base = chosen_sram.regs[0].addr + sram_size = chosen_sram.regs[0].size mapped_kernel_base = syms["z_mapped_start"] mapped_kernel_size = syms["z_mapped_size"] diff --git a/arch/xtensa/core/ptables.c b/arch/xtensa/core/ptables.c index 2f6d17d8f43a..a23073880f17 100644 --- a/arch/xtensa/core/ptables.c +++ b/arch/xtensa/core/ptables.c @@ -570,7 +570,7 @@ __weak void arch_reserved_pages_update(void) uintptr_t page; int idx; - for (page = CONFIG_SRAM_BASE_ADDRESS, idx = 0; + for (page = DT_CHOSEN_SRAM_ADDR, idx = 0; page < (uintptr_t)z_mapped_start; page += CONFIG_MMU_PAGE_SIZE, idx++) { k_mem_page_frame_set(&k_mem_page_frames[idx], K_MEM_PAGE_FRAME_RESERVED); diff --git a/boards/actinius/icarus/Kconfig.defconfig b/boards/actinius/icarus/Kconfig.defconfig index b5a635ca0d4c..bd3aab4e66f8 100644 --- a/boards/actinius/icarus/Kconfig.defconfig +++ b/boards/actinius/icarus/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2019 Actinius # SPDX-License-Identifier: Apache-2.0 -if BOARD_ACTINIUS_ICARUS - source "boards/actinius/common/Kconfig" # For the secure version of the board the firmware is linked at the beginning @@ -17,21 +15,5 @@ source "boards/actinius/common/Kconfig" # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_ACTINIUS_ICARUS_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_ACTINIUS_ICARUS_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_ACTINIUS_ICARUS_NRF9160_NS - -endif # BOARD_ACTINIUS_ICARUS +config BOARD_ACTINIUS_ICARUS + select USE_DT_CODE_PARTITION if BOARD_ACTINIUS_ICARUS_NRF9160_NS diff --git a/boards/actinius/icarus_bee/Kconfig.defconfig b/boards/actinius/icarus_bee/Kconfig.defconfig index 3c191e96cede..b97e9df4caa3 100644 --- a/boards/actinius/icarus_bee/Kconfig.defconfig +++ b/boards/actinius/icarus_bee/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2021 Actinius # SPDX-License-Identifier: Apache-2.0 -if BOARD_ACTINIUS_ICARUS_BEE - source "boards/actinius/common/Kconfig" # For the secure version of the board the firmware is linked at the beginning @@ -17,21 +15,5 @@ source "boards/actinius/common/Kconfig" # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_ACTINIUS_ICARUS_BEE_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_ACTINIUS_ICARUS_BEE_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_ACTINIUS_ICARUS_BEE_NRF9160_NS - -endif # BOARD_ACTINIUS_ICARUS_BEE +config BOARD_ACTINIUS_ICARUS_BEE + select USE_DT_CODE_PARTITION if BOARD_ACTINIUS_ICARUS_BEE_NRF9160_NS diff --git a/boards/actinius/icarus_som/Kconfig.defconfig b/boards/actinius/icarus_som/Kconfig.defconfig index 42d244ac763d..9c709b8e7179 100644 --- a/boards/actinius/icarus_som/Kconfig.defconfig +++ b/boards/actinius/icarus_som/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2021 Actinius # SPDX-License-Identifier: Apache-2.0 -if BOARD_ACTINIUS_ICARUS_SOM - source "boards/actinius/common/Kconfig" # For the secure version of the board the firmware is linked at the beginning @@ -17,21 +15,5 @@ source "boards/actinius/common/Kconfig" # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_ACTINIUS_ICARUS_SOM_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_ACTINIUS_ICARUS_SOM_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_ACTINIUS_ICARUS_SOM_NRF9160_NS - -endif # BOARD_ACTINIUS_ICARUS_SOM +config BOARD_ACTINIUS_ICARUS_SOM + select USE_DT_CODE_PARTITION if BOARD_ACTINIUS_ICARUS_SOM_NRF9160_NS diff --git a/boards/actinius/icarus_som_dk/Kconfig.defconfig b/boards/actinius/icarus_som_dk/Kconfig.defconfig index 3993f59dbf22..cd0c9885526c 100644 --- a/boards/actinius/icarus_som_dk/Kconfig.defconfig +++ b/boards/actinius/icarus_som_dk/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2022 Actinius # SPDX-License-Identifier: Apache-2.0 -if BOARD_ACTINIUS_ICARUS_SOM_DK - source "boards/actinius/common/Kconfig" # For the secure version of the board the firmware is linked at the beginning @@ -17,21 +15,5 @@ source "boards/actinius/common/Kconfig" # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_ACTINIUS_ICARUS_SOM_DK_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_ACTINIUS_ICARUS_SOM_DK_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_ACTINIUS_ICARUS_SOM_DK_NRF9160_NS - -endif # BOARD_ACTINIUS_ICARUS_SOM_DK +config BOARD_ACTINIUS_ICARUS_SOM_DK + select USE_DT_CODE_PARTITION if BOARD_ACTINIUS_ICARUS_SOM_DK_NRF9160_NS diff --git a/boards/circuitdojo/feather/Kconfig.defconfig b/boards/circuitdojo/feather/Kconfig.defconfig index f093911dc477..3a1dafc2ac3f 100644 --- a/boards/circuitdojo/feather/Kconfig.defconfig +++ b/boards/circuitdojo/feather/Kconfig.defconfig @@ -4,8 +4,6 @@ # Copyright (c) 2020 Circuit Dojo LLC # SPDX-License-Identifier: Apache-2.0 -if BOARD_CIRCUITDOJO_FEATHER - # 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- @@ -16,21 +14,5 @@ if BOARD_CIRCUITDOJO_FEATHER # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_CIRCUITDOJO_FEATHER_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_CIRCUITDOJO_FEATHER_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_CIRCUITDOJO_FEATHER_NRF9160_NS - -endif # BOARD_CIRCUITDOJO_FEATHER +config BOARD_CIRCUITDOJO_FEATHER + select USE_DT_CODE_PARTITION if BOARD_CIRCUITDOJO_FEATHER_NRF9160_NS diff --git a/boards/ct/ctcc/Kconfig.defconfig b/boards/ct/ctcc/Kconfig.defconfig index 298f3d2fe218..6087f4fd5dbd 100644 --- a/boards/ct/ctcc/Kconfig.defconfig +++ b/boards/ct/ctcc/Kconfig.defconfig @@ -9,23 +9,5 @@ source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig" endif # BOARD_CTCC_NRF52840 -if BOARD_CTCC_NRF9161 || BOARD_CTCC_NRF9161_NS - -# Workaround for not being able to have commas in macro arguments. -# For explanation please see: boards/nordic/nrf9161dk/Kconfig.defconfig -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_CTCC_NRF9161 && TRUSTED_EXECUTION_SECURE - -if BOARD_CTCC_NRF9161_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_CTCC_NRF9161_NS -endif # BOARD_CTCC_NRF9161 || BOARD_CTCC_NRF9161_NS +config BOARD_CTCC + select USE_DT_CODE_PARTITION if BOARD_CTCC_NRF9161_NS diff --git a/boards/ezurio/bl5340_dvk/Kconfig.defconfig b/boards/ezurio/bl5340_dvk/Kconfig.defconfig index b4ae23988e0b..b1284f731927 100644 --- a/boards/ezurio/bl5340_dvk/Kconfig.defconfig +++ b/boards/ezurio/bl5340_dvk/Kconfig.defconfig @@ -33,29 +33,9 @@ config I2C # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_BL5340_DVK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_BL5340_DVK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_BL5340_DVK_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_BL5340_DVK_NRF5340_CPUAPP_NS +config BOARD_BL5340_DVK + select USE_DT_CODE_PARTITION if BOARD_BL5340_DVK_NRF5340_CPUAPP_NS config BT_HCI_IPC default y if BT_HCI diff --git a/boards/ezurio/bl54l15_dvk/Kconfig.defconfig b/boards/ezurio/bl54l15_dvk/Kconfig.defconfig index 2ff8fe6e3027..6ea4cac9bba5 100644 --- a/boards/ezurio/bl54l15_dvk/Kconfig.defconfig +++ b/boards/ezurio/bl54l15_dvk/Kconfig.defconfig @@ -2,21 +2,14 @@ # Copyright (c) 2025 Ezurio LLC # SPDX-License-Identifier: Apache-2.0 -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - if BOARD_BL54L15_DVK_NRF54L10_CPUAPP_NS || BOARD_BL54L15_DVK_NRF54L15_CPUAPP_NS +config BOARD_BL54L15_DVK + select USE_DT_CODE_PARTITION + config HAS_BT_CTLR default BT -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - # 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 diff --git a/boards/ezurio/bl54l15u_dvk/Kconfig.defconfig b/boards/ezurio/bl54l15u_dvk/Kconfig.defconfig index 1e706cb66dd2..b3f51eddb637 100644 --- a/boards/ezurio/bl54l15u_dvk/Kconfig.defconfig +++ b/boards/ezurio/bl54l15u_dvk/Kconfig.defconfig @@ -2,21 +2,14 @@ # Copyright (c) 2025 Ezurio LLC # SPDX-License-Identifier: Apache-2.0 -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - if BOARD_BL54L15U_DVK_NRF54L15_CPUAPP_NS +config BOARD_BL54L15U_DVK + select USE_DT_CODE_PARTITION + config HAS_BT_CTLR default BT -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - # 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 diff --git a/boards/holyiot/yj16019/holyiot_yj16019.dts b/boards/holyiot/yj16019/holyiot_yj16019.dts index 561f394f1a10..d8a2adbcf8d3 100644 --- a/boards/holyiot/yj16019/holyiot_yj16019.dts +++ b/boards/holyiot/yj16019/holyiot_yj16019.dts @@ -13,6 +13,10 @@ model = "Holyiot YJ-16019"; compatible = "holyiot,yj-16019"; + chosen { + zephyr,sram = &sram0; + }; + leds { compatible = "gpio-leds"; diff --git a/boards/index.rst b/boards/index.rst index 3cc92770cfeb..2ffe426fc24b 100644 --- a/boards/index.rst +++ b/boards/index.rst @@ -12,33 +12,8 @@ template available under :zephyr_file:`doc/templates/board.tmpl`. Shields are hardware add-ons that can be stacked on top of a board to add extra functionality. Refer to the :ref:`shield_porting_guide` for more information on how to port a shield. -.. admonition:: Search Tips - :class: dropdown - - * Use the form below to filter the list of supported boards and shields. If a field is left - empty, it will not be used in the filtering process. - - * Filtering by name and vendor is available for both boards and shields. The rest of the fields - apply only to boards. - - * A board/shield must meet **all** criteria selected across different fields. For example, if you - select both a vendor and an architecture, only boards that match both will be displayed. Within - a single field, selecting multiple options (such as two architectures) will show boards - matching **either** option. - - * The list of supported hardware features for each board is automatically generated using - information from the Devicetree. It may not be reflecting the full list of supported features - since some of them may not be enabled by default. - - * Can't find your exact board? Don't worry! If a similar board with the same or a closely related - MCU exists, you can use it as a :ref:`starting point ` for adding - support for your own board. - .. toctree:: :maxdepth: 2 :glob: - :hidden: */index - -.. zephyr:board-catalog:: diff --git a/boards/innblue/innblue21/Kconfig.defconfig b/boards/innblue/innblue21/Kconfig.defconfig index abf57a46a11b..c7fc47f75e3b 100644 --- a/boards/innblue/innblue21/Kconfig.defconfig +++ b/boards/innblue/innblue21/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2020 InnBlue # SPDX-License-Identifier: Apache-2.0 -if BOARD_INNBLUE21 - # 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- @@ -15,31 +13,11 @@ if BOARD_INNBLUE21 # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. - -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -if BOARD_INNBLUE21_NRF9160 && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_INNBLUE21_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_INNBLUE21_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_INNBLUE21_NRF9160_NS +config BOARD_INNBLUE21 + select USE_DT_CODE_PARTITION if BOARD_INNBLUE21_NRF9160_NS config BT_HCI_VS default y if BT config REGULATOR default y if SENSOR - -endif # BOARD_INNBLUE21 diff --git a/boards/innblue/innblue22/Kconfig.defconfig b/boards/innblue/innblue22/Kconfig.defconfig index 540a784ec975..ee1d7a11e3eb 100644 --- a/boards/innblue/innblue22/Kconfig.defconfig +++ b/boards/innblue/innblue22/Kconfig.defconfig @@ -3,8 +3,6 @@ # Copyright (c) 2020 InnBlue # SPDX-License-Identifier: Apache-2.0 -if BOARD_INNBLUE22 - # 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- @@ -15,31 +13,11 @@ if BOARD_INNBLUE22 # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. - -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -if BOARD_INNBLUE22_NRF9160 && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_INNBLUE22_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_INNBLUE22_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_INNBLUE22_NRF9160_NS +config BOARD_INNBLUE22 + select USE_DT_CODE_PARTITION if BOARD_INNBLUE22_NRF9160_NS config BT_HCI_VS default y if BT config REGULATOR default y if SENSOR - -endif # BOARD_INNBLUE22 diff --git a/boards/nordic/nrf5340_audio_dk/Kconfig.defconfig b/boards/nordic/nrf5340_audio_dk/Kconfig.defconfig index de77a9846f82..58d37f48dfa5 100644 --- a/boards/nordic/nrf5340_audio_dk/Kconfig.defconfig +++ b/boards/nordic/nrf5340_audio_dk/Kconfig.defconfig @@ -32,29 +32,9 @@ if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP || BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAP # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP_NS +config BOARD_NRF5340_AUDIO_DK + select USE_DT_CODE_PARTITION if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP_NS config BT_HCI_IPC default y if BT_HCI @@ -64,7 +44,3 @@ config HEAP_MEM_POOL_ADD_SIZE_BOARD default 4096 if BT_HCI_IPC endif # BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP || BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP_NS - -if BOARD_NRF5340_AUDIO_DK_NRF5340_CPUNET - -endif # BOARD_NRF5340_AUDIO_DK_NRF5340_CPUNET diff --git a/boards/nordic/nrf5340dk/Kconfig.defconfig b/boards/nordic/nrf5340dk/Kconfig.defconfig index c0ac00bcfe54..48e892a04fff 100644 --- a/boards/nordic/nrf5340dk/Kconfig.defconfig +++ b/boards/nordic/nrf5340dk/Kconfig.defconfig @@ -40,16 +40,6 @@ if BOARD_NRF5340DK_NRF5340_CPUAPP || BOARD_NRF5340DK_NRF5340_CPUAPP_NS # always restricted to the allocated non-secure SRAM partition. # -if BOARD_NRF5340DK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_NRF5340DK_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - config BOARD_NRF5340DK select USE_DT_CODE_PARTITION if BOARD_NRF5340DK_NRF5340_CPUAPP_NS diff --git a/boards/nordic/nrf54h20dk/Kconfig.defconfig b/boards/nordic/nrf54h20dk/Kconfig.defconfig index 5c39b68e4929..3aaca9795ffa 100644 --- a/boards/nordic/nrf54h20dk/Kconfig.defconfig +++ b/boards/nordic/nrf54h20dk/Kconfig.defconfig @@ -13,6 +13,7 @@ config MAX_THREAD_BYTES default 3 if USERSPACE config ROM_START_OFFSET + default 0 if NCS_MCUBOOT_BOOTLOADER_SIGN_MERGED_BINARY default 0x800 if BOOTLOADER_MCUBOOT if !USE_DT_CODE_PARTITION @@ -42,6 +43,7 @@ config MAX_THREAD_BYTES default 3 if USERSPACE config ROM_START_OFFSET + default 0 if NCS_MCUBOOT_BOOTLOADER_SIGN_MERGED_BINARY default 0x800 if BOOTLOADER_MCUBOOT endif # BOARD_NRF54H20DK_NRF54H20_CPURAD diff --git a/boards/nordic/nrf54h20dk/Kconfig.sysbuild b/boards/nordic/nrf54h20dk/Kconfig.sysbuild new file mode 100644 index 000000000000..29bd62b49927 --- /dev/null +++ b/boards/nordic/nrf54h20dk/Kconfig.sysbuild @@ -0,0 +1,9 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NRF54H20DK_NRF54H20_CPURAD + +config NRF_DEFAULT_EMPTY + default y + +endif # BOARD_NRF54H20DK_NRF54H20_CPURAD diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts index 567e84336546..3025a413f498 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts @@ -27,6 +27,7 @@ zephyr,bt-hci = &bt_hci_ipc0; nordic,802154-spinel-ipc = &ipc0; zephyr,canbus = &can120; + zephyr,entropy = &psa_rng; }; aliases { @@ -111,6 +112,11 @@ pwms = <&pwm130 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; }; }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; }; &cpuapp_bellboard { @@ -321,6 +327,20 @@ zephyr_udc0: &usbhs { zephyr,memory-region = "PMLocalRamfunc"; }; + /* temporary stack for S2RAM resume logic */ + pm_s2ram_stack: cpuapp_s2ram_stack@7fc8 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x00007fc8 16>; + zephyr,memory-region = "pm_s2ram_stack"; + }; + + /* run-time common mcuboot S2RAM support section */ + mcuboot_s2ram: cpuapp_s2ram@7fd8 { + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x00007fd8 8>; + zephyr,memory-region = "mcuboot_s2ram_context"; + }; + /* run-time common S2RAM cpu context RAM */ pm_s2ram: cpuapp_s2ram@7fe0 { compatible = "zephyr,memory-region", "mmio-sram"; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts index cf88e536d43c..0c46f46b7249 100644 --- a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad.dts @@ -28,12 +28,18 @@ zephyr,ieee802154 = &cpurad_ieee802154; zephyr,bt-hci-ipc = &ipc0; nordic,802154-spinel-ipc = &ipc0; + zephyr,entropy = &psa_rng; }; aliases { ipc-to-cpusys = &cpurad_cpusys_ipc; resetinfo = &cpurad_resetinfo; }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; }; &cpurad_bellboard { diff --git a/boards/nordic/nrf7002dk/CMakeLists.txt b/boards/nordic/nrf7002dk/CMakeLists.txt new file mode 100644 index 000000000000..db20255712bc --- /dev/null +++ b/boards/nordic/nrf7002dk/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if((CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NS OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS) AND + CONFIG_BOARD_ENABLE_CPUNET) + zephyr_library() + zephyr_library_sources(nrf5340_cpunet_reset.c) +endif() diff --git a/boards/nordic/nrf7002dk/Kconfig b/boards/nordic/nrf7002dk/Kconfig index ca0328bd530b..c56650c74c68 100644 --- a/boards/nordic/nrf7002dk/Kconfig +++ b/boards/nordic/nrf7002dk/Kconfig @@ -10,7 +10,9 @@ config MBOX_NRFX_IPC default MBOX if BOARD_NRF7002DK_NRF5340_CPUAPP || \ - BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS config BT_HCI_IPC default y if BT_HCI diff --git a/boards/nordic/nrf7002dk/Kconfig.defconfig b/boards/nordic/nrf7002dk/Kconfig.defconfig index a6cf1d7fbca1..8eee0dcdf3da 100644 --- a/boards/nordic/nrf7002dk/Kconfig.defconfig +++ b/boards/nordic/nrf7002dk/Kconfig.defconfig @@ -16,3 +16,75 @@ config SPI_NOR_FLASH_LAYOUT_PAGE_SIZE endif # SPI_NOR endif # BOARD_NRF7002DK + +if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +# By default, if we build for a Non-Secure version of the board, +# force building with TF-M as the Secure Execution Environment. +config BUILD_WITH_TFM + default y if BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_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 + +# Code Partition: +# +# 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- +# secure image (TRUSTED_EXECUTION_SECURE=y), the secure FW image shall always +# be restricted to the size of its code partition. +# +# For the non-secure version of the board, the firmware +# must be linked into the code-partition (non-secure) defined in DT, regardless. +# Apply this configuration below by setting the Kconfig symbols used by +# the linker according to the information extracted from DT partitions. + +# SRAM Partition: +# +# If the secure firmware is to be combined with a non-secure image +# (TRUSTED_EXECUTION_SECURE=y), the secure FW image SRAM shall always +# be restricted to the secure image SRAM partition (sram-secure-partition). +# Otherwise (if TRUSTED_EXECUTION_SECURE is not set) the whole zephyr,sram +# may be used by the image. +# +# For the non-secure version of the board, the firmware image SRAM is +# always restricted to the allocated non-secure SRAM partition. +# +# Workaround for not being able to have commas in macro arguments +DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition +DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition + +if (BOARD_NRF7002DK_NRF5340_CPUAPP || BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001) && \ + TRUSTED_EXECUTION_SECURE + +config FLASH_LOAD_SIZE + default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) + +config SRAM_SIZE + default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) + +endif + +if BOARD_NRF7002DK_NRF5340_CPUAPP_NS || BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +config FLASH_LOAD_OFFSET + default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) + +config FLASH_LOAD_SIZE + default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) + +endif + +endif diff --git a/boards/nordic/nrf7002dk/Kconfig.nrf7002dk b/boards/nordic/nrf7002dk/Kconfig.nrf7002dk index 61b9e818f367..91f52ee6f08c 100644 --- a/boards/nordic/nrf7002dk/Kconfig.nrf7002dk +++ b/boards/nordic/nrf7002dk/Kconfig.nrf7002dk @@ -4,4 +4,6 @@ config BOARD_NRF7002DK select SOC_NRF5340_CPUNET_QKAA if BOARD_NRF7002DK_NRF5340_CPUNET select SOC_NRF5340_CPUAPP_QKAA if BOARD_NRF7002DK_NRF5340_CPUAPP || \ - BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS diff --git a/boards/nordic/nrf7002dk/board.cmake b/boards/nordic/nrf7002dk/board.cmake index f85bbc86f485..11a27910eebc 100644 --- a/boards/nordic/nrf7002dk/board.cmake +++ b/boards/nordic/nrf7002dk/board.cmake @@ -1,10 +1,24 @@ # Copyright (c) 2024 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP OR CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001) +if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NS OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS) + set(TFM_PUBLIC_KEY_FORMAT "full") +endif() + +if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NS OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 OR + CONFIG_BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS) board_runner_args(nrfutil "--ext-mem-config-file=${BOARD_DIR}/support/nrf7002dk_spi_nrfutil_config.json") board_runner_args(jlink "--device=nrf5340_xxaa_app" "--speed=4000") -elseif(CONFIG_BOARD_NRF7002DK_NRF5340_CPUNET) +endif() + +if(CONFIG_TFM_FLASH_MERGED_BINARY) + set_property(TARGET runners_yaml_props_target PROPERTY hex_file "${CMAKE_BINARY_DIR}/zephyr/tfm_merged.hex") +endif() + +if(CONFIG_BOARD_NRF7002DK_NRF5340_CPUNET) board_runner_args(jlink "--device=nrf5340_xxaa_net" "--speed=4000") endif() diff --git a/boards/nordic/nrf7002dk/board.yml b/boards/nordic/nrf7002dk/board.yml index 4f41341e4423..39db5dcfa3a7 100644 --- a/boards/nordic/nrf7002dk/board.yml +++ b/boards/nordic/nrf7002dk/board.yml @@ -5,5 +5,9 @@ board: socs: - name: nrf5340 variants: + - name: ns + cpucluster: cpuapp - name: nrf7001 cpucluster: cpuapp + variants: + - name: ns diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.dts b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.dts new file mode 100644 index 000000000000..ac863872d55d --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.dts @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "nrf5340_cpuapp_common.dtsi" + +/ { + model = "Nordic NRF5340 DK NRF5340 Application"; + compatible = "nordic,nrf5340-dk-nrf5340-cpuapp"; + + chosen { + zephyr,sram = &sram0_ns; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_ns_partition; + zephyr,entropy = &psa_rng; + zephyr,wifi = &wlan0; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; +}; + +&qspi { + nrf70: nrf7001@1 { + compatible = "nordic,nrf7001-qspi"; + status = "okay"; + reg = <1>; + qspi-frequency = <24000000>; + qspi-quad-mode; + + #include "nrf70_common.dtsi" + }; +}; diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.yaml b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.yaml new file mode 100644 index 000000000000..165759691260 --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns.yaml @@ -0,0 +1,19 @@ +identifier: nrf7002dk/nrf5340/cpuapp/nrf7001/ns +name: NRF7002-DK-NRF7001-NRF5340-application-MCU-Non-Secure +type: mcu +arch: arm +toolchain: + - gnuarmemb + - xtools + - zephyr +ram: 192 +flash: 192 +supported: + - gpio + - i2c + - pwm + - watchdog + - usbd + - usb_device + - netif:openthread +vendor: nordic diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns_defconfig b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns_defconfig new file mode 100644 index 000000000000..2c435653140a --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_nrf7001_ns_defconfig @@ -0,0 +1,24 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable TrustZone-M +CONFIG_ARM_TRUSTZONE_M=y + +# This Board implies building Non-Secure firmware +CONFIG_TRUSTED_EXECUTION_NONSECURE=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable uart driver +CONFIG_SERIAL=y + +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.dts b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.dts new file mode 100644 index 000000000000..8225e992bb82 --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.dts @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "nrf5340_cpuapp_common.dtsi" +#include "nordic/nrf5340_sram_partition.dtsi" +#include "nordic/nrf5340_cpuapp_ns_partition.dtsi" + +/ { + model = "Nordic NRF5340 DK NRF5340 Application"; + compatible = "nordic,nrf5340-dk-nrf5340-cpuapp"; + + chosen { + zephyr,sram = &sram0_ns_app; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_ns_partition; + zephyr,entropy = &psa_rng; + zephyr,wifi = &wlan0; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; +}; + +&qspi { + nrf70: nrf7002@1 { + compatible = "nordic,nrf7002-qspi"; + status = "okay"; + reg = <1>; + qspi-frequency = <24000000>; + qspi-quad-mode; + + #include "nrf70_common.dtsi" + #include "nrf70_common_5g.dtsi" + }; +}; diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.yaml b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.yaml new file mode 100644 index 000000000000..ea43785b4559 --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns.yaml @@ -0,0 +1,19 @@ +identifier: nrf7002dk/nrf5340/cpuapp/ns +name: NRF7002-DK-NRF5340-application-MCU-Non-Secure +type: mcu +arch: arm +toolchain: + - gnuarmemb + - xtools + - zephyr +ram: 192 +flash: 192 +supported: + - gpio + - i2c + - pwm + - watchdog + - usbd + - usb_device + - netif:openthread +vendor: nordic diff --git a/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns_defconfig b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns_defconfig new file mode 100644 index 000000000000..1886b926bfd5 --- /dev/null +++ b/boards/nordic/nrf7002dk/nrf7002dk_nrf5340_cpuapp_ns_defconfig @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable TrustZone-M +CONFIG_ARM_TRUSTZONE_M=y + +# This Board implies building Non-Secure firmware +CONFIG_TRUSTED_EXECUTION_NONSECURE=y + +# enable GPIO +CONFIG_GPIO=y + +# Enable uart driver +CONFIG_SERIAL=y + +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y diff --git a/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuapp_ns.yaml b/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuapp_ns.yaml index 3891b38e52a0..5d91c5978f3b 100644 --- a/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuapp_ns.yaml +++ b/boards/nordic/nrf7120dk/nrf7120dk_nrf7120_cpuapp_ns.yaml @@ -7,10 +7,9 @@ type: mcu arch: arm toolchain: - gnuarmemb - - xtools - zephyr -ram: 896 -flash: 512 +ram: 256 +flash: 844 supported: - adc - gpio @@ -18,5 +17,7 @@ supported: - spi - counter - watchdog - - adc - i2s + - pwm +vendor: nordic +sysbuild: true diff --git a/boards/nordic/nrf9131ek/Kconfig.defconfig b/boards/nordic/nrf9131ek/Kconfig.defconfig index e1d8de241c0a..1a30d006b4c6 100644 --- a/boards/nordic/nrf9131ek/Kconfig.defconfig +++ b/boards/nordic/nrf9131ek/Kconfig.defconfig @@ -8,3 +8,22 @@ config HW_STACK_PROTECTION config BOARD_NRF9131EK select USE_DT_CODE_PARTITION if BOARD_NRF9131EK_NRF9131_NS + +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 + +endif # BOARD_NRF9131EK_NRF9131 || BOARD_NRF9131EK_NRF9131_NS diff --git a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp.dts b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp.dts index f1bc01a8f742..dc8bee73f011 100644 --- a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp.dts +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpuapp.dts @@ -27,6 +27,7 @@ zephyr,uart-mcumgr = &uart136; zephyr,bt-hci = &bt_hci_ipc0; nordic,802154-spinel-ipc = &ipc0; + zephyr,entropy = &psa_rng; }; aliases { @@ -108,6 +109,11 @@ pwms = <&pwm130 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; }; }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; }; &cpuapp_ram0x_region { diff --git a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpurad.dts b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpurad.dts index 45fd620c37a1..17c482e7865c 100644 --- a/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpurad.dts +++ b/boards/nordic/nrf9280pdk/nrf9280pdk_nrf9280_cpurad.dts @@ -29,12 +29,18 @@ zephyr,ieee802154 = &cpurad_ieee802154; zephyr,bt-hci-ipc = &ipc0; nordic,802154-spinel-ipc = &ipc0; + zephyr,entropy = &psa_rng; }; aliases { ipc-to-cpusys = &cpurad_cpusys_ipc; resetinfo = &cpurad_resetinfo; }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; }; &cpuapp_cpurad_ram0x_region { diff --git a/boards/nordic/thingy53/Kconfig.defconfig b/boards/nordic/thingy53/Kconfig.defconfig index 218dbedfb128..a8ba0d17382c 100644 --- a/boards/nordic/thingy53/Kconfig.defconfig +++ b/boards/nordic/thingy53/Kconfig.defconfig @@ -15,6 +15,20 @@ endif # NORDIC_QSPI_NOR 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 + +if BUILD_WITH_TFM + +choice TFM_PROFILE_TYPE + default TFM_PROFILE_TYPE_MINIMAL +endchoice + +endif # BUILD_WITH_TFM + # Code Partition: # # For the secure version of the board the firmware is linked at the beginning @@ -39,29 +53,9 @@ if BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - -if BOARD_THINGY53_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) -endif # BOARD_THINGY53_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_THINGY53_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_THINGY53_NRF5340_CPUAPP_NS +config BOARD_THINGY53 + select USE_DT_CODE_PARTITION if BOARD_THINGY53_NRF5340_CPUAPP_NS if !TRUSTED_EXECUTION_SECURE @@ -91,6 +85,16 @@ endif # !TRUSTED_EXECUTION_SECURE source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig" +# 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 + +config NORDIC_QSPI_NOR + default y + endif # BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS if BOARD_THINGY53_NRF5340_CPUNET diff --git a/boards/nordic/thingy53/Kconfig.sysbuild b/boards/nordic/thingy53/Kconfig.sysbuild new file mode 100644 index 000000000000..df489c1dd546 --- /dev/null +++ b/boards/nordic/thingy53/Kconfig.sysbuild @@ -0,0 +1,29 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS + +choice BOOTLOADER + default BOOTLOADER_MCUBOOT +endchoice + +choice MCUBOOT_MODE + default MCUBOOT_MODE_OVERWRITE_ONLY +endchoice + +config SECURE_BOOT_NETCORE + default y + +config NETCORE_APP_UPDATE + default y if SECURE_BOOT_NETCORE + +config NRF_DEFAULT_EMPTY + default y if SECURE_BOOT_NETCORE + +config MCUBOOT_USE_ALL_AVAILABLE_RAM + default y if BOARD_THINGY53_NRF5340_CPUAPP_NS && BOOTLOADER_MCUBOOT + +endif # BOARD_THINGY53_NRF5340_CPUAPP || BOARD_THINGY53_NRF5340_CPUAPP_NS + +config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY + default y if BOOTLOADER_MCUBOOT 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 828b710c1ad4..fef36ec84f57 100644 --- a/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi +++ b/boards/nordic/thingy53/thingy53_nrf5340_common.dtsi @@ -13,6 +13,7 @@ zephyr,bt-hci = &bt_hci_ipc0; nordic,802154-spinel-ipc = &ipc0; zephyr,ieee802154 = &ieee802154; + nordic,pm-ext-flash = &mx25r64; }; buttons { diff --git a/boards/norik/octopus_io_board/Kconfig.defconfig b/boards/norik/octopus_io_board/Kconfig.defconfig index 4c00ab52ab59..76c48f90db55 100644 --- a/boards/norik/octopus_io_board/Kconfig.defconfig +++ b/boards/norik/octopus_io_board/Kconfig.defconfig @@ -1,8 +1,6 @@ # Copyright (c) 2024 Norik Systems # SPDX-License-Identifier: Apache-2.0 -if BOARD_OCTOPUS_IO_BOARD - # 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- @@ -13,21 +11,5 @@ if BOARD_OCTOPUS_IO_BOARD # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_OCTOPUS_IO_BOARD && TRUSTED_EXECUTION_SECURE - -if BOARD_OCTOPUS_IO_BOARD_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_OCTOPUS_IO_BOARD_NRF9160_NS - -endif # BOARD_OCTOPUS_IO_BOARD +config BOARD_OCTOPUS_IO_BOARD + select USE_DT_CODE_PARTITION if BOARD_OCTOPUS_IO_BOARD_NRF9160_NS diff --git a/boards/norik/octopus_som/Kconfig.defconfig b/boards/norik/octopus_som/Kconfig.defconfig index 6fe9d1618a5b..35a31fd95c11 100644 --- a/boards/norik/octopus_som/Kconfig.defconfig +++ b/boards/norik/octopus_som/Kconfig.defconfig @@ -1,8 +1,6 @@ # Copyright (c) 2024 Norik Systems # SPDX-License-Identifier: Apache-2.0 -if BOARD_OCTOPUS_SOM - # 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- @@ -13,21 +11,5 @@ if BOARD_OCTOPUS_SOM # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_OCTOPUS_SOM && TRUSTED_EXECUTION_SECURE - -if BOARD_OCTOPUS_SOM_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_OCTOPUS_SOM_NRF9160_NS - -endif # BOARD_OCTOPUS_SOM +config BOARD_OCTOPUS_SOM + select USE_DT_CODE_PARTITION if BOARD_OCTOPUS_SOM_NRF9160_NS diff --git a/boards/panasonic/panb611evb/Kconfig.defconfig b/boards/panasonic/panb611evb/Kconfig.defconfig index 1b469232537f..5c1da70d2375 100644 --- a/boards/panasonic/panb611evb/Kconfig.defconfig +++ b/boards/panasonic/panb611evb/Kconfig.defconfig @@ -1,21 +1,14 @@ # Copyright (c) 2025 Panasonic Industrial Devices Europe GmbH # SPDX-License-Identifier: Apache-2.0 -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition - if BOARD_PANB611EVB_NRF54L15_CPUAPP_NS +config BOARD_PANB611EVB + select USE_DT_CODE_PARTITION + config HAS_BT_CTLR default BT -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - # 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 diff --git a/boards/qemu/x86/board.cmake b/boards/qemu/x86/board.cmake index e8a4758f1303..b4a6530f3d5b 100644 --- a/boards/qemu/x86/board.cmake +++ b/boards/qemu/x86/board.cmake @@ -20,15 +20,23 @@ else() set(QEMU_CPU_TYPE_${ARCH} qemu32,+nx,+pae) endif() +if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + math(EXPR RAM_SIZE "${CONFIG_SRAM_SIZE} / 1024" OUTPUT_FORMAT HEXADECIMAL) +else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_size(RAM_SIZE PATH "${chosen_sram_path}") + math(EXPR RAM_SIZE "${RAM_SIZE} / 1024 / 1024" OUTPUT_FORMAT HEXADECIMAL) +endif() + if(CONFIG_XIP) # Extra 4MB to emulate flash area - math(EXPR QEMU_MEMORY_SIZE_MB "${CONFIG_SRAM_SIZE} / 1024 + 4") + math(EXPR QEMU_MEMORY_SIZE_MB "${RAM_SIZE} + 4") elseif(CONFIG_BOARD_QEMU_X86_TINY AND CONFIG_DEMAND_PAGING AND NOT CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT) # Flash is at 4MB-8MB, so need this to be large enough math(EXPR QEMU_MEMORY_SIZE_MB "8") else() - math(EXPR QEMU_MEMORY_SIZE_MB "${CONFIG_SRAM_SIZE} / 1024") + math(EXPR QEMU_MEMORY_SIZE_MB "${RAM_SIZE}") endif() set(QEMU_CPU_FLAGS "") diff --git a/boards/raytac/mdbt53_db_40/Kconfig.defconfig b/boards/raytac/mdbt53_db_40/Kconfig.defconfig index 128e5fc62dbc..780df72d1342 100644 --- a/boards/raytac/mdbt53_db_40/Kconfig.defconfig +++ b/boards/raytac/mdbt53_db_40/Kconfig.defconfig @@ -29,29 +29,9 @@ if BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP || BOARD_RAYTAC_MDBT53_DB_40_NRF5340 # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP_NS +config BOARD_RAYTAC_MDBT53_DB_40 + select USE_DT_CODE_PARTITION if BOARD_RAYTAC_MDBT53_DB_40_NRF5340_CPUAPP_NS config BT_HCI_IPC default y if BT_HCI diff --git a/boards/raytac/mdbt53v_db_40/Kconfig.defconfig b/boards/raytac/mdbt53v_db_40/Kconfig.defconfig index c30d57c073d0..63eaac0cac98 100644 --- a/boards/raytac/mdbt53v_db_40/Kconfig.defconfig +++ b/boards/raytac/mdbt53v_db_40/Kconfig.defconfig @@ -29,29 +29,9 @@ if BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP || BOARD_RAYTAC_MDBT53V_DB_40_NRF53 # For the non-secure version of the board, the firmware image SRAM is # always restricted to the allocated non-secure SRAM partition. # -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition -DT_CHOSEN_Z_SRAM_PARTITION := zephyr,sram-secure-partition -if BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config SRAM_SIZE - default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM_PARTITION),0,K) - -endif # BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP && TRUSTED_EXECUTION_SECURE - -if BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP_NS +config BOARD_RAYTAC_MDBT53V_DB_40 + select USE_DT_CODE_PARTITION if BOARD_RAYTAC_MDBT53V_DB_40_NRF5340_CPUAPP_NS config BT_HCI_IPC default y if BT_HCI diff --git a/boards/seeed/xiao_ble/pm_static.yml b/boards/seeed/xiao_ble/pm_static.yml new file mode 100644 index 000000000000..02915293177c --- /dev/null +++ b/boards/seeed/xiao_ble/pm_static.yml @@ -0,0 +1,18 @@ +# Mirror of partitions defined in nrf52840_partition_uf2_sdv7.dtsi +# Default flash layout for nrf52840 using UF2 and SoftDevice s140 v7 + +softdevice_reserved: + address: 0x00 + size: 0x27000 + +app: + address: 0x27000 + size: 0xC5000 + +settings_storage: + address: 0xEC000 + size: 0x8000 + +uf2_partition: + address: 0xF4000 + size: 0xC000 diff --git a/boards/sparkfun/thing_plus/Kconfig.defconfig b/boards/sparkfun/thing_plus/Kconfig.defconfig index 5273768aa501..cb9ac1d590dc 100644 --- a/boards/sparkfun/thing_plus/Kconfig.defconfig +++ b/boards/sparkfun/thing_plus/Kconfig.defconfig @@ -4,8 +4,6 @@ # Copyright (c) 2020 Circuit Dojo LLC # SPDX-License-Identifier: Apache-2.0 -if BOARD_SPARKFUN_THING_PLUS - # 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- @@ -16,21 +14,5 @@ if BOARD_SPARKFUN_THING_PLUS # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - depends on BOARD_SPARKFUN_THING_PLUS_NRF9160 && TRUSTED_EXECUTION_SECURE - -if BOARD_SPARKFUN_THING_PLUS_NRF9160_NS - -config FLASH_LOAD_OFFSET - default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -config FLASH_LOAD_SIZE - default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) - -endif # BOARD_SPARKFUN_THING_PLUS_NRF9160 - -endif # BOARD_SPARKFUN_THING_PLUS +config BOARD_SPARKFUN_THING_PLUS + select USE_DT_CODE_PARTITION if BOARD_SPARKFUN_THING_PLUS_NRF9160_NS diff --git a/boards/udoo/udoo_neo_full/doc/index.rst b/boards/udoo/udoo_neo_full/doc/index.rst index 020d43e33ac9..d3c75d84e4c5 100644 --- a/boards/udoo/udoo_neo_full/doc/index.rst +++ b/boards/udoo/udoo_neo_full/doc/index.rst @@ -179,9 +179,7 @@ DT_FLASH_SIZE macro to determine the region size and DT_FLASH_ADDR to determine the address where the region begins. If you want to have the data placed in the subregion of a memory, which will -likely be the case when using DDR, select "zephyr,sram = &sram", which sets the -CONFIG_SRAM_SIZE macro to determine the region size and -CONFIG_SRAM_BASE_ADDRESS to determine the address where the region begins. +likely be the case when using DDR, select "zephyr,sram = &sram". Otherwise set "zephyr,flash" and/or "zephyr,sram" to one of the predefined regions: diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index 592596576d11..ccf6a1903162 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -80,6 +80,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) ${current_includes} ${soc_linker_script_includes} ${template_script_defines} + -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/linker/lld/target.cmake b/cmake/linker/lld/target.cmake index 96df1c123796..fe8aad62c73d 100644 --- a/cmake/linker/lld/target.cmake +++ b/cmake/linker/lld/target.cmake @@ -52,6 +52,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define) -imacros ${AUTOCONF_H} ${current_includes} ${template_script_defines} + -DUSE_PARTITION_MANAGER=$ -E ${LINKER_SCRIPT} -P # Prevent generation of debug `#line' directives. -o ${linker_script_gen} diff --git a/cmake/linker_script/arm/linker.cmake b/cmake/linker_script/arm/linker.cmake index b6d2254911bd..a2b83ffb3149 100644 --- a/cmake/linker_script/arm/linker.cmake +++ b/cmake/linker_script/arm/linker.cmake @@ -63,8 +63,14 @@ else() endif() endif() -set(RAM_ADDR ${CONFIG_SRAM_BASE_ADDRESS}) -math(EXPR RAM_SIZE "(${CONFIG_SRAM_SIZE} + 0) * 1024" OUTPUT_FORMAT HEXADECIMAL) +if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + set(RAM_ADDR ${CONFIG_SRAM_BASE_ADDRESS}) + math(EXPR RAM_SIZE "(${CONFIG_SRAM_SIZE} + 0) * 1024" OUTPUT_FORMAT HEXADECIMAL) +else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(RAM_ADDR PATH "${chosen_sram_path}") + dt_reg_size(RAM_SIZE PATH "${chosen_sram_path}") +endif() # ToDo: decide on the optimal location for this. # linker/ld/target.cmake based on arch, or directly in arch and scatter_script.cmake can ignore diff --git a/cmake/modules/dts.cmake b/cmake/modules/dts.cmake index f72bf4b7289f..0d8998235273 100644 --- a/cmake/modules/dts.cmake +++ b/cmake/modules/dts.cmake @@ -127,287 +127,318 @@ set(DTS_KCONFIG ${KCONFIG_BINARY_DIR}/Kconfig.dts) # modules. set(VENDOR_PREFIXES dts/bindings/vendor-prefixes.txt) -# Fetch variable from sysbuild which might be forcing a configuration (for variant build images) -zephyr_get(DTS_SOURCE SYSBUILD LOCAL) +function(dts_configuration_files) + zephyr_get(DTS_SOURCE SYSBUILD LOCAL) -if(NOT DEFINED DTS_SOURCE) - zephyr_build_string(board_string SHORT shortened_board_string - BOARD ${BOARD} BOARD_QUALIFIERS ${BOARD_QUALIFIERS} - ) - foreach(dir ${BOARD_DIRECTORIES}) - if(EXISTS ${dir}/${shortened_board_string}.dts AND NOT BOARD_${BOARD}_SINGLE_SOC) - message(FATAL_ERROR "Board ${ZFILE_BOARD} defines multiple SoCs.\nShortened file name " - "(${shortened_board_string}.dts) not allowed, use '_.dts' naming" - ) + if(NOT DEFINED DTS_SOURCE) + zephyr_build_string(board_string SHORT shortened_board_string + BOARD ${BOARD} BOARD_QUALIFIERS ${BOARD_QUALIFIERS} + ) + foreach(dir ${BOARD_DIRECTORIES}) + if(EXISTS ${dir}/${shortened_board_string}.dts AND NOT BOARD_${BOARD}_SINGLE_SOC) + message(FATAL_ERROR "Board ${ZFILE_BOARD} defines multiple SoCs.\nShortened file name " + "(${shortened_board_string}.dts) not allowed, use '_.dts' naming" + ) elseif(EXISTS ${dir}/${board_string}.dts AND EXISTS ${dir}/${shortened_board_string}.dts) - message(FATAL_ERROR "Conflicting file names discovered. Cannot use both " - "${board_string}.dts and ${shortened_board_string}.dts. " - "Please choose one naming style, ${board_string}.dts is recommended." - ) - elseif(EXISTS ${dir}/${board_string}.dts) - set(DTS_SOURCE ${dir}/${board_string}.dts) - elseif(EXISTS ${dir}/${shortened_board_string}.dts) - set(DTS_SOURCE ${dir}/${shortened_board_string}.dts) - endif() - endforeach() -endif() + message(FATAL_ERROR "Conflicting file names discovered. Cannot use both " + "${board_string}.dts and ${shortened_board_string}.dts. " + "Please choose one naming style, ${board_string}.dts is recommended." + ) + elseif(EXISTS ${dir}/${board_string}.dts) + set(DTS_SOURCE ${dir}/${board_string}.dts) + elseif(EXISTS ${dir}/${shortened_board_string}.dts) + set(DTS_SOURCE ${dir}/${shortened_board_string}.dts) + endif() + endforeach() + endif() -if(EXISTS ${DTS_SOURCE}) - # We found a devicetree. Append all relevant dts overlays we can find... - zephyr_file(CONF_FILES ${BOARD_DIRECTORIES} DTS DTS_SOURCE) + if(EXISTS ${DTS_SOURCE}) + # We found a devicetree. Append all relevant dts overlays we can find... + zephyr_file(CONF_FILES ${BOARD_DIRECTORIES} DTS DTS_SOURCE) - zephyr_file( - CONF_FILES ${BOARD_DIRECTORIES} - DTS no_rev_suffix_dts_board_overlays - BOARD ${BOARD} - BOARD_QUALIFIERS ${BOARD_QUALIFIERS} - ) + zephyr_file( + CONF_FILES ${BOARD_DIRECTORIES} + DTS no_rev_suffix_dts_board_overlays + BOARD ${BOARD} + BOARD_QUALIFIERS ${BOARD_QUALIFIERS} + ) - # ...but remove the ones that do not include the revision suffix - list(REMOVE_ITEM DTS_SOURCE ${no_rev_suffix_dts_board_overlays}) -else() - # If we don't have a devicetree, provide an empty stub - set(DTS_SOURCE ${ZEPHYR_BASE}/boards/common/stub.dts) -endif() + # ...but remove the ones that do not include the revision suffix + list(REMOVE_ITEM DTS_SOURCE ${no_rev_suffix_dts_board_overlays}) + else() + # If we don't have a devicetree, provide an empty stub + set(DTS_SOURCE ${ZEPHYR_BASE}/boards/common/stub.dts) + endif() -# -# Find all the DTS files we need to concatenate and preprocess, as -# well as all the devicetree bindings and vendor prefixes associated -# with them. -# + # + # Find all the DTS files we need to concatenate and preprocess, as + # well as all the devicetree bindings and vendor prefixes associated + # with them. + # -zephyr_file(CONF_FILES ${BOARD_EXTENSION_DIRS} DTS board_extension_dts_files) + zephyr_file(CONF_FILES ${BOARD_EXTENSION_DIRS} DTS board_extension_dts_files) -set(dts_files - ${DTS_SOURCE} - ${board_extension_dts_files} - ${shield_dts_files} + set(dts_files + ${DTS_SOURCE} + ${board_extension_dts_files} + ${shield_dts_files} ) -if(DTC_OVERLAY_FILE) - zephyr_list(TRANSFORM DTC_OVERLAY_FILE NORMALIZE_PATHS - OUTPUT_VARIABLE DTC_OVERLAY_FILE_AS_LIST) - build_info(devicetree user-files PATH ${DTC_OVERLAY_FILE_AS_LIST}) - list(APPEND - dts_files - ${DTC_OVERLAY_FILE_AS_LIST} + if(DTC_OVERLAY_FILE) + zephyr_list(TRANSFORM DTC_OVERLAY_FILE NORMALIZE_PATHS + OUTPUT_VARIABLE DTC_OVERLAY_FILE_AS_LIST ) -endif() - -if(EXTRA_DTC_OVERLAY_FILE) - zephyr_list(TRANSFORM EXTRA_DTC_OVERLAY_FILE NORMALIZE_PATHS - OUTPUT_VARIABLE EXTRA_DTC_OVERLAY_FILE_AS_LIST) - build_info(devicetree extra-user-files PATH ${EXTRA_DTC_OVERLAY_FILE_AS_LIST}) - list(APPEND - dts_files - ${EXTRA_DTC_OVERLAY_FILE_AS_LIST} + build_info(devicetree user-files PATH ${DTC_OVERLAY_FILE_AS_LIST}) + list(APPEND + dts_files + ${DTC_OVERLAY_FILE_AS_LIST} ) -endif() - -set(i 0) -foreach(dts_file ${dts_files}) - if(i EQUAL 0) - message(STATUS "Found BOARD.dts: ${dts_file}") - else() - message(STATUS "Found devicetree overlay: ${dts_file}") endif() - math(EXPR i "${i}+1") -endforeach() - -unset(DTS_ROOT_BINDINGS) -foreach(dts_root ${DTS_ROOT}) - set(bindings_path ${dts_root}/dts/bindings) - if(EXISTS ${bindings_path}) + if(EXTRA_DTC_OVERLAY_FILE) + zephyr_list(TRANSFORM EXTRA_DTC_OVERLAY_FILE NORMALIZE_PATHS + OUTPUT_VARIABLE EXTRA_DTC_OVERLAY_FILE_AS_LIST + ) + build_info(devicetree extra-user-files PATH ${EXTRA_DTC_OVERLAY_FILE_AS_LIST}) list(APPEND - DTS_ROOT_BINDINGS - ${bindings_path} - ) - endif() - - set(vendor_prefixes ${dts_root}/${VENDOR_PREFIXES}) - if(EXISTS ${vendor_prefixes}) - list(APPEND EXTRA_GEN_EDT_ARGS --vendor-prefixes ${vendor_prefixes}) + dts_files + ${EXTRA_DTC_OVERLAY_FILE_AS_LIST} + ) endif() -endforeach() -# Cache the location of the root bindings so they can be used by -# scripts which use the build directory. -set(CACHED_DTS_ROOT_BINDINGS ${DTS_ROOT_BINDINGS} CACHE INTERNAL - "DT bindings root directories") - -# -# Run the C preprocessor on the devicetree source, so we can parse it -# (using the Python devicetree package) in later steps. -# + set(i 0) + foreach(dts_file ${dts_files}) + if(i EQUAL 0) + message(STATUS "Found BOARD.dts: ${dts_file}") + else() + message(STATUS "Found devicetree overlay: ${dts_file}") + endif() -# TODO: Cut down on CMake configuration time by avoiding -# regeneration of devicetree_generated.h on every configure. How -# challenging is this? Can we cache the dts dependencies? - -# Run the preprocessor on the DTS input files. -if(DEFINED CMAKE_DTS_PREPROCESSOR) - set(dts_preprocessor ${CMAKE_DTS_PREPROCESSOR}) -else() - set(dts_preprocessor ${CMAKE_C_COMPILER}) -endif() -zephyr_dt_preprocess( - CPP ${dts_preprocessor} - SOURCE_FILES ${dts_files} - OUT_FILE ${DTS_POST_CPP} - DEPS_FILE ${DTS_DEPS} - EXTRA_CPPFLAGS ${DTS_EXTRA_CPPFLAGS} - INCLUDE_DIRECTORIES ${DTS_ROOT_SYSTEM_INCLUDE_DIRS} - WORKING_DIRECTORY ${APPLICATION_SOURCE_DIR} - ) + math(EXPR i "${i}+1") + endforeach() -# Fetch variable from sysbuild which might be forcing a configuration (for variant build images) -zephyr_get(DTS_DEPS SYSBUILD LOCAL) + unset(DTS_ROOT_BINDINGS) + foreach(dts_root ${DTS_ROOT}) + set(bindings_path ${dts_root}/dts/bindings) + if(EXISTS ${bindings_path}) + list(APPEND + DTS_ROOT_BINDINGS + ${bindings_path} + ) + endif() -# -# Make sure we re-run CMake if any devicetree sources or transitive -# includes change. -# + set(vendor_prefixes ${dts_root}/${VENDOR_PREFIXES}) + if(EXISTS ${vendor_prefixes}) + list(APPEND EXTRA_GEN_EDT_ARGS --vendor-prefixes ${vendor_prefixes}) + endif() -# Parse the generated dependency file to find the DT sources that -# were included, including any transitive includes. -toolchain_parse_make_rule(${DTS_DEPS} - DTS_INCLUDE_FILES # Output parameter - ) + set(DTS_ROOT_BINDINGS ${DTS_ROOT_BINDINGS} PARENT_SCOPE) + endforeach() -# Add the results to the list of files that, when change, force the -# build system to re-run CMake. -set_property(DIRECTORY APPEND PROPERTY - CMAKE_CONFIGURE_DEPENDS - ${DTS_INCLUDE_FILES} - ${GEN_EDT_SCRIPT} - ${GEN_DEFINES_SCRIPT} - ${GEN_DRIVER_KCONFIG_SCRIPT} + # Cache the location of the root bindings so they can be used by + # scripts which use the build directory. + set(CACHED_DTS_ROOT_BINDINGS ${DTS_ROOT_BINDINGS} CACHE INTERNAL + "DT bindings root directories" ) - -# -# Run GEN_EDT_SCRIPT. -# - -if(WEST_TOPDIR) - set(GEN_EDT_WORKSPACE_DIR ${WEST_TOPDIR}) -else() - # If West is not available, define the parent directory of ZEPHYR_BASE as - # the workspace. This will create comments that reference the files in the - # Zephyr tree with a 'zephyr/' prefix. - set(GEN_EDT_WORKSPACE_DIR ${ZEPHYR_BASE}/..) -endif() - -string(REPLACE ";" " " EXTRA_DTC_FLAGS_RAW "${EXTRA_DTC_FLAGS}") -set(CMD_GEN_EDT ${PYTHON_EXECUTABLE} ${GEN_EDT_SCRIPT} ---dts ${DTS_POST_CPP} ---dtc-flags '${EXTRA_DTC_FLAGS_RAW}' ---bindings-dirs ${DTS_ROOT_BINDINGS} ---workspace-dir ${GEN_EDT_WORKSPACE_DIR} ---dts-out ${ZEPHYR_DTS}.new # for debugging and dtc ---edt-pickle-out ${EDT_PICKLE}.new -${EXTRA_GEN_EDT_ARGS} -) - -execute_process( - COMMAND ${CMD_GEN_EDT} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMAND_ERROR_IS_FATAL ANY + set(dts_files ${dts_files} PARENT_SCOPE) + set(DTS_SOURCE ${DTS_SOURCE} PARENT_SCOPE) + set(EXTRA_GEN_EDT_ARGS ${EXTRA_GEN_EDT_ARGS} PARENT_SCOPE) +endfunction() + +function(dts_edt_pickle) + # + # Run the C preprocessor on the devicetree source, so we can parse it + # (using the Python devicetree package) in later steps. + # + + # TODO: Cut down on CMake configuration time by avoiding + # regeneration of devicetree_generated.h on every configure. How + # challenging is this? Can we cache the dts dependencies? + + # Run the preprocessor on the DTS input files. + if(DEFINED CMAKE_DTS_PREPROCESSOR) + set(dts_preprocessor ${CMAKE_DTS_PREPROCESSOR}) + else() + set(dts_preprocessor ${CMAKE_C_COMPILER}) + endif() + zephyr_dt_preprocess( + CPP ${dts_preprocessor} + SOURCE_FILES ${dts_files} + OUT_FILE ${DTS_POST_CPP} + DEPS_FILE ${DTS_DEPS} + EXTRA_CPPFLAGS ${DTS_EXTRA_CPPFLAGS} + INCLUDE_DIRECTORIES ${DTS_ROOT_SYSTEM_INCLUDE_DIRS} + WORKING_DIRECTORY ${APPLICATION_SOURCE_DIR} ) -zephyr_file_copy(${ZEPHYR_DTS}.new ${ZEPHYR_DTS} ONLY_IF_DIFFERENT) -zephyr_file_copy(${EDT_PICKLE}.new ${EDT_PICKLE} ONLY_IF_DIFFERENT) -file(REMOVE ${ZEPHYR_DTS}.new ${EDT_PICKLE}.new) -message(STATUS "Generated zephyr.dts: ${ZEPHYR_DTS}") -message(STATUS "Generated pickled edt: ${EDT_PICKLE}") -# -# Run GEN_DEFINES_SCRIPT. -# + # Fetch variable from sysbuild which might be forcing a configuration (for variant build images) + zephyr_get(DTS_DEPS SYSBUILD LOCAL) -set(CMD_GEN_DEFINES ${PYTHON_EXECUTABLE} ${GEN_DEFINES_SCRIPT} ---header-out ${DEVICETREE_GENERATED_H}.new ---edt-pickle ${EDT_PICKLE} -${EXTRA_GEN_DEFINES_ARGS} -) + # + # Make sure we re-run CMake if any devicetree sources or transitive + # includes change. + # -execute_process( - COMMAND ${CMD_GEN_DEFINES} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMAND_ERROR_IS_FATAL ANY + # Parse the generated dependency file to find the DT sources that + # were included, including any transitive includes. + toolchain_parse_make_rule(${DTS_DEPS} + DTS_INCLUDE_FILES # Output parameter ) -zephyr_file_copy(${DEVICETREE_GENERATED_H}.new ${DEVICETREE_GENERATED_H} ONLY_IF_DIFFERENT) -file(REMOVE ${DEVICETREE_GENERATED_H}.new) -message(STATUS "Generated devicetree_generated.h: ${DEVICETREE_GENERATED_H}") -# -# Run GEN_DRIVER_KCONFIG_SCRIPT. -# + set(DTS_INCLUDE_FILES ${DTS_INCLUDE_FILES} PARENT_SCOPE) -execute_process( - COMMAND ${PYTHON_EXECUTABLE} ${GEN_DRIVER_KCONFIG_SCRIPT} - --kconfig-out ${DTS_KCONFIG} - --bindings-dirs ${DTS_ROOT_BINDINGS} - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - RESULT_VARIABLE ret + # Add the results to the list of files that, when change, force the + # build system to re-run CMake. + set_property(DIRECTORY APPEND PROPERTY + CMAKE_CONFIGURE_DEPENDS + ${DTS_INCLUDE_FILES} + ${GEN_EDT_SCRIPT} + ${GEN_DEFINES_SCRIPT} + ${GEN_DRIVER_KCONFIG_SCRIPT} ) -if(NOT "${ret}" STREQUAL "0") - message(FATAL_ERROR "gen_driver_kconfig_dts.py failed with return code: ${ret}") -endif() -# -# Import devicetree contents into CMake. -# This enables the CMake dt_* API. -# + # + # Run GEN_EDT_SCRIPT. + # -add_custom_target(devicetree_target) -zephyr_dt_import(EDT_PICKLE_FILE ${EDT_PICKLE} TARGET devicetree_target) + if(WEST_TOPDIR) + set(gen_edt_workspace_dir ${WEST_TOPDIR}) + else() + # If West is not available, define the parent directory of ZEPHYR_BASE as + # the workspace. This will create comments that reference the files in the + # Zephyr tree with a 'zephyr/' prefix. + set(gen_edt_workspace_dir ${ZEPHYR_BASE}/..) + endif() -# -# Run dtc if it was found. -# -# This is just to generate warnings and errors; we discard the output. -# + string(REPLACE ";" " " EXTRA_DTC_FLAGS_RAW "${EXTRA_DTC_FLAGS}") + set(cmd_gen_edt ${PYTHON_EXECUTABLE} ${GEN_EDT_SCRIPT} + --dts ${DTS_POST_CPP} + --dtc-flags '${EXTRA_DTC_FLAGS_RAW}' + --bindings-dirs ${CACHED_DTS_ROOT_BINDINGS} + --workspace-dir ${gen_edt_workspace_dir} + --dts-out ${ZEPHYR_DTS}.new # for debugging and dtc + --edt-pickle-out ${EDT_PICKLE}.new + ${EXTRA_GEN_EDT_ARGS} + ) -if(DTC) - -set(DTC_WARN_UNIT_ADDR_IF_ENABLED "") -check_dtc_flag("-Wunique_unit_address_if_enabled" check) -if(check) - set(DTC_WARN_UNIT_ADDR_IF_ENABLED "-Wunique_unit_address_if_enabled") -endif() - -set(DTC_NO_WARN_UNIT_ADDR "") -check_dtc_flag("-Wno-unique_unit_address" check) -if(check) - set(DTC_NO_WARN_UNIT_ADDR "-Wno-unique_unit_address") -endif() - -set(VALID_EXTRA_DTC_FLAGS "") -foreach(extra_opt ${EXTRA_DTC_FLAGS}) - check_dtc_flag(${extra_opt} check) - if(check) - list(APPEND VALID_EXTRA_DTC_FLAGS ${extra_opt}) - endif() -endforeach() -set(EXTRA_DTC_FLAGS ${VALID_EXTRA_DTC_FLAGS}) - -execute_process( - COMMAND ${DTC} - -O dts - -o - # Write output to stdout, which we discard below - -b 0 - -E unit_address_vs_reg - ${DTC_NO_WARN_UNIT_ADDR} - ${DTC_WARN_UNIT_ADDR_IF_ENABLED} - ${EXTRA_DTC_FLAGS} # User settable - ${ZEPHYR_DTS} - OUTPUT_QUIET # Discard stdout - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMAND_ERROR_IS_FATAL ANY + execute_process( + COMMAND ${cmd_gen_edt} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + zephyr_file_copy(${ZEPHYR_DTS}.new ${ZEPHYR_DTS} ONLY_IF_DIFFERENT) + zephyr_file_copy(${EDT_PICKLE}.new ${EDT_PICKLE} ONLY_IF_DIFFERENT) + file(REMOVE ${ZEPHYR_DTS}.new ${EDT_PICKLE}.new) + message(STATUS "Generated zephyr.dts: ${ZEPHYR_DTS}") + message(STATUS "Generated pickled edt: ${EDT_PICKLE}") +endfunction() + +function(dts_gen_defines) + # + # Run GEN_DEFINES_SCRIPT. + # + + set(cmd_gen_defines ${PYTHON_EXECUTABLE} ${GEN_DEFINES_SCRIPT} + --header-out ${DEVICETREE_GENERATED_H}.new + --edt-pickle ${EDT_PICKLE} + ${EXTRA_GEN_DEFINES_ARGS} ) -endif(DTC) + execute_process( + COMMAND ${cmd_gen_defines} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + zephyr_file_copy(${DEVICETREE_GENERATED_H}.new ${DEVICETREE_GENERATED_H} ONLY_IF_DIFFERENT) + file(REMOVE ${DEVICETREE_GENERATED_H}.new) + message(STATUS "Generated devicetree_generated.h: ${DEVICETREE_GENERATED_H}") +endfunction() + +function(dts_gen_driver_kconfig) + # + # Run GEN_DRIVER_KCONFIG_SCRIPT. + # + + execute_process( + COMMAND ${PYTHON_EXECUTABLE} ${GEN_DRIVER_KCONFIG_SCRIPT} + --kconfig-out ${DTS_KCONFIG} + --bindings-dirs ${CACHED_DTS_ROOT_BINDINGS} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + RESULT_VARIABLE ret + ) + if(NOT "${ret}" STREQUAL "0") + message(FATAL_ERROR "gen_driver_kconfig_dts.py failed with return code: ${ret}") + endif() +endfunction() + +function(dts_import) + # + # Import devicetree contents into CMake. + # This enables the CMake dt_* API. + # + + add_custom_target(devicetree_target) + zephyr_dt_import(EDT_PICKLE_FILE ${EDT_PICKLE} TARGET devicetree_target) +endfunction() + +function(dts_dtc) + # + # Run dtc if it was found. + # + # This is just to generate warnings and errors; we discard the output. + # + if(DTC) + set(DTC_WARN_UNIT_ADDR_IF_ENABLED "") + check_dtc_flag("-Wunique_unit_address_if_enabled" check) + if(check) + set(DTC_WARN_UNIT_ADDR_IF_ENABLED "-Wunique_unit_address_if_enabled") + endif() -build_info(devicetree files PATH ${dts_files}) -build_info(devicetree include-dirs PATH ${DTS_ROOT_SYSTEM_INCLUDE_DIRS}) -build_info(devicetree bindings-dirs PATH ${DTS_ROOT_BINDINGS}) + set(DTC_NO_WARN_UNIT_ADDR "") + check_dtc_flag("-Wno-unique_unit_address" check) + if(check) + set(DTC_NO_WARN_UNIT_ADDR "-Wno-unique_unit_address") + endif() + + set(VALID_EXTRA_DTC_FLAGS "") + foreach(extra_opt ${EXTRA_DTC_FLAGS}) + check_dtc_flag(${extra_opt} check) + if(check) + list(APPEND VALID_EXTRA_DTC_FLAGS ${extra_opt}) + endif() + endforeach() + set(EXTRA_DTC_FLAGS ${VALID_EXTRA_DTC_FLAGS}) + set(EXTRA_DTC_FLAGS ${EXTRA_DTC_FLAGS} PARENT_SCOPE) + + execute_process( + COMMAND ${DTC} + -O dts + -o - # Write output to stdout, which we discard below + -b 0 + -E unit_address_vs_reg + ${DTC_NO_WARN_UNIT_ADDR} + ${DTC_WARN_UNIT_ADDR_IF_ENABLED} + ${EXTRA_DTC_FLAGS} # User settable + ${ZEPHYR_DTS} + OUTPUT_QUIET # Discard stdout + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMAND_ERROR_IS_FATAL ANY + ) + endif(DTC) +endfunction() + +function(dts_build_info_output) + build_info(devicetree files PATH ${dts_files}) + build_info(devicetree include-dirs PATH ${DTS_ROOT_SYSTEM_INCLUDE_DIRS}) + build_info(devicetree bindings-dirs PATH ${CACHED_DTS_ROOT_BINDINGS}) +endfunction() + +macro(dts_init) + dts_configuration_files() + dts_edt_pickle() + dts_gen_defines() + dts_gen_driver_kconfig() + dts_import() + dts_dtc() + dts_build_info_output() +endmacro() diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 845a89833836..093e830cd378 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -5308,10 +5308,20 @@ function(zephyr_linker_section) # If KVMA is set and the Kernel virtual memory settings reqs are met, we # substitute the VMA setting with the specified KVMA value. if(CONFIG_MMU) - math(EXPR KERNEL_MEM_VM_OFFSET - "(${CONFIG_KERNEL_VM_BASE} + ${CONFIG_KERNEL_VM_OFFSET})\ - - (${CONFIG_SRAM_BASE_ADDRESS} + ${CONFIG_SRAM_OFFSET})" - ) + if(CONFIG_SRAM_DEPRECATED_KCONFIG_SET) + math(EXPR KERNEL_MEM_VM_OFFSET + "(${CONFIG_KERNEL_VM_BASE} + ${CONFIG_KERNEL_VM_OFFSET}) \ + - (${CONFIG_SRAM_BASE_ADDRESS} + ${CONFIG_SRAM_OFFSET})" + ) + else() + dt_chosen(chosen_sram_path PROPERTY "zephyr,sram") + dt_reg_addr(ram_addr PATH "${chosen_sram_path}") + + math(EXPR KERNEL_MEM_VM_OFFSET + "(${CONFIG_KERNEL_VM_BASE} + ${CONFIG_KERNEL_VM_OFFSET}) \ + - (${ram_addr} + ${CONFIG_SRAM_OFFSET})" + ) + endif() if(NOT (${KERNEL_MEM_VM_OFFSET} EQUAL 0)) set(SECTION_VMA ${SECTION_KVMA}) diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index 310a836eebcf..53aa705fdc9b 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -257,3 +257,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/zephyr_default.cmake b/cmake/modules/zephyr_default.cmake index 6cf27ebbde2a..fd05a1fb190c 100644 --- a/cmake/modules/zephyr_default.cmake +++ b/cmake/modules/zephyr_default.cmake @@ -128,6 +128,12 @@ foreach(module IN LISTS zephyr_cmake_modules) string(CONFIGURE "${module}" module) include(${module}) + if(NOT "${module}" MATCHES ";") + if(COMMAND ${module}_init) + cmake_language(CALL ${module}_init) + endif() + endif() + list(REMOVE_ITEM SUB_COMPONENTS ${module}) if(DEFINED SUB_COMPONENTS AND NOT SUB_COMPONENTS) # All requested Zephyr CMake modules have been loaded, so let's return. diff --git a/doc/_extensions/zephyr/kconfig/__init__.py b/doc/_extensions/zephyr/kconfig/__init__.py index e977a3b734a8..98422c8ba2fc 100644 --- a/doc/_extensions/zephyr/kconfig/__init__.py +++ b/doc/_extensions/zephyr/kconfig/__init__.py @@ -114,6 +114,9 @@ def kconfig_load(app: Sphinx) -> tuple[kconfiglib.Kconfig, kconfiglib.Kconfig, d for folder in soc_folders: f.write('source "' + (Path(folder) / 'Kconfig.soc').as_posix() + '"\n') + if "nordic" in folder: + f.write('osource "' + (Path(folder) / 'Kconfig.sysbuild').as_posix() + '"\n') + with open(Path(td) / "soc" / "Kconfig", "w") as f: for folder in soc_folders: f.write('osource "' + (Path(folder) / 'Kconfig').as_posix() + '"\n') diff --git a/doc/build/kconfig/setting.rst b/doc/build/kconfig/setting.rst index 17eafc95a3be..cbaf9c5b3897 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: diff --git a/doc/connectivity/networking/api/wifi_crypto.rst b/doc/connectivity/networking/api/wifi_crypto.rst index e7011680f49a..ba418e7fb9cc 100644 --- a/doc/connectivity/networking/api/wifi_crypto.rst +++ b/doc/connectivity/networking/api/wifi_crypto.rst @@ -18,7 +18,11 @@ Feature set (from hostap Kconfig) Features are gated by Kconfig. Relevant options include: * :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_WEP` — WEP (legacy) -* :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3` — WPA3-SAE (default on) +* :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_COMMON` — WPA3-SAE when Internal or + External is selected (``WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION``; default Internal). + :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3` is promptless and turns on the internal + bignum SAE path when Internal is chosen (set the implementation choice in ``prj.conf``, not + this symbol). * :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP` — Wi-Fi Easy Connect (DPP) * :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_WPS` — Wi-Fi Protected Setup * :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P` — P2P / Wi-Fi Direct (implies WPS) diff --git a/doc/connectivity/usb/device_next/cdc_acm.rst b/doc/connectivity/usb/device_next/cdc_acm.rst index 1fa7559b191a..eaf56483e680 100644 --- a/doc/connectivity/usb/device_next/cdc_acm.rst +++ b/doc/connectivity/usb/device_next/cdc_acm.rst @@ -97,6 +97,15 @@ As the configuration would be identical for any board, there are common :zephyr_file:`Kconfig file ` that must be included in the board's devicetree and Kconfig.defconfig files. +Application can use :kconfig:option:`CONFIG_CDC_ACM_SERIAL_MULTIPLE_INSTANCES` +if different CDC ACM serial backends are required for common use cases such as +logging, the shell, and specific protocols. This option also guarantees the +order in which the instances will be registered and appear in the configuration +descriptor. The option uses the chosen node properties to identify UART devices. +The following are currently supported, in this order: +"zephyr,console", "zephyr,shell-uart", "zephyr,uart-mcumgr". +A supported property may be missing, and properties may reference the same device. + Using CDC ACM UART in the application ===================================== diff --git a/doc/develop/application/index.rst b/doc/develop/application/index.rst index 3e6cceb55342..4346d10f6592 100644 --- a/doc/develop/application/index.rst +++ b/doc/develop/application/index.rst @@ -649,9 +649,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/hardware/arch/x86.rst b/doc/hardware/arch/x86.rst index 1587efa38c34..668aee24c80a 100644 --- a/doc/hardware/arch/x86.rst +++ b/doc/hardware/arch/x86.rst @@ -16,8 +16,8 @@ During very early boot, page tables are loaded so technically the kernel is executing in virtual address space. By default, physical and virtual memory are identity mapped and thus giving the appearance of execution taking place in physical address space. The physical address space is -marked by kconfig :kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` and -:kconfig:option:`CONFIG_SRAM_SIZE` while the virtual address space is marked by +marked by dts :c:macro:`DT_CHOSEN_SRAM_ADDR` and +:c:macro:`DT_CHOSEN_SRAM_SIZE` while the virtual address space is marked by :kconfig:option:`CONFIG_KERNEL_VM_BASE` and :kconfig:option:`CONFIG_KERNEL_VM_SIZE`. Note that :kconfig:option:`CONFIG_SRAM_OFFSET` controls where the Zephyr kernel is being placed in the memory, and its counterpart @@ -60,17 +60,17 @@ There are restrictions on where virtual address space can be: - Assuming ``CONFIG_SRAM_OFFSET`` and ``CONFIG_KERNEL_VM_OFFSET`` are both ``0x0``. - - ``CONFIG_SRAM_BASE_ADDRESS == 0x00000000`` and + - ``DT_CHOSEN_SRAM_ADDR == 0x00000000`` and ``CONFIG_KERNEL_VM_BASE = 0x40000000`` is valid, while - - ``CONFIG_SRAM_BASE_ADDRESS == 0x00000000`` and + - ``DT_CHOSEN_SRAM_ADDR == 0x00000000`` and ``CONFIG_KERNEL_VM_BASE = 0x20000000`` is not. - If :kconfig:option:`CONFIG_X86_PAE` is disabled (``=n``), each address space must reside in their own 4MB region, due to each entry of PD (Page Directory) covers 4MB of memory. - - Both ``CONFIG_SRAM_BASE_ADDRESS`` and ``CONFIG_KERNEL_VM_BASE`` + - Both ``DT_CHOSEN_SRAM_ADDR`` and ``CONFIG_KERNEL_VM_BASE`` must also align with the starting addresses of targeted regions. Specifying Additional Memory Mappings at Build Time 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/kernel/memory_management/virtual_memory.rst b/doc/kernel/memory_management/virtual_memory.rst index 4e2f11e90c7b..e566166d2e97 100644 --- a/doc/kernel/memory_management/virtual_memory.rst +++ b/doc/kernel/memory_management/virtual_memory.rst @@ -121,7 +121,7 @@ below. * If it is enabled, which means all physical memory are mapped in virtual memory address space, and it is the same as - (:kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` + :kconfig:option:`CONFIG_SRAM_SIZE`). + (:c:macro:`DT_CHOSEN_SRAM_ADDR` + :c:macro:`DT_CHOSEN_SRAM_SIZE`). * If it is disabled, ``K_MEM_VM_FREE_START`` is the same ``K_MEM_KERNEL_VIRT_END`` which is the end of the kernel image. diff --git a/doc/releases/migration-guide-4.4.rst b/doc/releases/migration-guide-4.4.rst index 5829b067c99c..f6e2f4434bb9 100644 --- a/doc/releases/migration-guide-4.4.rst +++ b/doc/releases/migration-guide-4.4.rst @@ -1210,6 +1210,9 @@ Bluetooth HCI Networking ********** +Wi-Fi +===== + * :c:struct:`wifi_channel_info` gained a ``band`` field for set-channel. Behaviour is backwards compatible for 2.4 GHz (channels 1–14) and 5 GHz (36–165): omit or leave ``band`` as :c:macro:`WIFI_FREQ_BAND_UNKNOWN` and the driver infers the @@ -1217,6 +1220,15 @@ Networking numbers overlap 1–14 with 2.4 GHz). Recompile so ``sizeof(struct wifi_channel_info)`` is correct when calling net_mgmt. +* WPA3 is configured with the choice + ``WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION`` (Internal, External, or None). + Replace any ``CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3=y`` line in ``prj.conf`` with + ``CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_INT=y`` (or ``_EXT`` / + ``_NONE`` as needed). :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3` is + now promptless and is selected only when Internal is chosen; do not assign it + directly. In C code, prefer :kconfig:option:`CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_COMMON` + to detect either internal or external WPA3. + * Networking APIs found in * :zephyr_file:`include/zephyr/net/net_ip.h` diff --git a/doc/releases/migration-guide-4.5.rst b/doc/releases/migration-guide-4.5.rst index e928cb873858..a21a720ba5d1 100644 --- a/doc/releases/migration-guide-4.5.rst +++ b/doc/releases/migration-guide-4.5.rst @@ -32,6 +32,12 @@ Kernel Boards ****** +* The Kconfig options :kconfig:option:`CONFIG_SRAM_SIZE` and + :kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` have been deprecated, boards should instead use the + devicetree ``zephyr.sram`` chosen node to specify the RAM node which will be used (whose values + populated the Kconfig values). If either option is manually adjusted, it will cause + :kconfig:option:`CONFIG_SRAM_DEPRECATED_KCONFIG_SET` to be set which indicates this deprecation. + Device Drivers and Devicetree ***************************** diff --git a/doc/services/device_mgmt/ota.rst b/doc/services/device_mgmt/ota.rst index c4e9bb3a737b..6cf6e67a26e4 100644 --- a/doc/services/device_mgmt/ota.rst +++ b/doc/services/device_mgmt/ota.rst @@ -19,90 +19,41 @@ same method can be used as part of OTA. The binary is first downloaded into an unoccupied code partition, usually named ``slot1_partition``, then upgraded using the :ref:`mcuboot` process. -Examples of OTA -*************** - -Golioth -======= - -`Golioth`_ is an IoT management platform that includes OTA updates. Devices are -configured to observe your available firmware revisions on the Golioth Cloud. -When a new version is available, the device downloads and flashes the binary. In -this implementation, the connection between cloud and device is secured using -TLS/DTLS, and the signed firmware binary is confirmed by MCUboot before the -upgrade occurs. - -1. A working sample can be found on the `Golioth Firmware SDK repository`_ -2. The `Golioth OTA documentation`_ includes complete information about the - versioning process - -Eclipse hawkBit™ -================ - -`Eclipse hawkBit™`_ is an update server framework that uses polling on a -REST api to detect firmware updates. When a new update is detected, the binary -is downloaded and installed. MCUboot can be used to verify the signature before -upgrading the firmware. - -There is a :zephyr:code-sample:`hawkbit-api` sample included in the -Zephyr :zephyr:code-sample-category:`mgmt` section. - -UpdateHub -========= - -`UpdateHub`_ is a platform for remotely updating embedded devices. Updates can -be manually triggered or monitored via polling. When a new update is detected, -the binary is downloaded and installed. MCUboot can be used to verify the -signature before upgrading the firmware. - -There is an :zephyr:code-sample:`updatehub-fota` sample included in the Zephyr -:zephyr:code-sample-category:`mgmt` section. - -SMP Server -========== - -A Simple Management Protocol (SMP) server can be used to update firmware via -Bluetooth Low Energy (LE) or UDP. :ref:`mcu_mgr` is used to send a signed -firmware binary to the remote device where it is verified by MCUboot before the -upgrade occurs. - -There is an :zephyr:code-sample:`smp-svr` sample included in the Zephyr -:zephyr:code-sample-category:`mgmt` section. - -Lightweight M2M (LWM2M) -======================= - -The :ref:`lwm2m_interface` protocol includes support for firmware update via -:kconfig:option:`CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT`. Devices securely -connect to an LwM2M server using DTLS. A :zephyr:code-sample:`lwm2m-client` sample is -available but it does not demonstrate the firmware update feature. - -mender-mcu -========== - -`mender-mcu`_ enables robust firmware updates on resource-constrained devices by -integrating with Zephyr. It implements an Update Module interface and provides -a default Update Module that integrates with MCUboot to provide A/B updates. -This allows microcontroller units (MCUs) to perform atomic, fail-safe OTA -updates with automatic rollback on failure. - -See :ref:`external_module_mender_mcu` for integration details and examples. - Memfault and nRF Cloud powered by Memfault -========================================== - -`Memfault`_ is a IoT observability platform that includes OTA management. Devices check-in with -Memfault's service periodically for an OTA update, and when an update is available, download and -install the binary. - -See :ref:`external_module_memfault_firmware_sdk` for overall integration details and -examples. +****************************************** + +`Memfault`_ is an IoT observability platform that includes OTA management. +Devices check in with Memfault's service periodically for an OTA update, and +when an update is available, download and install the binary. + +Zephyr projects that use MCUboot and have a direct Internet connection can +leverage the `Memfault Firmware SDK's `_ OTA client to +download a payload from Memfault's OTA service, load it into the secondary +partition, and then reboot into the new image. +See `Memfault OTA for Zephyr documentation`_ for more details on this support +for Zephyr projects. + +For Nordic Semiconductor cellular chip users, the Memfault +Firmware SDK includes support for downloading the payload over a cellular +connection using nRF Connect SDK's FOTA and downloader libraries. +See the `Memfault Quickstart for the nRF91 Series`_ for more +information. Zephyr projects with a Bluetooth Low Energy connection can +leverage the `Memfault Diagnostic Service`_ (MDS) with the `Memfault iOS SDK`_ +and `Memfault Android SDK`_ to deliver the update payload to the device. For +Nordic Semiconductor's Bluetooth Low Energy chip users, the Zephyr-based +nRF Connect SDK provides an implementation of MDS. See the +`nRF Connect SDK documentation on MDS`_ for more information as well as +`nRF Cloud powered by Memfault`_ for detail on using the Memfault platform with +Nordic Semiconductor Bluetooth Low Energy chips. +See :ref:`external_module_memfault_firmware_sdk` for overall integration +details and examples. -.. _MCUboot bootloader: https://mcuboot.com/ -.. _Golioth: https://golioth.io/ -.. _Golioth Firmware SDK repository: https://github.com/golioth/golioth-firmware-sdk/tree/main/examples/zephyr/fw_update -.. _Golioth OTA documentation: https://docs.golioth.io/device-management/ota -.. _Eclipse hawkBit™: https://www.eclipse.org/hawkbit/ -.. _UpdateHub: https://updatehub.io/ -.. _mender-mcu: https://github.com/mendersoftware/mender-mcu .. _Memfault: https://memfault.com/ +.. _Memfault Firmware SDK: https://github.com/memfault/memfault-firmware-sdk +.. _Memfault OTA for Zephyr documentation: https://docs.memfault.com/docs/mcu/zephyr-guide#ota +.. _Memfault Quickstart for the nRF91 Series: https://docs.memfault.com/docs/mcu/quickstart-nrf9160 +.. _Memfault Diagnostic Service: https://docs.memfault.com/docs/mcu/mds +.. _Memfault iOS SDK: https://github.com/memfault/memfault-cloud-ios +.. _Memfault Android SDK: https://github.com/memfault/memfault-cloud-android +.. _nRF Connect SDK documentation on MDS: https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/libraries/bluetooth/services/mds.html +.. _nRF Cloud powered by Memfault: https://nrfcloud.com/#/ diff --git a/doc/services/tfm/testsuites.rst b/doc/services/tfm/testsuites.rst index 35824adabd85..7db00da5a2b8 100644 --- a/doc/services/tfm/testsuites.rst +++ b/doc/services/tfm/testsuites.rst @@ -12,7 +12,8 @@ in the samples/tfm_integration folder. TF-M Regression Tests ********************* -The regression test suite can be run via the :ref:`tfm_regression_test` sample. +The regression test suite can be run via the +:zephyr_file:`tests/modules/tf-m/regression` test. This sample tests various services and communication mechanisms across the NS/S boundary via the PSA APIs. They provide a useful sanity check for proper diff --git a/drivers/cache/cache_aspeed.c b/drivers/cache/cache_aspeed.c index b8fe9a81880b..c8b68510cbb5 100644 --- a/drivers/cache/cache_aspeed.c +++ b/drivers/cache/cache_aspeed.c @@ -23,8 +23,8 @@ #define CACHE_INVALID_REG 0xa54 #define CACHE_FUNC_CTRL_REG 0xa58 -#define CACHED_SRAM_ADDR CONFIG_SRAM_BASE_ADDRESS -#define CACHED_SRAM_SIZE KB(CONFIG_SRAM_SIZE) +#define CACHED_SRAM_ADDR DT_CHOSEN_SRAM_ADDR +#define CACHED_SRAM_SIZE DT_CHOSEN_SRAM_SIZE #define CACHED_SRAM_END (CACHED_SRAM_ADDR + CACHED_SRAM_SIZE - 1) #define CACHE_AREA_SIZE_LOG2 15 diff --git a/drivers/can/Kconfig.mcan b/drivers/can/Kconfig.mcan index db09fc800c11..96c5f22446f6 100644 --- a/drivers/can/Kconfig.mcan +++ b/drivers/can/Kconfig.mcan @@ -7,3 +7,18 @@ config CAN_MCAN bool help Enable the Bosch M_CAN CAN IP module driver backend. + +if CAN_MCAN + +config CAN_MCAN_TXBCF_POLL_INTERVAL_MS + int "Polling interval in milliseconds of TXBCF register if DAR is enabled" + default 75 + help + When DAR (Disable Automatic Retransmission), used for CAN_MODE_ONE_SHOT, + is enabled, and a transmission fails, a bug in the MCAN IP prevents the + TCF (Transmission Cancellation Finalized) interrupt from triggering, + despite the correct bit being set in the TXBCF register. It is thus + necessary to poll TXBCF register to detect when a transmission failed if + DAR is enabled. + +endif # CAN_MCAN diff --git a/drivers/can/can_mcan.c b/drivers/can/can_mcan.c index 513daad82199..351423d16ac5 100644 --- a/drivers/can/can_mcan.c +++ b/drivers/can/can_mcan.c @@ -17,6 +17,7 @@ LOG_MODULE_REGISTER(can_mcan, CONFIG_CAN_LOG_LEVEL); #define CAN_INIT_TIMEOUT_MS 100 +#define TXBCF_TIMER_TIMEOUT K_MSEC(CONFIG_CAN_MCAN_TXBCF_POLL_INTERVAL_MS) int can_mcan_read_reg(const struct device *dev, uint16_t reg, uint32_t *val) { @@ -276,7 +277,7 @@ int can_mcan_get_capabilities(const struct device *dev, can_mode_t *cap) { ARG_UNUSED(dev); - *cap = CAN_MODE_NORMAL | CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY; + *cap = CAN_MODE_NORMAL | CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY | CAN_MODE_ONE_SHOT; if (IS_ENABLED(CONFIG_CAN_MANUAL_RECOVERY_MODE)) { *cap |= CAN_MODE_MANUAL_RECOVERY; @@ -322,12 +323,78 @@ int can_mcan_start(const struct device *dev) return err; } + uint32_t cccr; + + err = can_mcan_read_reg(dev, CAN_MCAN_CCCR, &cccr); + if (err != 0) { + return err; + } + + if (cccr & CAN_MCAN_CCCR_DAR) { + /* + * When DAR (Disable Automatic Retransmission), used for CAN_MODE_ONE_SHOT, + * is enabled, and a transmission fails, a bug in the MCAN IP prevents the + * TCF (Transmission Cancellation Finalized) interrupt from triggering, + * despite the correct bit being set in the TXBCF register. It is thus + * necessary to poll TXBCF register to detect when a transmission failed if + * DAR is enabled. + */ + k_timer_start(&data->txbcf_timer, TXBCF_TIMER_TIMEOUT, TXBCF_TIMER_TIMEOUT); + } + data->common.started = true; pm_device_busy_set(dev); return err; } +static int can_mcan_read_txbcf(const struct device *dev) +{ + const struct can_mcan_config *config = dev->config; + const struct can_mcan_callbacks *cbs = config->callbacks; + struct can_mcan_data *data = dev->data; + uint32_t txbcfs; + int err; + can_tx_callback_t tx_cb; + void *user_data; + + err = can_mcan_read_reg(dev, CAN_MCAN_TXBCF, &txbcfs); + if (err != 0) { + LOG_ERR("failed to read tx cancellation finished (err %d)", err); + return err; + } + + if (txbcfs == 0) { + return 0; + } + + for (size_t tx_idx = 0; tx_idx < cbs->num_tx; tx_idx++) { + if ((txbcfs & BIT(tx_idx)) == 0) { + continue; + } + + if (cbs->tx[tx_idx].function == NULL) { + continue; + } + + tx_cb = cbs->tx[tx_idx].function; + user_data = cbs->tx[tx_idx].user_data; + cbs->tx[tx_idx].function = NULL; + LOG_DBG("tx buffer cancellation finished (idx %u)", tx_idx); + k_sem_give(&data->tx_sem); + tx_cb(dev, -EIO, user_data); + } + + return 0; +} + +static void can_mcan_txbcf_timer_handler(struct k_timer *timer_id) +{ + const struct device *dev = k_timer_user_data_get(timer_id); + + can_mcan_read_txbcf(dev); +} + static bool can_mcan_rx_filters_exist(const struct device *dev) { const struct can_mcan_config *config = dev->config; @@ -362,6 +429,8 @@ int can_mcan_stop(const struct device *dev) return -EALREADY; } + k_timer_stop(&data->txbcf_timer); + /* CAN transmissions are automatically stopped when entering init mode */ err = can_mcan_enter_init_mode(dev, K_MSEC(CAN_INIT_TIMEOUT_MS)); if (err != 0) { @@ -402,7 +471,7 @@ int can_mcan_stop(const struct device *dev) int can_mcan_set_mode(const struct device *dev, can_mode_t mode) { - can_mode_t supported = CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY; + can_mode_t supported = CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY | CAN_MODE_ONE_SHOT; struct can_mcan_data *data = dev->data; uint32_t cccr; uint32_t test; @@ -460,6 +529,13 @@ int can_mcan_set_mode(const struct device *dev, can_mode_t mode) } #endif /* CONFIG_CAN_FD_MODE */ + if ((mode & CAN_MODE_ONE_SHOT) != 0) { + /* Disable Automatic Retransmission */ + cccr |= CAN_MCAN_CCCR_DAR; + } else { + cccr &= ~CAN_MCAN_CCCR_DAR; + } + err = can_mcan_write_reg(dev, CAN_MCAN_CCCR, cccr); if (err != 0) { goto unlock; @@ -1055,6 +1131,21 @@ int can_mcan_send(const struct device *dev, const struct can_frame *frame, k_tim } } + uint32_t cccr; + + err = can_mcan_read_reg(dev, CAN_MCAN_CCCR, &cccr); + if (err != 0) { + return err; + } + + if (cccr & CAN_MCAN_CCCR_DAR) { + /* + * TXBCR is cleared after TXBAR is set. Stop timer to ensure + * TXBCR is not read before TXBAR has been set. + */ + k_timer_stop(&data->txbcf_timer); + } + cbs->tx[put_idx].function = callback; cbs->tx[put_idx].user_data = user_data; @@ -1064,10 +1155,18 @@ int can_mcan_send(const struct device *dev, const struct can_frame *frame, k_tim goto err_unlock; } + if (cccr & CAN_MCAN_CCCR_DAR) { + k_timer_start(&data->txbcf_timer, TXBCF_TIMER_TIMEOUT, TXBCF_TIMER_TIMEOUT); + } + k_mutex_unlock(&data->tx_mtx); return 0; err_unlock: + if (cccr & CAN_MCAN_CCCR_DAR) { + k_timer_start(&data->txbcf_timer, TXBCF_TIMER_TIMEOUT, TXBCF_TIMER_TIMEOUT); + } + k_mutex_unlock(&data->tx_mtx); k_sem_give(&data->tx_sem); @@ -1420,6 +1519,8 @@ int can_mcan_init(const struct device *dev) k_mutex_init(&data->lock); k_mutex_init(&data->tx_mtx); k_sem_init(&data->tx_sem, cbs->num_tx, cbs->num_tx); + k_timer_init(&data->txbcf_timer, can_mcan_txbcf_timer_handler, NULL); + k_timer_user_data_set(&data->txbcf_timer, (void *)dev); if (config->common.phy != NULL && !device_is_ready(config->common.phy)) { LOG_ERR("CAN transceiver not ready"); @@ -1578,5 +1679,14 @@ int can_mcan_init(const struct device *dev) return err; } + /* + * Interrupt on every TX buffer cancellation finished event. + */ + reg = CAN_MCAN_TXBCIE_CFIE; + err = can_mcan_write_reg(dev, CAN_MCAN_TXBCIE, reg); + if (err != 0) { + return err; + } + return can_mcan_clear_mram(dev, 0, config->mram_size); } diff --git a/drivers/debug/debug_coresight_nrf.c b/drivers/debug/debug_coresight_nrf.c index f0762a871dc0..5bc4d094bc8f 100644 --- a/drivers/debug/debug_coresight_nrf.c +++ b/drivers/debug/debug_coresight_nrf.c @@ -134,8 +134,8 @@ static void nrf_stm_init(void) sys_write32((1 << STM_STMHEMCR_EN_Pos), stm + STM_STMHEMCR_OFFSET); } - sys_write32(((CONFIG_DEBUG_CORESIGHT_NRF_ATB_TRACE_ID_STM_GLOBAL & STM_STMTCSR_TRACEID_Msk) - << STM_STMTCSR_TRACEID_Pos) | + sys_write32(((CONFIG_DEBUG_CORESIGHT_NRF_ATB_TRACE_ID_STM_GLOBAL << STM_STMTCSR_TRACEID_Pos) + & STM_STMTCSR_TRACEID_Msk) | (1 << STM_STMTCSR_EN_Pos) | (1 << STM_STMTCSR_TSEN_Pos), stm + STM_STMTCSR_OFFSET); diff --git a/drivers/disk/flashdisk.c b/drivers/disk/flashdisk.c index bdb19fae1663..a23b719d4291 100644 --- a/drivers/disk/flashdisk.c +++ b/drivers/disk/flashdisk.c @@ -504,6 +504,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) @@ -545,6 +547,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/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index f6b8a6f5eef3..3e735a7edf78 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -36,6 +36,13 @@ LOG_MODULE_REGISTER(flash_nrf); #define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash) +#if CONFIG_TRUSTED_EXECUTION_NONSECURE +#include +#if USE_PARTITION_MANAGER +#include +#endif /* USE_PARTITION_MANAGER */ +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ + #ifndef CONFIG_SOC_FLASH_NRF_RADIO_SYNC_NONE #define FLASH_SLOT_WRITE 7500 #if defined(CONFIG_SOC_FLASH_NRF_PARTIAL_ERASE) @@ -165,6 +172,18 @@ static int flash_nrf_read(const struct device *dev, off_t addr, } #endif +#if CONFIG_TRUSTED_EXECUTION_NONSECURE +#if USE_PARTITION_MANAGER && PM_APP_ADDRESS + if (addr < PM_APP_ADDRESS) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#elif !USE_PARTITION_MANAGER && DT_NODE_EXISTS(DT_NODELABEL(slot0_ns_partition)) + if ((uintptr_t)addr < DT_REG_ADDR(DT_NODELABEL(slot0_ns_partition))) { + return soc_secure_mem_read(data, (void *)addr, len); + } +#endif +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE */ + nrf_nvmc_buffer_read(data, (uint32_t)addr, len); return 0; diff --git a/drivers/flash/soc_flash_nrf_rram.c b/drivers/flash/soc_flash_nrf_rram.c index 1f7f89b5509f..cd217a5f2c2d 100644 --- a/drivers/flash/soc_flash_nrf_rram.c +++ b/drivers/flash/soc_flash_nrf_rram.c @@ -54,6 +54,11 @@ LOG_MODULE_REGISTER(flash_nrf_rram, CONFIG_FLASH_LOG_LEVEL); #define WRITE_BLOCK_SIZE_FROM_DT DT_PROP(RRAM, write_block_size) #define ERASE_VALUE 0xFF +#if CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER +#include +#include +#endif /* CONFIG_TRUSTED_EXECUTION_NONSECURE && USE_PARTITION_MANAGER */ + #ifdef CONFIG_MULTITHREADING static struct k_sem sem_lock; #define SYNC_INIT() k_sem_init(&sem_lock, 1, 1) @@ -292,6 +297,12 @@ static int nrf_rram_read(const struct device *dev, off_t addr, void *data, size_ } addr += RRAM_START; +#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 + memcpy(data, (void *)addr, len); return 0; diff --git a/drivers/flash/spi_nor.c b/drivers/flash/spi_nor.c index e030a1d052d5..9bffb93dcdd6 100644 --- a/drivers/flash/spi_nor.c +++ b/drivers/flash/spi_nor.c @@ -50,6 +50,8 @@ LOG_MODULE_REGISTER(spi_nor, CONFIG_FLASH_LOG_LEVEL); #define ANY_INST_HAS_T_EXIT_DPD DT_ANY_INST_HAS_PROP_STATUS_OKAY(t_exit_dpd) #define ANY_INST_HAS_DPD_WAKEUP_SEQUENCE DT_ANY_INST_HAS_PROP_STATUS_OKAY(dpd_wakeup_sequence) #define ANY_INST_HAS_RESET_GPIOS DT_ANY_INST_HAS_PROP_STATUS_OKAY(reset_gpios) +#define ANY_INST_HAS_SUPPLY_GPIOS DT_ANY_INST_HAS_PROP_STATUS_OKAY(supply_gpios) +#define ANY_INST_HAS_T_RESET_RECOVERY DT_ANY_INST_HAS_PROP_STATUS_OKAY(t_reset_recovery) #define ANY_INST_HAS_WP_GPIOS DT_ANY_INST_HAS_PROP_STATUS_OKAY(wp_gpios) #define ANY_INST_HAS_HOLD_GPIOS DT_ANY_INST_HAS_PROP_STATUS_OKAY(hold_gpios) #define ANY_INST_USE_4B_ADDR_OPCODES DT_ANY_INST_HAS_BOOL_STATUS_OKAY(use_4b_addr_opcodes) @@ -81,6 +83,12 @@ struct spi_nor_config { #if ANY_INST_HAS_RESET_GPIOS const struct gpio_dt_spec reset; #endif +#if ANY_INST_HAS_SUPPLY_GPIOS + struct gpio_dt_spec supply; +#endif +#if ANY_INST_HAS_T_RESET_RECOVERY + uint32_t reset_recovery_us; +#endif /* Runtime SFDP stores no static configuration. */ @@ -1517,8 +1525,20 @@ static int spi_nor_configure(const struct device *dev) return -ENODEV; } -#if ANY_INST_HAS_RESET_GPIOS +#if ANY_INST_HAS_SUPPLY_GPIOS + if (cfg->supply.port != NULL) { + if (!gpio_is_ready_dt(&cfg->supply)) { + LOG_ERR("Supply GPIO port is not ready"); + return -ENODEV; + } + if (gpio_pin_configure_dt(&cfg->supply, GPIO_OUTPUT_ACTIVE)) { + LOG_ERR("Failed to activate power supply GPIO"); + return -EIO; + } + } +#endif +#if ANY_INST_HAS_RESET_GPIOS if (cfg->reset_gpios_exist) { if (!gpio_is_ready_dt(&cfg->reset)) { LOG_ERR("Reset pin not ready"); @@ -1535,6 +1555,12 @@ static int spi_nor_configure(const struct device *dev) } #endif +#if ANY_INST_HAS_T_RESET_RECOVERY + if (cfg->reset_recovery_us != 0) { + k_busy_wait(cfg->reset_recovery_us); + } +#endif + /* After a soft-reset the flash might be in DPD or busy writing/erasing. * Exit DPD and wait until flash is ready. */ @@ -1853,6 +1879,11 @@ static DEVICE_API(flash, spi_nor_api) = { #define INIT_RESET_GPIOS(idx) .reset = GPIO_DT_SPEC_INST_GET_OR(idx, reset_gpios, {0}) +#define INIT_SUPPLY_GPIOS(idx) .supply = GPIO_DT_SPEC_INST_GET_OR(idx, supply_gpios, {0}) + +#define INIT_T_RESET_RECOVERY(idx) \ + .reset_recovery_us = DT_INST_PROP_OR(idx, t_reset_recovery, 0) / NSEC_PER_USEC + #define INST_CONFIG_STRUCT_GEN(idx) \ DEFINE_PAGE_LAYOUT(idx) \ .flash_size = DT_INST_PROP(idx, size) / 8, \ @@ -1884,6 +1915,8 @@ static DEVICE_API(flash, spi_nor_api) = { IF_ENABLED(ANY_INST_HAS_MXICY_MX25R_POWER_MODE, \ (INIT_MXICY_MX25R_POWER_MODE(idx),)) \ IF_ENABLED(ANY_INST_HAS_RESET_GPIOS, (INIT_RESET_GPIOS(idx),)) \ + IF_ENABLED(ANY_INST_HAS_SUPPLY_GPIOS, (INIT_SUPPLY_GPIOS(idx),)) \ + IF_ENABLED(ANY_INST_HAS_T_RESET_RECOVERY, (INIT_T_RESET_RECOVERY(idx),)) \ IF_ENABLED(ANY_INST_HAS_WP_GPIOS, (INIT_WP_GPIOS(idx),)) \ IF_ENABLED(ANY_INST_HAS_HOLD_GPIOS, (INIT_HOLD_GPIOS(idx),)) \ IF_DISABLED(CONFIG_SPI_NOR_SFDP_RUNTIME, (INST_CONFIG_STRUCT_GEN(idx)))}; diff --git a/drivers/gpio/Kconfig.nrfx b/drivers/gpio/Kconfig.nrfx index bd77dbd35bd3..99340331f454 100644 --- a/drivers/gpio/Kconfig.nrfx +++ b/drivers/gpio/Kconfig.nrfx @@ -17,3 +17,7 @@ config GPIO_NRFX_INTERRUPT The option can be used to disable the GPIO interrupt support to significantly reduce memory footprint in case of application that does not need GPIO interrupts. + +config GPIO_NRFX_HAS_LATCH_DETECT + bool + default y if !(SOC_NRF54H20 || SOC_SERIES_NRF92 || TRUSTED_EXECUTION_NONSECURE) diff --git a/drivers/gpio/gpio_nrfx.c b/drivers/gpio/gpio_nrfx.c index f5e23f01659c..67aa1392fdf3 100644 --- a/drivers/gpio/gpio_nrfx.c +++ b/drivers/gpio/gpio_nrfx.c @@ -38,6 +38,10 @@ #define GPIOTE_FLAG_FIXED_CHAN BIT(1) #endif +#if NRF_GPIO_HAS_DETECT_MODE && defined(CONFIG_GPIO_NRFX_HAS_LATCH_DETECT) +#define GPIO_LATCH_DETECT_SUPPORT 1 +#endif + struct gpio_nrfx_data { /* gpio_driver_data needs to be first */ struct gpio_driver_data common; @@ -51,6 +55,9 @@ struct gpio_nrfx_cfg { nrfx_gpiote_t *gpiote; uint32_t edge_sense; uint8_t port_num; +#if defined(GPIO_LATCH_DETECT_SUPPORT) + bool latch_detect; +#endif #if defined(GPIOTE_FEATURE_FLAG) uint32_t flags; #endif @@ -449,6 +456,10 @@ static int gpio_nrfx_pin_interrupt_configure(const struct device *port, return 0; } +#if defined(GPIO_LATCH_DETECT_SUPPORT) + nrf_gpio_port_detect_latch_set(cfg->port, cfg->latch_detect); +#endif + nrfx_gpiote_trigger_config_t trigger_config = { .trigger = get_trigger(mode, trig), }; @@ -696,6 +707,8 @@ static DEVICE_API(gpio, gpio_nrfx_drv_api_funcs) = { .gpiote = GPIOTE_REF(id), \ .edge_sense = DT_INST_PROP_OR(id, sense_edge_mask, 0), \ .port_num = DT_INST_PROP(id, port), \ + IF_ENABLED(GPIO_LATCH_DETECT_SUPPORT, \ + (.latch_detect = DT_INST_PROP(id, latch_detect),)) \ IF_ENABLED(GPIOTE_FEATURE_FLAG, \ (.flags = \ (DT_PROP_OR(GPIOTE_PHANDLE(id), no_port_event, 0) ? \ diff --git a/drivers/hwinfo/Kconfig.nrf b/drivers/hwinfo/Kconfig.nrf index bae67e0a81d3..10ccb0f45747 100644 --- a/drivers/hwinfo/Kconfig.nrf +++ b/drivers/hwinfo/Kconfig.nrf @@ -5,7 +5,7 @@ config HWINFO_NRF bool "NRF device ID" default y depends on SOC_FAMILY_NORDIC_NRF - depends on SOC_SERIES_NRF54H || NRF_SOC_SECURE_SUPPORTED + depends on SOC_SERIES_NRF54H || SOC_SERIES_NRF92 || NRF_SOC_SECURE_SUPPORTED select HWINFO_HAS_DRIVER help Enable Nordic NRF hwinfo driver. diff --git a/drivers/hwinfo/hwinfo_nrf.c b/drivers/hwinfo/hwinfo_nrf.c index d7b7b077546b..c7803d19b3b6 100644 --- a/drivers/hwinfo/hwinfo_nrf.c +++ b/drivers/hwinfo/hwinfo_nrf.c @@ -9,7 +9,7 @@ #include #include #if defined(CONFIG_BOARD_QEMU_CORTEX_M0) || \ - (defined(CONFIG_NRF_PLATFORM_HALTIUM) && \ + ((defined(CONFIG_SOC_SERIES_NRF54H) || defined(CONFIG_SOC_SERIES_NRF92)) && \ defined(CONFIG_RISCV_CORE_NORDIC_VPR)) #define RESET_CAUSE_AVAILABLE 0 #else @@ -52,6 +52,13 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length) */ buf[1] |= (nrf_ficr_er_get(NRF_FICR, 0) & 0xFF) << 16; buf[1] |= (nrf_ficr_ir_get(NRF_FICR, 0) & 0xFF) << 24; +#elif NRF_FICR_HAS_NFC_TAGHEADER_ARRAY + /* DEVICEID is not accessible, use NFCID instead. + * Assume that it is always accessible from the non-secure image. + * Skip TAGHEADER[0] as it always contain Manufacturer ID. + */ + buf[0] = nrf_ficr_nfc_tagheader_get(NRF_FICR, 1); + buf[1] = nrf_ficr_nfc_tagheader_get(NRF_FICR, 2); #else #error "No suitable source for hwinfo device_id generation" #endif diff --git a/drivers/pinctrl/pinctrl_nrf.c b/drivers/pinctrl/pinctrl_nrf.c index a9902d33f801..750f38a83123 100644 --- a/drivers/pinctrl/pinctrl_nrf.c +++ b/drivers/pinctrl/pinctrl_nrf.c @@ -110,6 +110,18 @@ static const nrf_gpio_pin_drive_t drive_modes[NRF_DRIVE_COUNT] = { #define NRF_PSEL_TDM(reg, line) ((NRF_TDM_Type *)reg)->PSEL.line #endif +#if DT_HAS_COMPAT_STATUS_OKAY(nordic_hpf_mspi_controller) || \ + defined(CONFIG_MSPI_HPF) || \ + DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY(nordic_nrf_vpr_coprocessor, pinctrl_0) +#if defined(CONFIG_SOC_SERIES_NRF54L) +#define NRF_PSEL_SDP_MSPI(psel) \ + nrf_gpio_pin_control_select(psel, NRF_GPIO_PIN_SEL_VPR); +#elif defined(CONFIG_SOC_SERIES_NRF54H) +/* On nRF54H, pin routing is controlled by secure domain, via UICR. */ +#define NRF_PSEL_SDP_MSPI(psel) +#endif +#endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_hpf_mspi_controller) || ... */ + #if NRF_GPIO_HAS_RETENTION_SETCLEAR static void port_pin_retain_set(uint16_t pin_number, bool enable) @@ -468,7 +480,8 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_can) */ -#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif) +#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif) || \ + DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_exmif_spi) /* Pin routing is controlled by secure domain, via UICR */ case NRF_FUN_EXMIF_CK: case NRF_FUN_EXMIF_DQ0: @@ -499,6 +512,26 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, input = NRF_GPIO_PIN_INPUT_CONNECT; break; #endif /* DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_qspi_v2) */ +#if defined(NRF_PSEL_SDP_MSPI) + case NRF_FUN_SDP_MSPI_CS0: + case NRF_FUN_SDP_MSPI_CS1: + case NRF_FUN_SDP_MSPI_CS2: + case NRF_FUN_SDP_MSPI_CS3: + case NRF_FUN_SDP_MSPI_CS4: + case NRF_FUN_SDP_MSPI_SCK: + case NRF_FUN_SDP_MSPI_DQ0: + case NRF_FUN_SDP_MSPI_DQ1: + case NRF_FUN_SDP_MSPI_DQ2: + case NRF_FUN_SDP_MSPI_DQ3: + case NRF_FUN_SDP_MSPI_DQ4: + case NRF_FUN_SDP_MSPI_DQ5: + case NRF_FUN_SDP_MSPI_DQ6: + case NRF_FUN_SDP_MSPI_DQ7: + NRF_PSEL_SDP_MSPI(psel); + dir = NRF_GPIO_PIN_DIR_OUTPUT; + input = NRF_GPIO_PIN_INPUT_CONNECT; + break; +#endif /* defined(NRF_PSEL_SDP_MSPI) */ #if defined(NRF_PSEL_TWIS) case NRF_FUN_TWIS_SCL: NRF_PSEL_TWIS(reg, SCL) = psel; diff --git a/drivers/regulator/regulator_nrf_vregusb.c b/drivers/regulator/regulator_nrf_vregusb.c index 2c7122e4609a..13152041af12 100644 --- a/drivers/regulator/regulator_nrf_vregusb.c +++ b/drivers/regulator/regulator_nrf_vregusb.c @@ -8,6 +8,7 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(vregusb, CONFIG_REGULATOR_LOG_LEVEL); @@ -50,17 +51,47 @@ static void vregusb_isr(void *const arg) } } +/* Undocumented STATUS register offset and VBUS detected bit for nRF54LM20. + * The STATUS register is not part of the NRF_VREGUSB_Type struct in the MDK, + * but is present in hardware at offset 0x400 from the peripheral base. + */ +#define VREGUSB_STATUS_OFFSET 0x400 +#define VREGUSB_STATUS_VBUSDET BIT(2) + static int vregusb_enable(const struct device *const dev) { const struct vregusb_config *const config = dev->config; + struct vregusb_data *const data = dev->data; NRF_VREGUSB_Type *const base = config->base; + /* Clear stale events from a previous boot to prevent spurious ISR + * firing with wrong or overwritten event type. + */ + nrf_vregusb_event_clear(base, NRF_VREGUSB_EVENT_VBUS_DETECTED); + nrf_vregusb_event_clear(base, NRF_VREGUSB_EVENT_VBUS_REMOVED); + nrf_vregusb_int_enable(base, NRF_VREGUSB_INT_VBUS_DETECTED_MASK | NRF_VREGUSB_INT_VBUS_REMOVED_MASK); - config->irq_enable_func(dev); nrf_vregusb_task_trigger(base, NRF_VREGUSB_TASK_START); + /* If VBUS is already detected (e.g. after a warm reboot with the cable + * connected), no VBUS_DETECTED edge interrupt will fire. Synthesize + * the callback so the upper layers learn about the present VBUS. + */ + if (sys_read32((mem_addr_t)base + VREGUSB_STATUS_OFFSET) & VREGUSB_STATUS_VBUSDET) { + LOG_DBG("VBUS already detected at enable"); + if (data->cb != NULL) { + struct regulator_event event = { + .type = REGULATOR_VOLTAGE_DETECTED, + }; + + data->cb(dev, &event, data->user_data); + } + } + + config->irq_enable_func(dev); + return 0; } @@ -69,6 +100,8 @@ static int vregusb_disable(const struct device *const dev) const struct vregusb_config *const config = dev->config; NRF_VREGUSB_Type *const base = config->base; + nrf_vregusb_int_disable(base, NRF_VREGUSB_INT_VBUS_DETECTED_MASK | + NRF_VREGUSB_INT_VBUS_REMOVED_MASK); config->irq_disable_func(dev); nrf_vregusb_task_trigger(base, NRF_VREGUSB_TASK_STOP); diff --git a/drivers/sensor/bosch/bmi270/bmi270.c b/drivers/sensor/bosch/bmi270/bmi270.c index febcfeb2d032..9d965e6754b7 100644 --- a/drivers/sensor/bosch/bmi270/bmi270.c +++ b/drivers/sensor/bosch/bmi270/bmi270.c @@ -690,6 +690,13 @@ static int bmi270_init(const struct device *dev) k_usleep(BMI270_SOFT_RESET_TIME); + /* Initialize bus after soft reset according to BMI270 spec */ + ret = bmi270_bus_init(dev); + if (ret != 0) { + LOG_ERR("Could not initiate bus communication"); + return ret; + } + ret = bmi270_reg_read(dev, BMI270_REG_PWR_CONF, &adv_pwr_save, 1); if (ret != 0) { return ret; diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 60e8c23cd178..e35fbba89387 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -336,6 +336,14 @@ struct uarte_nrfx_data { (baudrate) == 921600 ? NRF_UARTE_BAUDRATE_921600 : \ (baudrate) == 1000000 ? NRF_UARTE_BAUDRATE_1000000 : 0) +/* Convert Zephyr data bits enum to HAL enum. Use 8 bit data size first as it is the most common. */ +#define DATABITS_TO_NRF_FRAMESIZE(data_bits) \ + ((data_bits) == UART_CFG_DATA_BITS_8 ? NRF_UARTE_FRAME_SIZE_8_BIT : \ + (data_bits) == UART_CFG_DATA_BITS_5 ? NRF_UARTE_FRAME_SIZE_5_BIT : \ + (data_bits) == UART_CFG_DATA_BITS_6 ? NRF_UARTE_FRAME_SIZE_6_BIT : \ + (data_bits) == UART_CFG_DATA_BITS_7 ? NRF_UARTE_FRAME_SIZE_7_BIT : \ + NRF_UARTE_FRAME_SIZE_9_BIT) + #define UARTE_MIN_BUF_SWAP_LEN 10 #define UARTE_US_TO_BYTES(baudrate) \ @@ -618,9 +626,11 @@ static int uarte_nrfx_configure(const struct device *dev, } #endif +#ifndef NRF_UARTE_HAS_FRAME_SIZE if (cfg->data_bits != UART_CFG_DATA_BITS_8) { return -ENOTSUP; } +#endif switch (cfg->flow_ctrl) { case UART_CFG_FLOW_CTRL_NONE: @@ -662,7 +672,7 @@ static int uarte_nrfx_configure(const struct device *dev, #endif #if NRF_UARTE_HAS_FRAME_SIZE - uarte_cfg.frame_size = NRF_UARTE_FRAME_SIZE_8_BIT; + uarte_cfg.frame_size = DATABITS_TO_NRF_FRAMESIZE(cfg->data_bits); uarte_cfg.endian = NRF_UARTE_ENDIAN_MSB; #endif @@ -3241,6 +3251,28 @@ static int uarte_instance_deinit(const struct device *dev) #define UARTE_DISABLE_RX_INIT(node_id) \ .disable_rx = DT_PROP(node_id, disable_rx) +#define _NRF_DT_FRAMESIZE(data_bits) ((data_bits) == 5 ? NRF_UARTE_FRAME_SIZE_5_BIT : \ + (data_bits) == 6 ? NRF_UARTE_FRAME_SIZE_6_BIT : \ + (data_bits) == 7 ? NRF_UARTE_FRAME_SIZE_7_BIT : \ + (data_bits) == 8 ? NRF_UARTE_FRAME_SIZE_8_BIT : NRF_UARTE_FRAME_SIZE_9_BIT) + +/* Convert DT numeric value to HAL enum. */ +#define NRF_DT_FRAMESIZE(idx) \ + COND_CODE_1(UARTE_HAS_PROP(idx, data_bits), \ + (_NRF_DT_FRAMESIZE(UARTE_PROP(idx, data_bits))), \ + (NRF_UARTE_FRAME_SIZE_8_BIT)) + +#define _CFG_DATA_BITS(data_bits) ((data_bits) == 5 ? UART_CFG_DATA_BITS_5 : \ + (data_bits) == 6 ? UART_CFG_DATA_BITS_6 : \ + (data_bits) == 7 ? UART_CFG_DATA_BITS_7 : \ + (data_bits) == 8 ? UART_CFG_DATA_BITS_8 : UART_CFG_DATA_BITS_9) + +/* Convert DT numeric value used for data bits to enum specified in the API. */ +#define CFG_DATA_BITS(idx) \ + COND_CODE_1(UTIL_AND(NRF_UARTE_HAS_FRAME_SIZE, UARTE_HAS_PROP(idx, data_bits)), \ + (_CFG_DATA_BITS(UARTE_PROP(idx, data_bits))), \ + (UART_CFG_DATA_BITS_8)) + /* Get frequency divider that is used to adjust the BAUDRATE value. */ #define UARTE_GET_BAUDRATE_DIV(f_pclk) (f_pclk / NRF_UARTE_BASE_FREQUENCY_16MHZ) @@ -3269,12 +3301,14 @@ static int uarte_instance_deinit(const struct device *dev) (.paritytype = NRF_UARTE_PARITYTYPE_EVEN,)) \ IF_ENABLED(UARTE_HAS_FRAME_TIMEOUT, \ (.frame_timeout = NRF_UARTE_FRAME_TIMEOUT_EN,)) \ + IF_ENABLED(NRF_UARTE_HAS_FRAME_SIZE, \ + (.frame_size = NRF_DT_FRAMESIZE(idx),)) \ } /* Macro for setting zephyr specific configuration structures. */ #define UARTE_CONFIG(idx) { \ .baudrate = UARTE_PROP(idx, current_speed), \ - .data_bits = UART_CFG_DATA_BITS_8, \ + .data_bits = CFG_DATA_BITS(idx), \ .stop_bits = UART_CFG_STOP_BITS_1, \ .parity = IS_ENABLED(CONFIG_UART_##idx##_NRF_PARITY_BIT) \ ? UART_CFG_PARITY_EVEN \ diff --git a/drivers/spi/spi_dw.c b/drivers/spi/spi_dw.c index 587342931aea..8025d8d28d7c 100644 --- a/drivers/spi/spi_dw.c +++ b/drivers/spi/spi_dw.c @@ -41,6 +41,14 @@ LOG_MODULE_REGISTER(spi_dw); #include #endif +#ifdef CONFIG_HAS_NRFX +#include +#endif + +#ifdef CONFIG_SOC_NRF54H20_GPD +#include +#endif + static inline bool spi_dw_is_slave(struct spi_dw_data *spi) { return (IS_ENABLED(CONFIG_SPI_SLAVE) && @@ -258,6 +266,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)) { @@ -512,6 +521,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, @@ -570,6 +583,18 @@ 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; + +#ifdef CONFIG_SOC_NRF54H20_GPD + err = nrf_gpd_request(NRF_GPD_FAST_ACTIVE1); + if (err < 0) { + return err; + } +#endif +#endif + info->config_func(); /* Masking interrupt and making sure controller is disabled */ @@ -596,6 +621,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_spi), \ + (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), \ @@ -677,7 +707,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_egis_et171.c b/drivers/spi/spi_egis_et171.c index ab0d61520d01..0a12b5528ab2 100644 --- a/drivers/spi/spi_egis_et171.c +++ b/drivers/spi/spi_egis_et171.c @@ -16,8 +16,9 @@ typedef void (*et171_cfg_func_t)(void); #ifdef CONFIG_CACHE_MANAGEMENT #include #define IS_ALIGN(x) (((uintptr_t)(x) & (sys_cache_data_line_size_get() - 1)) == 0) -#define DRAM_START CONFIG_SRAM_BASE_ADDRESS -#define DRAM_SIZE KB(CONFIG_SRAM_SIZE) + +#define DRAM_START DT_CHOSEN_SRAM_ADDR +#define DRAM_SIZE DT_CHOSEN_SRAM_SIZE #define DRAM_END (DRAM_START + DRAM_SIZE - 1) #define IS_ADDR_IN_RAM(addr) (((addr) >= DRAM_START) && ((addr) <= DRAM_END)) #endif diff --git a/drivers/timer/Kconfig.nrf_grtc b/drivers/timer/Kconfig.nrf_grtc index ab230245ebfd..499b65b7e38e 100644 --- a/drivers/timer/Kconfig.nrf_grtc +++ b/drivers/timer/Kconfig.nrf_grtc @@ -59,6 +59,20 @@ config NRF_GRTC_TIMER_AUTO_KEEP_ALIVE if NRF_GRTC_START_SYSCOUNTER +config NRF_GRTC_TIMER_STOP_AT_UNINIT + bool "Automatically stop the GRTC when uninitialized" + default y if !MCUBOOT + help + If enabled, the GRTC timer will be stopped automatically + when the driver is uninitialized (e.g. when sys_clock_disable() is called). + +config NRF_GRTC_TIMER_CLEAR_AT_UNINIT + bool "Automatically clear the GRTC when uninitialized" + default y if !MCUBOOT + help + If enabled, the GRTC timer will be cleared automatically + when the driver is uninitialized (e.g. when sys_clock_disable() is called). + choice NRF_GRTC_TIMER_SOURCE prompt "nRF GRTC clock source" # Default to LFLPRC if CLOCK_CONTROL_NRF_K32SRC_RC for backwards compatibility diff --git a/drivers/usb/device/usb_dc_smartbond.c b/drivers/usb/device/usb_dc_smartbond.c index 21a2f5fc8177..60990d00946f 100644 --- a/drivers/usb/device/usb_dc_smartbond.c +++ b/drivers/usb/device/usb_dc_smartbond.c @@ -505,7 +505,7 @@ static void start_tx_packet(struct smartbond_ep_state *ep_state) if (ep_state->ep_addr != EP0_IN && remaining > DMA_MIN_TRANSFER_SIZE && - (uint32_t)(ep_state->buffer) >= CONFIG_SRAM_BASE_ADDRESS && + (uint32_t)(ep_state->buffer) >= DT_CHOSEN_SRAM_ADDR && try_allocate_dma(ep_state, USB_EP_DIR_IN)) { /* * Whole packet will be put in FIFO by DMA. diff --git a/drivers/usb/udc/udc_smartbond.c b/drivers/usb/udc/udc_smartbond.c index 1e64470e02a4..3e7445e9c2bd 100644 --- a/drivers/usb/udc/udc_smartbond.c +++ b/drivers/usb/udc/udc_smartbond.c @@ -431,7 +431,7 @@ static void start_tx_packet(struct usb_smartbond_data *data, struct smartbond_ep } if (ep != USB_CONTROL_EP_IN && size > config->dma_min_transfer_size && - (uint32_t)(buf->data) >= CONFIG_SRAM_BASE_ADDRESS && try_allocate_dma(data, ep_state)) { + (uint32_t)(buf->data) >= DT_CHOSEN_SRAM_ADDR && try_allocate_dma(data, ep_state)) { start_tx_dma(&config->dma_cfg, (uintptr_t)buf->data, (uintptr_t)®s->txd, size); } else { fill_tx_fifo(ep_state); diff --git a/drivers/wifi/nrf_wifi/Kconfig.nrfwifi b/drivers/wifi/nrf_wifi/Kconfig.nrfwifi index 2530fd3cf8f2..ca2eef74c661 100644 --- a/drivers/wifi/nrf_wifi/Kconfig.nrfwifi +++ b/drivers/wifi/nrf_wifi/Kconfig.nrfwifi @@ -228,6 +228,13 @@ config NRF70_SR_COEX_SWCTRL1_OUTPUT config NRF70_SR_COEX_BT_GRANT_ACTIVE_LOW int "Configure BT grant active low" default 1 + +config NRF70_BT_SLOT_TIME + int "BT slot allocation time in Wi-Fi scan (ms)" + range 0 255 + default 0 + help + Time allocated in milliseconds for SR between successive Wi-Fi channel scan. endif # NRF70_SR_COEX config NRF70_WORKQ_STACK_SIZE @@ -919,6 +926,11 @@ config NRF_WIFI_COEX_DISABLE_PRIORITY_WINDOW_FOR_SCAN Enable this configuration to disable priority window for scan in the case of coexistence with Short Range radio. +config NRF_WIFI_DISPLAY_SCAN_ABORT_ON_BSS_LIMIT + bool "Abort scan when display BSS limit is reached" + help + Enable this configuration to abort display scan when the BSS limit is reached. + if NETWORKING config NRF_WIFI_ZERO_COPY_TX bool "Zero copy Transmit path [EXPERIMENTAL]" diff --git a/drivers/wifi/nrf_wifi/src/net_if.c b/drivers/wifi/nrf_wifi/src/net_if.c index f6482a8e06f5..d424e8b780a4 100644 --- a/drivers/wifi/nrf_wifi/src/net_if.c +++ b/drivers/wifi/nrf_wifi/src/net_if.c @@ -1385,9 +1385,6 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats) zstats->errors.rx = stats.host.total_rx_drop_pkts + stats.fw.umac.interface_data_stats.rx_checksum_error_count; zstats->overrun_count = stats.host.total_tx_drop_pkts + stats.host.total_rx_drop_pkts; -#ifdef CONFIG_NRF70_RAW_DATA_TX - zstats->errors.tx += sys_dev_ctx->raw_pkt_stats.raw_pkt_send_failure; -#endif /* CONFIG_NRF70_RAW_DATA_TX */ /* FMAC statistics */ status = nrf_wifi_sys_fmac_stats_get(rpu_ctx_zep->rpu_ctx, diff --git a/drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c b/drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c index 1a8e1e0d9004..f2024ea44249 100644 --- a/drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c +++ b/drivers/wifi/nrf_wifi/src/wifi_mgmt_scan.c @@ -298,6 +298,10 @@ static inline enum wifi_security_type drv_to_wifi_mgmt(int drv_security_type) return WIFI_SECURITY_TYPE_WAPI; case NRF_WIFI_EAP: return WIFI_SECURITY_TYPE_EAP; + case NRF_WIFI_WPA3_AUTO: + return WIFI_SECURITY_TYPE_SAE_AUTO; + case NRF_WIFI_WPA3_FT_SAE: + return WIFI_SECURITY_TYPE_FT_SAE; default: return WIFI_SECURITY_TYPE_UNKNOWN; } diff --git a/dts/arm/nordic/nrf52805.dtsi b/dts/arm/nordic/nrf52805.dtsi index 59f64d021368..ac703e2254b4 100644 --- a/dts/arm/nordic/nrf52805.dtsi +++ b/dts/arm/nordic/nrf52805.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -113,12 +113,13 @@ status = "okay"; ble-2mbps-supported; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52810.dtsi b/dts/arm/nordic/nrf52810.dtsi index fa786fc88d0a..6a40594215b5 100644 --- a/dts/arm/nordic/nrf52810.dtsi +++ b/dts/arm/nordic/nrf52810.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -121,12 +121,13 @@ status = "okay"; ble-2mbps-supported; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52811.dtsi b/dts/arm/nordic/nrf52811.dtsi index e8823af4afbf..e7658980dd7f 100644 --- a/dts/arm/nordic/nrf52811.dtsi +++ b/dts/arm/nordic/nrf52811.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -129,12 +129,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52820.dtsi b/dts/arm/nordic/nrf52820.dtsi index 67b4b6fa6200..a111c0ba1bf7 100644 --- a/dts/arm/nordic/nrf52820.dtsi +++ b/dts/arm/nordic/nrf52820.dtsi @@ -10,7 +10,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -130,12 +130,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK another Bluetooth controller - * is added and set as the default. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52832.dtsi b/dts/arm/nordic/nrf52832.dtsi index fe60970230f8..6cf8aff68bb8 100644 --- a/dts/arm/nordic/nrf52832.dtsi +++ b/dts/arm/nordic/nrf52832.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -121,12 +121,13 @@ status = "okay"; ble-2mbps-supported; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52833.dtsi b/dts/arm/nordic/nrf52833.dtsi index 14d23323c4e5..0cad8d33f67e 100644 --- a/dts/arm/nordic/nrf52833.dtsi +++ b/dts/arm/nordic/nrf52833.dtsi @@ -11,7 +11,7 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -131,12 +131,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf52840.dtsi b/dts/arm/nordic/nrf52840.dtsi index 14b3d14adc18..82cb57082943 100644 --- a/dts/arm/nordic/nrf52840.dtsi +++ b/dts/arm/nordic/nrf52840.dtsi @@ -11,8 +11,8 @@ / { chosen { - zephyr,bt-hci = &bt_hci_controller; - zephyr,entropy = &rng; + zephyr,bt-hci = &bt_hci_sdc; + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -125,12 +125,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; @@ -589,7 +590,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_clocks.dtsi b/dts/arm/nordic/nrf5340_clocks.dtsi new file mode 100644 index 000000000000..d2be00a78ae3 --- /dev/null +++ b/dts/arm/nordic/nrf5340_clocks.dtsi @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + clocks { + lfxo: lfxo { + compatible = "nordic,nrf53-lfxo"; + #clock-cells = <0>; + clock-frequency = <32768>; + }; + + hfxo: hfxo { + compatible = "nordic,nrf53-hfxo"; + #clock-cells = <0>; + clock-frequency = ; + startup-time-us = <1400>; + }; + }; +}; diff --git a/dts/arm/nordic/nrf5340_cpuapp.dtsi b/dts/arm/nordic/nrf5340_cpuapp.dtsi index 517bbb4c6e99..c8fd20237f9c 100644 --- a/dts/arm/nordic/nrf5340_cpuapp.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp.dtsi @@ -7,6 +7,7 @@ #include #include #include +#include / { cpus { @@ -34,7 +35,7 @@ }; chosen { - zephyr,entropy = &rng_hci; + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -132,7 +133,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/nrf5340_cpuapp_ns.dtsi b/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi index 784a670fe03e..f41ea81e12a8 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_ns.dtsi @@ -9,6 +9,7 @@ #include #include #include +#include / { cpus { diff --git a/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi b/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi index 46e2a0364758..5617c5f0e467 100644 --- a/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi +++ b/dts/arm/nordic/nrf5340_cpuapp_peripherals.dtsi @@ -15,19 +15,6 @@ dcnf: dcnf@0 { oscillators: clock-controller@4000 { compatible = "nordic,nrf53-oscillators"; reg = <0x4000 0x1000>; - - lfxo: lfxo { - compatible = "nordic,nrf53-lfxo"; - #clock-cells = <0>; - clock-frequency = <32768>; - }; - - hfxo: hfxo { - compatible = "nordic,nrf53-hfxo"; - #clock-cells = <0>; - clock-frequency = ; - startup-time-us = <1400>; - }; }; regulators: regulator@4000 { diff --git a/dts/arm/nordic/nrf5340_cpunet.dtsi b/dts/arm/nordic/nrf5340_cpunet.dtsi index 20c161945bfb..bc8357d91c33 100644 --- a/dts/arm/nordic/nrf5340_cpunet.dtsi +++ b/dts/arm/nordic/nrf5340_cpunet.dtsi @@ -6,10 +6,11 @@ #include #include +#include / { chosen { - zephyr,bt-hci = &bt_hci_controller; + zephyr,bt-hci = &bt_hci_sdc; zephyr,entropy = &rng; zephyr,flash-controller = &flash_controller; }; @@ -111,12 +112,13 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "okay"; + }; bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; - status = "okay"; + status = "disabled"; }; }; diff --git a/dts/arm/nordic/nrf54h20_cpurad.dtsi b/dts/arm/nordic/nrf54h20_cpurad.dtsi index b910e42789b0..2cde225beb01 100644 --- a/dts/arm/nordic/nrf54h20_cpurad.dtsi +++ b/dts/arm/nordic/nrf54h20_cpurad.dtsi @@ -31,6 +31,10 @@ wdt011: &cpurad_wdt011 {}; /delete-node/ &s2ram; / { + chosen { + zephyr,bt-hci = &bt_hci_sdc; + }; + soc { compatible = "simple-bus"; interrupt-parent = <&cpurad_nvic>; @@ -131,3 +135,7 @@ wdt011: &cpurad_wdt011 {}; &gdpwr_slow_main { status = "okay"; }; + +&bt_hci_sdc { + status = "okay"; +}; diff --git a/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi b/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi index 10739683e0c9..a94b246e0fd1 100644 --- a/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi +++ b/dts/arm/nordic/nrf54l_05_10_15_cpuapp.dtsi @@ -15,8 +15,8 @@ nvic: &cpuapp_nvic {}; / { chosen { - zephyr,bt-hci = &bt_hci_controller; - zephyr,entropy = &rng; + zephyr,bt-hci = &bt_hci_sdc; + zephyr,entropy = &psa_rng; }; soc { @@ -26,17 +26,17 @@ nvic: &cpuapp_nvic {}; }; rng: rng { - status = "okay"; + status = "disabled"; compatible = "nordic,nrf-cracen-ctrdrbg"; }; psa_rng: psa-rng { compatible = "zephyr,psa-crypto-rng"; - status = "disabled"; + status = "okay"; }; }; -&bt_hci_controller { +&bt_hci_sdc { status = "okay"; }; diff --git a/dts/arm/nordic/nrf54lm20_a_b_cpuapp.dtsi b/dts/arm/nordic/nrf54lm20_a_b_cpuapp.dtsi index 52c3450b6780..6f6e922f1520 100644 --- a/dts/arm/nordic/nrf54lm20_a_b_cpuapp.dtsi +++ b/dts/arm/nordic/nrf54lm20_a_b_cpuapp.dtsi @@ -17,8 +17,8 @@ nvic: &cpuapp_nvic {}; / { chosen { - zephyr,bt-hci = &bt_hci_controller; - zephyr,entropy = &rng; + zephyr,bt-hci = &bt_hci_sdc; + zephyr,entropy = &psa_rng; }; soc { @@ -29,23 +29,23 @@ nvic: &cpuapp_nvic {}; psa_rng: psa-rng { compatible = "zephyr,psa-crypto-rng"; - status = "disabled"; + status = "okay"; }; rng: rng { - status = "okay"; + status = "disabled"; compatible = "nordic,nrf-cracen-ctrdrbg"; }; }; -&bt_hci_controller { +&bt_hci_sdc { status = "okay"; }; &cpuflpr_vpr { cpuapp_vevif_rx: mailbox@1 { compatible = "nordic,nrf-vevif-event-rx"; - reg = <0x0 0x1000>; + reg = <0x1 0x1000>; status = "disabled"; interrupts = <76 NRF_DEFAULT_IRQ_PRIORITY>; #mbox-cells = <1>; diff --git a/dts/arm/nordic/nrf7120_enga_cpuapp.dtsi b/dts/arm/nordic/nrf7120_enga_cpuapp.dtsi index 37425bc9a430..9cdc8361cbad 100644 --- a/dts/arm/nordic/nrf7120_enga_cpuapp.dtsi +++ b/dts/arm/nordic/nrf7120_enga_cpuapp.dtsi @@ -17,7 +17,8 @@ nvic: &cpuapp_nvic {}; / { chosen { - zephyr,entropy = &rng; + zephyr,bt-hci = &bt_hci_sdc; + zephyr,entropy = &psa_rng; }; soc { @@ -27,20 +28,24 @@ nvic: &cpuapp_nvic {}; }; rng: rng { - status = "okay"; + status = "disabled"; compatible = "nordic,nrf-cracen-ctrdrbg"; }; psa_rng: psa-rng { compatible = "zephyr,psa-crypto-rng"; - status = "disabled"; + status = "okay"; }; }; +&bt_hci_sdc { + status = "okay"; +}; + &cpuflpr_vpr { cpuapp_vevif_rx: mailbox@1 { compatible = "nordic,nrf-vevif-event-rx"; - reg = <0x0 0x1000>; + reg = <0x1 0x1000>; status = "disabled"; interrupts = <76 NRF_DEFAULT_IRQ_PRIORITY>; #mbox-cells = <1>; diff --git a/dts/arm/nordic/nrf91.dtsi b/dts/arm/nordic/nrf91.dtsi index 5d625ed2cb8f..b840bdaa5fc7 100644 --- a/dts/arm/nordic/nrf91.dtsi +++ b/dts/arm/nordic/nrf91.dtsi @@ -28,6 +28,7 @@ }; chosen { + zephyr,entropy = &cryptocell; zephyr,flash-controller = &flash_controller; }; @@ -76,7 +77,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/arm/nordic,nrf71-uicr.yaml b/dts/bindings/arm/nordic,nrf71-uicr.yaml new file mode 100644 index 000000000000..d5597beba97f --- /dev/null +++ b/dts/bindings/arm/nordic,nrf71-uicr.yaml @@ -0,0 +1,33 @@ +# Copyright (c) 2026 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic nRF71 UICR (User Information Configuration Registers) + +compatible: "nordic,nrf71-uicr" + +include: base.yaml + +properties: + reg: + required: true + + supply-config1v8: + type: string + enum: + - "normal" + - "external" + - "high-load" + description: | + Configuration of the VDD_AO_1V8 supply rail. + + normal - Autonomous control by the internal power management block. + The LDO_VBAT_1V8 regulator operates in its default mode. + external - 1.8 V supplied externally on VDD_AO_1V8 pin. + Internal LDO_VBAT_1V8 regulator disabled to prevent + conflict with external supply. + high-load - Up to 10mA can be consumed from 1V8 supply for other + devices/IO. Keep LDO_VBAT_1V8 in high power mode at + all times (including system OFF). + + This setting, once applied, can only be unset by erasing the UICR + registers. Refer to the nRF7120 Product Specification for details. diff --git a/dts/bindings/gpio/nordic,nrf-gpio.yaml b/dts/bindings/gpio/nordic,nrf-gpio.yaml index 6bde10bad07d..238274533aca 100644 --- a/dts/bindings/gpio/nordic,nrf-gpio.yaml +++ b/dts/bindings/gpio/nordic,nrf-gpio.yaml @@ -37,6 +37,11 @@ properties: port = <1>; + latch-detect: + type: boolean + description: | + Enable latch detect mode for this GPIO port. + gpio-cells: - pin - flags diff --git a/dts/bindings/mtd/jedec,mspi-nor.yaml b/dts/bindings/mtd/jedec,mspi-nor.yaml index e59fe117557e..ce8077aed35e 100644 --- a/dts/bindings/mtd/jedec,mspi-nor.yaml +++ b/dts/bindings/mtd/jedec,mspi-nor.yaml @@ -19,6 +19,7 @@ include: - dpd-wakeup-sequence - t-enter-dpd - t-exit-dpd + - t-reset-recovery properties: read-frequency: @@ -87,13 +88,6 @@ properties: description: | Minimum duration, in nanoseconds, of an active pulse on the RESET line. - t-reset-recovery: - type: int - description: | - Minimum time, in nanoseconds, the flash chip needs to recover after reset. - Such delay is performed when a GPIO or software reset is done, or after - power is supplied to the chip if the "supply-gpios" property is specified. - transfer-timeout: type: int default: 10 diff --git a/dts/bindings/mtd/jedec,spi-nor-common.yaml b/dts/bindings/mtd/jedec,spi-nor-common.yaml index fba319da31ec..b4f65196230d 100644 --- a/dts/bindings/mtd/jedec,spi-nor-common.yaml +++ b/dts/bindings/mtd/jedec,spi-nor-common.yaml @@ -74,6 +74,13 @@ properties: If not provided the driver does not enforce a delay. + t-reset-recovery: + type: int + description: | + Minimum time, in nanoseconds, the flash chip needs to recover after reset. + Such delay is performed when a GPIO or software reset is done, or after + power is supplied to the chip if the "supply-gpios" property is specified. + has-lock: type: int description: | diff --git a/dts/bindings/spi/nordic,nrf-exmif-spi.yaml b/dts/bindings/spi/nordic,nrf-exmif-spi.yaml new file mode 100644 index 000000000000..d988b4146878 --- /dev/null +++ b/dts/bindings/spi/nordic,nrf-exmif-spi.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic External Memory Interface (EXMIF) used in SPI mode only + +compatible: "nordic,nrf-exmif-spi" + +include: snps,designware-spi.yaml diff --git a/dts/vendor/nordic/nrf54h20.dtsi b/dts/vendor/nordic/nrf54h20.dtsi index aecd7d896678..1fc013a37521 100644 --- a/dts/vendor/nordic/nrf54h20.dtsi +++ b/dts/vendor/nordic/nrf54h20.dtsi @@ -518,6 +518,16 @@ compatible = "nordic,nrf-ieee802154"; status = "disabled"; }; + + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "disabled"; + }; + + bt_hci_controller: bt_hci_controller { + compatible = "zephyr,bt-hci-ll-sw-split"; + status = "disabled"; + }; }; ppib030: ppib@31000 { @@ -875,6 +885,7 @@ reg = <0x8ef000 0x1000>; status = "disabled"; channels = <8>; + offset = <16>; }; cpuppr_vpr: vpr@908000 { diff --git a/dts/vendor/nordic/nrf54l_05_10_15.dtsi b/dts/vendor/nordic/nrf54l_05_10_15.dtsi index 50396ff0042c..02897232a6c7 100644 --- a/dts/vendor/nordic/nrf54l_05_10_15.dtsi +++ b/dts/vendor/nordic/nrf54l_05_10_15.dtsi @@ -267,9 +267,11 @@ status = "disabled"; }; - /* Note: In the nRF Connect SDK the SoftDevice Controller - * is added and set as the default Bluetooth Controller. - */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "disabled"; + }; + bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; status = "disabled"; diff --git a/dts/vendor/nordic/nrf54lm20_a_b.dtsi b/dts/vendor/nordic/nrf54lm20_a_b.dtsi index 39c94ffdea06..26a62a9226be 100644 --- a/dts/vendor/nordic/nrf54lm20_a_b.dtsi +++ b/dts/vendor/nordic/nrf54lm20_a_b.dtsi @@ -315,6 +315,11 @@ /* Note: In the nRF Connect SDK the SoftDevice Controller * is added and set as the default Bluetooth Controller. */ + bt_hci_sdc: bt_hci_sdc { + compatible = "nordic,bt-hci-sdc"; + status = "disabled"; + }; + bt_hci_controller: bt_hci_controller { compatible = "zephyr,bt-hci-ll-sw-split"; status = "disabled"; diff --git a/dts/vendor/nordic/nrf7120_enga.dtsi b/dts/vendor/nordic/nrf7120_enga.dtsi index 7468ff052be2..0ccd3fa62749 100644 --- a/dts/vendor/nordic/nrf7120_enga.dtsi +++ b/dts/vendor/nordic/nrf7120_enga.dtsi @@ -135,7 +135,7 @@ /* Intentionally empty because uicr is hardware fixed to Secure */ #else uicr: uicr@ffd000 { - compatible = "nordic,nrf-uicr"; + compatible = "nordic,nrf71-uicr"; reg = <0xffd000 0x1000>; ranges = <0x0 0xffd000 0x1000>; #address-cells = <1>; diff --git a/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld b/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld index 04cc147bf8b7..fb3f14372670 100644 --- a/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld @@ -40,8 +40,12 @@ #define ROM_END_OFFSET 0 #endif -#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) +#if defined(CONFIG_XIP) #define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#else +#define ROM_ADDR RAM_ADDR +#endif #define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) #else #if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) @@ -57,8 +61,8 @@ #endif #endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ -#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) -#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#define RAM_ADDR DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE /* Set alignment to CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE * to make linker section alignment comply with MPU granularity. diff --git a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld index 2f3d55412f06..831f2a560f19 100644 --- a/include/zephyr/arch/arm/cortex_m/scripts/linker.ld +++ b/include/zephyr/arch/arm/cortex_m/scripts/linker.ld @@ -34,14 +34,51 @@ #define ROMSTART_REGION ROMABLE_REGION #endif +#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 + +#if defined(CONFIG_PM_USE_CONFIG_SRAM_SIZE) +#define RAM_SIZE CONFIG_PM_SRAM_SIZE +#else +#define RAM_SIZE PM_SRAM_SIZE +#endif +#define RAM_ADDR PM_SRAM_ADDRESS + +#else /* ! USE_PARTITION_MANAGER */ + #if defined(CONFIG_ROM_END_OFFSET) #define ROM_END_OFFSET CONFIG_ROM_END_OFFSET #else #define ROM_END_OFFSET 0 #endif -#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) +#if defined(CONFIG_XIP) #define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#else +#define ROM_ADDR RAM_ADDR +#endif #define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) #else #if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) @@ -57,8 +94,25 @@ #endif #endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ -#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) -#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#define RAM_ADDR DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE + +#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; diff --git a/include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h b/include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h index a99223262d64..7d3eb3797539 100644 --- a/include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h +++ b/include/zephyr/arch/arm/mpu/arm_mpu_mem_cfg.h @@ -52,49 +52,53 @@ #error "Unsupported flash size configuration" #endif +#define Z_SRAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + /* SRAM Region Definitions */ -#if CONFIG_SRAM_SIZE <= 16 +#if Z_SRAM_SIZE <= 16 #define REGION_SRAM_SIZE REGION_16K -#elif CONFIG_SRAM_SIZE <= 32 +#elif Z_SRAM_SIZE <= 32 #define REGION_SRAM_SIZE REGION_32K -#elif CONFIG_SRAM_SIZE <= 64 +#elif Z_SRAM_SIZE <= 64 #define REGION_SRAM_SIZE REGION_64K -#elif CONFIG_SRAM_SIZE <= 128 +#elif Z_SRAM_SIZE <= 128 #define REGION_SRAM_SIZE REGION_128K -#elif CONFIG_SRAM_SIZE <= 256 +#elif Z_SRAM_SIZE <= 256 #define REGION_SRAM_SIZE REGION_256K -#elif CONFIG_SRAM_SIZE <= 512 +#elif Z_SRAM_SIZE <= 512 #define REGION_SRAM_SIZE REGION_512K -#elif CONFIG_SRAM_SIZE <= 1024 +#elif Z_SRAM_SIZE <= 1024 #define REGION_SRAM_SIZE REGION_1M -#elif CONFIG_SRAM_SIZE <= 2048 +#elif Z_SRAM_SIZE <= 2048 #define REGION_SRAM_SIZE REGION_2M -#elif CONFIG_SRAM_SIZE <= 4096 +#elif Z_SRAM_SIZE <= 4096 #define REGION_SRAM_SIZE REGION_4M -#elif CONFIG_SRAM_SIZE <= 8192 +#elif Z_SRAM_SIZE <= 8192 #define REGION_SRAM_SIZE REGION_8M -#elif CONFIG_SRAM_SIZE <= 16384 +#elif Z_SRAM_SIZE <= 16384 #define REGION_SRAM_SIZE REGION_16M -#elif CONFIG_SRAM_SIZE <= 32768 +#elif Z_SRAM_SIZE <= 32768 #define REGION_SRAM_SIZE REGION_32M -#elif CONFIG_SRAM_SIZE <= 65536 +#elif Z_SRAM_SIZE <= 65536 #define REGION_SRAM_SIZE REGION_64M -#elif CONFIG_SRAM_SIZE <= 131072 +#elif Z_SRAM_SIZE <= 131072 #define REGION_SRAM_SIZE REGION_128M -#elif CONFIG_SRAM_SIZE <= 262144 +#elif Z_SRAM_SIZE <= 262144 #define REGION_SRAM_SIZE REGION_256M -#elif CONFIG_SRAM_SIZE <= 524288 +#elif Z_SRAM_SIZE <= 524288 #define REGION_SRAM_SIZE REGION_512M -#elif CONFIG_SRAM_SIZE <= 1048576 +#elif Z_SRAM_SIZE <= 1048576 #define REGION_SRAM_SIZE REGION_1G -#elif CONFIG_SRAM_SIZE <= 2097152 +#elif Z_SRAM_SIZE <= 2097152 #define REGION_SRAM_SIZE REGION_2G -#elif CONFIG_SRAM_SIZE <= 4194304 +#elif Z_SRAM_SIZE <= 4194304 #define REGION_SRAM_SIZE REGION_4G #else #error "Unsupported sram size configuration" #endif +#undef Z_SRAM_SIZE + /* Define Wrong value */ #define REGION_SIZE_UNSUPPORTED -1 diff --git a/include/zephyr/arch/arm64/scripts/linker.ld b/include/zephyr/arch/arm64/scripts/linker.ld index 93c8b2f5db64..7a1d3751e108 100644 --- a/include/zephyr/arch/arm64/scripts/linker.ld +++ b/include/zephyr/arch/arm64/scripts/linker.ld @@ -32,8 +32,12 @@ #define ROM_END_OFFSET 0 #endif -#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) +#if defined(CONFIG_FLASH_USES_MAPPED_PARTITION) +#if defined(CONFIG_XIP) #define ROM_ADDR (DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))) +#else +#define ROM_ADDR RAM_ADDR +#endif #define ROM_SIZE (DT_REG_SIZE(DT_CHOSEN(zephyr_code_partition)) - ROM_END_OFFSET) #else #if !defined(CONFIG_XIP) && (CONFIG_FLASH_SIZE == 0) @@ -49,8 +53,8 @@ #endif #endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) */ -#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) -#define RAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#define RAM_ADDR DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE #if defined(CONFIG_ARM_MMU) _region_min_align = CONFIG_MMU_PAGE_SIZE; diff --git a/include/zephyr/arch/mips/linker.ld b/include/zephyr/arch/mips/linker.ld index e82d756bdee8..66e865b34799 100644 --- a/include/zephyr/arch/mips/linker.ld +++ b/include/zephyr/arch/mips/linker.ld @@ -22,9 +22,12 @@ #define _EXCEPTION_SECTION_NAME exceptions #define _RESET_SECTION_NAME reset +#define RAM_BASE DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE + MEMORY { - RAM (rwx) : ORIGIN = CONFIG_SRAM_BASE_ADDRESS, LENGTH = KB(CONFIG_SRAM_SIZE) + RAM (rwx) : ORIGIN = RAM_BASE, LENGTH = RAM_SIZE /* Used by and documented in include/linker/intlist.ld */ IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K } @@ -37,9 +40,9 @@ REGION_ALIAS("REGION_BSS", RAM); ENTRY(CONFIG_KERNEL_ENTRY) -PROVIDE (__memory_base = CONFIG_SRAM_BASE_ADDRESS); -PROVIDE (__memory_size = CONFIG_SRAM_SIZE * 1024); -PROVIDE (__stack = CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE - 1) * 1024); +PROVIDE (__memory_base = RAM_BASE); +PROVIDE (__memory_size = RAM_SIZE); +PROVIDE (__stack = RAM_BASE + (RAM_SIZE - 1024)); SECTIONS { diff --git a/include/zephyr/arch/openrisc/linker.ld b/include/zephyr/arch/openrisc/linker.ld index 6b2357b02d61..e840dafde3dc 100644 --- a/include/zephyr/arch/openrisc/linker.ld +++ b/include/zephyr/arch/openrisc/linker.ld @@ -38,8 +38,8 @@ #define ROM_SIZE (CONFIG_FLASH_SIZE * 1024) #endif -#define RAM_SIZE (CONFIG_SRAM_SIZE * 1K) -#define RAM_BASE CONFIG_SRAM_BASE_ADDRESS +#define RAM_BASE DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE #define _EXCEPTION_SECTION_NAME exception @@ -57,9 +57,9 @@ MEMORY ENTRY(CONFIG_KERNEL_ENTRY) -PROVIDE (__memory_base = CONFIG_SRAM_BASE_ADDRESS); -PROVIDE (__memory_size = CONFIG_SRAM_SIZE * 1024); -PROVIDE (__stack = CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE - 1) * 1024); +PROVIDE (__memory_base = RAM_BASE); +PROVIDE (__memory_size = RAM_SIZE); +PROVIDE (__stack = RAM_BASE + (RAM_SIZE - 1024)); SECTIONS { diff --git a/include/zephyr/arch/riscv/common/linker.ld b/include/zephyr/arch/riscv/common/linker.ld index 2f87e4a828da..d272f621be5f 100644 --- a/include/zephyr/arch/riscv/common/linker.ld +++ b/include/zephyr/arch/riscv/common/linker.ld @@ -82,13 +82,13 @@ #endif /* DT_NODE_HAS_COMPAT_STATUS */ #else /* CONFIG_XIP */ -#define ROM_BASE CONFIG_SRAM_BASE_ADDRESS -#define ROM_SIZE (KB(CONFIG_SRAM_SIZE) - ROM_END_OFFSET) +#define ROM_BASE DT_CHOSEN_SRAM_ADDR +#define ROM_SIZE (DT_CHOSEN_SRAM_SIZE - ROM_END_OFFSET) #endif /* CONFIG_XIP */ #endif /* defined(CONFIG_FLASH_USES_MAPPED_PARTITION) && defined(CONFIG_XIP) */ -#define RAM_BASE CONFIG_SRAM_BASE_ADDRESS -#define RAM_SIZE KB(CONFIG_SRAM_SIZE) +#define RAM_BASE DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE #ifdef CONFIG_RISCV_PMP #define MPU_MIN_SIZE CONFIG_PMP_GRANULARITY @@ -275,25 +275,22 @@ SECTIONS *(.data) *(".data.*") - -#ifdef CONFIG_RISCV_GP - /* - * RISC-V architecture has 12-bit signed immediate offsets in the + *(.sdata .sdata.* .gnu.linkonce.s.*) +#if defined(CONFIG_RISCV_GP) + /* RISC-V architecture has 12-bit signed immediate offsets in the * instructions. If we can put the most commonly accessed globals * in a special 4K span of memory addressed by the GP register, then * we can access those values in a single instruction, saving both * codespace and runtime. * * Since these immediate offsets are signed, place gp 0x800 past the - * beginning of .sdata so that we can use both positive and negative + * end of .sdata so that we can use both positive and negative * offsets. */ . = ALIGN(8); PROVIDE (__global_pointer$ = . + 0x800); #endif - *(.sdata .sdata.* .gnu.linkonce.s.*) - /* Located in generated directory. This file is populated by the * zephyr_linker_sources() Cmake function. */ diff --git a/include/zephyr/arch/rx/linker.ld b/include/zephyr/arch/rx/linker.ld index 91d81612eb56..c09459a6eff1 100644 --- a/include/zephyr/arch/rx/linker.ld +++ b/include/zephyr/arch/rx/linker.ld @@ -45,8 +45,8 @@ #endif #endif -#define RAM_START (CONFIG_SRAM_BASE_ADDRESS) -#define RAM_SIZE (KB(CONFIG_SRAM_SIZE)) +#define RAM_START DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE _region_min_align = 4; @@ -230,7 +230,7 @@ SECTIONS _app_smem_rom_start = LOADADDR(_APP_SMEM_SECTION_NAME); #endif /* CONFIG_USERSPACE */ - #if CONFIG_SRAM_BASE_ADDRESS == 0 + #if DT_CHOSEN_SRAM_ADDR == 0 /* RX memory starts at address 0 which can be confused with NULL. To prevent this, block * the first memory page (16 Bytes). */ diff --git a/include/zephyr/arch/x86/memory.ld b/include/zephyr/arch/x86/memory.ld index 3e2c0b693527..8dfc636be511 100644 --- a/include/zephyr/arch/x86/memory.ld +++ b/include/zephyr/arch/x86/memory.ld @@ -37,7 +37,7 @@ /* Virtual base address for the kernel; with CONFIG_MMU this is not necessarily * the same as its physical location, although an identity mapping for RAM - * is still supported by setting CONFIG_KERNEL_VM_BASE=CONFIG_SRAM_BASE_ADDRESS. + * is still supported by setting CONFIG_KERNEL_VM_BASE=DT_CHOSEN_SRAM_ADDR. */ #ifdef K_MEM_IS_VM_KERNEL #define KERNEL_BASE_ADDR (CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) diff --git a/include/zephyr/bluetooth/bluetooth.h b/include/zephyr/bluetooth/bluetooth.h index 8d6ce5835d80..31a5e7140766 100644 --- a/include/zephyr/bluetooth/bluetooth.h +++ b/include/zephyr/bluetooth/bluetooth.h @@ -1312,6 +1312,10 @@ struct bt_le_per_adv_param { * This error code is only guaranteed when using Zephyr * controller, for other controllers code returned in * this case may be -EIO. + * @return -EPERM When @kconfig{CONFIG_BT_PRIVACY} and + * @kconfig{CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS} are enabled and connectable + * advertising is requested, and the given local identity has a conflicting + * key with another local identity for which advertising is already started. */ int bt_le_adv_start(const struct bt_le_adv_param *param, const struct bt_data *ad, size_t ad_len, @@ -1439,6 +1443,12 @@ struct bt_le_ext_adv_start_param { * * @param adv Advertising set object. * @param param Advertise start parameters. + * + * @return Zero on success or (negative) error code otherwise. + * @return -EPERM When @kconfig{CONFIG_BT_PRIVACY} and + * @kconfig{CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS} are enabled and connectable + * advertising is requested, and the given local identity has a conflicting + * key with another local identity for which advertising is already started. */ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, const struct bt_le_ext_adv_start_param *param); diff --git a/include/zephyr/bluetooth/conn.h b/include/zephyr/bluetooth/conn.h index a70eeae1e4c5..12cb779b1cf2 100644 --- a/include/zephyr/bluetooth/conn.h +++ b/include/zephyr/bluetooth/conn.h @@ -1577,11 +1577,15 @@ int bt_conn_le_read_min_conn_interval(uint16_t *min_interval_us); /** @brief Set Default Connection Rate Parameters. * - * Set default connection rate parameters to be used for future connections. - * This command does not affect any existing connection. - * Parameters set for specific connection will always have precedence. + * Configure the range of Connection Rate values that this device will + * accept from a Peripheral initiating a Connection Rate Update procedure. * - * @kconfig_dep{CONFIG_BT_SHORTER_CONNECTION_INTERVALS} + * The configured bounds: + * - Apply only to connections established after this call. + * - Are overridden on a given connection by any + * @ref bt_conn_le_conn_rate_request on that connection. + * + * @kconfig_dep{CONFIG_BT_SHORTER_CONNECTION_INTERVALS,CONFIG_BT_CENTRAL} * * @param params Connection rate parameters. * diff --git a/include/zephyr/bluetooth/hci_types.h b/include/zephyr/bluetooth/hci_types.h index 0704e9f06780..b44fca16446c 100644 --- a/include/zephyr/bluetooth/hci_types.h +++ b/include/zephyr/bluetooth/hci_types.h @@ -967,6 +967,7 @@ struct bt_hci_rp_configure_data_path { #define BT_HCI_VERSION_6_0 14 #define BT_HCI_VERSION_6_1 15 #define BT_HCI_VERSION_6_2 16 +#define BT_HCI_VERSION_6_3 17 #define BT_HCI_OP_READ_LOCAL_VERSION_INFO BT_OP(BT_OGF_INFO, 0x0001) /* 0x1001 */ struct bt_hci_rp_read_local_version_info { diff --git a/include/zephyr/bluetooth/uuid.h b/include/zephyr/bluetooth/uuid.h index aefc02aa5e2c..4c3c00aaa774 100644 --- a/include/zephyr/bluetooth/uuid.h +++ b/include/zephyr/bluetooth/uuid.h @@ -5188,6 +5188,24 @@ struct bt_uuid_any { */ #define BT_UUID_GMAP_BGR_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_BGR_FEAT_VAL) +/** + * @brief HID SCI (Shorter Connection Intervals) Mode UUID value + */ +#define BT_UUID_HIDS_SCI_MODE_VAL 0x2C39 +/** + * @brief HID SCI (Shorter Connection Intervals) Mode + */ +#define BT_UUID_HIDS_SCI_MODE BT_UUID_DECLARE_16(BT_UUID_HIDS_SCI_MODE_VAL) + +/** + * @brief HID SCI (Shorter Connection Intervals) Information UUID value + */ +#define BT_UUID_HIDS_SCI_INFO_VAL 0x2C3A +/** + * @brief HID SCI (Shorter Connection Intervals) Information + */ +#define BT_UUID_HIDS_SCI_INFO BT_UUID_DECLARE_16(BT_UUID_HIDS_SCI_INFO_VAL) + /* * Protocol UUIDs */ diff --git a/include/zephyr/devicetree.h b/include/zephyr/devicetree.h index 929af69a865a..bc981a1d4874 100644 --- a/include/zephyr/devicetree.h +++ b/include/zephyr/devicetree.h @@ -5911,5 +5911,6 @@ #include #include #include +#include #endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */ diff --git a/include/zephyr/devicetree/sram.h b/include/zephyr/devicetree/sram.h new file mode 100644 index 000000000000..bf83a14808aa --- /dev/null +++ b/include/zephyr/devicetree/sram.h @@ -0,0 +1,59 @@ +/** + * @file + * @brief Chosen SRAM Devicetree macro public API header file. + */ + +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_DEVICETREE_SRAM_H_ +#define ZEPHYR_INCLUDE_DEVICETREE_SRAM_H_ + +#ifdef CONFIG_SRAM_DEPRECATED_KCONFIG_SET +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup devicetree-chosen-sram Devicetree SRAM API + * @ingroup devicetree + * @{ + */ + +/** + * @brief Get chosen SRAM node address + * + * @return Absolute address of chosen SRAM node, if it exists + */ +#ifdef CONFIG_SRAM_DEPRECATED_KCONFIG_SET +#define DT_CHOSEN_SRAM_ADDR CONFIG_SRAM_BASE_ADDRESS +#else +#define DT_CHOSEN_SRAM_ADDR DT_REG_ADDR(DT_CHOSEN(zephyr_sram)) +#endif + +/** + * @brief Get chosen SRAM node size + * + * @return Size of chosen SRAM node, if it exists + */ +#ifdef CONFIG_SRAM_DEPRECATED_KCONFIG_SET +#define DT_CHOSEN_SRAM_SIZE (CONFIG_SRAM_SIZE * 1024) +#else +#define DT_CHOSEN_SRAM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) +#endif + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_DEVICETREE_SRAM_H_ */ diff --git a/include/zephyr/drivers/can/can_mcan.h b/include/zephyr/drivers/can/can_mcan.h index c064cc87d0c1..c62b4009526c 100644 --- a/include/zephyr/drivers/can/can_mcan.h +++ b/include/zephyr/drivers/can/can_mcan.h @@ -1065,6 +1065,7 @@ struct can_mcan_data { struct k_mutex lock; struct k_sem tx_sem; struct k_mutex tx_mtx; + struct k_timer txbcf_timer; void *custom; } __aligned(4); diff --git a/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h index 92e62a9a6bed..480e3f13797c 100644 --- a/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h +++ b/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h @@ -172,6 +172,64 @@ #define NRF_FUN_GRTC_CLKOUT_FAST 55U /** GRTC slow clock output */ #define NRF_FUN_GRTC_CLKOUT_32K 56U +/** SDP_MSPI clock pin */ +#define NRF_FUN_SDP_MSPI_SCK 57U +/** SDP_MSPI data pin 0 */ +#define NRF_FUN_SDP_MSPI_DQ0 58U +/** SDP_MSPI data pin 1 */ +#define NRF_FUN_SDP_MSPI_DQ1 59U +/** SDP_MSPI data pin 2 */ +#define NRF_FUN_SDP_MSPI_DQ2 60U +/** SDP_MSPI data pin 3 */ +#define NRF_FUN_SDP_MSPI_DQ3 61U +/** SDP_MSPI data pin 4 */ +#define NRF_FUN_SDP_MSPI_DQ4 62U +/** SDP_MSPI data pin 5 */ +#define NRF_FUN_SDP_MSPI_DQ5 63U +/** SDP_MSPI data pin 6 */ +#define NRF_FUN_SDP_MSPI_DQ6 64U +/** SDP_MSPI data pin 7 */ +#define NRF_FUN_SDP_MSPI_DQ7 65U +/** SDP_MSPI chip select 0 */ +#define NRF_FUN_SDP_MSPI_CS0 66U +/** SDP_MSPI chip select 1 */ +#define NRF_FUN_SDP_MSPI_CS1 67U +/** SDP_MSPI chip select 2 */ +#define NRF_FUN_SDP_MSPI_CS2 68U +/** SDP_MSPI chip select 3 */ +#define NRF_FUN_SDP_MSPI_CS3 69U +/** SDP_MSPI chip select 4 */ +#define NRF_FUN_SDP_MSPI_CS4 70U +/** Generic soft peripheral pin */ +#define NRF_FUN_SP_PIN NRF_FUN_SDP_MSPI_SCK +/** High-Performance Framework MSPI clock pin */ +#define NRF_FUN_HPF_MSPI_SCK NRF_FUN_SDP_MSPI_SCK +/** High-Performance Framework MSPI data pin 0 */ +#define NRF_FUN_HPF_MSPI_DQ0 NRF_FUN_SDP_MSPI_DQ0 +/** High-Performance Framework MSPI data pin 1 */ +#define NRF_FUN_HPF_MSPI_DQ1 NRF_FUN_SDP_MSPI_DQ1 +/** High-Performance Framework MSPI data pin 2 */ +#define NRF_FUN_HPF_MSPI_DQ2 NRF_FUN_SDP_MSPI_DQ2 +/** High-Performance Framework MSPI data pin 3 */ +#define NRF_FUN_HPF_MSPI_DQ3 NRF_FUN_SDP_MSPI_DQ3 +/** High-Performance Framework MSPI data pin 4 */ +#define NRF_FUN_HPF_MSPI_DQ4 NRF_FUN_SDP_MSPI_DQ4 +/** High-Performance Framework MSPI data pin 5 */ +#define NRF_FUN_HPF_MSPI_DQ5 NRF_FUN_SDP_MSPI_DQ5 +/** High-Performance Framework MSPI data pin 6 */ +#define NRF_FUN_HPF_MSPI_DQ6 NRF_FUN_SDP_MSPI_DQ6 +/** High-Performance Framework MSPI data pin 7 */ +#define NRF_FUN_HPF_MSPI_DQ7 NRF_FUN_SDP_MSPI_DQ7 +/** High-Performance Framework MSPI chip select pin 0 */ +#define NRF_FUN_HPF_MSPI_CS0 NRF_FUN_SDP_MSPI_CS0 +/** High-Performance Framework MSPI chip select pin 1 */ +#define NRF_FUN_HPF_MSPI_CS1 NRF_FUN_SDP_MSPI_CS1 +/** High-Performance Framework MSPI chip select pin 2 */ +#define NRF_FUN_HPF_MSPI_CS2 NRF_FUN_SDP_MSPI_CS2 +/** High-Performance Framework MSPI chip select pin 3 */ +#define NRF_FUN_HPF_MSPI_CS3 NRF_FUN_SDP_MSPI_CS3 +/** High-Performance Framework MSPI chip select pin 4 */ +#define NRF_FUN_HPF_MSPI_CS4 NRF_FUN_SDP_MSPI_CS4 /** TDM SCK in master mode */ #define NRF_FUN_TDM_SCK_M 71U /** TDM SCK in slave mode */ diff --git a/include/zephyr/kernel/internal/mm.h b/include/zephyr/kernel/internal/mm.h index cd5927e1c062..7b7cc9a1b6bd 100644 --- a/include/zephyr/kernel/internal/mm.h +++ b/include/zephyr/kernel/internal/mm.h @@ -9,6 +9,7 @@ #include #include +#include /** * @defgroup kernel_mm_internal_apis Kernel Memory Management Internal APIs @@ -26,7 +27,7 @@ * virt_addr = phys_addr + K_MEM_VIRT_OFFSET * * This only works for virtual addresses within the interval - * [CONFIG_KERNEL_VM_BASE, CONFIG_KERNEL_VM_BASE + (CONFIG_SRAM_SIZE * 1024)). + * [CONFIG_KERNEL_VM_BASE, CONFIG_KERNEL_VM_BASE + DT_CHOSEN_SRAM_ADDR). * * These macros are intended for assembly, linker code, and static initializers. * Use with care. @@ -39,22 +40,20 @@ */ #ifdef CONFIG_MMU #define K_MEM_VIRT_OFFSET ((CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) - \ - (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_OFFSET)) + (DT_CHOSEN_SRAM_ADDR + CONFIG_SRAM_OFFSET)) #else #define K_MEM_VIRT_OFFSET 0 #endif /* CONFIG_MMU */ -#if CONFIG_SRAM_BASE_ADDRESS != 0 -#define IS_SRAM_ADDRESS_LOWER(ADDR) ((ADDR) >= CONFIG_SRAM_BASE_ADDRESS) +#if DT_CHOSEN_SRAM_ADDR != 0 +#define IS_SRAM_ADDRESS_LOWER(ADDR) ((ADDR) >= DT_CHOSEN_SRAM_ADDR) #else #define IS_SRAM_ADDRESS_LOWER(ADDR) true -#endif /* CONFIG_SRAM_BASE_ADDRESS != 0 */ +#endif /* DT_CHOSEN_SRAM_ADDR != 0 */ - -#if (CONFIG_SRAM_BASE_ADDRESS + (CONFIG_SRAM_SIZE * 1024UL)) != 0 +#if (DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE) != 0 #define IS_SRAM_ADDRESS_UPPER(ADDR) \ - ((ADDR) < (CONFIG_SRAM_BASE_ADDRESS + \ - (CONFIG_SRAM_SIZE * 1024UL))) + ((ADDR) < (DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE)) #else #define IS_SRAM_ADDRESS_UPPER(ADDR) false #endif diff --git a/include/zephyr/linker/linker-tool-gcc.h b/include/zephyr/linker/linker-tool-gcc.h index d21524bc5420..f5b972d67ac3 100644 --- a/include/zephyr/linker/linker-tool-gcc.h +++ b/include/zephyr/linker/linker-tool-gcc.h @@ -83,7 +83,7 @@ * the memory area specified by 'where' argument. * * This macro is intentionally undefined for CONFIG_MMU systems when - * CONFIG_KERNEL_VM_BASE is not the same as CONFIG_SRAM_BASE_ADDRESS, + * CONFIG_KERNEL_VM_BASE is not the same as DT_CHOSEN_SRAM_ADDR, * as both the LMA and VMA destinations must be known for all sections * as this corresponds to physical vs. virtual location. * diff --git a/include/zephyr/net/ethernet.h b/include/zephyr/net/ethernet.h index 2833bbb0c488..a852876debd1 100644 --- a/include/zephyr/net/ethernet.h +++ b/include/zephyr/net/ethernet.h @@ -946,7 +946,7 @@ int net_eth_get_hw_config(struct net_if *iface, enum ethernet_config_type type, struct ethernet_config *config) { const struct device *dev = net_if_get_device(iface); - const struct ethernet_api *eth = dev->api; + const struct ethernet_api *eth = (struct ethernet_api *)dev->api; if (!eth->get_config) { return -ENOTSUP; diff --git a/include/zephyr/net/mqtt.h b/include/zephyr/net/mqtt.h index a4d961a502ef..c1f3b9924133 100644 --- a/include/zephyr/net/mqtt.h +++ b/include/zephyr/net/mqtt.h @@ -763,6 +763,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 certificate verification. */ const char *hostname; diff --git a/include/zephyr/net/net_stats.h b/include/zephyr/net/net_stats.h index de95b35fbb72..33f151335254 100644 --- a/include/zephyr/net/net_stats.h +++ b/include/zephyr/net/net_stats.h @@ -191,6 +191,23 @@ struct net_stats_udp { net_stats_t chkerr; }; +/** + * @brief Raw packet socket statistics + */ +struct net_stats_raw { + /** Amount of received and sent raw packet data. */ + struct net_stats_bytes bytes; + + /** Number of dropped raw packets. */ + net_stats_t drop; + + /** Number of received raw packets. */ + net_stats_t recv; + + /** Number of sent raw packets. */ + net_stats_t sent; +}; + /** * @brief IPv6 neighbor discovery statistics */ @@ -445,6 +462,11 @@ struct net_stats { struct net_stats_udp udp; #endif +#if defined(CONFIG_NET_STATISTICS_RAW) + /** Raw packet socket statistics */ + struct net_stats_raw raw; +#endif + #if defined(CONFIG_NET_STATISTICS_IPV6_ND) /** IPv6 neighbor discovery statistics */ struct net_stats_ipv6_nd ipv6_nd; @@ -751,6 +773,7 @@ enum net_request_stats_cmd { NET_REQUEST_STATS_CMD_GET_IPV4_PMTU, NET_REQUEST_STATS_CMD_GET_ICMP, NET_REQUEST_STATS_CMD_GET_UDP, + NET_REQUEST_STATS_CMD_GET_RAW, NET_REQUEST_STATS_CMD_GET_TCP, NET_REQUEST_STATS_CMD_GET_ETHERNET, NET_REQUEST_STATS_CMD_GET_PPP, @@ -865,6 +888,16 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_UDP); /** @endcond */ #endif /* CONFIG_NET_STATISTICS_UDP */ +#if defined(CONFIG_NET_STATISTICS_RAW) +/** Request raw packet socket statistics */ +#define NET_REQUEST_STATS_GET_RAW \ + (NET_STATS_BASE | NET_REQUEST_STATS_CMD_GET_RAW) + +/** @cond INTERNAL_HIDDEN */ +NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_RAW); +/** @endcond */ +#endif /* CONFIG_NET_STATISTICS_RAW */ + #if defined(CONFIG_NET_STATISTICS_TCP) /** Request TCP statistics */ #define NET_REQUEST_STATS_GET_TCP \ @@ -1120,6 +1153,50 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_RESET_WIFI); #define NET_STATS_PROMETHEUS_UDP(iface, dev_id, sfx) #endif +/* Raw packet socket statistics */ +#if defined(CONFIG_NET_STATISTICS_RAW) +#define NET_STATS_PROMETHEUS_RAW(iface, dev_id, sfx) \ + NET_STATS_PROMETHEUS_COUNTER_DEFINE( \ + "Raw packets sent", \ + NET_STATS_GET_INSTANCE(dev_id, sfx, raw_sent), \ + "packet_count", \ + NET_STATS_GET_COLLECTOR_NAME(dev_id, sfx), \ + NET_STATS_GET_VAR(dev_id, sfx, raw_sent), \ + &(iface)->stats.raw.sent); \ + NET_STATS_PROMETHEUS_COUNTER_DEFINE( \ + "Raw packets received", \ + NET_STATS_GET_INSTANCE(dev_id, sfx, raw_recv), \ + "packet_count", \ + NET_STATS_GET_COLLECTOR_NAME(dev_id, sfx), \ + NET_STATS_GET_VAR(dev_id, sfx, raw_recv), \ + &(iface)->stats.raw.recv); \ + NET_STATS_PROMETHEUS_COUNTER_DEFINE( \ + "Raw packets dropped", \ + NET_STATS_GET_INSTANCE(dev_id, sfx, raw_drop), \ + "packet_count", \ + NET_STATS_GET_COLLECTOR_NAME(dev_id, sfx), \ + NET_STATS_GET_VAR(dev_id, sfx, raw_drop), \ + &(iface)->stats.raw.drop); \ + NET_STATS_PROMETHEUS_COUNTER_DEFINE( \ + "Raw bytes sent", \ + NET_STATS_GET_INSTANCE(dev_id, sfx, raw_bytes_sent), \ + "byte_count", \ + NET_STATS_GET_COLLECTOR_NAME(dev_id, sfx), \ + NET_STATS_GET_VAR(dev_id, sfx, raw_bytes_sent), \ + &(iface)->stats.raw.bytes.sent); \ + NET_STATS_PROMETHEUS_COUNTER_DEFINE( \ + "Raw bytes received", \ + NET_STATS_GET_INSTANCE(dev_id, sfx, raw_bytes_recv), \ + "byte_count", \ + NET_STATS_GET_COLLECTOR_NAME(dev_id, sfx), \ + NET_STATS_GET_VAR(dev_id, sfx, raw_bytes_recv), \ + &(iface)->stats.raw.bytes.received) +#else +/** @cond INTERNAL_HIDDEN */ +#define NET_STATS_PROMETHEUS_RAW(iface, dev_id, sfx) +/** @endcond */ +#endif + /* TCP layer statistics */ #if defined(CONFIG_NET_STATISTICS_TCP) #define NET_STATS_PROMETHEUS_TCP(iface, dev_id, sfx) \ @@ -1536,6 +1613,7 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_RESET_WIFI); NET_STATS_PROMETHEUS_IPV4(iface, dev_id, sfx); \ NET_STATS_PROMETHEUS_ICMP(iface, dev_id, sfx); \ NET_STATS_PROMETHEUS_UDP(iface, dev_id, sfx); \ + NET_STATS_PROMETHEUS_RAW(iface, dev_id, sfx); \ NET_STATS_PROMETHEUS_TCP(iface, dev_id, sfx); \ NET_STATS_PROMETHEUS_IPV6_ND(iface, dev_id, sfx); \ NET_STATS_PROMETHEUS_IPV6_PMTU(iface, dev_id, sfx); \ diff --git a/include/zephyr/net/socket.h b/include/zephyr/net/socket.h index 322309c26f02..3dd8874fbc60 100644 --- a/include/zephyr/net/socket.h +++ b/include/zephyr/net/socket.h @@ -36,6 +36,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..7c8bae645f6c --- /dev/null +++ b/include/zephyr/net/socket_ncs.h @@ -0,0 +1,228 @@ +/* + * 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 + +#include + +/* 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 + +/** Define a base for NCS specific socket options to prevent overlaps with Zephyr's socket options. + */ +#define NET_SOCKET_NCS_BASE 1000 + +/* 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 (NET_SOCKET_NCS_BASE + 18) + +/** Socket option to save DTLS connection, specifically for nRF sockets. + */ +#define TLS_DTLS_CONN_SAVE (NET_SOCKET_NCS_BASE + 19) + +/** Socket option to load DTLS connection, specifically for nRF sockets. + */ +#define TLS_DTLS_CONN_LOAD (NET_SOCKET_NCS_BASE + 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 (NET_SOCKET_NCS_BASE + 21) + +/* 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 + +/** Socket option to enable the DTLS fragmentation extension. + * Accepted values for the option are: @ref DTLS_FRAG_EXT_DISABLED, + * @ref DTLS_FRAG_EXT_512_ENABLED, @ref DTLS_FRAG_EXT_1024_ENABLED. + */ +#define TLS_DTLS_FRAG_EXT (NET_SOCKET_NCS_BASE + 22) + +/** Disabled - The DTLS fragmentation extension is not included in the Client Hello. */ +#define DTLS_FRAG_EXT_DISABLED 0 +/** Enabled - The DTLS fragmentation extension is included in the Client Hello with the fragment + * size of 512 bytes. + * + * @note The user data size in send requests also becomes limited to a maximum of 512 bytes. + */ +#define DTLS_FRAG_EXT_512_ENABLED 1 +/** Enabled - The DTLS fragmentation extension is included in the Client Hello with the fragment + * size of 1024 bytes. + * + * @note The user data size in send requests also becomes limited to a maximum of 1024 bytes. + */ +#define DTLS_FRAG_EXT_1024_ENABLED 2 + +/* NCS specific socket options */ + +/** sockopt: enable sending data as part of exceptional events */ +#define SO_EXCEPTIONAL_DATA (NET_SOCKET_NCS_BASE + 33) +/** sockopt: Keep socket open when its PDN connection is lost + * or the device is put into flight mode. + */ +#define SO_KEEPOPEN (NET_SOCKET_NCS_BASE + 34) +/** sockopt: bind to PDN */ +#define SO_BINDTOPDN (NET_SOCKET_NCS_BASE + 40) + +/** 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 (NET_SOCKET_NCS_BASE + 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 + +/** sockopt: set a callback to be called when a send request is acknowledged by the network and + * the data has been acknowledged by the peer, if required by the network protocol, or until the + * timeout, given by the SO_SNDTIMEO socket option, is reached. Valid timeout values are + * 1 to 600 seconds. + * This option takes a @ref socket_ncs_sendcb structure. + * + * @note The callback is executed in an interrupt context. + * Take care to offload any processing as appropriate. + * + * @note This is only supported by the following modem firmware: + * - mfw_nrf9151-ntn + * + * This socket option cannot be used along with the @ref MSG_WAITACK send flag. + */ +#define SO_SENDCB (NET_SOCKET_NCS_BASE + 63) + +/** Parameters returned in the @ref socket_ncs_sendcb_t callback. */ +struct socket_ncs_sendcb_params { + /** Socket handle. */ + int fd; + /** Status. Can be 0 on successful send or EAGAIN on timeout. */ + int status; + /** Number of bytes that was sent. */ + size_t bytes_sent; +}; + +/** Callback type in the @ref socket_ncs_sendcb structure. */ +typedef void (*socket_ncs_sendcb_t)(const struct socket_ncs_sendcb_params *params); + +/** Option value for the @ref SO_SENDCB socket option. */ +struct socket_ncs_sendcb { + /** Callback function. */ + socket_ncs_sendcb_t callback; +}; + +/* 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 (NET_SOCKET_NCS_BASE + 30) + +/* NCS specific IPPROTO_IP level socket options */ + +/** sockopt: enable IPv4 ICMP replies */ +#define SO_IP_ECHO_REPLY (NET_SOCKET_NCS_BASE + 31) + +/* NCS specific IPPROTO_IPV6 level socket options */ + +/** sockopt: enable IPv6 ICMP replies */ +#define SO_IPV6_ECHO_REPLY (NET_SOCKET_NCS_BASE + 32) + +/** sockopt: Delay IPv6 address refresh during power saving mode */ +#define SO_IPV6_DELAYED_ADDR_REFRESH (NET_SOCKET_NCS_BASE + 62) + +/* 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 (NET_SOCKET_NCS_BASE + 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 ace82cd4d1bc..0929cc844154 100644 --- a/include/zephyr/net/wifi.h +++ b/include/zephyr/net/wifi.h @@ -125,6 +125,16 @@ enum wifi_security_type { /** @endcond */ }; +/** @brief WEP key type (based on key length). */ +enum wifi_wep_key_type { + /** WEP key type unknown or not applicable. */ + WIFI_WEP_KEY_TYPE_UNKNOWN = 0, + /** WEP-64 (40-bit key: 5 ASCII or 10 hex chars). */ + WIFI_WEP_KEY_TYPE_64, + /** WEP-128 (104-bit key: 13 ASCII or 26 hex chars). */ + WIFI_WEP_KEY_TYPE_128, +}; + /** @brief EPA method Types. */ enum wifi_eap_type { /** No EPA security. */ @@ -239,6 +249,9 @@ const char *wifi_security_txt(enum wifi_security_type security); /** Helper function to get user-friendly wpa3 enterprise security type name. */ const char *wifi_wpa3_enterprise_txt(enum wifi_wpa3_enterprise_type wpa3_ent); +/** Helper function to get user-friendly WEP key type name. */ +const char *wifi_wep_key_type_txt(enum wifi_wep_key_type wep_key_type); + /** @brief IEEE 802.11w - Management frame protection. */ enum wifi_mfp_options { /** MFP disabled. */ diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index 24f3ec36aac6..3fd632ddea0f 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -863,6 +863,8 @@ struct wifi_iface_status { enum wifi_wpa3_enterprise_type wpa3_ent_type; /** Security type, see enum wifi_security_type */ enum wifi_security_type security; + /** WEP key type (64-bit or 128-bit), see enum wifi_wep_key_type */ + enum wifi_wep_key_type wep_key_type; /** MFP options, see enum wifi_mfp_options */ enum wifi_mfp_options mfp; /** RSSI */ diff --git a/include/zephyr/shell/shell.h b/include/zephyr/shell/shell.h index 7348fb157cfc..41ace41f5d5d 100644 --- a/include/zephyr/shell/shell.h +++ b/include/zephyr/shell/shell.h @@ -1040,10 +1040,11 @@ struct shell_ctx { volatile union shell_backend_cfg cfg; volatile union shell_backend_ctx ctx; +#if CONFIG_MULTITHREADING struct k_event signal_event; - struct k_sem lock_sem; k_tid_t tid; +#endif int ret_val; }; @@ -1079,13 +1080,29 @@ struct shell { LOG_INSTANCE_PTR_DECLARE(log); const char *name; + +#if CONFIG_MULTITHREADING struct k_thread *thread; k_thread_stack_t *stack; +#endif }; extern void z_shell_print_stream(const void *user_ctx, const char *data, size_t data_len); +#if CONFIG_MULTITHREADING +#define Z_SHELL_THREAD_DEFINE(_name) \ + static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \ + static struct k_thread _name##_thread + +#define Z_SHELL_THREAD_INIT(_name) \ + .thread = &_name##_thread, \ + .stack = _name##_stack, +#else +#define Z_SHELL_THREAD_DEFINE(_name) +#define Z_SHELL_THREAD_INIT(_name) +#endif + /** @brief Internal macro for defining a shell instance. * * As it does not create the default shell logging backend it allows to use @@ -1106,8 +1123,7 @@ extern void z_shell_print_stream(const void *user_ctx, const char *data, IS_ENABLED(CONFIG_SHELL_PRINTF_AUTOFLUSH), z_shell_print_stream); \ LOG_INSTANCE_REGISTER(shell, _name, CONFIG_SHELL_LOG_LEVEL); \ Z_SHELL_STATS_DEFINE(_name); \ - static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \ - static struct k_thread _name##_thread; \ + Z_SHELL_THREAD_DEFINE(_name); \ static const STRUCT_SECTION_ITERABLE(shell, _name) = { \ .default_prompt = _prompt, \ .iface = _transport_iface, \ @@ -1117,8 +1133,9 @@ extern void z_shell_print_stream(const void *user_ctx, const char *data, .fprintf_ctx = &_name##_fprintf, \ .stats = Z_SHELL_STATS_PTR(_name), \ .log_backend = _log_backend, \ - LOG_INSTANCE_PTR_INIT(log, shell, _name).name = \ - STRINGIFY(_name), .thread = &_name##_thread, .stack = _name##_stack} + LOG_INSTANCE_PTR_INIT(log, shell, _name).name = STRINGIFY(_name), \ + Z_SHELL_THREAD_INIT(_name) \ + } /** * @brief Macro for defining a shell instance. diff --git a/include/zephyr/storage/flash_map.h b/include/zephyr/storage/flash_map.h index 13f381e135fd..819f94182474 100644 --- a/include/zephyr/storage/flash_map.h +++ b/include/zephyr/storage/flash_map.h @@ -351,6 +351,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 partition of given DTS node label exists. * @@ -620,6 +624,8 @@ DT_FOREACH_STATUS_OKAY(fixed_subpartitions, FOR_EACH_SUBPARTITION_TABLE) #undef FOR_EACH_SUBPARTITION_TABLE /** @endcond */ +#endif /* USE_PARTITION_MANAGER */ + #ifdef __cplusplus } #endif diff --git a/include/zephyr/sw_isr_table.h b/include/zephyr/sw_isr_table.h index 0520b72525df..3264b9a51dd6 100644 --- a/include/zephyr/sw_isr_table.h +++ b/include/zephyr/sw_isr_table.h @@ -41,14 +41,18 @@ struct _isr_table_entry { void (*isr)(const void *); }; +#if defined(CONFIG_GEN_SW_ISR_TABLE_ARRAY) /* The software ISR table itself, an array of these structures indexed by the * irq line */ extern #ifndef CONFIG_DYNAMIC_INTERRUPTS -const -#endif -struct _isr_table_entry _sw_isr_table[]; + const +#endif /* CONFIG_DYNAMIC_INTERRUPTS */ + struct _isr_table_entry _sw_isr_table[]; +#elif defined(CONFIG_GEN_SW_ISR_TABLE_SWITCH) +extern void __sw_isr_table get_isr_entry(int irq_number, struct _isr_table_entry *entry); +#endif /* CONFIG_GEN_SW_ISR_TABLE_ARRAY */ struct _irq_parent_entry { const struct device *dev; diff --git a/include/zephyr/sys/mem_manage.h b/include/zephyr/sys/mem_manage.h index a05b72d3886e..ab55a1f9ede1 100644 --- a/include/zephyr/sys/mem_manage.h +++ b/include/zephyr/sys/mem_manage.h @@ -23,9 +23,9 @@ * * This checks if the physical address (@p virt) is within * permissible range, e.g. between - * :kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` and - * (:kconfig:option:`CONFIG_SRAM_BASE_ADDRESS` + - * :kconfig:option:`CONFIG_SRAM_SIZE`). + * :c:macro:`DT_CHOSEN_SRAM_ADDR` and + * (:c:macro:`DT_CHOSEN_SRAM_ADDR` + + * :c:macro:`DT_CHOSEN_SRAM_SIZE`). * * @note Only used if * :kconfig:option:`CONFIG_KERNEL_VM_USE_CUSTOM_MEM_RANGE_CHECK` diff --git a/include/zephyr/usb/usbd.h b/include/zephyr/usb/usbd.h index 4527f417483e..1af162325332 100644 --- a/include/zephyr/usb/usbd.h +++ b/include/zephyr/usb/usbd.h @@ -853,6 +853,8 @@ int usbd_add_configuration(struct usbd_context *uds_ctx, * @param[in] cfg Configuration value (bConfigurationValue) * * @return 0 on success, other values on fail. + * @retval -EALREADY If class instance is already registered. + * @retval -EBUSY If USB device support is already initialized. */ int usbd_register_class(struct usbd_context *uds_ctx, const char *name, diff --git a/kernel/include/mmu.h b/kernel/include/mmu.h index e4a9f84d334a..f3b4b5f370e9 100644 --- a/kernel/include/mmu.h +++ b/kernel/include/mmu.h @@ -14,12 +14,13 @@ #include #include #include +#include /** Start address of physical memory. */ -#define K_MEM_PHYS_RAM_START ((uintptr_t)CONFIG_SRAM_BASE_ADDRESS) +#define K_MEM_PHYS_RAM_START ((uintptr_t)DT_CHOSEN_SRAM_ADDR) /** Size of physical memory. */ -#define K_MEM_PHYS_RAM_SIZE (KB(CONFIG_SRAM_SIZE)) +#define K_MEM_PHYS_RAM_SIZE DT_CHOSEN_SRAM_SIZE /** End address (exclusive) of physical memory. */ #define K_MEM_PHYS_RAM_END (K_MEM_PHYS_RAM_START + K_MEM_PHYS_RAM_SIZE) @@ -49,7 +50,7 @@ */ #define K_MEM_VM_OFFSET \ ((CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_OFFSET) - \ - (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_OFFSET)) + (K_MEM_PHYS_RAM_START + CONFIG_SRAM_OFFSET)) /** * @brief Get physical address from virtual address for boot RAM mappings. @@ -87,7 +88,7 @@ * * - If it is enabled, which means all physical memory are mapped in virtual * memory address space, and it is the same as - * (CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE). + * (DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE). * * - If it is disabled, K_MEM_VM_FREE_START is the same K_MEM_KERNEL_VIRT_END which * is the end of the kernel image. @@ -113,8 +114,8 @@ * @brief Number of page frames. * * At present, page frame management is only done for main system RAM, - * and we generate paging structures based on CONFIG_SRAM_BASE_ADDRESS - * and CONFIG_SRAM_SIZE. + * and we generate paging structures based on DT_CHOSEN_SRAM_ADDR + * and DT_CHOSEN_SRAM_SIZE. * * If we have other RAM regions (DCCM, etc) these typically have special * properties and shouldn't be used generically for demand paging or diff --git a/lib/heap/Kconfig b/lib/heap/Kconfig index b9e6371fabff..b50427aeaa73 100644 --- a/lib/heap/Kconfig +++ b/lib/heap/Kconfig @@ -157,10 +157,14 @@ module = SYS_HEAP module-str = sys_heap source "subsys/logging/Kconfig.template.log_config" +DT_CHOSEN_Z_SRAM = zephyr,sram +DT_SRAM_SIZE = $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) + choice prompt "Supported heap sizes" depends on !64BIT - default SYS_HEAP_SMALL_ONLY if (SRAM_SIZE <= 256) + default SYS_HEAP_SMALL_ONLY if ((SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 256) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(DT_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 74193fbdce48..f4d8be2671d9 100644 --- a/lib/libc/common/source/stdlib/malloc.c +++ b/lib/libc/common/source/stdlib/malloc.c @@ -25,6 +25,16 @@ #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_ADDR DT_CHOSEN_SRAM_ADDR +#define RAM_SIZE DT_CHOSEN_SRAM_SIZE +#endif /* USE_PARTITION_MANAGER */ + #ifdef CONFIG_COMMON_LIBC_MALLOC #if (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE != 0) @@ -106,8 +116,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((size_t) 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/lib/libc/newlib/libc-hooks.c b/lib/libc/newlib/libc-hooks.c index 55c109d8fe84..f7cd15da0324 100644 --- a/lib/libc/newlib/libc-hooks.c +++ b/lib/libc/newlib/libc-hooks.c @@ -111,8 +111,8 @@ int _getpid(void); #define MAX_HEAP_SIZE (POINTER_TO_UINT(&_heap_sentry) - \ HEAP_BASE) #else - #define MAX_HEAP_SIZE (KB(CONFIG_SRAM_SIZE) - (HEAP_BASE - \ - CONFIG_SRAM_BASE_ADDRESS)) + #define MAX_HEAP_SIZE (DT_CHOSEN_SRAM_SIZE - (HEAP_BASE - \ + DT_CHOSEN_SRAM_ADDR)) #endif /* CONFIG_XTENSA */ #endif diff --git a/lib/os/zvfs/Kconfig b/lib/os/zvfs/Kconfig index d7b6914cb5d8..420d6bc41333 100644 --- a/lib/os/zvfs/Kconfig +++ b/lib/os/zvfs/Kconfig @@ -5,7 +5,6 @@ menuconfig ZVFS bool "Zephyr virtual filesystem (ZVFS) support [EXPERIMENTAL]" - select EXPERIMENTAL help ZVFS is a central, Zephyr-native library that provides a common interoperable API for all types of file descriptors such as those from the non-virtual FS, sockets, eventfds, FILE *'s diff --git a/lib/uuid/CMakeLists.txt b/lib/uuid/CMakeLists.txt index fa0b91ac5c5a..e0d58982e368 100644 --- a/lib/uuid/CMakeLists.txt +++ b/lib/uuid/CMakeLists.txt @@ -2,4 +2,4 @@ zephyr_sources_ifdef(CONFIG_UUID uuid.c) -zephyr_library_link_libraries_ifdef(CONFIG_UUID_V5 mbedTLS) +zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS_BUILTIN mbedTLS) diff --git a/lib/uuid/Kconfig b/lib/uuid/Kconfig index 040b7c7768c5..189893ad3935 100644 --- a/lib/uuid/Kconfig +++ b/lib/uuid/Kconfig @@ -2,25 +2,21 @@ # # SPDX-License-Identifier: Apache-2.0 -menu "Universally Unique Identifier (UUID)" - -config UUID - bool "UUID support" +menuconfig UUID + bool "Universally Unique Identifier (UUID) library" help Enable use of the UUID library. +if UUID + config UUID_V4 bool "UUID version 4 generation support" - depends on UUID depends on ENTROPY_GENERATOR help Enable generation of UUID v4. config UUID_V5 bool "UUID version 5 generation support" - depends on UUID - depends on MBEDTLS - depends on MBEDTLS_PSA_CRYPTO_C depends on PSA_WANT_ALG_SHA_1 # When TF-M is enabled, Mbed TLS's MD module (which is used to generate # v5 UUIDs) will dispacth hash operations to TF-M. Unfortunately TF-M @@ -32,10 +28,9 @@ config UUID_V5 config UUID_BASE64 bool "UUID Base64 support" - depends on UUID depends on BASE64 help Enable conversion functions to write UUIDs in base 64 formats. -endmenu +endif diff --git a/modules/hal_nordic/CMakeLists.txt b/modules/hal_nordic/CMakeLists.txt index a49aec6406fa..83354b9d2f64 100644 --- a/modules/hal_nordic/CMakeLists.txt +++ b/modules/hal_nordic/CMakeLists.txt @@ -14,6 +14,7 @@ if(CONFIG_NRF_REGTOOL_GENERATE_UICR) endif() if(DEFINED nrf_regtool_components) find_package(nrf-regtool 9.2.0 + REQUIRED COMPONENTS ${nrf_regtool_components} PATHS ${CMAKE_CURRENT_LIST_DIR}/nrf-regtool NO_CMAKE_PATH diff --git a/modules/hal_nordic/ironside/se/CMakeLists.txt b/modules/hal_nordic/ironside/se/CMakeLists.txt index ee5b2be8e2fa..771186cf24bc 100644 --- a/modules/hal_nordic/ironside/se/CMakeLists.txt +++ b/modules/hal_nordic/ironside/se/CMakeLists.txt @@ -48,7 +48,7 @@ if(CONFIG_NRF_PERIPHCONF_SECTION AND NOT SYSBUILD) message(WARNING "CONFIG_NRF_PERIPHCONF_SECTION is enabled, but Sysbuild is not being used. " "The global peripheral configuration will not be applied unless artifacts " "are generated manually/externally. To enable automatic generation, build with " - "Sysbuild and ensure that SB_CONFIG_NRF_HALTIUM_GENERATE_UICR=y." + "Sysbuild and ensure that SB_CONFIG_NRF_GENERATE_UICR=y." ) endif() @@ -56,6 +56,6 @@ if(CONFIG_NRF_MPCCONF_SECTION AND NOT SYSBUILD) message(WARNING "CONFIG_NRF_MPCCONF_SECTION is enabled, but Sysbuild is not being used. " "The MPC configuration will not be applied unless artifacts " "are generated manually/externally. To enable automatic generation, build with " - "Sysbuild and ensure that SB_CONFIG_NRF_HALTIUM_GENERATE_UICR=y." + "Sysbuild and ensure that SB_CONFIG_NRF_GENERATE_UICR=y." ) endif() diff --git a/modules/hal_nordic/nrfx/CMakeLists.txt b/modules/hal_nordic/nrfx/CMakeLists.txt index ea7b59902454..dffdaa361b2b 100644 --- a/modules/hal_nordic/nrfx/CMakeLists.txt +++ b/modules/hal_nordic/nrfx/CMakeLists.txt @@ -139,9 +139,7 @@ zephyr_library_sources_ifdef(CONFIG_HAS_NORDIC_RAM_CTRL ${HELPERS_DIR}/nrf if(CONFIG_NRFX_GPPI AND NOT CONFIG_NRFX_GPPI_V1) zephyr_library_sources_ifdef(CONFIG_HAS_HW_NRF_PPI ${HELPERS_DIR}/nrfx_gppi_ppi.c) - if(CONFIG_SOC_SERIES_NRF54H OR CONFIG_SOC_SERIES_NRF54L OR CONFIG_SOC_SERIES_NRF71 OR CONFIG_HAS_HW_NRF_DPPIC) - zephyr_library_sources(${HELPERS_DIR}/nrfx_gppi_dppi.c) - endif() + zephyr_library_sources_ifndef(CONFIG_HAS_HW_NRF_PPI ${HELPERS_DIR}/nrfx_gppi_dppi.c) if(CONFIG_SOC_COMPATIBLE_NRF54LX OR CONFIG_SOC_SERIES_NRF71) zephyr_library_sources(${BSP_DIR}/soc/interconnect/nrfx_gppi_d2ppi.c) endif() diff --git a/modules/hal_nordic/nrfx/Kconfig b/modules/hal_nordic/nrfx/Kconfig index e45a405b2482..f196ef2129e8 100644 --- a/modules/hal_nordic/nrfx/Kconfig +++ b/modules/hal_nordic/nrfx/Kconfig @@ -140,6 +140,14 @@ config NRFX_GPPI_V1 help When enabled then legacy version of Generic PPI layer is used. +config NRFX_GPPI_SD2PPI_GLOBAL + bool + depends on NRFX_GPPI && !NRFX_GPPI_V1 + help + Indicates GPPI implementation for SD^2PPI (Secure multi-Domain DPPI) architecture. + SD^2PPI architecture is using multiple instances of DPPI controllers and Ironside service + to configure the security and ownership of the PPI resources. + config NRFX_GRTC bool "GRTC driver" depends on $(dt_nodelabel_exists,grtc) @@ -328,6 +336,6 @@ endmenu config NRFX_RESERVED_RESOURCES_HEADER string - default "nrfx_reserved_resources.h" + default "nrfx_reserved_resources_ncs.h" endmenu # "nrfx drivers" diff --git a/modules/hal_nordic/nrfx/nrfx_kconfig.h b/modules/hal_nordic/nrfx/nrfx_kconfig.h index b63b2ed4e308..4b54dcb3df02 100644 --- a/modules/hal_nordic/nrfx/nrfx_kconfig.h +++ b/modules/hal_nordic/nrfx/nrfx_kconfig.h @@ -150,6 +150,14 @@ #define NRFX_GRTC_CONFIG_AUTOSTART 1 #endif +#ifdef CONFIG_NRF_GRTC_TIMER_STOP_AT_UNINIT +#define NRFX_GRTC_CONFIG_STOP_AT_UNINIT 1 +#endif + +#ifdef CONFIG_NRF_GRTC_TIMER_CLEAR_AT_UNINIT +#define NRFX_GRTC_CONFIG_CLEAR_AT_UNINIT 1 +#endif + #ifdef CONFIG_NRFX_GPIOTE #define NRFX_GPIOTE_ENABLED 1 #endif @@ -430,6 +438,10 @@ #define NRFX_WDT_CONFIG_LOG_ENABLED 1 #endif +#ifdef CONFIG_NRFX_GPPI_SD2PPI_GLOBAL +#define NRFX_GPPI_CONFIG_DPPI_PPIB_EXT_FUNC 1 +#endif + #ifdef CONFIG_NRF52_ANOMALY_109_WORKAROUND #define NRF52_ERRATA_109_ENABLE_WORKAROUND 1 #define NRFX_PWM_NRF52_ANOMALY_109_EGU_INSTANCE \ diff --git a/modules/hal_nordic/nrfx/nrfx_reserved_resources_ncs.h b/modules/hal_nordic/nrfx/nrfx_reserved_resources_ncs.h new file mode 100644 index 000000000000..26e8ea67cbea --- /dev/null +++ b/modules/hal_nordic/nrfx/nrfx_reserved_resources_ncs.h @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2024, Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef NRFX_RESERVED_RESOURCES_NCS_H__ +#define NRFX_RESERVED_RESOURCES_NCS_H__ + +#if defined(CONFIG_BT_LL_SOFTDEVICE) +#include +#if defined(CONFIG_SOC_COMPATIBLE_NRF52X) +#define NRFX_PPI_CHANNELS_USED_BY_BT_CTLR SDC_PPI_CHANNELS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF53X) +#define NRFX_DPPI0_CHANNELS_USED_BY_BT_CTLR SDC_DPPI_CHANNELS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) || defined(CONFIG_SOC_SERIES_NRF71) +#define NRFX_DPPI10_CHANNELS_USED_BY_BT_CTLR SDC_DPPIC10_CHANNELS_USED_MASK +#define NRFX_DPPI00_CHANNELS_USED_BY_BT_CTLR SDC_DPPIC00_CHANNELS_USED_MASK +#define NRFX_PPIB_00_10_CHANNELS_USED_BY_BT_CTLR \ + (SDC_PPIB00_CHANNELS_USED_MASK | SDC_PPIB10_CHANNELS_USED_MASK) +#elif defined(CONFIG_SOC_SERIES_NRF54H) +#define NRFX_DPPI020_CHANNELS_USED_BY_BT_CTLR SDC_DPPIC020_CHANNELS_USED_MASK +#define NRFX_DPPI030_CHANNELS_USED_BY_BT_CTLR SDC_DPPIC030_CHANNELS_USED_MASK +#define NRFX_PPIB_020_030_CHANNELS_USED_BY_BT_CTLR \ + (SDC_PPIB020_CHANNELS_USED_MASK | SDC_PPIB030_CHANNELS_USED_MASK) +#else +#error Unsupported chip family +#endif +#endif /* defined(CONFIG_BT_LL_SOFTDEVICE) */ + +#if defined(CONFIG_MPSL) +#include +#if defined(CONFIG_SOC_COMPATIBLE_NRF52X) +#define NRFX_PPI_CHANNELS_USED_BY_MPSL MPSL_PPI_CHANNELS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF53X) +#define NRFX_DPPI0_CHANNELS_USED_BY_MPSL MPSL_DPPIC_CHANNELS_USED_MASK +#elif defined(CONFIG_SOC_COMPATIBLE_NRF54LX) || defined(CONFIG_SOC_SERIES_NRF71) +#define NRFX_DPPI10_CHANNELS_USED_BY_MPSL MPSL_DPPIC10_CHANNELS_USED_MASK +#define NRFX_DPPI20_CHANNELS_USED_BY_MPSL MPSL_DPPIC20_CHANNELS_USED_MASK +#define NRFX_PPIB_11_21_CHANNELS_USED_BY_MPSL \ + (MPSL_PPIB11_CHANNELS_USED_MASK | MPSL_PPIB21_CHANNELS_USED_MASK) +#elif defined(CONFIG_SOC_SERIES_NRF54H) +#define NRFX_DPPI020_CHANNELS_USED_BY_MPSL MPSL_DPPIC020_CHANNELS_USED_MASK +#else +#error Unsupported chip family +#endif +#endif + +#include "nrfx_reserved_resources.h" + +#if defined(NRF_802154_VERIFY_PERIPHS_ALLOC_AGAINST_MPSL) + +BUILD_ASSERT((NRFX_DPPI0_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI0_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI0_GROUPS_USED_BY_802154_DRV & NRFX_DPPI0_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI00_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI00_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI00_GROUPS_USED_BY_802154_DRV & NRFX_DPPI00_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI10_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI10_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI10_GROUPS_USED_BY_802154_DRV & NRFX_DPPI10_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI20_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI20_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI20_GROUPS_USED_BY_802154_DRV & NRFX_DPPI20_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI30_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI30_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI30_GROUPS_USED_BY_802154_DRV & NRFX_DPPI30_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI020_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI020_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI020_GROUPS_USED_BY_802154_DRV & NRFX_DPPI020_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI030_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI030_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI030_GROUPS_USED_BY_802154_DRV & NRFX_DPPI030_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI120_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI120_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI120_GROUPS_USED_BY_802154_DRV & NRFX_DPPI120_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI130_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI130_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI130_GROUPS_USED_BY_802154_DRV & NRFX_DPPI130_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI131_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI131_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI131_GROUPS_USED_BY_802154_DRV & NRFX_DPPI131_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI132_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI132_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI132_GROUPS_USED_BY_802154_DRV & NRFX_DPPI132_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI133_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI133_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI133_GROUPS_USED_BY_802154_DRV & NRFX_DPPI133_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI134_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI134_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI134_GROUPS_USED_BY_802154_DRV & NRFX_DPPI134_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI135_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI135_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI135_GROUPS_USED_BY_802154_DRV & NRFX_DPPI135_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI136_CHANNELS_USED_BY_802154_DRV & NRFX_DPPI136_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_DPPI136_GROUPS_USED_BY_802154_DRV & NRFX_DPPI136_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPI_CHANNELS_USED_BY_802154_DRV & NRFX_PPI_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPI_GROUPS_USED_BY_802154_DRV & NRFX_PPI_GROUPS_USED_BY_MPSL) == 0, + "PPI groups used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_00_10_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_00_10_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_01_20_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_01_20_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_11_21_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_11_21_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_22_30_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_22_30_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_02_03_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_02_03_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_04_12_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_04_12_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +BUILD_ASSERT((NRFX_PPIB_020_030_CHANNELS_USED_BY_802154_DRV & + NRFX_PPIB_020_030_CHANNELS_USED_BY_MPSL) == 0, + "PPI channels used by the IEEE802.15.4 radio driver overlap with those " + "assigned to the MPSL."); + +#endif /* NRF_802154_VERIFY_PERIPHS_ALLOC_AGAINST_MPSL */ +#endif /* NRFX_RESERVED_RESOURCES_NCS_H__ */ diff --git a/modules/hostap/Kconfig b/modules/hostap/Kconfig index 354eacaef98c..219f56e6ded8 100644 --- a/modules/hostap/Kconfig +++ b/modules/hostap/Kconfig @@ -39,8 +39,7 @@ config WIFI_NM_WPA_SUPPLICANT_HEAP int "Dedicated memory pool for wpa_supplicant" def_int 66560 if WIFI_NM_HOSTAPD_AP def_int 60000 if WIFI_USAGE_MODE_STA_AP - def_int 55000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE && WIFI_CREDENTIALS - def_int 48000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE + def_int 55000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE def_int 41808 if WIFI_NM_WPA_SUPPLICANT_AP def_int 40000 if WIFI_NM_MAX_MANAGED_INTERFACES=2 # 30K is mandatory, but might need more for long duration use cases @@ -51,8 +50,7 @@ if WIFI_NM_WPA_SUPPLICANT_GLOBAL_HEAP config HEAP_MEM_POOL_ADD_SIZE_HOSTAP def_int 66560 if WIFI_NM_HOSTAPD_AP def_int 60000 if WIFI_USAGE_MODE_STA_AP - def_int 55000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE && WIFI_CREDENTIALS - def_int 48000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE + def_int 55000 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE def_int 80000 if WIFI_NM_WPA_SUPPLICANT_P2P def_int 41808 if WIFI_NM_WPA_SUPPLICANT_AP # 30K is mandatory, but might need more for long duration use cases @@ -64,7 +62,7 @@ config WIFI_NM_WPA_SUPPLICANT_THREAD_STACK_SIZE int "Stack size for wpa_supplicant thread" # TODO: Providing higher stack size for Enterprise mode to fix stack # overflow issues. Need to identify the cause for higher stack usage. - default 8192 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE || WIFI_USAGE_MODE_STA_AP + default 8600 if WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE || WIFI_USAGE_MODE_STA_AP default 7900 if WIFI_NM_WPA_SUPPLICANT_P2P # This is needed to handle stack overflow issues on nRF Wi-Fi drivers. default 6300 if WIFI_NM_WPA_SUPPLICANT_AP @@ -318,10 +316,42 @@ config EAP_TLSV1_3 endif # WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE -config WIFI_NM_WPA_SUPPLICANT_WPA3 - bool "WPA3 support" +choice WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION + prompt "WPA3 implementation" + default WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_INT depends on !WIFI_NM_WPA_SUPPLICANT_CRYPTO_NONE - default y + help + Select how WPA3/SAE is provided. Internal uses the supplicant + bignum-based implementation. External uses an out-of-tree + implementation (e.g. PSA crypto). None disables WPA3. + +config WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_NONE + bool "None" + help + WPA3 is disabled. Only WPA2 and earlier are available. + +config WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_INT + bool "Internal" + select WIFI_NM_WPA_SUPPLICANT_WPA3 + +config WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_EXT + bool "External" + +endchoice + +config WIFI_NM_WPA_SUPPLICANT_WPA3 + bool + help + Internal WPA3/SAE implementation (bignum-based). Selected by + WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_INT. + +config WIFI_NM_WPA_SUPPLICANT_WPA3_COMMON + bool + default y if WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_INT || \ + WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_EXT + help + WPA3/SAE is available (either internal or external implementation). + Use this in code to gate WPA3 functionality regardless of backend. config WIFI_NM_WPA_SUPPLICANT_AP bool "SoftAP mode support based on WPA supplicant" diff --git a/modules/hostap/src/supp_api.c b/modules/hostap/src/supp_api.c index 756ac507b680..9e4614dc9ba8 100644 --- a/modules/hostap/src/supp_api.c +++ b/modules/hostap/src/supp_api.c @@ -404,6 +404,11 @@ enum wifi_security_type wpas_key_mgmt_to_zephyr(bool is_hapd, void *config, int for (int i = 0; i < NUM_WEP_KEYS; i++) { if (ssid->wep_key_len[i] > 0) { + if (ssid->auth_alg == WPA_AUTH_ALG_OPEN) { + return WIFI_SECURITY_TYPE_WEP_OPEN; + } else if (ssid->auth_alg == WPA_AUTH_ALG_SHARED) { + return WIFI_SECURITY_TYPE_WEP_SHARED; + } return WIFI_SECURITY_TYPE_WEP; } } @@ -419,7 +424,7 @@ enum wifi_security_type wpas_key_mgmt_to_zephyr(bool is_hapd, void *config, int case WPA_KEY_MGMT_PSK_SHA256: return WIFI_SECURITY_TYPE_PSK_SHA256; case WPA_KEY_MGMT_SAE: - if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3)) { + if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_COMMON)) { if (pwe == 1) { return WIFI_SECURITY_TYPE_SAE_H2E; } else if (pwe == 2) { @@ -438,7 +443,7 @@ enum wifi_security_type wpas_key_mgmt_to_zephyr(bool is_hapd, void *config, int case WPA_KEY_MGMT_FT_PSK: return WIFI_SECURITY_TYPE_FT_PSK; case WPA_KEY_MGMT_FT_SAE: - if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3)) { + if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_COMMON)) { return WIFI_SECURITY_TYPE_FT_SAE; } return WIFI_SECURITY_TYPE_UNKNOWN; @@ -449,7 +454,7 @@ enum wifi_security_type wpas_key_mgmt_to_zephyr(bool is_hapd, void *config, int case WPA_KEY_MGMT_FT_IEEE8021X_SHA384: return WIFI_SECURITY_TYPE_FT_EAP_SHA384; case WPA_KEY_MGMT_SAE_EXT_KEY: - if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3)) { + if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_COMMON)) { return WIFI_SECURITY_TYPE_SAE_EXT_KEY; } return WIFI_SECURITY_TYPE_UNKNOWN; @@ -747,7 +752,7 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s, } } - if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3) && + if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_COMMON) && (params->security == WIFI_SECURITY_TYPE_SAE_HNP || params->security == WIFI_SECURITY_TYPE_SAE_H2E || params->security == WIFI_SECURITY_TYPE_SAE_AUTO || @@ -853,7 +858,7 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s, goto out; } - if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3)) { + if (IS_ENABLED(CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_COMMON)) { if (params->sae_password) { if ((params->sae_password_length < WIFI_PSK_MIN_LEN) || (params->sae_password_length > WIFI_SAE_PSWD_MAX_LEN)) { @@ -1489,6 +1494,19 @@ int supplicant_status(const struct device *dev, struct wifi_iface_status *status status->band = wpas_band_to_zephyr(wpas_freq_to_band(wpa_s->assoc_freq)); status->wpa3_ent_type = wpas_key_mgmt_to_zephyr_wpa3_ent(key_mgmt); status->security = wpas_key_mgmt_to_zephyr(0, ssid, key_mgmt, proto, sae_pwe); +#ifdef CONFIG_WEP + if (status->security == WIFI_SECURITY_TYPE_WEP || + status->security == WIFI_SECURITY_TYPE_WEP_OPEN || + status->security == WIFI_SECURITY_TYPE_WEP_SHARED) { + size_t klen = ssid->wep_key_len[ssid->wep_tx_keyidx]; + + if (klen == 5 || klen == 10) { + status->wep_key_type = WIFI_WEP_KEY_TYPE_64; + } else if (klen == 13 || klen == 26) { + status->wep_key_type = WIFI_WEP_KEY_TYPE_128; + } + } +#endif status->mfp = get_mfp(ssid->ieee80211w); ieee80211_freq_to_chan(wpa_s->assoc_freq, &channel); status->channel = channel; @@ -2214,6 +2232,13 @@ static int supplicant_wps_pin(const struct device *dev, struct wifi_wps_config_p if (zephyr_wpa_cli_cmd_resp(wpa_s->ctrl_conn, get_pin_cmd, params->pin)) { goto out; } + + if (!wpa_cli_cmd_v("wps_pin any %s", params->pin)) { + goto out; + } + + wpas_api_ctrl.dev = dev; + wpas_api_ctrl.requested_op = WPS_PIN; } else if (params->oper == WIFI_WPS_PIN_SET) { if (!wpa_cli_cmd_v("wps_check_pin %s", params->pin)) { goto out; @@ -2976,13 +3001,12 @@ int supplicant_p2p_oper(const struct device *dev, struct wifi_p2p_params *params join_str); break; case WIFI_P2P_METHOD_KEYPAD: - method_str = "keypad"; if (params->connect.pin[0] == '\0') { wpa_printf(MSG_ERROR, "PIN required for keypad method"); return -EINVAL; } - snprintk(cmd_buf, sizeof(cmd_buf), "P2P_CONNECT %s %s %s go_intent=%d%s%s", - addr_str, method_str, params->connect.pin, + snprintk(cmd_buf, sizeof(cmd_buf), "P2P_CONNECT %s %s go_intent=%d%s%s", + addr_str, params->connect.pin, params->connect.go_intent, freq_str, join_str); break; default: diff --git a/modules/mbedtls/CMakeLists.txt b/modules/mbedtls/CMakeLists.txt index e75bfae7feb9..20e1b0b7ac62 100644 --- a/modules/mbedtls/CMakeLists.txt +++ b/modules/mbedtls/CMakeLists.txt @@ -5,85 +5,236 @@ # if(CONFIG_MBEDTLS) + zephyr_interface_library_named(mbedTLS) if(CONFIG_MBEDTLS_BUILTIN) - # Create an interface library named "mbedTLS": - # - This is the library other modules/subsystems link against. - # - It contains some Mbed TLS configuration flags (ex: MBEDTLS_CONFIG_FILE - # and TF_PSA_CRYPTO_CONFIG_FILE) which are used in Mbed TLS build, but - # which must also be defined when Zephyr code includes headers - # from Mbed TLS. - # - It contains public include directories which are provided by Mbed TLS. - zephyr_interface_library_named(mbedTLS) - - # Explicitly link zephyr_interface to mbedTLS - zephyr_link_libraries(mbedTLS) + if(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR AND NOT CONFIG_ENTROPY_HAS_DRIVER) + message(WARNING "No entropy device on the system, using fake entropy source!") + endif() + + if(CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) + if(CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG OR + CONFIG_TEST_CSPRNG_GENERATOR) + message(WARNING " + Non cryptographycally secure sources are enabled for psa_generate_random(). + This is meant to be used only for tests, not in production!") + else() + if(NOT CONFIG_CSPRNG_ENABLED) + message(FATAL_ERROR " + MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is set but there is + no CSPRNG enabled.") + endif() + endif() + endif() + # Add the config-file entry point target_compile_definitions(mbedTLS INTERFACE - MBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CONFIG_FILE}" - TF_PSA_CRYPTO_CONFIG_FILE="${CONFIG_TF_PSA_CRYPTO_CONFIG_FILE}" + MBEDTLS_CONFIG_FILE="${CONFIG_MBEDTLS_CONFIG_FILE}" ) - # Some CMake variables that are used in Mbed TLS build - set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) - set(MBEDTLS_AS_SUBPROJECT ON) - set(ENABLE_PROGRAMS OFF) - set(ENABLE_TESTING OFF) - set(GEN_FILES OFF) - # Workaround to get rid of a warning generated by the Mbed TLS build system. - set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "") - set(TF_PSA_CRYPTO_DIR ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}) - set(MLDSA_NATIVE_DIR ${ZEPHYR_MLDSA_NATIVE_MODULE_DIR}) - - # Add Mbed TLS (TF-PSA-Crypto is automatically included from there). - # This creates 3 libraries: mbedtls, mbedx509 and tfpsacrypto. - add_subdirectory(${ZEPHYR_MBEDTLS_MODULE_DIR} mbedtls) - - foreach(lib mbedtls mbedx509 tfpsacrypto builtin p256-m everest pqcp extras platform utilities) - # Mbed TLS libraries are normal CMake libraries. - # To ensure Mbed TLS libraries are including Zephyr include directories and - # Zephyr compile options we link those libraries with 'zephyr_interface'. - target_link_libraries(${lib} PRIVATE zephyr_interface) - # Mbed TLS libraries are external CMake targets (not zephyr_library()), - # so they miss the automatic add_dependencies on zephyr_generated_headers - # that zephyr_library() targets get. Without this, generated headers - # like heap_constants.h may not exist when Mbed TLS sources compile. - add_dependencies(${lib} zephyr_generated_headers) - endforeach() - - # Custom macro to tell that a TF-PSA-Crypto source file is being compiled. - # This is used by Secure Storage. - target_compile_definitions(tfpsacrypto PRIVATE BUILDING_MBEDTLS_CRYPTO) - - # Add Mbed TLS libraries ("tfpsacrypto" and "mbedx509" are linked to "mbedtls") - # to ZEPHYR_LIBS list. - zephyr_append_cmake_library(mbedtls) - - # Add Mbed TLS public include directories to the "mbedTLS" interface library. + if(CONFIG_BUILD_WITH_TFM) + target_include_directories(mbedTLS INTERFACE + $/api_ns/interface/include + ) + endif() + + # 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 ) - # Add local include directories to the "mbedTLS" interface library. - target_include_directories(mbedTLS INTERFACE - ${CMAKE_CURRENT_LIST_DIR}/configs - ${CMAKE_CURRENT_LIST_DIR}/include + if(CONFIG_MBEDTLS_PSA_P256M_DRIVER_RAW) + target_include_directories(mbedTLS INTERFACE + ${ZEPHYR_CURRENT_MODULE_DIR}/3rdparty/p256-m/p256-m + ) + endif() + + # Add base library with files required by all drivers/backends. + zephyr_library_named(mbedTLSBase) + + # Base mbed TLS files + list(APPEND mbedtls_base_src + ${ZEPHYR_CURRENT_MODULE_DIR}/library/aes.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/aesni.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/aria.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/asn1parse.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/asn1write.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/base64.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/bignum_core.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/bignum_mod_raw.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/bignum_mod.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/bignum.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/block_cipher.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/camellia.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ccm.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/chacha20.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/chachapoly.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/cipher_wrap.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/cipher.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/cmac.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/constant_time.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ctr_drbg.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/debug.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/des.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/dhm.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ecdh.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ecdsa.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ecjpake.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ecp_curves_new.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ecp_curves.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ecp.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/entropy_poll.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/entropy.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/error.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/gcm.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/hkdf.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/hmac_drbg.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/lmots.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/lms.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/md.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/md5.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/memory_buffer_alloc.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/mps_reader.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/mps_trace.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/nist_kw.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/oid.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/padlock.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/platform_util.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/platform.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/poly1305.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_util.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ripemd160.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/rsa_alt_helpers.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/rsa.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/sha1.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/sha256.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/sha512.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/sha3.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/threading.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/timing.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/version_features.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/version.c + zephyr_init.c + zephyr_entropy.c ) - # Add some support for legacy crypto that unfortunately is still required - # in some scenarios. - include(${CMAKE_CURRENT_LIST_DIR}/legacy_support.cmake) + zephyr_library_sources(${mbedtls_base_src}) - # Add another library to provide Zephyr-specific support - zephyr_library() - zephyr_library_sources( - ${CMAKE_CURRENT_LIST_DIR}/zephyr_init.c - ${CMAKE_CURRENT_LIST_DIR}/zephyr_entropy.c - $<$:${CMAKE_CURRENT_LIST_DIR}/debug.c> - $<$:${CMAKE_CURRENT_LIST_DIR}/shell.c> + zephyr_library_sources_ifdef(CONFIG_MBEDTLS_DEBUG debug.c) + zephyr_library_sources_ifdef(CONFIG_MBEDTLS_SHELL shell.c) + + zephyr_library_app_memory(k_mbedtls_partition) + if(CONFIG_ARCH_POSIX AND CONFIG_ASAN AND NOT CONFIG_64BIT AND NOT CONFIG_NO_OPTIMIZATIONS) + # i386 assembly code used in MBEDTLS does not compile with size optimization + # if address sanitizer is enabled, as such switch default optimization level + # to speed + set_property(SOURCE ${ZEPHYR_CURRENT_MODULE_DIR}/library/bignum_core.c APPEND PROPERTY COMPILE_OPTIONS + "${COMPILER_OPTIMIZE_FOR_SPEED_FLAG}") + endif() + + zephyr_library_link_libraries(mbedTLS) + + zephyr_library_named(mbedTLSCrypto) + + if(CONFIG_MBEDTLS_PSA_CRYPTO_C) + list(APPEND crypto_source + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_aead.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_cipher.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_driver_wrappers_no_static.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_ecp.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_ffdh.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_hash.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_mac.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_pake.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_random.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_rsa.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_se.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_storage.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_its_file.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_client.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/psa_crypto_slot_management.c + ) + endif() + + if(CONFIG_MBEDTLS_PSA_P256M_DRIVER_ENABLED) + list(APPEND crypto_source + ${ZEPHYR_CURRENT_MODULE_DIR}/3rdparty/p256-m/p256-m_driver_entrypoints.c + ${ZEPHYR_CURRENT_MODULE_DIR}/3rdparty/p256-m/p256-m/p256-m.c + ) + zephyr_library_include_directories(${ZEPHYR_CURRENT_MODULE_DIR}/library) + endif() + + list(APPEND crypto_source + ${ZEPHYR_CURRENT_MODULE_DIR}/library/pem.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/pkcs12.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/pkcs5.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/pkparse.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/pkwrite.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/pk.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/pk_ecc.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/pk_wrap.c + ) + + zephyr_library_sources(${crypto_source}) + + # Custom macro to tell that an mbedTLSCrypto source file is being compiled. + zephyr_library_compile_definitions(BUILDING_MBEDTLS_CRYPTO) + + zephyr_library_link_libraries(mbedTLS) + + zephyr_library_link_libraries_ifdef(CONFIG_BUILD_WITH_TFM tfm_api) + + zephyr_library_named(mbedTLSX509) + + list(APPEND x509_source + ${ZEPHYR_CURRENT_MODULE_DIR}/library/x509.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/x509_create.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/x509_crl.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/x509_crt.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/x509_csr.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/x509write_crt.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/x509write_csr.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/x509write.c ) + + zephyr_library_sources(${x509_source}) + zephyr_library_link_libraries(mbedTLS) + zephyr_library() + + list(APPEND mbedtls_source + ${ZEPHYR_CURRENT_MODULE_DIR}/library/net_sockets.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_cache.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_ciphersuites.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_client.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_cookie.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_debug_helpers_generated.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_msg.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_ticket.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls12_client.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls12_server.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls13_client.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls13_generic.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls13_keys.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls13_server.c + ${ZEPHYR_CURRENT_MODULE_DIR}/library/ssl_tls.c + ) + + zephyr_library_sources(${mbedtls_source}) + + zephyr_library_link_libraries( + mbedTLSX509 + mbedTLSCrypto + mbedTLSBase + mbedTLS + ) + elseif(CONFIG_MBEDTLS_LIBRARY) # NB: CONFIG_MBEDTLS_LIBRARY is not regression tested and is # therefore susceptible to bit rot diff --git a/modules/mbedtls/Kconfig b/modules/mbedtls/Kconfig index c6111e0f7c32..ea6bfecac519 100644 --- a/modules/mbedtls/Kconfig +++ b/modules/mbedtls/Kconfig @@ -14,12 +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. -config MBEDTLS_VERSION_4_x - bool - default y - help - Hidden Kconfig symbol used internally to mark support for Mbed TLS 4.x. - rsource "Kconfig.psa.auto" rsource "Kconfig.psa.logic" diff --git a/modules/mbedtls/Kconfig.mbedtls b/modules/mbedtls/Kconfig.mbedtls index 9ed4768f3a46..c63a533d9524 100644 --- a/modules/mbedtls/Kconfig.mbedtls +++ b/modules/mbedtls/Kconfig.mbedtls @@ -21,7 +21,6 @@ config MBEDTLS_CONFIG_FILE config MBEDTLS_USER_CONFIG_FILE string "User configuration file for Mbed TLS" - default MBEDTLS_CFG_FILE if MBEDTLS_USER_CONFIG_ENABLE help If defined, this is a header which will be included after MBEDTLS_CONFIG_FILE. This allows you to modify the default configuration, @@ -97,9 +96,15 @@ comment "Supported key exchange modes" config MBEDTLS_KEY_EXCHANGE_ALL_ENABLED bool "All available ciphersuite modes" select MBEDTLS_MD_C + select MBEDTLS_RSA_C + select MBEDTLS_PKCS1_V15 + select MBEDTLS_PKCS1_V21 select MBEDTLS_X509_CRT_PARSE_C select MBEDTLS_KEY_EXCHANGE_PSK_ENABLED + select MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED select MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED + select MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + select MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED select MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED select MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED select MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED @@ -109,10 +114,18 @@ config MBEDTLS_KEY_EXCHANGE_ALL_ENABLED config MBEDTLS_KEY_EXCHANGE_PSK_ENABLED bool "PSK based ciphersuite modes" +config MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED + bool "DHE-PSK based ciphersuite modes" + config MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED bool "ECDHE-PSK based ciphersuite modes" depends on PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC +config MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED + bool "RSA-PSK based ciphersuite modes" + depends on PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC + depends on MBEDTLS_X509_CRT_PARSE_C + config MBEDTLS_PSK_MAX_LEN int "Max size of TLS pre-shared keys" default 32 @@ -120,6 +133,11 @@ config MBEDTLS_PSK_MAX_LEN Max size of TLS pre-shared keys, in bytes. It has no effect if no PSK key exchange is used. +config MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED + bool "DHE-RSA based ciphersuite modes" + depends on MBEDTLS_PKCS1_V15 || MBEDTLS_PKCS1_V21 + depends on MBEDTLS_X509_CRT_PARSE_C + config MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED bool "ECDHE-RSA based ciphersuite modes" depends on PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC @@ -128,22 +146,22 @@ config MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED config MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED bool "ECDHE-ECDSA based ciphersuite modes" - depends on PSA_WANT_ALG_ECDH && PSA_WANT_ALG_ECDSA + depends on (MBEDTLS_ECDH_C && MBEDTLS_ECDSA_C) || (PSA_WANT_ALG_ECDH && PSA_WANT_ALG_ECDSA) depends on MBEDTLS_X509_CRT_PARSE_C config MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED bool "ECDH-ECDSA based ciphersuite modes" - depends on PSA_WANT_ALG_ECDH && PSA_WANT_ALG_ECDSA + depends on (MBEDTLS_ECDH_C && MBEDTLS_ECDSA_C) || (PSA_WANT_ALG_ECDH && PSA_WANT_ALG_ECDSA) depends on MBEDTLS_X509_CRT_PARSE_C config MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED bool "ECDH-RSA based ciphersuite modes" - depends on PSA_WANT_ALG_ECDH + depends on MBEDTLS_ECDH_C depends on MBEDTLS_X509_CRT_PARSE_C config MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED bool "ECJPAKE based ciphersuite modes" - depends on PSA_WANT_ALG_JPAKE + depends on MBEDTLS_ECJPAKE_C || PSA_WANT_ALG_JPAKE if MBEDTLS_SSL_PROTO_TLS1_3 diff --git a/modules/mbedtls/Kconfig.psa.auto b/modules/mbedtls/Kconfig.psa.auto index ef6b7d363db9..c1b0c4377ba8 100644 --- a/modules/mbedtls/Kconfig.psa.auto +++ b/modules/mbedtls/Kconfig.psa.auto @@ -36,10 +36,6 @@ config PSA_WANT_ALG_CMAC bool "PSA_WANT_ALG_CMAC" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_ALG_CFB - bool "PSA_WANT_ALG_CFB" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_ALG_CHACHA20_POLY1305 bool "PSA_WANT_ALG_CHACHA20_POLY1305" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL @@ -60,10 +56,6 @@ config PSA_WANT_ALG_ECDH bool "PSA_WANT_ALG_ECDH" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_ALG_FFDH - bool "PSA_WANT_ALG_FFDH" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_ALG_ECDSA bool "PSA_WANT_ALG_ECDSA" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL @@ -79,6 +71,7 @@ config PSA_WANT_ALG_GCM config PSA_WANT_ALG_HKDF bool "PSA_WANT_ALG_HKDF" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_HMAC config PSA_WANT_ALG_HKDF_EXTRACT bool "PSA_WANT_ALG_HKDF_EXTRACT" if !MBEDTLS_PROMPTLESS @@ -95,22 +88,20 @@ config PSA_WANT_ALG_HMAC config PSA_WANT_ALG_MD5 bool "PSA_WANT_ALG_MD5" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + select NOT_SECURE + help + The MD5 hash algorithm is weak and deprecated and should not be used. -config PSA_WANT_ALG_OFB - bool "PSA_WANT_ALG_OFB" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL config PSA_WANT_ALG_PBKDF2_HMAC bool "PSA_WANT_ALG_PBKDF2_HMAC" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_HMAC config PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128 bool "PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_ALG_RIPEMD160 - bool "PSA_WANT_ALG_RIPEMD160" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_CMAC config PSA_WANT_ALG_RSA_OAEP bool "PSA_WANT_ALG_RSA_OAEP" if !MBEDTLS_PROMPTLESS @@ -131,6 +122,8 @@ config PSA_WANT_ALG_RSA_PSS config PSA_WANT_ALG_SHA_1 bool "PSA_WANT_ALG_SHA_1" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + help + The SHA-1 hash is weak and deprecated and should not be used. config PSA_WANT_ALG_SHA_224 bool "PSA_WANT_ALG_SHA_224" if !MBEDTLS_PROMPTLESS @@ -171,14 +164,17 @@ config PSA_WANT_ALG_STREAM_CIPHER config PSA_WANT_ALG_TLS12_PRF bool "PSA_WANT_ALG_TLS12_PRF" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_HMAC config PSA_WANT_ALG_TLS12_PSK_TO_MS bool "PSA_WANT_ALG_TLS12_PSK_TO_MS" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_HMAC config PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS bool "PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_SHA_256 config PSA_WANT_ALG_SHAKE128 bool "PSA_WANT_ALG_SHAKE128" if !MBEDTLS_PROMPTLESS @@ -224,26 +220,6 @@ config PSA_WANT_ECC_SECP_R1_521 bool "PSA_WANT_ECC_SECP_R1_521" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_DH_RFC7919_2048 - bool "PSA_WANT_DH_RFC7919_2048" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_DH_RFC7919_3072 - bool "PSA_WANT_DH_RFC7919_3072" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_DH_RFC7919_4096 - bool "PSA_WANT_DH_RFC7919_4096" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_DH_RFC7919_6144 - bool "PSA_WANT_DH_RFC7919_6144" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_DH_RFC7919_8192 - bool "PSA_WANT_DH_RFC7919_8192" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_KEY_TYPE_DERIVE bool "PSA_WANT_KEY_TYPE_DERIVE" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL @@ -264,26 +240,16 @@ config PSA_WANT_KEY_TYPE_AES bool "PSA_WANT_KEY_TYPE_AES" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_KEY_TYPE_ARIA - bool "PSA_WANT_KEY_TYPE_ARIA" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_KEY_TYPE_CAMELLIA - bool "PSA_WANT_KEY_TYPE_CAMELLIA" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_KEY_TYPE_CHACHA20 bool "PSA_WANT_KEY_TYPE_CHACHA20" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL + depends on PSA_WANT_ALG_CHACHA20_POLY1305 || \ + PSA_WANT_ALG_STREAM_CIPHER config PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY bool "PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY - bool "PSA_WANT_KEY_TYPE_DH_PUBLIC_KEY" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - config PSA_WANT_KEY_TYPE_RAW_DATA bool "PSA_WANT_KEY_TYPE_RAW_DATA" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL @@ -320,16 +286,4 @@ config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE bool "PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE" if !MBEDTLS_PROMPTLESS default y if PSA_CRYPTO_ENABLE_ALL -config PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT - bool "PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT - bool "PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - -config PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE - bool "PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE" if !MBEDTLS_PROMPTLESS - default y if PSA_CRYPTO_ENABLE_ALL - endif # PSA_CRYPTO_CLIENT diff --git a/modules/mbedtls/Kconfig.psa.logic b/modules/mbedtls/Kconfig.psa.logic index 972054e105b0..9c3a55ea3191 100644 --- a/modules/mbedtls/Kconfig.psa.logic +++ b/modules/mbedtls/Kconfig.psa.logic @@ -47,10 +47,3 @@ config PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC 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_BASIC - bool - default y - depends on PSA_WANT_KEY_TYPE_DH_KEY_PAIR_IMPORT || \ - PSA_WANT_KEY_TYPE_DH_KEY_PAIR_EXPORT || \ - PSA_WANT_KEY_TYPE_DH_KEY_PAIR_GENERATE diff --git a/modules/mbedtls/Kconfig.tf-psa-crypto b/modules/mbedtls/Kconfig.tf-psa-crypto index aab9c1104ee8..3fcf8c80faef 100644 --- a/modules/mbedtls/Kconfig.tf-psa-crypto +++ b/modules/mbedtls/Kconfig.tf-psa-crypto @@ -18,39 +18,162 @@ config TF_PSA_CRYPTO_USER_CONFIG_FILE config TF_PSA_CRYPTO_USER_CONFIG def_bool TF_PSA_CRYPTO_USER_CONFIG_FILE != "" +config MBEDTLS_RSA_C + bool "RSA base support" + +if MBEDTLS_RSA_C + +config MBEDTLS_PKCS1_V15 + bool "RSA PKCS1 v1.5" + +config MBEDTLS_PKCS1_V21 + bool "RSA PKCS1 v2.1" + +config MBEDTLS_GENPRIME_ENABLED + bool "Prime number generation code" + +endif # MBEDTLS_RSA_C + +config MBEDTLS_RSA_ENABLE_LEGACY_APIS + bool + imply MBEDTLS_RSA_C + imply MBEDTLS_PKCS1_V15 + default y if MBEDTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 + help + Promptless Kconfig to automatically enable legacy RSA crypto support + when RSA based ciphersuites are enabled. + This is required because TLS/X.509 code still relies on these legacy + symbols to guard parts of the code. + In theory this fix is only necessary when TF-M is enabled, because + otherwise when Mbed TLS uses its own implementation of PSA Crypto + it automatically does this internally. On the other hand it doesn't hurt to + always enable it. + This fix is very likely to be removed with Mbed TLS 4.x. + +config MBEDTLS_ECDSA_DETERMINISTIC + bool "Deterministic ECDSA (RFC 6979)" + +config MBEDTLS_HKDF_C + bool "HMAC-based Extract-and-Expand Key Derivation Function" + +comment "Elliptic curve libraries" + +config MBEDTLS_ECDH_C + bool "Elliptic curve Diffie-Hellman library" + depends on MBEDTLS_ECP_C + +config MBEDTLS_ECDSA_C + bool "Elliptic curve DSA library" + depends on MBEDTLS_ECP_C + select MBEDTLS_ASN1_PARSE_C + +config MBEDTLS_ECJPAKE_C + bool "Elliptic curve J-PAKE library" + depends on MBEDTLS_ECP_C + +config MBEDTLS_ECP_C + bool "Elliptic curve over GF(p) library" + +if MBEDTLS_ECP_C + +comment "Supported elliptic curves" + +config MBEDTLS_ECP_ALL_ENABLED + bool "All available elliptic curves" + select MBEDTLS_ECP_DP_SECP192R1_ENABLED + select MBEDTLS_ECP_DP_SECP192R1_ENABLED + select MBEDTLS_ECP_DP_SECP224R1_ENABLED + select MBEDTLS_ECP_DP_SECP256R1_ENABLED + select MBEDTLS_ECP_DP_SECP384R1_ENABLED + select MBEDTLS_ECP_DP_SECP521R1_ENABLED + select MBEDTLS_ECP_DP_SECP192K1_ENABLED + select MBEDTLS_ECP_DP_SECP224K1_ENABLED + select MBEDTLS_ECP_DP_SECP256K1_ENABLED + select MBEDTLS_ECP_DP_BP256R1_ENABLED + select MBEDTLS_ECP_DP_BP384R1_ENABLED + select MBEDTLS_ECP_DP_BP512R1_ENABLED + select MBEDTLS_ECP_DP_CURVE25519_ENABLED + select MBEDTLS_ECP_DP_CURVE448_ENABLED + select MBEDTLS_ECP_NIST_OPTIM + +config MBEDTLS_ECP_DP_SECP192R1_ENABLED + bool "SECP192R1 elliptic curve" + +config MBEDTLS_ECP_DP_SECP224R1_ENABLED + bool "SECP224R1 elliptic curve" + +config MBEDTLS_ECP_DP_SECP256R1_ENABLED + bool "SECP256R1 elliptic curve" + +config MBEDTLS_ECP_DP_SECP384R1_ENABLED + bool "SECP384R1 elliptic curve" + +config MBEDTLS_ECP_DP_SECP521R1_ENABLED + bool "SECP521R1 elliptic curve" + +config MBEDTLS_ECP_DP_SECP192K1_ENABLED + bool "SECP192K1 elliptic curve" + +config MBEDTLS_ECP_DP_SECP224K1_ENABLED + bool "SECP224K1 elliptic curve" + +config MBEDTLS_ECP_DP_SECP256K1_ENABLED + bool "SECP256K1 elliptic curve" + +config MBEDTLS_ECP_DP_BP256R1_ENABLED + bool "BP256R1 elliptic curve" + +config MBEDTLS_ECP_DP_BP384R1_ENABLED + bool "BP384R1 elliptic curve" + +config MBEDTLS_ECP_DP_BP512R1_ENABLED + bool "BP512R1 elliptic curve" + +config MBEDTLS_ECP_DP_CURVE25519_ENABLED + bool "CURVE25519 elliptic curve" + +config MBEDTLS_ECP_DP_CURVE448_ENABLED + bool "CURVE448 elliptic curve" + config MBEDTLS_ECP_NIST_OPTIM bool "NIST curves optimization" - depends on PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC + +endif comment "Supported ciphers and cipher modes" config MBEDTLS_CIPHER_ALL_ENABLED bool "All available ciphers and modes" - select PSA_WANT_KEY_TYPE_AES - select PSA_WANT_KEY_TYPE_CAMELLIA - select PSA_WANT_KEY_TYPE_CHACHA20 - select PSA_WANT_ALG_GCM - select PSA_WANT_ALG_CCM - select PSA_WANT_ALG_CBC_NO_PADDING - select PSA_WANT_ALG_CBC_PKCS7 - select PSA_WANT_ALG_CTR - select PSA_WANT_ALG_CHACHA20_POLY1305 + select MBEDTLS_CIPHER_AES_ENABLED + select MBEDTLS_CIPHER_CAMELLIA_ENABLED + select MBEDTLS_CIPHER_DES_ENABLED + select MBEDTLS_CIPHER_CHACHA20_ENABLED + select MBEDTLS_CIPHER_CCM_ENABLED + select MBEDTLS_CIPHER_GCM_ENABLED + select MBEDTLS_CIPHER_MODE_XTS_ENABLED + select MBEDTLS_CIPHER_MODE_CBC_ENABLED + select MBEDTLS_CIPHER_MODE_CTR_ENABLED + select MBEDTLS_CHACHAPOLY_AEAD_ENABLED config MBEDTLS_SOME_AEAD_CIPHER_ENABLED bool default y depends on \ - PSA_WANT_KEY_TYPE_AES || \ - PSA_WANT_KEY_TYPE_CAMELLIA + MBEDTLS_CIPHER_AES_ENABLED || \ + MBEDTLS_CIPHER_CAMELLIA_ENABLED config MBEDTLS_SOME_CIPHER_ENABLED bool default y depends on \ MBEDTLS_SOME_AEAD_CIPHER_ENABLED || \ - PSA_WANT_KEY_TYPE_CHACHA20 + MBEDTLS_CIPHER_DES_ENABLED || \ + MBEDTLS_CIPHER_CHACHA20_ENABLED -if PSA_WANT_KEY_TYPE_AES +config MBEDTLS_CIPHER_AES_ENABLED + bool "AES block cipher" + +if MBEDTLS_CIPHER_AES_ENABLED config MBEDTLS_AES_ROM_TABLES bool "Use precomputed AES tables stored in ROM" @@ -65,31 +188,95 @@ config MBEDTLS_AES_FEWER_TABLES lookups are converted to 1 table lookup, 3 additions and 6 bit shifts. -endif # PSA_WANT_KEY_TYPE_AES +config MBEDTLS_CIPHER_MODE_XTS_ENABLED + bool "Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES" + +endif # MBEDTLS_CIPHER_AES_ENABLED + +config MBEDTLS_CIPHER_CAMELLIA_ENABLED + bool "Camellia block cipher" + +config MBEDTLS_CIPHER_DES_ENABLED + bool "DES block cipher" + +config MBEDTLS_CIPHER_CHACHA20_ENABLED + bool "ChaCha20 stream cipher" + +if MBEDTLS_SOME_AEAD_CIPHER_ENABLED + +config MBEDTLS_CIPHER_CCM_ENABLED + bool "Counter with CBC-MAC (CCM) mode for 128-bit block cipher" + +config MBEDTLS_CIPHER_GCM_ENABLED + bool "Galois/Counter Mode (GCM) for symmetric ciphers" + +endif # MBEDTLS_SOME_AEAD_CIPHER_ENABLED + +if MBEDTLS_SOME_CIPHER_ENABLED + +config MBEDTLS_CIPHER_MODE_CBC_ENABLED + bool "Cipher Block Chaining mode (CBC) for symmetric ciphers" + +config MBEDTLS_CIPHER_MODE_CTR_ENABLED + bool "Counter Block Cipher mode (CTR) for symmetric ciphers" + +endif # MBEDTLS_SOME_CIPHER_ENABLED + +config MBEDTLS_CHACHAPOLY_AEAD_ENABLED + bool "ChaCha20-Poly1305 AEAD algorithm" + depends on MBEDTLS_CIPHER_CHACHA20_ENABLED && MBEDTLS_POLY1305 + +config MBEDTLS_CMAC + bool "CMAC (Cipher-based Message Authentication Code) mode for block ciphers" + depends on MBEDTLS_CIPHER_AES_ENABLED || MBEDTLS_CIPHER_DES_ENABLED comment "Supported hash algorithms" config MBEDTLS_HASH_ALL_ENABLED bool "All available MAC methods" - select PSA_WANT_ALG_MD5 - select PSA_WANT_ALG_SHA_1 - select PSA_WANT_ALG_SHA_224 - select PSA_WANT_ALG_SHA_256 - select PSA_WANT_ALG_SHA_384 - select PSA_WANT_ALG_SHA_512 + select MBEDTLS_MD5 + select MBEDTLS_SHA1 + select MBEDTLS_SHA224 + select MBEDTLS_SHA256 + select MBEDTLS_SHA384 + select MBEDTLS_SHA512 + select MBEDTLS_POLY1305 + +config MBEDTLS_MD5 + bool "MD5 hash algorithm" + +config MBEDTLS_SHA1 + bool "SHA-1 hash algorithm" + +config MBEDTLS_SHA224 + bool "SHA-224 hash algorithm" + +config MBEDTLS_SHA256 + bool "SHA-256 hash algorithm" config MBEDTLS_SHA256_SMALLER bool "Smaller SHA-256 implementation" - depends on PSA_WANT_ALG_SHA_256 + depends on MBEDTLS_SHA256 default y help Enable an implementation of SHA-256 that has a smaller ROM footprint but also lower performance. +config MBEDTLS_SHA384 + bool "SHA-384 hash algorithm" + +config MBEDTLS_SHA512 + bool "SHA-512 hash algorithm" + +config MBEDTLS_POLY1305 + bool "Poly1305 hash family" + comment "Random number generators" config MBEDTLS_CTR_DRBG_C bool "CTR_DRBG AES-256-based random generator" + depends on MBEDTLS_CIPHER_AES_ENABLED + default y config MBEDTLS_HMAC_DRBG_C bool "HMAC_DRBG random generator" @@ -169,14 +356,13 @@ config MBEDTLS_HAVE_ASM config MBEDTLS_ENTROPY_C bool "Mbed TLS entropy accumulator" - select PSA_WANT_ALG_SHA_256 if !PSA_WANT_ALG_SHA_512 + select MBEDTLS_SHA256 if !(MBEDTLS_SHA384 || MBEDTLS_SHA512) help This module gathers entropy data from enabled entropy sources. It's mostly used in conjunction with CTR_DRBG or HMAC_DRBG to create a deterministic random number generator. - It requires either PSA_WANT_ALG_SHA_256 or PSA_WANT_ALG_SHA_512. -config MBEDTLS_PSA_DRIVER_GET_ENTROPY +config MBEDTLS_ENTROPY_POLL_ZEPHYR bool "Provide entropy data to Mbed TLS through entropy driver or random generator" default y depends on MBEDTLS_ENTROPY_C @@ -226,7 +412,8 @@ config MBEDTLS_PKCS5_C choice MBEDTLS_PSA_CRYPTO_RNG_SOURCE prompt "PSA crypto random source" depends on MBEDTLS_PSA_CRYPTO_C - default MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG if CSPRNG_ENABLED && !ENTROPY_NEEDS_PRNG + default MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG if CSPRNG_ENABLED \ + || !PSA_CRYPTO_PROVIDER_MBEDTLS default MBEDTLS_PSA_CRYPTO_LEGACY_RNG config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG @@ -245,9 +432,10 @@ config MBEDTLS_PSA_CRYPTO_LEGACY_RNG bool "Mbed TLS legacy modules (ENTROPY + [CTR|HMAC]_DRBG)" select MBEDTLS_ENTROPY_C select MBEDTLS_HMAC_DRBG_C if !MBEDTLS_CTR_DRBG_C - # Enable test random generator only if there really is no entropy driver - # that can be used to gather data. - select TEST_RANDOM_GENERATOR if !ENTROPY_HAS_DRIVER + # If there is any entropy driver in the system, then the choice would be + # CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG. If we fall here, then the only + # way to get some random data is to enable CONFIG_TEST_RANDOM_GENERATOR. + select TEST_RANDOM_GENERATOR help Use legacy Mbed TLS modules to generate random data. In this configuration the entropy module is used to gather some data and then @@ -280,7 +468,14 @@ config MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG_ALLOW_NON_CSPRNG config MBEDTLS_PSA_CRYPTO_C bool "Platform Security Architecture cryptography API" depends on !BUILD_WITH_TFM - select CSPRNG_NEEDED + select CSPRNG_NEEDED if PSA_CRYPTO_PROVIDER_MBEDTLS + +config MBEDTLS_USE_PSA_CRYPTO + bool "Use PSA APIs instead of legacy MbedTLS when possible" + default y if MBEDTLS_PSA_CRYPTO_CLIENT + help + Use PSA APIs instead of legacy MbedTLS functions in TLS/DTLS and other + "intermediate" modules such as PK, MD and Cipher. config MBEDTLS_PSA_CRYPTO_CLIENT bool @@ -291,6 +486,7 @@ config MBEDTLS_PSA_CRYPTO_CLIENT config MBEDTLS_LMS_C bool "Support LMS signature schemes" depends on MBEDTLS_PSA_CRYPTO_CLIENT + depends on MBEDTLS_SHA256 select PSA_WANT_ALG_SHA_256 if MBEDTLS_PSA_CRYPTO_C @@ -353,11 +549,17 @@ endif # MBEDTLS_PSA_CRYPTO_C config MBEDTLS_NIST_KW_C bool "NIST key wrap" - depends on PSA_WANT_KEY_TYPE_AES + depends on MBEDTLS_CIPHER_AES_ENABLED help Key Wrapping mode for 128-bit block ciphers, as defined in NIST SP 800-38F. +config MBEDTLS_DHM_C + bool "Diffie-Hellman-Merkle mode" + help + Used by the following key exchanges, + DHE-RSA, DHE-PSK + config MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS bool "Legacy crypto support (private)" help diff --git a/modules/mbedtls/configs/config-mbedtls.h b/modules/mbedtls/configs/config-mbedtls.h index 226c370efc6c..cc9884b0da81 100644 --- a/modules/mbedtls/configs/config-mbedtls.h +++ b/modules/mbedtls/configs/config-mbedtls.h @@ -11,10 +11,14 @@ #ifndef MBEDTLS_CONFIG_H #define MBEDTLS_CONFIG_H +#include CONFIG_TF_PSA_CRYPTO_CONFIG_FILE + #if defined(CONFIG_MBEDTLS_USER_CONFIG) #define MBEDTLS_USER_CONFIG_FILE CONFIG_MBEDTLS_USER_CONFIG_FILE #endif +/* System support */ + #if defined(CONFIG_MBEDTLS_VERSION_C) #define MBEDTLS_VERSION_C #endif @@ -70,14 +74,26 @@ #define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED #endif +#if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) +#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED +#endif + #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) #define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED #endif +#if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) +#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED +#endif + #if defined(CONFIG_MBEDTLS_PSK_MAX_LEN) #define MBEDTLS_PSK_MAX_LEN CONFIG_MBEDTLS_PSK_MAX_LEN #endif +#if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) +#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED +#endif + #if defined(CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED #endif diff --git a/modules/mbedtls/configs/config-tf-psa-crypto.h b/modules/mbedtls/configs/config-tf-psa-crypto.h index 8f423a301448..542ebb8d2c29 100644 --- a/modules/mbedtls/configs/config-tf-psa-crypto.h +++ b/modules/mbedtls/configs/config-tf-psa-crypto.h @@ -25,6 +25,7 @@ #define MBEDTLS_MEMORY_BUFFER_ALLOC_C #define MBEDTLS_MEMORY_ALIGN_MULTIPLE (sizeof(void *)) #define MBEDTLS_PLATFORM_EXIT_ALT +#define MBEDTLS_NO_PLATFORM_ENTROPY #if defined(CONFIG_MBEDTLS_ZEROIZE_ALT) #define MBEDTLS_PLATFORM_ZEROIZE_ALT @@ -38,8 +39,10 @@ #define MBEDTLS_PLATFORM_SNPRINTF_ALT #endif /* defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) */ -#if defined(CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY) -#define MBEDTLS_PSA_DRIVER_GET_ENTROPY +#if defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR) +#define MBEDTLS_ENTROPY_HARDWARE_ALT +#else +#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES #endif #if defined(CONFIG_MBEDTLS_HAVE_ASM) @@ -56,6 +59,20 @@ #define MBEDTLS_PLATFORM_MS_TIME_ALT #endif +#if defined(CONFIG_MBEDTLS_ECDSA_DETERMINISTIC) +#define MBEDTLS_ECDSA_DETERMINISTIC +#endif + +#if defined(CONFIG_MBEDTLS_HKDF_C) +#define MBEDTLS_HKDF_C +#endif + +/* Supported cipher modes */ + +#if defined(CONFIG_MBEDTLS_CIPHER_AES_ENABLED) +#define MBEDTLS_AES_C +#endif + #if defined(CONFIG_MBEDTLS_AES_ROM_TABLES) #define MBEDTLS_AES_ROM_TABLES #endif @@ -64,14 +81,152 @@ #define MBEDTLS_AES_FEWER_TABLES #endif +#if defined(CONFIG_MBEDTLS_CIPHER_CAMELLIA_ENABLED) +#define MBEDTLS_CAMELLIA_C +#endif + +#if defined(CONFIG_MBEDTLS_CIPHER_DES_ENABLED) +#define MBEDTLS_DES_C +#endif + +#if defined(CONFIG_MBEDTLS_CIPHER_CHACHA20_ENABLED) +#define MBEDTLS_CHACHA20_C +#endif + +#if defined(CONFIG_MBEDTLS_CIPHER_CCM_ENABLED) +#define MBEDTLS_CCM_C +#endif + +#if defined(CONFIG_MBEDTLS_CIPHER_GCM_ENABLED) +#define MBEDTLS_GCM_C +#endif + +#if defined(CONFIG_MBEDTLS_CIPHER_MODE_XTS_ENABLED) +#define MBEDTLS_CIPHER_MODE_XTS +#endif + +#if defined(CONFIG_MBEDTLS_CIPHER_MODE_CBC_ENABLED) +#define MBEDTLS_CIPHER_MODE_CBC +#endif + +#if defined(CONFIG_MBEDTLS_CIPHER_MODE_CTR_ENABLED) +#define MBEDTLS_CIPHER_MODE_CTR +#endif + +/* Supported elliptic curve libraries */ + +#if defined(CONFIG_MBEDTLS_ECDH_C) +#define MBEDTLS_ECDH_C +#endif + +#if defined(CONFIG_MBEDTLS_ECDSA_C) +#define MBEDTLS_ECDSA_C +#endif + +#if defined(CONFIG_MBEDTLS_ECJPAKE_C) +#define MBEDTLS_ECJPAKE_C +#endif + +#if defined(CONFIG_MBEDTLS_ECP_C) +#define MBEDTLS_ECP_C +#endif + +/* Supported elliptic curves */ + +#if defined(CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED) +#define MBEDTLS_ECP_DP_SECP192R1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED) +#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED) +#define MBEDTLS_ECP_DP_SECP256R1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED) +#define MBEDTLS_ECP_DP_SECP384R1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED) +#define MBEDTLS_ECP_DP_SECP521R1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED) +#define MBEDTLS_ECP_DP_SECP192K1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED) +#define MBEDTLS_ECP_DP_SECP224K1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED) +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED) +#define MBEDTLS_ECP_DP_BP256R1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED) +#define MBEDTLS_ECP_DP_BP384R1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED) +#define MBEDTLS_ECP_DP_BP512R1_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED) +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED +#endif + +#if defined(CONFIG_MBEDTLS_ECP_DP_CURVE448_ENABLED) +#define MBEDTLS_ECP_DP_CURVE448_ENABLED +#endif + #if defined(CONFIG_MBEDTLS_ECP_NIST_OPTIM) #define MBEDTLS_ECP_NIST_OPTIM #endif +/* Supported hash algorithms */ + +#if defined(CONFIG_MBEDTLS_MD5) +#define MBEDTLS_MD5_C +#endif + +#if defined(CONFIG_MBEDTLS_SHA1) +#define MBEDTLS_SHA1_C +#endif + +#if defined(CONFIG_MBEDTLS_SHA224) +#define MBEDTLS_SHA224_C +#endif + +#if defined(CONFIG_MBEDTLS_SHA256) +#define MBEDTLS_SHA256_C +#endif + #if defined(CONFIG_MBEDTLS_SHA256_SMALLER) #define MBEDTLS_SHA256_SMALLER #endif +#if defined(CONFIG_MBEDTLS_SHA384) +#define MBEDTLS_SHA384_C +#endif + +#if defined(CONFIG_MBEDTLS_SHA512) +#define MBEDTLS_SHA512_C +#endif + +#if defined(CONFIG_MBEDTLS_POLY1305) +#define MBEDTLS_POLY1305_C +#endif + +#if defined(CONFIG_MBEDTLS_CMAC) +#define MBEDTLS_CMAC_C +#endif + #if defined(CONFIG_MBEDTLS_CTR_DRBG_C) #define MBEDTLS_CTR_DRBG_C #endif @@ -84,10 +239,43 @@ #define MBEDTLS_MEMORY_DEBUG #endif +#if defined(CONFIG_MBEDTLS_CHACHAPOLY_AEAD_ENABLED) +#define MBEDTLS_CHACHAPOLY_C +#endif + +#if defined(CONFIG_MBEDTLS_GENPRIME_ENABLED) +#define MBEDTLS_GENPRIME +#endif + +#if defined(CONFIG_MBEDTLS_ENTROPY_C) +#define MBEDTLS_ENTROPY_C +#endif + +#if defined(CONFIG_MBEDTLS_CIPHER) +#define MBEDTLS_CIPHER_C +#endif + #if defined(CONFIG_MBEDTLS_MD_C) #define MBEDTLS_MD_C #endif +#if defined(CONFIG_MBEDTLS_RSA_C) +#define MBEDTLS_RSA_C +#endif + +#if defined(CONFIG_MBEDTLS_PKCS1_V15) +#define MBEDTLS_PKCS1_V15 +#endif + +#if defined(CONFIG_MBEDTLS_PKCS1_V21) +#define MBEDTLS_PKCS1_V21 +#endif + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) +#define MBEDTLS_DHM_C +#endif + #if defined(CONFIG_MBEDTLS_BASE64_C) #define MBEDTLS_BASE64_C #endif @@ -100,6 +288,19 @@ #define MBEDTLS_PEM_WRITE_C #endif +#if defined(MBEDTLS_DHM_C) || \ + defined(MBEDTLS_ECP_C) || \ + defined(MBEDTLS_RSA_C) || \ + defined(MBEDTLS_X509_USE_C) || \ + defined(MBEDTLS_GENPRIME) +#define MBEDTLS_BIGNUM_C +#endif + +#if defined(CONFIG_MBEDTLS_RSA_C) || \ + defined(CONFIG_MBEDTLS_X509_USE_C) +#define MBEDTLS_OID_C +#endif + #if defined(CONFIG_MBEDTLS_PK_PARSE_C) #define MBEDTLS_PK_PARSE_C #endif @@ -129,6 +330,7 @@ #define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */ #define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */ #define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */ +#define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */ #endif #if defined(CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) @@ -156,18 +358,28 @@ #define MBEDTLS_PSA_KEY_SLOT_COUNT CONFIG_MBEDTLS_PSA_KEY_SLOT_COUNT #endif +#if defined(CONFIG_MBEDTLS_USE_PSA_CRYPTO) +#define MBEDTLS_USE_PSA_CRYPTO +#endif + #if defined(CONFIG_MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS) #define MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS #endif #if defined(CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT) #define MBEDTLS_PSA_CRYPTO_CLIENT +#define MBEDTLS_PSA_CRYPTO_CONFIG +#define MBEDTLS_PSA_CRYPTO_CONFIG_FILE "config-psa.h" #endif #if defined(CONFIG_MBEDTLS_NIST_KW_C) #define MBEDTLS_NIST_KW_C #endif +#if defined(CONFIG_MBEDTLS_DHM_C) +#define MBEDTLS_DHM_C +#endif + #if defined(CONFIG_MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS) #define MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS #endif diff --git a/modules/mbedtls/zephyr_entropy.c b/modules/mbedtls/zephyr_entropy.c index 44d6a9687a2a..9adc308bae5e 100644 --- a/modules/mbedtls/zephyr_entropy.c +++ b/modules/mbedtls/zephyr_entropy.c @@ -4,56 +4,55 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include #include +#include #include -#include -#if defined(CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY) || \ - defined(CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) - +#if defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR) || defined(CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) static int get_random_data(uint8_t *output, size_t output_size, bool allow_non_cs) { - int ret = -EINVAL; - -#if defined(CONFIG_ENTROPY_HAS_DRIVER) - static const struct device *const entropy_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy)); + int ret = MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED; - if (!device_is_ready(entropy_dev)) { - return -ENODEV; +#if defined(CONFIG_CSPRNG_ENABLED) + ret = sys_csrand_get(output, output_size); + if (ret == 0) { + return 0; } +#endif /* CONFIG_CSPRNG_ENABLED */ - ret = entropy_get_entropy(entropy_dev, output, output_size); -#endif /* CONFIG_ENTROPY_HAS_DRIVER */ - if (ret < 0) { - if (allow_non_cs) { - sys_rand_get(output, output_size); - ret = 0; - } + if (allow_non_cs) { + sys_rand_get(output, output_size); + ret = 0; } return ret; } +#endif /* CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR || CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */ -#endif /* CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY || CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */ - -#if defined(CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY) -int mbedtls_platform_get_entropy(psa_driver_get_entropy_flags_t flags, - size_t *estimate_bits, - unsigned char *output, size_t output_size) +#if defined(CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR) +int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, + size_t *olen) { - ARG_UNUSED(flags); + int ret; + uint16_t request_len = len > UINT16_MAX ? UINT16_MAX : len; - if (get_random_data(output, output_size, true) < 0) { - return -EIO; + ARG_UNUSED(data); + + if (output == NULL || olen == NULL || len == 0) { + return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; + } + + ret = get_random_data(output, len, true); + if (ret < 0) { + return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; } - *estimate_bits = 8 * output_size; + *olen = request_len; return 0; } -#endif /* CONFIG_MBEDTLS_PSA_DRIVER_GET_ENTROPY */ +#endif /* CONFIG_MBEDTLS_ENTROPY_POLL_ZEPHYR */ #if defined(CONFIG_MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG) psa_status_t mbedtls_psa_external_get_random( diff --git a/modules/mbedtls/zephyr_init.c b/modules/mbedtls/zephyr_init.c index a4abcd7969dd..9da886d155a3 100644 --- a/modules/mbedtls/zephyr_init.c +++ b/modules/mbedtls/zephyr_init.c @@ -12,10 +12,8 @@ */ #include -#include #include #include -#include #include diff --git a/modules/trusted-firmware-m/CMakeLists.txt b/modules/trusted-firmware-m/CMakeLists.txt index c7fe3b0b67d2..70266b2794d2 100644 --- a/modules/trusted-firmware-m/CMakeLists.txt +++ b/modules/trusted-firmware-m/CMakeLists.txt @@ -3,19 +3,30 @@ # # SPDX-License-Identifier: Apache-2.0 -# List of all partitions supported by TF-M -# Name must match name in 'trusted-firmware-m/tools/tfm_manifest_list.yaml' -set(TFM_VALID_PARTITIONS - TFM_PARTITION_NS_AGENT_MAILBOX - TFM_PARTITION_PROTECTED_STORAGE - TFM_PARTITION_INTERNAL_TRUSTED_STORAGE - TFM_PARTITION_CRYPTO - TFM_PARTITION_PLATFORM - TFM_PARTITION_INITIAL_ATTESTATION - TFM_PARTITION_FIRMWARE_UPDATE - ) - if(CONFIG_BUILD_WITH_TFM) + + macro(kconfig_bool_to_tfm kconfig_option tfm_option) + if(${kconfig_option}) + set(value ON) + else() + set(value OFF) + endif() + list(APPEND TFM_CMAKE_ARGS -D${tfm_option}=${value}) + endmacro() + + kconfig_bool_to_tfm(CONFIG_TFM_PARTITION_PROTECTED_STORAGE + TFM_PARTITION_PROTECTED_STORAGE) + kconfig_bool_to_tfm(CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE + TFM_PARTITION_INTERNAL_TRUSTED_STORAGE) + kconfig_bool_to_tfm(CONFIG_TFM_PARTITION_CRYPTO + TFM_PARTITION_CRYPTO) + kconfig_bool_to_tfm(CONFIG_TFM_PARTITION_PLATFORM + TFM_PARTITION_PLATFORM) + kconfig_bool_to_tfm(CONFIG_TFM_PARTITION_INITIAL_ATTESTATION + TFM_PARTITION_INITIAL_ATTESTATION) + kconfig_bool_to_tfm(CONFIG_TFM_PARTITION_FIRMWARE_UPDATE + TFM_PARTITION_FIRMWARE_UPDATE) + # PSA API awareness for the Non-Secure application target_compile_definitions(app PRIVATE "TFM_PSA_API") @@ -36,14 +47,6 @@ if(CONFIG_BUILD_WITH_TFM) else() # CONFIG_TFM_IPC list(APPEND TFM_CMAKE_ARGS -DCONFIG_TFM_SPM_BACKEND="IPC") endif() - if(CONFIG_TFM_REGRESSION_S) - list(APPEND TFM_CMAKE_ARGS -DTEST_S=ON) - list(APPEND TFM_CMAKE_ARGS -DTFM_S_REG_TEST:BOOL=ON) - endif() - if(CONFIG_TFM_REGRESSION_NS) - list(APPEND TFM_CMAKE_ARGS -DTEST_NS=ON) - list(APPEND TFM_CMAKE_ARGS -DTFM_NS_REG_TEST:BOOL=ON) - endif() if(CONFIG_TFM_BL2) list(APPEND TFM_CMAKE_ARGS -DBL2=TRUE) list(APPEND TFM_CMAKE_ARGS -DMCUBOOT_IMAGE_VERSION_S=${CONFIG_TFM_IMAGE_VERSION_S}) @@ -97,17 +100,11 @@ if(CONFIG_BUILD_WITH_TFM) list(APPEND TFM_CMAKE_ARGS -DMCUBOOT_IMAGE_NUMBER=${CONFIG_TFM_MCUBOOT_IMAGE_NUMBER}) endif() - if(CONFIG_TFM_DUMMY_PROVISIONING) - list(APPEND TFM_CMAKE_ARGS -DTFM_DUMMY_PROVISIONING=ON) - else() - list(APPEND TFM_CMAKE_ARGS -DTFM_DUMMY_PROVISIONING=OFF) - endif() + kconfig_bool_to_tfm(CONFIG_TFM_DUMMY_PROVISIONING TFM_DUMMY_PROVISIONING) - if(CONFIG_TFM_EXCEPTION_INFO_DUMP) - list(APPEND TFM_CMAKE_ARGS -DTFM_EXCEPTION_INFO_DUMP=ON) - else() - list(APPEND TFM_CMAKE_ARGS -DTFM_EXCEPTION_INFO_DUMP=OFF) - endif() + kconfig_bool_to_tfm(CONFIG_TFM_EXCEPTION_INFO_DUMP TFM_EXCEPTION_INFO_DUMP) + + kconfig_bool_to_tfm(CONFIG_TFM_PS_ROLLBACK_PROTECTION PS_ROLLBACK_PROTECTION) if(CONFIG_TFM_BL2) if(CONFIG_TFM_BL2_LOG_LEVEL_DEBUG) @@ -162,17 +159,6 @@ if(CONFIG_BUILD_WITH_TFM) list(APPEND TFM_CMAKE_ARGS -DSECURE_UART1=0) endif() - # Enable TFM partitions as specified in Kconfig - foreach(partition ${TFM_VALID_PARTITIONS}) - if(CONFIG_${partition}) - # list(APPEND TFM_ENABLED_PARTITIONS_ARG ${partition}) - set(val "ON") - else() - set(val "OFF") - endif() - list(APPEND TFM_CMAKE_ARGS -D${partition}=${val}) - endforeach() - set(TFM_BINARY_DIR ${CMAKE_BINARY_DIR}/tfm) set(TFM_INTERFACE_SOURCE_DIR ${TFM_BINARY_DIR}/api_ns/interface/src) @@ -386,53 +372,51 @@ if(CONFIG_BUILD_WITH_TFM) TFM_S_NS_SIGNED_BIN_FILE ${TFM_S_NS_SIGNED_BIN_FILE} # Merged TFM Secure/Nonsecure FW (signed) ) - if(NOT CONFIG_TFM_USE_NS_APP) - zephyr_library_named(tfm_api) + zephyr_library_named(tfm_api) - zephyr_library_sources( - src/zephyr_tfm_log.c - interface/interface.c - ) + zephyr_library_sources( + src/zephyr_tfm_log.c + interface/interface.c + ) - # A dependency on tfm_s.hex for zephyr.elf will not cause a Zephyr re-link when - # tfm_s.hex is updated, as the hex is not a direct input on the executable. - # Instead we establish a source file dependency which ensures that tfm_api is - # updated when there are changes in tfm itself, this again will trigger an re-link - # of Zephyr.elf. - set_property(SOURCE interface/interface.c APPEND PROPERTY OBJECT_DEPENDS ${TFM_S_HEX_FILE}) + # A dependency on tfm_s.hex for zephyr.elf will not cause a Zephyr re-link when + # tfm_s.hex is updated, as the hex is not a direct input on the executable. + # Instead we establish a source file dependency which ensures that tfm_api is + # updated when there are changes in tfm itself, this again will trigger an re-link + # of Zephyr.elf. + set_property(SOURCE interface/interface.c APPEND PROPERTY OBJECT_DEPENDS ${TFM_S_HEX_FILE}) - # Non-Secure interface to request system reboot - if(CONFIG_TFM_PARTITION_PLATFORM AND NOT CONFIG_TFM_PARTITION_PLATFORM_CUSTOM_REBOOT) - zephyr_library_sources(src/reboot.c) - endif() + # Non-Secure interface to request system reboot + if(CONFIG_TFM_PARTITION_PLATFORM AND NOT CONFIG_TFM_PARTITION_PLATFORM_CUSTOM_REBOOT) + zephyr_library_sources(src/reboot.c) + endif() - zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_PLATFORM ${TFM_INTERFACE_SOURCE_DIR}/tfm_platform_api.c) - zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_PROTECTED_STORAGE ${TFM_INTERFACE_SOURCE_DIR}/tfm_ps_api.c) - zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ${TFM_INTERFACE_SOURCE_DIR}/tfm_its_api.c) - zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_CRYPTO ${TFM_INTERFACE_SOURCE_DIR}/tfm_crypto_api.c) - zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_INITIAL_ATTESTATION ${TFM_INTERFACE_SOURCE_DIR}/tfm_attest_api.c) - zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_FIRMWARE_UPDATE ${TFM_INTERFACE_SOURCE_DIR}/tfm_fwu_api.c) + zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_PLATFORM ${TFM_INTERFACE_SOURCE_DIR}/tfm_platform_api.c) + zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_PROTECTED_STORAGE ${TFM_INTERFACE_SOURCE_DIR}/tfm_ps_api.c) + zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ${TFM_INTERFACE_SOURCE_DIR}/tfm_its_api.c) + zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_CRYPTO ${TFM_INTERFACE_SOURCE_DIR}/tfm_crypto_api.c) + zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_INITIAL_ATTESTATION ${TFM_INTERFACE_SOURCE_DIR}/tfm_attest_api.c) + zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_FIRMWARE_UPDATE ${TFM_INTERFACE_SOURCE_DIR}/tfm_fwu_api.c) - zephyr_library_sources(${TFM_INTERFACE_SOURCE_DIR}/tfm_tz_psa_ns_api.c) + zephyr_library_sources(${TFM_INTERFACE_SOURCE_DIR}/tfm_tz_psa_ns_api.c) - if(CONFIG_SOC_FAMILY_NORDIC_NRF) - zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_PLATFORM ${TFM_INTERFACE_SOURCE_DIR}/tfm_ioctl_core_ns_api.c) - endif() + if(CONFIG_SOC_FAMILY_NORDIC_NRF) + zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_PLATFORM ${TFM_INTERFACE_SOURCE_DIR}/tfm_ioctl_core_ns_api.c) + endif() - # TFM_INTERFACE_INCLUDE_DIR is already added to zephyr_interface below - zephyr_library_include_directories( - ${TFM_INTERFACE_INCLUDE_DIR}/crypto_keys - ) + # TFM_INTERFACE_INCLUDE_DIR is already added to zephyr_interface below + zephyr_library_include_directories( + ${TFM_INTERFACE_INCLUDE_DIR}/crypto_keys + ) - # Add interface include directory (exported by TF-M) to zephyr_interface - zephyr_include_directories( - ${TFM_INTERFACE_INCLUDE_DIR} - ) + # Add interface include directory (exported by TF-M) to zephyr_interface + zephyr_include_directories( + ${TFM_INTERFACE_INCLUDE_DIR} + ) - zephyr_library_link_libraries( - ${TFM_INTERFACE_LIB_DIR}/s_veneers.o - ) - endif(NOT CONFIG_TFM_USE_NS_APP) + zephyr_library_link_libraries( + ${TFM_INTERFACE_LIB_DIR}/s_veneers.o + ) # Ensure that the generated syscall include headers of Zephyr are available to TF-M # because some platforms might use the same source files for both builds. diff --git a/modules/trusted-firmware-m/Kconfig b/modules/trusted-firmware-m/Kconfig index 06835cfc0759..4392a3c9523e 100644 --- a/modules/trusted-firmware-m/Kconfig +++ b/modules/trusted-firmware-m/Kconfig @@ -5,5 +5,9 @@ # SPDX-License-Identifier: Apache-2.0 rsource "Kconfig.tfm" + +if BUILD_WITH_TFM rsource "Kconfig.tfm.partitions" -rsource "Kconfig.tfm.crypto_modules" +rsource "Kconfig.tfm.crypto" +rsource "Kconfig.tfm.ps" +endif diff --git a/modules/trusted-firmware-m/Kconfig.tfm b/modules/trusted-firmware-m/Kconfig.tfm index 5ad74fba22be..83a5067be440 100644 --- a/modules/trusted-firmware-m/Kconfig.tfm +++ b/modules/trusted-firmware-m/Kconfig.tfm @@ -52,7 +52,7 @@ menuconfig BUILD_WITH_TFM select PSA_CRYPTO_CLIENT imply INIT_ARCH_HW_AT_BOOT imply ARM_NONSECURE_PREEMPTIBLE_SECURE_CALLS - imply MBEDTLS if !TFM_USE_NS_APP + imply MBEDTLS help When enabled, this option instructs the Zephyr build process to additionally generate a TF-M image for the Secure Execution @@ -388,21 +388,6 @@ config TFM_SFN endchoice # TFM_MODEL -config TFM_REGRESSION_S - bool "TF-M Secure Regression tests" - help - When enabled, this option signifies that the TF-M build includes - the Secure domain regression tests. - The regression tests will be included in the TF-M secure firmware. - -config TFM_REGRESSION_NS - bool "TF-M Non-Secure Regression tests" - help - When enabled, this option signifies that the TF-M build includes - the Non-Secure domain regression tests. - The regression tests will be included in the TF-M non-secure - application. - choice TFM_PSA_TEST prompt "Enable a PSA test suite" default TFM_PSA_TEST_NONE diff --git a/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules b/modules/trusted-firmware-m/Kconfig.tfm.crypto similarity index 80% rename from modules/trusted-firmware-m/Kconfig.tfm.crypto_modules rename to modules/trusted-firmware-m/Kconfig.tfm.crypto index 1d70a2c44d29..e19b53559a8a 100644 --- a/modules/trusted-firmware-m/Kconfig.tfm.crypto_modules +++ b/modules/trusted-firmware-m/Kconfig.tfm.crypto @@ -3,13 +3,12 @@ # Copyright (c) 2021 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -if BUILD_WITH_TFM - 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 +16,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 +25,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 +34,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 +43,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 +52,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 +61,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 +70,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,11 +79,11 @@ 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. endif # TFM_PARTITION_CRYPTO - -endif # BUILD_WITH_TFM diff --git a/modules/trusted-firmware-m/Kconfig.tfm.partitions b/modules/trusted-firmware-m/Kconfig.tfm.partitions index d16ba86d8c21..eb4f8ee1d8ae 100644 --- a/modules/trusted-firmware-m/Kconfig.tfm.partitions +++ b/modules/trusted-firmware-m/Kconfig.tfm.partitions @@ -3,8 +3,6 @@ # Copyright (c) 2021 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -if BUILD_WITH_TFM - config TFM_PARTITION_PROTECTED_STORAGE bool "Secure partition 'Protected Storage'" depends on TFM_PARTITION_PLATFORM # Specifically TFM_SP_PLATFORM_NV_COUNTER service @@ -89,5 +87,3 @@ config TFM_PARTITION_LOG_LEVEL_ERROR config TFM_PARTITION_LOG_LEVEL_SILENCE bool "Off" endchoice - -endif # BUILD_WITH_TFM diff --git a/modules/trusted-firmware-m/Kconfig.tfm.ps b/modules/trusted-firmware-m/Kconfig.tfm.ps new file mode 100644 index 000000000000..cce2078b234e Binary files /dev/null and b/modules/trusted-firmware-m/Kconfig.tfm.ps differ diff --git a/samples/arch/mpu/mpu_test/src/main.c b/samples/arch/mpu/mpu_test/src/main.c index c850a9dd9029..e5cb626dbaee 100644 --- a/samples/arch/mpu/mpu_test/src/main.c +++ b/samples/arch/mpu/mpu_test/src/main.c @@ -18,9 +18,10 @@ shell_fprintf(sh, SHELL_ERROR, fmt, ##__VA_ARGS__) /* Assumption: our devices have less than 64MB of memory */ -#define RESERVED_MEM_MAP (CONFIG_SRAM_BASE_ADDRESS + 0x4000000) +#define RESERVED_MEM_MAP (DT_CHOSEN_SRAM_ADDR + 0x4000000) +#define RAM_MEM DT_CHOSEN_SRAM_ADDR + #define FLASH_MEM CONFIG_FLASH_BASE_ADDRESS -#define RAM_MEM CONFIG_SRAM_BASE_ADDRESS /* MPU test command help texts */ #define READ_CMD_HELP "Read from a reserved address in the memory map" diff --git a/samples/basic/blinky/boards/nrf54l15dk_nrf54l15_cpuapp_hpf_gpio.overlay b/samples/basic/blinky/boards/nrf54l15dk_nrf54l15_cpuapp_hpf_gpio.overlay new file mode 100644 index 000000000000..bd1ceb2f8945 --- /dev/null +++ b/samples/basic/blinky/boards/nrf54l15dk_nrf54l15_cpuapp_hpf_gpio.overlay @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&led0 { + gpios = <&hpf_gpio 9 GPIO_ACTIVE_HIGH>; +}; diff --git a/samples/bluetooth/bap_broadcast_sink/sample.yaml b/samples/bluetooth/bap_broadcast_sink/sample.yaml index e6739dc10242..3eb1acd40762 100644 --- a/samples/bluetooth/bap_broadcast_sink/sample.yaml +++ b/samples/bluetooth/bap_broadcast_sink/sample.yaml @@ -25,5 +25,7 @@ tests: - nrf52_bsim - nrf52833dk/nrf52833 - nrf52840dongle/nrf52840 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/bap_broadcast_sink/sysbuild.cmake b/samples/bluetooth/bap_broadcast_sink/sysbuild.cmake index f030ce94ef20..f969f05ecffd 100644 --- a/samples/bluetooth/bap_broadcast_sink/sysbuild.cmake +++ b/samples/bluetooth/bap_broadcast_sink/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/bap_broadcast_source/sample.yaml b/samples/bluetooth/bap_broadcast_source/sample.yaml index 5e5b01d942d0..5f745cd08950 100644 --- a/samples/bluetooth/bap_broadcast_source/sample.yaml +++ b/samples/bluetooth/bap_broadcast_source/sample.yaml @@ -36,5 +36,7 @@ tests: - nrf52_bsim - nrf52833dk/nrf52833 - nrf52840dongle/nrf52840 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/bap_broadcast_source/sysbuild.cmake b/samples/bluetooth/bap_broadcast_source/sysbuild.cmake index 5aa4c28ce922..8ff4c02acf5a 100644 --- a/samples/bluetooth/bap_broadcast_source/sysbuild.cmake +++ b/samples/bluetooth/bap_broadcast_source/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/bap_unicast_client/sample.yaml b/samples/bluetooth/bap_unicast_client/sample.yaml index 7283090b8781..44f32934ce99 100644 --- a/samples/bluetooth/bap_unicast_client/sample.yaml +++ b/samples/bluetooth/bap_unicast_client/sample.yaml @@ -22,5 +22,7 @@ tests: - nrf52840dk/nrf52840 integration_platforms: - nrf52dk/nrf52832 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/bap_unicast_client/sysbuild.cmake b/samples/bluetooth/bap_unicast_client/sysbuild.cmake index 5aa4c28ce922..8ff4c02acf5a 100644 --- a/samples/bluetooth/bap_unicast_client/sysbuild.cmake +++ b/samples/bluetooth/bap_unicast_client/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/bap_unicast_server/sample.yaml b/samples/bluetooth/bap_unicast_server/sample.yaml index 068f752b626b..266ced73f66d 100644 --- a/samples/bluetooth/bap_unicast_server/sample.yaml +++ b/samples/bluetooth/bap_unicast_server/sample.yaml @@ -22,5 +22,7 @@ tests: - nrf52840dk/nrf52840 integration_platforms: - nrf52dk/nrf52832 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/bap_unicast_server/sysbuild.cmake b/samples/bluetooth/bap_unicast_server/sysbuild.cmake index 5aa4c28ce922..8ff4c02acf5a 100644 --- a/samples/bluetooth/bap_unicast_server/sysbuild.cmake +++ b/samples/bluetooth/bap_unicast_server/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/beacon/sample.yaml b/samples/bluetooth/beacon/sample.yaml index 1cbfc7da36f7..fe90b5952f92 100644 --- a/samples/bluetooth/beacon/sample.yaml +++ b/samples/bluetooth/beacon/sample.yaml @@ -21,7 +21,9 @@ tests: - ophelia4ev/nrf54l15/cpuapp - nrf54lm20dk/nrf54lm20a/cpuapp sample.bluetooth.beacon-coex: - extra_args: CONF_FILE="prj-coex.conf" + extra_args: + - CONF_FILE="prj-coex.conf" + - SNIPPET="bt-ll-sw-split" harness: bluetooth platform_allow: - nrf52840dk/nrf52840 diff --git a/samples/bluetooth/cap_acceptor/sample.yaml b/samples/bluetooth/cap_acceptor/sample.yaml index 824e744eecaf..9061f44679fb 100644 --- a/samples/bluetooth/cap_acceptor/sample.yaml +++ b/samples/bluetooth/cap_acceptor/sample.yaml @@ -26,5 +26,7 @@ tests: - nrf52833dk/nrf52833 - nrf52840dk/nrf52840 - nrf52840dongle/nrf52840 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/cap_acceptor/sysbuild.cmake b/samples/bluetooth/cap_acceptor/sysbuild.cmake index 5aa4c28ce922..8ff4c02acf5a 100644 --- a/samples/bluetooth/cap_acceptor/sysbuild.cmake +++ b/samples/bluetooth/cap_acceptor/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/cap_initiator/sample.yaml b/samples/bluetooth/cap_initiator/sample.yaml index b4f593c99129..e3e557f48301 100644 --- a/samples/bluetooth/cap_initiator/sample.yaml +++ b/samples/bluetooth/cap_initiator/sample.yaml @@ -26,5 +26,7 @@ tests: - nrf52833dk/nrf52833 - nrf52840dk/nrf52840 - nrf52840dongle/nrf52840 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/cap_initiator/sysbuild.cmake b/samples/bluetooth/cap_initiator/sysbuild.cmake index 5aa4c28ce922..8ff4c02acf5a 100644 --- a/samples/bluetooth/cap_initiator/sysbuild.cmake +++ b/samples/bluetooth/cap_initiator/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/direction_finding_central/sample.yaml b/samples/bluetooth/direction_finding_central/sample.yaml index b7a118e6cdc8..ffdf634c6e3e 100644 --- a/samples/bluetooth/direction_finding_central/sample.yaml +++ b/samples/bluetooth/direction_finding_central/sample.yaml @@ -14,15 +14,24 @@ tests: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - nrf5340dk/nrf5340/cpuapp - sample.bluetooth.direction_finding.central.aod: + sample.bluetooth.direction_finding.central.aod_with_controller: harness: bluetooth - extra_args: EXTRA_CONF_FILE="overlay-aod.conf" + extra_args: + - EXTRA_CONF_FILE="overlay-aod.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - - nrf5340dk/nrf5340/cpuapp tags: bluetooth integration_platforms: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 + sample.bluetooth.direction_finding.central.aod_host_only: + harness: bluetooth + extra_args: + - OVERLAY_CONFIG="overlay-aod.conf" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + tags: bluetooth + integration_platforms: - nrf5340dk/nrf5340/cpuapp diff --git a/samples/bluetooth/direction_finding_connectionless_rx/sample.yaml b/samples/bluetooth/direction_finding_connectionless_rx/sample.yaml index 8e6097de58ae..c500cc80dcec 100644 --- a/samples/bluetooth/direction_finding_connectionless_rx/sample.yaml +++ b/samples/bluetooth/direction_finding_connectionless_rx/sample.yaml @@ -12,14 +12,22 @@ tests: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - nrf5340dk/nrf5340/cpuapp - sample.bluetooth.direction_finding_connectionless_rx.aod: + sample.bluetooth.direction_finding_connectionless_rx.aod_with_controller: harness: bluetooth - extra_args: EXTRA_CONF_FILE="overlay-aod.conf" + extra_args: + - EXTRA_CONF_FILE="overlay-aod.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - - nrf5340dk/nrf5340/cpuapp integration_platforms: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 + sample.bluetooth.direction_finding_connectionless_rx.aod_host_only: + harness: bluetooth + extra_args: + - OVERLAY_CONFIG="overlay-aod.conf" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + integration_platforms: - nrf5340dk/nrf5340/cpuapp diff --git a/samples/bluetooth/direction_finding_connectionless_tx/sample.yaml b/samples/bluetooth/direction_finding_connectionless_tx/sample.yaml index 78d21b2c95f5..2a4fa93d19d5 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/sample.yaml +++ b/samples/bluetooth/direction_finding_connectionless_tx/sample.yaml @@ -12,14 +12,22 @@ tests: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - nrf5340dk/nrf5340/cpuapp - sample.bluetooth.direction_finding_connectionless.aoa: + sample.bluetooth.direction_finding_connectionless.aoa_with_controller: harness: bluetooth - extra_args: EXTRA_CONF_FILE="overlay-aoa.conf" + extra_args: + - EXTRA_CONF_FILE="overlay-aoa.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - - nrf5340dk/nrf5340/cpuapp integration_platforms: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 + sample.bluetooth.direction_finding_connectionless.aoa_host_only: + harness: bluetooth + extra_args: + - OVERLAY_CONFIG="overlay-aoa.conf" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + integration_platforms: - nrf5340dk/nrf5340/cpuapp diff --git a/samples/bluetooth/direction_finding_peripheral/sample.yaml b/samples/bluetooth/direction_finding_peripheral/sample.yaml index f300cb415cc5..01f612ad08a0 100644 --- a/samples/bluetooth/direction_finding_peripheral/sample.yaml +++ b/samples/bluetooth/direction_finding_peripheral/sample.yaml @@ -14,15 +14,24 @@ tests: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - nrf5340dk/nrf5340/cpuapp - sample.bluetooth.direction_finding.peripheral.aod: + sample.bluetooth.direction_finding.peripheral.aod_with_controller: harness: bluetooth - extra_args: EXTRA_CONF_FILE="overlay-aoa.conf" + extra_args: + - EXTRA_CONF_FILE="overlay-aoa.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 - - nrf5340dk/nrf5340/cpuapp tags: bluetooth integration_platforms: - nrf52833dk/nrf52833 - nrf52833dk/nrf52820 + sample.bluetooth.direction_finding.peripheral.aod_host_only: + harness: bluetooth + extra_args: + - OVERLAY_CONFIG="overlay-aoa.conf" + platform_allow: + - nrf5340dk/nrf5340/cpuapp + tags: bluetooth + integration_platforms: - nrf5340dk/nrf5340/cpuapp diff --git a/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf b/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 000000000000..296e68366389 --- /dev/null +++ b/samples/bluetooth/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1,2 @@ +# Increase stack size for Cracen driver. +CONFIG_MAIN_STACK_SIZE=1024 diff --git a/samples/bluetooth/hci_ipc/nrf54h20_cpurad-bt_ll_softdevice.conf b/samples/bluetooth/hci_ipc/nrf54h20_cpurad-bt_ll_softdevice.conf new file mode 100644 index 000000000000..1f7748e5cd7d --- /dev/null +++ b/samples/bluetooth/hci_ipc/nrf54h20_cpurad-bt_ll_softdevice.conf @@ -0,0 +1,33 @@ +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +CONFIG_ISR_STACK_SIZE=1024 +CONFIG_IDLE_STACK_SIZE=256 +CONFIG_MAIN_STACK_SIZE=512 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 +CONFIG_IPC_SERVICE_BACKEND_RPMSG_WQ_STACK_SIZE=512 +CONFIG_HEAP_MEM_POOL_SIZE=8192 + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y + +CONFIG_BT_BUF_EVT_RX_COUNT=16 +CONFIG_BT_BUF_EVT_RX_SIZE=255 +CONFIG_BT_BUF_ACL_RX_SIZE=255 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_BUF_CMD_TX_SIZE=255 + +# Host +CONFIG_BT_BROADCASTER=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_OBSERVER=y +CONFIG_BT_CENTRAL=y +CONFIG_BT_EXT_ADV=y +CONFIG_BT_PER_ADV=y +CONFIG_BT_PER_ADV_SYNC=y + +# Controller +CONFIG_BT_LL_SW_SPLIT=n +CONFIG_BT_LL_SOFTDEVICE=y +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 +CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 diff --git a/samples/bluetooth/hci_ipc/sample.yaml b/samples/bluetooth/hci_ipc/sample.yaml index b758b2547688..3763478b6b33 100644 --- a/samples/bluetooth/hci_ipc/sample.yaml +++ b/samples/bluetooth/hci_ipc/sample.yaml @@ -15,7 +15,9 @@ tests: sample.bluetooth.hci_ipc.iso_broadcast.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -25,7 +27,9 @@ tests: sample.bluetooth.hci_ipc.iso_receive.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -35,7 +39,9 @@ tests: sample.bluetooth.hci_ipc.bis.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_bis-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_bis-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -45,7 +51,9 @@ tests: sample.bluetooth.hci_ipc.iso_central.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso_central-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso_central-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -55,7 +63,9 @@ tests: sample.bluetooth.hci_ipc.iso_peripheral.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -65,7 +75,9 @@ tests: sample.bluetooth.hci_ipc.cis.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_cis-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_cis-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -75,7 +87,9 @@ tests: sample.bluetooth.hci_ipc.iso.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_iso-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_iso-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf5340_audio_dk/nrf5340/cpunet @@ -99,6 +113,7 @@ tests: extra_args: - CONF_FILE="nrf5340_cpunet_df-bt_ll_sw_split.conf" - DTC_OVERLAY_FILE="nrf5340_cpunet_df-bt_ll_sw_split.overlay" + - SNIPPET="bt-ll-sw-split" platform_allow: nrf5340dk/nrf5340/cpunet integration_platforms: - nrf5340dk/nrf5340/cpunet @@ -109,13 +124,16 @@ tests: - CONF_FILE="nrf5340_cpunet_df-bt_ll_sw_split.conf" - DTC_OVERLAY_FILE="nrf5340_cpunet_df-bt_ll_sw_split.overlay" - CONFIG_BT_CTLR_PHY_CODED=n + - SNIPPET="bt-ll-sw-split" platform_allow: nrf5340dk/nrf5340/cpunet integration_platforms: - nrf5340dk/nrf5340/cpunet sample.bluetooth.hci_ipc.mesh.bt_ll_sw_split: harness: bluetooth tags: bluetooth - extra_args: CONF_FILE="nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf" + extra_args: + - CONF_FILE="nrf5340_cpunet_bt_mesh-bt_ll_sw_split.conf" + - SNIPPET="bt-ll-sw-split" platform_allow: nrf5340dk/nrf5340/cpunet integration_platforms: - nrf5340dk/nrf5340/cpunet 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/hci_uart/sample.yaml b/samples/bluetooth/hci_uart/sample.yaml index df2b40135c67..8555c65cf0df 100644 --- a/samples/bluetooth/hci_uart/sample.yaml +++ b/samples/bluetooth/hci_uart/sample.yaml @@ -24,7 +24,9 @@ tests: platform_allow: nrf52833dk/nrf52833 integration_platforms: - nrf52833dk/nrf52833 - extra_args: DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + extra_args: + - DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + - SNIPPET="bt-ll-sw-split" extra_configs: - CONFIG_BT_CTLR_DF=y tags: @@ -33,7 +35,9 @@ tests: sample.bluetooth.hci_uart.nrf5340_netcore.df: harness: bluetooth platform_allow: nrf5340dk/nrf5340/cpunet - extra_args: DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay + extra_args: + - DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay + - SNIPPET="bt-ll-sw-split" extra_configs: - CONFIG_BT_CTLR_DF=y tags: @@ -44,7 +48,9 @@ tests: platform_allow: nrf52833dk/nrf52833 integration_platforms: - nrf52833dk/nrf52833 - extra_args: DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + extra_args: + - DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + - SNIPPET="bt-ll-sw-split" extra_configs: - CONFIG_BT_CTLR_DF=y - CONFIG_BT_CTLR_DTM_HCI_DF_IQ_REPORT=y @@ -54,7 +60,9 @@ tests: sample.bluetooth.hci_uart.nrf5340_netcore.df.iq_report: harness: bluetooth platform_allow: nrf5340dk/nrf5340/cpunet - extra_args: DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay + extra_args: + - DTC_OVERLAY_FILE=./boards/nrf5340dk_nrf5340_cpunet_df.overlay + - SNIPPET="bt-ll-sw-split" extra_configs: - CONFIG_BT_CTLR_DF=y - CONFIG_BT_CTLR_DTM_HCI_DF_IQ_REPORT=y @@ -88,6 +96,7 @@ tests: extra_args: - EXTRA_CONF_FILE=overlay-all-bt_ll_sw_split.conf - DTC_OVERLAY_FILE=./boards/nrf52833dk_nrf52833_df.overlay + - SNIPPET="bt-ll-sw-split" tags: - uart - bluetooth @@ -99,6 +108,7 @@ tests: extra_args: - EXTRA_CONF_FILE=overlay-all-bt_ll_sw_split.conf - DTC_OVERLAY_FILE=./boards/nrf54l15dk_nrf54l15_cpuapp_df.overlay + - SNIPPET="bt-ll-sw-split" tags: - uart - bluetooth diff --git a/samples/bluetooth/hci_vs_scan_req/sample.yaml b/samples/bluetooth/hci_vs_scan_req/sample.yaml index 245a83aa0d96..49526522d16e 100644 --- a/samples/bluetooth/hci_vs_scan_req/sample.yaml +++ b/samples/bluetooth/hci_vs_scan_req/sample.yaml @@ -9,4 +9,6 @@ tests: - nrf52dk/nrf52832 extra_configs: - CONFIG_BT_LL_SW_SPLIT=y + extra_args: + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/iso_central/sample.yaml b/samples/bluetooth/iso_central/sample.yaml index 3a7dedd404ae..57254ee809ab 100644 --- a/samples/bluetooth/iso_central/sample.yaml +++ b/samples/bluetooth/iso_central/sample.yaml @@ -11,11 +11,11 @@ tests: sample.bluetooth.iso_central.bt_ll_sw_split: harness: bluetooth platform_allow: - - qemu_cortex_m3 - - qemu_x86 - nrf52_bsim - nrf52833dk/nrf52833 integration_platforms: - nrf52833dk/nrf52833 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/mesh/prj.conf b/samples/bluetooth/mesh/prj.conf index 05db4813e912..c98fddec6f9a 100644 --- a/samples/bluetooth/mesh/prj.conf +++ b/samples/bluetooth/mesh/prj.conf @@ -5,7 +5,7 @@ CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y CONFIG_HWINFO=y CONFIG_BT=y diff --git a/samples/bluetooth/mesh_demo/prj.conf b/samples/bluetooth/mesh_demo/prj.conf index bcb738ae5bd1..b7016b02c65b 100644 --- a/samples/bluetooth/mesh_demo/prj.conf +++ b/samples/bluetooth/mesh_demo/prj.conf @@ -31,7 +31,7 @@ CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y CONFIG_BT_MESH_RPL_STORE_TIMEOUT=600 -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y # Limit the number of key slots in PSA Crypto core to reduce # RAM footprint diff --git a/samples/bluetooth/mesh_provisioner/prj.conf b/samples/bluetooth/mesh_provisioner/prj.conf index 5660adcd48c3..ba3520610f60 100644 --- a/samples/bluetooth/mesh_provisioner/prj.conf +++ b/samples/bluetooth/mesh_provisioner/prj.conf @@ -1,6 +1,10 @@ #CONFIG_INIT_STACKS=y -CONFIG_MAIN_STACK_SIZE=2500 -CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2500 +# Stack sizes from thread analysis + 50% margin, rounded to nearest 100 +CONFIG_MAIN_STACK_SIZE=4400 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4800 +CONFIG_BT_MESH_SETTINGS_WORKQ_STACK_SIZE=1700 +CONFIG_BT_MESH_ADV_STACK_SIZE=4000 +CONFIG_BT_RX_STACK_SIZE=3300 # The Bluetooth API should not be used from a preemptive thread: CONFIG_MAIN_THREAD_PRIORITY=-2 @@ -46,7 +50,7 @@ CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y CONFIG_BT_MESH_RPL_STORE_TIMEOUT=600 -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y #CONFIG_BT_MESH_LOG_LEVEL_DBG=y #CONFIG_BT_MESH_SETTINGS_LOG_LEVEL_DBG=y diff --git a/samples/bluetooth/pbp_public_broadcast_sink/sample.yaml b/samples/bluetooth/pbp_public_broadcast_sink/sample.yaml index d7c816ee5b76..901d40b00d4f 100644 --- a/samples/bluetooth/pbp_public_broadcast_sink/sample.yaml +++ b/samples/bluetooth/pbp_public_broadcast_sink/sample.yaml @@ -23,5 +23,7 @@ tests: integration_platforms: - nrf52_bsim - nrf52833dk/nrf52833 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/pbp_public_broadcast_sink/sysbuild.cmake b/samples/bluetooth/pbp_public_broadcast_sink/sysbuild.cmake index 5aa4c28ce922..8ff4c02acf5a 100644 --- a/samples/bluetooth/pbp_public_broadcast_sink/sysbuild.cmake +++ b/samples/bluetooth/pbp_public_broadcast_sink/sysbuild.cmake @@ -18,6 +18,10 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/bluetooth/pbp_public_broadcast_source/sample.yaml b/samples/bluetooth/pbp_public_broadcast_source/sample.yaml index 80c907042119..1d2e31306e29 100644 --- a/samples/bluetooth/pbp_public_broadcast_source/sample.yaml +++ b/samples/bluetooth/pbp_public_broadcast_source/sample.yaml @@ -23,5 +23,7 @@ tests: integration_platforms: - nrf52_bsim - nrf52833dk/nrf52833 - extra_args: EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + extra_args: + - EXTRA_CONF_FILE=overlay-bt_ll_sw_split.conf + - SNIPPET="bt-ll-sw-split" tags: bluetooth diff --git a/samples/bluetooth/pbp_public_broadcast_source/sysbuild.cmake b/samples/bluetooth/pbp_public_broadcast_source/sysbuild.cmake index f0aa34b7ad4a..fa62c31f7b3b 100644 --- a/samples/bluetooth/pbp_public_broadcast_source/sysbuild.cmake +++ b/samples/bluetooth/pbp_public_broadcast_source/sysbuild.cmake @@ -18,6 +18,10 @@ if(NOT("${SB_CONFIG_NET_CORE_BOARD}" STREQUAL "")) CACHE INTERNAL "" ) + list(APPEND ${NET_APP}_SNIPPET ${SNIPPET}) + list(APPEND ${NET_APP}_SNIPPET bt-ll-sw-split) + set(${NET_APP}_SNIPPET ${${NET_APP}_SNIPPET} CACHE STRING "" FORCE) + native_simulator_set_child_images(${DEFAULT_IMAGE} ${NET_APP}) endif() diff --git a/samples/boards/nordic/coresight_stm/pytest/test_stm.py b/samples/boards/nordic/coresight_stm/pytest/test_stm.py index 993df0b55fb8..feb9a7cf37a5 100644 --- a/samples/boards/nordic/coresight_stm/pytest/test_stm.py +++ b/samples/boards/nordic/coresight_stm/pytest/test_stm.py @@ -172,7 +172,7 @@ def nrfutil_dictionary_from_serial( decoded_file_name: str = "output.txt", collect_time: float = 60.0, ) -> None: - UART_PATH = dut.device_config.serial + UART_PATH = dut.device_config.serial_configs[0].port dut.close() logger.debug(f"Using serial: {UART_PATH}") @@ -203,7 +203,12 @@ def nrfutil_dictionary_from_serial( try: # run nrfutil trace in background non-blocking logger.info(f"Executing:\n{cmd}") - proc = subprocess.Popen(cmd.split(), stdout=subprocess.DEVNULL) + proc = subprocess.Popen(cmd.split(), + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + encoding='UTF-8', + errors='replace') except OSError as exc: logger.error(f"Unable to start nrfutil trace:\n{cmd}\n{exc}") try: @@ -212,6 +217,8 @@ def nrfutil_dictionary_from_serial( pass finally: _kill(proc) + outs, errs = proc.communicate() + logger.info(f"{outs=}\n{errs=}") def test_sample_STM_decoded(dut: DeviceAdapter): @@ -302,7 +309,7 @@ def test_STM_decoded(dut: DeviceAdapter): log_2_arg=26.9, log_3_arg=27.5, log_str=68.3, - tracepoint=0.55, + tracepoint=0.9, tracepoint_d32=0.25, tolerance=0.5, ) @@ -313,8 +320,8 @@ def test_STM_decoded(dut: DeviceAdapter): log_2_arg=1.2, log_3_arg=1.2, log_str=3.0, - tracepoint=0.25, - tracepoint_d32=0.25, + tracepoint=0.5, + tracepoint_d32=0.5, tolerance=0.5, ) @@ -447,8 +454,8 @@ def test_STM_dictionary_mode(dut: DeviceAdapter): log_2_arg=8.6, log_3_arg=17.4, log_str=45.2, - tracepoint=0.5, - tracepoint_d32=0.5, + tracepoint=1.5, + tracepoint_d32=1.5, tolerance=0.5, ) flpr_constraints = STMLimits( diff --git a/samples/boards/nordic/coresight_stm/sample.yaml b/samples/boards/nordic/coresight_stm/sample.yaml index 4dde7feb0219..4a15ce2afb96 100644 --- a/samples/boards/nordic/coresight_stm/sample.yaml +++ b/samples/boards/nordic/coresight_stm/sample.yaml @@ -23,6 +23,9 @@ tests: - SB_CONFIG_APP_CPUFLPR_RUN=y sample.boards.nrf.coresight_stm.tpiu.dict: + harness: console + harness_config: + fixture: jlink_trace_pro required_snippets: - nordic-log-stm-tpiu-dict extra_args: @@ -42,6 +45,11 @@ tests: - SB_CONFIG_APP_CPUFLPR_RUN=y sample.boards.nrf.coresight_stm.rtt: + harness: pytest + harness_config: + pytest_dut_scope: session + pytest_root: + - "pytest/test_stm.py::test_sample_STM_decoded" required_snippets: - nordic-log-stm extra_configs: diff --git a/samples/boards/nordic/mesh/onoff-app/prj.conf b/samples/boards/nordic/mesh/onoff-app/prj.conf index 0e67042b2653..0783579e795e 100644 --- a/samples/boards/nordic/mesh/onoff-app/prj.conf +++ b/samples/boards/nordic/mesh/onoff-app/prj.conf @@ -9,7 +9,7 @@ CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y CONFIG_BT_MESH_RPL_STORE_TIMEOUT=600 diff --git a/samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/prj.conf b/samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/prj.conf index 3bb984208c70..96b5466b4a16 100644 --- a/samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/prj.conf +++ b/samples/boards/nordic/mesh/onoff_level_lighting_vnd_app/prj.conf @@ -7,7 +7,7 @@ CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y CONFIG_BT_OBSERVER=y CONFIG_BT_BROADCASTER=y diff --git a/samples/boards/nordic/nrf53_sync_rtc/sysbuild.conf b/samples/boards/nordic/nrf53_sync_rtc/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/boards/nordic/nrf53_sync_rtc/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20_common.dtsi b/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20_common.dtsi new file mode 100644 index 000000000000..246efa029ede --- /dev/null +++ b/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20_common.dtsi @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +sample_counter: &timer20 { + status = "okay"; +}; diff --git a/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay b/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay index 246efa029ede..a669ed1275a8 100644 --- a/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay +++ b/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay @@ -3,6 +3,4 @@ * SPDX-License-Identifier: Apache-2.0 */ -sample_counter: &timer20 { - status = "okay"; -}; +#include "nrf54lm20dk_nrf54lm20_common.dtsi" diff --git a/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay b/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay new file mode 100644 index 000000000000..a669ed1275a8 --- /dev/null +++ b/samples/boards/nordic/nrf_sys_event/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay @@ -0,0 +1,6 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf54lm20dk_nrf54lm20_common.dtsi" diff --git a/samples/boards/nordic/nrf_sys_event/sample.yaml b/samples/boards/nordic/nrf_sys_event/sample.yaml index 6ac248d7fc3c..e3fd48ae3b9b 100644 --- a/samples/boards/nordic/nrf_sys_event/sample.yaml +++ b/samples/boards/nordic/nrf_sys_event/sample.yaml @@ -67,5 +67,6 @@ tests: platform_allow: - nrf54l15dk/nrf54l15/cpuapp - nrf54lm20dk/nrf54lm20a/cpuapp + - nrf54lm20dk/nrf54lm20b/cpuapp integration_platforms: - nrf54l15dk/nrf54l15/cpuapp diff --git a/samples/drivers/i2s/echo/src/main.c b/samples/drivers/i2s/echo/src/main.c index 31b8cf1e8619..031bbae3d73a 100644 --- a/samples/drivers/i2s/echo/src/main.c +++ b/samples/drivers/i2s/echo/src/main.c @@ -21,8 +21,10 @@ #define I2S_TX_NODE DT_NODELABEL(i2s_tx) #endif +#define RAM_SIZE (DT_CHOSEN_SRAM_ADDR / 1024) + /* Reduce echo delay when running on low ram devices */ -#if CONFIG_SRAM_SIZE <= 48 +#if SRAM_SIZE <= 48 #define ECHO_DELAY 30 #else #define ECHO_DELAY 10 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/drivers/soc_flash_nrf/sample.yaml b/samples/drivers/soc_flash_nrf/sample.yaml index 02d90fb2e337..54e8285a0284 100644 --- a/samples/drivers/soc_flash_nrf/sample.yaml +++ b/samples/drivers/soc_flash_nrf/sample.yaml @@ -12,6 +12,7 @@ tests: - nrf54l15dk/nrf54l15/cpuapp - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp + - nrf7120dk/nrf7120/cpuapp integration_platforms: - nrf52dk/nrf52832 - nrf52840dk/nrf52840 diff --git a/samples/kernel/bootargs/app_efi.overlay b/samples/kernel/bootargs/app_efi.overlay new file mode 100644 index 000000000000..3867176dbcda --- /dev/null +++ b/samples/kernel/bootargs/app_efi.overlay @@ -0,0 +1,3 @@ +&dram0 { + reg = <0x0 0xc800000>; +}; diff --git a/samples/kernel/bootargs/prj_efi.conf b/samples/kernel/bootargs/prj_efi.conf index 75a723633012..8b3416d3a6db 100644 --- a/samples/kernel/bootargs/prj_efi.conf +++ b/samples/kernel/bootargs/prj_efi.conf @@ -1,4 +1,4 @@ +CONFIG_BOOTARGS=y CONFIG_DYNAMIC_BOOTARGS=y CONFIG_QEMU_UEFI_BOOT=y CONFIG_BUILD_OUTPUT_EFI=y -CONFIG_SRAM_SIZE=204800 diff --git a/samples/kernel/bootargs/sample.yaml b/samples/kernel/bootargs/sample.yaml index 020f07188f68..8ff0d7cc2a44 100644 --- a/samples/kernel/bootargs/sample.yaml +++ b/samples/kernel/bootargs/sample.yaml @@ -12,7 +12,7 @@ tests: regex: - "argv\\[0\\] = .*/zephyr(-qemu-locore)?.elf" sample.kernel.bootargs.efi: - extra_args: EXTRA_CONF_FILE=prj_efi.conf + extra_args: FILE_SUFFIX=efi platform_allow: qemu_x86_64 harness: console harness_config: diff --git a/samples/net/dns_resolve/Kconfig.sysbuild b/samples/net/dns_resolve/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/dns_resolve/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/ipv4_autoconf/Kconfig.sysbuild b/samples/net/ipv4_autoconf/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/ipv4_autoconf/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/lwm2m_client/Kconfig.sysbuild b/samples/net/lwm2m_client/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/lwm2m_client/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/lwm2m_client/overlay-nrf91x.conf b/samples/net/lwm2m_client/overlay-nrf91x.conf new file mode 100644 index 000000000000..7b902178e078 --- /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_NET_SAMPLE_LWM2M_ID="nrf91x" +CONFIG_NET_SAMPLE_LWM2M_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/Kconfig.sysbuild b/samples/net/mdns_responder/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/mdns_responder/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/mqtt_publisher/Kconfig.sysbuild b/samples/net/mqtt_publisher/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/mqtt_publisher/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/mqtt_sn_publisher/Kconfig.sysbuild b/samples/net/mqtt_sn_publisher/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/mqtt_sn_publisher/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/big_http_download/prj.conf b/samples/net/sockets/big_http_download/prj.conf index c623d3b763bf..661ff62e9d92 100644 --- a/samples/net/sockets/big_http_download/prj.conf +++ b/samples/net/sockets/big_http_download/prj.conf @@ -3,6 +3,7 @@ CONFIG_REQUIRES_FULL_LIBC=y CONFIG_PSA_CRYPTO=y CONFIG_MBEDTLS_ENABLE_HEAP=y CONFIG_PSA_WANT_ALG_SHA_256=y +CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y CONFIG_MAIN_STACK_SIZE=2536 # Networking config diff --git a/samples/net/sockets/coap_server/Kconfig.sysbuild b/samples/net/sockets/coap_server/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/coap_server/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/echo_async/Kconfig.sysbuild b/samples/net/sockets/echo_async/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/echo_async/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/echo_client/Kconfig.sysbuild b/samples/net/sockets/echo_client/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/echo_client/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/echo_server/Kconfig.sysbuild b/samples/net/sockets/echo_server/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/echo_server/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/http_get/Kconfig.sysbuild b/samples/net/sockets/http_get/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/http_get/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/sockets/http_get/overlay-tls.conf b/samples/net/sockets/http_get/overlay-tls.conf index 4fa30f6f8797..7e2fefc09736 100644 --- a/samples/net/sockets/http_get/overlay-tls.conf +++ b/samples/net/sockets/http_get/overlay-tls.conf @@ -6,7 +6,7 @@ CONFIG_MBEDTLS_ENABLE_HEAP=y CONFIG_MBEDTLS_HEAP_SIZE=60000 CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=7168 CONFIG_MBEDTLS_HASH_ALL_ENABLED=y -CONFIG_PSA_WANT_ALG_CMAC=y +CONFIG_MBEDTLS_CMAC=y CONFIG_NET_SOCKETS_SOCKOPT_TLS=y CONFIG_MBEDTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256=y diff --git a/samples/net/sockets/sntp_client/Kconfig.sysbuild b/samples/net/sockets/sntp_client/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/sockets/sntp_client/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/syslog_net/Kconfig.sysbuild b/samples/net/syslog_net/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/syslog_net/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/telnet/Kconfig.sysbuild b/samples/net/telnet/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/telnet/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/wifi/Kconfig.sysbuild b/samples/net/wifi/Kconfig.sysbuild new file mode 100644 index 000000000000..158551060c56 --- /dev/null +++ b/samples/net/wifi/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/wifi/shell/sample.yaml b/samples/net/wifi/shell/sample.yaml index d799c1b9beec..52edf0c6267f 100644 --- a/samples/net/wifi/shell/sample.yaml +++ b/samples/net/wifi/shell/sample.yaml @@ -58,6 +58,7 @@ tests: - nrf7002dk/nrf5340/cpuapp/nrf7001 sample.net.wifi.nrf7002ek: extra_args: + - SB_CONFIG_WIFI_NRF70=y - CONFIG_BUILD_ONLY_NO_BLOBS=y - SHIELD=nrf7002ek platform_allow: @@ -69,6 +70,7 @@ tests: sample.net.wifi.nrf7002eb: extra_args: - CONFIG_NRF70_UTIL=y + - SB_CONFIG_WIFI_NRF70=y - CONFIG_BUILD_ONLY_NO_BLOBS=y - SHIELD=nrf7002eb platform_allow: diff --git a/samples/subsys/demand_paging/app.overlay b/samples/subsys/demand_paging/app.overlay new file mode 100644 index 000000000000..9035cfd48e20 --- /dev/null +++ b/samples/subsys/demand_paging/app.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x0 0x40000000 0x0 0x40000>; +}; diff --git a/samples/subsys/demand_paging/prj.conf b/samples/subsys/demand_paging/prj.conf index c1111f3b8348..f03ea52ffc4d 100644 --- a/samples/subsys/demand_paging/prj.conf +++ b/samples/subsys/demand_paging/prj.conf @@ -1,4 +1,3 @@ -CONFIG_SRAM_SIZE=256 CONFIG_DEMAND_PAGING=y CONFIG_DEMAND_PAGING_ALLOW_IRQ=y CONFIG_DEMAND_PAGING_STATS=y 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/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/subsys/usb/console/sample.yaml b/samples/subsys/usb/console/sample.yaml index d009dbdb3d0a..50fc98003c21 100644 --- a/samples/subsys/usb/console/sample.yaml +++ b/samples/subsys/usb/console/sample.yaml @@ -1,17 +1,21 @@ sample: name: Console over CDC ACM serial +common: + depends_on: + - usbd + tags: usb + harness: console + harness_config: + fixture: fixture_usb_cdc + integration_platforms: + - nrf52840dk/nrf52840 + - frdm_k64f + - stm32f723e_disco + - nucleo_f413zh + - mimxrt685_evk/mimxrt685s/cm33 + - mimxrt1060_evk/mimxrt1062/qspi tests: - sample.usbd.console: - depends_on: - - usbd - tags: usb - integration_platforms: - - nrf52840dk/nrf52840 - - frdm_k64f - - stm32f723e_disco - - nucleo_f413zh - - mimxrt685_evk/mimxrt685s/cm33 - - mimxrt1060_evk/mimxrt1062/qspi - harness: console - harness_config: - fixture: fixture_usb_cdc + sample.usbd.console: {} + sample.usbd.console.multiple-instances: + extra_configs: + - CONFIG_CDC_ACM_SERIAL_MULTIPLE_INSTANCES=y diff --git a/samples/subsys/usb/dfu/sysbuild.conf b/samples/subsys/usb/dfu/sysbuild.conf new file mode 100644 index 000000000000..47f00ff3cff8 --- /dev/null +++ b/samples/subsys/usb/dfu/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/samples/subsys/zbus/proxy_agent_ipc/sysbuild.conf b/samples/subsys/zbus/proxy_agent_ipc/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/samples/subsys/zbus/proxy_agent_ipc/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/samples/sysbuild/hello_world/sysbuild.cmake b/samples/sysbuild/hello_world/sysbuild.cmake index fa0599c6a621..b86a7659fdd6 100644 --- a/samples/sysbuild/hello_world/sysbuild.cmake +++ b/samples/sysbuild/hello_world/sysbuild.cmake @@ -9,6 +9,18 @@ if(DEFINED SB_CONFIG_REMOTE_BOARD) BOARD_REVISION ${BOARD_REVISION} ) + if(SB_CONFIG_SOC_SERIES_NRF53) + set_property(GLOBAL APPEND PROPERTY PM_DOMAINS CPUNET) + set_property(GLOBAL APPEND PROPERTY PM_CPUNET_IMAGES remote) + set_property(GLOBAL PROPERTY DOMAIN_APP_CPUNET remote) + set(CPUNET_PM_DOMAIN_DYNAMIC_PARTITION remote CACHE INTERNAL "") + else(SB_CONFIG_SOC_SERIES_NRF54L) + set_property(GLOBAL APPEND PROPERTY PM_DOMAINS CPUFLPR) + set_property(GLOBAL APPEND PROPERTY PM_CPUFLPR_IMAGES remote) + set_property(GLOBAL PROPERTY DOMAIN_APP_CPUFLPR remote) + set(CPUFLPR_PM_DOMAIN_DYNAMIC_PARTITION remote CACHE INTERNAL "") + endif() + add_dependencies(${DEFAULT_IMAGE} remote) sysbuild_add_dependencies(FLASH ${DEFAULT_IMAGE} remote) endif() diff --git a/samples/tfm_integration/config_build/sample.yaml b/samples/tfm_integration/config_build/sample.yaml index b8d0a6876238..928ed2478db7 100644 --- a/samples/tfm_integration/config_build/sample.yaml +++ b/samples/tfm_integration/config_build/sample.yaml @@ -11,6 +11,7 @@ common: - nrf54l15dk/nrf54l15/cpuapp/ns - nrf54l15dk/nrf54l10/cpuapp/ns - nrf54lm20dk/nrf54lm20a/cpuapp/ns + - nrf7120dk/nrf7120/cpuapp/ns - bl5340_dvk/nrf5340/cpuapp/ns integration_platforms: - nrf5340dk/nrf5340/cpuapp/ns diff --git a/samples/tfm_integration/tfm_ipc/sample.yaml b/samples/tfm_integration/tfm_ipc/sample.yaml index 0ec789de7526..78242176e202 100644 --- a/samples/tfm_integration/tfm_ipc/sample.yaml +++ b/samples/tfm_integration/tfm_ipc/sample.yaml @@ -39,6 +39,7 @@ tests: - nrf54l15dk/nrf54l15/cpuapp/ns - nrf54l15dk/nrf54l10/cpuapp/ns - nrf54lm20dk/nrf54lm20a/cpuapp/ns + - nrf7120dk/nrf7120/cpuapp/ns extra_configs: - CONFIG_TFM_BL2=n harness: console diff --git a/samples/tfm_integration/tfm_regression_test/CMakeLists.txt b/samples/tfm_integration/tfm_regression_test/CMakeLists.txt deleted file mode 100644 index 26d97709929b..000000000000 --- a/samples/tfm_integration/tfm_regression_test/CMakeLists.txt +++ /dev/null @@ -1,73 +0,0 @@ -# -# Copyright (c) 2021 Nordic Semiconductor ASA -# -# SPDX-License-Identifier: Apache-2.0 -# - -cmake_minimum_required(VERSION 3.20.0) - -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) - -project(tfm_regression_test) - -target_sources(app PRIVATE src/main.c) - -get_target_property(TFM_BINARY_DIR tfm TFM_BINARY_DIR) -get_target_property(TFM_NS_BIN_FILE tfm TFM_NS_BIN_FILE) -get_target_property(TFM_NS_HEX_FILE tfm TFM_NS_HEX_FILE) -get_target_property(TFM_NS_SIGNED_BIN_FILE tfm TFM_NS_SIGNED_BIN_FILE) - -get_target_property(TFM_TOOLCHAIN_PATH tfm TFM_TOOLCHAIN_PATH) -get_target_property(TFM_TOOLCHAIN_PREFIX tfm TFM_TOOLCHAIN_PREFIX) -get_target_property(TFM_TOOLCHAIN_NS_FILE tfm TFM_TOOLCHAIN_NS_FILE) - -set(TFM_TEST_REPO_PATH ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/../tf-m-tests) - -set(TFM_TEST_DIR "${TFM_TEST_REPO_PATH}/tests_reg/test/secure_regression") -set(TFM_TEST_CONFIG_FILE "${TFM_TEST_REPO_PATH}/tests_reg/test/config/config.cmake") - -set_property(TARGET zephyr_property_target - APPEND PROPERTY TFM_CMAKE_OPTIONS - -DCONFIG_TFM_TEST_DIR=${TFM_TEST_DIR} -) - -set_property(TARGET zephyr_property_target - APPEND PROPERTY TFM_CMAKE_OPTIONS - -DCONFIG_TFM_TEST_CONFIG_FILE=${TFM_TEST_CONFIG_FILE} -) - -# Let TF-M install Mbed TLS (3.6.5) include files in the binary directory. -set_property(TARGET zephyr_property_target - APPEND PROPERTY TFM_CMAKE_OPTIONS - -DTFM_INSTALL_MBEDTLS_HEADERS=ON -) - -include(ExternalProject) - -ExternalProject_Add(tfm_regression_test_app - SOURCE_DIR ${TFM_TEST_REPO_PATH}/tests_reg - BINARY_DIR ${PROJECT_BINARY_DIR}/tfm_ns - CONFIGURE_COMMAND - ${CMAKE_COMMAND} - -G ${CMAKE_GENERATOR} - -S ${TFM_TEST_REPO_PATH}/tests_reg - -B ${PROJECT_BINARY_DIR}/tfm_ns - -DPython3_EXECUTABLE=${PYTHON_EXECUTABLE} - -DCONFIG_SPE_PATH=${TFM_BINARY_DIR}/api_ns - -DTFM_TOOLCHAIN_FILE=cmake/${TFM_TOOLCHAIN_NS_FILE} - -DCROSS_COMPILE=${TFM_TOOLCHAIN_PATH}/${TFM_TOOLCHAIN_PREFIX} - -DQCBOR_PATH${QCBOR_PATH_TYPE}=${CONFIG_TFM_QCBOR_PATH} - -DCMAKE_BUILD_TYPE=RelWithDebInfo - BUILD_COMMAND ${CMAKE_COMMAND} --build . - INSTALL_COMMAND "" - BUILD_ALWAYS True - USES_TERMINAL_BUILD True - WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tfm_ns - DEPENDS tfm - BUILD_BYPRODUCTS - ${TFM_NS_HEX_FILE} - ${TFM_NS_BIN_FILE} - ${TFM_NS_SIGNED_BIN_FILE} -) - -add_dependencies(app tfm_regression_test_app) diff --git a/samples/tfm_integration/tfm_regression_test/README.rst b/samples/tfm_integration/tfm_regression_test/README.rst deleted file mode 100644 index 047bd79b2216..000000000000 --- a/samples/tfm_integration/tfm_regression_test/README.rst +++ /dev/null @@ -1,117 +0,0 @@ -.. _tfm_regression_test: - -TF-M Regression Test Sample -########################### - -Overview -******** - -Run both the Secure and Non-secure TF-M Regression tests using the Zephyr build system. - -The build system will replace the Zephyr application with the Non-Secure TF-M test application, -while the Secure tests will be included in the TF-M build itself. - -The TF-M regression tests are implemented in the tf-m-tests repo: https://git.trustedfirmware.org/TF-M/tf-m-tests.git/ - -This sample is available for platforms that are supported in the trusted-firmware-m repo: https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/ -See sample.yaml for a list of supported platforms. - -Building and Running -******************** - -Tests for both the secure and non-secure domain are enabled by default, controlled via the CONFIG_TFM_REGRESSION_S and CONFIG_TFM_REGRESSION_NS configs. - -On Target -========= - -Refer to :zephyr:code-sample:`tfm_ipc` for detailed instructions. - -On QEMU: -======== - -Refer to :zephyr:code-sample:`tfm_ipc` for detailed instructions. -Following is an example based on ``west build`` - - .. code-block:: bash - - $ west build samples/tfm_integration/tfm_regression_test/ -p -b mps2/an521/cpu0/ns -t run - -Sample Output -============= - - .. code-block:: console - - Non-Secure system starting... - - #### Execute test suites for the Secure area #### - - [...] - - Running Test Suite PS reliability tests (TFM_PS_TEST_3XXX)... - > Executing 'TFM_PS_TEST_3001' - Description: 'repetitive sets and gets in/from an asset' - > Iteration 15 of 15 - TEST: TFM_PS_TEST_3001 - PASSED! - > Executing 'TFM_PS_TEST_3002' - Description: 'repetitive sets, gets and removes' - > Iteration 15 of 15 - TEST: TFM_PS_TEST_3002 - PASSED! - TESTSUITE PASSED! - - [...] - - *** Secure test suites summary *** - Test suite 'PSA protected storage S interface tests (TFM_PS_TEST_2XXX)' has PASSED - Test suite 'PS reliability tests (TFM_PS_TEST_3XXX)' has PASSED - Test suite 'PS rollback protection tests (TFM_PS_TEST_4XXX)' has PASSED - Test suite 'PSA internal trusted storage S interface tests (TFM_ITS_TEST_2XXX)' has PASSED - Test suite 'ITS reliability tests (TFM_ITS_TEST_3XXX)' has PASSED - Test suite 'Crypto secure interface tests (TFM_CRYPTO_TEST_5XXX)' has PASSED - Test suite 'Initial Attestation Service secure interface tests(TFM_ATTEST_TEST_1XXX)' has PASSED - Test suite 'Platform Service Secure interface tests(TFM_PLATFORM_TEST_1XXX)' has PASSED - Test suite 'IPC secure interface test (TFM_IPC_TEST_1XXX)' has PASSED - - *** End of Secure test suites *** - - #### Execute test suites for the Non-secure area #### - - [...] - - Running Test Suite Core non-secure positive tests (TFM_CORE_TEST_1XXX)... - > Executing 'TFM_CORE_TEST_1001' - Description: 'Test service request from NS thread mode' - TEST: TFM_CORE_TEST_1001 - PASSED! - > Executing 'TFM_CORE_TEST_1003' - Description: 'Test the success of service init' - TEST: TFM_CORE_TEST_1003 - PASSED! - > Executing 'TFM_CORE_TEST_1007' - Description: 'Test secure service buffer accesses' - TEST: TFM_CORE_TEST_1007 - PASSED! - > Executing 'TFM_CORE_TEST_1008' - Description: 'Test secure service to service call' - TEST: TFM_CORE_TEST_1008 - PASSED! - > Executing 'TFM_CORE_TEST_1010' - Description: 'Test secure service to service call with buffer handling' - TEST: TFM_CORE_TEST_1010 - PASSED! - > Executing 'TFM_CORE_TEST_1015' - Description: 'Test service parameter sanitization' - TEST: TFM_CORE_TEST_1015 - PASSED! - > Executing 'TFM_CORE_TEST_1016' - Description: 'Test outvec write' - TEST: TFM_CORE_TEST_1016 - PASSED! - TESTSUITE PASSED! - - [...] - - *** Non-secure test suites summary *** - Test suite 'PSA protected storage NS interface tests (TFM_PS_TEST_1XXX)' has PASSED - Test suite 'PSA internal trusted storage NS interface tests (TFM_ITS_TEST_1XXX)' has PASSED - Test suite 'Crypto non-secure interface test (TFM_CRYPTO_TEST_6XXX)' has PASSED - Test suite 'Platform Service Non-Secure interface tests(TFM_PLATFORM_TEST_2XXX)' has PASSED - Test suite 'Initial Attestation Service non-secure interface tests(TFM_ATTEST_TEST_2XXX)' has PASSED - Test suite 'QCBOR regression test(TFM_QCBOR_TEST_7XXX)' has PASSED - Test suite 'T_COSE regression test(TFM_T_COSE_TEST_8XXX)' has PASSED - Test suite 'Core non-secure positive tests (TFM_CORE_TEST_1XXX)' has PASSED - Test suite 'IPC non-secure interface test (TFM_IPC_TEST_1XXX)' has PASSED - - *** End of Non-secure test suites *** diff --git a/samples/tfm_integration/tfm_regression_test/boards/max32657evkit_max32657_ns.conf b/samples/tfm_integration/tfm_regression_test/boards/max32657evkit_max32657_ns.conf deleted file mode 100644 index 8d42e1c2c12c..000000000000 --- a/samples/tfm_integration/tfm_regression_test/boards/max32657evkit_max32657_ns.conf +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2025 Analog Devices, Inc. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# MAX32657 only contains one UART. -# It is allocated to NS. -# Therefore, disable S side regression test. -CONFIG_TFM_REGRESSION_S=n - -# MAX32657 currently only supports SFN -# and isolation level 1 -CONFIG_TFM_SFN=y -CONFIG_TFM_ISOLATION_LEVEL=1 diff --git a/samples/tfm_integration/tfm_regression_test/boards/nucleo_l552ze_q_stm32l552xx_ns.overlay b/samples/tfm_integration/tfm_regression_test/boards/nucleo_l552ze_q_stm32l552xx_ns.overlay deleted file mode 100644 index 2760c3f22ca8..000000000000 --- a/samples/tfm_integration/tfm_regression_test/boards/nucleo_l552ze_q_stm32l552xx_ns.overlay +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2023 STMicroelectronics - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/* This partition table could be used along with TFM configuration: - * - TEST_S=ON (REGRESSION) - * - TFM_PSA_API=ON (IPC) - * - */ - -/ { - chosen { - zephyr,code-partition = &slot0_ns_partition; - }; -}; - -/delete-node/ &slot1_partition; -/delete-node/ &slot1_ns_partition; - -&flash0 { - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - boot_partition: partition@0 { - label = "mcuboot"; - reg = <0x00000000 DT_SIZE_K(80)>; - read-only; - }; - - /* Secure image primary slot */ - slot0_partition: partition@14000 { - label = "image-0"; - reg = <0x00014000 DT_SIZE_K(224)>; - }; - - /* Non-secure image primary slot */ - slot1_partition: partition@4c000 { - label = "image-1"; - reg = <0x0004c000 DT_SIZE_K(172)>; - }; - - /* - * The flash starting at 0x7F000 and ending at - * 0x80000 is reserved for the application. - */ - storage_partition: partition@77000 { - label = "storage"; - reg = <0x0007f000 DT_SIZE_K(40)>; - }; - }; -}; diff --git a/samples/tfm_integration/tfm_regression_test/sample.yaml b/samples/tfm_integration/tfm_regression_test/sample.yaml deleted file mode 100644 index e94a2d490aae..000000000000 --- a/samples/tfm_integration/tfm_regression_test/sample.yaml +++ /dev/null @@ -1,47 +0,0 @@ -common: - tags: - - trusted-firmware-m - - mcuboot - modules: - - tf-m-tests - platform_allow: - # Disabling this platform as there are currently build issues at link - # time with 'tfm_platform_gpio_pin_mcu_select'. Since NS app is the official - # one from TF-M the fix has to be sumbitted upstream. - # - nrf5340dk/nrf5340/cpuapp/ns - - nrf9160dk/nrf9160/ns - - nrf9161dk/nrf9161/ns - - v2m_musca_s1/musca_s1/ns - - stm32h573i_dk/stm32h573xx/ns - - frdm_mcxn947/mcxn947/cpu0/ns - - frdm_mcxa577/mcxa577/ns - integration_platforms: - - nrf9161dk/nrf9161/ns - harness: console - harness_config: - type: multi_line - regex: - - "Non-Secure system starting..." - - "\\#\\#\\#\\# Execute test suites for the Non-secure area \\#\\#\\#\\#" - - "\\*\\*\\* End of Non-secure test suites \\*\\*\\*" - -sample: - name: "TFM Regression Test" - -tests: - sample.tfm.regression_ipc_lvl1: - extra_args: - - CONFIG_TFM_IPC=y - - CONFIG_TFM_ISOLATION_LEVEL=1 - timeout: 200 - - sample.tfm.regression_ipc_lvl2: - timeout: 200 - - sample.tfm.regression_sfn: - platform_allow: - - max32657evkit/max32657/ns - extra_args: - - CONFIG_TFM_SFN=y - - CONFIG_TFM_ISOLATION_LEVEL=1 - timeout: 200 diff --git a/scripts/build/gen_isr_tables_parser_carrays.py b/scripts/build/gen_isr_tables_parser_carrays.py index f85536da6112..55a220649c42 100755 --- a/scripts/build/gen_isr_tables_parser_carrays.py +++ b/scripts/build/gen_isr_tables_parser_carrays.py @@ -253,23 +253,58 @@ def __write_shared_table(self, fp): fp.write("};\n") - def write_source(self, fp): - fp.write(self.source_header) + def write_isr_switch_start(self, fp): + fp.write("void __sw_isr_table ") + fp.write("get_isr_entry(int irq_index, struct _isr_table_entry *entry)\n") + fp.write("{\n") + fp.write("\tswitch (irq_index)\n") + fp.write("\t{\n") + + def write_isr_case_block(self, fp, i, isr, arg): + fp.write(f"\t\tcase {i}:\n") + fp.write("\t\t{\n") + fp.write(f"\t\t\tentry->isr = (ISR){isr:#x};\n") + fp.write(f"\t\t\tentry->arg = (const void *){arg};\n") + fp.write("\t\t\tbreak;\n") + fp.write("\t\t}\n") + + def write_isr_case_single_irq(self, fp, i): + arg = f"{self.__swt[i][0][0]:#x}" + isr = self.__swt[i][0][1] + self.write_isr_case_block(fp, i, isr, arg) + + def write_isr_case_shared_irq(self, fp, i): + arg = f"&z_shared_sw_isr_table[{i}]" + isr = self.__config.swt_shared_handler + self.write_isr_case_block(fp, i, isr, arg) + + def write_isr_case_default_block(self, fp): + fp.write("\t\tdefault:\n") + fp.write("\t\t{\n") + fp.write(f"\t\t\tentry->isr = (ISR){self.__config.swt_spurious_handler};\n") + fp.write("\t\t\tentry->arg = (const void *)0x0;\n") + fp.write("\t\t\tbreak;\n") + fp.write("\t\t}\n") + fp.write("\t}\n") + fp.write("}\n") - if self.__config.check_shared_interrupts(): - self.__write_shared_table(fp) + def write_isr_table_switch(self, fp): + self.write_isr_switch_start(fp) - if self.__vt: - if self.__config.check_sym("CONFIG_IRQ_VECTOR_TABLE_JUMP_BY_ADDRESS"): - self.__write_address_irq_vector_table(fp) - elif self.__config.check_sym("CONFIG_IRQ_VECTOR_TABLE_JUMP_BY_CODE"): - self.__write_code_irq_vector_table(fp) + for i in range(self.__nv): + if len(self.__swt[i]) == 0: + # Unused interrupt - default will be used + continue + elif len(self.__swt[i]) == 1: + # Single interrupt + self.write_isr_case_single_irq(fp, i) else: - self.__log.error("CONFIG_IRQ_VECTOR_TABLE_JUMP_BY_{ADDRESS,CODE} not set") + # Shared interrupt + self.write_isr_case_shared_irq(fp, i) - if not self.__swt: - return + self.write_isr_case_default_block(fp) + def write_isr_table_array(self, fp): if not self.__config.check_sym("CONFIG_DYNAMIC_INTERRUPTS"): fp.write("const ") fp.write(f"struct _isr_table_entry __sw_isr_table _sw_isr_table[{self.__nv}] = {{\n") @@ -303,3 +338,29 @@ def write_source(self, fp): fp.write(f"\t{{(const void *){param}, (ISR){func_as_string}}}, /* {i} */\n") fp.write("};\n") + + def write_source(self, fp): + fp.write(self.source_header) + + if self.__config.check_shared_interrupts(): + self.__write_shared_table(fp) + + if self.__vt: + if self.__config.check_sym("CONFIG_IRQ_VECTOR_TABLE_JUMP_BY_ADDRESS"): + self.__write_address_irq_vector_table(fp) + elif self.__config.check_sym("CONFIG_IRQ_VECTOR_TABLE_JUMP_BY_CODE"): + self.__write_code_irq_vector_table(fp) + else: + self.__log.error("CONFIG_IRQ_VECTOR_TABLE_JUMP_BY_{ADDRESS,CODE} not set") + + if not self.__swt: + return + + fp.write("\n") + + if self.__config.get_sym("CONFIG_GEN_SW_ISR_TABLE_ARRAY"): + self.write_isr_table_array(fp) + elif self.__config.get_sym("CONFIG_GEN_SW_ISR_TABLE_SWITCH"): + self.write_isr_table_switch(fp) + else: + raise ValueError("Unsupported CONFIG_GEN_SW_ISR_TABLE_TYPE") diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index 9c3aa721b830..dfec13c96f7f 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -705,6 +705,46 @@ class KconfigCheck(ComplianceTest): # Kconfig symbol prefix/namespace. CONFIG_ = "CONFIG_" + # If modules should be excluded from checks. + EXCLUDE_MODULES = False + + # This block list contains a list of upstream Zephyr modules that should not be checked + # DO NOT MERGE CHANGES TO THIS WITHOUT BUILD SYSTEM AND CODE OWNER APPROVAL! + external_module_name_block_list = [ + 'canopennode', + 'chre', + 'cmsis', + 'cmsis-dsp', + 'cmsis-nn', + 'cmsis_6', + 'edtt', + 'fatfs', + 'hal_st', + 'hal_tdk', + 'hal_wurthelektronik', + 'liblc3', + 'libmetal', + 'littlefs', + 'loramac-node', + 'lvgl', + 'lz4', + 'mipi-sys-t', + 'nanopb', + 'net-tools', + 'nrf_hw_models', + 'open-amp', + 'percepio', + 'picolibc', + 'segger', + 'tf-m-tests', + 'tinycrypt', + 'uoscore-uedhoc', + 'zscilib', + ] + + # Holds a list or directories/files which should not be checked + blocked_module_dirs = [] + def run(self): kconf = self.parse_kconfig() @@ -746,6 +786,24 @@ def get_modules(self, _module_dirs_file, modules_file, sysbuild_modules_file, se modules_dir = ZEPHYR_BASE / 'modules' modules = [name for name in os.listdir(modules_dir) if modules_dir / name / 'Kconfig'] + nrf_modules_dir = (Path(ZEPHYR_BASE) / '..' / 'nrf' / 'modules').resolve() + nrf_modules = [] + + for module in modules: + if module in self.external_module_name_block_list: + self.blocked_module_dirs.append(modules_dir / module / 'Kconfig') + + 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')) + ] + + for module in nrf_modules: + if module in self.external_module_name_block_list: + self.blocked_module_dirs.append(nrf_modules_dir / module / 'Kconfig') + with open(modules_file) as fp_module_file: content = fp_module_file.read() @@ -757,8 +815,40 @@ def get_modules(self, _module_dirs_file, modules_file, sysbuild_modules_file, se 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', + ) + ) + + # Add NRF as static entry as workaround for ext Kconfig root support + fp_module_file.write( + "ZEPHYR_NRF_KCONFIG = {}\n".format( + nrf_modules_dir / '..' / 'Kconfig.nrf', + ) + ) fp_module_file.write(content) + with open(sysbuild_modules_file) as fp_sysbuild_module_file: + content = fp_sysbuild_module_file.read() + + with open(sysbuild_modules_file, 'w') as fp_sysbuild_module_file: + # Add NRF as static entry as workaround for ext Kconfig root support + fp_sysbuild_module_file.write( + "SYSBUILD_NRF_KCONFIG = {}\n".format( + nrf_modules_dir / '..' / 'sysbuild' / 'Kconfig.sysbuild', + ) + ) + fp_sysbuild_module_file.write(content) + def get_kconfig_dts(self, kconfig_dts_file, settings_file): """ Generate the Kconfig.dts using dts/bindings as the source. @@ -1303,9 +1393,33 @@ def check_no_enable_in_boolean_prompt(self, kconf): # Checks that boolean's prompt does not start with "Enable...". for node in kconf.node_iter(): - # skip Kconfig nodes not in-tree (will present an absolute path) + skip_node = False + + # skip Kconfig nodes not in-tree when set to (will present an absolute path) if os.path.isabs(node.filename): - continue + if self.EXCLUDE_MODULES is True: + continue + + normalised_file_name = Path(node.filename).resolve() + + for module_name in self.external_module_name_block_list: + # Workaround for being unable to use full_match() due to python version + if '/modules/' in str(normalised_file_name) and ( + '/' + module_name + '/' + ) in str(normalised_file_name): + skip_node = True + break + + if skip_node: + continue + + for blocked_dir in self.blocked_module_dirs: + if normalised_file_name.match(blocked_dir, case_sensitive=True): + skip_node = True + break + + if skip_node: + continue # 'kconfiglib' is global # pylint: disable=undefined-variable @@ -1444,6 +1558,10 @@ def check_no_undef_outside_kconfig(self, kconf): ":!/doc/releases", ":!/doc/develop/manifest/external", ":!/doc/security/vulnerabilities.rst", + ":!/doc/nrf/releases_and_maturity", + ":!/doc/nrf/libraries/bin/lwm2m_carrier/CHANGELOG.rst", + ":!/doc/nrf/app_dev/device_guides/nrf70/wifi_advanced_security_modes.rst", + ":!/doc/nrf-bm/release_notes", cwd=GIT_TOP, ) @@ -1657,6 +1775,80 @@ def check_no_undef_outside_kconfig(self, kconf): "ZTEST_FAIL_TEST_", # regex in tests/ztest/fail/CMakeLists.txt "ZVFS_OPEN_ADD_SIZE_", # Used as an option matching prefix # zephyr-keep-sorted-stop + # NCS-specific allow list + # zephyr-keep-sorted-start re(^\s+") + "APPLICATION", # Example documentation + "BAR", # Example documentation + "BOOT_IMAGE_ACCESS_HOOK", # MCUboot setting used in documentation + "BT_ADV_PROV_", # Documentation + "BT_CTLR_TX_PWR_MINUS", # CHIP documentation + "BT_CTLR_TX_PWR_MINUS_", # CHIP documentation + "BT_CTLR_TX_PWR_PLUS", # CHIP documentation + "BT_CTLR_TX_PWR_PLUS_", # CHIP documentation + "BT_SDC_ADDITIONAL_MEMORY", # From dragoon repo + "CHANNEL", # NRF desktop + "CHANNEL_FETCHED_DATA_MAX_SIZE", # NRF desktop + "CHANNEL_TRANSPORT_DISABLED", # NRF desktop + "CHANNEL_TRANSPORT_IDLE", # NRF desktop + "CHANNEL_TRANSPORT_RSP_READY", # NRF desktop + "CHANNEL_TRANSPORT_WAIT_RSP", # NRF desktop + "CHIP_DFU_OVER_BT_SMP", # CHIP module + "CHIP_LAST_FABRIC_REMOVED_ACTION_DELAY", # CHIP module + "CHIP_LAST_FABRIC_REMOVED_ERASE_AND_PAIRING_START", # CHIP module + "CHIP_LAST_FABRIC_REMOVED_ERASE_AND_REBOOT", # CHIP module + "CHIP_LAST_FABRIC_REMOVED_ERASE_ONLY", # CHIP module + "CHIP_LAST_FABRIC_REMOVED_NONE", # CHIP module + "CHIP_MEMORY_PROFILING", # CHIP module + "CHIP_NUS", # CHIP module + "CHIP_NUS_FIXED_PASSKEY", # CHIP module + "CHIP_NUS_MAX_COMMANDS", # CHIP module + "CHIP_NUS_MAX_COMMAND_LEN", # CHIP module + "CHIP_QSPI_NOR", # CHIP module + "CHIP_SPI_NOR", # CHIP module + "CHIP_WIFI", # CHIP module + "DESKTOP_DVFS_STATE_", # NRF desktop + "DESKTOP_DVFS_STATE_CONFIG_CHANNEL_ENABLE", # NRF desktop + "DESKTOP_DVFS_STATE_INITIALIZING_ENABLE", # NRF desktop + "DESKTOP_DVFS_STATE_LLPM_CONNECTED_ENABLE", # NRF desktop + "DESKTOP_DVFS_STATE_SMP_TRANSFER_ENABLE", # NRF desktop + "DESKTOP_DVFS_STATE_USB_CONNECTED_ENABLE", # NRF desktop + "FACTORY_DATA_CUSTOM_BACKEND", # CHIP module + "MEMFAULT_", # Documentation + "MEMFAULT_NCS", # Documentation + "MEMFAULT_NCS_", # Documentation + "MY_CUSTOM_CONFIG", # Example documentation + "MY_EXT_API_ENABLED", # Example documentation + "MY_EXT_API_REQUIRED", # Example documentation + "NCS_IS_VARIANT_IMAGE", # Build system defined symbol + "NCS_MCUBOOT_UUID_CID_IMAGE_0_VALUE", # MCUboot + "NCS_MCUBOOT_UUID_CID_IMAGE_1_VALUE", # MCUboot + "NCS_VARIANT_MERGE_KCONFIG", # Build system defined symbol + "NRF_MODEM_LIB_TRACE_BACKEND_MY_TRACE_BACKEND", # Documentation + "PM_PARTITION_SIZE", # Used in search link + "PM_PARTITION_SIZE_", # Used in documentation + "PM_PARTITION_SIZE_MEMFAULT_STORAGE", # Created by Kconfig template + "PM_PARTITION_SIZE_SETTINGS", # Created by Kconfig template + "SOC_NRF54H20_CPUSEC", # Internal + "SSF_SERVER_PSA_CRYPTO_SERVICE_ENABLED", # Internal + "STATUS_", # NRF desktop + "STATUS_COUNT", # NRF desktop + "STATUS_DISCONNECTED", # NRF desktop + "STATUS_FETCH", # NRF desktop + "STATUS_GET_BOARD_NAME", # NRF desktop + "STATUS_GET_HWID", # NRF desktop + "STATUS_GET_MAX_MOD_ID", # NRF desktop + "STATUS_GET_PEER", # NRF desktop + "STATUS_GET_PEERS_CACHE", # NRF desktop + "STATUS_INDEX_PEERS", # NRF desktop + "STATUS_LIST", # NRF desktop + "STATUS_PENDING", # NRF desktop + "STATUS_POS", # NRF desktop + "STATUS_REJECT", # NRF desktop + "STATUS_SET", # NRF desktop + "STATUS_SUCCESS", # NRF desktop + "STATUS_TIMEOUT", # NRF desktop + "STATUS_WRITE_FAIL", # NRF desktop + # zephyr-keep-sorted-stop } @@ -1684,6 +1876,7 @@ class KconfigBasicNoModulesCheck(KconfigBasicCheck): name = "KconfigBasicNoModules" path_hint = "" EMPTY_FILE_CONTENTS = "# Empty\n" + EXCLUDE_MODULES = True def get_modules(self, module_dirs_file, modules_file, sysbuild_modules_file, settings_file): with open(module_dirs_file, 'w') as fp_module_file: @@ -1731,6 +1924,31 @@ class SysbuildKconfigCheck(KconfigCheck): "OTHER_APP_IMAGE_PATH", # Used in sysbuild documentation as example "SECOND_SAMPLE", # Used in sysbuild documentation # zephyr-keep-sorted-stop + # NCS-specific allowlist + # zephyr-keep-sorted-start re(^\s+") + "APP_CPUNET_RUN", # Used by sample + "APP_DFU", # Used by sample + "BT_FAST_PAIR", # Legacy/removed, used in migration documentation + "COMP_DATA_LAYOUT_ARRAY", # Used by test + "COMP_DATA_LAYOUT_MULTIPLE", # Used by test + "COMP_DATA_LAYOUT_SINGLE", # Used by test + "DTM_NO_DFE", # Used by DTM application + "DTM_TRANSPORT_HCI", # Used by DTM application + "FIRMWARE_LOADER_IMAGE_ABC", # Used in documentation + "INCLUDE_REMOTE_IMAGE", # Used by machine learning application + "MCUBOOT_FPROTECT_ALLOW_COMBINED_REGIONS", # Used in migration documentation + "ML_APP_INCLUDE_REMOTE_IMAGE", # Used by machine learning application + "ML_APP_REMOTE_BOARD", # Used by machine learning application + "MY_APP_IMAGE_ABC", # Used in documentation + "NETCORE_ABC", # Used in documentation + "REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING", # Used in tests + "SOC_FLASH_NRF_RADIO_SYNC_RPC", # Used in documentation + "SUIT_ENVELOPE_", # Used by jinja + "SUIT_ENVELOPE_SEQUENCE_NUM", # Legacy/removed, used in migration documentation + "SUIT_MPI_", # Used by jinja + "SUIT_RECOVERY_APPLICATION_CUSTOM", # Used in documentation + "SUPPORT_NETCORE_PERIPHERAL_RADIO_TEST", # Used by wifi radio test sample + # zephyr-keep-sorted-stop } @@ -1754,6 +1972,7 @@ class SysbuildKconfigBasicNoModulesCheck(SysbuildKconfigCheck, KconfigBasicNoMod name = "SysbuildKconfigBasicNoModules" path_hint = "" + EXCLUDE_MODULES = True class Nits(ComplianceTest): 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/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-actions.txt b/scripts/requirements-actions.txt index c19521716478..275382dbdea6 100644 --- a/scripts/requirements-actions.txt +++ b/scripts/requirements-actions.txt @@ -51,7 +51,7 @@ certifi==2026.2.25 \ # via # elastic-transport # requests -cffi==2.0.0 ; platform_python_implementation != 'PyPy' \ +cffi==2.0.0 \ --hash=sha256:00bdf7acc5f795150faa6957054fbbca2439db2f775ce831222b66f192f03beb \ --hash=sha256:07b271772c100085dd28b74fa0cd81c8fb1a3ba18b21e03d7c27f3436a10606b \ --hash=sha256:087067fa8953339c723661eda6b54bc98c5625757ea62e95eb4898ad5e776e9f \ @@ -304,11 +304,7 @@ colorama==0.4.6 \ --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 # via # awscli - # click - # pylint - # pytest # tox - # tqdm # west cryptography==46.0.6 \ --hash=sha256:02fad249cb0e090b574e30b276a3da6a149e04ee2f049725b1f69e7b8351ec70 \ @@ -411,9 +407,9 @@ gitpython==3.1.46 \ --hash=sha256:400124c7d0ef4ea03f7310ac2fbf7151e09ff97f2a3288d64a440c584a29c37f \ --hash=sha256:79812ed143d9d25b6d176a10bb511de0f9c67b1fa641d82097b0ab90398a2058 # via -r requirements-actions.in -idna==3.11 \ - --hash=sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea \ - --hash=sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902 +idna==3.15 \ + --hash=sha256:048adeaf8c2d788c40fee287673ccaa74c24ffd8dcf09ffa555a2fbb59f10ac8 \ + --hash=sha256:ca962446ea538f7092a95e057da437618e886f4d349216d2b1e294abfdb65fdc # via requests ijson==3.5.0 \ --hash=sha256:009f41443e1521847701c6d87fa3923c0b1961be3c7e7de90947c8cb92ea7c44 \ @@ -550,7 +546,7 @@ junitparser==4.0.2 \ --hash=sha256:94c3570e41fcaedc64cc3c634ca99457fe41a84dd1aa8ff74e9e12e66223a155 \ --hash=sha256:d5d07cece6d4a600ff3b7b96c8db5ffa45a91eed695cb86c45c3db113c1ca0f8 # via -r requirements-actions.in -librt==0.8.1 ; platform_python_implementation != 'PyPy' \ +librt==0.8.1 \ --hash=sha256:01170b6729a438f0dedc4a26ed342e3dc4f02d1000b4b19f980e1877f0c297e6 \ --hash=sha256:039b9f2c506bd0ab0f8725aa5ba339c6f0cd19d3b514b50d134789809c24285d \ --hash=sha256:05bd41cdee35b0c59c259f870f6da532a2c5ca57db95b5f23689fcb5c9e42440 \ @@ -999,7 +995,7 @@ pyasn1==0.6.3 \ --hash=sha256:697a8ecd6d98891189184ca1fa05d1bb00e2f84b5977c481452050549c8a72cf \ --hash=sha256:a80184d120f0864a52a073acc6fc642847d0be408e7c7252f31390c0f4eadcde # via rsa -pycparser==3.0 ; implementation_name != 'PyPy' and platform_python_implementation != 'PyPy' \ +pycparser==3.0 \ --hash=sha256:600f49d217304a5902ac3c37e1281c9fe94e4d0489de643a9504c5cdfdfc6b29 \ --hash=sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992 # via cffi @@ -1017,7 +1013,7 @@ pygments==2.19.2 \ # via # gcovr # pytest -pyjwt==2.12.1 \ +pyjwt[crypto]==2.12.1 \ --hash=sha256:28ca37c070cad8ba8cd9790cd940535d40274d22f80ab87f3ac6a713e6e8454c \ --hash=sha256:c74a7a2adf861c04d002db713dd85f84beb242228e671280bf709d765b03672b # via pygithub @@ -1098,17 +1094,12 @@ python-dotenv==1.2.2 \ --hash=sha256:1d8214789a24de455a8b8bd8ae6fe3c6b69a5e3d64aa8a8e5d68e694bbcb285a \ --hash=sha256:2c371a91fbd7ba082c2c1dc1f8bf89ca22564a087c2c287cd9b662adde799cf3 # via -r requirements-actions.in -python-magic==0.4.27 \ +python-magic==0.4.27 ; sys_platform != "win32" \ --hash=sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b \ --hash=sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3 # via # -r requirements-actions.in # reuse -python-magic-bin==0.4.14 ; sys_platform == 'win32' \ - --hash=sha256:34a788c03adde7608028203e2dbb208f1f62225ad91518787ae26d603ae68892 \ - --hash=sha256:7b1743b3dbf16601d6eedf4e7c2c9a637901b0faaf24ad4df4d4527e7d8f66a4 \ - --hash=sha256:90be6206ad31071a36065a2fc169c5afb5e0355cbe6030e87641c6c62edc2b69 - # via -r requirements-actions.in pyyaml==6.0.3 \ --hash=sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c \ --hash=sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a \ @@ -1479,11 +1470,7 @@ semantic-version==2.10.0 \ --hash=sha256:bdabb6d336998cbb378d4b9db3a4b56a1e3235701dc05ea2690d9a997ed5041c \ --hash=sha256:de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177 # via spdx-tools -setuptools==82.0.1 \ - --hash=sha256:7d872682c5d01cfde07da7bccc7b65469d3dca203318515ada1de5eda35efbf9 \ - --hash=sha256:a59e362652f08dcd477c78bb6e7bd9d80a7995bc73ce773050228a348ce2e5bb - # via -r requirements-actions.in -sh==2.2.2 ; sys_platform != 'win32' \ +sh==2.2.2 \ --hash=sha256:653227a7c41a284ec5302173fbc044ee817c7bad5e6e4d8d55741b9aeb9eb65b \ --hash=sha256:e0b15b4ae8ffcd399bc8ffddcbd770a43c7a70a24b16773fbb34c001ad5d52af # via gitlint-core @@ -1530,11 +1517,9 @@ typing-extensions==4.15.0 \ --hash=sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548 # via # elasticsearch - # exceptiongroup # mypy # pygithub # python-can - # referencing tzdata==2025.3 \ --hash=sha256:06a47e5700f3081aab02b2e513160914ff0694bce9947d6b76ebd6bf57cfc5d1 \ --hash=sha256:de39c2ca5dc7b0344f2eba86f49d614019d29f060fc4ebc8a417896a620b56a7 diff --git a/scripts/west_commands/build.py b/scripts/west_commands/build.py index 10ea4644e687..7d99fbd5c2f9 100644 --- a/scripts/west_commands/build.py +++ b/scripts/west_commands/build.py @@ -663,7 +663,12 @@ def _run_cmake(self, board, origin): if user_args: cmake_opts.extend(shlex.split(user_args)) - config_sysbuild = config_getboolean('sysbuild', False) + config_sysbuild = config_getboolean('sysbuild', []) + + if config_sysbuild == []: + # If no option is set, then enable sysbuild globally + config_sysbuild = True + if self.args.sysbuild is True or (config_sysbuild and self.args.sysbuild is not False): cmake_opts.extend([f'-S{SYSBUILD_PROJ_DIR}']) cmake_env = os.environ.copy() diff --git a/scripts/west_commands/runners/core.py b/scripts/west_commands/runners/core.py index ef90eee4b3f9..f5389661563a 100644 --- a/scripts/west_commands/runners/core.py +++ b/scripts/west_commands/runners/core.py @@ -781,9 +781,13 @@ def flash_address_from_build_conf(build_conf: BuildConfiguration): @staticmethod def sram_address_from_build_conf(build_conf: BuildConfiguration): - '''return CONFIG_SRAM_BASE_ADDRESS. + '''return SRAM address. ''' - return build_conf['CONFIG_SRAM_BASE_ADDRESS'] + if build_conf.getboolean('CONFIG_SRAM_DEPRECATED_KCONFIG_SET'): + return build_conf['CONFIG_SRAM_BASE_ADDRESS'] + else: + sram_node = build_conf.edt.chosen_node('zephyr,sram') + return sram_node.regs[0].addr def run(self, command: str, **kwargs): '''Runs command ('flash', 'debug', 'debugserver', 'attach'). diff --git a/scripts/west_commands/runners/nrf_common.py b/scripts/west_commands/runners/nrf_common.py index e47dd73f4a38..f1fe179474b4 100644 --- a/scripts/west_commands/runners/nrf_common.py +++ b/scripts/west_commands/runners/nrf_common.py @@ -305,22 +305,15 @@ def recover_target(self): def _get_core(self): if self.family in ('nrf54h', 'nrf92'): - if (self.build_conf.getboolean('CONFIG_SOC_NRF54H20_CPUAPP') or - self.build_conf.getboolean('CONFIG_SOC_NRF54H20_CPUFLPR') or - self.build_conf.getboolean('CONFIG_SOC_NRF54H20_CPUPPR') or - self.build_conf.getboolean('CONFIG_SOC_NRF9280_CPUAPP')): - return 'Application' if (self.build_conf.getboolean('CONFIG_SOC_NRF54H20_CPURAD') or self.build_conf.getboolean('CONFIG_SOC_NRF9280_CPURAD')): return 'Network' - raise RuntimeError(f'Core not found for family: {self.family}') + return 'Application' if self.family in ('nrf53'): - if self.build_conf.getboolean('CONFIG_SOC_NRF5340_CPUAPP'): - return 'Application' if self.build_conf.getboolean('CONFIG_SOC_NRF5340_CPUNET'): return 'Network' - raise RuntimeError(f'Core not found for family: {self.family}') + return 'Application' return None diff --git a/share/sysbuild/cmake/modules/sysbuild_extensions.cmake b/share/sysbuild/cmake/modules/sysbuild_extensions.cmake index d19dcb2c74f2..0aa1c8b6cb2d 100644 --- a/share/sysbuild/cmake/modules/sysbuild_extensions.cmake +++ b/share/sysbuild/cmake/modules/sysbuild_extensions.cmake @@ -543,6 +543,11 @@ function(ExternalZephyrVariantProject_Add) endif() endforeach() + # Add the variant image CMake module path to replace the normal Zephyr module path + list(APPEND shared_cmake_vars_argument + "-DCMAKE_MODULE_PATH:PATH=${CMAKE_SOURCE_DIR}/cmake/zephyr/variant" + ) + set(list_separator ",") include(ExternalProject) diff --git a/share/sysbuild/cmake/zephyr/variant/dts.cmake b/share/sysbuild/cmake/zephyr/variant/dts.cmake new file mode 100644 index 000000000000..d99824190443 --- /dev/null +++ b/share/sysbuild/cmake/zephyr/variant/dts.cmake @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: Apache-2.0 + +include_guard(GLOBAL) + +include(${ZEPHYR_BASE}/cmake/modules/dts.cmake) + +function(variant_dts_configuration_files) + zephyr_get(DTS_SOURCE SYSBUILD LOCAL) + set(dts_files ${DTS_SOURCE}) + + if(EXTRA_DTC_OVERLAY_FILE) + zephyr_list(TRANSFORM EXTRA_DTC_OVERLAY_FILE NORMALIZE_PATHS + OUTPUT_VARIABLE EXTRA_DTC_OVERLAY_FILE_AS_LIST + ) + build_info(devicetree extra-user-files PATH ${EXTRA_DTC_OVERLAY_FILE_AS_LIST}) + list(APPEND + dts_files + ${EXTRA_DTC_OVERLAY_FILE_AS_LIST} + ) + endif() + + set(i 0) + foreach(dts_file ${dts_files}) + if(i EQUAL 0) + message(STATUS "Found BOARD.dts: ${dts_file}") + else() + message(STATUS "Found devicetree overlay: ${dts_file}") + endif() + + math(EXPR i "${i}+1") + endforeach() + + unset(DTS_ROOT_BINDINGS) + foreach(dts_root ${DTS_ROOT}) + set(bindings_path ${dts_root}/dts/bindings) + if(EXISTS ${bindings_path}) + list(APPEND + DTS_ROOT_BINDINGS + ${bindings_path} + ) + endif() + + set(vendor_prefixes ${dts_root}/${VENDOR_PREFIXES}) + if(EXISTS ${vendor_prefixes}) + list(APPEND EXTRA_GEN_EDT_ARGS --vendor-prefixes ${vendor_prefixes}) + endif() + + set(DTS_ROOT_BINDINGS ${DTS_ROOT_BINDINGS} PARENT_SCOPE) + endforeach() + + # Cache the location of the root bindings so they can be used by + # scripts which use the build directory. + set(CACHED_DTS_ROOT_BINDINGS ${DTS_ROOT_BINDINGS} CACHE INTERNAL + "DT bindings root directories" + ) + set(dts_files ${dts_files} PARENT_SCOPE) + set(DTS_SOURCE ${DTS_SOURCE} PARENT_SCOPE) + set(EXTRA_GEN_EDT_ARGS ${EXTRA_GEN_EDT_ARGS} PARENT_SCOPE) +endfunction() + +macro(dts_init) + variant_dts_configuration_files() + dts_edt_pickle() + dts_gen_defines() + dts_gen_driver_kconfig() + dts_import() + dts_dtc() + dts_build_info_output() +endmacro() diff --git a/share/sysbuild/images/bootloader/Kconfig b/share/sysbuild/images/bootloader/Kconfig index 40790490cda6..01849e54210e 100644 --- a/share/sysbuild/images/bootloader/Kconfig +++ b/share/sysbuild/images/bootloader/Kconfig @@ -153,6 +153,7 @@ endchoice config MCUBOOT_DIRECT_XIP_GENERATE_VARIANT bool "Generate slot 1 variant image [EXPERIMENTAL]" depends on MCUBOOT_MODE_DIRECT_XIP || MCUBOOT_MODE_DIRECT_XIP_WITH_REVERT + depends on !PARTITION_MANAGER select EXPERIMENTAL default y help diff --git a/share/zephyr-package/cmake/ZephyrConfig.cmake b/share/zephyr-package/cmake/ZephyrConfig.cmake index d7854e43cc82..a83cb266f970 100644 --- a/share/zephyr-package/cmake/ZephyrConfig.cmake +++ b/share/zephyr-package/cmake/ZephyrConfig.cmake @@ -29,7 +29,7 @@ macro(include_boilerplate location) set(Zephyr_DIR ${ZEPHYR_BASE}/share/zephyr-package/cmake CACHE PATH "The directory containing a CMake configuration file for Zephyr." FORCE ) - list(PREPEND CMAKE_MODULE_PATH ${ZEPHYR_BASE}/cmake/modules) + list(APPEND CMAKE_MODULE_PATH ${ZEPHYR_BASE}/cmake/modules) if(ZEPHYR_UNITTEST) zephyr_package_message(DEPRECATION "The ZephyrUnittest CMake package has been deprecated.\n" "ZephyrUnittest has been replaced with Zephyr CMake module 'unittest' \n" diff --git a/snippets/bt-ll-sw-split/bt-ll-sw-split.overlay b/snippets/bt-ll-sw-split/bt-ll-sw-split.overlay index 04bf83ef44d4..a57a0e82ba6e 100644 --- a/snippets/bt-ll-sw-split/bt-ll-sw-split.overlay +++ b/snippets/bt-ll-sw-split/bt-ll-sw-split.overlay @@ -2,6 +2,10 @@ status = "okay"; }; +&bt_hci_sdc { + status = "disabled"; +}; + / { chosen { zephyr,bt-hci = &bt_hci_controller; diff --git a/soc/nordic/Kconfig b/soc/nordic/Kconfig index 6a8b8a0810e4..683047042031 100644 --- a/soc/nordic/Kconfig +++ b/soc/nordic/Kconfig @@ -219,7 +219,7 @@ endchoice config NRF_SKIP_CLOCK_CONFIG bool prompt "Skip clock frequency configuration" if TRUSTED_EXECUTION_SECURE - depends on NRF_PLATFORM_LUMOS + depends on SOC_SERIES_NRF54L || SOC_SERIES_NRF71 default y if TRUSTED_EXECUTION_NONSECURE help With this option, the CPU clock frequency is not set during system initialization. @@ -233,18 +233,34 @@ config NRF_TRACE_PORT Unit) for tracing using a hardware probe. If disabled, the trace pins will be used as GPIO. +config NRF_CUSTOM_ON_ENTER_CPU_IDLE_HOOK + bool "Custom on enter CPU idle hook" + depends on ARM_ON_ENTER_CPU_IDLE_HOOK + help + Select this option to use a custom on enter CPU idle hook. If enabled, + the hook is implemented by the user. It is the user's responsibility to + implement the SoC-specific code in the hook that is present in the default + implementation. + +# Backward-compatibility aliases for symbols removed during the Haltium / Lumos +# Kconfig cleanup. Slated for removal in a future release. + config NRF_PLATFORM_HALTIUM - bool + bool "[DEPRECATED] Replaced by SOC_SERIES_NRF54H / SOC_SERIES_NRF92" + default y if SOC_SERIES_NRF54H || SOC_SERIES_NRF92 + select DEPRECATED help - SoC series based on the Nordic nRF Haltium platform need to select - this option. This allows to easily enable common functionality on - SoCs based on the Haltium platform. + This option has been removed. Use SOC_SERIES_NRF54H or SOC_SERIES_NRF92 + directly. The symbol is kept temporarily so that out-of-tree code that + still references it continues to build, with a deprecation warning. config NRF_PLATFORM_LUMOS - bool + bool "[DEPRECATED] Replaced by SOC_SERIES_NRF54L / SOC_SERIES_NRF71" + default y if SOC_SERIES_NRF54L || SOC_SERIES_NRF71 + select DEPRECATED help - SoC series based on the Nordic nRF Lumos platform such as nRF54Lx - series. This allows to easily enable common functionality on - SoCs based on the Lumos platform. + This option has been removed. Use SOC_SERIES_NRF54L or SOC_SERIES_NRF71 + directly. The symbol is kept temporarily so that out-of-tree code that + still references it continues to build, with a deprecation warning. endif # SOC_FAMILY_NORDIC_NRF diff --git a/soc/nordic/Kconfig.defconfig b/soc/nordic/Kconfig.defconfig index b1490a2f338c..7972374e57c2 100644 --- a/soc/nordic/Kconfig.defconfig +++ b/soc/nordic/Kconfig.defconfig @@ -7,11 +7,8 @@ if SOC_FAMILY_NORDIC_NRF rsource "*/Kconfig.defconfig" -# If the kernel has timer support, enable clock control, except for SoCs -# based on the Haltium platform SoCs where clock control is not needed -# for the system timer config CLOCK_CONTROL - default y if SYS_CLOCK_EXISTS && !NRF_PLATFORM_HALTIUM && !RISCV_CORE_NORDIC_VPR + default y if SYS_CLOCK_EXISTS && !SOC_SERIES_NRF54H && !SOC_SERIES_NRF92 && !RISCV_CORE_NORDIC_VPR config SYS_CLOCK_TICKS_PER_SEC default 128 if !TICKLESS_KERNEL diff --git a/soc/nordic/common/CMakeLists.txt b/soc/nordic/common/CMakeLists.txt index 163184c1ad25..7d1feb04c76a 100644 --- a/soc/nordic/common/CMakeLists.txt +++ b/soc/nordic/common/CMakeLists.txt @@ -16,14 +16,7 @@ endif() zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c) -if(CONFIG_NRF_PLATFORM_HALTIUM AND CONFIG_ARM) - zephyr_library_sources(haltium_power.c) - zephyr_code_relocate( - FILES haltium_power.c - FILTER ".*\\.cache_retain_and_sleep" - LOCATION PMLocalRamfunc_TEXT - ) - zephyr_library_sources_ifdef(CONFIG_PM_S2RAM haltium_pm_s2ram.c) +if((CONFIG_SOC_SERIES_NRF54H OR CONFIG_SOC_SERIES_NRF92) AND CONFIG_ARM) zephyr_library_sources_ifdef(CONFIG_CPU_HAS_CUSTOM_FIXED_SOC_MPU_REGIONS nrf54hx_nrf92x_mpu_regions.c) zephyr_library_sources(soc_lrcconf.c) endif() @@ -36,6 +29,7 @@ endif() if(CONFIG_NRFX_GPPI AND NOT CONFIG_NRFX_GPPI_V1) zephyr_library_sources(gppi_init.c) + zephyr_library_sources_ifdef(CONFIG_NRFX_GPPI_SD2PPI_GLOBAL nrfx_gppi_sd2ppi_global.c) endif() if(CONFIG_TFM_PARTITION_PLATFORM) diff --git a/soc/nordic/common/Kconfig b/soc/nordic/common/Kconfig index f1c31e46551b..7c522cc0ce69 100644 --- a/soc/nordic/common/Kconfig +++ b/soc/nordic/common/Kconfig @@ -19,7 +19,7 @@ config NRF_FORCE_RAM_ON_REBOOT config NRF_SYS_EVENT bool "nRF system event support" - select NRFX_POWER if !NRF_PLATFORM_HALTIUM + select NRFX_POWER if !SOC_SERIES_NRF54H && !SOC_SERIES_NRF92 if NRF_SYS_EVENT diff --git a/soc/nordic/common/Kconfig.peripherals b/soc/nordic/common/Kconfig.peripherals index e54ba6f21f92..0ae024e00bef 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_NRF91) 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)) diff --git a/soc/nordic/common/gppi_init.c b/soc/nordic/common/gppi_init.c index afa5c9fb2583..3615826583cc 100644 --- a/soc/nordic/common/gppi_init.c +++ b/soc/nordic/common/gppi_init.c @@ -7,8 +7,8 @@ #include #if defined(NRFX_GPPI_MULTI_DOMAIN) && !defined(NRFX_GPPI_FIXED_CONNECTIONS) #include -#elif defined(CONFIG_SOC_NRF54H20_CPUAPP) -#include +#elif defined(CONFIG_NRFX_GPPI_SD2PPI_GLOBAL) +#include #elif defined(CONFIG_SOC_NRF54H20_CPURAD) #include #endif @@ -51,7 +51,7 @@ static int gppi_init(void) NRFX_BIT_MASK(DPPIC20_GROUP_NUM_SIZE) & ~NRFX_DPPI20_GROUPS_USED); nrfx_gppi_groups_init(NRFX_GPPI_NODE_DPPIC30, NRFX_BIT_MASK(DPPIC30_GROUP_NUM_SIZE) & ~NRFX_DPPI30_GROUPS_USED); -#elif defined(CONFIG_SOC_NRF54H20_CPUAPP) +#elif defined(CONFIG_NRFX_GPPI_SD2PPI_GLOBAL) gppi_instance.routes = nrfx_gppi_routes_get(); gppi_instance.route_map = nrfx_gppi_route_map_get(); gppi_instance.nodes = nrfx_gppi_nodes_get(); @@ -67,10 +67,14 @@ static int gppi_init(void) BIT_MASK(DT_PROP(DT_NODELABEL(dppic133), channels))); nrfx_gppi_channel_init(NRFX_GPPI_NODE_DPPIC134, BIT_MASK(DT_PROP(DT_NODELABEL(dppic134), channels))); +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) nrfx_gppi_channel_init(NRFX_GPPI_NODE_DPPIC135, BIT_MASK(DT_PROP(DT_NODELABEL(dppic135), channels))); +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) nrfx_gppi_channel_init(NRFX_GPPI_NODE_DPPIC136, BIT_MASK(DT_PROP(DT_NODELABEL(dppic136), channels))); +#endif nrfx_gppi_channel_init(NRFX_GPPI_NODE_DPPIC120, BIT_MASK(DT_PROP(DT_NODELABEL(dppic120), channels))); @@ -85,10 +89,14 @@ static int gppi_init(void) BIT_MASK(DT_PROP(DT_NODELABEL(dppic133), groups))); nrfx_gppi_groups_init(NRFX_GPPI_NODE_DPPIC134, BIT_MASK(DT_PROP(DT_NODELABEL(dppic134), groups))); +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) nrfx_gppi_groups_init(NRFX_GPPI_NODE_DPPIC135, BIT_MASK(DT_PROP(DT_NODELABEL(dppic135), groups))); +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) nrfx_gppi_groups_init(NRFX_GPPI_NODE_DPPIC136, BIT_MASK(DT_PROP(DT_NODELABEL(dppic136), groups))); +#endif nrfx_gppi_groups_init(NRFX_GPPI_NODE_DPPIC120, BIT_MASK(DT_PROP(DT_NODELABEL(dppic120), groups))); @@ -101,10 +109,14 @@ static int gppi_init(void) BIT_MASK(DT_PROP(DT_NODELABEL(ppib134), channels))); nrfx_gppi_channel_init(NRFX_GPPI_NODE_PPIB130_135, BIT_MASK(DT_PROP(DT_NODELABEL(ppib135), channels))); +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) nrfx_gppi_channel_init(NRFX_GPPI_NODE_PPIB131_136, BIT_MASK(DT_PROP(DT_NODELABEL(ppib136), channels))); +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) nrfx_gppi_channel_init(NRFX_GPPI_NODE_PPIB131_137, BIT_MASK(DT_PROP(DT_NODELABEL(ppib137), channels))); +#endif nrfx_gppi_channel_init(NRFX_GPPI_NODE_PPIB131_121, BIT_MASK(DT_PROP(DT_NODELABEL(ppib121), channels))); #elif defined(CONFIG_SOC_NRF54H20_CPURAD) @@ -131,11 +143,12 @@ static int gppi_init(void) #if defined(CONFIG_NRFX_GPPI) && !defined(CONFIG_NRFX_GPPI_V1) -/* For nrf54h20 GPPI requires that ironside communication is up so delay the initialization. */ -#define GPPI_INIT_STATE COND_CODE_1(IS_ENABLED(CONFIG_SOC_NRF54H20_CPUAPP), (POST_KERNEL), (EARLY)) +/* For SD2PPI GPPI it is required that ironside communication is up so delay the initialization. */ +#define GPPI_INIT_STATE \ + COND_CODE_1(IS_ENABLED(CONFIG_NRFX_GPPI_SD2PPI_GLOBAL), (POST_KERNEL), (EARLY)) #define GPPI_INIT_PRIO \ - COND_CODE_1(IS_ENABLED(CONFIG_SOC_NRF54H20_CPUAPP), \ + COND_CODE_1(IS_ENABLED(CONFIG_NRFX_GPPI_SD2PPI_GLOBAL), \ (UTIL_INC(CONFIG_IRONSIDE_SE_CALL_INIT_PRIORITY)), (0)) SYS_INIT(gppi_init, GPPI_INIT_STATE, GPPI_INIT_PRIO); diff --git a/soc/nordic/common/haltium_pm_s2ram.h b/soc/nordic/common/haltium_pm_s2ram.h index 565afad6ca10..c145b755058a 100644 --- a/soc/nordic/common/haltium_pm_s2ram.h +++ b/soc/nordic/common/haltium_pm_s2ram.h @@ -4,28 +4,19 @@ */ /** - * @file Common pm_s2ram.h include for Nordic SoCs. + * @file + * @brief [DEPRECATED] Backward-compatibility layer for . + * + * This header has been renamed to . The file exists so that + * out-of-tree code using the old include path keeps building during the + * deprecation period. It will be removed in a future release. */ -#ifndef _ZEPHYR_SOC_ARM_NORDIC_NRF_PM_S2RAM_H_ -#define _ZEPHYR_SOC_ARM_NORDIC_NRF_PM_S2RAM_H_ +#ifndef ZEPHYR_SOC_NORDIC_COMMON_HALTIUM_PM_S2RAM_H_ +#define ZEPHYR_SOC_NORDIC_COMMON_HALTIUM_PM_S2RAM_H_ -/** - * @brief Save CPU state on suspend - * - * This function is used on suspend-to-RAM (S2RAM) to save the CPU state in - * (retained) RAM before powering the system off using the provided function. - * This function is usually called from the PM subsystem / hooks. - * - * The CPU state consist of internal registers and peripherals like - * interrupt controller, memory controllers, etc. - * - * @param system_off Function to power off the system. - * - * @retval 0 The CPU context was successfully saved and restored. - * @retval -EBUSY The system is busy and cannot be suspended at this time. - * @retval -errno Negative errno code in case of failure. - */ -int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off); +#warning " is deprecated, include instead" + +#include -#endif /* _ZEPHYR_SOC_ARM_NORDIC_NRF_PM_S2RAM_H_ */ +#endif /* ZEPHYR_SOC_NORDIC_COMMON_HALTIUM_PM_S2RAM_H_ */ diff --git a/soc/nordic/common/haltium_power.h b/soc/nordic/common/haltium_power.h index e9bac733cf19..7ed8644a0375 100644 --- a/soc/nordic/common/haltium_power.h +++ b/soc/nordic/common/haltium_power.h @@ -4,30 +4,19 @@ */ /** - * @file Common power.h include for Nordic Haltium SoCs. - */ - -#ifndef _ZEPHYR_SOC_ARM_NORDIC_NRF_HALTIUM_POWER_H_ -#define _ZEPHYR_SOC_ARM_NORDIC_NRF_HALTIUM_POWER_H_ - -/** - * @brief Power domain early init. + * @file + * @brief [DEPRECATED] Backward-compatibility layer for . * + * This header has been renamed to . The file exists so that + * out-of-tree code using the old include path keeps building during the + * deprecation period. It will be removed in a future release. */ -void nrf_power_domain_init(void); -#if defined(CONFIG_PM) || defined(CONFIG_POWEROFF) -/** - * @brief Perform a power off. - * - * This function performs a power off of the core. - */ -void nrf_poweroff(void); +#ifndef ZEPHYR_SOC_NORDIC_COMMON_HALTIUM_POWER_H_ +#define ZEPHYR_SOC_NORDIC_COMMON_HALTIUM_POWER_H_ -/** - * @brief Power up and enable instruction and data cache. - */ -void nrf_power_up_cache(void); -#endif /* defined(CONFIG_PM) || defined(CONFIG_POWEROFF) */ +#warning " is deprecated, include instead" + +#include -#endif /* _ZEPHYR_SOC_ARM_NORDIC_NRF_HALTIUM_POWER_H_ */ +#endif /* ZEPHYR_SOC_NORDIC_COMMON_HALTIUM_POWER_H_ */ diff --git a/soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c b/soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c index 303fdf8ac8ae..62d4af22bbf8 100644 --- a/soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c +++ b/soc/nordic/common/nrf54hx_nrf92x_mpu_regions.c @@ -22,6 +22,9 @@ #define SOFTPERIPH_BASE DT_REG_ADDR(DT_NODELABEL(softperiph_ram)) #define SOFTPERIPH_SIZE DT_REG_SIZE(DT_NODELABEL(softperiph_ram)) +#define RAM_BASE DT_REG_ADDR(DT_CHOSEN(zephyr_sram)) +#define RAM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) + static struct arm_mpu_region mpu_regions[] = { #ifdef CONFIG_XIP MPU_REGION_ENTRY("FLASH_0", @@ -30,9 +33,8 @@ static struct arm_mpu_region mpu_regions[] = { CONFIG_FLASH_SIZE * 1024)), #endif MPU_REGION_ENTRY("SRAM_0", - CONFIG_SRAM_BASE_ADDRESS, - REGION_RAM_ATTR(CONFIG_SRAM_BASE_ADDRESS, - CONFIG_SRAM_SIZE * 1024)), + RAM_BASE, + REGION_RAM_ATTR(RAM_BASE, RAM_SIZE)), #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(usbhs)) MPU_REGION_ENTRY("USBHS_CORE", USBHS_BASE, diff --git a/soc/nordic/common/nrfx_gppi_sd2ppi_global.c b/soc/nordic/common/nrfx_gppi_sd2ppi_global.c new file mode 100644 index 000000000000..8742a4db6372 --- /dev/null +++ b/soc/nordic/common/nrfx_gppi_sd2ppi_global.c @@ -0,0 +1,519 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "nrfx_gppi_sd2ppi_global.h" +#include + +static nrfx_atomic_t channels[NRFX_GPPI_NODE_COUNT]; +static nrfx_atomic_t group_channels[NRFX_GPPI_NODE_DPPI_COUNT]; +static struct periphconf_entry write_entries[1]; +static size_t write_entries_count; + +#define PPIB_REG(id) (NRF_PPIB_Type *)DT_REG_ADDR(DT_NODELABEL(ppib##id)) +#define PPIB_OFF(id) DT_PROP_OR(DT_NODELABEL(ppib##id), offset, 0) + +#define _NRFX_GPPI_PPIB_EXT_NODE_DEFINE(_id1, _id2) \ + [NRFX_GPPI_NODE_PPIB##_id1##_##_id2] = { \ + .type = NRFX_GPPI_NODE_PPIB, \ + .domain_id = NRFX_GPPI_NODE_PPIB##_id1##_##_id2, \ + .ch_off = { PPIB_OFF(_id2), 0 }, \ + .ppib = { \ + .p_channels = &channels[NRFX_GPPI_NODE_PPIB##_id1##_##_id2], \ + .p_reg = { PPIB_REG(_id1), PPIB_REG(_id2) } \ + } \ + } + +/** @brief Conditionally create PPIB node. + * + * Node is created if both ppib nodes exist. If node exists then comma is added so macro should not + * be followed by the comma. + * + * @param _id1 PPIB node ID. + * @param _id2 PPIB node ID. + */ +#define NRFX_GPPI_PPIB_EXT_NODE_DEFINE(_id1, _id2) \ + IF_ENABLED(UTIL_AND(DT_NODE_EXISTS(DT_NODELABEL(ppib##_id1)), \ + DT_NODE_EXISTS(DT_NODELABEL(ppib##_id2))), \ + (_NRFX_GPPI_PPIB_EXT_NODE_DEFINE(_id1, _id2),)) + +/** @brief Conditionally create DPPI node. + * + * Node is created if dppic node exists. If node exists then comma is added so macro should not be + * followed by the comma. + */ +#define DPPI_NODE_DEFINE(_node_id) \ + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic##_node_id)), \ + (NRFX_GPPI_DPPI_NODE_DEFINE(_node_id, NRFX_GPPI_NODE_DPPIC##_node_id),)) + +static const nrfx_gppi_node_t nodes[] = { + /* DPPI nodes */ + DPPI_NODE_DEFINE(130) + DPPI_NODE_DEFINE(131) + DPPI_NODE_DEFINE(132) + DPPI_NODE_DEFINE(133) + DPPI_NODE_DEFINE(134) + DPPI_NODE_DEFINE(135) + DPPI_NODE_DEFINE(136) + DPPI_NODE_DEFINE(120) + + /* PPIB nodes */ + NRFX_GPPI_PPIB_EXT_NODE_DEFINE(130, 132) + NRFX_GPPI_PPIB_EXT_NODE_DEFINE(130, 133) + NRFX_GPPI_PPIB_EXT_NODE_DEFINE(130, 134) + NRFX_GPPI_PPIB_EXT_NODE_DEFINE(130, 135) + NRFX_GPPI_PPIB_EXT_NODE_DEFINE(131, 136) + NRFX_GPPI_PPIB_EXT_NODE_DEFINE(131, 137) + NRFX_GPPI_PPIB_EXT_NODE_DEFINE(131, 121) +}; + +enum nrfx_gppi_route_id { + NRFX_GPPI_ROUTE_ID_130, + NRFX_GPPI_ROUTE_ID_131, + NRFX_GPPI_ROUTE_ID_132, + NRFX_GPPI_ROUTE_ID_133, + NRFX_GPPI_ROUTE_ID_134, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_ROUTE_ID_135,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_ROUTE_ID_136,)) + NRFX_GPPI_ROUTE_ID_120, + NRFX_GPPI_ROUTE_ID_130_131, + NRFX_GPPI_ROUTE_ID_130_132, + NRFX_GPPI_ROUTE_ID_130_133, + NRFX_GPPI_ROUTE_ID_130_134, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_ROUTE_ID_130_135,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_ROUTE_ID_130_136,)) + NRFX_GPPI_ROUTE_ID_130_120, + NRFX_GPPI_ROUTE_ID_131_132, + NRFX_GPPI_ROUTE_ID_131_133, + NRFX_GPPI_ROUTE_ID_131_134, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_ROUTE_ID_131_135,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_ROUTE_ID_131_136,)) + NRFX_GPPI_ROUTE_ID_131_120, + NRFX_GPPI_ROUTE_ID_132_133, + NRFX_GPPI_ROUTE_ID_132_134, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_ROUTE_ID_132_135,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_ROUTE_ID_132_136,)) + NRFX_GPPI_ROUTE_ID_132_120, + NRFX_GPPI_ROUTE_ID_133_134, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_ROUTE_ID_133_135,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_ROUTE_ID_133_136,)) + NRFX_GPPI_ROUTE_ID_133_120, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_ROUTE_ID_134_135,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_ROUTE_ID_134_136,)) + NRFX_GPPI_ROUTE_ID_134_120, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_ROUTE_ID_135_136,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_ROUTE_ID_135_120,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_ROUTE_ID_136_120,)) + NRFX_GPPI_ROUTE_ID_COUNT, +}; + +static const nrfx_gppi_route_t routes[] = { + [NRFX_GPPI_ROUTE_ID_130] = + NRFX_GPPI_ROUTE_DEFINE("dppi130", (&nodes[NRFX_GPPI_NODE_DPPIC130])), + [NRFX_GPPI_ROUTE_ID_131] = + NRFX_GPPI_ROUTE_DEFINE("dppi131", (&nodes[NRFX_GPPI_NODE_DPPIC131])), + [NRFX_GPPI_ROUTE_ID_132] = + NRFX_GPPI_ROUTE_DEFINE("dppi132", (&nodes[NRFX_GPPI_NODE_DPPIC132])), + [NRFX_GPPI_ROUTE_ID_133] = + NRFX_GPPI_ROUTE_DEFINE("dppi133", (&nodes[NRFX_GPPI_NODE_DPPIC133])), + [NRFX_GPPI_ROUTE_ID_134] = + NRFX_GPPI_ROUTE_DEFINE("dppi134", (&nodes[NRFX_GPPI_NODE_DPPIC134])), +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) + [NRFX_GPPI_ROUTE_ID_135] = + NRFX_GPPI_ROUTE_DEFINE("dppi135", (&nodes[NRFX_GPPI_NODE_DPPIC135])), +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) + [NRFX_GPPI_ROUTE_ID_136] = + NRFX_GPPI_ROUTE_DEFINE("dppi136", (&nodes[NRFX_GPPI_NODE_DPPIC136])), +#endif + [NRFX_GPPI_ROUTE_ID_120] = + NRFX_GPPI_ROUTE_DEFINE("dppi120", (&nodes[NRFX_GPPI_NODE_DPPIC120])), + [NRFX_GPPI_ROUTE_ID_130_131] = + NRFX_GPPI_ROUTE_DEFINE("dppi130_dppi131", (&nodes[NRFX_GPPI_NODE_DPPIC130], + &nodes[NRFX_GPPI_NODE_PPIB130_132], + &nodes[NRFX_GPPI_NODE_DPPIC131])), + [NRFX_GPPI_ROUTE_ID_130_132] = + NRFX_GPPI_ROUTE_DEFINE("dppi130_dppi132", (&nodes[NRFX_GPPI_NODE_DPPIC130], + &nodes[NRFX_GPPI_NODE_PPIB130_133], + &nodes[NRFX_GPPI_NODE_DPPIC132])), + [NRFX_GPPI_ROUTE_ID_130_133] = + NRFX_GPPI_ROUTE_DEFINE("dppi130_dppi133", (&nodes[NRFX_GPPI_NODE_DPPIC130], + &nodes[NRFX_GPPI_NODE_PPIB130_134], + &nodes[NRFX_GPPI_NODE_DPPIC133])), + [NRFX_GPPI_ROUTE_ID_130_134] = + NRFX_GPPI_ROUTE_DEFINE("dppi130_dppi134", (&nodes[NRFX_GPPI_NODE_DPPIC130], + &nodes[NRFX_GPPI_NODE_PPIB130_135], + &nodes[NRFX_GPPI_NODE_DPPIC134])), +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) + [NRFX_GPPI_ROUTE_ID_130_135] = + NRFX_GPPI_ROUTE_DEFINE("dppi130_dppi135", (&nodes[NRFX_GPPI_NODE_DPPIC130], + &nodes[NRFX_GPPI_NODE_PPIB131_136], + &nodes[NRFX_GPPI_NODE_DPPIC135])), +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) + [NRFX_GPPI_ROUTE_ID_130_136] = + NRFX_GPPI_ROUTE_DEFINE("dppi130_dppi136", (&nodes[NRFX_GPPI_NODE_DPPIC130], + &nodes[NRFX_GPPI_NODE_PPIB131_137], + &nodes[NRFX_GPPI_NODE_DPPIC136])), +#endif + [NRFX_GPPI_ROUTE_ID_130_120] = + NRFX_GPPI_ROUTE_DEFINE("dppi130_dppi120", (&nodes[NRFX_GPPI_NODE_DPPIC130], + &nodes[NRFX_GPPI_NODE_PPIB131_121], + &nodes[NRFX_GPPI_NODE_DPPIC120])), + + [NRFX_GPPI_ROUTE_ID_131_132] = NRFX_GPPI_ROUTE_DEFINE( + "dppi131_dppi132", + (&nodes[NRFX_GPPI_NODE_DPPIC131], &nodes[NRFX_GPPI_NODE_PPIB130_132], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB130_133], + &nodes[NRFX_GPPI_NODE_DPPIC132])), + [NRFX_GPPI_ROUTE_ID_131_133] = NRFX_GPPI_ROUTE_DEFINE( + "dppi131_dppi133", + (&nodes[NRFX_GPPI_NODE_DPPIC131], &nodes[NRFX_GPPI_NODE_PPIB130_132], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB130_134], + &nodes[NRFX_GPPI_NODE_DPPIC133])), + [NRFX_GPPI_ROUTE_ID_131_134] = NRFX_GPPI_ROUTE_DEFINE( + "dppi131_dppi134", + (&nodes[NRFX_GPPI_NODE_DPPIC131], &nodes[NRFX_GPPI_NODE_PPIB130_132], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB130_135], + &nodes[NRFX_GPPI_NODE_DPPIC134])), +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) + [NRFX_GPPI_ROUTE_ID_131_135] = NRFX_GPPI_ROUTE_DEFINE( + "dppi131_dppi135", + (&nodes[NRFX_GPPI_NODE_DPPIC131], &nodes[NRFX_GPPI_NODE_PPIB130_132], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_136], + &nodes[NRFX_GPPI_NODE_DPPIC135])), +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) + [NRFX_GPPI_ROUTE_ID_131_136] = NRFX_GPPI_ROUTE_DEFINE( + "dppi131_dppi136", + (&nodes[NRFX_GPPI_NODE_DPPIC131], &nodes[NRFX_GPPI_NODE_PPIB130_132], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_137], + &nodes[NRFX_GPPI_NODE_DPPIC136])), +#endif + [NRFX_GPPI_ROUTE_ID_131_120] = NRFX_GPPI_ROUTE_DEFINE( + "dppi131_dppi120", + (&nodes[NRFX_GPPI_NODE_DPPIC131], &nodes[NRFX_GPPI_NODE_PPIB130_132], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_121], + &nodes[NRFX_GPPI_NODE_DPPIC120])), + + [NRFX_GPPI_ROUTE_ID_132_133] = NRFX_GPPI_ROUTE_DEFINE( + "dppi132_dppi133", + (&nodes[NRFX_GPPI_NODE_DPPIC132], &nodes[NRFX_GPPI_NODE_PPIB130_133], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB130_134], + &nodes[NRFX_GPPI_NODE_DPPIC133])), + [NRFX_GPPI_ROUTE_ID_132_134] = NRFX_GPPI_ROUTE_DEFINE( + "dppi132_dppi134", + (&nodes[NRFX_GPPI_NODE_DPPIC132], &nodes[NRFX_GPPI_NODE_PPIB130_133], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB130_135], + &nodes[NRFX_GPPI_NODE_DPPIC134])), +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) + [NRFX_GPPI_ROUTE_ID_132_135] = NRFX_GPPI_ROUTE_DEFINE( + "dppi132_dppi135", + (&nodes[NRFX_GPPI_NODE_DPPIC132], &nodes[NRFX_GPPI_NODE_PPIB130_133], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_136], + &nodes[NRFX_GPPI_NODE_DPPIC135])), +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) + [NRFX_GPPI_ROUTE_ID_132_136] = NRFX_GPPI_ROUTE_DEFINE( + "dppi132_dppi136", + (&nodes[NRFX_GPPI_NODE_DPPIC132], &nodes[NRFX_GPPI_NODE_PPIB130_133], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_137], + &nodes[NRFX_GPPI_NODE_DPPIC136])), +#endif + [NRFX_GPPI_ROUTE_ID_132_120] = NRFX_GPPI_ROUTE_DEFINE( + "dppi132_dppi120", + (&nodes[NRFX_GPPI_NODE_DPPIC132], &nodes[NRFX_GPPI_NODE_PPIB130_133], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_121], + &nodes[NRFX_GPPI_NODE_DPPIC120])), + + [NRFX_GPPI_ROUTE_ID_133_134] = NRFX_GPPI_ROUTE_DEFINE( + "dppi133_dppi134", + (&nodes[NRFX_GPPI_NODE_DPPIC133], &nodes[NRFX_GPPI_NODE_PPIB130_134], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB130_135], + &nodes[NRFX_GPPI_NODE_DPPIC134])), +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) + [NRFX_GPPI_ROUTE_ID_133_135] = NRFX_GPPI_ROUTE_DEFINE( + "dppi133_dppi135", + (&nodes[NRFX_GPPI_NODE_DPPIC133], &nodes[NRFX_GPPI_NODE_PPIB130_134], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_136], + &nodes[NRFX_GPPI_NODE_DPPIC135])), +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) + [NRFX_GPPI_ROUTE_ID_133_136] = NRFX_GPPI_ROUTE_DEFINE( + "dppi133_dppi136", + (&nodes[NRFX_GPPI_NODE_DPPIC133], &nodes[NRFX_GPPI_NODE_PPIB130_134], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_137], + &nodes[NRFX_GPPI_NODE_DPPIC136])), +#endif + [NRFX_GPPI_ROUTE_ID_133_120] = NRFX_GPPI_ROUTE_DEFINE( + "dppi133_dppi120", + (&nodes[NRFX_GPPI_NODE_DPPIC133], &nodes[NRFX_GPPI_NODE_PPIB130_134], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_121], + &nodes[NRFX_GPPI_NODE_DPPIC120])), +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) + [NRFX_GPPI_ROUTE_ID_134_135] = NRFX_GPPI_ROUTE_DEFINE( + "dppi134_dppi135", + (&nodes[NRFX_GPPI_NODE_DPPIC134], &nodes[NRFX_GPPI_NODE_PPIB130_135], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_136], + &nodes[NRFX_GPPI_NODE_DPPIC135])), +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) + [NRFX_GPPI_ROUTE_ID_134_136] = NRFX_GPPI_ROUTE_DEFINE( + "dppi134_dppi136", + (&nodes[NRFX_GPPI_NODE_DPPIC134], &nodes[NRFX_GPPI_NODE_PPIB130_135], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_137], + &nodes[NRFX_GPPI_NODE_DPPIC136])), +#endif + [NRFX_GPPI_ROUTE_ID_134_120] = NRFX_GPPI_ROUTE_DEFINE( + "dppi134_dppi120", + (&nodes[NRFX_GPPI_NODE_DPPIC134], &nodes[NRFX_GPPI_NODE_PPIB130_135], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_121], + &nodes[NRFX_GPPI_NODE_DPPIC120])), + +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) + [NRFX_GPPI_ROUTE_ID_135_136] = NRFX_GPPI_ROUTE_DEFINE( + "dppi135_dppi136", + (&nodes[NRFX_GPPI_NODE_DPPIC135], &nodes[NRFX_GPPI_NODE_PPIB131_136], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_137], + &nodes[NRFX_GPPI_NODE_DPPIC136])), +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) + [NRFX_GPPI_ROUTE_ID_135_120] = NRFX_GPPI_ROUTE_DEFINE( + "dppi135_dppi120", + (&nodes[NRFX_GPPI_NODE_DPPIC135], &nodes[NRFX_GPPI_NODE_PPIB131_136], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_121], + &nodes[NRFX_GPPI_NODE_DPPIC120])), +#endif +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) + [NRFX_GPPI_ROUTE_ID_136_120] = NRFX_GPPI_ROUTE_DEFINE( + "dppi136_dppi120", + (&nodes[NRFX_GPPI_NODE_DPPIC136], &nodes[NRFX_GPPI_NODE_PPIB131_137], + &nodes[NRFX_GPPI_NODE_DPPIC130], &nodes[NRFX_GPPI_NODE_PPIB131_121], + &nodes[NRFX_GPPI_NODE_DPPIC120])), +#endif +}; + +static const nrfx_gppi_route_t *dppi130_routes[] = { + &routes[NRFX_GPPI_ROUTE_ID_130], + &routes[NRFX_GPPI_ROUTE_ID_130_131], + &routes[NRFX_GPPI_ROUTE_ID_130_132], + &routes[NRFX_GPPI_ROUTE_ID_130_133], + &routes[NRFX_GPPI_ROUTE_ID_130_134], + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (&routes[NRFX_GPPI_ROUTE_ID_130_135],)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (&routes[NRFX_GPPI_ROUTE_ID_130_136],)) + &routes[NRFX_GPPI_ROUTE_ID_130_120] +}; + +static const nrfx_gppi_route_t *dppi131_routes[] = { + &routes[NRFX_GPPI_ROUTE_ID_131], + &routes[NRFX_GPPI_ROUTE_ID_131_132], + &routes[NRFX_GPPI_ROUTE_ID_131_133], + &routes[NRFX_GPPI_ROUTE_ID_131_134], + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (&routes[NRFX_GPPI_ROUTE_ID_131_135],)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (&routes[NRFX_GPPI_ROUTE_ID_131_136],)) + &routes[NRFX_GPPI_ROUTE_ID_131_120] +}; + +static const nrfx_gppi_route_t *dppi132_routes[] = { + &routes[NRFX_GPPI_ROUTE_ID_132], + &routes[NRFX_GPPI_ROUTE_ID_132_133], + &routes[NRFX_GPPI_ROUTE_ID_132_134], + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (&routes[NRFX_GPPI_ROUTE_ID_132_135],)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (&routes[NRFX_GPPI_ROUTE_ID_132_136],)) + &routes[NRFX_GPPI_ROUTE_ID_132_120] +}; + +static const nrfx_gppi_route_t *dppi133_routes[] = { + &routes[NRFX_GPPI_ROUTE_ID_133], + &routes[NRFX_GPPI_ROUTE_ID_133_134], + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (&routes[NRFX_GPPI_ROUTE_ID_133_135],)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (&routes[NRFX_GPPI_ROUTE_ID_133_136],)) + &routes[NRFX_GPPI_ROUTE_ID_133_120] +}; + +static const nrfx_gppi_route_t *dppi134_routes[] = { + &routes[NRFX_GPPI_ROUTE_ID_134], + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (&routes[NRFX_GPPI_ROUTE_ID_134_135],)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (&routes[NRFX_GPPI_ROUTE_ID_134_136],)) + &routes[NRFX_GPPI_ROUTE_ID_134_120] +}; + +#if DT_NODE_EXISTS(DT_NODELABEL(dppic135)) +static const nrfx_gppi_route_t *dppi135_routes[] = { + &routes[NRFX_GPPI_ROUTE_ID_135], + &routes[NRFX_GPPI_ROUTE_ID_135_136], + &routes[NRFX_GPPI_ROUTE_ID_135_120] +}; +#endif + +#if DT_NODE_EXISTS(DT_NODELABEL(dppic136)) +static const nrfx_gppi_route_t *dppi136_routes[] = { + &routes[NRFX_GPPI_ROUTE_ID_136], + &routes[NRFX_GPPI_ROUTE_ID_136_120] +}; +#endif + +static const nrfx_gppi_route_t *dppi120_routes[] = { + &routes[NRFX_GPPI_ROUTE_ID_120] +}; + +static const nrfx_gppi_route_t **dppi_route_map[] = { + dppi130_routes, + dppi131_routes, + dppi132_routes, + dppi133_routes, + dppi134_routes, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (dppi135_routes,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (dppi136_routes,)) + dppi120_routes +}; + +uint32_t nrfx_gppi_domain_id_get(uint32_t addr) +{ + uint32_t apb = (addr >> 16) & 0xff; + uint32_t domain = (addr >> 24) & 0xf; + + (void)domain; + __ASSERT_NO_MSG(domain == 0xf); + + if (apb < 0x92) { + return NRFX_GPPI_NODE_DPPIC120; + } else if (apb <= 0x93) { + return NRFX_GPPI_NODE_DPPIC130; + } + return apb - 0x98 + NRFX_GPPI_NODE_DPPIC131; +} + +const nrfx_gppi_route_t ***nrfx_gppi_route_map_get(void) +{ + return dppi_route_map; +} + +const nrfx_gppi_route_t *nrfx_gppi_routes_get(void) +{ + return routes; +} + +const nrfx_gppi_node_t *nrfx_gppi_nodes_get(void) +{ + return nodes; +} + +BUILD_ASSERT(SPU_FEATURE_DPPIC_CH_LOCK_Msk == SPU_FEATURE_DPPIC_CHG_LOCK_Msk); +BUILD_ASSERT(SPU_FEATURE_DPPIC_CH_OWNERID_Pos == SPU_FEATURE_DPPIC_CHG_OWNERID_Pos); + +static bool check_spu_value(uint32_t val) +{ + if ((val >> SPU_FEATURE_DPPIC_CH_OWNERID_Pos) != NRF_OWNER) { + return false; + } + + return true; +} + +static int actual_channel_mask(nrfx_gppi_node_id_t node_id, uint32_t *ch_mask, bool group) +{ + static const NRF_SPU_Type * spu_addr[] = { + NRF_SPU131, + NRF_SPU132, + NRF_SPU133, + NRF_SPU134, + NRF_SPU135, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRF_SPU136,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRF_SPU137,)) + NRF_SPU122, + }; + uint32_t out_mask = 0; + uint32_t in_mask = *ch_mask; + struct periphconf_entry entries[IRONSIDE_SE_PERIPHCONF_INLINE_READ_MAX_COUNT]; + uint8_t entries_idx[IRONSIDE_SE_PERIPHCONF_INLINE_READ_MAX_COUNT]; + struct ironside_se_periphconf_status status; + size_t entries_count = 0; + + while (in_mask) { + uint32_t idx = 31 - __builtin_clz(in_mask); + + in_mask &= ~BIT(idx); + /* Collect batch of requests. */ + entries_idx[entries_count] = idx; + entries[entries_count].regptr = group ? + PERIPHCONF_SPU_FEATURE_DPPIC_CHG_REGPTR(spu_addr[node_id], idx) : + PERIPHCONF_SPU_FEATURE_DPPIC_CH_REGPTR(spu_addr[node_id], idx); + entries_count++; + if ((entries_count == ARRAY_SIZE(entries)) || (in_mask == 0)) { + /* Read batch of registers. */ + status = ironside_se_periphconf_read(entries, entries_count); + if (status.status == 0) { + for (uint32_t i = 0; i < entries_count; i++) { + /* If SPU register has default value assume that channel + * is unused and can be in the pool. + */ + if (check_spu_value(entries[i].value)) { + out_mask |= BIT(entries_idx[i]); + } + } + entries_count = 0; + } else { + return status.status; + } + } + } + + *ch_mask = out_mask; + + return 0; +} + +void nrfx_gppi_channel_init(nrfx_gppi_node_id_t node_id, uint32_t ch_mask) +{ + NRFX_ASSERT(node_id < NRFX_GPPI_NODE_COUNT); + int rv; + + if (node_id < NRFX_GPPI_NODE_DPPI_COUNT) { + rv = actual_channel_mask(node_id, &ch_mask, false); + __ASSERT_NO_MSG(rv == 0); + if (rv < 0) { + return; + } + } + + *nodes[node_id].generic.p_channels = ch_mask; +} + +void nrfx_gppi_groups_init(nrfx_gppi_node_id_t node_id, uint32_t group_mask) +{ + NRFX_ASSERT(node_id < NRFX_GPPI_NODE_DPPI_COUNT); + int rv; + + rv = actual_channel_mask(node_id, &group_mask, true); + __ASSERT_NO_MSG(rv == 0); + if (rv < 0) { + return; + } + + *nodes[node_id].dppi.p_group_channels = group_mask; +} + +int nrfx_gppi_ext_ppib_write(volatile uint32_t *p_addr, uint32_t value) +{ + struct ironside_se_periphconf_status status; + + if (p_addr != NULL) { + write_entries[write_entries_count].regptr = (uint32_t)p_addr; + write_entries[write_entries_count].value = value; + write_entries_count++; + if (write_entries_count < ARRAY_SIZE(write_entries)) { + return 0; + } + } + + if (write_entries_count == 0) { + return 0; + } + + status = ironside_se_periphconf_write(write_entries, write_entries_count); + write_entries_count = 0; + + return (status.status < 0) ? -EIO : 0; +} diff --git a/soc/nordic/nrf54h/nrfx_gppi_nrf54h_global.h b/soc/nordic/common/nrfx_gppi_sd2ppi_global.h similarity index 64% rename from soc/nordic/nrf54h/nrfx_gppi_nrf54h_global.h rename to soc/nordic/common/nrfx_gppi_sd2ppi_global.h index 391d2a817c6f..b55ad58c805c 100644 --- a/soc/nordic/nrf54h/nrfx_gppi_nrf54h_global.h +++ b/soc/nordic/common/nrfx_gppi_sd2ppi_global.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef SOC_NORDIC_NRF54H_NRFX_GPPI_NRF54H_GLOBAL_H_ -#define SOC_NORDIC_NRF54H_NRFX_GPPI_NRF54H_GLOBAL_H_ +#ifndef SOC_NORDIC_COMMON_NRFX_GPPI_SD2PPI_GLOBAL_H_ +#define SOC_NORDIC_COMMON_NRFX_GPPI_SD2PPI_GLOBAL_H_ #include #include @@ -16,8 +16,8 @@ typedef enum { NRFX_GPPI_NODE_DPPIC132, NRFX_GPPI_NODE_DPPIC133, NRFX_GPPI_NODE_DPPIC134, - NRFX_GPPI_NODE_DPPIC135, - NRFX_GPPI_NODE_DPPIC136, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_NODE_DPPIC135,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_NODE_DPPIC136,)) NRFX_GPPI_NODE_DPPIC120, NRFX_GPPI_NODE_DPPI_COUNT, @@ -25,8 +25,8 @@ typedef enum { NRFX_GPPI_NODE_PPIB130_133, NRFX_GPPI_NODE_PPIB130_134, NRFX_GPPI_NODE_PPIB130_135, - NRFX_GPPI_NODE_PPIB131_136, - NRFX_GPPI_NODE_PPIB131_137, + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic135)), (NRFX_GPPI_NODE_PPIB131_136,)) + IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(dppic136)), (NRFX_GPPI_NODE_PPIB131_137,)) NRFX_GPPI_NODE_PPIB131_121, NRFX_GPPI_NODE_COUNT, } nrfx_gppi_node_id_t; @@ -37,4 +37,4 @@ const nrfx_gppi_node_t *nrfx_gppi_nodes_get(void); void nrfx_gppi_channel_init(nrfx_gppi_node_id_t node_id, uint32_t ch_mask); void nrfx_gppi_groups_init(nrfx_gppi_node_id_t node_id, uint32_t group_mask); -#endif /* SOC_NORDIC_NRF54H_NRFX_GPPI_NRF54H_GLOBAL_H_ */ +#endif /* SOC_NORDIC_COMMON_NRFX_GPPI_SD2PPI_GLOBAL_H_ */ diff --git a/soc/nordic/common/poweroff.c b/soc/nordic/common/poweroff.c index ecdde3aa2adf..6bb2068abb35 100644 --- a/soc/nordic/common/poweroff.c +++ b/soc/nordic/common/poweroff.c @@ -7,10 +7,12 @@ #include #include -#if defined(CONFIG_SOC_SERIES_NRF51) || defined(CONFIG_SOC_SERIES_NRF52) +#if defined(CONFIG_TFM_NRF_SYSTEM_OFF_SERVICE) +#include "tfm_platform_api.h" +#elif defined(CONFIG_SOC_SERIES_NRF51) || defined(CONFIG_SOC_SERIES_NRF52) #include -#elif defined(CONFIG_NRF_PLATFORM_HALTIUM) -#include +#elif defined(CONFIG_SOC_SERIES_NRF54H) || defined(CONFIG_SOC_SERIES_NRF92) +#include #else #include #endif @@ -30,6 +32,10 @@ void z_sys_poweroff(void) { +#if defined(CONFIG_TFM_NRF_SYSTEM_OFF_SERVICE) + tfm_platform_system_off(); +#else + #if defined(CONFIG_HAS_NORDIC_RAM_CTRL) uint8_t *ram_start; size_t ram_size; @@ -72,11 +78,13 @@ void z_sys_poweroff(void) #endif #if defined(CONFIG_SOC_SERIES_NRF51) || defined(CONFIG_SOC_SERIES_NRF52) nrf_power_system_off(NRF_POWER); -#elif defined(CONFIG_NRF_PLATFORM_HALTIUM) +#elif defined(CONFIG_SOC_SERIES_NRF54H) || defined(CONFIG_SOC_SERIES_NRF92) nrf_poweroff(); #else nrf_regulators_system_off(NRF_REGULATORS); #endif +#endif /* CONFIG_TFM_NRF_SYSTEM_OFF_SERVICE */ + CODE_UNREACHABLE; } diff --git a/soc/nordic/common/uicr/Kconfig.gen_uicr b/soc/nordic/common/uicr/Kconfig.gen_uicr index c07ba3e051f1..47c7c097991c 100644 --- a/soc/nordic/common/uicr/Kconfig.gen_uicr +++ b/soc/nordic/common/uicr/Kconfig.gen_uicr @@ -404,4 +404,36 @@ config GEN_UICR_POLICY_MPCCONF_STAGE_VALUE default 0x1730C77F if GEN_UICR_POLICY_MPCCONF_STAGE_NORMAL default 0 +config GEN_UICR_SNAPSHOT_REGIONS + bool "UICR.SNAPSHOT.REGIONS" + depends on SOC_SERIES_NRF54H + help + When enabled, the UICR generator will configure the snapshot regions + specified in Kconfig. + +if GEN_UICR_SNAPSHOT_REGIONS + +index = 0 +rsource "Kconfig.template.gen_uicr_snapshot_region" + +index = 1 +rsource "Kconfig.template.gen_uicr_snapshot_region" + +index = 2 +rsource "Kconfig.template.gen_uicr_snapshot_region" + +index = 3 +rsource "Kconfig.template.gen_uicr_snapshot_region" + +index = 4 +rsource "Kconfig.template.gen_uicr_snapshot_region" + +index = 5 +rsource "Kconfig.template.gen_uicr_snapshot_region" + +index = 6 +rsource "Kconfig.template.gen_uicr_snapshot_region" + +endif # GEN_UICR_SNAPSHOT_REGIONS + endmenu diff --git a/soc/nordic/common/uicr/Kconfig.sysbuild b/soc/nordic/common/uicr/Kconfig.sysbuild index df44dc0fcc99..eab8e9b0bc74 100644 --- a/soc/nordic/common/uicr/Kconfig.sysbuild +++ b/soc/nordic/common/uicr/Kconfig.sysbuild @@ -1,7 +1,7 @@ # Copyright (c) 2025 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -config NRF_HALTIUM_GENERATE_UICR +config NRF_GENERATE_UICR bool "Generate UICR artifacts" depends on SOC_SERIES_NRF54H || SOC_SERIES_NRF92 default y @@ -9,3 +9,13 @@ config NRF_HALTIUM_GENERATE_UICR When enabled, a UICR generator image is included in the build. This generates binary configuration artifacts based on the Kconfig and device tree of the UICR generator image. See the UICR generator options for further details. + +config NRF_HALTIUM_GENERATE_UICR + bool "[DEPRECATED] Renamed to NRF_GENERATE_UICR" + depends on SOC_SERIES_NRF54H || SOC_SERIES_NRF92 + select DEPRECATED + select NRF_GENERATE_UICR + help + This option has been renamed. Use NRF_GENERATE_UICR instead. + The old name is kept temporarily so that existing sysbuild.conf files + continue to build, with a deprecation warning. diff --git a/soc/nordic/common/uicr/Kconfig.template.gen_uicr_snapshot_region b/soc/nordic/common/uicr/Kconfig.template.gen_uicr_snapshot_region new file mode 100644 index 000000000000..5eed27ac39eb --- /dev/null +++ b/soc/nordic/common/uicr/Kconfig.template.gen_uicr_snapshot_region @@ -0,0 +1,22 @@ +# Copyright (c) 2026 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config GEN_UICR_SNAPSHOT_REGION_$(index) + bool "UICR.SNAPSHOT region" + depends on GEN_UICR_SNAPSHOT_REGIONS + help + When enabled, configures a UICR.SNAPSHOT region. + +config GEN_UICR_SNAPSHOT_REGION_$(index)_ADDRESS + hex "UICR.SNAPSHOT region start address" + range 0x0e030000 0x0e1ff000 + depends on GEN_UICR_SNAPSHOT_REGION_$(index) + help + UICR.SNAPSHOT region start address. Must be aligned to a 1 KB boundary. + +config GEN_UICR_SNAPSHOT_REGION_$(index)_SIZE_BYTES + int "UICR.SNAPSHOT region size in bytes" + range 1024 1048576 + depends on GEN_UICR_SNAPSHOT_REGION_$(index) + help + Size of the snapshot region in bytes. Must be a multiple of 1024. diff --git a/soc/nordic/common/uicr/gen_uicr/CMakeLists.txt b/soc/nordic/common/uicr/gen_uicr/CMakeLists.txt index e877e67c504f..a5cedb4b7a71 100644 --- a/soc/nordic/common/uicr/gen_uicr/CMakeLists.txt +++ b/soc/nordic/common/uicr/gen_uicr/CMakeLists.txt @@ -71,6 +71,14 @@ function(compute_optional_partition_address_and_size partition_nodelabel output_ endif() endfunction() +set(IRONSIDE_SE_PERIPHCONF_REGISTERS_FILE "") + +if(CONFIG_SOC_NRF54H20) + set(IRONSIDE_SE_PERIPHCONF_REGISTERS_FILE + "${IRONSIDE_SUPPORT_DIR}/se/resources/periphconf_registers-nrf54h20_xxaa-v23.4.0+27.json" + ) +endif() + # Use CMAKE_VERBOSE_MAKEFILE to silence an unused-variable warning. if(CMAKE_VERBOSE_MAKEFILE) endif() @@ -80,6 +88,7 @@ set(eraseprotect_args) set(approtect_args) set(protectedmem_args) set(periphconf_args) +set(snapshot_args) set(mpcconf_args) set(wdtstart_args) set(periphconf_elfs) @@ -356,6 +365,83 @@ if(CONFIG_GEN_UICR_POLICY_MPCCONF_STAGE_INIT OR CONFIG_GEN_UICR_POLICY_MPCCONF_S list(APPEND policy_args --policy-mpcconf-stage ${CONFIG_GEN_UICR_POLICY_MPCCONF_STAGE_VALUE}) endif() +# Handle SNAPSHOT configuration (indices 0..6 match Kconfig.template.gen_uicr_snapshot_region) +if(CONFIG_GEN_UICR_SNAPSHOT_REGIONS) + foreach(snapshot_region_idx RANGE 0 6) + if(CONFIG_GEN_UICR_SNAPSHOT_REGION_${snapshot_region_idx}) + list(APPEND snapshot_args + --snapshot-region + ${CONFIG_GEN_UICR_SNAPSHOT_REGION_${snapshot_region_idx}_ADDRESS} + ${CONFIG_GEN_UICR_SNAPSHOT_REGION_${snapshot_region_idx}_SIZE_BYTES} + ) + endif() + endforeach() +endif() + +set(periphconf_check_base_cmd + ${CMAKE_COMMAND} -E env ZEPHYR_BASE=${ZEPHYR_BASE} + ${PYTHON_EXECUTABLE} ${IRONSIDE_SUPPORT_DIR}/se/tool/ironside/__main__.py + periphconf-check + --in-periphconf-registers-json ${IRONSIDE_SE_PERIPHCONF_REGISTERS_FILE} +) + +set(periphconf_validate_command) +set(secondary_periphconf_validate_command) + +if(CONFIG_GEN_UICR_GENERATE_PERIPHCONF AND IRONSIDE_SE_PERIPHCONF_REGISTERS_FILE) + set(check_cmd ${periphconf_check_base_cmd} --in-periphconf-hex ${periphconf_hex_file}) + + set(periphconf_validate_build_command + COMMAND ${check_cmd} --mode errors + ) + + add_custom_target( + periphconf_validate + COMMAND ${check_cmd} --mode errors + DEPENDS ${periphconf_hex_file} + COMMENT "Validating ${periphconf_hex_file}" + ) + add_custom_target( + periphconf_dump + COMMAND ${check_cmd} --mode full + DEPENDS ${periphconf_hex_file} + COMMENT "Printing ${periphconf_hex_file}" + ) + add_custom_target( + periphconf_dump_raw + COMMAND ${check_cmd} --mode full --style raw + DEPENDS ${periphconf_hex_file} + COMMENT "Printing ${periphconf_hex_file}" + ) +endif() + +if(CONFIG_GEN_UICR_SECONDARY_GENERATE_PERIPHCONF AND IRONSIDE_SE_PERIPHCONF_REGISTERS_FILE) + set(check_cmd ${periphconf_check_base_cmd} --in-periphconf-hex ${secondary_periphconf_hex_file}) + + set(secondary_periphconf_validate_build_command + COMMAND ${check_cmd} --mode errors + ) + + add_custom_target( + secondary_periphconf_validate + COMMAND ${check_cmd} --mode errors + DEPENDS ${secondary_periphconf_hex_file} + COMMENT "Validating ${secondary_periphconf_hex_file}" + ) + add_custom_target( + secondary_periphconf_dump + COMMAND ${check_cmd} --mode full + DEPENDS ${secondary_periphconf_hex_file} + COMMENT "Printing ${secondary_periphconf_hex_file}" + ) + add_custom_target( + secondary_periphconf_dump_raw + COMMAND ${check_cmd} --mode full --style raw + DEPENDS ${secondary_periphconf_hex_file} + COMMENT "Printing ${secondary_periphconf_hex_file}" + ) +endif() + add_custom_command( OUTPUT ${gen_uicr_outputs} COMMAND ${PYTHON_EXECUTABLE} ${IRONSIDE_SUPPORT_DIR}/se/tool/ironside/__main__.py @@ -376,6 +462,9 @@ add_custom_command( ${protectedmem_args} ${secondary_args} ${policy_args} + ${snapshot_args} + ${periphconf_validate_build_command} + ${secondary_periphconf_validate_build_command} DEPENDS ${gen_uicr_depends} WORKING_DIRECTORY ${APPLICATION_BINARY_DIR} COMMENT "Generating UICR artifacts" diff --git a/soc/nordic/nrf53/Kconfig b/soc/nordic/nrf53/Kconfig index 7794fba63ba1..3b82cb23b4a6 100644 --- a/soc/nordic/nrf53/Kconfig +++ b/soc/nordic/nrf53/Kconfig @@ -170,12 +170,32 @@ config NRF_SPU_FLASH_REGION_SIZE help FLASH region size for the NRF_SPU peripheral +config NRF_TRUSTZONE_FLASH_REGION_SIZE + hex + default NRF_SPU_FLASH_REGION_SIZE + help + Define the flash region size from a TrustZone perspective. + This is used when we set the security attributes(S/NSC/NS) of a region + in TrustZone enabled devices. + In practice this option defines the granularity of the security attributes, + i.e. the smallest region that can be set to secure or non-secure. + config NRF_SPU_RAM_REGION_SIZE hex default 0x2000 help RAM region size for the NRF_SPU peripheral +config NRF_TRUSTZONE_RAM_REGION_SIZE + hex + default NRF_SPU_RAM_REGION_SIZE + help + Define the RAM region size from a TrustZone perspective. + This is used when we set the security attributes(S/NSC/NS) of a region + in TrustZone enabled devices. + In practice this option defines the granularity of the security attributes, + i.e. the smallest region that can be set to secure or non-secure. + config SOC_NRF_GPIO_FORWARDER_FOR_NRF5340 bool "Forward GPIO pins to network core" depends on NRF_SOC_SECURE_SUPPORTED diff --git a/soc/nordic/nrf53/soc.c b/soc/nordic/nrf53/soc.c index 5887399c6ace..3a86f158cc3c 100644 --- a/soc/nordic/nrf53/soc.c +++ b/soc/nordic/nrf53/soc.c @@ -334,7 +334,7 @@ void z_arm_on_enter_cpu_idle_prepare(void) #if defined(CONFIG_SOC_NRF53_ANOMALY_160_WORKAROUND) || \ (defined(CONFIG_SOC_NRF53_RTC_PRETICK) && defined(CONFIG_SOC_NRF5340_CPUNET)) -bool z_arm_on_enter_cpu_idle(void) +bool z_nrf53_on_enter_cpu_idle(void) { bool ok_to_sleep = true; @@ -385,6 +385,18 @@ bool z_arm_on_enter_cpu_idle(void) * (CONFIG_SOC_NRF53_RTC_PRETICK && CONFIG_SOC_NRF5340_CPUNET) */ +#if defined(CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK) && !defined(CONFIG_NRF_CUSTOM_ON_ENTER_CPU_IDLE_HOOK) +bool z_arm_on_enter_cpu_idle(void) +{ +#if defined(CONFIG_SOC_NRF53_ANOMALY_160_WORKAROUND) || \ + (defined(CONFIG_SOC_NRF53_RTC_PRETICK) && defined(CONFIG_SOC_NRF5340_CPUNET)) + return z_nrf53_on_enter_cpu_idle(); +#endif /* CONFIG_SOC_NRF53_ANOMALY_160_WORKAROUND || + * (CONFIG_SOC_NRF53_RTC_PRETICK && CONFIG_SOC_NRF5340_CPUNET) + */ +} +#endif + #if CONFIG_SOC_NRF53_RTC_PRETICK #ifdef CONFIG_SOC_NRF5340_CPUAPP /* RTC pretick - application core part. */ diff --git a/soc/nordic/nrf54h/CMakeLists.txt b/soc/nordic/nrf54h/CMakeLists.txt index 567bc423c9db..2928c6916ea1 100644 --- a/soc/nordic/nrf54h/CMakeLists.txt +++ b/soc/nordic/nrf54h/CMakeLists.txt @@ -3,11 +3,19 @@ if(CONFIG_ARM) zephyr_library_sources(soc.c) + zephyr_library_sources(soc_power.c) + zephyr_code_relocate( + FILES soc_power.c + FILTER ".*\\.cache_retain_and_sleep" + LOCATION PMLocalRamfunc_TEXT + ) + if(NOT CONFIG_SOC_NRF54H20_PM_S2RAM_OVERRIDE) + zephyr_library_sources_ifdef(CONFIG_PM_S2RAM soc_pm_s2ram.c) + endif() endif() if(CONFIG_NRFX_GPPI AND NOT CONFIG_NRFX_GPPI_V1) zephyr_library_sources_ifdef(CONFIG_SOC_NRF54H20_CPURAD nrfx_gppi_cpurad.c) - zephyr_library_sources_ifdef(CONFIG_SOC_NRF54H20_CPUAPP nrfx_gppi_nrf54h_global.c) endif() zephyr_include_directories(.) diff --git a/soc/nordic/nrf54h/Kconfig b/soc/nordic/nrf54h/Kconfig index 500183877938..bc08e45d20b8 100644 --- a/soc/nordic/nrf54h/Kconfig +++ b/soc/nordic/nrf54h/Kconfig @@ -9,7 +9,6 @@ config SOC_SERIES_NRF54H select HAS_NRFX select HAS_NORDIC_DRIVERS select SOC_EARLY_INIT_HOOK if ARM - select NRF_PLATFORM_HALTIUM config SOC_SERIES_NRF54HX select DEPRECATED @@ -41,6 +40,7 @@ config SOC_NRF54H20_CPUAPP_COMMON select HAS_PM_S2RAM_CUSTOM_MARKING select HAS_POWEROFF select HAS_IRONSIDE_SE_CALL + imply NRFX_GPPI_SD2PPI_GLOBAL config SOC_NRF54H20_CPUAPP select SOC_NRF54H20_CPUAPP_COMMON @@ -100,6 +100,11 @@ config SOC_NRF54H20_CPURAD_ENABLE_DEBUG_WAIT endif # SOC_NRF54H20_CPURAD_ENABLE +config SOC_NRF54H20_PM_S2RAM_OVERRIDE + bool "Override `pm_s2ram` implementation" + help + Override Nordic s2ram implementation. + config SOC_NRF54H20_CPURAD select SOC_NRF54H20_CPURAD_COMMON diff --git a/soc/nordic/nrf54h/nrfx_gppi_nrf54h_global.c b/soc/nordic/nrf54h/nrfx_gppi_nrf54h_global.c deleted file mode 100644 index ebb5f4662ca4..000000000000 --- a/soc/nordic/nrf54h/nrfx_gppi_nrf54h_global.c +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (c) 2026 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include "nrfx_gppi_nrf54h_global.h" -#include - -static nrfx_atomic_t channels[NRFX_GPPI_NODE_COUNT]; -static nrfx_atomic_t group_channels[NRFX_GPPI_NODE_DPPI_COUNT]; -static struct periphconf_entry write_entries[1]; -static size_t write_entries_count; - -#define PPIB_REG(id) (NRF_PPIB_Type *)DT_REG_ADDR(DT_NODELABEL(ppib##id)) -#define PPIB_OFF(id) DT_PROP_OR(DT_NODELABEL(ppib##id), offset, 0) - -#define NRFX_GPPI_PPIB_EXT_NODE_DEFINE(_id1, _id2) \ -[NRFX_GPPI_NODE_PPIB##_id1##_##_id2] = { \ - .type = NRFX_GPPI_NODE_PPIB, \ - .domain_id = NRFX_GPPI_NODE_PPIB##_id1##_##_id2, \ - .ch_off = {PPIB_OFF(_id2), 0}, \ - .ppib = { \ - .p_channels = &channels[NRFX_GPPI_NODE_PPIB##_id1##_##_id2],\ - .p_reg = {PPIB_REG(_id1), PPIB_REG(_id2)} \ - } \ - } - -static const nrfx_gppi_node_t nodes[] = { - NRFX_GPPI_DPPI_NODE_DEFINE(130, NRFX_GPPI_NODE_DPPIC130), - NRFX_GPPI_DPPI_NODE_DEFINE(131, NRFX_GPPI_NODE_DPPIC131), - NRFX_GPPI_DPPI_NODE_DEFINE(132, NRFX_GPPI_NODE_DPPIC132), - NRFX_GPPI_DPPI_NODE_DEFINE(133, NRFX_GPPI_NODE_DPPIC133), - NRFX_GPPI_DPPI_NODE_DEFINE(134, NRFX_GPPI_NODE_DPPIC134), - NRFX_GPPI_DPPI_NODE_DEFINE(135, NRFX_GPPI_NODE_DPPIC135), - NRFX_GPPI_DPPI_NODE_DEFINE(136, NRFX_GPPI_NODE_DPPIC136), - NRFX_GPPI_DPPI_NODE_DEFINE(120, NRFX_GPPI_NODE_DPPIC120), - NRFX_GPPI_PPIB_EXT_NODE_DEFINE(130, 132), - NRFX_GPPI_PPIB_EXT_NODE_DEFINE(130, 133), - NRFX_GPPI_PPIB_EXT_NODE_DEFINE(130, 134), - NRFX_GPPI_PPIB_EXT_NODE_DEFINE(130, 135), - NRFX_GPPI_PPIB_EXT_NODE_DEFINE(131, 136), - NRFX_GPPI_PPIB_EXT_NODE_DEFINE(131, 137), - NRFX_GPPI_PPIB_EXT_NODE_DEFINE(131, 121), -}; - -static const nrfx_gppi_route_t routes[] = { - /* 0 */NRFX_GPPI_ROUTE_DEFINE("apb32", - (&nodes[NRFX_GPPI_NODE_DPPIC130])), - /* 1 */NRFX_GPPI_ROUTE_DEFINE("apb38", - (&nodes[NRFX_GPPI_NODE_DPPIC131])), - /* 2 */NRFX_GPPI_ROUTE_DEFINE("apb39", - (&nodes[NRFX_GPPI_NODE_DPPIC132])), - /* 3 */NRFX_GPPI_ROUTE_DEFINE("apb3a", - (&nodes[NRFX_GPPI_NODE_DPPIC133])), - /* 4 */NRFX_GPPI_ROUTE_DEFINE("apb3b", - (&nodes[NRFX_GPPI_NODE_DPPIC134])), - /* 5 */NRFX_GPPI_ROUTE_DEFINE("apb3c", - (&nodes[NRFX_GPPI_NODE_DPPIC135])), - /* 6 */NRFX_GPPI_ROUTE_DEFINE("apb3d", - (&nodes[NRFX_GPPI_NODE_DPPIC136])), - /* 7 */NRFX_GPPI_ROUTE_DEFINE("apb22", - (&nodes[NRFX_GPPI_NODE_DPPIC120])), - - /* 8 */NRFX_GPPI_ROUTE_DEFINE("apb32_apb38", - (&nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_132], - &nodes[NRFX_GPPI_NODE_DPPIC131])), - /* 9 */NRFX_GPPI_ROUTE_DEFINE("apb32_apb39", - (&nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_133], - &nodes[NRFX_GPPI_NODE_DPPIC132])), - /* 10 */NRFX_GPPI_ROUTE_DEFINE("apb32_apb3a", - (&nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_134], - &nodes[NRFX_GPPI_NODE_DPPIC133])), - /* 11 */NRFX_GPPI_ROUTE_DEFINE("apb32_apb3b", - (&nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_135], - &nodes[NRFX_GPPI_NODE_DPPIC134])), - /* 12 */NRFX_GPPI_ROUTE_DEFINE("apb32_apb3c", - (&nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_136], - &nodes[NRFX_GPPI_NODE_DPPIC135])), - /* 13 */NRFX_GPPI_ROUTE_DEFINE("apb32_apb3d", - (&nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_137], - &nodes[NRFX_GPPI_NODE_DPPIC136])), - /* 14 */NRFX_GPPI_ROUTE_DEFINE("apb32_apb22", - (&nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_121], - &nodes[NRFX_GPPI_NODE_DPPIC120])), - - /* 15 */NRFX_GPPI_ROUTE_DEFINE("apb38_apb39", - (&nodes[NRFX_GPPI_NODE_DPPIC131], - &nodes[NRFX_GPPI_NODE_PPIB130_132], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_133], - &nodes[NRFX_GPPI_NODE_DPPIC132])), - /* 16 */NRFX_GPPI_ROUTE_DEFINE("apb38_apb3a", - (&nodes[NRFX_GPPI_NODE_DPPIC131], - &nodes[NRFX_GPPI_NODE_PPIB130_132], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_134], - &nodes[NRFX_GPPI_NODE_DPPIC133])), - /* 17 */NRFX_GPPI_ROUTE_DEFINE("apb38_apb3b", - (&nodes[NRFX_GPPI_NODE_DPPIC131], - &nodes[NRFX_GPPI_NODE_PPIB130_132], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_135], - &nodes[NRFX_GPPI_NODE_DPPIC134])), - /* 18 */NRFX_GPPI_ROUTE_DEFINE("apb38_apb3c", - (&nodes[NRFX_GPPI_NODE_DPPIC131], - &nodes[NRFX_GPPI_NODE_PPIB130_132], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_136], - &nodes[NRFX_GPPI_NODE_DPPIC135])), - /* 19 */NRFX_GPPI_ROUTE_DEFINE("apb38_apb3d", - (&nodes[NRFX_GPPI_NODE_DPPIC131], - &nodes[NRFX_GPPI_NODE_PPIB130_132], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_137], - &nodes[NRFX_GPPI_NODE_DPPIC136])), - /* 20 */NRFX_GPPI_ROUTE_DEFINE("apb38_apb22", - (&nodes[NRFX_GPPI_NODE_DPPIC131], - &nodes[NRFX_GPPI_NODE_PPIB130_132], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_121], - &nodes[NRFX_GPPI_NODE_DPPIC120])), - - /* 21 */NRFX_GPPI_ROUTE_DEFINE("apb39_apb3a", - (&nodes[NRFX_GPPI_NODE_DPPIC132], - &nodes[NRFX_GPPI_NODE_PPIB130_133], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_134], - &nodes[NRFX_GPPI_NODE_DPPIC133])), - /* 22 */NRFX_GPPI_ROUTE_DEFINE("apb39_apb3b", - (&nodes[NRFX_GPPI_NODE_DPPIC132], - &nodes[NRFX_GPPI_NODE_PPIB130_133], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_135], - &nodes[NRFX_GPPI_NODE_DPPIC134])), - /* 23 */NRFX_GPPI_ROUTE_DEFINE("apb39_apb3c", - (&nodes[NRFX_GPPI_NODE_DPPIC132], - &nodes[NRFX_GPPI_NODE_PPIB130_133], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_136], - &nodes[NRFX_GPPI_NODE_DPPIC135])), - /* 24 */NRFX_GPPI_ROUTE_DEFINE("apb39_apb3d", - (&nodes[NRFX_GPPI_NODE_DPPIC132], - &nodes[NRFX_GPPI_NODE_PPIB130_133], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_137], - &nodes[NRFX_GPPI_NODE_DPPIC136])), - /* 25 */NRFX_GPPI_ROUTE_DEFINE("apb39_apb22", - (&nodes[NRFX_GPPI_NODE_DPPIC132], - &nodes[NRFX_GPPI_NODE_PPIB130_133], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_121], - &nodes[NRFX_GPPI_NODE_DPPIC120])), - - /* 26 */NRFX_GPPI_ROUTE_DEFINE("apb3a_apb3b", - (&nodes[NRFX_GPPI_NODE_DPPIC133], - &nodes[NRFX_GPPI_NODE_PPIB130_134], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB130_135], - &nodes[NRFX_GPPI_NODE_DPPIC134])), - /* 27 */NRFX_GPPI_ROUTE_DEFINE("apb3a_apb3c", - (&nodes[NRFX_GPPI_NODE_DPPIC133], - &nodes[NRFX_GPPI_NODE_PPIB130_134], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_136], - &nodes[NRFX_GPPI_NODE_DPPIC135])), - /* 28 */NRFX_GPPI_ROUTE_DEFINE("apb3a_apb3d", - (&nodes[NRFX_GPPI_NODE_DPPIC133], - &nodes[NRFX_GPPI_NODE_PPIB130_134], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_137], - &nodes[NRFX_GPPI_NODE_DPPIC136])), - /* 29 */NRFX_GPPI_ROUTE_DEFINE("apb3a_apb22", - (&nodes[NRFX_GPPI_NODE_DPPIC133], - &nodes[NRFX_GPPI_NODE_PPIB130_134], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_121], - &nodes[NRFX_GPPI_NODE_DPPIC120])), - - /* 30 */NRFX_GPPI_ROUTE_DEFINE("apb3b_apb3c", - (&nodes[NRFX_GPPI_NODE_DPPIC134], - &nodes[NRFX_GPPI_NODE_PPIB130_135], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_136], - &nodes[NRFX_GPPI_NODE_DPPIC135])), - /* 31 */NRFX_GPPI_ROUTE_DEFINE("apb3b_apb3d", - (&nodes[NRFX_GPPI_NODE_DPPIC134], - &nodes[NRFX_GPPI_NODE_PPIB130_135], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_137], - &nodes[NRFX_GPPI_NODE_DPPIC136])), - /* 32 */NRFX_GPPI_ROUTE_DEFINE("apb22_apb3b", - (&nodes[NRFX_GPPI_NODE_DPPIC134], - &nodes[NRFX_GPPI_NODE_PPIB130_135], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_121], - &nodes[NRFX_GPPI_NODE_DPPIC120])), - - /* 33 */NRFX_GPPI_ROUTE_DEFINE("apb3c_apb3d", - (&nodes[NRFX_GPPI_NODE_DPPIC135], - &nodes[NRFX_GPPI_NODE_PPIB131_136], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_137], - &nodes[NRFX_GPPI_NODE_DPPIC136])), - /* 34 */NRFX_GPPI_ROUTE_DEFINE("apb3c_apb22", - (&nodes[NRFX_GPPI_NODE_DPPIC135], - &nodes[NRFX_GPPI_NODE_PPIB131_136], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_121], - &nodes[NRFX_GPPI_NODE_DPPIC120])), - - /* 35 */NRFX_GPPI_ROUTE_DEFINE("apb3d_apb22", - (&nodes[NRFX_GPPI_NODE_DPPIC136], - &nodes[NRFX_GPPI_NODE_PPIB131_137], - &nodes[NRFX_GPPI_NODE_DPPIC130], - &nodes[NRFX_GPPI_NODE_PPIB131_121], - &nodes[NRFX_GPPI_NODE_DPPIC120])), -}; - -static const nrfx_gppi_route_t *apb32_routes[] = { - &routes[0], &routes[8], &routes[9], &routes[10], &routes[11], - &routes[12], &routes[13], &routes[14] -}; -static const nrfx_gppi_route_t *apb38_routes[] = { - &routes[1], &routes[15], &routes[16], &routes[17], &routes[18], &routes[19], &routes[20] -}; -static const nrfx_gppi_route_t *apb39_routes[] = { - &routes[2], &routes[21], &routes[22], &routes[23], &routes[24], &routes[25] -}; - -static const nrfx_gppi_route_t *apb3a_routes[] = { - &routes[3], &routes[26], &routes[27], &routes[28], &routes[29] -}; - -static const nrfx_gppi_route_t *apb3b_routes[] = { - &routes[4], &routes[30], &routes[31], &routes[32] -}; - -static const nrfx_gppi_route_t *apb3c_routes[] = { - &routes[5], &routes[33], &routes[34] -}; - -static const nrfx_gppi_route_t *apb3d_routes[] = { - &routes[6], &routes[35] -}; - -static const nrfx_gppi_route_t *apb22_routes[] = { - &routes[7] -}; - -static const nrfx_gppi_route_t **dppi_route_map[] = { - apb32_routes, apb38_routes, apb39_routes, apb3a_routes, - apb3b_routes, apb3c_routes, apb3d_routes, apb22_routes -}; - -uint32_t nrfx_gppi_domain_id_get(uint32_t addr) -{ - uint32_t apb = (addr >> 16) & 0xff; - uint32_t domain = (addr >> 24) & 0xf; - - (void)domain; - __ASSERT_NO_MSG(domain == 0xf); - - if (apb < 0x92) { - return NRFX_GPPI_NODE_DPPIC120; - } else if (apb <= 0x93) { - return NRFX_GPPI_NODE_DPPIC130; - } - return apb - 0x98 + NRFX_GPPI_NODE_DPPIC131; -} - -const nrfx_gppi_route_t ***nrfx_gppi_route_map_get(void) -{ - return dppi_route_map; -} - -const nrfx_gppi_route_t *nrfx_gppi_routes_get(void) -{ - return routes; -} - -const nrfx_gppi_node_t *nrfx_gppi_nodes_get(void) -{ - return nodes; -} - -BUILD_ASSERT(SPU_FEATURE_DPPIC_CH_LOCK_Msk == SPU_FEATURE_DPPIC_CHG_LOCK_Msk); -BUILD_ASSERT(SPU_FEATURE_DPPIC_CH_OWNERID_Pos == SPU_FEATURE_DPPIC_CHG_OWNERID_Pos); - -static bool check_spu_value(uint32_t val) -{ - if ((val >> SPU_FEATURE_DPPIC_CH_OWNERID_Pos) != NRF_OWNER) { - return false; - } - - return true; -} - -static int actual_channel_mask(nrfx_gppi_node_id_t node_id, uint32_t *ch_mask, bool group) -{ - static const NRF_SPU_Type * spu_addr[] = { - NRF_SPU131, - NRF_SPU132, - NRF_SPU133, - NRF_SPU134, - NRF_SPU135, - NRF_SPU136, - NRF_SPU137, - NRF_SPU122, - }; - uint32_t out_mask = 0; - uint32_t in_mask = *ch_mask; - struct periphconf_entry entries[IRONSIDE_SE_PERIPHCONF_INLINE_READ_MAX_COUNT]; - uint8_t entries_idx[IRONSIDE_SE_PERIPHCONF_INLINE_READ_MAX_COUNT]; - struct ironside_se_periphconf_status status; - size_t entries_count = 0; - - while (in_mask) { - uint32_t idx = 31 - __builtin_clz(in_mask); - - in_mask &= ~BIT(idx); - /* Collect batch of requests. */ - entries_idx[entries_count] = idx; - entries[entries_count].regptr = group ? - PERIPHCONF_SPU_FEATURE_DPPIC_CHG_REGPTR(spu_addr[node_id], idx) : - PERIPHCONF_SPU_FEATURE_DPPIC_CH_REGPTR(spu_addr[node_id], idx); - entries_count++; - if ((entries_count == ARRAY_SIZE(entries)) || (in_mask == 0)) { - /* Read batch of registers. */ - status = ironside_se_periphconf_read(entries, entries_count); - if (status.status == 0) { - for (uint32_t i = 0; i < entries_count; i++) { - /* If SPU register has default value assume that channel - * is unused and can be in the pool. - */ - if (check_spu_value(entries[i].value)) { - out_mask |= BIT(entries_idx[i]); - } - } - entries_count = 0; - } else { - return status.status; - } - } - } - - *ch_mask = out_mask; - - return 0; -} - -void nrfx_gppi_channel_init(nrfx_gppi_node_id_t node_id, uint32_t ch_mask) -{ - NRFX_ASSERT(node_id < NRFX_GPPI_NODE_COUNT); - int rv; - - if (node_id < NRFX_GPPI_NODE_DPPI_COUNT) { - rv = actual_channel_mask(node_id, &ch_mask, false); - __ASSERT_NO_MSG(rv == 0); - if (rv < 0) { - return; - } - } - - *nodes[node_id].generic.p_channels = ch_mask; -} - -void nrfx_gppi_groups_init(nrfx_gppi_node_id_t node_id, uint32_t group_mask) -{ - NRFX_ASSERT(node_id < NRFX_GPPI_NODE_DPPI_COUNT); - int rv; - - rv = actual_channel_mask(node_id, &group_mask, true); - __ASSERT_NO_MSG(rv == 0); - if (rv < 0) { - return; - } - - *nodes[node_id].dppi.p_group_channels = group_mask; -} - -int nrfx_gppi_ext_ppib_write(volatile uint32_t *p_addr, uint32_t value) -{ - struct ironside_se_periphconf_status status; - - if (p_addr != NULL) { - write_entries[write_entries_count].regptr = (uint32_t)p_addr; - write_entries[write_entries_count].value = value; - write_entries_count++; - if (write_entries_count < ARRAY_SIZE(write_entries)) { - return 0; - } - } - - if (write_entries_count == 0) { - return 0; - } - - status = ironside_se_periphconf_write(write_entries, write_entries_count); - write_entries_count = 0; - - return (status.status < 0) ? -EIO : 0; -} diff --git a/soc/nordic/nrf54h/soc.c b/soc/nordic/nrf54h/soc.c index e5cf9c34fc69..59e146bf997e 100644 --- a/soc/nordic/nrf54h/soc.c +++ b/soc/nordic/nrf54h/soc.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include "soc_power.h" #include #if defined(CONFIG_SOC_NRF54H20_CPURAD_ENABLE) @@ -94,7 +94,7 @@ static int trim_hsfll(void) return 0; } -#if defined(CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK) +#if defined(CONFIG_ARM_ON_ENTER_CPU_IDLE_HOOK) && !defined(CONFIG_NRF_CUSTOM_ON_ENTER_CPU_IDLE_HOOK) bool z_arm_on_enter_cpu_idle(void) { #ifdef CONFIG_LOG_FRONTEND_STMESP diff --git a/soc/nordic/common/haltium_pm_s2ram.c b/soc/nordic/nrf54h/soc_pm_s2ram.c similarity index 85% rename from soc/nordic/common/haltium_pm_s2ram.c rename to soc/nordic/nrf54h/soc_pm_s2ram.c index 976a4677cead..054ad527f611 100644 --- a/soc/nordic/common/haltium_pm_s2ram.c +++ b/soc/nordic/nrf54h/soc_pm_s2ram.c @@ -11,8 +11,8 @@ #include #include #include -#include "haltium_pm_s2ram.h" -#include "haltium_power.h" +#include "soc_pm_s2ram.h" +#include "soc_power.h" #include @@ -77,10 +77,24 @@ static void fpu_power_up(void) } #endif /* defined(CONFIG_FPU) */ +#if DT_NODE_EXISTS(DT_NODELABEL(mcuboot_s2ram)) &&\ + DT_NODE_HAS_COMPAT(DT_NODELABEL(mcuboot_s2ram), zephyr_memory_region) +/* Linker section name is given by `zephyr,memory-region` property of + * `zephyr,memory-region` compatible DT node with nodelabel `mcuboot_s2ram`. + */ +__attribute__((section(DT_PROP(DT_NODELABEL(mcuboot_s2ram), zephyr_memory_region)))) +volatile struct mcuboot_resume_s _mcuboot_resume; + +#define SET_MCUBOOT_RESUME_MAGIC() _mcuboot_resume.magic = MCUBOOT_S2RAM_RESUME_MAGIC +#else +#define SET_MCUBOOT_RESUME_MAGIC() +#endif + int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off) { int ret; + SET_MCUBOOT_RESUME_MAGIC(); z_arm_save_scb_context(&backup_data.scb_context); #if defined(CONFIG_FPU) #if !defined(CONFIG_FPU_SHARING) diff --git a/soc/nordic/nrf54h/soc_pm_s2ram.h b/soc/nordic/nrf54h/soc_pm_s2ram.h new file mode 100644 index 000000000000..743c24a0ca7a --- /dev/null +++ b/soc/nordic/nrf54h/soc_pm_s2ram.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file Common pm_s2ram.h include for Nordic nRF54H SoCs. + */ + +#ifndef ZEPHYR_SOC_NORDIC_NRF54H_SOC_PM_S2RAM_H_ +#define ZEPHYR_SOC_NORDIC_NRF54H_SOC_PM_S2RAM_H_ + +#define MCUBOOT_S2RAM_RESUME_MAGIC 0x75832419 + +struct mcuboot_resume_s { + uint32_t magic; /* magic value to identify valid structure */ + uint32_t slot_info; +}; + +/** + * @brief Save CPU state on suspend + * + * This function is used on suspend-to-RAM (S2RAM) to save the CPU state in + * (retained) RAM before powering the system off using the provided function. + * This function is usually called from the PM subsystem / hooks. + * + * The CPU state consist of internal registers and peripherals like + * interrupt controller, memory controllers, etc. + * + * @param system_off Function to power off the system. + * + * @retval 0 The CPU context was successfully saved and restored. + * @retval -EBUSY The system is busy and cannot be suspended at this time. + * @retval -errno Negative errno code in case of failure. + */ +int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off); + +#endif /* ZEPHYR_SOC_NORDIC_NRF54H_SOC_PM_S2RAM_H_ */ diff --git a/soc/nordic/common/haltium_power.c b/soc/nordic/nrf54h/soc_power.c similarity index 95% rename from soc/nordic/common/haltium_power.c rename to soc/nordic/nrf54h/soc_power.c index aa4fcb1616e3..692a54ec7f53 100644 --- a/soc/nordic/common/haltium_power.c +++ b/soc/nordic/nrf54h/soc_power.c @@ -12,12 +12,12 @@ #include #include #include -#include +#include "soc_power.h" #include #include -#include "haltium_pm_s2ram.h" +#include "soc_pm_s2ram.h" -#if defined(CONFIG_SOC_NRF54H20_CPUAPP) || defined(CONFIG_SOC_NRF9280_CPUAPP) +#if defined(CONFIG_SOC_NRF54H20_CPUAPP) #define RAMBLOCK_CONTROL_BIT_ICACHE MEMCONF_POWER_CONTROL_MEM1_Pos #define RAMBLOCK_CONTROL_BIT_DCACHE MEMCONF_POWER_CONTROL_MEM2_Pos #define RAMBLOCK_POWER_ID 0 @@ -25,7 +25,7 @@ #define RAMBLOCK_RET_MASK (MEMCONF_POWER_RET_MEM0_Msk) #define RAMBLOCK_RET_BIT_ICACHE MEMCONF_POWER_RET_MEM1_Pos #define RAMBLOCK_RET_BIT_DCACHE MEMCONF_POWER_RET_MEM2_Pos -#elif defined(CONFIG_SOC_NRF54H20_CPURAD) || defined(CONFIG_SOC_NRF9280_CPURAD) +#elif defined(CONFIG_SOC_NRF54H20_CPURAD) #define RAMBLOCK_CONTROL_BIT_ICACHE MEMCONF_POWER_CONTROL_MEM6_Pos #define RAMBLOCK_CONTROL_BIT_DCACHE MEMCONF_POWER_CONTROL_MEM7_Pos #define RAMBLOCK_POWER_ID 0 @@ -250,7 +250,7 @@ static void s2ram_exit(void) /* Function called during local domain suspend to RAM. */ static int sys_suspend_to_ram(void) { - /* Set intormation which is used on domain wakeup to determine if resume from RAM shall + /* Set information which is used on domain wakeup to determine if resume from RAM shall * be performed. */ nrf_resetinfo_resetreas_local_set(NRF_RESETINFO, @@ -268,7 +268,7 @@ static int sys_suspend_to_ram(void) __DSB(); __WFI(); /* - * We might reach this point is k_cpu_idle returns (there is a pre sleep hook that + * We might reach this point if k_cpu_idle returns (there is a pre sleep hook that * can abort sleeping. */ return -EBUSY; @@ -277,7 +277,7 @@ static int sys_suspend_to_ram(void) static void s2ram_enter(void) { /* - * Save the CPU context (including the return address),set the SRAM + * Save the CPU context (including the return address), set the SRAM * marker and power off the system. */ if (soc_s2ram_suspend(sys_suspend_to_ram)) { diff --git a/soc/nordic/nrf54h/soc_power.h b/soc/nordic/nrf54h/soc_power.h new file mode 100644 index 000000000000..8d8ed8a8a8f2 --- /dev/null +++ b/soc/nordic/nrf54h/soc_power.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file Common power management for Nordic nRF54H SoCs. + */ + +#ifndef ZEPHYR_SOC_NORDIC_NRF54H_SOC_POWER_H_ +#define ZEPHYR_SOC_NORDIC_NRF54H_SOC_POWER_H_ + +/** + * @brief Power domain early init. + * + */ +void nrf_power_domain_init(void); + +#if defined(CONFIG_PM) || defined(CONFIG_POWEROFF) +/** + * @brief Perform a power off. + * + * This function performs a power off of the core. + */ +void nrf_poweroff(void); + +/** + * @brief Power up and enable instruction and data cache. + */ +void nrf_power_up_cache(void); +#endif /* defined(CONFIG_PM) || defined(CONFIG_POWEROFF) */ + +#endif /* ZEPHYR_SOC_NORDIC_NRF54H_SOC_POWER_H_ */ diff --git a/soc/nordic/nrf54l/CMakeLists.txt b/soc/nordic/nrf54l/CMakeLists.txt index cebbda571b68..b220b9d2a7a2 100644 --- a/soc/nordic/nrf54l/CMakeLists.txt +++ b/soc/nordic/nrf54l/CMakeLists.txt @@ -6,3 +6,16 @@ zephyr_library_sources( ../validate_rram_partitions.c ) zephyr_include_directories(.) + +dt_nodelabel(kmu_push_area_node NODELABEL nrf_kmu_reserved_push_area) + +# We need a buffer in memory in a static location which can be used by +# the KMU peripheral. The KMU has a static destination address, we chose +# this address to be 0x20000000, which is the first address in the SRAM. +if(NOT CONFIG_BUILD_WITH_TFM AND CONFIG_PSA_NEED_CRACEN_KMU_DRIVER AND NOT kmu_push_area_node) +# Exclamation mark is printable character with the lowest number in ASCII table. +# We are sure that this file will be included first. +zephyr_linker_sources(RAM_SECTIONS SORT_KEY ! kmu_push_area_section.ld) + +zephyr_linker_section(NAME ".nrf_kmu_reserved_push_area" ADDRESS "${RAM_ADDR}" GROUP RAM_REGION NOINIT) +endif() diff --git a/soc/nordic/nrf54l/Kconfig b/soc/nordic/nrf54l/Kconfig index 94a76b03e919..86f44c615bec 100644 --- a/soc/nordic/nrf54l/Kconfig +++ b/soc/nordic/nrf54l/Kconfig @@ -8,7 +8,6 @@ config SOC_SERIES_NRF54L select HAS_NRFX select HAS_NORDIC_DRIVERS select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE - select NRF_PLATFORM_LUMOS config SOC_SERIES_NRF54LX select DEPRECATED diff --git a/soc/nordic/nrf54l/Kconfig.defconfig b/soc/nordic/nrf54l/Kconfig.defconfig index 2cd38dca0e95..0f9b60762dcd 100644 --- a/soc/nordic/nrf54l/Kconfig.defconfig +++ b/soc/nordic/nrf54l/Kconfig.defconfig @@ -33,7 +33,8 @@ choice NULL_POINTER_EXCEPTION_DETECTION endchoice config ROM_START_OFFSET - default 0x800 if BOOTLOADER_MCUBOOT + default 0 if PARTITION_MANAGER_ENABLED + default 0x800 if BOOTLOADER_MCUBOOT && !BUILD_WITH_TFM endif # ARM diff --git a/soc/nordic/nrf54l/kmu_push_area_section.ld b/soc/nordic/nrf54l/kmu_push_area_section.ld new file mode 100644 index 000000000000..e8c8cd9f09ad --- /dev/null +++ b/soc/nordic/nrf54l/kmu_push_area_section.ld @@ -0,0 +1,19 @@ +# This section must be loaded first of all the +# custom sections because we want it to be placed +# at the top address of RAM. +SECTION_PROLOGUE(NRF_KMU_RESERVED_PUSH_SECTION,(NOLOAD) ,) +{ + __nrf_kmu_reserved_push_area = .; + *(.nrf_kmu_reserved_push_area) + __nrf_kmu_reserved_push_area_end = .; +} GROUP_NOLOAD_LINK_IN(RAMABLE_REGION, RAMABLE_REGION) + +# It doesn't seem to be possible to enforce placing a section +# at a specific address in memory using the Zephyr SECTION macros. +# So this assert is necessary to avoid accidentatly moving this +# section to a different address. +ASSERT(__nrf_kmu_reserved_push_area == RAM_ADDR, "Error: \ + The section NRF_KMU_RESERVED_PUSH_SECTION needs to be \ + placed on the top RAM address but it is not, please edit \ + your linker scripts to make sure that it is placed on \ + the to RAM address.") diff --git a/soc/nordic/nrf71/Kconfig b/soc/nordic/nrf71/Kconfig index e58604ab3102..8f2ca6890e51 100644 --- a/soc/nordic/nrf71/Kconfig +++ b/soc/nordic/nrf71/Kconfig @@ -10,7 +10,6 @@ config SOC_SERIES_NRF71 select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE select SOC_EARLY_INIT_HOOK select SOC_RESET_HOOK - select NRF_PLATFORM_LUMOS config SOC_NRF7120_ENGA_CPUAPP select ARM diff --git a/soc/nordic/nrf71/Kconfig.sysbuild b/soc/nordic/nrf71/Kconfig.sysbuild new file mode 100644 index 000000000000..f835ed6ab56c --- /dev/null +++ b/soc/nordic/nrf71/Kconfig.sysbuild @@ -0,0 +1,18 @@ +# Copyright (c) 2026 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if SOC_NRF7120_ENGA_CPUFLPR + +config HAS_NORDIC_VPR_LAUNCHER_IMAGE + default y + +endif + +config SOC_NRF71_GENERATE_UICR + bool "Generate nRF71 UICR hex" + depends on SOC_SERIES_NRF71 + default y + help + When enabled, a UICR generator image is included in the build. + This generates a standalone hex containing UICR values derived from + the devicetree (nordic,nrf71-uicr binding). diff --git a/soc/nordic/nrf71/uicr/gen_uicr/CMakeLists.txt b/soc/nordic/nrf71/uicr/gen_uicr/CMakeLists.txt new file mode 100644 index 000000000000..8d1204b7059d --- /dev/null +++ b/soc/nordic/nrf71/uicr/gen_uicr/CMakeLists.txt @@ -0,0 +1,70 @@ +# Copyright (c) 2026 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr + COMPONENTS zephyr_default:boards + REQUIRED HINTS $ENV{ZEPHYR_BASE} +) + +project(uicr LANGUAGES NONE) + +# Override the runners.yaml path to use CMAKE_CURRENT_BINARY_DIR/zephyr +# instead of PROJECT_BINARY_DIR, this ensures runners.yaml is generated +# at /uicr/zephyr where west expects it +set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/zephyr) + +set(gen_script ${CMAKE_CURRENT_LIST_DIR}/gen_uicr.py) +set(uicr_hex ${PROJECT_BINARY_DIR}/zephyr.hex) + +zephyr_get(DEFAULT_IMAGE_EDT_PICKLE SYSBUILD GLOBAL) + +if(NOT DEFAULT_IMAGE_EDT_PICKLE) + message(FATAL_ERROR + "DEFAULT_IMAGE_EDT_PICKLE not found. " + "The UICR generator must be built via sysbuild." + ) +endif() + +add_custom_command( + OUTPUT ${uicr_hex} + COMMAND ${PYTHON_EXECUTABLE} ${gen_script} + --zephyr-base ${ZEPHYR_BASE} + --edt-pickle ${DEFAULT_IMAGE_EDT_PICKLE} + --output ${uicr_hex} + DEPENDS ${DEFAULT_IMAGE_EDT_PICKLE} ${gen_script} + COMMENT "Generating UICR hex: ${uicr_hex}" +) + +add_custom_target(gen_uicr ALL DEPENDS ${uicr_hex}) + +# Create the runners_yaml_props_target that flash system expects +add_custom_target(runners_yaml_props_target) + +# Copy over Kconfig and dts files from the main image +get_filename_component(default_image_binary_dir ${DEFAULT_IMAGE_EDT_PICKLE} DIRECTORY) +zephyr_file_copy(${default_image_binary_dir}/.config ${PROJECT_BINARY_DIR}/.config + ONLY_IF_DIFFERENT +) +zephyr_file_copy(${default_image_binary_dir}/edt.pickle ${PROJECT_BINARY_DIR}/edt.pickle + ONLY_IF_DIFFERENT +) +import_kconfig(CONFIG_ ${default_image_binary_dir}/.config) + +# Manually include board configuration to enable automatic runners.yaml generation +foreach(dir ${BOARD_DIRECTORIES}) + include(${dir}/board.cmake OPTIONAL) +endforeach() + +# Override hex_file after board.cmake to ensure it always flash its own output +set_target_properties(runners_yaml_props_target PROPERTIES + hex_file "zephyr.hex" +) + +# Include flash support to automatically generate runners.yaml +include(${ZEPHYR_BASE}/cmake/flash/CMakeLists.txt) + +# Silent unused variable warnings +set(EXTRA_KCONFIG_TARGETS) +set(FORCED_CONF_FILE) diff --git a/soc/nordic/nrf71/uicr/gen_uicr/gen_uicr.py b/soc/nordic/nrf71/uicr/gen_uicr/gen_uicr.py new file mode 100644 index 000000000000..c120f8fa91f2 --- /dev/null +++ b/soc/nordic/nrf71/uicr/gen_uicr/gen_uicr.py @@ -0,0 +1,112 @@ +# Copyright 2026 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +""" +Generate an Intel HEX file containing nRF71 UICR register values +read from a Zephyr edtlib.EDT pickle. +""" + +import argparse +import pickle +import struct +import sys +from pathlib import Path + +from intelhex import IntelHex + +UICR_COMPATIBLE = "nordic,nrf71-uicr" + +# ── Field table ────────────────────────────────────────────────────── +# +# Each entry describes one UICR register field configurable via DTS. +# +# property – DTS property name (must match the binding YAML) +# offset – byte offset from UICR base +# mask – bit mask of the field within the 32-bit register +# encoding – maps DTS string values to integer field values +# reset – 32-bit reset value +# +# The full register word is computed as: +# word = (reset & ~mask) | (encoding[value] & mask) +# + +UICR_FIELDS = [ + { + "property": "supply-config1v8", + "offset": 0x400, + "mask": 0x00000003, + "encoding": { + "normal": 0, + "external": 1, + "high-load": 2, + }, + "reset": 0xFFFFFFFF, + }, +] + + +def setup_devicetree_path(zephyr_base): + """Add the devicetree package to sys.path so EDT can be unpickled.""" + + devicetree_path = Path(zephyr_base) / "scripts/dts/python-devicetree/src" + if not devicetree_path.is_dir(): + sys.exit(f"Devicetree path does not exist: {devicetree_path}") + sys.path.insert(0, str(devicetree_path)) + + +def parse_uicr(args): + setup_devicetree_path(args.zephyr_base) + + with open(args.edt_pickle, "rb") as f: + edt = pickle.load(f) + + # Find the UICR node. + uicr_nodes = edt.compat2okay.get(UICR_COMPATIBLE, []) + if not uicr_nodes: + IntelHex().write_hex_file(args.output) + return + + uicr = uicr_nodes[0] + base = uicr.regs[0].addr + + ih = IntelHex() + + for field in UICR_FIELDS: + prop = uicr.props.get(field["property"]) + if prop is None: + continue + + val_str = prop.val + encoding = field["encoding"] + if val_str not in encoding: + valid = ", ".join(f'"{k}"' for k in encoding) + sys.exit(f"Unknown value '{val_str}' for '{field['property']}'. Expected: {valid}") + + mask = field["mask"] + word = (field["reset"] & ~mask) | (encoding[val_str] & mask) + addr = base + field["offset"] + ih.puts(addr, struct.pack(" #include #include -#include +#include "soc_power.h" #include LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL); diff --git a/soc/nordic/nrf92/soc_pm_s2ram.c b/soc/nordic/nrf92/soc_pm_s2ram.c new file mode 100644 index 000000000000..054ad527f611 --- /dev/null +++ b/soc/nordic/nrf92/soc_pm_s2ram.c @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "soc_pm_s2ram.h" +#include "soc_power.h" + +#include + +#define NVIC_MEMBER_SIZE(member) ARRAY_SIZE(((NVIC_Type *)0)->member) + +/* Coprocessor Power Control Register Definitions */ +#define SCnSCB_CPPWR_SU11_Pos 22U /*!< CPPWR: SU11 Position */ +#define SCnSCB_CPPWR_SU11_Msk (1UL << SCnSCB_CPPWR_SU11_Pos) /*!< CPPWR: SU11 Mask */ + +#define SCnSCB_CPPWR_SU10_Pos 20U /*!< CPPWR: SU10 Position */ +#define SCnSCB_CPPWR_SU10_Msk (1UL << SCnSCB_CPPWR_SU10_Pos) /*!< CPPWR: SU10 Mask */ + +typedef struct { + /* NVIC components stored into RAM. */ + uint32_t ISER[NVIC_MEMBER_SIZE(ISER)]; + uint32_t ISPR[NVIC_MEMBER_SIZE(ISPR)]; + uint8_t IPR[NVIC_MEMBER_SIZE(IPR)]; +} _nvic_context_t; + +struct backup { + _nvic_context_t nvic_context; +#if defined(CONFIG_ARM_MPU) + struct z_mpu_context_retained mpu_context; +#endif + struct scb_context scb_context; +#if defined(CONFIG_FPU) && !defined(CONFIG_FPU_SHARING) + struct fpu_ctx_full fpu_context; +#endif +}; + +static __noinit struct backup backup_data; + +static void nvic_save(_nvic_context_t *backup) +{ + memcpy(backup->ISER, (uint32_t *)NVIC->ISER, sizeof(NVIC->ISER)); + memcpy(backup->ISPR, (uint32_t *)NVIC->ISPR, sizeof(NVIC->ISPR)); + memcpy(backup->IPR, (uint32_t *)NVIC->IPR, sizeof(NVIC->IPR)); +} + +static void nvic_restore(_nvic_context_t *backup) +{ + memcpy((uint32_t *)NVIC->ISER, backup->ISER, sizeof(NVIC->ISER)); + memcpy((uint32_t *)NVIC->ISPR, backup->ISPR, sizeof(NVIC->ISPR)); + memcpy((uint32_t *)NVIC->IPR, backup->IPR, sizeof(NVIC->IPR)); +} + +#if defined(CONFIG_FPU) +static void fpu_power_down(void) +{ + SCB->CPACR &= (~(CPACR_CP10_Msk | CPACR_CP11_Msk)); + SCnSCB->CPPWR |= (SCnSCB_CPPWR_SU11_Msk | SCnSCB_CPPWR_SU10_Msk); + __DSB(); + __ISB(); +} + +static void fpu_power_up(void) +{ + SCnSCB->CPPWR &= (~(SCnSCB_CPPWR_SU11_Msk | SCnSCB_CPPWR_SU10_Msk)); + SCB->CPACR |= (CPACR_CP10_Msk | CPACR_CP11_Msk); + __DSB(); + __ISB(); +} +#endif /* defined(CONFIG_FPU) */ + +#if DT_NODE_EXISTS(DT_NODELABEL(mcuboot_s2ram)) &&\ + DT_NODE_HAS_COMPAT(DT_NODELABEL(mcuboot_s2ram), zephyr_memory_region) +/* Linker section name is given by `zephyr,memory-region` property of + * `zephyr,memory-region` compatible DT node with nodelabel `mcuboot_s2ram`. + */ +__attribute__((section(DT_PROP(DT_NODELABEL(mcuboot_s2ram), zephyr_memory_region)))) +volatile struct mcuboot_resume_s _mcuboot_resume; + +#define SET_MCUBOOT_RESUME_MAGIC() _mcuboot_resume.magic = MCUBOOT_S2RAM_RESUME_MAGIC +#else +#define SET_MCUBOOT_RESUME_MAGIC() +#endif + +int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off) +{ + int ret; + + SET_MCUBOOT_RESUME_MAGIC(); + z_arm_save_scb_context(&backup_data.scb_context); +#if defined(CONFIG_FPU) +#if !defined(CONFIG_FPU_SHARING) + z_arm_save_fp_context(&backup_data.fpu_context); +#endif + fpu_power_down(); +#endif + nvic_save(&backup_data.nvic_context); +#if defined(CONFIG_ARM_MPU) + z_arm_save_mpu_context(&backup_data.mpu_context); +#endif + ret = arch_pm_s2ram_suspend(system_off); + /* Cache and FPU are powered down so power up is needed even if s2ram failed. */ + nrf_power_up_cache(); +#if defined(CONFIG_FPU) + fpu_power_up(); +#if !defined(CONFIG_FPU_SHARING) + /* Also the FPU content might be lost. */ + z_arm_restore_fp_context(&backup_data.fpu_context); +#endif +#endif + if (ret < 0) { + return ret; + } + +#if defined(CONFIG_ARM_MPU) + z_arm_restore_mpu_context(&backup_data.mpu_context); +#endif + nvic_restore(&backup_data.nvic_context); + z_arm_restore_scb_context(&backup_data.scb_context); + + return ret; +} + +void pm_s2ram_mark_set(void) +{ + /* empty */ +} + +bool pm_s2ram_mark_check_and_clear(void) +{ + bool restore_valid; + uint32_t reset_reason = nrf_resetinfo_resetreas_local_get(NRF_RESETINFO); + + if (reset_reason != NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK) { + return false; + } + nrf_resetinfo_resetreas_local_set(NRF_RESETINFO, 0); + + restore_valid = nrf_resetinfo_restore_valid_check(NRF_RESETINFO); + nrf_resetinfo_restore_valid_set(NRF_RESETINFO, false); + + return restore_valid; +} diff --git a/soc/nordic/nrf92/soc_pm_s2ram.h b/soc/nordic/nrf92/soc_pm_s2ram.h new file mode 100644 index 000000000000..235ebefa8d15 --- /dev/null +++ b/soc/nordic/nrf92/soc_pm_s2ram.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file Common pm_s2ram.h include for Nordic nRF92 SoCs. + */ + +#ifndef ZEPHYR_SOC_NORDIC_NRF92_SOC_PM_S2RAM_H_ +#define ZEPHYR_SOC_NORDIC_NRF92_SOC_PM_S2RAM_H_ + +#define MCUBOOT_S2RAM_RESUME_MAGIC 0x75832419 + +struct mcuboot_resume_s { + uint32_t magic; /* magic value to identify valid structure */ + uint32_t slot_info; +}; + +/** + * @brief Save CPU state on suspend + * + * This function is used on suspend-to-RAM (S2RAM) to save the CPU state in + * (retained) RAM before powering the system off using the provided function. + * This function is usually called from the PM subsystem / hooks. + * + * The CPU state consist of internal registers and peripherals like + * interrupt controller, memory controllers, etc. + * + * @param system_off Function to power off the system. + * + * @retval 0 The CPU context was successfully saved and restored. + * @retval -EBUSY The system is busy and cannot be suspended at this time. + * @retval -errno Negative errno code in case of failure. + */ +int soc_s2ram_suspend(pm_s2ram_system_off_fn_t system_off); + +#endif /* ZEPHYR_SOC_NORDIC_NRF92_SOC_PM_S2RAM_H_ */ diff --git a/soc/nordic/nrf92/soc_power.c b/soc/nordic/nrf92/soc_power.c new file mode 100644 index 000000000000..fe96d9d8cbd8 --- /dev/null +++ b/soc/nordic/nrf92/soc_power.c @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "soc_power.h" +#include +#include +#include "soc_pm_s2ram.h" + +#if defined(CONFIG_SOC_NRF9280_CPUAPP) +#define RAMBLOCK_CONTROL_BIT_ICACHE MEMCONF_POWER_CONTROL_MEM1_Pos +#define RAMBLOCK_CONTROL_BIT_DCACHE MEMCONF_POWER_CONTROL_MEM2_Pos +#define RAMBLOCK_POWER_ID 0 +#define RAMBLOCK_CONTROL_OFF 0 +#define RAMBLOCK_RET_MASK (MEMCONF_POWER_RET_MEM0_Msk) +#define RAMBLOCK_RET_BIT_ICACHE MEMCONF_POWER_RET_MEM1_Pos +#define RAMBLOCK_RET_BIT_DCACHE MEMCONF_POWER_RET_MEM2_Pos +#elif defined(CONFIG_SOC_NRF9280_CPURAD) +#define RAMBLOCK_CONTROL_BIT_ICACHE MEMCONF_POWER_CONTROL_MEM6_Pos +#define RAMBLOCK_CONTROL_BIT_DCACHE MEMCONF_POWER_CONTROL_MEM7_Pos +#define RAMBLOCK_POWER_ID 0 +#define RAMBLOCK_CONTROL_OFF 0 +#define RAMBLOCK_RET_MASK \ + (MEMCONF_POWER_RET_MEM0_Msk | MEMCONF_POWER_RET_MEM1_Msk | MEMCONF_POWER_RET_MEM2_Msk | \ + MEMCONF_POWER_RET_MEM3_Msk | MEMCONF_POWER_RET_MEM4_Msk | MEMCONF_POWER_RET_MEM5_Msk | \ + MEMCONF_POWER_RET_MEM8_Msk) +#define RAMBLOCK_RET2_MASK \ + (MEMCONF_POWER_RET2_MEM0_Msk | MEMCONF_POWER_RET2_MEM1_Msk | MEMCONF_POWER_RET2_MEM2_Msk | \ + MEMCONF_POWER_RET2_MEM3_Msk | MEMCONF_POWER_RET2_MEM4_Msk | MEMCONF_POWER_RET2_MEM5_Msk | \ + MEMCONF_POWER_RET2_MEM8_Msk) +#define RAMBLOCK_RET_BIT_ICACHE MEMCONF_POWER_RET_MEM6_Pos +#define RAMBLOCK_RET_BIT_DCACHE MEMCONF_POWER_RET_MEM7_Pos +#define RAMBLOCK_RET2_BIT_ICACHE MEMCONF_POWER_RET2_MEM6_Pos +#define RAMBLOCK_RET2_BIT_DCACHE MEMCONF_POWER_RET2_MEM7_Pos +#endif + +static sys_snode_t soc_node; + +static void nrf_soc_memconf_retain_set(bool enable) +{ + uint32_t ret_mask = BIT(RAMBLOCK_RET_BIT_ICACHE) | BIT(RAMBLOCK_RET_BIT_DCACHE); + + nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 0, ret_mask, enable); + nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 1, ret_mask, enable); + +#if defined(RAMBLOCK_RET2_MASK) + ret_mask = 0; +#if defined(RAMBLOCK_RET2_BIT_ICACHE) + ret_mask |= BIT(RAMBLOCK_RET2_BIT_ICACHE); +#endif +#if defined(RAMBLOCK_RET2_BIT_DCACHE) + ret_mask |= BIT(RAMBLOCK_RET2_BIT_DCACHE); +#endif + nrf_memconf_ramblock_ret2_mask_enable_set(NRF_MEMCONF, 0, ret_mask, enable); + nrf_memconf_ramblock_ret2_mask_enable_set(NRF_MEMCONF, 1, ret_mask, enable); +#endif /* defined(RAMBLOCK_RET2_MASK) */ +} + +void nrf_power_domain_init(void) +{ + /* + * Set: + * - LRCCONF010.POWERON.MAIN: 1 + * - LRCCONF010.POWERON.ACT: 1 + * - LRCCONF010.RETAIN.MAIN: 1 + * - LRCCONF010.RETAIN.ACT: 1 + * + * This is done here at boot so that when the idle routine will hit + * WFI the power domain will be correctly retained. + */ + + soc_lrcconf_poweron_request(&soc_node, NRF_LRCCONF_POWER_DOMAIN_0); + nrf_lrcconf_poweron_force_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_MAIN, false); + nrf_soc_memconf_retain_set(false); + nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 0, RAMBLOCK_RET_MASK, true); + nrf_memconf_ramblock_ret_mask_enable_set(NRF_MEMCONF, 1, RAMBLOCK_RET_MASK, true); +#if defined(RAMBLOCK_RET2_MASK) + nrf_memconf_ramblock_ret2_mask_enable_set(NRF_MEMCONF, 0, RAMBLOCK_RET2_MASK, true); + nrf_memconf_ramblock_ret2_mask_enable_set(NRF_MEMCONF, 1, RAMBLOCK_RET2_MASK, true); +#endif +} + +#if defined(CONFIG_PM) || defined(CONFIG_POWEROFF) + +static void nrf_power_down_cache(void) +{ + static const uint32_t msk = + (IS_ENABLED(CONFIG_DCACHE) ? BIT(RAMBLOCK_CONTROL_BIT_DCACHE) : 0) | + (IS_ENABLED(CONFIG_ICACHE) ? BIT(RAMBLOCK_CONTROL_BIT_ICACHE) : 0); + + if (msk == 0) { + return; + } + + /* Functions are non-empty only if cache is enabled. + * Data cache disabling include flushing. + */ + sys_cache_data_disable(); + sys_cache_instr_disable(); + nrf_memconf_ramblock_control_mask_enable_set(NRF_MEMCONF, RAMBLOCK_POWER_ID, msk, false); +} + +void nrf_power_up_cache(void) +{ + static const uint32_t msk = + (IS_ENABLED(CONFIG_DCACHE) ? BIT(RAMBLOCK_CONTROL_BIT_DCACHE) : 0) | + (IS_ENABLED(CONFIG_ICACHE) ? BIT(RAMBLOCK_CONTROL_BIT_ICACHE) : 0); + + if (msk == 0) { + return; + } + + nrf_memconf_ramblock_control_mask_enable_set(NRF_MEMCONF, RAMBLOCK_POWER_ID, msk, true); + sys_cache_instr_enable(); + sys_cache_data_enable(); +} + +static void common_suspend(void) +{ + soc_lrcconf_poweron_release(&soc_node, NRF_LRCCONF_POWER_DOMAIN_0); + nrf_power_down_cache(); +} + +static void common_resume(void) +{ + /* Common part does not include cache enabling. In case of s2ram it is done + * as early as possible to speed up the process. + */ + soc_lrcconf_poweron_request(&soc_node, NRF_LRCCONF_POWER_DOMAIN_0); +} + +void nrf_poweroff(void) +{ + nrf_resetinfo_resetreas_local_set(NRF_RESETINFO, 0); + nrf_resetinfo_restore_valid_set(NRF_RESETINFO, false); + + /* Disable retention */ + nrf_lrcconf_retain_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_MAIN, false); + nrf_lrcconf_retain_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, false); + + common_suspend(); + + nrf_lrcconf_task_trigger(NRF_LRCCONF010, NRF_LRCCONF_TASK_SYSTEMOFFREADY); + + __set_BASEPRI(0); + __ISB(); + __DSB(); + __WFI(); + + CODE_UNREACHABLE; +} + +#if CONFIG_MCUBOOT +static __ramfunc +#else +static __attribute__((__used__, noinline)) +#endif +void cache_retain_and_sleep(void) +{ + nrf_cache_task_trigger(NRF_DCACHE, NRF_CACHE_TASK_SAVE); + nrf_cache_task_trigger(NRF_ICACHE, NRF_CACHE_TASK_SAVE); + while (nrf_cache_busy_check(NRF_DCACHE) || + nrf_cache_busy_check(NRF_ICACHE)) { + + } + + __set_BASEPRI(0); + __ISB(); + __DSB(); + __WFI(); + + nrf_cache_task_trigger(NRF_ICACHE, NRF_CACHE_TASK_RESTORE); + nrf_cache_task_trigger(NRF_DCACHE, NRF_CACHE_TASK_RESTORE); + while (nrf_cache_busy_check(NRF_DCACHE) || + nrf_cache_busy_check(NRF_ICACHE)) { + + } +} + +void s2idle_enter(uint8_t substate_id) +{ + soc_lrcconf_poweron_request(&soc_node, NRF_LRCCONF_POWER_MAIN); + + switch (substate_id) { + case 0: + /* Substate for idle with cache powered on - not implemented yet. */ + break; + case 1: /* Substate for idle with cache retained. */ + soc_lrcconf_poweron_release(&soc_node, NRF_LRCCONF_POWER_DOMAIN_0); + nrf_soc_memconf_retain_set(true); + cache_retain_and_sleep(); + return; + case 2: /* Substate for idle with cache disabled. */ + common_suspend(); + break; + default: /* Unknown substate. */ + return; + } + + __set_BASEPRI(0); + __ISB(); + __DSB(); + __WFI(); +} + +static void s2idle_exit(uint8_t substate_id) +{ + switch (substate_id) { + case 0: + /* Substate for idle with cache powered on - not implemented yet. */ + break; + case 1: /* Substate for idle with cache retained. */ + nrf_soc_memconf_retain_set(false); + break; + case 2: /* Substate for idle with cache disabled. */ + nrf_power_up_cache(); + break; + default: /* Unknown substate. */ + return; + } + common_resume(); + + soc_lrcconf_poweron_release(&soc_node, NRF_LRCCONF_POWER_MAIN); +} + +#if defined(CONFIG_PM_S2RAM) +/* Resume domain after local suspend to RAM. */ +static void s2ram_exit(void) +{ + common_resume(); + + /* Re-enable domain retention. */ + nrf_lrcconf_retain_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, true); +} + +/* Function called during local domain suspend to RAM. */ +static int sys_suspend_to_ram(void) +{ + /* Set information which is used on domain wakeup to determine if resume from RAM shall + * be performed. + */ + nrf_resetinfo_resetreas_local_set(NRF_RESETINFO, + NRF_RESETINFO_RESETREAS_LOCAL_UNRETAINED_MASK); + nrf_resetinfo_restore_valid_set(NRF_RESETINFO, true); + + /* Disable retention */ + nrf_lrcconf_retain_set(NRF_LRCCONF010, NRF_LRCCONF_POWER_DOMAIN_0, false); + + common_suspend(); + + __set_BASEPRI(0); + __ISB(); + __DSB(); + __WFI(); + /* + * We might reach this point if k_cpu_idle returns (there is a pre sleep hook that + * can abort sleeping. + */ + return -EBUSY; +} + +static void s2ram_enter(void) +{ + /* + * Save the CPU context (including the return address), set the SRAM + * marker and power off the system. + */ + if (soc_s2ram_suspend(sys_suspend_to_ram)) { + return; + } +} +#endif /* defined(CONFIG_PM_S2RAM) */ + +void pm_state_set(enum pm_state state, uint8_t substate_id) +{ + if (state == PM_STATE_SUSPEND_TO_IDLE) { + __disable_irq(); + sys_trace_idle(); + s2idle_enter(substate_id); + /* Resume here. */ + s2idle_exit(substate_id); + sys_trace_idle_exit(); + __enable_irq(); + } +#if defined(CONFIG_PM_S2RAM) + else if (state == PM_STATE_SUSPEND_TO_RAM) { + __disable_irq(); + sys_trace_idle(); + s2ram_enter(); + /* On resuming or error we return exactly *HERE* */ + s2ram_exit(); + sys_trace_idle_exit(); + __enable_irq(); + } +#endif + else { + k_cpu_idle(); + } +} + +void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id) +{ + irq_unlock(0); +} + +#endif /* defined(CONFIG_PM) || defined(CONFIG_POWEROFF) */ diff --git a/soc/nordic/nrf92/soc_power.h b/soc/nordic/nrf92/soc_power.h new file mode 100644 index 000000000000..5c7d5abaf29a --- /dev/null +++ b/soc/nordic/nrf92/soc_power.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file Common power management for Nordic nRF92 SoCs. + */ + +#ifndef ZEPHYR_SOC_NORDIC_NRF92_SOC_POWER_H_ +#define ZEPHYR_SOC_NORDIC_NRF92_SOC_POWER_H_ + +/** + * @brief Power domain early init. + * + */ +void nrf_power_domain_init(void); + +#if defined(CONFIG_PM) || defined(CONFIG_POWEROFF) +/** + * @brief Perform a power off. + * + * This function performs a power off of the core. + */ +void nrf_poweroff(void); + +/** + * @brief Power up and enable instruction and data cache. + */ +void nrf_power_up_cache(void); +#endif /* defined(CONFIG_PM) || defined(CONFIG_POWEROFF) */ + +#endif /* ZEPHYR_SOC_NORDIC_NRF92_SOC_POWER_H_ */ diff --git a/soc/nordic/sysbuild.cmake b/soc/nordic/sysbuild.cmake index c20185c93f3b..7154ed5e2f6e 100644 --- a/soc/nordic/sysbuild.cmake +++ b/soc/nordic/sysbuild.cmake @@ -30,6 +30,10 @@ if(SB_CONFIG_VPR_LAUNCHER) sysbuild_cache_set(VAR ${image}_SNIPPET APPEND REMOVE_DUPLICATES ${launcher_snippet}) endif() -if(SB_CONFIG_NRF_HALTIUM_GENERATE_UICR) +if(SB_CONFIG_NRF_GENERATE_UICR) include(${CMAKE_CURRENT_LIST_DIR}/common/uicr/sysbuild.cmake) endif() + +if(SB_CONFIG_SOC_NRF71_GENERATE_UICR) + include(${CMAKE_CURRENT_LIST_DIR}/nrf71/uicr/sysbuild.cmake) +endif() \ No newline at end of file diff --git a/soc/nordic/validate_base_addresses.c b/soc/nordic/validate_base_addresses.c index 321549cfb047..f92e77588936 100644 --- a/soc/nordic/validate_base_addresses.c +++ b/soc/nordic/validate_base_addresses.c @@ -373,7 +373,7 @@ CHECK_DT_REG(cpuflpr_clic, NRF_FLPR_VPRCLIC); CHECK_DT_REG(cpuppr_clic, NRF_PPR_VPRCLIC); #if defined(CONFIG_SOC_SERIES_NRF54L) CHECK_DT_REG(cpuflpr_vpr, NRF_VPR00); -#elif defined(CONFIG_NRF_PLATFORM_HALTIUM) +#elif defined(CONFIG_SOC_SERIES_NRF54H) || defined(CONFIG_SOC_SERIES_NRF92) CHECK_DT_REG(cpuflpr_vpr, NRF_VPR121); CHECK_DT_REG(cpuppr_vpr, NRF_VPR130); #endif diff --git a/subsys/bluetooth/controller/Kconfig b/subsys/bluetooth/controller/Kconfig index 0d5cba824162..abffc5faa164 100644 --- a/subsys/bluetooth/controller/Kconfig +++ b/subsys/bluetooth/controller/Kconfig @@ -141,10 +141,12 @@ config HAS_BT_CTLR bool config BT_LL_SW_SPLIT - bool "Software-based Bluetooth LE Link Layer" + bool "Software-based Bluetooth LE Link Layer [EXPERIMENTAL]" default y depends on DT_HAS_ZEPHYR_BT_HCI_LL_SW_SPLIT_ENABLED select HAS_BT_CTLR + select EXPERIMENTAL + select ENTROPY_GENERATOR help Use Zephyr software Bluetooth LE Link Layer ULL LLL split implementation. diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c index 9a39b1fe3829..0ae21070aa6d 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c @@ -63,7 +63,7 @@ static struct { /* FIXME: This could probably use a chosen entropy device instead on relying on * the nodelabel being the same as for the old nrf rng. */ -static const struct device *const dev_entropy = DEVICE_DT_GET(DT_NODELABEL(rng)); +static const struct device *const dev_entropy = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy)); #endif /* CONFIG_ENTROPY_HAS_DRIVER */ static int init_reset(void); diff --git a/subsys/bluetooth/host/Kconfig b/subsys/bluetooth/host/Kconfig index 47191fa407ce..7115003bb13b 100644 --- a/subsys/bluetooth/host/Kconfig +++ b/subsys/bluetooth/host/Kconfig @@ -726,6 +726,24 @@ config BT_ID_UNPAIR_MATCHING_BONDS link-layer. The Host does not have control over this acknowledgment, and the order of distribution is fixed by the specification. +config BT_ID_AUTO_SWAP_MATCHING_BONDS + bool "Automatically swap conflicting entries in the Resolving List" + depends on !BT_ID_UNPAIR_MATCHING_BONDS + depends on BT_SMP && BT_PERIPHERAL && !BT_CENTRAL + help + If this option is enabled, the Host will not add a new bond with + the same peer address (or IRK) to the Resolving List if there is + already a bond with the same peer address (or IRK) on another local + identity. + + In case of Peripheral, the Host will swap the existing entry in the + Resolving List with the new one, so that the new bond will be used for + address resolution for the new local identity if the device starts + advertising with the new local identity. + + Important: this option is supported exclusively in the Peripheral + role. Excluding the Central role. + config BT_ID_ALLOW_UNAUTH_OVERWRITE bool "Allow unauthenticated pairing with same peer with other local identity" depends on !BT_SMP_ALLOW_UNAUTH_OVERWRITE diff --git a/subsys/bluetooth/host/Kconfig.gatt b/subsys/bluetooth/host/Kconfig.gatt index 38bbeaa989a3..dc1ad4ad0376 100644 --- a/subsys/bluetooth/host/Kconfig.gatt +++ b/subsys/bluetooth/host/Kconfig.gatt @@ -38,6 +38,20 @@ config BT_ATT_RETRY_ON_SEC_ERR If an ATT request fails due to insufficient security, the host will try to elevate the security level and retry the ATT request. +config BT_ATT_SENT_CB_AFTER_TX + bool "Delay ATT sent callback until data transmission is done by controller [EXPERIMENTAL]" + select EXPERIMENTAL + help + By default, the BLE stack calls sent callback for ATT data when the + data is passed to BLE controller for transmission. Enabling this + Kconfig option delays calling the sent callback until data + transmission is finished by BLE controller (the callback is called + upon receiving the Number of Completed Packets HCI Event). + + The feature is not available in Zephyr RTOS (it's specific to NCS + Zephyr fork). It is a temporary solution allowing to control flow of + GATT notifications with HID reports for HID use-case. + config BT_EATT bool "Enhanced ATT Bearers support [EXPERIMENTAL]" depends on BT_L2CAP_ECRED diff --git a/subsys/bluetooth/host/Kconfig.l2cap b/subsys/bluetooth/host/Kconfig.l2cap index dc98241a6730..64f9420fbbff 100644 --- a/subsys/bluetooth/host/Kconfig.l2cap +++ b/subsys/bluetooth/host/Kconfig.l2cap @@ -52,7 +52,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/host/adv.c b/subsys/bluetooth/host/adv.c index 8e1cc7e5da5c..22068c8d11d0 100644 --- a/subsys/bluetooth/host/adv.c +++ b/subsys/bluetooth/host/adv.c @@ -233,6 +233,25 @@ struct bt_le_ext_adv *bt_hci_adv_lookup_handle(uint8_t handle) #endif /* CONFIG_BT_BROADCASTER */ #endif /* defined(CONFIG_BT_EXT_ADV) */ +struct bt_le_ext_adv *bt_adv_lookup_by_id(uint8_t id) +{ +#if defined(CONFIG_BT_EXT_ADV) + for (size_t i = 0; i < ARRAY_SIZE(adv_pool); i++) { + if (atomic_test_bit(adv_pool[i].flags, BT_ADV_CREATED) && + adv_pool[i].id == id) { + return &adv_pool[i]; + } + } +#else + if (atomic_test_bit(bt_dev.adv.flags, BT_ADV_CREATED) && bt_dev.adv.id == id) { + return &bt_dev.adv; + } +#endif + + return NULL; +} + + void bt_le_ext_adv_foreach(void (*func)(struct bt_le_ext_adv *adv, void *data), void *data) { @@ -935,6 +954,14 @@ static int adv_start_legacy(struct bt_le_ext_adv *adv, adv->id = param->id; bt_dev.adv_conn_id = adv->id; + if (IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + err = bt_id_resolving_list_check_and_update(adv->id, param->peer); + if (err) { + LOG_ERR("Failed to check and update resolving list: %d", err); + return err; + } + } + err = bt_id_set_adv_own_addr(adv, param->options, dir_adv, &set_param.own_addr_type); if (err) { @@ -1192,7 +1219,7 @@ static int le_ext_adv_param_set(struct bt_le_ext_adv *adv, return 0; } -int bt_le_adv_start_ext(struct bt_le_ext_adv *adv, +static int adv_start_ext(struct bt_le_ext_adv *adv, const struct bt_le_adv_param *param, const struct bt_data *ad, size_t ad_len, const struct bt_data *sd, size_t sd_len) @@ -1217,7 +1244,20 @@ int bt_le_adv_start_ext(struct bt_le_ext_adv *adv, return -EALREADY; } + if (IS_ENABLED(CONFIG_BT_SMP) && atomic_test_bit(bt_dev.flags, BT_DEV_ID_PENDING)) { + bt_id_pending_keys_update(); + } + adv->id = param->id; + + if (IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + err = bt_id_resolving_list_check_and_update(adv->id, param->peer); + if (err) { + LOG_ERR("Failed to check and update resolving list: %d", err); + return err; + } + } + err = le_ext_adv_param_set(adv, param, sd != NULL); if (err) { return err; @@ -1291,7 +1331,7 @@ int bt_le_adv_start(const struct bt_le_adv_param *param, if (IS_ENABLED(CONFIG_BT_EXT_ADV) && BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features)) { - err = bt_le_adv_start_ext(adv, param, ad, ad_len, sd, sd_len); + err = adv_start_ext(adv, param, ad, ad_len, sd, sd_len); } else { err = adv_start_legacy(adv, param, ad, ad_len, sd, sd_len); } @@ -1509,6 +1549,22 @@ int bt_le_ext_adv_start(struct bt_le_ext_adv *adv, bt_id_pending_keys_update(); } + if (IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + const bt_addr_le_t *peer; + + if (bt_addr_le_eq(&adv->target_addr, BT_ADDR_LE_ANY)) { + peer = NULL; + } else { + peer = &adv->target_addr; + } + + err = bt_id_resolving_list_check_and_update(adv->id, peer); + if (err) { + LOG_ERR("Failed to check and update resolving list: %d", err); + return err; + } + } + if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && atomic_test_bit(adv->flags, BT_ADV_CONNECTABLE)) { err = le_adv_start_add_conn(adv, &conn); diff --git a/subsys/bluetooth/host/adv.h b/subsys/bluetooth/host/adv.h index 6cc950fe8e7f..a6f7007f64b4 100644 --- a/subsys/bluetooth/host/adv.h +++ b/subsys/bluetooth/host/adv.h @@ -23,3 +23,4 @@ int bt_le_adv_set_enable_ext(struct bt_le_ext_adv *adv, int bt_le_adv_set_enable_legacy(struct bt_le_ext_adv *adv, bool enable); int bt_le_lim_adv_cancel_timeout(struct bt_le_ext_adv *adv); void bt_adv_reset_adv_pool(void); +struct bt_le_ext_adv *bt_adv_lookup_by_id(uint8_t id); diff --git a/subsys/bluetooth/host/att.c b/subsys/bluetooth/host/att.c index 58ec4472e7f3..797bb5096a34 100644 --- a/subsys/bluetooth/host/att.c +++ b/subsys/bluetooth/host/att.c @@ -394,6 +394,13 @@ static void att_disconnect(struct bt_att_chan *chan) } } +static void chan_sent_cb(struct bt_conn *conn, void *user_data, int err) +{ + struct net_buf *nb = user_data; + + net_buf_unref(nb); +} + /* In case of success the ownership of the buffer is transferred to the stack * which takes care of releasing it when it completes transmitting to the * controller. @@ -487,7 +494,15 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf) data->att_chan = chan; - err = bt_l2cap_send_pdu(&chan->chan, buf, NULL, NULL); + if (IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX)) { + err = bt_l2cap_send_pdu(&chan->chan, buf, chan_sent_cb, net_buf_ref(buf)); + if (err) { + net_buf_unref(buf); + } + } else { + err = bt_l2cap_send_pdu(&chan->chan, buf, NULL, NULL); + } + if (err) { if (err == -ENOBUFS) { LOG_ERR("Ran out of TX buffers or contexts."); diff --git a/subsys/bluetooth/host/conn.c b/subsys/bluetooth/host/conn.c index 569467915c4d..ea70207e2b86 100644 --- a/subsys/bluetooth/host/conn.c +++ b/subsys/bluetooth/host/conn.c @@ -698,12 +698,29 @@ static int send_buf(struct bt_conn *conn, struct net_buf *buf, uint16_t frag_len = MIN(conn_mtu(conn), len); - /* Check that buf->ref is 1 or 2. It would be 1 if this - * was the only reference (e.g. buf was removed - * from the conn tx_queue). It would be 2 if the - * tx_data_pull kept it on the tx_queue for segmentation. + /* If ATT sent callback is delayed until data transmission + * is done by BLE controller (CONFIG_BT_ATT_SENT_CB_AFTER_TX), + * the `chan_send` function from `att.c` introduces an additional + * reference. The reference is used to extend lifetime of the net + * buffer until the data transmission is confirmed by ACK of the + * remote (the reference is removed when the TX callback passed + * to `bt_l2cap_send_pdu` is called). + * + * send_buf function can be called multiple times, if buffer + * has to be fragmented over HCI. In that case, the callback + * is provided as an argument only for the last transmitted + * fragment. The `buf->ref == 1` (or 2) check is skipped + * because it's impossible to properly validate number of + * references for the sent fragments if buffers may have the + * additional reference. + * + * Otherwise, check that buf->ref is 1 or 2. It would be 1 + * if this was the only reference (e.g. buf was removed from + * the conn tx_queue). It would be 2 if the tx_data_pull + * kept it on the tx_queue for segmentation. */ - __ASSERT_NO_MSG((buf->ref == 1) || (buf->ref == 2)); + __ASSERT_NO_MSG(IS_ENABLED(CONFIG_BT_ATT_SENT_CB_AFTER_TX) || (buf->ref == 1) || + (buf->ref == 2)); /* The reference is always transferred to the frag, so when * the frag is destroyed, the parent reference is decremented. diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 67d2eba5bf0a..c3b53d1af695 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -4050,7 +4050,7 @@ const char *bt_hci_get_ver_str(uint8_t core_version) { const char * const str[] = { "1.0b", "1.1", "1.2", "2.0", "2.1", "3.0", "4.0", "4.1", "4.2", - "5.0", "5.1", "5.2", "5.3", "5.4", "6.0", "6.1", "6.2" + "5.0", "5.1", "5.2", "5.3", "5.4", "6.0", "6.1", "6.2", "6.3" }; if (core_version < ARRAY_SIZE(str)) { diff --git a/subsys/bluetooth/host/hci_core.h b/subsys/bluetooth/host/hci_core.h index 132f94a50cd7..de6b7571e9b7 100644 --- a/subsys/bluetooth/host/hci_core.h +++ b/subsys/bluetooth/host/hci_core.h @@ -490,7 +490,28 @@ struct bt_keys; void bt_id_add(struct bt_keys *keys); void bt_id_del(struct bt_keys *keys); -struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate); +/** @brief Find a conflict in the resolving list for a candidate IRK. + * + * @param candidate The candidate keys to check for conflicts. + * @param all If true, check all IRKs, otherwise check only added keys. + * + * @return The conflicting key if there is one, or NULL if no conflict was found. + */ +struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate, bool all); + +/** * @brief Find multiple conflicts in the resolving list for a candidate IRK. + * + * This function iterates over all keys (added and not added to the Resolving List). If there are + * multiple conflicts, this function will return true. Otherwise, it will return false. + * + * If @c firt_conflict is not NULL, it will be set to the first found conflict. + * + * @param candidate The candidate key to check for conflicts. + * @param first_conflict Pointer to store the first found conflict, if any. Can be NULL. + * + * @return True if there are multiple conflicts, otherwise it returns false. + */ +bool bt_id_find_conflict_multiple(struct bt_keys *candidate, struct bt_keys **first_conflict); int bt_setup_random_id_addr(void); int bt_setup_public_id_addr(void); diff --git a/subsys/bluetooth/host/id.c b/subsys/bluetooth/host/id.c index bdcb21e80780..7ff52e18fe3f 100644 --- a/subsys/bluetooth/host/id.c +++ b/subsys/bluetooth/host/id.c @@ -947,9 +947,33 @@ void bt_id_pending_keys_update(void) } } +static bool keys_conflict_check(const struct bt_keys *candidate, const struct bt_keys *resident) +{ + bool addr_conflict; + bool irk_conflict; + + addr_conflict = bt_addr_le_eq(&candidate->addr, &resident->addr); + + /* All-zero IRK is "no IRK", and does not conflict with other Zero-IRKs. */ + irk_conflict = (!bt_irk_eq(&candidate->irk, &(struct bt_irk){}) && + bt_irk_eq(&candidate->irk, &resident->irk)); + + if (addr_conflict || irk_conflict) { + LOG_DBG("Resident : addr %s and IRK %s", bt_addr_le_str(&resident->addr), + bt_hex(resident->irk.val, sizeof(resident->irk.val))); + LOG_DBG("Candidate: addr %s and IRK %s", bt_addr_le_str(&candidate->addr), + bt_hex(candidate->irk.val, sizeof(candidate->irk.val))); + + return true; + } + + return false; +} + struct bt_id_conflict { struct bt_keys *candidate; struct bt_keys *found; + bool check_all_irk; }; /* The Controller Resolve List is constrained by 7.8.38 "LE Add Device To @@ -961,8 +985,6 @@ struct bt_id_conflict { static void find_rl_conflict(struct bt_keys *resident, void *user_data) { struct bt_id_conflict *conflict = user_data; - bool addr_conflict; - bool irk_conflict; __ASSERT_NO_MSG(conflict != NULL); __ASSERT_NO_MSG(conflict->candidate != NULL); @@ -975,32 +997,26 @@ static void find_rl_conflict(struct bt_keys *resident, void *user_data) } /* Test against committed bonds only. */ - if ((resident->state & BT_KEYS_ID_ADDED) == 0) { + if (!conflict->check_all_irk && (resident->state & BT_KEYS_ID_ADDED) == 0) { + /* If the resident bond is not committed, we cannot have a conflict. */ return; } - addr_conflict = bt_addr_le_eq(&conflict->candidate->addr, &resident->addr); - - /* All-zero IRK is "no IRK", and does not conflict with other Zero-IRKs. */ - irk_conflict = (!bt_irk_eq(&conflict->candidate->irk, &(struct bt_irk){}) && - bt_irk_eq(&conflict->candidate->irk, &resident->irk)); - - if (addr_conflict || irk_conflict) { - LOG_DBG("Resident : addr %s and IRK %s, id: %d", bt_addr_le_str(&resident->addr), - bt_hex(resident->irk.val, sizeof(resident->irk.val)), resident->id); - LOG_DBG("Candidate: addr %s and IRK %s, id: %d", - bt_addr_le_str(&conflict->candidate->addr), - bt_hex(conflict->candidate->irk.val, sizeof(conflict->candidate->irk.val)), - conflict->candidate->id); + if (resident->id == conflict->candidate->id) { + /* If the IDs are the same, we cannot have a conflict. */ + return; + } + if (keys_conflict_check(conflict->candidate, resident)) { conflict->found = resident; } } -struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate) +struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate, bool check_all_irk) { struct bt_id_conflict conflict = { .candidate = candidate, + .check_all_irk = check_all_irk, }; bt_keys_foreach_type(BT_KEYS_IRK, find_rl_conflict, &conflict); @@ -1008,6 +1024,59 @@ struct bt_keys *bt_id_find_conflict(struct bt_keys *candidate) return conflict.found; } +struct bt_id_conflict_multiple { + struct bt_keys *candidate; + struct bt_keys *found; + bool found_multiple; +}; + +void find_rl_conflict_multiple(struct bt_keys *resident, void *user_data) +{ + struct bt_id_conflict_multiple *conflict = user_data; + + __ASSERT_NO_MSG(conflict != NULL); + __ASSERT_NO_MSG(conflict->candidate != NULL); + __ASSERT_NO_MSG(resident != NULL); + + if (conflict->found_multiple) { + /* If we already found enough conflicts, we can stop searching. */ + return; + } + + if (resident->id == conflict->candidate->id) { + /* If the IDs are the same, we cannot have a conflict. */ + return; + } + + if (keys_conflict_check(conflict->candidate, resident)) { + if (conflict->found) { + conflict->found_multiple = true; + + LOG_WRN("Found multiple conflicts for %s: addr %s and IRK %s", + bt_addr_le_str(&conflict->candidate->addr), + bt_addr_le_str(&resident->addr), + bt_hex(resident->irk.val, sizeof(resident->irk.val))); + } else { + conflict->found = resident; + } + } +} + +bool bt_id_find_conflict_multiple(struct bt_keys *candidate, struct bt_keys **first_conflict) +{ + struct bt_id_conflict_multiple conflict = { + .candidate = candidate, + }; + + bt_keys_foreach_type(BT_KEYS_IRK, find_rl_conflict_multiple, &conflict); + + if (first_conflict != NULL) { + *first_conflict = conflict.found; + } + + return conflict.found_multiple; +} + void bt_id_add(struct bt_keys *keys) { if (keys == NULL) { @@ -1270,6 +1339,122 @@ void bt_id_del(struct bt_keys *keys) bt_le_ext_adv_foreach(adv_unpause_enabled, NULL); } } + +static int conflict_check_and_replace(uint8_t id, struct bt_keys *keys) +{ + /* For the given key check if it has conflicts with other keys in the Resolving List + * (such keys have BT_KEYS_ID_ADDED state and BT_KEYS_ID_CONFLICT flag set). If it does, we + * need to remove the conflicting key from the Resolving List and add the new key. + * + * If the key is not in the Resolving List, we can add the new key right away. + * + * If advertiser for the conflicting key is enabled, we cannot remove the key from the + * Resolving List, so we return an error. + */ + + struct bt_keys *conflict; + const struct bt_le_ext_adv *adv; + + if (!(keys->flags & BT_KEYS_ID_CONFLICT)) { + LOG_DBG("Key has no conflicts for id %u addr %s", id, bt_addr_le_str(&keys->addr)); + return 0; + } + + if (keys->state & BT_KEYS_ID_ADDED) { + LOG_DBG("Key is already added to resolving list for id %u addr %s", id, + bt_addr_le_str(&keys->addr)); + return 0; + } + + /* bt_id_find_conflict returns only keys added to the Resolving List (state is + * BT_KEYS_ID_ADDED). If the key has conflict, but no keys were added (for example, if the + * last added key was removed after bt_unpair()), then this function will return NULL. Then, + * we don't need to remove a conflicting key from the Resolving List. Otherwise, we need to + * remove the conflicting key from the Resolving List before adding the new key. + */ + conflict = bt_id_find_conflict(keys, false); + if (conflict != NULL) { + __ASSERT_NO_MSG((conflict->flags & BT_KEYS_ID_CONFLICT) != 0); + + LOG_DBG("Found conflicting key with id %u addr %s", conflict->id, + bt_addr_le_str(&conflict->addr)); + + adv = bt_adv_lookup_by_id(conflict->id); + if (adv && atomic_test_bit(adv->flags, BT_ADV_ENABLED)) { + LOG_WRN("Cannot remove the conflicting key from the Resolving List while" + " advertising"); + return -EPERM; + } + + /* Drop BT_KEYS_ID_PENDING_DEL flag if we were about to delete the keys since we + * delete it here. + */ + conflict->state &= ~BT_KEYS_ID_PENDING_DEL; + bt_id_del(conflict); + } + + bt_id_add(keys); + + return 0; +} + +struct bt_id_resolve { + uint8_t id; + int err; +}; + +static void check_and_add_keys_for_id(struct bt_keys *keys, void *data) +{ + struct bt_id_resolve *resolve = data; + + if (resolve->err) { + /* Skipping other keys because we got error. */ + return; + } + + if (resolve->id != keys->id) { + /* We are only interested in keys for the given id */ + return; + } + + resolve->err = conflict_check_and_replace(resolve->id, keys); +} + +int bt_id_resolving_list_check_and_update(uint8_t id, const bt_addr_le_t *peer) +{ + int err; + + if (peer == NULL) { + struct bt_id_resolve resolve = { + .id = id, + }; + + LOG_DBG("Updating resolving list for id %u without peer address", id); + + bt_keys_foreach_type(BT_KEYS_IRK, check_and_add_keys_for_id, &resolve); + err = resolve.err; + } else { + struct bt_keys *keys; + + LOG_DBG("Updating resolving list for id %u addr %s", id, bt_addr_le_str(peer)); + + keys = bt_keys_get_addr(id, peer); + if (!keys) { + LOG_DBG("No keys found for id %u addr %s", id, bt_addr_le_str(peer)); + return -ENOENT; + } + + err = conflict_check_and_replace(id, keys); + } + + if (err) { + LOG_ERR("Failed to update resolving list for id %u addr %s (err %d)", id, + peer ? bt_addr_le_str(peer) : "NULL", err); + return err; + } + + return err; +} #endif /* defined(CONFIG_BT_SMP) */ void bt_id_get(bt_addr_le_t *addrs, size_t *count) diff --git a/subsys/bluetooth/host/id.h b/subsys/bluetooth/host/id.h index 8824d3bb496b..cd66784a5037 100644 --- a/subsys/bluetooth/host/id.h +++ b/subsys/bluetooth/host/id.h @@ -60,3 +60,26 @@ void bt_id_pending_keys_update(void); void bt_id_pending_keys_update_set(struct bt_keys *keys, uint8_t flag); void bt_id_adv_limited_stopped(struct bt_le_ext_adv *adv); + +/** + * @brief Check and update the resolving list for a given identity. + * + * This function checks if the resolving list contains the keys for the given + * identity and peer address. If the keys are not present, it adds them to the + * resolving list. If the keys are present, it checks for conflicts with + * existing keys in the resolving list. If a conflict is found, it replaces + * the conflicting key with the new key. + * + * If the peer address is NULL, it updates the resolving list for all keys that belong to the given + * identity. + * + * If for any of the keys belonging to the given identity a conflict is found and the advertiser for + * that key is enabled, the function returns an error. + * + * @param id The identity ID to check and update. + * @param peer The peer address to check against the resolving list. + * + * @return 0 on success, or a negative error code on failure. + * @return -EPERM if a conflict is found and the advertiser for the conflicting key is enabled. + */ +int bt_id_resolving_list_check_and_update(uint8_t id, const bt_addr_le_t *peer); diff --git a/subsys/bluetooth/host/keys.c b/subsys/bluetooth/host/keys.c index 6d58f8ed0baf..d999330ad451 100644 --- a/subsys/bluetooth/host/keys.c +++ b/subsys/bluetooth/host/keys.c @@ -46,7 +46,9 @@ static struct bt_keys key_pool[CONFIG_BT_MAX_PAIRED]; /* Configuration version used to detect if the device has configuration flags present in the stored * keys. Shall be higher than the maximum value of the `enc_size` field (16). */ -#define STORAGE_CFG_VERSION 17U +#define STORAGE_CFG_VERSION_MIN 17U +#define STORAGE_CFG_VERSION 17U +BUILD_ASSERT(STORAGE_CFG_VERSION >= STORAGE_CFG_VERSION_MIN, "STORAGE_CFG_VERSION is too small"); BUILD_ASSERT(STORAGE_CFG_VERSION <= UINT8_MAX, "STORAGE_CFG_VERSION is too large"); /* Configuration flags for storage. Based on the bt_keys_cfg_flags enum. */ #define STORAGE_CFG_FLAGS \ @@ -324,16 +326,57 @@ void bt_keys_add_type(struct bt_keys *keys, enum bt_keys_type type) keys->keys |= type; } +static void add_id_cb(struct k_work *work) +{ + bt_id_pending_keys_update(); +} + +static K_WORK_DEFINE(add_id_work, add_id_cb); + void bt_keys_clear(struct bt_keys *keys) { + struct bt_keys *conflict = NULL; + __ASSERT_NO_MSG(keys != NULL); LOG_DBG("%s (keys 0x%04x)", bt_addr_le_str(&keys->addr), keys->keys); + if (IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS) && + (keys->flags & BT_KEYS_ID_CONFLICT) != 0) { + /* We need to check how many conflicting keys left. If there is only one conflicting + * key left, we can remove the BT_KEYS_ID_CONFLICT flag from it so that Host don't + * need to check and update the Resolving List whenever this is needed. The key + * should be re-added to the Resolving List. + */ + bool found_multiple; + + found_multiple = bt_id_find_conflict_multiple(keys, &conflict); + if (conflict) { + if (found_multiple || (conflict->state & BT_KEYS_ID_ADDED) != 0) { + /* If we found multiple conflicting keys or the conflicting key + * is already added to the ID list, we don't need to clear the + * conflict flag for it and re-add it to the Resolving List. + */ + conflict = NULL; + } else { + /* Clear the conflict flag for the conflicting key */ + conflict->flags &= ~BT_KEYS_ID_CONFLICT; + } + } + } + if (keys->state & BT_KEYS_ID_ADDED) { bt_id_del(keys); } + if (conflict) { + /* Re-add the conflicting key to the Resolving List if it was the last conflicting + * key. + */ + bt_id_pending_keys_update_set(conflict, BT_KEYS_ID_PENDING_ADD); + k_work_submit(&add_id_work); + } + if (IS_ENABLED(CONFIG_BT_SETTINGS)) { /* Delete stored keys from flash */ bt_settings_delete_keys(keys->id, &keys->addr); @@ -361,6 +404,28 @@ int bt_keys_store(struct bt_keys *keys) return 0; } +static void check_and_set_id_conflict_flag(struct bt_keys *keys) +{ + struct bt_keys *conflict; + + if (!IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + /* If auto-swap is not enabled, we don't need to check for conflicts */ + return; + } + + /* Use bt_id_find_conflict() to check if there are any conflicting keys for the given keys. + * If there is at least one, set the BT_KEYS_ID_CONFLICT flag for both the keys and the + * conflicting key. + */ + conflict = bt_id_find_conflict(keys, true); + if (conflict != NULL) { + LOG_DBG("Found conflicting key %p.", conflict); + + keys->flags |= BT_KEYS_ID_CONFLICT; + conflict->flags |= BT_KEYS_ID_CONFLICT; + } +} + static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, void *cb_arg) { @@ -424,7 +489,7 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, return -ENOMEM; } if (len != BT_KEYS_STORAGE_LEN) { - if ((uint8_t)val[0] != (uint8_t)STORAGE_CFG_VERSION && + if ((uint8_t)val[0] < (uint8_t)STORAGE_CFG_VERSION_MIN && len == BT_KEYS_STORAGE_LEN_COMPAT) { /* This check migrates keys without configuration flags to the new format * granted only the configuration version and flags are missing. Older keys @@ -448,6 +513,35 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, return -EINVAL; } + } else if (!IS_ENABLED(CONFIG_BT_SIGNING) && IS_ENABLED(CONFIG_BT_SMP_SC_PAIR_ONLY) && + (uint8_t)val[0] < (uint8_t)STORAGE_CFG_VERSION_MIN) { + /* Migrate `bt_keys` stored with extra data to the new format in the most common + * scenario where both legacy pairing and signing support are disabled. This allows + * to still properly load and use the keys after firmware upgrade. + */ + size_t load_size = BT_KEYS_STORAGE_LEN_COMPAT; + + if (IS_ENABLED(CONFIG_BT_KEYS_OVERWRITE_OLDEST)) { + /* Restoring aging counter is not implemented for this use-case. */ + LOG_WRN("Skip aging counter - keys for %s", bt_addr_le_str(&addr)); + /* `aging_counter` is an `uint32_t` */ + load_size -= sizeof(uint32_t); + } + + if (len >= load_size) { + LOG_DBG("Adding configuration flags to keys for %s", bt_addr_le_str(&addr)); + keys->cfg_version = STORAGE_CFG_VERSION; + sys_put_le24(STORAGE_CFG_FLAGS, keys->cfg_flags); + (void)memcpy((char *)keys + offsetof(struct bt_keys, enc_size), + val, load_size); + /* Ensure no unsupported key types are set. */ + keys->keys &= (BT_KEYS_IRK | BT_KEYS_LTK_P256); + if ((keys->keys & BT_KEYS_LTK_P256) == 0U) { + LOG_WRN("Dropping keys for %s, no SC LTK", bt_addr_le_str(&addr)); + bt_keys_clear(keys); + return -EINVAL; + } + } } else { memcpy(keys->storage_start, val, len); } @@ -475,6 +569,8 @@ static int keys_set(const char *name, size_t len_rd, settings_read_cb read_cb, keys->flags &= ~BT_KEYS_AUTHENTICATED; } + check_and_set_id_conflict_flag(keys); + LOG_DBG("Successfully restored keys for %s", bt_addr_le_str(&addr)); #if defined(CONFIG_BT_KEYS_OVERWRITE_OLDEST) if (aging_counter_val < keys->aging_counter) { @@ -492,6 +588,14 @@ static void id_add(struct bt_keys *keys, void *user_data) * demand when advertising or scanning starts, avoiding bt_id_add() * blocking settings_load() on HCI. */ + + if (keys->flags & BT_KEYS_ID_CONFLICT) { + /* If the keys have the conflict flag set, we don't want to add them to the ID list, + * as this will cause issues with resolving list. + */ + return; + } + bt_id_pending_keys_update_set(keys, BT_KEYS_ID_PENDING_ADD); } diff --git a/subsys/bluetooth/host/keys.h b/subsys/bluetooth/host/keys.h index 4fd0f38cb5d3..84f0c8e6c7ff 100644 --- a/subsys/bluetooth/host/keys.h +++ b/subsys/bluetooth/host/keys.h @@ -45,6 +45,12 @@ enum { /* Bit 2 and 3 might accidentally exist in old stored keys */ BT_KEYS_SC = BIT(4), BT_KEYS_OOB = BIT(5), + /** Indicates that the keys are in conflict with existing keys. + * + * This is used to indicate that the keys being added conflict with + * existing keys from different identity. + */ + BT_KEYS_ID_CONFLICT = BIT(6), }; enum bt_keys_cfg_flags { diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 148a1b9a9b9f..2b6a201d1ad4 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -777,13 +777,19 @@ int bt_l2cap_send_pdu(struct bt_l2cap_le_chan *le_chan, struct net_buf *pdu, return -ENOTCONN; } - if (pdu->ref != 1) { + /* If ATT sent callback is delayed until data transmission is done by BLE controller + * (CONFIG_BT_ATT_SENT_CB_AFTER_TX), the `chan_send` function from `att.c` introduces an + * additional reference. The reference is used to extend lifetime of the net buffer until + * the data transmission is confirmed by ACK of the remote (the reference is removed when + * the TX callback passed to `bt_l2cap_send_pdu` is called). + */ + if (pdu->ref > 1 + (cb ? 1 : 0)) { /* The host may alter the buf contents when fragmenting. Higher * layers cannot expect the buf contents to stay intact. Extra * refs suggests a silent data corruption would occur if not for * this error. */ - LOG_ERR("Expecting 1 ref, got %d", pdu->ref); + LOG_ERR("Expecting up to %d refs, got %d", cb ? 2 : 1, pdu->ref); return -EINVAL; } diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c index 5c62124022db..6f92302e6961 100644 --- a/subsys/bluetooth/host/smp.c +++ b/subsys/bluetooth/host/smp.c @@ -924,7 +924,7 @@ static void smp_br_id_add_replace(struct bt_keys *keys) bt_id_del(keys); } - conflict = bt_id_find_conflict(keys); + conflict = bt_id_find_conflict(keys, false); if (conflict != NULL) { int err; @@ -934,7 +934,7 @@ static void smp_br_id_add_replace(struct bt_keys *keys) __ASSERT_NO_MSG(!err); } - __ASSERT_NO_MSG(!bt_id_find_conflict(keys)); + __ASSERT_NO_MSG(!bt_id_find_conflict(keys, false)); bt_id_add(keys); } @@ -4135,16 +4135,24 @@ static uint8_t smp_id_add_replace(struct bt_smp *smp, struct bt_keys *new_bond) */ __ASSERT_NO_MSG(!(smp->remote_dist & BT_SMP_DIST_ID_KEY)); - conflict = bt_id_find_conflict(new_bond); + conflict = bt_id_find_conflict(new_bond, IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)); if (conflict) { LOG_DBG("New bond conflicts with a bond on id %d.", conflict->id); } - if (conflict && !IS_ENABLED(CONFIG_BT_ID_UNPAIR_MATCHING_BONDS)) { + if (conflict && !IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS) && + !IS_ENABLED(CONFIG_BT_ID_UNPAIR_MATCHING_BONDS)) { LOG_WRN("Refusing new pairing. The old bond must be unpaired first."); return BT_SMP_ERR_AUTH_REQUIREMENTS; } + if (conflict && IS_ENABLED(CONFIG_BT_ID_AUTO_SWAP_MATCHING_BONDS)) { + LOG_WRN("Conflict detected with %p. Don't add key to Resolve List.", conflict); + new_bond->flags |= BT_KEYS_ID_CONFLICT; + conflict->flags |= BT_KEYS_ID_CONFLICT; + return 0; + } + if (conflict && IS_ENABLED(CONFIG_BT_ID_UNPAIR_MATCHING_BONDS)) { bool trust_ok; int unpair_err; @@ -4161,7 +4169,7 @@ static uint8_t smp_id_add_replace(struct bt_smp *smp, struct bt_keys *new_bond) __ASSERT_NO_MSG(!unpair_err); } - __ASSERT_NO_MSG(!bt_id_find_conflict(new_bond)); + __ASSERT_NO_MSG(!bt_id_find_conflict(new_bond, false)); bt_id_add(new_bond); return 0; } diff --git a/subsys/bluetooth/mesh/Kconfig b/subsys/bluetooth/mesh/Kconfig index 423f120c681f..91a0e8fc7360 100644 --- a/subsys/bluetooth/mesh/Kconfig +++ b/subsys/bluetooth/mesh/Kconfig @@ -60,12 +60,16 @@ choice BT_MESH_ADV menuconfig BT_MESH_ADV_LEGACY bool "Legacy advertising" + depends on BT_LL_SW_SPLIT help Use legacy advertising commands for mesh sending. Legacy - advertising is significantly slower than the extended advertising, but - is supported by all controllers. + advertising is significantly slower than the extended advertising. - WARNING: The legacy advertiser can occasionally do more message + WARNING: This feature is not supported in NCS. The legacy advertiser will not work + with SDC, as attempting to start an advertisement during the scanner duty cycle + will result in an error. The Zephyr Link Layer can be used experimentally as an + alternative. + The legacy advertiser can occasionally do more message retransmissions than requested because of limitations of HCI interface API. @@ -212,6 +216,17 @@ config BT_MESH_ADV_EXT_FRIEND_SEPARATE messages as close to the start of the ReceiveWindow as possible, thus reducing the scanning time on the Low Power node. +config BT_MESH_ADV_EXT_ACCEPT_EXT_ADV_PACKETS + bool "Reject or accept extended advertising packets" + depends on BT_LL_SOFTDEVICE + help + Configure the scanner and initiator to either reject or accept extended + advertising packets by the SoftDevice Controller. This is set to false + by default, to prevent loss of scan time when receiving a pointer packet + while scanning for Bluetooth Mesh packets. Set to true if extended + advertising packets are to be received by the SoftDevice Controller for + purposes other than Bluetooth Mesh. + endif # BT_MESH_ADV_EXT endchoice @@ -1706,7 +1721,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 a73bf86ad15f..abcccd27a1ac 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" @@ -149,6 +152,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_alloc(K_FOREVER); + 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, @@ -504,6 +529,18 @@ void bt_mesh_adv_init(void) K_PRIO_COOP(MESH_WORKQ_PRIORITY), NULL); k_thread_name_set(&bt_mesh_workq.thread, "BT MESH WQ"); } + +#if defined(CONFIG_BT_LL_SOFTDEVICE) + const sdc_hci_cmd_vs_scan_accept_ext_adv_packets_set_t cmd_params = { + .accept_ext_adv_packets = IS_ENABLED(CONFIG_BT_MESH_ADV_EXT_ACCEPT_EXT_ADV_PACKETS), + }; + + int err = sdc_hci_cmd_vs_scan_accept_ext_adv_packets_set(&cmd_params); + + if (err) { + LOG_ERR("Failed to set accept_ext_adv_packets: %d", err); + } +#endif } static struct bt_mesh_ext_adv *adv_instance_find(struct bt_le_ext_adv *instance) @@ -552,6 +589,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 792c53d4a0a6..58604d92f935 100644 --- a/subsys/bluetooth/mesh/blob_io_flash.c +++ b/subsys/bluetooth/mesh/blob_io_flash.c @@ -142,17 +142,6 @@ static int wr_chunk(const struct bt_mesh_blob_io *io, const struct flash_parameters *fparam = flash_get_parameters(fdev); - /* - * If device has no erase requirement then write directly. - * This is required since trick with padding using the erase value will - * not work in this case. - */ - if (!(flash_params_get_erase_cap(fparam) & FLASH_ERASE_C_EXPLICIT)) { - return flash_area_write(flash->area, - flash->offset + block->offset + chunk->offset, - chunk->data, chunk->size); - } - /* * Allocate one additional write block for the case where a chunk will need * an extra write block on both sides to fit. @@ -162,6 +151,28 @@ static int wr_chunk(const struct bt_mesh_blob_io *io, uint32_t write_block_size = flash_area_align(flash->area); off_t area_offset = flash->offset + block->offset + chunk->offset; int start_pad = area_offset % write_block_size; + off_t aligned_offset = ROUND_DOWN(area_offset, write_block_size); + size_t write_size = ROUND_UP(start_pad + chunk->size, write_block_size); + + if (!(flash_params_get_erase_cap(fparam) & FLASH_ERASE_C_EXPLICIT)) { + /* + * For devices without explicit erase (e.g. RRAM), read existing + * data at alignment boundaries to preserve bytes outside the + * chunk region, then overlay the chunk data and write back. + * The erase-value padding trick cannot be used here because + * writes are destructive regardless of the value written. + */ + int err; + + err = flash_area_read(flash->area, aligned_offset, buf, write_size); + if (err) { + return err; + } + + memcpy(&buf[start_pad], chunk->data, chunk->size); + + return flash_area_write(flash->area, aligned_offset, buf, write_size); + } /* * Fill buffer with erase value, to make sure only the part of the @@ -173,10 +184,7 @@ static int wr_chunk(const struct bt_mesh_blob_io *io, memcpy(&buf[start_pad], chunk->data, chunk->size); - return flash_area_write(flash->area, - ROUND_DOWN(area_offset, write_block_size), - buf, - ROUND_UP(start_pad + chunk->size, write_block_size)); + return flash_area_write(flash->area, aligned_offset, buf, write_size); } int bt_mesh_blob_io_flash_init(struct bt_mesh_blob_io_flash *flash, diff --git a/subsys/debug/coresight/cs_trace_defmt.c b/subsys/debug/coresight/cs_trace_defmt.c index adae83207993..6a36f700eae0 100644 --- a/subsys/debug/coresight/cs_trace_defmt.c +++ b/subsys/debug/coresight/cs_trace_defmt.c @@ -25,7 +25,7 @@ int cs_trace_defmt_process(const uint8_t *data, size_t len) uint8_t aux = data[15]; uint8_t d_id; - uint8_t cb_id; + uint8_t cb_id = 0; bool do_cb = false; for (int i = 0; i < 8; i++) { diff --git a/subsys/dfu/boot/mcuboot.c b/subsys/dfu/boot/mcuboot.c index a776a24a3c15..d754acc8d939 100644 --- a/subsys/dfu/boot/mcuboot.c +++ b/subsys/dfu/boot/mcuboot.c @@ -73,8 +73,49 @@ enum IMAGE_INDEXES { IMAGE_INDEX_7, }; -#if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) || \ - defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD_WITH_REVERT) +#if USE_PARTITION_MANAGER +#include + +#if CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER != -1 +/* Sysbuild */ +#ifdef CONFIG_MCUBOOT +/* lib is part of MCUboot -> operate on the primary application slot */ +#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID +#else +/* TODO: Add firmware loader support */ +/* lib is part of the app -> operate on active slot */ +#if defined(CONFIG_NCS_IS_VARIANT_IMAGE) +#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_SECONDARY_ID +#else +#define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID +#endif +#endif /* CONFIG_MCUBOOT */ +#else +/* Legacy child/parent */ +#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 primary application slot */ + #define ACTIVE_SLOT_FLASH_AREA_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_FLASH_AREA_ID PM_MCUBOOT_PRIMARY_ID +#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS + #define ACTIVE_SLOT_FLASH_AREA_ID PM_MCUBOOT_SECONDARY_ID +#else + #error Missing partition definitions. +#endif +#endif /* CONFIG_MCUBOOT */ +#endif /* CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER != -1 */ + +#else + +#if defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD) /* For RAM LOAD mode, the active image must be fetched from the bootloader */ #define ACTIVE_SLOT_FLASH_AREA_ID boot_fetch_active_slot() #define INVALID_SLOT_ID 255 @@ -83,6 +124,8 @@ enum IMAGE_INDEXES { #define ACTIVE_SLOT_FLASH_AREA_ID DT_PARTITION_ID(DT_CHOSEN(zephyr_code_partition)) #endif +#endif /* USE_PARTITION_MANAGER */ + /* * Raw (on-flash) representation of the v1 image header. */ diff --git a/subsys/dfu/boot/mcuboot_shell.c b/subsys/dfu/boot/mcuboot_shell.c index 583bc4778362..06eb79baa92b 100644 --- a/subsys/dfu/boot/mcuboot_shell.c +++ b/subsys/dfu/boot/mcuboot_shell.c @@ -20,6 +20,16 @@ #endif #endif +#if USE_PARTITION_MANAGER +#include + +#ifdef CONFIG_NCS_IS_VARIANT_IMAGE +#define ACTIVE_IMAGE_ID PM_MCUBOOT_SECONDARY_ID +#else +#define ACTIVE_IMAGE_ID PM_MCUBOOT_PRIMARY_ID +#endif +#endif + struct area_desc { const char *name; unsigned int id; @@ -93,6 +103,35 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, id = strtoul(argv[1], NULL, 0); /* Check if this is the parent (MCUboot) or own slot and if so, deny the request */ +#if USE_PARTITION_MANAGER +#ifdef PM_MCUBOOT_ID + if (id == PM_MCUBOOT_ID || id == PM_MCUBOOT_PAD_ID) { + shell_error(sh, "Cannot erase boot partition"); + return -EACCES; + } +#endif + +#ifdef PM_APP_ID + if (id == PM_APP_ID) { + shell_error(sh, "Cannot erase this area"); + return -EACCES; + } +#endif + +#ifdef PM_MCUBOOT_PRIMARY_APP_ID + if (id == PM_MCUBOOT_PRIMARY_APP_ID) { + shell_error(sh, "Cannot erase this area"); + return -EACCES; + } +#endif + +#ifdef ACTIVE_IMAGE_ID + if (id == ACTIVE_IMAGE_ID) { + shell_error(sh, "Cannot erase active partitions"); + return -EACCES; + } +#endif +#else #if PARTITION_EXISTS(boot_partition) if (id == PARTITION_ID(boot_partition)) { shell_error(sh, "Cannot erase boot partition"); @@ -105,6 +144,7 @@ static int cmd_mcuboot_erase(const struct shell *sh, size_t argc, shell_error(sh, "Cannot erase active partitions"); return -EACCES; } +#endif #endif err = boot_erase_img_bank(id); diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index e41287edf2f6..094cb761756b 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -1133,7 +1133,12 @@ struct fs_mount_t FS_FSTAB_ENTRY(DT_DRV_INST(inst)) = { \ .type = FS_LITTLEFS, \ .mnt_point = FSTAB_ENTRY_DT_INST_MOUNT_POINT(inst), \ .fs_data = &fs_data_##inst, \ - .storage_dev = (void *)DT_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_PARTITION_ID(FS_PARTITION(inst)))), \ .flags = FSTAB_ENTRY_DT_MOUNT_FLAGS(DT_DRV_INST(inst)), \ }; diff --git a/subsys/ipc/rpmsg_service/rpmsg_backend.h b/subsys/ipc/rpmsg_service/rpmsg_backend.h index 349eee664810..e7015d512d36 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 */ #ifdef CONFIG_OPENAMP_RSC_TABLE #define SHM_START_ADDR (VDEV_START_ADDR) diff --git a/subsys/kvss/nvs/Kconfig b/subsys/kvss/nvs/Kconfig index 48915c2f048e..21798932f521 100644 --- a/subsys/kvss/nvs/Kconfig +++ b/subsys/kvss/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. + config NVS_DATA_CRC bool "Non-volatile Storage CRC protection on the data" help diff --git a/subsys/kvss/nvs/nvs.c b/subsys/kvss/nvs/nvs.c index fd6dd480d571..720ba43eb329 100644 --- a/subsys/kvss/nvs/nvs.c +++ b/subsys/kvss/nvs/nvs.c @@ -14,6 +14,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); @@ -23,6 +28,45 @@ static int nvs_ate_valid(struct nvs_fs *fs, uint16_t entry_addr, #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; @@ -38,6 +82,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/kvss/zms/zms.c b/subsys/kvss/zms/zms.c index 13f87289665e..04dd014777cb 100644 --- a/subsys/kvss/zms/zms.c +++ b/subsys/kvss/zms/zms.c @@ -13,8 +13,12 @@ #include #include "zms_priv.h" #ifdef CONFIG_ZMS_LOOKUP_CACHE_FOR_SETTINGS +#ifdef CONFIG_SETTINGS_ZMS_LEGACY +#include +#else #include #endif +#endif #include LOG_MODULE_REGISTER(fs_zms, CONFIG_ZMS_LOG_LEVEL); @@ -33,6 +37,40 @@ static int zms_ate_valid_different_sector(struct zms_fs *fs, const struct zms_at static inline size_t zms_lookup_cache_pos(zms_id_t id) { #ifdef CONFIG_ZMS_LOOKUP_CACHE_FOR_SETTINGS +#ifdef CONFIG_SETTINGS_ZMS_LEGACY + /* + * 1. The ZMS settings backend uses up to (ZMS_NAME_ID_OFFSET - 1) ZMS IDs to + store keys and equal number of ZMS IDs to store values. + * 2. For each key-value pair, the value is stored at ZMS ID greater by exactly + * ZMS_NAME_ID_OFFSET than ZMS ID that holds the key. + * 3. The backend tries to minimize the range of ZMS IDs used to store keys. + * That is, ZMS IDs are allocated sequentially, and freed ZMS 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 ZMS 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(ZMS_NAMECNT_ID), "ZMS_NAMECNT_ID is not power of 2"); + BUILD_ASSERT(IS_POWER_OF_TWO(ZMS_NAME_ID_OFFSET), "ZMS_NAME_ID_OFFSET is not power of 2"); + + uint32_t key_value_bit; + uint32_t key_value_ord; + uint32_t hash; + + key_value_bit = (id >> LOG2(ZMS_NAME_ID_OFFSET)) & 1; + key_value_ord = id & (ZMS_NAME_ID_OFFSET - 1); + + hash = ((key_value_ord << 1) | key_value_bit); +#else /* * 1. Settings subsystem is storing the name ID and the linked list node ID * with only one bit difference at BIT(0). @@ -58,6 +96,7 @@ static inline size_t zms_lookup_cache_pos(zms_id_t id) key_value_ll = id & BIT(0); hash = (key_value_hash << 2) | (key_value_bit << 1) | key_value_ll; +#endif /* CONFIG_SETTINGS_ZMS_LEGACY */ #elif defined(CONFIG_ZMS_ID_64BIT) /* 64-bit integer hash function found by https://github.com/skeeto/hash-prospector. */ diff --git a/subsys/mgmt/mcumgr/CMakeLists.txt b/subsys/mgmt/mcumgr/CMakeLists.txt index 39d4a4ca8ce0..3bb21e16f798 100644 --- a/subsys/mgmt/mcumgr/CMakeLists.txt +++ b/subsys/mgmt/mcumgr/CMakeLists.txt @@ -16,3 +16,12 @@ add_subdirectory(transport) add_subdirectory_ifdef(CONFIG_SMP_CLIENT smp_client) zephyr_library_link_libraries(mgmt_mcumgr) + +if(CONFIG_MCUMGR_GRP_IMG_NRF5340_BOOTUTIL_HOOK) + 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 c917b1e55e0a..be48e2f4fb7e 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 && MCUMGR_GRP_IMG && MCUBOOT_NETWORK_CORE_IMAGE_NUMBER > -1 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..b372ce4e4945 --- /dev/null +++ b/subsys/mgmt/mcumgr/bootutil_hooks/nrf53_hooks.c @@ -0,0 +1,26 @@ +/* + * 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 == CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER) { + /* Pretend that primary slot of the network core update image is 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/Kconfig b/subsys/mgmt/mcumgr/grp/img_mgmt/Kconfig index ca5362f1fd68..b3a7410d6408 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/Kconfig +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/Kconfig @@ -231,6 +231,14 @@ config MCUMGR_GRP_IMG_SLOT_INFO_HOOKS This will enable the slot info function hooks which can be used to add additional information to responses. +config MCUMGR_GRP_IMG_NRF5340_BOOTUTIL_HOOK + bool "nRF5340 network core bootutil hook" + depends on SOC_NRF5340_CPUAPP && BOOT_IMAGE_ACCESS_HOOKS && MCUBOOT_NETWORK_CORE_IMAGE_NUMBER > -1 + default y + help + This option will enable a bootutil hook that populates the network core update image + slot with dummy data to allow for uploading a firmware update to the network core. + module = MCUMGR_GRP_IMG module-str = mcumgr_grp_img source "subsys/logging/Kconfig.template.log_config" diff --git a/subsys/net/ip/Kconfig.stats b/subsys/net/ip/Kconfig.stats index e7ed8dfaa28b..eb615bfdefba 100644 --- a/subsys/net/ip/Kconfig.stats +++ b/subsys/net/ip/Kconfig.stats @@ -93,6 +93,13 @@ config NET_STATISTICS_TCP help Keep track of TCP related statistics +config NET_STATISTICS_RAW + bool "Raw packet socket statistics" + depends on NET_SOCKETS_PACKET + default y + help + Keep track of raw packet socket related statistics + config NET_STATISTICS_MLD bool "Multicast Listener Discovery (MLD) statistics" depends on NET_IPV6_MLD diff --git a/subsys/net/ip/connection.c b/subsys/net/ip/connection.c index 140fc23663f7..3d76b0d5e6b9 100644 --- a/subsys/net/ip/connection.c +++ b/subsys/net/ip/connection.c @@ -624,12 +624,21 @@ static void conn_raw_socket_deliver(struct net_pkt *pkt, struct net_conn *conn, raw_pkt = net_pkt_clone(pkt, K_MSEC(CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT)); if (raw_pkt == NULL) { + if (!is_ip) { + net_stats_update_raw_drop(net_pkt_iface(pkt)); + } NET_WARN("pkt cloning failed, pkt %p not delivered", pkt); goto out; } if (conn->cb(conn, raw_pkt, NULL, NULL, conn->user_data) == NET_DROP) { + if (!is_ip) { + net_stats_update_raw_drop(net_pkt_iface(pkt)); + } net_pkt_unref(raw_pkt); + } else if (!is_ip) { + net_stats_update_raw_recv(net_pkt_iface(pkt), + net_pkt_get_len(raw_pkt)); } out: diff --git a/subsys/net/ip/net_context.c b/subsys/net/ip/net_context.c index a70e11a0a4a4..f82e7cb4f636 100644 --- a/subsys/net/ip/net_context.c +++ b/subsys/net/ip/net_context.c @@ -2817,6 +2817,7 @@ static int context_sendto(struct net_context *context, net_pkt_set_ll_proto_type(pkt, net_ntohs(ll_dst_addr->sll_protocol)); + net_stats_update_raw_sent(net_pkt_iface(pkt), len); net_if_try_queue_tx(net_pkt_iface(pkt), pkt, timeout); } else if (IS_ENABLED(CONFIG_NET_SOCKETS_CAN) && family == NET_AF_CAN && net_context_get_proto(context) == NET_CAN_RAW) { diff --git a/subsys/net/ip/net_stats.c b/subsys/net/ip/net_stats.c index 812e993f50fb..cb483706bb4f 100644 --- a/subsys/net/ip/net_stats.c +++ b/subsys/net/ip/net_stats.c @@ -152,6 +152,16 @@ static inline void stats(struct net_if *iface) GET_STAT(iface, udp.chkerr)); #endif +#if defined(CONFIG_NET_STATISTICS_RAW) + NET_INFO("Raw recv %u\tsent\t%u\tdrop\t%u", + GET_STAT(iface, raw.recv), + GET_STAT(iface, raw.sent), + GET_STAT(iface, raw.drop)); + NET_INFO("Raw bytes recv %llu\tsent\t%llu", + GET_STAT(iface, raw.bytes.received), + GET_STAT(iface, raw.bytes.sent)); +#endif + #if defined(CONFIG_NET_STATISTICS_TCP) NET_INFO("TCP bytes recv %llu\tsent\t%llu", GET_STAT(iface, tcp.bytes.received), @@ -322,6 +332,12 @@ static int net_stats_get(uint64_t mgmt_request, struct net_if *iface, src = GET_STAT_ADDR(iface, udp); break; #endif +#if defined(CONFIG_NET_STATISTICS_RAW) + case NET_REQUEST_STATS_CMD_GET_RAW: + len_chk = sizeof(struct net_stats_raw); + src = GET_STAT_ADDR(iface, raw); + break; +#endif #if defined(CONFIG_NET_STATISTICS_TCP) case NET_REQUEST_STATS_CMD_GET_TCP: len_chk = sizeof(struct net_stats_tcp); @@ -392,6 +408,11 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_GET_UDP, net_stats_get); #endif +#if defined(CONFIG_NET_STATISTICS_RAW) +NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_GET_RAW, + net_stats_get); +#endif + #if defined(CONFIG_NET_STATISTICS_TCP) NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_GET_TCP, net_stats_get); diff --git a/subsys/net/ip/net_stats.h b/subsys/net/ip/net_stats.h index 529dbd089feb..cf77412dff48 100644 --- a/subsys/net/ip/net_stats.h +++ b/subsys/net/ip/net_stats.h @@ -276,6 +276,32 @@ static inline void net_stats_update_udp_chkerr(struct net_if *iface) #define net_stats_update_udp_chkerr(iface) #endif /* CONFIG_NET_STATISTICS_UDP */ +#if defined(CONFIG_NET_STATISTICS_RAW) && defined(CONFIG_NET_NATIVE) +/* Raw packet socket stats */ +static inline void net_stats_update_raw_sent(struct net_if *iface, + uint32_t bytes) +{ + UPDATE_STAT(iface, stats.raw.bytes.sent += bytes); + UPDATE_STAT(iface, stats.raw.sent++); +} + +static inline void net_stats_update_raw_recv(struct net_if *iface, + uint32_t bytes) +{ + UPDATE_STAT(iface, stats.raw.bytes.received += bytes); + UPDATE_STAT(iface, stats.raw.recv++); +} + +static inline void net_stats_update_raw_drop(struct net_if *iface) +{ + UPDATE_STAT(iface, stats.raw.drop++); +} +#else +#define net_stats_update_raw_sent(iface, bytes) +#define net_stats_update_raw_recv(iface, bytes) +#define net_stats_update_raw_drop(iface) +#endif /* CONFIG_NET_STATISTICS_RAW */ + #if defined(CONFIG_NET_STATISTICS_TCP) && defined(CONFIG_NET_NATIVE_TCP) /* TCP stats */ static inline void net_stats_update_tcp_sent(struct net_if *iface, uint32_t bytes) diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index aa7891ab91de..db5156fb60e9 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -104,6 +104,19 @@ const char *wifi_security_txt(enum wifi_security_type security) } } +const char *wifi_wep_key_type_txt(enum wifi_wep_key_type wep_key_type) +{ + switch (wep_key_type) { + case WIFI_WEP_KEY_TYPE_64: + return " (64-bit key)"; + case WIFI_WEP_KEY_TYPE_128: + return " (128-bit key)"; + case WIFI_WEP_KEY_TYPE_UNKNOWN: + default: + return ""; + } +} + const char *wifi_wpa3_enterprise_txt(enum wifi_wpa3_enterprise_type wpa3_ent) { switch (wpa3_ent) { diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index a194979cb6ad..1f383050ee3c 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1266,8 +1266,10 @@ static int cmd_wifi_status(const struct shell *sh, size_t argc, char *argv[]) sizeof(mac_string_buf))); PR("Band: %s\n", wifi_band_txt(status.band)); PR("Channel: %d\n", status.channel); - PR("Security: %s %s\n", wifi_wpa3_enterprise_txt(status.wpa3_ent_type), - wifi_security_txt(status.security)); + PR("Security: %s %s%s\n", + wifi_wpa3_enterprise_txt(status.wpa3_ent_type), + wifi_security_txt(status.security), + wifi_wep_key_type_txt(status.wep_key_type)); PR("MFP: %s\n", wifi_mfp_txt(status.mfp)); if (status.iface_mode == WIFI_MODE_INFRA) { PR("RSSI: %d\n", status.rssi); diff --git a/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c b/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c index 1164424ebbdb..57a3138a949a 100644 --- a/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c +++ b/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c @@ -23,10 +23,15 @@ int mqtt_client_tls_connect(struct mqtt_client *client) { const struct net_sockaddr *broker = client->broker; struct mqtt_sec_config *tls_config = &client->transport.tls.config; + int type = NET_SOCK_STREAM; int ret; + if (!IS_ENABLED(CONFIG_NET_SOCKETS_OFFLOAD_DISPATCHER) && tls_config->set_native_tls) { + type |= SOCK_NATIVE_TLS; + } + client->transport.tls.sock = zsock_socket(broker->sa_family, - NET_SOCK_STREAM, NET_IPPROTO_TLS_1_2); + type, NET_IPPROTO_TLS_1_2); if (client->transport.tls.sock < 0) { return -errno; } @@ -122,6 +127,16 @@ int mqtt_client_tls_connect(struct mqtt_client *client) } } + if (tls_config->session_cache == ZSOCK_TLS_SESSION_CACHE_ENABLED) { + ret = zsock_setsockopt(client->transport.tls.sock, ZSOCK_SOL_TLS, + ZSOCK_TLS_SESSION_CACHE, + &tls_config->session_cache, + sizeof(tls_config->session_cache)); + if (ret < 0) { + goto error; + } + } + if (tls_config->cert_nocopy != ZSOCK_TLS_CERT_NOCOPY_NONE) { ret = zsock_setsockopt(client->transport.tls.sock, ZSOCK_SOL_TLS, ZSOCK_TLS_CERT_NOCOPY, &tls_config->cert_nocopy, diff --git a/subsys/net/lib/shell/stats.c b/subsys/net/lib/shell/stats.c index 06aa1c4ffa95..ca2df13d2590 100644 --- a/subsys/net/lib/shell/stats.c +++ b/subsys/net/lib/shell/stats.c @@ -585,6 +585,16 @@ static void net_shell_print_statistics(struct net_if *iface, void *user_data) GET_STAT(iface, udp.chkerr)); #endif +#if defined(CONFIG_NET_STATISTICS_RAW) + PR("Raw recv %u\tsent\t%u\tdrop\t%u\n", + GET_STAT(iface, raw.recv), + GET_STAT(iface, raw.sent), + GET_STAT(iface, raw.drop)); + PR("Raw bytes recv %llu\tsent\t%llu\n", + GET_STAT(iface, raw.bytes.received), + GET_STAT(iface, raw.bytes.sent)); +#endif + #if defined(CONFIG_NET_STATISTICS_TCP) && defined(CONFIG_NET_NATIVE_TCP) PR("TCP bytes recv %llu\tsent\t%llu\tresent\t%u\n", GET_STAT(iface, tcp.bytes.received), diff --git a/subsys/net/lib/sockets/sockets_tls.c b/subsys/net/lib/sockets/sockets_tls.c index cc0d5c76fad5..1a0a73e7b556 100644 --- a/subsys/net/lib/sockets/sockets_tls.c +++ b/subsys/net/lib/sockets/sockets_tls.c @@ -331,6 +331,19 @@ bool net_socket_is_tls(void *obj) return PART_OF_ARRAY(tls_contexts, (struct tls_context *)obj); } +static int tls_ctr_drbg_random(void *ctx, unsigned char *buf, size_t len) +{ + ARG_UNUSED(ctx); + +#if defined(CONFIG_CSPRNG_ENABLED) + return sys_csrand_get(buf, len); +#else + sys_rand_get(buf, len); + + return 0; +#endif +} + #if defined(CONFIG_NET_SOCKETS_ENABLE_DTLS) /* mbedTLS-defined function for setting timer. */ static void dtls_timing_set_delay(void *data, uint32_t int_ms, uint32_t fin_ms) @@ -1428,7 +1441,8 @@ static int tls_set_private_key(struct tls_context *tls, int err; err = mbedtls_pk_parse_key(&tls->priv_key, priv_key->buf, - priv_key->len, NULL, 0); + priv_key->len, NULL, 0, + tls_ctr_drbg_random, NULL); if (err != 0) { return -EINVAL; } @@ -1814,7 +1828,9 @@ static int tls_mbedtls_init(struct tls_context *context, bool is_server) /* Configure cookie for DTLS server */ if (role == MBEDTLS_SSL_IS_SERVER) { - ret = mbedtls_ssl_cookie_setup(&context->cookie); + ret = mbedtls_ssl_cookie_setup(&context->cookie, + tls_ctr_drbg_random, + NULL); if (ret != 0) { return -ENOMEM; } @@ -1839,6 +1855,10 @@ static int tls_mbedtls_init(struct tls_context *context, bool is_server) context->options.verify_level); } + mbedtls_ssl_conf_rng(&context->config, + tls_ctr_drbg_random, + NULL); + ret = tls_mbedtls_set_credentials(context); if (ret != 0) { return ret; @@ -1935,7 +1955,8 @@ static int tls_check_priv_key(struct tls_credential *priv_key) mbedtls_pk_init(&key_ctx); err = mbedtls_pk_parse_key(&key_ctx, priv_key->buf, - priv_key->len, NULL, 0); + priv_key->len, NULL, 0, + tls_ctr_drbg_random, NULL); if (err != 0) { NET_ERR("Failed to parse %s on tag %d, err: -0x%x", "private key", priv_key->tag, -err); diff --git a/subsys/net/lib/wireguard/CMakeLists.txt b/subsys/net/lib/wireguard/CMakeLists.txt index 77c922957974..673a27f7d843 100644 --- a/subsys/net/lib/wireguard/CMakeLists.txt +++ b/subsys/net/lib/wireguard/CMakeLists.txt @@ -7,3 +7,5 @@ zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/ip) zephyr_library_sources(wg.c) zephyr_library_sources_ifdef(CONFIG_BOARD_NATIVE_SIM ns_rtc.c) + +zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS_BUILTIN mbedTLS) diff --git a/subsys/secure_storage/CMakeLists.txt b/subsys/secure_storage/CMakeLists.txt index 3d93e2d36b20..2717994ebb08 100644 --- a/subsys/secure_storage/CMakeLists.txt +++ b/subsys/secure_storage/CMakeLists.txt @@ -2,12 +2,6 @@ zephyr_library() zephyr_library_link_libraries_ifdef(CONFIG_MBEDTLS mbedTLS) -# Add some Mbed TLS' internal folders where there are files included from -# "psa_crypto_driver_wrappers.h" in "src/its/transform/aead.c". -if(CONFIG_SECURE_STORAGE_ITS_TRANSFORM_IMPLEMENTATION_AEAD) - zephyr_library_include_directories($) -endif() - zephyr_library_include_directories(include/internal) # secure_storage headers add_subdirectory(src) diff --git a/subsys/secure_storage/Kconfig.its_transform b/subsys/secure_storage/Kconfig.its_transform index 1b073a08aab5..f8008353616b 100644 --- a/subsys/secure_storage/Kconfig.its_transform +++ b/subsys/secure_storage/Kconfig.its_transform @@ -6,6 +6,7 @@ choice SECURE_STORAGE_ITS_TRANSFORM_IMPLEMENTATION config SECURE_STORAGE_ITS_TRANSFORM_IMPLEMENTATION_AEAD bool "ITS transform module implementation using AEAD to protect the data" + select PSA_CRYPTO imply HWINFO # for HWINFO_HAS_DRIVER config SECURE_STORAGE_ITS_TRANSFORM_IMPLEMENTATION_CUSTOM diff --git a/subsys/secure_storage/src/its/transform/aead.c b/subsys/secure_storage/src/its/transform/aead.c index a687d00c337b..75fed41c41ca 100644 --- a/subsys/secure_storage/src/its/transform/aead.c +++ b/subsys/secure_storage/src/its/transform/aead.c @@ -1,7 +1,7 @@ /* Copyright (c) 2024 Nordic Semiconductor * SPDX-License-Identifier: Apache-2.0 */ -#include <../core/psa_crypto_driver_wrappers.h> +#include <../library/psa_crypto_driver_wrappers.h> #include #include #include diff --git a/subsys/shell/Kconfig b/subsys/shell/Kconfig index 4bbc1aef709d..3565b2556c1a 100644 --- a/subsys/shell/Kconfig +++ b/subsys/shell/Kconfig @@ -8,7 +8,7 @@ menuconfig SHELL bool "Shell" imply LOG_RUNTIME_FILTERING - select EVENTS + select EVENTS if MULTITHREADING if SHELL diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index b86806a18c11..1ea4503616f9 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -1213,13 +1213,21 @@ static void state_collect(const struct shell *sh) static void transport_evt_handler(enum shell_transport_evt evt_type, void *ctx) { struct shell *sh = (struct shell *)ctx; + +#if CONFIG_MULTITHREADING enum shell_signal sig = evt_type == SHELL_TRANSPORT_EVT_RX_RDY ? SHELL_SIGNAL_RXRDY : SHELL_SIGNAL_TXDONE; k_event_post(&sh->ctx->signal_event, sig); +#endif + + if (evt_type == SHELL_TRANSPORT_EVT_TX_RDY) { + z_flag_tx_rdy_set(sh, true); + } } +#if CONFIG_MULTITHREADING static void shell_log_process(const struct shell *sh) { bool processed = false; @@ -1243,6 +1251,7 @@ static void shell_log_process(const struct shell *sh) } while (processed && !k_event_test(&sh->ctx->signal_event, SHELL_SIGNAL_RXRDY)); } +#endif static int instance_init(const struct shell *sh, const void *transport_config, @@ -1256,8 +1265,10 @@ static int instance_init(const struct shell *sh, sh->ctx->selected_cmd = root_cmd_find(CONFIG_SHELL_CMD_ROOT); } +#if CONFIG_MULTITHREADING k_event_init(&sh->ctx->signal_event); k_sem_init(&sh->ctx->lock_sem, 1, 1); +#endif if (IS_ENABLED(CONFIG_SHELL_STATS)) { sh->stats->log_lost_cnt = 0; @@ -1324,6 +1335,7 @@ static int instance_uninit(const struct shell *sh) return 0; } +#if CONFIG_MULTITHREADING typedef void (*shell_signal_handler_t)(const struct shell *sh); static void shell_signal_handle(const struct shell *sh, @@ -1398,6 +1410,7 @@ void shell_thread(void *shell_handle, void *arg_log_backend, z_shell_unlock(sh); } } +#endif int shell_init(const struct shell *sh, const void *transport_config, struct shell_backend_config_flags cfg_flags, @@ -1406,9 +1419,11 @@ int shell_init(const struct shell *sh, const void *transport_config, __ASSERT_NO_MSG(sh); __ASSERT_NO_MSG(sh->ctx && sh->iface && sh->default_prompt); +#if CONFIG_MULTITHREADING if (sh->ctx->tid) { return -EALREADY; } +#endif int err = instance_init(sh, transport_config, cfg_flags); @@ -1416,6 +1431,7 @@ int shell_init(const struct shell *sh, const void *transport_config, return err; } +#if CONFIG_MULTITHREADING k_tid_t tid = k_thread_create(sh->thread, sh->stack, CONFIG_SHELL_STACK_SIZE, shell_thread, (void *)sh, (void *)log_backend, @@ -1424,6 +1440,7 @@ int shell_init(const struct shell *sh, const void *transport_config, sh->ctx->tid = tid; k_thread_name_set(tid, sh->name); +#endif return 0; } @@ -1432,12 +1449,10 @@ void shell_uninit(const struct shell *sh, shell_uninit_cb_t cb) { __ASSERT_NO_MSG(sh); - if (IS_ENABLED(CONFIG_MULTITHREADING)) { - sh->ctx->uninit_cb = cb; - k_event_post(&sh->ctx->signal_event, SHELL_SIGNAL_KILL); - return; - } - +#if CONFIG_MULTITHREADING + sh->ctx->uninit_cb = cb; + k_event_post(&sh->ctx->signal_event, SHELL_SIGNAL_KILL); +#else int err = instance_uninit(sh); if (cb) { @@ -1445,6 +1460,7 @@ void shell_uninit(const struct shell *sh, shell_uninit_cb_t cb) } else { __ASSERT_NO_MSG(0); } +#endif } int shell_start(const struct shell *sh) diff --git a/subsys/shell/shell_ops.c b/subsys/shell/shell_ops.c index fa904cfc6c6f..6a61cfff2c7b 100644 --- a/subsys/shell/shell_ops.c +++ b/subsys/shell/shell_ops.c @@ -434,11 +434,14 @@ void z_shell_print_prompt_and_cmd(const struct shell *sh) static void shell_pend_on_txdone(const struct shell *sh) { - if (IS_ENABLED(CONFIG_MULTITHREADING) && - (sh->ctx->state < SHELL_STATE_PANIC_MODE_ACTIVE)) { +#if CONFIG_MULTITHREADING + if (sh->ctx->state < SHELL_STATE_PANIC_MODE_ACTIVE) { k_event_wait(&sh->ctx->signal_event, SHELL_SIGNAL_TXDONE, false, K_FOREVER); k_event_clear(&sh->ctx->signal_event, SHELL_SIGNAL_TXDONE); } else { +#else + { +#endif /* Blocking wait in case of bare metal. */ while (!z_flag_tx_rdy_get(sh)) { } diff --git a/subsys/shell/shell_ops.h b/subsys/shell/shell_ops.h index a608c17daaea..feec96172ead 100644 --- a/subsys/shell/shell_ops.h +++ b/subsys/shell/shell_ops.h @@ -381,6 +381,7 @@ void z_shell_vfprintf(const struct shell *sh, enum shell_vt100_color color, */ void z_shell_backend_rx_buffer_flush(const struct shell *sh); +#if CONFIG_MULTITHREADING static inline bool z_shell_trylock(const struct shell *sh, k_timeout_t timeout) { return k_sem_take(&sh->ctx->lock_sem, timeout) == 0; @@ -395,6 +396,24 @@ static inline void z_shell_unlock(const struct shell *sh) { k_sem_give(&sh->ctx->lock_sem); } +#else +static inline bool z_shell_trylock(const struct shell *sh, k_timeout_t timeout) +{ + ARG_UNUSED(sh); + ARG_UNUSED(timeout); + return true; +} + +static inline void z_shell_lock(const struct shell *sh) +{ + ARG_UNUSED(sh); +} + +static inline void z_shell_unlock(const struct shell *sh) +{ + ARG_UNUSED(sh); +} +#endif #ifdef __cplusplus } diff --git a/subsys/usb/device_next/app/Kconfig.cdc_acm_serial b/subsys/usb/device_next/app/Kconfig.cdc_acm_serial index 5192d5636d9e..c170ed9be0e4 100644 --- a/subsys/usb/device_next/app/Kconfig.cdc_acm_serial +++ b/subsys/usb/device_next/app/Kconfig.cdc_acm_serial @@ -23,6 +23,19 @@ config CDC_ACM_SERIAL_ENABLE_AT_BOOT When disabled, the application is responsible for enabling/disabling the USB device. +config CDC_ACM_SERIAL_MULTIPLE_INSTANCES + bool "Register and initialize multiple CDC ACM instances" + help + Register multiple CDC ACM instances whose UARTs are referenced by + appropriate Zephyr-specific chosen node properties. The order in which + the instances will be registered and appear in the configuration + descriptor is guaranteed. The following are currently supported, in + this order: "zephyr,console", "zephyr,shell-uart", "zephyr,uart-mcumgr". + A supported property may be missing, and properties may reference the + same device. + Each instance occupies two IN endpoints and one OUT endpoint. USB device + controller must have enough resources to support multiple instances. + config CDC_ACM_SERIAL_MANUFACTURER_STRING string "USB device manufacturer string descriptor" default "Zephyr Project" diff --git a/subsys/usb/device_next/app/cdc_acm_serial.c b/subsys/usb/device_next/app/cdc_acm_serial.c index af0814693030..845a9f0cf300 100644 --- a/subsys/usb/device_next/app/cdc_acm_serial.c +++ b/subsys/usb/device_next/app/cdc_acm_serial.c @@ -43,9 +43,69 @@ USBD_CONFIGURATION_DEFINE(cdc_acm_serial_hs_config, attributes, CONFIG_CDC_ACM_SERIAL_MAX_POWER, &hs_cfg_desc); +/* + * The CDC ACM instances are registered in the same order that they appear in + * this array. Therefore, they are always presented in the same order on the + * host side. Add new entries at the end. + */ +const static struct device *uart_devs[] = { + DEVICE_DT_GET_OR_NULL(DT_CHOSEN(zephyr_console)), + DEVICE_DT_GET_OR_NULL(DT_CHOSEN(zephyr_shell_uart)), + DEVICE_DT_GET_OR_NULL(DT_CHOSEN(zephyr_uart_mcumgr)), +}; -static int register_cdc_acm_0(struct usbd_context *const uds_ctx, - const enum usbd_speed speed) +/* + * The class data stores a reference to the implemented UART device for + * internal purposes. Iterate over all class instances and compare the dev + * parameter with the referenced UART device. Then, try to register the + * instance. If multiple chosen node properties reference the same device, + * usbd_register_class() will fail with -EALREADY. + */ +static int register_chosen(struct usbd_context *const uds_ctx, + const enum usbd_speed speed, + const struct device *const dev) +{ + int err; + + if (speed == USBD_SPEED_HS) { + STRUCT_SECTION_FOREACH_ALTERNATE(usbd_class_hs, usbd_class_node, c_nd) { + struct usbd_class_data *c_data = c_nd->c_data; + + if (usbd_class_get_private(c_data) == dev) { + err = usbd_register_class(&cdc_acm_serial, + c_data->name, speed, 1); + if (err != 0 && err != -EALREADY) { + LOG_ERR("Failed to register %s", c_data->name); + return err; + } + + break; + } + } + } + + if (speed == USBD_SPEED_FS) { + STRUCT_SECTION_FOREACH_ALTERNATE(usbd_class_fs, usbd_class_node, c_nd) { + struct usbd_class_data *c_data = c_nd->c_data; + + if (usbd_class_get_private(c_data) == dev) { + err = usbd_register_class(&cdc_acm_serial, + c_data->name, speed, 1); + if (err != 0 && err != -EALREADY) { + LOG_ERR("Failed to register %s", c_data->name); + return err; + } + + break; + } + } + } + + return 0; +} + +static int register_cdc_acm(struct usbd_context *const uds_ctx, + const enum usbd_speed speed) { struct usbd_config_node *cfg_nd; int err; @@ -62,10 +122,28 @@ static int register_cdc_acm_0(struct usbd_context *const uds_ctx, return err; } - err = usbd_register_class(&cdc_acm_serial, "cdc_acm_0", speed, 1); - if (err) { - LOG_ERR("Failed to register classes"); - return err; + if (IS_ENABLED(CONFIG_CDC_ACM_SERIAL_MULTIPLE_INSTANCES)) { + for (int n = 0; n < ARRAY_SIZE(uart_devs); n++) { + if (uart_devs[n] == NULL) { + continue; + } + + err = register_chosen(uds_ctx, speed, uart_devs[n]); + if (err) { + return err; + } + } + } else { + /* + * Only register the first instance to maintain the legacy + * stack behavior when using CDC ACM as a serial backend for + * different applications. + */ + err = usbd_register_class(&cdc_acm_serial, "cdc_acm_0", speed, 1); + if (err) { + LOG_ERR("Failed to register %s", "cdc_acm_0"); + return err; + } } return usbd_device_set_code_triple(uds_ctx, speed, @@ -105,13 +183,13 @@ static int cdc_acm_serial_init_device(void) if (USBD_SUPPORTS_HIGH_SPEED && usbd_caps_speed(&cdc_acm_serial) == USBD_SPEED_HS) { - err = register_cdc_acm_0(&cdc_acm_serial, USBD_SPEED_HS); + err = register_cdc_acm(&cdc_acm_serial, USBD_SPEED_HS); if (err) { return err; } } - err = register_cdc_acm_0(&cdc_acm_serial, USBD_SPEED_FS); + err = register_cdc_acm(&cdc_acm_serial, USBD_SPEED_FS); if (err) { return err; } diff --git a/subsys/usb/device_next/usbd_class.c b/subsys/usb/device_next/usbd_class.c index ae5f74b5c5d9..17571bda2cbb 100644 --- a/subsys/usb/device_next/usbd_class.c +++ b/subsys/usb/device_next/usbd_class.c @@ -319,13 +319,13 @@ int usbd_register_class(struct usbd_context *const uds_ctx, /* TODO: does it still need to be atomic ? */ if (atomic_test_bit(&c_nd->state, USBD_CCTX_REGISTERED)) { LOG_WRN("Class instance already registered"); - ret = -EBUSY; + ret = -EALREADY; goto register_class_error; } if ((c_data->uds_ctx != NULL) && (c_data->uds_ctx != uds_ctx)) { LOG_ERR("Class registered to other context at different speed"); - ret = -EBUSY; + ret = -EALREADY; goto register_class_error; } diff --git a/tests/application_development/code_relocation/linker_arm_sram2.ld b/tests/application_development/code_relocation/linker_arm_sram2.ld index deb2c6f5aca6..91fb21dd0db3 100644 --- a/tests/application_development/code_relocation/linker_arm_sram2.ld +++ b/tests/application_development/code_relocation/linker_arm_sram2.ld @@ -25,14 +25,16 @@ #define _SRAM2_DATA_SECTION_NAME .sram2_data #define _SRAM2_BSS_SECTION_NAME .sram2_bss #define _SRAM2_TEXT_SECTION_NAME .sram2_text - #define SRAM2_ADDR (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2) + + #define SRAM2_ADDR (DT_CHOSEN_SRAM_ADDR + RAM_SIZE2) #endif -#define RAM_SIZE2 (CONFIG_SRAM_SIZE * 512) +#define RAM_SIZE2 (DT_CHOSEN_SRAM_SIZE / 2) + MEMORY { #ifdef CONFIG_SRAM2 - SRAM2 (wx) : ORIGIN = (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2), LENGTH = RAM_SIZE2 + SRAM2 (wx) : ORIGIN = SRAM2_ADDR, LENGTH = RAM_SIZE2 #endif } diff --git a/tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld b/tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld index cf59a6aad69c..9c0e57c742a5 100644 --- a/tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld +++ b/tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld @@ -16,12 +16,13 @@ #define _SRAM2_DATA_SECTION_NAME .sram2_data #define _SRAM2_BSS_SECTION_NAME .sram2_bss #define _SRAM2_TEXT_SECTION_NAME .sram2_text -#define SRAM2_ADDR (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2) -#define RAM_SIZE2 (CONFIG_SRAM_SIZE * 512) +#define RAM_SIZE2 (DT_CHOSEN_SRAM_SIZE / 2) +#define RAM_BASE2 (DT_CHOSEN_SRAM_ADDR + RAM_SIZE2) + MEMORY { - SRAM2 (wx) : ORIGIN = (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2), LENGTH = RAM_SIZE2 + SRAM2 (wx) : ORIGIN = RAM_BASE2, LENGTH = RAM_SIZE2 } #include diff --git a/tests/application_development/code_relocation/linker_xtensa_qemu_sram2.ld b/tests/application_development/code_relocation/linker_xtensa_qemu_sram2.ld index 3fd33186a8f4..1526d2e580ae 100644 --- a/tests/application_development/code_relocation/linker_xtensa_qemu_sram2.ld +++ b/tests/application_development/code_relocation/linker_xtensa_qemu_sram2.ld @@ -10,12 +10,12 @@ #include #include -#define SRAM2_ADDR (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2) #define RAM_SIZE2 (0x4000000) +#define SRAM2_ADDR (DT_CHOSEN_SRAM_ADDR + RAM_SIZE2) MEMORY { - SRAM2 (wx) : ORIGIN = (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2), LENGTH = RAM_SIZE2 + SRAM2 (wx) : ORIGIN = SRAM2_ADDR, LENGTH = RAM_SIZE2 } PHDRS diff --git a/tests/application_development/ram_context_for_isr/src/main.c b/tests/application_development/ram_context_for_isr/src/main.c index 64955e7e2a2f..b06ea584ee69 100644 --- a/tests/application_development/ram_context_for_isr/src/main.c +++ b/tests/application_development/ram_context_for_isr/src/main.c @@ -37,17 +37,17 @@ static void test_irq_callback(const struct device *dev, void *user_data) driver_isr_addr = (uintptr_t)user_data; /* Check that the function and its call stack are in RAM */ - zassert_true(func_addr >= CONFIG_SRAM_BASE_ADDRESS && - func_addr <= CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE * 1024, + zassert_true(func_addr >= DT_CHOSEN_SRAM_ADDR && + func_addr <= DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE, "%s is not in RAM! Address: 0x%lx", __func__, func_addr); - zassert_true(driver_isr_addr >= CONFIG_SRAM_BASE_ADDRESS && - driver_isr_addr <= CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE * 1024, + zassert_true(driver_isr_addr >= DT_CHOSEN_SRAM_ADDR && + driver_isr_addr <= DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE, "fake_driver_isr is not in RAM! Address: 0x%lx", driver_isr_addr); - zassert_true(arch_isr_wrapper_addr >= CONFIG_SRAM_BASE_ADDRESS && + zassert_true(arch_isr_wrapper_addr >= DT_CHOSEN_SRAM_ADDR && arch_isr_wrapper_addr <= - CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE * 1024, + DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE, "arch_isr_wrapper_addr is not in RAM! Address: 0x%lx", arch_isr_wrapper_addr); TC_PRINT("Callback function address: 0x%lx\n", func_addr); @@ -61,8 +61,8 @@ ZTEST(ram_context_for_isr, test_fake_driver_in_ram) const struct fake_driver_api *api = DEVICE_API_GET(fake, dev); uintptr_t dev_addr = (uintptr_t)dev; - zassert_true(dev_addr >= CONFIG_SRAM_BASE_ADDRESS && - dev_addr <= CONFIG_SRAM_BASE_ADDRESS + CONFIG_SRAM_SIZE * 1024, + zassert_true(dev_addr >= DT_CHOSEN_SRAM_ADDR && + dev_addr <= DT_CHOSEN_SRAM_ADDR + DT_CHOSEN_SRAM_SIZE, "fake driver device is not in RAM! Address: 0x%lx", dev_addr); TC_PRINT("Fake driver device address: 0x%lx\n", dev_addr); diff --git a/tests/application_development/vector_table_relocation/src/main.c b/tests/application_development/vector_table_relocation/src/main.c index 5de58fcb43bf..c21bab03f145 100644 --- a/tests/application_development/vector_table_relocation/src/main.c +++ b/tests/application_development/vector_table_relocation/src/main.c @@ -22,8 +22,8 @@ #define SRAM_VT_BASE DT_REG_ADDR(ITCM_NODE) #define SRAM_VT_SIZE DT_REG_SIZE(ITCM_NODE) #else -#define SRAM_VT_BASE CONFIG_SRAM_BASE_ADDRESS -#define SRAM_VT_SIZE (CONFIG_SRAM_SIZE * 1024U) +#define SRAM_VT_BASE DT_CHOSEN_SRAM_ADDR +#define SRAM_VT_SIZE DT_CHOSEN_SRAM_SIZE #endif #ifdef SCB_VTOR_TBLBASE_Msk diff --git a/tests/arch/arm64/arm64_high_addresses/high_address.overlay b/tests/arch/arm64/arm64_high_addresses/high_address.overlay new file mode 100644 index 000000000000..21a335fe5708 --- /dev/null +++ b/tests/arch/arm64/arm64_high_addresses/high_address.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x2 0x00880000 0x0 0x80000>; +}; diff --git a/tests/arch/arm64/arm64_high_addresses/low_address.overlay b/tests/arch/arm64/arm64_high_addresses/low_address.overlay new file mode 100644 index 000000000000..11e27cae9abf --- /dev/null +++ b/tests/arch/arm64/arm64_high_addresses/low_address.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x0 0x400000 0x0 0x80000>; +}; diff --git a/tests/arch/arm64/arm64_high_addresses/testcase.yaml b/tests/arch/arm64/arm64_high_addresses/testcase.yaml index 9b09f9745a61..fe350f2f0261 100644 --- a/tests/arch/arm64/arm64_high_addresses/testcase.yaml +++ b/tests/arch/arm64/arm64_high_addresses/testcase.yaml @@ -10,48 +10,56 @@ common: tests: arch.arm64.high_addr.high_sram_low_vm: extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x00400000 + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.low_sram_high_vm: extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x00400000 - CONFIG_KERNEL_VM_BASE=0x200880000 + extra_args: + - EXTRA_DTC_OVERLAY_FILE="low_address.overlay" arch.arm64.high_addr.high_sram_equal_vm: extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x200880000 + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.high_sram_high_vm: extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x200800000 + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.high_sram_low_vm.picolibc: tags: picolibc extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x00400000 - CONFIG_PICOLIBC=y + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.low_sram_high_vm.picolibc: tags: picolibc extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x00400000 - CONFIG_KERNEL_VM_BASE=0x200880000 - CONFIG_PICOLIBC=y + extra_args: + - EXTRA_DTC_OVERLAY_FILE="low_address.overlay" arch.arm64.high_addr.high_sram_equal_vm.picolibc: tags: picolibc extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x200880000 - CONFIG_PICOLIBC=y + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" arch.arm64.high_addr.high_sram_high_vm.picolibc: tags: picolibc extra_configs: - - CONFIG_SRAM_BASE_ADDRESS=0x200880000 - CONFIG_KERNEL_VM_BASE=0x200800000 - CONFIG_PICOLIBC=y + extra_args: + - EXTRA_DTC_OVERLAY_FILE="high_address.overlay" diff --git a/tests/arch/common/gen_isr_table/CMakeLists.txt b/tests/arch/common/gen_isr_table/CMakeLists.txt index 8e26d28c835d..7b9b59e5c54a 100644 --- a/tests/arch/common/gen_isr_table/CMakeLists.txt +++ b/tests/arch/common/gen_isr_table/CMakeLists.txt @@ -10,3 +10,7 @@ target_sources(app PRIVATE ${app_sources}) target_sources_ifdef(CONFIG_MULTI_LEVEL_INTERRUPTS app PRIVATE src/multilevel_irq.c ) + +if(CONFIG_RISCV_CORE_NORDIC_VPR) + zephyr_compile_options(-msmall-data-limit=0) +endif() diff --git a/tests/arch/common/interrupt/CMakeLists.txt b/tests/arch/common/interrupt/CMakeLists.txt index 9068dc77b5cd..19250da6f3a6 100644 --- a/tests/arch/common/interrupt/CMakeLists.txt +++ b/tests/arch/common/interrupt/CMakeLists.txt @@ -20,6 +20,10 @@ if(CONFIG_ARM64) add_compile_options(-mgeneral-regs-only) endif() +if(CONFIG_RISCV_CORE_NORDIC_VPR) + zephyr_compile_options(-msmall-data-limit=0) +endif() + target_sources_ifdef(CONFIG_DYNAMIC_INTERRUPTS app PRIVATE src/dynamic_isr.c) target_sources_ifdef(CONFIG_X86 app PRIVATE src/regular_isr.c) target_sources_ifdef(CONFIG_SHARED_INTERRUPTS app PRIVATE src/static_shared_irq.c) diff --git a/tests/arch/x86/pagetables/src/main.c b/tests/arch/x86/pagetables/src/main.c index c75c73bfbec4..c1f0d9cbffc6 100644 --- a/tests/arch/x86/pagetables/src/main.c +++ b/tests/arch/x86/pagetables/src/main.c @@ -242,9 +242,11 @@ void z_vrfy_dump_my_ptables(void) #include #endif /* CONFIG_USERSPACE */ +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + void dump_pagetables(void) { -#if CONFIG_SRAM_SIZE > (32 << 10) +#if RAM_SIZE > (32 << 10) /* * Takes too long to dump page table, so skip dumping * if memory size is larger than 32MB. diff --git a/tests/benchmarks/mbedtls/prj.conf b/tests/benchmarks/mbedtls/prj.conf index ba24d6663924..944544eed5a3 100644 --- a/tests/benchmarks/mbedtls/prj.conf +++ b/tests/benchmarks/mbedtls/prj.conf @@ -11,8 +11,6 @@ CONFIG_PSA_WANT_ALG_SHA_384=y CONFIG_PSA_WANT_ALG_SHA_512=y CONFIG_PSA_WANT_KEY_TYPE_AES=y -CONFIG_PSA_WANT_KEY_TYPE_ARIA=y -CONFIG_PSA_WANT_KEY_TYPE_CAMELLIA=y CONFIG_PSA_WANT_ALG_ECB_NO_PADDING=y CONFIG_MAIN_STACK_SIZE=4096 diff --git a/tests/benchmarks/mbedtls/src/benchmark.c b/tests/benchmarks/mbedtls/src/benchmark.c index 890652d14a4e..02e9ec2171c2 100644 --- a/tests/benchmarks/mbedtls/src/benchmark.c +++ b/tests/benchmarks/mbedtls/src/benchmark.c @@ -112,30 +112,6 @@ int main(void) printk("Failed to import AES key (%d)", status); } - status = make_cipher_key(PSA_KEY_TYPE_ARIA, PSA_ALG_ECB_NO_PADDING, &key_id); - if (status == PSA_SUCCESS) { - COMPUTE_THROUGHPUT("ARIA-256-ECB", - psa_cipher_encrypt(key_id, PSA_ALG_ECB_NO_PADDING, - in_buf, sizeof(in_buf), - out_buf, sizeof(out_buf), &out_len) - ); - psa_destroy_key(key_id); - } else { - printk("Failed to import ARIA key (%d)", status); - } - - status = make_cipher_key(PSA_KEY_TYPE_CAMELLIA, PSA_ALG_ECB_NO_PADDING, &key_id); - if (status == PSA_SUCCESS) { - COMPUTE_THROUGHPUT("CAMELLIA-256-ECB", - psa_cipher_encrypt(key_id, PSA_ALG_ECB_NO_PADDING, - in_buf, sizeof(in_buf), - out_buf, sizeof(out_buf), &out_len) - ); - psa_destroy_key(key_id); - } else { - printk("Failed to import Camellia key (%d)", status); - } - printk("Benchmark completed\n"); return 0; } diff --git a/tests/benchmarks/sys_kernel/src/syskernel.h b/tests/benchmarks/sys_kernel/src/syskernel.h index f12c2ea21d73..d8827ee60644 100644 --- a/tests/benchmarks/sys_kernel/src/syskernel.h +++ b/tests/benchmarks/sys_kernel/src/syskernel.h @@ -15,7 +15,9 @@ #include #define STACK_SIZE 2048 -#if CONFIG_SRAM_SIZE <= 32 +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + +#if RAM_SIZE <= 32 #define NUMBER_OF_LOOPS 100 #else #define NUMBER_OF_LOOPS 1000 diff --git a/tests/bluetooth/controller/ctrl_api/testcase.yaml b/tests/bluetooth/controller/ctrl_api/testcase.yaml index 19bf6c9ab490..21f178bf9b2b 100644 --- a/tests/bluetooth/controller/ctrl_api/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_api/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_api.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_chmu/testcase.yaml b/tests/bluetooth/controller/ctrl_chmu/testcase.yaml index f7e8068d60ec..9c3ee6264335 100644 --- a/tests/bluetooth/controller/ctrl_chmu/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_chmu/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_chmu.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_cis_create/testcase.yaml b/tests/bluetooth/controller/ctrl_cis_create/testcase.yaml index 99612a89bc31..2371d7063eb7 100644 --- a/tests/bluetooth/controller/ctrl_cis_create/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_cis_create/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_cis_create.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_cis_terminate/testcase.yaml b/tests/bluetooth/controller/ctrl_cis_terminate/testcase.yaml index 956172a89b20..a98229ba45f3 100644 --- a/tests/bluetooth/controller/ctrl_cis_terminate/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_cis_terminate/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_cis_terminate.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_collision/testcase.yaml b/tests/bluetooth/controller/ctrl_collision/testcase.yaml index 6086a9a4ebc8..daa8f3bc6c3d 100644 --- a/tests/bluetooth/controller/ctrl_collision/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_collision/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_collision.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_conn_update/testcase.yaml b/tests/bluetooth/controller/ctrl_conn_update/testcase.yaml index 5b0bda4b9088..fc4ecb0b647d 100644 --- a/tests/bluetooth/controller/ctrl_conn_update/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_conn_update/testcase.yaml @@ -7,11 +7,18 @@ common: tests: bluetooth.controller.ctrl_conn_update.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_conn_update.apm_test: type: unit - extra_args: CONF_FILE=prj_apm.conf + extra_args: + - CONF_FILE=prj_apm.conf + - SNIPPET="bt-ll-sw-split" + bluetooth.controller.ctrl_conn_update.no_param_req_test: type: unit - extra_args: CONF_FILE=prj_no_param_req.conf + extra_args: + - CONF_FILE=prj_no_param_req.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_cte_req/testcase.yaml b/tests/bluetooth/controller/ctrl_cte_req/testcase.yaml index fd6ff51118d9..c6288aecc433 100644 --- a/tests/bluetooth/controller/ctrl_cte_req/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_cte_req/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_cte_req.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_data_length_update/testcase.yaml b/tests/bluetooth/controller/ctrl_data_length_update/testcase.yaml index 9778af435b4a..c7d1174e12bf 100644 --- a/tests/bluetooth/controller/ctrl_data_length_update/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_data_length_update/testcase.yaml @@ -6,11 +6,17 @@ common: tests: bluetooth.controller.ctrl_data_length_update.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_data_length_update.test_nocodedphy: type: unit - extra_args: CONF_FILE=prj_nocoded.conf + extra_args: + - CONF_FILE=prj_nocoded.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_data_length_update.test_nophy: type: unit - extra_args: CONF_FILE=prj_nophy.conf + extra_args: + - CONF_FILE=prj_nophy.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_encrypt/testcase.yaml b/tests/bluetooth/controller/ctrl_encrypt/testcase.yaml index d5bb2cb8b110..86dd5bfe4d30 100644 --- a/tests/bluetooth/controller/ctrl_encrypt/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_encrypt/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_encrypt.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_feature_exchange/testcase.yaml b/tests/bluetooth/controller/ctrl_feature_exchange/testcase.yaml index 257542f36120..087e49575ff7 100644 --- a/tests/bluetooth/controller/ctrl_feature_exchange/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_feature_exchange/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_feature_exchange.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_hci/testcase.yaml b/tests/bluetooth/controller/ctrl_hci/testcase.yaml index d7f7ce7168d1..e0735bae6962 100644 --- a/tests/bluetooth/controller/ctrl_hci/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_hci/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_hci.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_invalid/testcase.yaml b/tests/bluetooth/controller/ctrl_invalid/testcase.yaml index 2d1741931e37..cee54e6b09ed 100644 --- a/tests/bluetooth/controller/ctrl_invalid/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_invalid/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_invalid.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_le_ping/testcase.yaml b/tests/bluetooth/controller/ctrl_le_ping/testcase.yaml index b6a77528f32d..54178905da17 100644 --- a/tests/bluetooth/controller/ctrl_le_ping/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_le_ping/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_le_ping.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_min_used_chans/testcase.yaml b/tests/bluetooth/controller/ctrl_min_used_chans/testcase.yaml index 0991b0cdd43c..a9445cbf8c4d 100644 --- a/tests/bluetooth/controller/ctrl_min_used_chans/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_min_used_chans/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_min_used_chans.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_phy_update/testcase.yaml b/tests/bluetooth/controller/ctrl_phy_update/testcase.yaml index 1d7da169f1d8..d5c49d587a8f 100644 --- a/tests/bluetooth/controller/ctrl_phy_update/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_phy_update/testcase.yaml @@ -6,6 +6,10 @@ common: tests: bluetooth.controller.ctrl_phy_update.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_phy_update.test_reduced_buf: type: unit - extra_args: CONF_FILE=prj_rx_cnt.conf + extra_args: + - CONF_FILE=prj_rx_cnt.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_sca_update/testcase.yaml b/tests/bluetooth/controller/ctrl_sca_update/testcase.yaml index cbf63aa1b575..cbc3c3faf720 100644 --- a/tests/bluetooth/controller/ctrl_sca_update/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_sca_update/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_sca_update.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_sw_privacy/testcase.yaml b/tests/bluetooth/controller/ctrl_sw_privacy/testcase.yaml index 778606d69549..ac5dd6e957eb 100644 --- a/tests/bluetooth/controller/ctrl_sw_privacy/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_sw_privacy/testcase.yaml @@ -4,3 +4,5 @@ common: tests: bluetooth.ctrl_sw_privacy.test: platform_allow: nrf52_bsim + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_terminate/testcase.yaml b/tests/bluetooth/controller/ctrl_terminate/testcase.yaml index cbe639401ea3..6b1409e9653e 100644 --- a/tests/bluetooth/controller/ctrl_terminate/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_terminate/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_terminate.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_tx_buffer_alloc/testcase.yaml b/tests/bluetooth/controller/ctrl_tx_buffer_alloc/testcase.yaml index 614eb7fe94c0..363986bd3d35 100644 --- a/tests/bluetooth/controller/ctrl_tx_buffer_alloc/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_tx_buffer_alloc/testcase.yaml @@ -6,23 +6,35 @@ common: tests: bluetooth.controller.ctrl_tx_buffer_alloc.test_0_per_conn: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_1_per_conn: type: unit - extra_args: CONF_FILE=prj_1.conf + extra_args: + - CONF_FILE=prj_1.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_2_per_conn: type: unit - extra_args: CONF_FILE=prj_2.conf + extra_args: + - CONF_FILE=prj_2.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_3_per_conn: type: unit - extra_args: CONF_FILE=prj_3.conf + extra_args: + - CONF_FILE=prj_3.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_max_per_conn_alloc: type: unit - extra_args: CONF_FILE=prj_max.conf + extra_args: + - CONF_FILE=prj_max.conf + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_tx_buffer_alloc.test_max_common_alloc: type: unit - extra_args: CONF_FILE=prj_max_common.conf + extra_args: + - CONF_FILE=prj_max_common.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_tx_queue/testcase.yaml b/tests/bluetooth/controller/ctrl_tx_queue/testcase.yaml index 295ad891a630..282b620b317a 100644 --- a/tests/bluetooth/controller/ctrl_tx_queue/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_tx_queue/testcase.yaml @@ -5,3 +5,5 @@ common: tests: bluetooth.ctrl_tx_queue.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_unsupported/testcase.yaml b/tests/bluetooth/controller/ctrl_unsupported/testcase.yaml index 28aba1a752a8..48b18af93536 100644 --- a/tests/bluetooth/controller/ctrl_unsupported/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_unsupported/testcase.yaml @@ -6,7 +6,11 @@ common: tests: bluetooth.controller.ctrl_unsupported.default.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" bluetooth.controller.ctrl_unsupported.test: type: unit - extra_args: CONF_FILE=prj_unsupported.conf + extra_args: + - CONF_FILE=prj_unsupported.conf + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_user_ext/testcase.yaml b/tests/bluetooth/controller/ctrl_user_ext/testcase.yaml index af319a7a7191..be963df24a8a 100644 --- a/tests/bluetooth/controller/ctrl_user_ext/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_user_ext/testcase.yaml @@ -4,3 +4,5 @@ common: tests: bluetooth.ctrl_user_ext.test: platform_allow: nrf52_bsim + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/controller/ctrl_version/testcase.yaml b/tests/bluetooth/controller/ctrl_version/testcase.yaml index 6badcbc72547..5df86b9bca9f 100644 --- a/tests/bluetooth/controller/ctrl_version/testcase.yaml +++ b/tests/bluetooth/controller/ctrl_version/testcase.yaml @@ -6,3 +6,5 @@ common: tests: bluetooth.controller.ctrl_version.test: type: unit + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connection_cte_req/testcase.yaml b/tests/bluetooth/df/connection_cte_req/testcase.yaml index 768aba4a51f5..fbfe4b0d9a1a 100644 --- a/tests/bluetooth/df/connection_cte_req/testcase.yaml +++ b/tests/bluetooth/df/connection_cte_req/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.conection_cte_req: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connection_cte_tx_params/testcase.yaml b/tests/bluetooth/df/connection_cte_tx_params/testcase.yaml index 38a23b0950e3..a9986c5b0e53 100644 --- a/tests/bluetooth/df/connection_cte_tx_params/testcase.yaml +++ b/tests/bluetooth/df/connection_cte_tx_params/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.conection_cte_tx_params: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connectionless_cte_chains/testcase.yaml b/tests/bluetooth/df/connectionless_cte_chains/testcase.yaml index 6aa5bb0f0c1c..844a7bbb524e 100644 --- a/tests/bluetooth/df/connectionless_cte_chains/testcase.yaml +++ b/tests/bluetooth/df/connectionless_cte_chains/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.connectionless_cte_chains: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connectionless_cte_rx/testcase.yaml b/tests/bluetooth/df/connectionless_cte_rx/testcase.yaml index f839b1910eb2..c8f08a908436 100644 --- a/tests/bluetooth/df/connectionless_cte_rx/testcase.yaml +++ b/tests/bluetooth/df/connectionless_cte_rx/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.connectionless_cte_rx: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/df/connectionless_cte_tx/testcase.yaml b/tests/bluetooth/df/connectionless_cte_tx/testcase.yaml index 77d651d0cbc2..491cc0e7e599 100644 --- a/tests/bluetooth/df/connectionless_cte_tx/testcase.yaml +++ b/tests/bluetooth/df/connectionless_cte_tx/testcase.yaml @@ -2,3 +2,5 @@ tests: bluetooth.df.connectionless_cte_tx: platform_allow: nrf52_bsim tags: bluetooth + extra_args: + - SNIPPET="bt-ll-sw-split" diff --git a/tests/bluetooth/host/crypto/CMakeLists.txt b/tests/bluetooth/host/crypto/CMakeLists.txt index cb02bd50abff..b1edecf46073 100644 --- a/tests/bluetooth/host/crypto/CMakeLists.txt +++ b/tests/bluetooth/host/crypto/CMakeLists.txt @@ -25,8 +25,7 @@ target_include_directories(mocks PUBLIC ${ZEPHYR_BASE}/subsys/bluetooth/host ${ZEPHYR_BASE}/tests/bluetooth/host ${ZEPHYR_BASE}/tests/bluetooth/host/crypto/mocks - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/include - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/include/ + ${ZEPHYR_MBEDTLS_MODULE_DIR}/include ) target_link_libraries(mocks PRIVATE test_interface) diff --git a/tests/bluetooth/host/id/mocks/adv.c b/tests/bluetooth/host/id/mocks/adv.c index 2c2d4f3f3c7a..a22123dea3da 100644 --- a/tests/bluetooth/host/id/mocks/adv.c +++ b/tests/bluetooth/host/id/mocks/adv.c @@ -15,3 +15,4 @@ DEFINE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable_legacy, struct bt_le_ext_adv *, DEFINE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable_ext, struct bt_le_ext_adv *, bool, const struct bt_le_ext_adv_start_param *); DEFINE_FAKE_VOID_FUNC(bt_le_ext_adv_foreach, bt_le_ext_adv_foreach_cb, void *); +DEFINE_FAKE_VALUE_FUNC(struct bt_le_ext_adv *, bt_adv_lookup_by_id, uint8_t); diff --git a/tests/bluetooth/host/id/mocks/adv.h b/tests/bluetooth/host/id/mocks/adv.h index bfb744001596..1602ddf47185 100644 --- a/tests/bluetooth/host/id/mocks/adv.h +++ b/tests/bluetooth/host/id/mocks/adv.h @@ -18,7 +18,8 @@ typedef void (*bt_le_ext_adv_foreach_cb)(struct bt_le_ext_adv *adv, void *data); FAKE(bt_le_adv_lookup_legacy) \ FAKE(bt_le_ext_adv_get_index) \ FAKE(bt_le_adv_set_enable_ext) \ - FAKE(bt_le_ext_adv_foreach) + FAKE(bt_le_ext_adv_foreach) \ + FAKE(bt_adv_lookup_by_id) DECLARE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable, struct bt_le_ext_adv *, bool); DECLARE_FAKE_VALUE_FUNC(struct bt_le_ext_adv *, bt_le_adv_lookup_legacy); @@ -27,3 +28,4 @@ DECLARE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable_legacy, struct bt_le_ext_adv * DECLARE_FAKE_VALUE_FUNC(int, bt_le_adv_set_enable_ext, struct bt_le_ext_adv *, bool, const struct bt_le_ext_adv_start_param *); DECLARE_FAKE_VOID_FUNC(bt_le_ext_adv_foreach, bt_le_ext_adv_foreach_cb, void *); +DECLARE_FAKE_VALUE_FUNC(struct bt_le_ext_adv *, bt_adv_lookup_by_id, uint8_t); diff --git a/tests/bluetooth/host/id/mocks/keys.c b/tests/bluetooth/host/id/mocks/keys.c index f885ab875c0f..61f73569c469 100644 --- a/tests/bluetooth/host/id/mocks/keys.c +++ b/tests/bluetooth/host/id/mocks/keys.c @@ -10,3 +10,4 @@ DEFINE_FAKE_VALUE_FUNC(struct bt_keys *, bt_keys_find_irk, uint8_t, const bt_addr_le_t *); DEFINE_FAKE_VOID_FUNC(bt_keys_foreach_type, enum bt_keys_type, bt_keys_foreach_type_cb, void *); +DEFINE_FAKE_VALUE_FUNC(struct bt_keys *, bt_keys_get_addr, uint8_t, const bt_addr_le_t *); diff --git a/tests/bluetooth/host/id/mocks/keys.h b/tests/bluetooth/host/id/mocks/keys.h index b6901e315ab9..1912472b78de 100644 --- a/tests/bluetooth/host/id/mocks/keys.h +++ b/tests/bluetooth/host/id/mocks/keys.h @@ -15,7 +15,9 @@ typedef void (*bt_keys_foreach_type_cb)(struct bt_keys *keys, void *data); /* List of fakes used by this unit tester */ #define KEYS_FFF_FAKES_LIST(FAKE) \ FAKE(bt_keys_find_irk) \ - FAKE(bt_keys_foreach_type) + FAKE(bt_keys_foreach_type) \ + FAKE(bt_keys_get_addr) DECLARE_FAKE_VALUE_FUNC(struct bt_keys *, bt_keys_find_irk, uint8_t, const bt_addr_le_t *); DECLARE_FAKE_VOID_FUNC(bt_keys_foreach_type, enum bt_keys_type, bt_keys_foreach_type_cb, void *); +DECLARE_FAKE_VALUE_FUNC(struct bt_keys *, bt_keys_get_addr, uint8_t, const bt_addr_le_t *); diff --git a/tests/bluetooth/init/testcase.yaml b/tests/bluetooth/init/testcase.yaml index 120b6a3d81bd..bbefd93265c1 100644 --- a/tests/bluetooth/init/testcase.yaml +++ b/tests/bluetooth/init/testcase.yaml @@ -62,7 +62,9 @@ tests: extra_args: CONF_FILE=prj_6.conf platform_allow: qemu_cortex_m3 bluetooth.init.test_ctlr: - extra_args: CONF_FILE=prj_ctlr.conf + extra_args: + - CONF_FILE=prj_ctlr.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -74,7 +76,9 @@ tests: - nrf51dk/nrf51822 - rv32m1_vega/openisa_rv32m1/ri5cy bluetooth.init.test_ctlr_4_0: - extra_args: CONF_FILE=prj_ctlr_4_0.conf + extra_args: + - CONF_FILE=prj_ctlr_4_0.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -83,7 +87,9 @@ tests: - nrf52dk/nrf52832 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_4_0_dbg: - extra_args: CONF_FILE=prj_ctlr_4_0_dbg.conf + extra_args: + - CONF_FILE=prj_ctlr_4_0_dbg.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -92,7 +98,9 @@ tests: - nrf52dk/nrf52832 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_tiny: - extra_args: CONF_FILE=prj_ctlr_tiny.conf + extra_args: + - CONF_FILE=prj_ctlr_tiny.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -104,6 +112,7 @@ tests: extra_args: - CONF_FILE=prj_ctlr_dbg.conf - DTC_OVERLAY_FILE=pa_lna.overlay + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -114,6 +123,7 @@ tests: extra_args: - CONF_FILE=prj_ctlr_5_x_dbg.conf - DTC_OVERLAY_FILE=pa_lna.overlay + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -125,6 +135,7 @@ tests: - CONF_FILE=prj_ctlr.conf - CONFIG_BT_CTLR_ADVANCED_FEATURES=y - CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER=y + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf5340dk/nrf5340/cpunet - nrf52840dk/nrf52840 @@ -134,13 +145,16 @@ tests: bluetooth.init.test_ctlr_ticker: extra_args: - CONF_FILE=prj_ctlr_ticker.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 integration_platforms: - nrf52dk/nrf52832 bluetooth.init.test_ctlr_broadcaster: - extra_args: CONF_FILE=prj_ctlr_broadcaster.conf + extra_args: + - CONF_FILE=prj_ctlr_broadcaster.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -149,7 +163,9 @@ tests: integration_platforms: - nrf52dk/nrf52832 bluetooth.init.test_ctlr_peripheral: - extra_args: CONF_FILE=prj_ctlr_peripheral.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -158,7 +174,9 @@ tests: integration_platforms: - nrf52dk/nrf52832 bluetooth.init.test_ctlr_peripheral_priv: - extra_args: CONF_FILE=prj_ctlr_peripheral_priv.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral_priv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -167,7 +185,9 @@ tests: integration_platforms: - nrf52840dk/nrf52840 bluetooth.init.test_ctlr_observer: - extra_args: CONF_FILE=prj_ctlr_observer.conf + extra_args: + - CONF_FILE=prj_ctlr_observer.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -176,7 +196,9 @@ tests: integration_platforms: - nrf52dk/nrf52832 bluetooth.init.test_ctlr_central: - extra_args: CONF_FILE=prj_ctlr_central.conf + extra_args: + - CONF_FILE=prj_ctlr_central.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -186,7 +208,9 @@ tests: - nrf52dk/nrf52832 - rv32m1_vega/openisa_rv32m1/ri5cy bluetooth.init.test_ctlr_central_priv: - extra_args: CONF_FILE=prj_ctlr_central_priv.conf + extra_args: + - CONF_FILE=prj_ctlr_central_priv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -196,7 +220,9 @@ tests: - nrf52dk/nrf52832 - rv32m1_vega/openisa_rv32m1/ri5cy bluetooth.init.test_ctlr_broadcaster_ext: - extra_args: CONF_FILE=prj_ctlr_broadcaster_ext.conf + extra_args: + - CONF_FILE=prj_ctlr_broadcaster_ext.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -205,7 +231,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_peripheral_ext: - extra_args: CONF_FILE=prj_ctlr_peripheral_ext.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral_ext.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -214,7 +242,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_peripheral_ext_priv: - extra_args: CONF_FILE=prj_ctlr_peripheral_ext_priv.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral_ext_priv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -223,7 +253,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_oberver_ext: - extra_args: CONF_FILE=prj_ctlr_observer_ext.conf + extra_args: + - CONF_FILE=prj_ctlr_observer_ext.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -232,7 +264,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_central_ext: - extra_args: CONF_FILE=prj_ctlr_central_ext.conf + extra_args: + - CONF_FILE=prj_ctlr_central_ext.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -241,7 +275,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_central_ext_priv: - extra_args: CONF_FILE=prj_ctlr_central_ext_priv.conf + extra_args: + - CONF_FILE=prj_ctlr_central_ext_priv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -250,7 +286,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_adv: - extra_args: CONF_FILE=prj_ctlr_per_adv.conf + extra_args: + - CONF_FILE=prj_ctlr_per_adv.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -259,7 +297,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_adv_no_adi: - extra_args: CONF_FILE=prj_ctlr_per_adv_no_adi.conf + extra_args: + - CONF_FILE=prj_ctlr_per_adv_no_adi.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -268,7 +308,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_sync: - extra_args: CONF_FILE=prj_ctlr_per_sync.conf + extra_args: + - CONF_FILE=prj_ctlr_per_sync.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -277,7 +319,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_sync_no_adi: - extra_args: CONF_FILE=prj_ctlr_per_sync_no_adi.conf + extra_args: + - CONF_FILE=prj_ctlr_per_sync_no_adi.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -286,7 +330,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_per_sync_no_filter: - extra_args: CONF_FILE=prj_ctlr_per_sync_no_filter.conf + extra_args: + - CONF_FILE=prj_ctlr_per_sync_no_filter.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -295,7 +341,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_peripheral_iso: - extra_args: CONF_FILE=prj_ctlr_peripheral_iso.conf + extra_args: + - CONF_FILE=prj_ctlr_peripheral_iso.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -304,7 +352,9 @@ tests: - nrf52840dk/nrf52840 - nrf51dk/nrf51822 bluetooth.init.test_ctlr_central_iso: - extra_args: CONF_FILE=prj_ctlr_central_iso.conf + extra_args: + - CONF_FILE=prj_ctlr_central_iso.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -323,7 +373,9 @@ tests: - DTC_OVERLAY_FILE=h5.overlay platform_allow: qemu_cortex_m3 bluetooth.init.test_llcp: - extra_args: CONF_FILE=prj_llcp.conf + extra_args: + - CONF_FILE=prj_llcp.conf + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 - nrf52dk/nrf52832 @@ -335,6 +387,7 @@ tests: extra_args: - CONF_FILE=prj_ctlr.conf - CONFIG_BT_RECV_WORKQ_BT=y + - SNIPPET="bt-ll-sw-split" platform_allow: - nrf52840dk/nrf52840 bluetooth.init.test_host_6_x: diff --git a/tests/bluetooth/mesh/brg/CMakeLists.txt b/tests/bluetooth/mesh/brg/CMakeLists.txt index 809dddfd358b..039215c66f10 100644 --- a/tests/bluetooth/mesh/brg/CMakeLists.txt +++ b/tests/bluetooth/mesh/brg/CMakeLists.txt @@ -14,8 +14,7 @@ target_sources(app target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/bluetooth/mesh - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/include - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/include/ + ${ZEPHYR_MBEDTLS_MODULE_DIR}/include ) target_compile_options(app diff --git a/tests/bluetooth/mesh/delayable_msg/CMakeLists.txt b/tests/bluetooth/mesh/delayable_msg/CMakeLists.txt index 2729668dd01e..6b955369c437 100644 --- a/tests/bluetooth/mesh/delayable_msg/CMakeLists.txt +++ b/tests/bluetooth/mesh/delayable_msg/CMakeLists.txt @@ -14,8 +14,7 @@ target_sources(app target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/bluetooth/mesh - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/include - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/include/ + ${ZEPHYR_MBEDTLS_MODULE_DIR}/include ) target_compile_options(app diff --git a/tests/bluetooth/mesh/net/CMakeLists.txt b/tests/bluetooth/mesh/net/CMakeLists.txt index 284602e218de..dd68ac06bb20 100644 --- a/tests/bluetooth/mesh/net/CMakeLists.txt +++ b/tests/bluetooth/mesh/net/CMakeLists.txt @@ -15,8 +15,7 @@ target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/bluetooth/mesh ${ZEPHYR_BASE}/subsys/bluetooth - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/include - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/include/ + ${ZEPHYR_MBEDTLS_MODULE_DIR}/include ) target_compile_options(app diff --git a/tests/bluetooth/mesh/rpl/CMakeLists.txt b/tests/bluetooth/mesh/rpl/CMakeLists.txt index faa753540516..5a627ca0f4d2 100644 --- a/tests/bluetooth/mesh/rpl/CMakeLists.txt +++ b/tests/bluetooth/mesh/rpl/CMakeLists.txt @@ -14,8 +14,7 @@ target_sources(app target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/bluetooth/mesh - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/include - ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/include/ + ${ZEPHYR_MBEDTLS_MODULE_DIR}/include ) target_compile_options(app diff --git a/tests/bluetooth/mesh_shell/prj.conf b/tests/bluetooth/mesh_shell/prj.conf index 2af600295680..aab2745d359f 100644 --- a/tests/bluetooth/mesh_shell/prj.conf +++ b/tests/bluetooth/mesh_shell/prj.conf @@ -14,7 +14,7 @@ CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_NVS=y CONFIG_SETTINGS=y -CONFIG_SECURE_STORAGE=y +# CONFIG_SECURE_STORAGE=y CONFIG_BT=y CONFIG_BT_OBSERVER=y diff --git a/tests/bluetooth/tester/Kconfig.sysbuild b/tests/bluetooth/tester/Kconfig.sysbuild index 69e4d5a97fbe..e14a6e1aa8e0 100644 --- a/tests/bluetooth/tester/Kconfig.sysbuild +++ b/tests/bluetooth/tester/Kconfig.sysbuild @@ -5,6 +5,7 @@ source "share/sysbuild/Kconfig" config NET_CORE_BOARD string + default "nrf54h20dk/nrf54h20/cpurad" if "$(BOARD)" = "nrf54h20dk" default "nrf5340dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340dk" default "nrf5340_audio_dk/nrf5340/cpunet" if "$(BOARD)" = "nrf5340_audio_dk" default "nrf5340bsim/nrf5340/cpunet" if $(BOARD_TARGET_STRING) = "NRF5340BSIM_NRF5340_CPUAPP" diff --git a/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.conf b/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.conf index 5bb1c4d82846..80cd932a3976 100644 --- a/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.conf +++ b/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.conf @@ -22,3 +22,8 @@ CONFIG_LOG_DEFAULT_LEVEL=3 CONFIG_BTTESTER_LOG_LEVEL_DBG=y CONFIG_UART_INTERRUPT_DRIVEN=y + +# Enable PSA RNG +CONFIG_PSA_CRYPTO_DRIVER_OBERON=n +CONFIG_PSA_SSF_CRYPTO_CLIENT=y +CONFIG_PSA_CRYPTO=y diff --git a/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index e6d4f675f57a..4f9de686b7e5 100644 --- a/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/bluetooth/tester/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -12,3 +12,17 @@ status = "okay"; hw-flow-control; }; + +// Enable PSA RNG +/ { + chosen { + zephyr,entropy = &psa_rng; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; + + /delete-node/ prng; +}; diff --git a/tests/bluetooth/tester/sysbuild.cmake b/tests/bluetooth/tester/sysbuild.cmake index b0bb228ab997..b4c05e1ee4aa 100644 --- a/tests/bluetooth/tester/sysbuild.cmake +++ b/tests/bluetooth/tester/sysbuild.cmake @@ -2,8 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) - # For builds in the nrf5340, we build the netcore image with the controller - set(NET_APP hci_ipc) set(NET_APP_SRC_DIR ${ZEPHYR_BASE}/samples/bluetooth/${NET_APP}) @@ -13,6 +11,13 @@ if(SB_CONFIG_NET_CORE_IMAGE_HCI_IPC) BOARD ${SB_CONFIG_NET_CORE_BOARD} ) + if(SB_CONFIG_SOC_NRF5340_CPUAPP) + set(${NET_APP}_SNIPPET + "bt-ll-sw-split" + CACHE INTERNAL "" + ) + endif() + set(${NET_APP}_EXTRA_CONF_FILE ${APP_DIR}/overlay-bt_ll_sw_split.conf CACHE INTERNAL "" diff --git a/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf b/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 000000000000..081c04a7bc5f --- /dev/null +++ b/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1,38 @@ +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +CONFIG_ISR_STACK_SIZE=1024 +CONFIG_IDLE_STACK_SIZE=256 +CONFIG_MAIN_STACK_SIZE=1024 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 +CONFIG_IPC_SERVICE_BACKEND_RPMSG_WQ_STACK_SIZE=512 +CONFIG_HEAP_MEM_POOL_SIZE=8192 + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y + +CONFIG_BT_BUF_EVT_RX_COUNT=16 +CONFIG_BT_BUF_EVT_RX_SIZE=255 +CONFIG_BT_BUF_ACL_RX_SIZE=255 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_BUF_CMD_TX_SIZE=255 + +# Host +CONFIG_BT_BROADCASTER=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_OBSERVER=y +CONFIG_BT_CENTRAL=y +CONFIG_BT_EXT_ADV=y +CONFIG_BT_PER_ADV=y +CONFIG_BT_PER_ADV_SYNC=y + +# Controller +CONFIG_BT_LL_SW_SPLIT=n +CONFIG_BT_LL_SOFTDEVICE=y +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 +CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 + +# Enable PSA RNG +CONFIG_PSA_CRYPTO_DRIVER_OBERON=n +CONFIG_PSA_SSF_CRYPTO_CLIENT=y +CONFIG_PSA_CRYPTO=y diff --git a/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay new file mode 100644 index 000000000000..e34567fe834a --- /dev/null +++ b/tests/bluetooth/tester/sysbuild/hci_ipc/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -0,0 +1,13 @@ +// Enable PSA RNG +/ { + chosen { + zephyr,entropy = &psa_rng; + }; + + psa_rng: psa-rng { + compatible = "zephyr,psa-crypto-rng"; + status = "okay"; + }; + + /delete-node/ prng; +}; diff --git a/tests/bluetooth/tester/sysbuild/hci_ipc/prj.conf b/tests/bluetooth/tester/sysbuild/hci_ipc/prj.conf new file mode 100644 index 000000000000..08b1aed9e7f6 --- /dev/null +++ b/tests/bluetooth/tester/sysbuild/hci_ipc/prj.conf @@ -0,0 +1,23 @@ +CONFIG_IPC_SERVICE=y +CONFIG_MBOX=y + +CONFIG_HEAP_MEM_POOL_SIZE=4096 + +CONFIG_MAIN_STACK_SIZE=512 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512 + +CONFIG_BT=y +CONFIG_BT_HCI_RAW=y +CONFIG_BT_MAX_CONN=16 + + +# Workaround: Unable to allocate command buffer when using K_NO_WAIT since +# Host number of completed commands does not follow normal flow control. +CONFIG_BT_BUF_CMD_TX_COUNT=10 + +# Enable and adjust the below value as necessary +# CONFIG_BT_BUF_EVT_RX_COUNT=16 +# CONFIG_BT_BUF_EVT_RX_SIZE=255 +# CONFIG_BT_BUF_ACL_RX_SIZE=255 +# CONFIG_BT_BUF_ACL_TX_SIZE=251 +# CONFIG_BT_BUF_CMD_TX_SIZE=255 diff --git a/tests/boards/nrf/gppi/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/boards/nrf/gppi/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index 7e59ee37c829..f9d9637019e4 100644 --- a/tests/boards/nrf/gppi/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/boards/nrf/gppi/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -16,6 +16,6 @@ dut_timer2: &timer134 { status = "reserved"; }; -&comp { +&pdm0 { status = "reserved"; }; diff --git a/tests/boards/nrf/gppi/src/main.c b/tests/boards/nrf/gppi/src/main.c index f8af6fbe12ef..5323c4dd6dfc 100644 --- a/tests/boards/nrf/gppi/src/main.c +++ b/tests/boards/nrf/gppi/src/main.c @@ -10,17 +10,46 @@ #include #include #include -#if defined(CONFIG_SOC_NRF54H20_CPURAD) +#include +#if DT_NODE_EXISTS(DT_NODELABEL(pdm0)) && DT_NODE_HAS_STATUS(DT_NODELABEL(pdm0), reserved) +#include +#elif DT_NODE_EXISTS(DT_NODELABEL(comp)) && DT_NODE_HAS_STATUS(DT_NODELABEL(comp), reserved) +#include +#elif defined(CONFIG_SOC_NRF54H20_CPURAD) #include #endif -#include -#include NRF_TIMER_Type *timer0 = (NRF_TIMER_Type *)DT_REG_ADDR(DT_NODELABEL(dut_timer0)); NRF_TIMER_Type *timer1 = (NRF_TIMER_Type *)DT_REG_ADDR(DT_NODELABEL(dut_timer1)); NRF_TIMER_Type *timer2 = (NRF_TIMER_Type *)DT_REG_ADDR(DT_NODELABEL(dut_timer2)); -#if DT_NODE_EXISTS(DT_NODELABEL(comp)) && DT_NODE_HAS_STATUS(DT_NODELABEL(comp), reserved) +#if DT_NODE_EXISTS(DT_NODELABEL(pdm0)) && DT_NODE_HAS_STATUS(DT_NODELABEL(pdm0), reserved) +NRF_PDM_Type *pdm = (NRF_PDM_Type *)DT_REG_ADDR(DT_NODELABEL(pdm0)); + +static void sink_setup(void) +{ + nrf_pdm_task_trigger(pdm, NRF_PDM_TASK_STOP); + nrf_pdm_event_clear(pdm, NRF_PDM_EVENT_STARTED); + nrf_pdm_enable(pdm); +} + +static void sink_cleanup(void) +{ + nrf_pdm_task_trigger(pdm, NRF_PDM_TASK_STOP); + nrf_pdm_disable(pdm); +} + +static bool sink_evt_check(void) +{ + return nrf_pdm_event_check(pdm, NRF_PDM_EVENT_STARTED); +} + +static uint32_t sink_tsk_addr(void) +{ + return nrf_pdm_task_address_get(pdm, NRF_PDM_TASK_START); +} + +#elif DT_NODE_EXISTS(DT_NODELABEL(comp)) && DT_NODE_HAS_STATUS(DT_NODELABEL(comp), reserved) NRF_LPCOMP_Type *lpcomp = (NRF_LPCOMP_Type *)DT_REG_ADDR(DT_NODELABEL(comp)); static void sink_setup(void) diff --git a/tests/boards/nrf/i2c/i2c_slave/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay b/tests/boards/nrf/i2c/i2c_slave/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay new file mode 100644 index 000000000000..a9bb00b00e2d --- /dev/null +++ b/tests/boards/nrf/i2c/i2c_slave/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120dk_nrf7120_cpuapp.overlay" diff --git a/tests/boards/nrf/i2c/i2c_slave/testcase.yaml b/tests/boards/nrf/i2c/i2c_slave/testcase.yaml index 2e0191e4af2d..5830946f731a 100644 --- a/tests/boards/nrf/i2c/i2c_slave/testcase.yaml +++ b/tests/boards/nrf/i2c/i2c_slave/testcase.yaml @@ -19,6 +19,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns integration_platforms: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp @@ -44,6 +45,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns integration_platforms: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp diff --git a/tests/boards/nrf/qdec/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay b/tests/boards/nrf/qdec/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay new file mode 100644 index 000000000000..d806d1dae7c5 --- /dev/null +++ b/tests/boards/nrf/qdec/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay @@ -0,0 +1,6 @@ +/* + * Copyright 2025 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120dk_nrf7120_common.dtsi" diff --git a/tests/boards/nrf/qdec/testcase.yaml b/tests/boards/nrf/qdec/testcase.yaml index 3142d11cb725..cc2a4a0c7782 100644 --- a/tests/boards/nrf/qdec/testcase.yaml +++ b/tests/boards/nrf/qdec/testcase.yaml @@ -11,6 +11,7 @@ common: - nrf54lm20dk/nrf54lm20b/cpuapp - nrf54lm20dk/nrf54lm20b/cpuflpr - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns integration_platforms: - nrf52840dk/nrf52840 - nrf5340dk/nrf5340/cpuapp @@ -20,6 +21,7 @@ common: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20a/cpuflpr - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns harness: ztest harness_config: fixture: gpio_loopback 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/boot/uefi/app.overlay b/tests/boot/uefi/app.overlay new file mode 100644 index 000000000000..3867176dbcda --- /dev/null +++ b/tests/boot/uefi/app.overlay @@ -0,0 +1,3 @@ +&dram0 { + reg = <0x0 0xc800000>; +}; diff --git a/tests/boot/uefi/prj.conf b/tests/boot/uefi/prj.conf index 48ca509cdd56..5ba848d79bef 100644 --- a/tests/boot/uefi/prj.conf +++ b/tests/boot/uefi/prj.conf @@ -1,4 +1,3 @@ CONFIG_QEMU_UEFI_BOOT=y CONFIG_BUILD_OUTPUT_EFI=y -CONFIG_SRAM_SIZE=204800 CONFIG_ACPI=y diff --git a/tests/drivers/clock_control/clock_control_api/testcase.yaml b/tests/drivers/clock_control/clock_control_api/testcase.yaml index a21d217f2c0c..0e1a75bd690b 100644 --- a/tests/drivers/clock_control/clock_control_api/testcase.yaml +++ b/tests/drivers/clock_control/clock_control_api/testcase.yaml @@ -30,6 +30,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 @@ -44,6 +45,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 diff --git a/tests/drivers/clock_control/nrf_clock_calibration/testcase.yaml b/tests/drivers/clock_control/nrf_clock_calibration/testcase.yaml index 2fc0d85f0f4a..6515882b6e1b 100644 --- a/tests/drivers/clock_control/nrf_clock_calibration/testcase.yaml +++ b/tests/drivers/clock_control/nrf_clock_calibration/testcase.yaml @@ -13,6 +13,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/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 995d7825ccd8..a03ce7660cfd 100644 --- a/tests/drivers/clock_control/nrf_lf_clock_start/testcase.yaml +++ b/tests/drivers/clock_control/nrf_lf_clock_start/testcase.yaml @@ -19,6 +19,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp extra_configs: - CONFIG_SYSTEM_CLOCK_WAIT_FOR_STABILITY=y @@ -39,6 +40,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp extra_configs: - CONFIG_SYSTEM_CLOCK_WAIT_FOR_AVAILABILITY=y @@ -59,6 +61,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 @@ -78,6 +81,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 @@ -97,6 +101,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 @@ -116,6 +121,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 @@ -135,6 +141,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 @@ -154,6 +161,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 @@ -173,6 +181,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp integration_platforms: - nrf51dk/nrf51822 diff --git a/tests/drivers/clock_control/onoff/testcase.yaml b/tests/drivers/clock_control/onoff/testcase.yaml index 7497615623d3..e24fefe70cd9 100644 --- a/tests/drivers/clock_control/onoff/testcase.yaml +++ b/tests/drivers/clock_control/onoff/testcase.yaml @@ -14,6 +14,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - nrf9160dk/nrf9160 - ophelia4ev/nrf54l15/cpuapp integration_platforms: diff --git a/tests/drivers/comparator/gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay b/tests/drivers/comparator/gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay new file mode 100644 index 000000000000..e2649a103542 --- /dev/null +++ b/tests/drivers/comparator/gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120dk_nrf7120_cpuapp.overlay" diff --git a/tests/drivers/comparator/gpio_loopback/socs/nrf7120_cpuapp_ns_nrf_comp.overlay b/tests/drivers/comparator/gpio_loopback/socs/nrf7120_cpuapp_ns_nrf_comp.overlay new file mode 100644 index 000000000000..1b329bcdc6e4 --- /dev/null +++ b/tests/drivers/comparator/gpio_loopback/socs/nrf7120_cpuapp_ns_nrf_comp.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2025 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120_cpuapp_nrf_comp.overlay" diff --git a/tests/drivers/comparator/gpio_loopback/socs/nrf7120_cpuapp_ns_nrf_lpcomp.overlay b/tests/drivers/comparator/gpio_loopback/socs/nrf7120_cpuapp_ns_nrf_lpcomp.overlay new file mode 100644 index 000000000000..0c0be798eb1b --- /dev/null +++ b/tests/drivers/comparator/gpio_loopback/socs/nrf7120_cpuapp_ns_nrf_lpcomp.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120_cpuapp_nrf_lpcomp.overlay" diff --git a/tests/drivers/comparator/gpio_loopback/testcase.yaml b/tests/drivers/comparator/gpio_loopback/testcase.yaml index 5c3acb060075..a250523d0460 100644 --- a/tests/drivers/comparator/gpio_loopback/testcase.yaml +++ b/tests/drivers/comparator/gpio_loopback/testcase.yaml @@ -32,6 +32,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp drivers.comparator.gpio_loopback.nrf_lpcomp: extra_args: @@ -44,6 +45,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp drivers.comparator.gpio_loopback.stm32_comp: platform_allow: diff --git a/tests/drivers/disk/disk_access/src/main.c b/tests/drivers/disk/disk_access/src/main.c index fa891e946829..bca4dc991cb8 100644 --- a/tests/drivers/disk/disk_access/src/main.c +++ b/tests/drivers/disk/disk_access/src/main.c @@ -37,7 +37,9 @@ #error "No disk device defined, is your board supported?" #endif -#if CONFIG_SRAM_SIZE >= 512 +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + +#if RAM_SIZE >= 512 /* Cap buffer size at 128 KiB */ #define MAX_TOTAL_BUF_SIZE 128 #elif CONFIG_SOC_POSIX @@ -45,7 +47,7 @@ #define MAX_TOTAL_BUF_SIZE 128 #else /* Use half of all SRAM */ -#define MAX_TOTAL_BUF_SIZE (CONFIG_SRAM_SIZE / 2) +#define MAX_TOTAL_BUF_SIZE (RAM_SIZE / 2) #endif #define BUF_SIZE ((MAX_TOTAL_BUF_SIZE * 1024) / 2) diff --git a/tests/drivers/disk/disk_performance/src/main.c b/tests/drivers/disk/disk_performance/src/main.c index d10968535f6d..3e79e4186900 100644 --- a/tests/drivers/disk/disk_performance/src/main.c +++ b/tests/drivers/disk/disk_performance/src/main.c @@ -24,7 +24,9 @@ #error "No disk device defined, is your board supported?" #endif -#if CONFIG_SRAM_SIZE >= 512 +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + +#if RAM_SIZE >= 512 /* Cap buffer size at 128 KiB */ #define MAX_TOTAL_BUF_SIZE 128 #elif CONFIG_SOC_POSIX @@ -32,7 +34,7 @@ #define MAX_TOTAL_BUF_SIZE 128 #else /* Use half of all SRAM */ -#define MAX_TOTAL_BUF_SIZE (CONFIG_SRAM_SIZE / 2) +#define MAX_TOTAL_BUF_SIZE (RAM_SIZE / 2) #endif #define BUF_SIZE ((MAX_TOTAL_BUF_SIZE * 1024) / 2) diff --git a/tests/drivers/flash/common/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/flash/common/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index 5272bb8fdde3..7e2c58fc2b11 100644 --- a/tests/drivers/flash/common/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/drivers/flash/common/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -27,4 +27,5 @@ &mx25uw63 { status = "okay"; supply-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; + t-reset-recovery = <10000>; }; diff --git a/tests/drivers/flash/common/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay b/tests/drivers/flash/common/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay index 8a5afda2ab00..9d783d640f7a 100644 --- a/tests/drivers/flash/common/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay +++ b/tests/drivers/flash/common/boards/nrf54lm20dk_nrf54lm20a_cpuapp.overlay @@ -4,6 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ +/ { + zephyr,user { + test-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + }; +}; + &mx25r64 { status = "okay"; + supply-gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>; + t-reset-recovery = <10000>; }; diff --git a/tests/drivers/flash/common/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay b/tests/drivers/flash/common/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay index 3ab838329612..34983d6a4b5f 100644 --- a/tests/drivers/flash/common/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay +++ b/tests/drivers/flash/common/boards/nrf54lm20dk_nrf54lm20b_cpuapp.overlay @@ -4,6 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ +/ { + zephyr,user { + test-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + }; +}; + &mx25r64 { status = "okay"; + supply-gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>; + t-reset-recovery = <10000>; }; diff --git a/tests/drivers/flash/negative_tests/src/main.c b/tests/drivers/flash/negative_tests/src/main.c index 46a2d57eb067..311204253be5 100644 --- a/tests/drivers/flash/negative_tests/src/main.c +++ b/tests/drivers/flash/negative_tests/src/main.c @@ -29,9 +29,15 @@ #if defined(CONFIG_SOC_SERIES_NRF54L) || defined(CONFIG_SOC_FAMILY_MICROCHIP_SAM_D5X_E5X) #define TEST_FLASH_START (DT_REG_ADDR(DT_MEM_FROM_PARTITION(DT_NODELABEL(TEST_AREA)))) #define TEST_FLASH_SIZE (DT_REG_SIZE(DT_MEM_FROM_PARTITION(DT_NODELABEL(TEST_AREA)))) -#elif defined(CONFIG_SOC_NRF54H20) +#elif defined(CONFIG_SOC_NRF54H20) || defined(CONFIG_SOC_SERIES_NRF92) #define TEST_FLASH_START (DT_REG_ADDR(DT_PARENT(DT_PARENT(DT_NODELABEL(TEST_AREA))))) #define TEST_FLASH_SIZE (DT_REG_SIZE(DT_PARENT(DT_PARENT(DT_NODELABEL(TEST_AREA))))) +#elif defined(CONFIG_SOC_NRF7120) +#undef TEST_AREA_DEVICE +#define DEVICE_NODE DT_PARENT(DT_PARENT(DT_PARENT(DT_NODELABEL(TEST_AREA)))) +#define TEST_AREA_DEVICE (DEVICE_DT_GET(DEVICE_NODE)) +#define TEST_FLASH_START (DT_REG_ADDR(DT_MEM_FROM_PARTITION(DT_NODELABEL(TEST_AREA)))) +#define TEST_FLASH_SIZE (DT_REG_SIZE(DT_MEM_FROM_PARTITION(DT_NODELABEL(TEST_AREA)))) #elif defined(CONFIG_SOC_FAMILY_INFINEON_PSOC4) /* For PSoC4, storage_partition is a child of partitions, which is a child of flash0 */ /* We need to go up two levels: storage_partition -> partitions -> flash0 */ diff --git a/tests/drivers/flash/negative_tests/sysbuild.conf b/tests/drivers/flash/negative_tests/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/tests/drivers/flash/negative_tests/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/drivers/flash/negative_tests/testcase.yaml b/tests/drivers/flash/negative_tests/testcase.yaml index b6b4137c31a4..ac5517520ef5 100644 --- a/tests/drivers/flash/negative_tests/testcase.yaml +++ b/tests/drivers/flash/negative_tests/testcase.yaml @@ -10,4 +10,5 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - ophelia4ev/nrf54l15/cpuapp + - nrf7120dk/nrf7120/cpuapp - sam_e54_xpro diff --git a/tests/drivers/i2s/i2s_api/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay b/tests/drivers/i2s/i2s_api/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay new file mode 100644 index 000000000000..e2649a103542 --- /dev/null +++ b/tests/drivers/i2s/i2s_api/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120dk_nrf7120_cpuapp.overlay" diff --git a/tests/drivers/i2s/i2s_speed/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay b/tests/drivers/i2s/i2s_speed/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay new file mode 100644 index 000000000000..e2649a103542 --- /dev/null +++ b/tests/drivers/i2s/i2s_speed/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120dk_nrf7120_cpuapp.overlay" diff --git a/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpuapp.overlay index 6e0d84e07cdb..2e6b6cf5eacc 100644 --- a/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpuapp.overlay +++ b/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -8,6 +8,10 @@ aliases { mspi0 = &exmif; }; + + psa_rng: psa-rng { + status = "disabled"; + }; }; &gpio6 { diff --git a/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpurad.conf b/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 000000000000..a026df97a458 --- /dev/null +++ b/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1 @@ +CONFIG_PM=n diff --git a/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpurad.overlay new file mode 100644 index 000000000000..09b4edc100a4 --- /dev/null +++ b/tests/drivers/mspi/flash/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -0,0 +1,5 @@ +/ { + psa_rng: psa-rng { + status = "disabled"; + }; +}; diff --git a/tests/drivers/pwm/pwm_gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.conf b/tests/drivers/pwm/pwm_gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.conf new file mode 100644 index 000000000000..795414a504ab --- /dev/null +++ b/tests/drivers/pwm/pwm_gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.conf @@ -0,0 +1 @@ +CONFIG_SKIP_EDGE_NUM=4 diff --git a/tests/drivers/pwm/pwm_gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay b/tests/drivers/pwm/pwm_gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay new file mode 100644 index 000000000000..e2649a103542 --- /dev/null +++ b/tests/drivers/pwm/pwm_gpio_loopback/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120dk_nrf7120_cpuapp.overlay" diff --git a/tests/drivers/pwm/pwm_gpio_loopback/testcase.yaml b/tests/drivers/pwm/pwm_gpio_loopback/testcase.yaml index bf1b0533e5be..0c41f36ee1cc 100644 --- a/tests/drivers/pwm/pwm_gpio_loopback/testcase.yaml +++ b/tests/drivers/pwm/pwm_gpio_loopback/testcase.yaml @@ -41,6 +41,7 @@ tests: - nrf54lm20dk/nrf54lm20a/cpuapp - nrf54lm20dk/nrf54lm20b/cpuapp - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp drivers.pwm.gpio_loopback.silabs: diff --git a/tests/drivers/tee/optee/app.overlay b/tests/drivers/tee/optee/app.overlay new file mode 100644 index 000000000000..0a472c90132e --- /dev/null +++ b/tests/drivers/tee/optee/app.overlay @@ -0,0 +1,14 @@ +/ { + chosen { + zephyr,sram = &sram0; + }; +}; + +&soc { + sram0: memory@0 { + compatible = "mmio-sram"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x0 0x80000000>; + }; +}; diff --git a/tests/drivers/tee/optee/boards/native_sim_64.overlay b/tests/drivers/tee/optee/boards/native_sim_64.overlay index 65ceec3f5fb2..9276c56cfa53 100644 --- a/tests/drivers/tee/optee/boards/native_sim_64.overlay +++ b/tests/drivers/tee/optee/boards/native_sim_64.overlay @@ -10,4 +10,18 @@ status = "okay"; }; }; + + chosen { + zephyr,sram = &sram0; + }; + + soc { + #address-cells = <1>; + #size-cells = <2>; + + sram0: memory@0 { + compatible = "mmio-sram"; + reg = <0x0 0x20ffbe6 0xe4000000>; + }; + }; }; diff --git a/tests/drivers/tee/optee/prj.conf b/tests/drivers/tee/optee/prj.conf index 7550829f1dd3..6df8e7992066 100644 --- a/tests/drivers/tee/optee/prj.conf +++ b/tests/drivers/tee/optee/prj.conf @@ -3,4 +3,3 @@ CONFIG_BOOT_BANNER=n CONFIG_HEAP_MEM_POOL_SIZE=270044 CONFIG_TEE=y CONFIG_OPTEE=y -CONFIG_SRAM_SIZE=145131134582784 diff --git a/tests/drivers/timer/nrf_grtc_timer/testcase.yaml b/tests/drivers/timer/nrf_grtc_timer/testcase.yaml index ae6cee3a4563..178d30296ae5 100644 --- a/tests/drivers/timer/nrf_grtc_timer/testcase.yaml +++ b/tests/drivers/timer/nrf_grtc_timer/testcase.yaml @@ -14,6 +14,7 @@ common: - nrf54lm20dk/nrf54lm20b/cpuapp - nrf54lm20dk/nrf54lm20b/cpuflpr - nrf7120dk/nrf7120/cpuapp + - nrf7120dk/nrf7120/cpuapp/ns - ophelia4ev/nrf54l15/cpuapp - ophelia4ev/nrf54l15/cpuflpr integration_platforms: diff --git a/tests/drivers/uart/uart_async_api/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay b/tests/drivers/uart/uart_async_api/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay new file mode 100644 index 000000000000..e2649a103542 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/nrf7120dk_nrf7120_cpuapp_ns.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2026 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf7120dk_nrf7120_cpuapp.overlay" diff --git a/tests/drivers/uart/uart_mix_fifo_poll/prj.conf b/tests/drivers/uart/uart_mix_fifo_poll/prj.conf index fa22b3a47b89..13234ab13d9a 100644 --- a/tests/drivers/uart/uart_mix_fifo_poll/prj.conf +++ b/tests/drivers/uart/uart_mix_fifo_poll/prj.conf @@ -5,6 +5,7 @@ CONFIG_ZTEST_THREAD_PRIORITY=5 CONFIG_MAIN_STACK_SIZE=2048 CONFIG_ZTEST_STACK_SIZE=2048 CONFIG_TEST_RANDOM_GENERATOR=y +CONFIG_TIMER_RANDOM_GENERATOR=y CONFIG_COUNTER=y # CONFIG_NO_OPTIMIZATIONS=y diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf index 91a28adf437d..a66a33df93c7 100644 --- a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.conf @@ -3,4 +3,3 @@ CONFIG_BACKING_STORE_RAM=y CONFIG_BACKING_STORE_RAM_PAGES=24 -CONFIG_SRAM_SIZE=440 diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.overlay b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.overlay new file mode 100644 index 000000000000..3ba24b9fb01b --- /dev/null +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x0 0x40000000 0x0 0x72000>; +}; diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.conf b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.conf index 1ce923d0cbb9..bc16db15e462 100644 --- a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.conf +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.conf @@ -3,5 +3,4 @@ CONFIG_BACKING_STORE_RAM=y CONFIG_BACKING_STORE_RAM_PAGES=24 -CONFIG_SRAM_SIZE=560 CONFIG_DEMAND_PAGING_ALLOW_IRQ=y diff --git a/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.overlay b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.overlay new file mode 100644 index 000000000000..df9069553ee6 --- /dev/null +++ b/tests/kernel/mem_protect/demand_paging/mem_map/boards/qemu_cortex_a53_smp.overlay @@ -0,0 +1,3 @@ +&sram0 { + reg = <0x0 0x40000000 0x0 0x8c000>; +}; diff --git a/tests/kernel/pipe/deprecated/pipe_api/prj.conf b/tests/kernel/pipe/deprecated/pipe_api/prj.conf new file mode 100644 index 000000000000..df3270adfdf8 --- /dev/null +++ b/tests/kernel/pipe/deprecated/pipe_api/prj.conf @@ -0,0 +1,9 @@ +CONFIG_ZTEST=y +CONFIG_IRQ_OFFLOAD=y +CONFIG_TEST_USERSPACE=y +CONFIG_DYNAMIC_OBJECTS=y +CONFIG_MP_MAX_NUM_CPUS=1 +CONFIG_ZTEST_FATAL_HOOK=y +CONFIG_PIPES=y +CONFIG_DEPRECATION_TEST=y +CONFIG_MINIMAL_LIBC=y diff --git a/tests/kernel/sched/schedule_api/prj.conf b/tests/kernel/sched/schedule_api/prj.conf index a5ceef694331..8b649a3b7fca 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=6 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_multiq.conf b/tests/kernel/sched/schedule_api/prj_multiq.conf index c8dd4bf786bc..84c9d80ac619 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/kernel/sched/schedule_api/src/test_priority_scheduling.c b/tests/kernel/sched/schedule_api/src/test_priority_scheduling.c index 7d72b54c0d6f..e0aebf988e17 100644 --- a/tests/kernel/sched/schedule_api/src/test_priority_scheduling.c +++ b/tests/kernel/sched/schedule_api/src/test_priority_scheduling.c @@ -7,10 +7,12 @@ #include #include "test_sched.h" +#define RAM_SIZE (DT_CHOSEN_SRAM_SIZE / 1024) + /* nrf 51 has lower ram, so creating less number of threads */ -#if CONFIG_SRAM_SIZE <= 24 +#if RAM_SIZE <= 24 #define NUM_THREAD 2 -#elif (CONFIG_SRAM_SIZE <= 32) \ +#elif (RAM_SIZE <= 32) \ || defined(CONFIG_SOC_EMSK_EM7D) #define NUM_THREAD 3 #else diff --git a/tests/kernel/sched/schedule_api/src/test_slice_scheduling.c b/tests/kernel/sched/schedule_api/src/test_slice_scheduling.c index a65e7dcb3c7e..a301d07200b4 100644 --- a/tests/kernel/sched/schedule_api/src/test_slice_scheduling.c +++ b/tests/kernel/sched/schedule_api/src/test_slice_scheduling.c @@ -10,9 +10,9 @@ #ifdef CONFIG_TIMESLICING /* nrf 51 has lower ram, so creating less number of threads */ -#if CONFIG_SRAM_SIZE <= 24 +#if (DT_CHOSEN_SRAM_SIZE / 1024) <= 24 #define NUM_THREAD 2 -#elif (CONFIG_SRAM_SIZE <= 32) \ +#elif ((DT_CHOSEN_SRAM_SIZE / 1024) <= 32) \ || defined(CONFIG_SOC_EMSK_EM7D) #define NUM_THREAD 3 #else diff --git a/tests/kernel/timer/timer_behavior/Kconfig b/tests/kernel/timer/timer_behavior/Kconfig index 520354416762..cd4890c5d906 100644 --- a/tests/kernel/timer/timer_behavior/Kconfig +++ b/tests/kernel/timer/timer_behavior/Kconfig @@ -8,13 +8,20 @@ config SYS_CLOCK_TICKS_PER_SEC source "Kconfig.zephyr" +DT_CHOSEN_Z_SRAM = zephyr,sram + config TIMER_TEST_SAMPLES int "The number of timer samples to gather for statistics" - default 1000 if (SRAM_SIZE <= 24) - default 2000 if (SRAM_SIZE <= 32) - default 3000 if (SRAM_SIZE <= 48) - default 5000 if (SRAM_SIZE <= 64) - default 7000 if (SRAM_SIZE <= 96) + default 1000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 24) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 24) + default 2000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 32) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 32) + default 3000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 48) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 48) + default 5000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 64) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 64) + default 7000 if (SRAM_DEPRECATED_KCONFIG_SET && SRAM_SIZE <= 96) || \ + (!SRAM_DEPRECATED_KCONFIG_SET && $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_SRAM),0,K) <= 96) default 10000 config TIMER_TEST_PERIOD diff --git a/tests/lib/cpp/cxx/testcase.yaml b/tests/lib/cpp/cxx/testcase.yaml index 14a6d64becbf..c3998b7ad6b2 100644 --- a/tests/lib/cpp/cxx/testcase.yaml +++ b/tests/lib/cpp/cxx/testcase.yaml @@ -43,8 +43,9 @@ tests: filter: not CONFIG_HAS_RENESAS_RA_FSP and not CONFIG_HAS_RENESAS_RZ_FSP and not CONFIG_HAS_SILABS_WISECONNECT and not CONFIG_SOC_FAMILY_AMBIQ and - not (CONFIG_CPU_CORTEX_M and (CONFIG_NRF_PLATFORM_HALTIUM or - CONFIG_SOC_SERIES_NRF54L or CONFIG_SOC_SERIES_NRF71)) + not (CONFIG_CPU_CORTEX_M and (CONFIG_SOC_SERIES_NRF54H or + CONFIG_SOC_SERIES_NRF92 or CONFIG_SOC_SERIES_NRF54L or + CONFIG_SOC_SERIES_NRF71)) build_only: true extra_configs: - CONFIG_STD_CPP98=y diff --git a/tests/lib/heap/src/main.c b/tests/lib/heap/src/main.c index 8804fb13cea0..87b4e53d69b4 100644 --- a/tests/lib/heap/src/main.c +++ b/tests/lib/heap/src/main.c @@ -21,7 +21,7 @@ */ # define MEMSZ (192 * 1024) #elif defined(CONFIG_ARCH_POSIX) -/* POSIX arch based targets don't support CONFIG_SRAM_SIZE at all (because +/* POSIX arch based targets don't support DT_CHOSEN_SRAM_SIZE at all (because * they can link anything big enough to fit on the host), so just use a * reasonable value. */ @@ -33,9 +33,7 @@ */ # define MEMSZ (16 * 1024) #else -/* Otherwise just trust CONFIG_SRAM_SIZE - */ -# define MEMSZ (1024 * (size_t) CONFIG_SRAM_SIZE) +# define MEMSZ DT_CHOSEN_SRAM_SIZE #endif #define BIG_HEAP_SZ MIN(256 * 1024, MEMSZ / 3) 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/lib/uuid/testcase.yaml b/tests/lib/uuid/testcase.yaml index 9bd172c96ece..6565ba9f3b22 100644 --- a/tests/lib/uuid/testcase.yaml +++ b/tests/lib/uuid/testcase.yaml @@ -7,8 +7,7 @@ tests: libraries.uuid.base: extra_configs: - CONFIG_UUID_V5=y - - CONFIG_MBEDTLS=y - - CONFIG_MBEDTLS_PSA_CRYPTO_C=y + - CONFIG_PSA_CRYPTO=y - CONFIG_PSA_WANT_ALG_SHA_1=y - CONFIG_UUID_BASE64=y - CONFIG_BASE64=y diff --git a/tests/modules/tf-m/regression/CMakeLists.txt b/tests/modules/tf-m/regression/CMakeLists.txt new file mode 100644 index 000000000000..aacd56cb5fef --- /dev/null +++ b/tests/modules/tf-m/regression/CMakeLists.txt @@ -0,0 +1,302 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(tfm_regression_test) + +set(TFM_TEST_REG_TEST_PATH ${ZEPHYR_TF_M_TESTS_MODULE_DIR}/tests_reg/test) +set(TFM_TEST_LIB_PATH ${ZEPHYR_TF_M_TESTS_MODULE_DIR}/lib) +set(TFM_API_NS_PATH ${CMAKE_BINARY_DIR}/tfm/api_ns) + +# This is used to pass some extra build parameters to the TF-M build. +macro(add_tfm_build_params) + foreach(param ${ARGN}) + set_property(TARGET zephyr_property_target + APPEND PROPERTY TFM_CMAKE_OPTIONS + ${param} + ) + endforeach() +endmacro() + +macro(add_inc_and_src_if_def) + cmake_parse_arguments( + ARG + "" # options - none here + "KCONFIG" # one_value_keywords + "INC;SRC;GLOB_SRC" # multi_value_keywords + ${ARGN} + ) + + if(${ARG_KCONFIG}) + # Append include directories + target_include_directories(app PRIVATE ${ARG_INC}) + # Append source files + file(GLOB new_sources ${ARG_GLOB_SRC}) + list(APPEND new_sources ${ARG_SRC}) + target_sources(app PRIVATE ${new_sources}) + endif() +endmacro() + +message(STATUS "Enabled:") + +macro(def_if_def kconfig build_flag) + if(${kconfig}) + target_compile_definitions(app PRIVATE -D${build_flag}) + message(STATUS " ${build_flag}") + endif() +endmacro() + +add_tfm_build_params( + -DTEST_S=ON + -DTEST_NS=ON + -DTFM_S_REG_TEST=ON + -DTFM_NS_REG_TEST=ON + -DCONFIG_TFM_TEST_DIR="${ZEPHYR_TF_M_TESTS_MODULE_DIR}/tests_reg/test/secure_regression" + -DCONFIG_TFM_TEST_CONFIG_FILE="${ZEPHYR_TF_M_TESTS_MODULE_DIR}/tests_reg/test/config/config.cmake" +) + +target_sources(app PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/src/main.c +) + +add_inc_and_src_if_def( + KCONFIG + TRUE # Not a real Kconfig, because we always need the following + GLOB_SRC + ${TFM_TEST_REG_TEST_PATH}/secure_regression/*.c + ${TFM_TEST_REG_TEST_PATH}/ns_regression/*.c + ${TFM_TEST_REG_TEST_PATH}/framework/*.c + SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/common/suites/client_api_tests.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/common/suites/irq_test.c + INC + ${TFM_TEST_LIB_PATH}/log + ${TFM_TEST_LIB_PATH}/os_wrapper/ + ${TFM_TEST_REG_TEST_PATH}/ns_regression + ${TFM_TEST_REG_TEST_PATH}/secure_regression + ${TFM_TEST_REG_TEST_PATH}/framework + ${TFM_TEST_REG_TEST_PATH}/secure_fw/common_test_services/tfm_secure_client_2 + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/common/suites + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/common/service + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/common + ${TFM_API_NS_PATH}/platform/include + ${TFM_API_NS_PATH}/interface/include +) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_PARTITION_CRYPTO + INC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/crypto + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/crypto/non_secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/crypto/secure + GLOB_SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/crypto/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/crypto/non_secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/crypto/secure/*.c +) +def_if_def(CONFIG_TFM_PARTITION_CRYPTO TEST_NS_CRYPTO) +def_if_def(CONFIG_TFM_PARTITION_CRYPTO TEST_S_CRYPTO) +def_if_def(CONFIG_TFM_PARTITION_CRYPTO TFM_CRYPTO_TEST_UNSUPPORTED_ALG) +def_if_def(CONFIG_TFM_PARTITION_CRYPTO TFM_CRYPTO_TEST_SINGLE_PART_FUNCS) +def_if_def(CONFIG_PSA_WANT_ALG_CBC_NO_PADDING TFM_CRYPTO_TEST_ALG_CBC) +def_if_def(CONFIG_PSA_WANT_ALG_CCM TFM_CRYPTO_TEST_ALG_CCM) +def_if_def(CONFIG_PSA_WANT_ALG_CFB TFM_CRYPTO_TEST_ALG_CFB) +def_if_def(CONFIG_PSA_WANT_ALG_CFB TFM_CRYPTO_TEST_ALG_CFB) +def_if_def(CONFIG_PSA_WANT_ALG_ECB_NO_PADDING TFM_CRYPTO_TEST_ALG_ECB) +def_if_def(CONFIG_PSA_WANT_ALG_CTR TFM_CRYPTO_TEST_ALG_CTR) +def_if_def(CONFIG_PSA_WANT_ALG_OFB TFM_CRYPTO_TEST_ALG_OFB) +def_if_def(CONFIG_PSA_WANT_ALG_OFB TFM_CRYPTO_TEST_ALG_OFB) +def_if_def(CONFIG_PSA_WANT_ALG_GCM TFM_CRYPTO_TEST_ALG_GCM) +def_if_def(CONFIG_PSA_WANT_ALG_SHA_224 TFM_CRYPTO_TEST_ALG_SHA_224) +def_if_def(CONFIG_PSA_WANT_ALG_SHA_384 TFM_CRYPTO_TEST_ALG_SHA_384) +def_if_def(CONFIG_PSA_WANT_ALG_SHA_512 TFM_CRYPTO_TEST_ALG_SHA_512) +def_if_def(CONFIG_PSA_WANT_ALG_HKDF TFM_CRYPTO_TEST_HKDF) +def_if_def(CONFIG_PSA_WANT_ALG_ECDH TFM_CRYPTO_TEST_ECDH) +def_if_def(CONFIG_PSA_WANT_ALG_RSA_PSS TFM_CRYPTO_TEST_ALG_RSASSA_PSS_VERIFICATION) +def_if_def(CONFIG_PSA_WANT_KEY_TYPE_CHACHA20 TFM_CRYPTO_TEST_CHACHA20) +def_if_def(CONFIG_PSA_WANT_ALG_CHACHA20_POLY1305 TFM_CRYPTO_TEST_ALG_CHACHA20_POLY1305) +def_if_def(CONFIG_PSA_WANT_ALG_DETERMINISTIC_ECDSA TFM_CRYPTO_TEST_ALG_DETERMINISTIC_ECDSA) +def_if_def(CONFIG_PSA_WANT_ALG_ECDSA TFM_CRYPTO_TEST_ALG_ECDSA) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_PARTITION_PROTECTED_STORAGE + INC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/ps/non_secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/ps/secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/ps/secure/nv_counters + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/ps/service/ + ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/secure_fw/partitions/protected_storage + GLOB_SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/ps/non_secure/*.c + SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/ps/secure/psa_ps_s_interface_testsuite.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/ps/secure/psa_ps_s_reliability_testsuite.c +) +def_if_def(CONFIG_TFM_PARTITION_PROTECTED_STORAGE TEST_NS_PS) +def_if_def(CONFIG_TFM_PARTITION_PROTECTED_STORAGE TEST_S_PS) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_PS_ROLLBACK_PROTECTION + SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/ps/secure/ps_rollback_protection_testsuite.c +) +def_if_def(CONFIG_TFM_PS_ROLLBACK_PROTECTION PS_TEST_NV_COUNTERS) +def_if_def(CONFIG_TFM_PS_ROLLBACK_PROTECTION PLATFORM_DEFAULT_NV_COUNTERS) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE + INC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/its/non_secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/its/secure + GLOB_SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/its/non_secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/its/secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/its/*.c +) +def_if_def(CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE TEST_NS_ITS) +def_if_def(CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE TEST_S_ITS) +def_if_def(CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE TFM_PARTITION_INTERNAL_TRUSTED_STORAGE) +def_if_def(CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE TFM_INTERNAL_TRUSTED_STORAGE_SERVICE) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_PARTITION_PLATFORM + INC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/platform/non_secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/platform/secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/platform/ + GLOB_SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/platform/non_secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/platform/secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/platform/*.c +) +def_if_def(CONFIG_TFM_PARTITION_PLATFORM TEST_NS_PLATFORM) +def_if_def(CONFIG_TFM_PARTITION_PLATFORM TEST_S_PLATFORM) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_PARTITION_INITIAL_ATTESTATION + INC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation/non_secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation/secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation/ext/qcbor_util + ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/secure_fw/partitions/initial_attestation + ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/secure_fw/spm/include/boot + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/inc + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/inc + SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation/non_secure/attest_asymmetric_ns_interface_testsuite.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation/secure/attest_asymmetric_s_interface_testsuite.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation/attest_token_decode_asymmetric.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation/attest_token_decode_common.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/attestation/attest_token_test.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/ieee754.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/qcbor_decode.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/qcbor_encode.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/qcbor_err_to_str.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/UsefulBuf.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_encrypt_dec.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_encrypt_enc.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_key.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_mac_compute.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_mac_validate.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_parameters.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_qcbor_gap.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_recipient_dec_esdh.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_recipient_dec_keywrap.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_recipient_enc_esdh.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_recipient_enc_keywrap.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_sign1_sign.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_sign1_verify.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_sign_eddsa.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_sign_main.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_sign_restart.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_verify_eddsa.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_verify_main.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_sign_sign.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_sign_verify.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_util.c +) +set_source_files_properties( + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/ieee754.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/qcbor_decode.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/qcbor_encode.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/qcbor_err_to_str.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/qcbor-src/src/UsefulBuf.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_encrypt_dec.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_encrypt_enc.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_key.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_mac_compute.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_mac_validate.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_parameters.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_qcbor_gap.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_recipient_dec_esdh.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_recipient_dec_keywrap.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_recipient_enc_esdh.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_recipient_enc_keywrap.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_sign1_sign.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_sign1_verify.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_sign_eddsa.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_sign_main.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_sign_restart.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_verify_eddsa.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_signature_verify_main.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_sign_sign.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_sign_verify.c + ${CMAKE_BINARY_DIR}/tfm/lib/ext/t_cose-src/src/t_cose_util.c + PROPERTIES GENERATED TRUE +) +def_if_def(CONFIG_TFM_PARTITION_INITIAL_ATTESTATION TEST_NS_ATTESTATION) +def_if_def(CONFIG_TFM_PARTITION_INITIAL_ATTESTATION TEST_S_ATTESTATION) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_PARTITION_FIRMWARE_UPDATE + INC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/fwu/mcuboot/non_secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/fwu/mcuboot/secure + GLOB_SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/fwu/mcuboot/non_secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/fwu/mcuboot/secure/*.c +) +def_if_def(CONFIG_TFM_PARTITION_FIRMWARE_UPDATE TEST_NS_FWU) +def_if_def(CONFIG_TFM_PARTITION_FIRMWARE_UPDATE TEST_S_FWU) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_IPC + INC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/ipc/non_secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/ipc/secure + GLOB_SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/ipc/non_secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/ipc/secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/ipc/*.c +) +def_if_def(CONFIG_TFM_IPC TEST_NS_IPC) +def_if_def(CONFIG_TFM_IPC TEST_S_IPC) + +add_inc_and_src_if_def( + KCONFIG + CONFIG_TFM_SFN + INC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/sfn/non_secure + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/sfn/secure + GLOB_SRC + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/sfn/non_secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/sfn/secure/*.c + ${TFM_TEST_REG_TEST_PATH}/secure_fw/suites/spm/sfn/*.c +) +def_if_def(CONFIG_TFM_SFN TEST_NS_SFN_BACKEND) +def_if_def(CONFIG_TFM_SFN TEST_S_SFN_BACKEND) diff --git a/tests/modules/tf-m/regression/Kconfig b/tests/modules/tf-m/regression/Kconfig new file mode 100644 index 000000000000..ec7b991b864f --- /dev/null +++ b/tests/modules/tf-m/regression/Kconfig @@ -0,0 +1,169 @@ +# Copyright (c) 2026, BayLibre SAS +# SPDX-License-Identifier: Apache-2.0 + +config TFM_PROFILE_TYPE_NOT_SET + imply PSA_WANT_ALG_CBC_NO_PADDING + imply PSA_WANT_ALG_CBC_PKCS7 + imply PSA_WANT_ALG_CCM + imply PSA_WANT_ALG_CMAC + imply PSA_WANT_ALG_CFB + imply PSA_WANT_ALG_CTR + imply PSA_WANT_ALG_DETERMINISTIC_ECDSA + imply PSA_WANT_ALG_ECB_NO_PADDING + imply PSA_WANT_ALG_ECDH + imply PSA_WANT_ALG_ECDSA + imply PSA_WANT_ALG_GCM + imply PSA_WANT_ALG_HKDF + imply PSA_WANT_ALG_HMAC + imply PSA_WANT_ALG_OFB + imply PSA_WANT_ALG_PBKDF2_HMAC + imply PSA_WANT_ALG_RSA_OAEP + imply PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + imply PSA_WANT_ALG_RSA_PKCS1V15_SIGN + imply PSA_WANT_ALG_RSA_PSS + imply PSA_WANT_ALG_SHA_224 + imply PSA_WANT_ALG_SHA_256 + imply PSA_WANT_ALG_SHA_384 + imply PSA_WANT_ALG_SHA_512 + imply PSA_WANT_ALG_TLS12_PRF + imply PSA_WANT_ALG_TLS12_PSK_TO_MS + imply PSA_WANT_ECC_MONTGOMERY_255 + imply PSA_WANT_ECC_MONTGOMERY_448 + imply PSA_WANT_ECC_SECP_K1_256 + imply PSA_WANT_ECC_SECP_R1_256 + imply PSA_WANT_ECC_SECP_R1_384 + imply PSA_WANT_ECC_SECP_R1_521 + imply PSA_WANT_KEY_TYPE_DERIVE + imply PSA_WANT_KEY_TYPE_HMAC + imply PSA_WANT_KEY_TYPE_AES + imply PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + imply PSA_WANT_KEY_TYPE_RAW_DATA + imply PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE + imply PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC + imply PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT + imply PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT + imply PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE + help + Automatically select crypto features which are enabled in TF-M when + no profile is specified. These are taken from + "lib/ext/mbedcrypto/crypto_config_default.h". + + +config TFM_PROFILE_TYPE_SMALL + imply PSA_WANT_ALG_CCM + imply PSA_WANT_ALG_HMAC + imply PSA_WANT_ALG_SHA_224 + imply PSA_WANT_ALG_SHA_256 + imply PSA_WANT_ALG_TLS12_PRF + imply PSA_WANT_ALG_TLS12_PSK_TO_MS + imply PSA_WANT_KEY_TYPE_DERIVE + imply PSA_WANT_KEY_TYPE_HMAC + imply PSA_WANT_KEY_TYPE_AES + imply PSA_WANT_KEY_TYPE_RAW_DATA + help + Automatically select crypto features which are enabled in TF-M when + small profile is specified. These are taken from + "lib/ext/mbedcrypto/crypto_config_profile_small.h". + +config TFM_PROFILE_TYPE_MEDIUM + imply PSA_WANT_ALG_CCM + imply PSA_WANT_ALG_ECDH + imply PSA_WANT_ALG_ECDSA + imply PSA_WANT_ALG_HKDF + imply PSA_WANT_ALG_HMAC + imply PSA_WANT_ALG_SHA_224 + imply PSA_WANT_ALG_SHA_256 + imply PSA_WANT_ALG_TLS12_PRF + imply PSA_WANT_ALG_TLS12_PSK_TO_MS + imply PSA_WANT_ECC_SECP_R1_256 + imply PSA_WANT_KEY_TYPE_DERIVE + imply PSA_WANT_KEY_TYPE_HMAC + imply PSA_WANT_KEY_TYPE_AES + imply PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + imply PSA_WANT_KEY_TYPE_RAW_DATA + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE + help + Automatically select crypto features which are enabled in TF-M when + medium profile is specified. These are taken from + "lib/ext/mbedcrypto/crypto_config_profile_medium.h". + +config TFM_PROFILE_TYPE_AROTLESS + imply PSA_WANT_ALG_CCM + imply PSA_WANT_ALG_ECDH + imply PSA_WANT_ALG_ECDSA + imply PSA_WANT_ALG_HKDF + imply PSA_WANT_ALG_HMAC + imply PSA_WANT_ALG_SHA_224 + imply PSA_WANT_ALG_SHA_256 + imply PSA_WANT_ALG_TLS12_PRF + imply PSA_WANT_ALG_TLS12_PSK_TO_MS + imply PSA_WANT_ECC_SECP_R1_256 + imply PSA_WANT_KEY_TYPE_DERIVE + imply PSA_WANT_KEY_TYPE_HMAC + imply PSA_WANT_KEY_TYPE_AES + imply PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + imply PSA_WANT_KEY_TYPE_RAW_DATA + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE + help + Automatically select crypto features which are enabled in TF-M when + medium-arotless profile is specified. These are taken from + "lib/ext/mbedcrypto/crypto_config_profile_medium.h". + +config TFM_PROFILE_TYPE_LARGE + imply PSA_WANT_ALG_CBC_NO_PADDING + imply PSA_WANT_ALG_CBC_PKCS7 + imply PSA_WANT_ALG_CCM + imply PSA_WANT_ALG_CMAC + imply PSA_WANT_ALG_CFB + imply PSA_WANT_ALG_CTR + imply PSA_WANT_ALG_DETERMINISTIC_ECDSA + imply PSA_WANT_ALG_ECDH + imply PSA_WANT_ALG_ECDSA + imply PSA_WANT_ALG_GCM + imply PSA_WANT_ALG_HKDF + imply PSA_WANT_ALG_HMAC + imply PSA_WANT_ALG_PBKDF2_HMAC + imply PSA_WANT_ALG_RSA_OAEP + imply PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + imply PSA_WANT_ALG_RSA_PKCS1V15_SIGN + imply PSA_WANT_ALG_RSA_PSS + imply PSA_WANT_ALG_SHA_224 + imply PSA_WANT_ALG_SHA_256 + imply PSA_WANT_ALG_SHA_384 + imply PSA_WANT_ALG_SHA_512 + imply PSA_WANT_ALG_TLS12_PRF + imply PSA_WANT_ALG_TLS12_PSK_TO_MS + imply PSA_WANT_ECC_SECP_K1_256 + imply PSA_WANT_ECC_SECP_R1_256 + imply PSA_WANT_ECC_SECP_R1_384 + imply PSA_WANT_KEY_TYPE_DERIVE + imply PSA_WANT_KEY_TYPE_HMAC + imply PSA_WANT_KEY_TYPE_AES + imply PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY + imply PSA_WANT_KEY_TYPE_RAW_DATA + imply PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE + imply PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE + imply PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC + imply PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT + imply PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT + imply PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE + help + Automatically select crypto features which are enabled in TF-M when + large profile is specified. These are taken from + "lib/ext/mbedcrypto/crypto_config_profile_large.h". + +source "Kconfig.zephyr" diff --git a/samples/tfm_integration/tfm_regression_test/prj.conf b/tests/modules/tf-m/regression/prj.conf similarity index 53% rename from samples/tfm_integration/tfm_regression_test/prj.conf rename to tests/modules/tf-m/regression/prj.conf index 0a6573f811c7..01bd30057186 100644 --- a/samples/tfm_integration/tfm_regression_test/prj.conf +++ b/tests/modules/tf-m/regression/prj.conf @@ -4,19 +4,10 @@ # SPDX-License-Identifier: Apache-2.0 # -CONFIG_BUILD_WITH_TFM=y -CONFIG_TFM_PROFILE_TYPE_NOT_SET=y -CONFIG_TFM_USE_NS_APP=y -CONFIG_TFM_REGRESSION_S=y -CONFIG_TFM_REGRESSION_NS=y - # Regression tests are included if a related secure partition is enabled. CONFIG_TFM_PARTITION_PROTECTED_STORAGE=y CONFIG_TFM_PARTITION_INTERNAL_TRUSTED_STORAGE=y CONFIG_TFM_PARTITION_CRYPTO=y -CONFIG_TFM_PARTITION_INITIAL_ATTESTATION=n CONFIG_TFM_PARTITION_PLATFORM=y -# Enable IPC mode and isolation level 2 by default -CONFIG_TFM_IPC=y -CONFIG_TFM_ISOLATION_LEVEL=2 +CONFIG_MAIN_STACK_SIZE=2048 diff --git a/samples/tfm_integration/tfm_regression_test/src/main.c b/tests/modules/tf-m/regression/src/main.c similarity index 56% rename from samples/tfm_integration/tfm_regression_test/src/main.c rename to tests/modules/tf-m/regression/src/main.c index 7241cf79472f..7979f41f7bed 100644 --- a/samples/tfm_integration/tfm_regression_test/src/main.c +++ b/tests/modules/tf-m/regression/src/main.c @@ -5,12 +5,11 @@ */ #include +#include "non_secure_suites.h" int main(void) { - printk("Should not be printed, expected TF-M's NS application to be run instead.\n"); - k_panic(); + ns_reg_test_start(); - for (;;) { - } + return 0; } diff --git a/tests/modules/tf-m/regression/testcase.yaml b/tests/modules/tf-m/regression/testcase.yaml new file mode 100644 index 000000000000..4e0ce4ac1b4a --- /dev/null +++ b/tests/modules/tf-m/regression/testcase.yaml @@ -0,0 +1,47 @@ +common: + tags: + - trusted-firmware-m + - mcuboot + modules: + - tf-m-tests + filter: CONFIG_BUILD_WITH_TFM + integration_platforms: + - mps2/an521/cpu0/ns + harness: console + harness_config: + type: multi_line + ordered: true + regex: + # There's an ANSI escape code between has and PASSED: \x1b[32m (green color). The log file + # strips ANSI sequences, which is why it looks clean there. But harness.handle() receives + # the raw line with ANSI codes — so has PASSED never matches as a literal string. + - "Test suite 'PSA protected storage NS interface tests.*' has.*PASSED" + - "Test suite 'PSA internal trusted storage NS interface tests.*' has.*PASSED" + - "Test suite 'Crypto non-secure interface test.*' has.*PASSED" + - "Test suite 'Platform Service Non-Secure interface tests.*' has.*PASSED" + +tests: + tf-m.regression.ipc.lvl1: + extra_args: + - CONFIG_TFM_IPC=y + - CONFIG_TFM_ISOLATION_LEVEL=1 + timeout: 30 + + tf-m.regression.ipc.lvl2: + extra_args: + - CONFIG_TFM_IPC=y + - CONFIG_TFM_ISOLATION_LEVEL=2 + timeout: 30 + + tf-m.regression.sfn.profile.not_set: + extra_args: + - CONFIG_TFM_SFN=y + - CONFIG_TFM_ISOLATION_LEVEL=1 + timeout: 30 + + tf-m.regression.sfn.profile.small: + extra_args: + - CONFIG_TFM_SFN=y + - CONFIG_TFM_ISOLATION_LEVEL=1 + - CONFIG_TFM_PROFILE_TYPE_SMALL=y + timeout: 30 diff --git a/tests/net/dhcpv6/prj.conf b/tests/net/dhcpv6/prj.conf index 0c7e5c319eab..78a01aa5b295 100644 --- a/tests/net/dhcpv6/prj.conf +++ b/tests/net/dhcpv6/prj.conf @@ -15,3 +15,4 @@ CONFIG_NET_TC_TX_COUNT=1 CONFIG_NET_MGMT=y CONFIG_NET_MGMT_EVENT=y CONFIG_NET_MGMT_EVENT_INFO=y +CONFIG_NET_MGMT_EVENT_STACK_SIZE=1024 diff --git a/tests/net/ipv6/prj.conf b/tests/net/ipv6/prj.conf index 9f9f21d59050..6a6be5dba36a 100644 --- a/tests/net/ipv6/prj.conf +++ b/tests/net/ipv6/prj.conf @@ -33,6 +33,7 @@ CONFIG_NET_IF_MAX_IPV6_COUNT=2 CONFIG_NET_IPV6_PE=y CONFIG_NET_IPV6_PE_FILTER_PREFIX_COUNT=2 CONFIG_NET_IPV6_PE_PREFER_PUBLIC_ADDRESSES=n +CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y # Increase the stack a bit for mps2/an385 CONFIG_NET_RX_STACK_SIZE=1700 diff --git a/tests/net/lib/lwm2m/lwm2m_engine/CMakeLists.txt b/tests/net/lib/lwm2m/lwm2m_engine/CMakeLists.txt index 4643d758785e..42887cdd49c6 100644 --- a/tests/net/lib/lwm2m/lwm2m_engine/CMakeLists.txt +++ b/tests/net/lib/lwm2m/lwm2m_engine/CMakeLists.txt @@ -16,9 +16,7 @@ zephyr_linker_sources(SECTIONS ${ZEPHYR_BASE}/subsys/net/lib/lwm2m/iterables.ld) target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) target_include_directories(app PRIVATE ${ZEPHYR_BASE}/include/) target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/net/lib/lwm2m/) -target_include_directories(app PRIVATE ${ZEPHYR_MBEDTLS_MODULE_DIR}/include/) -target_include_directories(app PRIVATE ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/include/) -target_include_directories(app PRIVATE ${ZEPHYR_TF_PSA_CRYPTO_MODULE_DIR}/drivers/builtin/include/) +target_include_directories(app PRIVATE ${ZEPHYR_BASE}/../modules/crypto/mbedtls/include/) add_compile_definitions(CONFIG_LWM2M_ENGINE_MAX_PENDING=2) add_compile_definitions(CONFIG_LWM2M_ENGINE_MAX_REPLIES=2) diff --git a/tests/net/lib/wifi_credentials_backend_psa/CMakeLists.txt b/tests/net/lib/wifi_credentials_backend_psa/CMakeLists.txt index 605a076569c8..9403f8d6325b 100644 --- a/tests/net/lib/wifi_credentials_backend_psa/CMakeLists.txt +++ b/tests/net/lib/wifi_credentials_backend_psa/CMakeLists.txt @@ -20,7 +20,7 @@ target_sources(app zephyr_include_directories(${ZEPHYR_BASE}/subsys/testsuite/include) zephyr_include_directories(${ZEPHYR_BASE}/subsys/net/lib/wifi_credentials/) zephyr_include_directories(${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/interface/include/) -zephyr_include_directories(${ZEPHYR_MBEDTLS_3_6_MODULE_DIR}/include/) +zephyr_include_directories(${ZEPHYR_BASE}/../modules/crypto/mbedtls/include/) target_compile_options(app PRIVATE diff --git a/tests/net/socket/tls/prj.conf b/tests/net/socket/tls/prj.conf index 4b5a4a8d1a8d..9302ed1659e1 100644 --- a/tests/net/socket/tls/prj.conf +++ b/tests/net/socket/tls/prj.conf @@ -52,4 +52,9 @@ CONFIG_MBEDTLS_HEAP_SIZE=30000 CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID=y CONFIG_MBEDTLS_PSA_KEY_SLOT_COUNT=32 CONFIG_MBEDTLS_CIPHERSUITE_TLS_PSK_WITH_AES_256_CBC_SHA384=y -CONFIG_MBEDTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256=y + +# For tests verifying certificate validation +CONFIG_MBEDTLS_X509_CRT_PARSE_C=y +CONFIG_PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY=y +CONFIG_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT=y +CONFIG_PSA_WANT_ALG_RSA_PKCS1V15_SIGN=y diff --git a/tests/net/socket/tls/src/main.c b/tests/net/socket/tls/src/main.c index 5db92a18ff36..f8b04900974e 100644 --- a/tests/net/socket/tls/src/main.c +++ b/tests/net/socket/tls/src/main.c @@ -66,6 +66,9 @@ static void test_config_psk(int s_sock, int c_sock) sec_tag_t sec_tag_list[] = { PSK_TAG }; + const int cipher_list[] = { + MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384, + }; (void)tls_credential_delete(PSK_TAG, TLS_CREDENTIAL_PSK); (void)tls_credential_delete(PSK_TAG, TLS_CREDENTIAL_PSK_ID); @@ -81,12 +84,18 @@ static void test_config_psk(int s_sock, int c_sock) zassert_equal(zsock_setsockopt(s_sock, ZSOCK_SOL_TLS, ZSOCK_TLS_SEC_TAG_LIST, sec_tag_list, sizeof(sec_tag_list)), 0, "Failed to set PSK on server socket"); + zassert_equal(zsock_setsockopt(s_sock, ZSOCK_SOL_TLS, ZSOCK_TLS_CIPHERSUITE_LIST, + cipher_list, sizeof(cipher_list)), + 0, "Failed to set ciphersuite list on server socket"); } if (c_sock >= 0) { zassert_equal(zsock_setsockopt(c_sock, ZSOCK_SOL_TLS, ZSOCK_TLS_SEC_TAG_LIST, sec_tag_list, sizeof(sec_tag_list)), 0, "Failed to set PSK on client socket"); + zassert_equal(zsock_setsockopt(c_sock, ZSOCK_SOL_TLS, ZSOCK_TLS_CIPHERSUITE_LIST, + cipher_list, sizeof(cipher_list)), + 0, "Failed to set ciphersuite list on client socket"); } } diff --git a/tests/net/wifi/configs/testcase.yaml b/tests/net/wifi/configs/testcase.yaml index 271bcd41fdfa..5af448a39e12 100644 --- a/tests/net/wifi/configs/testcase.yaml +++ b/tests/net/wifi/configs/testcase.yaml @@ -37,7 +37,7 @@ tests: - CONFIG_EAP_AKA=y wifi.build.wpa3: extra_configs: - - CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3=y + - CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3_IMPLEMENTATION_INT=y - CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y wifi.build.ap: extra_configs: diff --git a/tests/subsys/fs/fcb/sysbuild.conf b/tests/subsys/fs/fcb/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/tests/subsys/fs/fcb/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/subsys/fs/fcb/testcase.yaml b/tests/subsys/fs/fcb/testcase.yaml index 8c318e8dde76..228ea7afb3c3 100644 --- a/tests/subsys/fs/fcb/testcase.yaml +++ b/tests/subsys/fs/fcb/testcase.yaml @@ -17,6 +17,7 @@ tests: platform_allow: - nrf54l15dk/nrf54l15/cpuapp - nrf54lm20dk/nrf54lm20a/cpuapp + - nrf54lm20dk/nrf54lm20b/cpuapp - ophelia4ev/nrf54l15/cpuapp - native_sim integration_platforms: diff --git a/tests/subsys/fs/littlefs/sysbuild.conf b/tests/subsys/fs/littlefs/sysbuild.conf new file mode 100644 index 000000000000..6408669a8474 --- /dev/null +++ b/tests/subsys/fs/littlefs/sysbuild.conf @@ -0,0 +1 @@ +SB_CONFIG_PARTITION_MANAGER=n diff --git a/tests/subsys/secure_storage/psa/its/testcase.yaml b/tests/subsys/secure_storage/psa/its/testcase.yaml index 217f113b31b5..ee7cafed08eb 100644 --- a/tests/subsys/secure_storage/psa/its/testcase.yaml +++ b/tests/subsys/secure_storage/psa/its/testcase.yaml @@ -33,6 +33,7 @@ tests: - EXTRA_DTC_OVERLAY_FILE=zms.overlay - EXTRA_CONF_FILE=\ overlay-secure_storage.conf;overlay-store_zms.conf;overlay-transform_default.conf + - SB_CONFIG_PARTITION_MANAGER=n secure_storage.psa.its.secure_storage.store.zms.64-bit_uids: platform_allow: *zms_platform_allow diff --git a/tests/subsys/settings/functional/tfm_psa/testcase.yaml b/tests/subsys/settings/functional/tfm_psa/testcase.yaml index eaed7cc4b8e5..9ff419860fad 100644 --- a/tests/subsys/settings/functional/tfm_psa/testcase.yaml +++ b/tests/subsys/settings/functional/tfm_psa/testcase.yaml @@ -4,6 +4,7 @@ common: - nrf5340dk/nrf5340/cpuapp/ns - nrf54l15dk/nrf54l15/cpuapp/ns - nrf54lm20dk/nrf54lm20a/cpuapp/ns + - nrf7120dk/nrf7120/cpuapp/ns - mps2/an521/cpu0/ns platform_exclude: - lpcxpresso55s69/lpc55s69/cpu0/ns diff --git a/west.yml b/west.yml index 4f5640818960..5176ec9311dd 100644 --- a/west.yml +++ b/west.yml @@ -203,7 +203,7 @@ manifest: groups: - hal - name: hal_nordic - revision: 44fd3d44b15cb75f80a25b4679f91d2787e28664 + revision: a820f00abfc2fe2f4d03ebdb3d185e21607e9006 path: modules/hal/nordic groups: - hal @@ -361,7 +361,7 @@ manifest: revision: 158b9710d6e10c57b2c623f8f4178f0bbc85c23f path: modules/bsim_hw_models/nrf_hw_models - name: nrf_wifi - revision: cebea8e27ceb91a7d4580d17db65f93669befe72 + revision: 47bd5b4ebd357ba637be0f2b092e1c0d370eea2f path: modules/lib/nrf_wifi - name: open-amp revision: 5efe7974f9546582e99f5a842a816ea4b65f5227