diff --git a/.github/workflows/bsim-tests.yaml b/.github/workflows/bsim-tests.yaml index 47c6aa86c27..4739f99e68b 100644 --- a/.github/workflows/bsim-tests.yaml +++ b/.github/workflows/bsim-tests.yaml @@ -37,7 +37,7 @@ jobs: runs-on: group: zephyr-runner-v2-linux-x64-4xlarge container: - image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.3.20241022 + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 options: '--entrypoint /bin/bash' env: ZEPHYR_TOOLCHAIN_VARIANT: zephyr diff --git a/.github/workflows/clang.yaml b/.github/workflows/clang.yaml index 8e1d51ca05e..4221babe2e5 100644 --- a/.github/workflows/clang.yaml +++ b/.github/workflows/clang.yaml @@ -12,7 +12,7 @@ jobs: runs-on: group: zephyr-runner-v2-linux-x64-4xlarge container: - image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.3.20241022 + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 options: '--entrypoint /bin/bash' strategy: fail-fast: false diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 834ec8505e3..56edb6a1e87 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -14,7 +14,7 @@ jobs: runs-on: group: zephyr-runner-v2-linux-x64-4xlarge container: - image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.3.20241022 + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 options: '--entrypoint /bin/bash' strategy: fail-fast: false diff --git a/.github/workflows/errno.yml b/.github/workflows/errno.yml index c70368ade30..d3fe1b0dcae 100644 --- a/.github/workflows/errno.yml +++ b/.github/workflows/errno.yml @@ -10,7 +10,7 @@ jobs: check-errno: runs-on: ubuntu-22.04 container: - image: ghcr.io/zephyrproject-rtos/ci:v0.27.3 + image: ghcr.io/zephyrproject-rtos/ci:v0.27.4 steps: - name: Apply container owner mismatch workaround diff --git a/.github/workflows/footprint-tracking.yml b/.github/workflows/footprint-tracking.yml index 694dc8166be..93eae63e954 100644 --- a/.github/workflows/footprint-tracking.yml +++ b/.github/workflows/footprint-tracking.yml @@ -26,7 +26,7 @@ jobs: group: zephyr-runner-v2-linux-x64-4xlarge if: github.repository_owner == 'zephyrproject-rtos' container: - image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.3.20241022 + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 options: '--entrypoint /bin/bash' defaults: run: diff --git a/.github/workflows/manifest.yml b/.github/workflows/manifest.yml index 76b80f66504..8da3e1d6109 100644 --- a/.github/workflows/manifest.yml +++ b/.github/workflows/manifest.yml @@ -26,7 +26,7 @@ jobs: west init -l . || true - name: Manifest - uses: zephyrproject-rtos/action-manifest@v1.3.1 + uses: zephyrproject-rtos/action-manifest@pull/14/head with: github-token: ${{ secrets.ZB_GITHUB_TOKEN }} manifest-path: 'west.yml' diff --git a/.github/workflows/twister.yaml b/.github/workflows/twister.yaml index 8f940ce11c6..f12cdeb2efa 100644 --- a/.github/workflows/twister.yaml +++ b/.github/workflows/twister.yaml @@ -25,7 +25,7 @@ jobs: runs-on: group: zephyr-runner-v2-linux-x64-4xlarge container: - image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.3.20241022 + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 options: '--entrypoint /bin/bash' outputs: subset: ${{ steps.output-services.outputs.subset }} @@ -130,7 +130,7 @@ jobs: needs: twister-build-prep if: needs.twister-build-prep.outputs.size != 0 container: - image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.3.20241022 + image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 options: '--entrypoint /bin/bash' strategy: fail-fast: false diff --git a/.github/workflows/twister_tests_blackbox.yml b/.github/workflows/twister_tests_blackbox.yml index 0e36630d092..f2f64e66a89 100644 --- a/.github/workflows/twister_tests_blackbox.yml +++ b/.github/workflows/twister_tests_blackbox.yml @@ -24,7 +24,7 @@ jobs: python-version: ['3.10', '3.11', '3.12', '3.13'] os: [ubuntu-22.04] container: - image: ghcr.io/zephyrproject-rtos/ci:v0.27.3 + image: ghcr.io/zephyrproject-rtos/ci:v0.27.4 steps: - name: Apply Container Owner Mismatch Workaround diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 425d79f4e74..f97819896d9 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -17,13 +17,13 @@ osource "${APPLICATION_SOURCE_DIR}/VERSION" # Shield defaults should have precedence over board defaults, which should have # precedence over SoC defaults, so include them in that order. # -# $ARCH and $BOARD_DIR will be glob patterns when building documentation. +# $ARCH and $KCONFIG_BOARD_DIR will be glob patterns when building documentation. # This loads custom shields defconfigs (from BOARD_ROOT) osource "$(KCONFIG_BINARY_DIR)/Kconfig.shield.defconfig" # This loads Zephyr base shield defconfigs source "boards/shields/*/Kconfig.defconfig" -osource "$(BOARD_DIR)/Kconfig.defconfig" +osource "$(KCONFIG_BOARD_DIR)/Kconfig.defconfig" # This loads Zephyr specific SoC root defconfigs source "$(KCONFIG_BINARY_DIR)/soc/Kconfig.defconfig" diff --git a/VERSION b/VERSION index 83bbbb1d942..1659ec4dbe2 100644 --- a/VERSION +++ b/VERSION @@ -1,5 +1,5 @@ -VERSION_MAJOR = 3 -VERSION_MINOR = 7 -PATCHLEVEL = 99 +VERSION_MAJOR = 4 +VERSION_MINOR = 0 +PATCHLEVEL = 0 VERSION_TWEAK = 0 -EXTRAVERSION = +EXTRAVERSION = rc1 diff --git a/boards/Kconfig b/boards/Kconfig index 6eb9ca5916d..8f186b32caf 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -129,7 +129,7 @@ config QEMU_EXTRA_FLAGS GDBstub over serial with `-serial tcp:127.0.0.1:5678,server` # There might not be any board options, hence the optional source -osource "$(BOARD_DIR)/Kconfig" +osource "$(KCONFIG_BOARD_DIR)/Kconfig" endmenu config BOARD_HAS_TIMING_FUNCTIONS diff --git a/boards/Kconfig.v1 b/boards/Kconfig.v1 index 670e2f2376e..c98bd27d2db 100644 --- a/boards/Kconfig.v1 +++ b/boards/Kconfig.v1 @@ -2,9 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 +# In HWMv1 the KCONFIG_BOARD_DIR points directly to the BOARD_DIR. +# Set the BOARD_DIR variable for backwards compatibility to legacy hardware model. +BOARD_DIR := $(KCONFIG_BOARD_DIR) + choice prompt "Board Selection" -source "$(BOARD_DIR)/Kconfig.board" +source "$(KCONFIG_BOARD_DIR)/Kconfig.board" endchoice diff --git a/boards/Kconfig.v2 b/boards/Kconfig.v2 index 47bb3ae2240..6fce9ccb99d 100644 --- a/boards/Kconfig.v2 +++ b/boards/Kconfig.v2 @@ -25,4 +25,4 @@ config BOARD_QUALIFIERS For example, if building for ``nrf5340dk/nrf5340/cpuapp`` then this will contain the value ``nrf5340/cpuapp``. -osource "$(BOARD_DIR)/Kconfig.$(BOARD)" +osource "$(KCONFIG_BOARD_DIR)/Kconfig.$(BOARD)" diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_0_8_0.dtsi b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_0_8_0.dtsi new file mode 100644 index 00000000000..940ac4d2391 --- /dev/null +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_0_8_0.dtsi @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/delete-node/ &suit_storage_partition; + +/ { + reserved-memory { + suit_storage_partition: memory@e1eb000 { + reg = <0xe1eb000 DT_SIZE_K(24)>; + }; + }; +}; diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_0_8_0.overlay b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_0_8_0.overlay new file mode 100644 index 00000000000..dfee18c5b6f --- /dev/null +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp_0_8_0.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf54h20dk_nrf54h20_0_8_0.dtsi" diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuflpr_0_8_0.overlay b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuflpr_0_8_0.overlay new file mode 100644 index 00000000000..dfee18c5b6f --- /dev/null +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuflpr_0_8_0.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf54h20dk_nrf54h20_0_8_0.dtsi" diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr_0_8_0.overlay b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr_0_8_0.overlay new file mode 100644 index 00000000000..dfee18c5b6f --- /dev/null +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuppr_0_8_0.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf54h20dk_nrf54h20_0_8_0.dtsi" diff --git a/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_0_8_0.overlay b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_0_8_0.overlay new file mode 100644 index 00000000000..dfee18c5b6f --- /dev/null +++ b/boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpurad_0_8_0.overlay @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "nrf54h20dk_nrf54h20_0_8_0.dtsi" diff --git a/boards/seeed/xiao_esp32s3/Kconfig b/boards/seeed/xiao_esp32s3/Kconfig index 9261164bb3f..361a4f5fc84 100644 --- a/boards/seeed/xiao_esp32s3/Kconfig +++ b/boards/seeed/xiao_esp32s3/Kconfig @@ -3,5 +3,5 @@ config HEAP_MEM_POOL_ADD_SIZE_BOARD int - default 4096 if BOARD_XIAO_ESP32S3_ESP32S3_PROCPU + default 4096 if BOARD_XIAO_ESP32S3_ESP32S3_PROCPU || BOARD_XIAO_ESP32S3_ESP32S3_PROCPU_SENSE default 256 if BOARD_XIAO_ESP32S3_ESP32S3_APPCPU diff --git a/boards/seeed/xiao_esp32s3/Kconfig.xiao_esp32s3 b/boards/seeed/xiao_esp32s3/Kconfig.xiao_esp32s3 index cbe07014750..212d510c344 100644 --- a/boards/seeed/xiao_esp32s3/Kconfig.xiao_esp32s3 +++ b/boards/seeed/xiao_esp32s3/Kconfig.xiao_esp32s3 @@ -5,5 +5,5 @@ config BOARD_XIAO_ESP32S3 select SOC_ESP32S3_WROOM_N8R8 - select SOC_ESP32S3_PROCPU if BOARD_XIAO_ESP32S3_ESP32S3_PROCPU + select SOC_ESP32S3_PROCPU if BOARD_XIAO_ESP32S3_ESP32S3_PROCPU || BOARD_XIAO_ESP32S3_ESP32S3_PROCPU_SENSE select SOC_ESP32S3_APPCPU if BOARD_XIAO_ESP32S3_ESP32S3_APPCPU diff --git a/boards/seeed/xiao_esp32s3/board.yml b/boards/seeed/xiao_esp32s3/board.yml index c3eb3a0204d..1d3c200f657 100644 --- a/boards/seeed/xiao_esp32s3/board.yml +++ b/boards/seeed/xiao_esp32s3/board.yml @@ -4,3 +4,6 @@ board: vendor: seeed socs: - name: esp32s3 + variants: + - name: 'sense' + cpucluster: 'procpu' diff --git a/boards/seeed/xiao_esp32s3/doc/img/xiao-esp32s3-sense.png b/boards/seeed/xiao_esp32s3/doc/img/xiao-esp32s3-sense.png new file mode 100644 index 00000000000..90e0824a13e Binary files /dev/null and b/boards/seeed/xiao_esp32s3/doc/img/xiao-esp32s3-sense.png differ diff --git a/boards/seeed/xiao_esp32s3/doc/index.rst b/boards/seeed/xiao_esp32s3/doc/index.rst index 0da45987f35..6ce906d3bde 100644 --- a/boards/seeed/xiao_esp32s3/doc/index.rst +++ b/boards/seeed/xiao_esp32s3/doc/index.rst @@ -1,13 +1,28 @@ -.. zephyr:board:: xiao_esp32s3 +.. _xiao_esp32s3: + +XIAO ESP32S3/XIAO ESP32S3 Sense +############################### Overview ******** -Seeed Studio XIAO ESP32S3 is an IoT mini development board based on the +Seeed Studio XIAO ESP32S3 and XIAO ESP32S3 Sense are IoT mini development boards based on the Espressif ESP32-S3 WiFi/Bluetooth dual-mode chip. For more details see the `Seeed Studio XIAO ESP32S3`_ wiki page. +.. figure:: img/xiao_esp32s3.jpg + :align: center + :alt: XIAO ESP32S3 + + XIAO ESP32S3 + +.. figure:: img/xiao-esp32s3-sense.png + :align: center + :alt: XIAO ESP32S3 Sense + + XIAO ESP32S3 Sense + Hardware ******** @@ -21,6 +36,8 @@ and Bluetooth® Low Energy (Bluetooth LE). It consists of high-performance dual- (Xtensa® 32-bit LX7), a low power coprocessor, a Wi-Fi baseband, a Bluetooth LE baseband, RF module, and numerous peripherals. +Additionally, Sense variant integrates a OV2640 camera sensor, microphone and sdcard slot. + Supported Features ================== @@ -57,6 +74,8 @@ Current Zephyr's XIAO ESP32S3 board supports the following features: +------------+------------+-------------------------------------+ | GDMA | on-chip | dma | +------------+------------+-------------------------------------+ +| LCD_CAM | on-chip | lcd_cam | ++------------+------------+-------------------------------------+ Connections and IOs =================== @@ -67,7 +86,7 @@ The board uses a standard XIAO pinout, the default pin mapping is the following: :align: center :alt: XIAO ESP32S3 Pinout - XIAO ESP32S3 Pinout + XIAO ESP32S3 and XIAO ESP32S3 Sense Pinout Prerequisites ------------- @@ -174,19 +193,41 @@ The only difference is the structure of the build directory. Build and flash applications as usual (see :ref:`build_an_application` and :ref:`application_run` for more details). -.. zephyr-app-commands:: - :zephyr-app: samples/hello_world - :board: xiao_esp32s3/esp32s3/procpu - :goals: build +.. tabs:: + + .. group-tab:: XIAO ESP32S3 + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: xiao_esp32s3/esp32/procpu + :goals: build + + .. group-tab:: XIAO ESP32S3 Sense + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: xiao_esp32s3/esp32/procpu/sense + :goals: build The usual ``flash`` target will work with the ``xiao_esp32s3`` board configuration. Here is an example for the :zephyr:code-sample:`hello_world` application. -.. zephyr-app-commands:: - :zephyr-app: samples/hello_world - :board: xiao_esp32s3/esp32s3/procpu - :goals: flash +.. tabs:: + + .. group-tab:: XIAO ESP32S3 + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: xiao_esp32s3/esp32/procpu + :goals: flash + + .. group-tab:: XIAO ESP32S3 Sense + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: xiao_esp32s3/esp32/procpu/sense + :goals: flash Open the serial monitor using the following command: @@ -213,17 +254,39 @@ Further documentation can be obtained from the SoC vendor in `JTAG debugging for Here is an example for building the :zephyr:code-sample:`hello_world` application. -.. zephyr-app-commands:: - :zephyr-app: samples/hello_world - :board: xiao_esp32s3/esp32/procpu - :goals: build flash +.. tabs:: + + .. group-tab:: XIAO ESP32S3 + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: xiao_esp32s3/esp32/procpu + :goals: debug + + .. group-tab:: XIAO ESP32S3 Sense + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: xiao_esp32s3/esp32/procpu/sense + :goals: debug You can debug an application in the usual way. Here is an example for the :zephyr:code-sample:`hello_world` application. -.. zephyr-app-commands:: - :zephyr-app: samples/hello_world - :board: xiao_esp32s3/esp32/procpu - :goals: debug +.. tabs:: + + .. group-tab:: XIAO ESP32S3 + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: xiao_esp32s3/esp32/procpu + :goals: debug + + .. group-tab:: XIAO ESP32S3 Sense + + .. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: xiao_esp32s3/esp32/procpu/sense + :goals: debug References ********** diff --git a/boards/seeed/xiao_esp32s3/xiao_esp32s3-pinctrl.dtsi b/boards/seeed/xiao_esp32s3/xiao_esp32s3-pinctrl.dtsi index 27097b6bb26..3159a39611b 100644 --- a/boards/seeed/xiao_esp32s3/xiao_esp32s3-pinctrl.dtsi +++ b/boards/seeed/xiao_esp32s3/xiao_esp32s3-pinctrl.dtsi @@ -41,6 +41,38 @@ }; }; + i2c1_default: i2c1_default { + group1 { + pinmux = , + ; + bias-pull-up; + drive-open-drain; + output-high; + }; + }; + + lcd_cam_default: lcd_cam_default { + group1 { + pinmux = ; + output-enable; + }; + group2 { + pinmux = , + , + , + , + , + , + , + , + , + , + ; + input-enable; + bias-disable; + }; + }; + twai_default: twai_default { group1 { pinmux = , diff --git a/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu.dts b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu.dts index 2c1349b735c..2a68af1ee18 100644 --- a/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu.dts +++ b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu.dts @@ -5,130 +5,9 @@ */ /dts-v1/; - -#include -#include "xiao_esp32s3-pinctrl.dtsi" -#include "seeed_xiao_connector.dtsi" +#include "xiao_esp32s3_procpu_common.dtsi" / { model = "Seeed Xiao ESP32S3 PROCPU"; compatible = "seeed,xiao-esp32s3"; - - chosen { - zephyr,sram = &sram0; - zephyr,console = &usb_serial; - zephyr,shell-uart = &usb_serial; - zephyr,flash = &flash0; - zephyr,code-partition = &slot0_partition; - zephyr,bt-hci = &esp32_bt_hci; - }; - - aliases { - i2c-0 = &i2c0; - watchdog0 = &wdt0; - led0 = &led0; - }; - - leds { - compatible = "gpio-leds"; - led0: led_0 { - gpios = <&gpio0 21 GPIO_ACTIVE_LOW>; - label = "BUILTIN LED"; - }; - }; - -}; - -&usb_serial { - status = "okay"; -}; - -&uart0 { - status = "okay"; - current-speed = <115200>; - pinctrl-0 = <&uart0_default>; - pinctrl-names = "default"; -}; - -&i2c0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_default>; - pinctrl-names = "default"; -}; - -&trng0 { - status = "okay"; -}; - -&spi2 { - #address-cells = <1>; - #size-cells = <0>; - status = "okay"; - pinctrl-0 = <&spim2_default>; - pinctrl-names = "default"; -}; - -&gpio0 { - status = "okay"; -}; - -&gpio1 { - status = "okay"; -}; - -&wdt0 { - status = "okay"; -}; - -&twai { - pinctrl-0 = <&twai_default>; - pinctrl-names = "default"; -}; - -&timer0 { - status = "okay"; -}; - -&timer1 { - status = "okay"; -}; - -&flash0 { - status = "okay"; - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - boot_partition: partition@0 { - label = "mcuboot"; - reg = <0x00000000 0x0000F000>; - read-only; - }; - - slot0_partition: partition@10000 { - label = "image-0"; - reg = <0x00010000 0x00100000>; - }; - - slot1_partition: partition@110000 { - label = "image-1"; - reg = <0x00110000 0x00100000>; - }; - - scratch_partition: partition@210000 { - label = "image-scratch"; - reg = <0x00210000 0x00040000>; - }; - - storage_partition: partition@250000 { - label = "storage"; - reg = <0x00250000 0x00006000>; - }; - }; -}; - -&esp32_bt_hci { - status = "okay"; }; diff --git a/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_common.dtsi b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_common.dtsi new file mode 100644 index 00000000000..8a99ef2c694 --- /dev/null +++ b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_common.dtsi @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2023 Seeed Studio inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include "xiao_esp32s3-pinctrl.dtsi" +#include "seeed_xiao_connector.dtsi" + +/ { + chosen { + zephyr,sram = &sram0; + zephyr,console = &usb_serial; + zephyr,shell-uart = &usb_serial; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + zephyr,bt-hci = &esp32_bt_hci; + }; + + aliases { + i2c-0 = &i2c0; + watchdog0 = &wdt0; + led0 = &led0; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 21 GPIO_ACTIVE_LOW>; + label = "BUILTIN LED"; + }; + }; + +}; + +&usb_serial { + status = "okay"; +}; + +&uart0 { + status = "okay"; + current-speed = <115200>; + pinctrl-0 = <&uart0_default>; + pinctrl-names = "default"; +}; + +&i2c0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_default>; + pinctrl-names = "default"; +}; + +&trng0 { + status = "okay"; +}; + +&spi2 { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + pinctrl-0 = <&spim2_default>; + pinctrl-names = "default"; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&wdt0 { + status = "okay"; +}; + +&twai { + pinctrl-0 = <&twai_default>; + pinctrl-names = "default"; +}; + +&timer0 { + status = "okay"; +}; + +&timer1 { + status = "okay"; +}; + +&flash0 { + status = "okay"; + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 0x0000F000>; + read-only; + }; + + slot0_partition: partition@10000 { + label = "image-0"; + reg = <0x00010000 0x00100000>; + }; + + slot1_partition: partition@110000 { + label = "image-1"; + reg = <0x00110000 0x00100000>; + }; + + scratch_partition: partition@210000 { + label = "image-scratch"; + reg = <0x00210000 0x00040000>; + }; + + storage_partition: partition@250000 { + label = "storage"; + reg = <0x00250000 0x00006000>; + }; + }; +}; + +&esp32_bt_hci { + status = "okay"; +}; diff --git a/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense.dts b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense.dts new file mode 100644 index 00000000000..1fc6f2560d7 --- /dev/null +++ b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense.dts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Seeed Studio inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include "xiao_esp32s3_procpu_common.dtsi" + +/ { + model = "Seeed Xiao ESP32S3 PROCPU Sense"; + compatible = "seeed,xiao-esp32s3"; + + chosen { + zephyr,camera = &lcd_cam; + }; +}; + +&i2c1 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_default>; + pinctrl-names = "default"; + + ov2640: ov2640@30 { + compatible = "ovti,ov2640"; + reg = <0x30>; + status = "okay"; + clock-rate-control = <0x80>; + port { + ov2640_ep_out: endpoint { + remote-endpoint-label = "dvp_ep_in"; + }; + }; + }; +}; + +&dma { + status = "okay"; +}; + +&lcd_cam { + status = "okay"; + cam-clk = <10000000>; + pinctrl-0 = <&lcd_cam_default>; + pinctrl-names = "default"; + source = <&ov2640>; + dmas = <&dma 2>; + dma-names = "rx"; + port { + dvp_ep_in: endpoint { + remote-endpoint-label = "ov2640_ep_out"; + }; + }; +}; + +&spi2 { + status = "okay"; + cs-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>; + + sdcard: sdcard@0 { + compatible = "zephyr,sdhc-spi-slot"; + reg = <0>; + status = "okay"; + mmc { + compatible = "zephyr,sdmmc-disk"; + status = "okay"; + }; + spi-max-frequency = <20000000>; + }; +}; diff --git a/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense.yaml b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense.yaml new file mode 100644 index 00000000000..91521bcd7d6 --- /dev/null +++ b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense.yaml @@ -0,0 +1,22 @@ +identifier: xiao_esp32s3/esp32s3/procpu/sense +name: XIAO ESP32S3 Sense PROCPU +type: mcu +arch: xtensa +toolchain: + - zephyr +supported: + - gpio + - uart + - i2c + - spi + - can + - counter + - watchdog + - entropy + - pwm + - dma +testing: + ignore_tags: + - net + - bluetooth +vendor: seeed diff --git a/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense_defconfig b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense_defconfig new file mode 100644 index 00000000000..6539bd42e59 --- /dev/null +++ b/boards/seeed/xiao_esp32s3/xiao_esp32s3_procpu_sense_defconfig @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_UART_CONSOLE=y +CONFIG_GPIO=y diff --git a/boards/st/nucleo_wb05kz/nucleo_wb05kz.yaml b/boards/st/nucleo_wb05kz/nucleo_wb05kz.yaml index 8070d9ece04..bf602772d9d 100644 --- a/boards/st/nucleo_wb05kz/nucleo_wb05kz.yaml +++ b/boards/st/nucleo_wb05kz/nucleo_wb05kz.yaml @@ -9,6 +9,7 @@ toolchain: ram: 24 flash: 192 supported: + - adc - arduino_i2c - arduino_spi - dma diff --git a/boards/st/nucleo_wb09ke/nucleo_wb09ke.yaml b/boards/st/nucleo_wb09ke/nucleo_wb09ke.yaml index 922f199851d..a853e0e1d7f 100644 --- a/boards/st/nucleo_wb09ke/nucleo_wb09ke.yaml +++ b/boards/st/nucleo_wb09ke/nucleo_wb09ke.yaml @@ -9,6 +9,7 @@ toolchain: ram: 64 flash: 512 supported: + - adc - arduino_i2c - arduino_spi - dma diff --git a/cmake/modules/boards.cmake b/cmake/modules/boards.cmake index a1b05b07b57..2b78845482a 100644 --- a/cmake/modules/boards.cmake +++ b/cmake/modules/boards.cmake @@ -185,9 +185,7 @@ set(format_str "{NAME}\;{DIR}\;{HWM}\;") set(format_str "${format_str}{REVISION_FORMAT}\;{REVISION_DEFAULT}\;{REVISION_EXACT}\;") set(format_str "${format_str}{REVISIONS}\;{SOCS}\;{QUALIFIERS}") -if(BOARD_DIR) - set(board_dir_arg "--board-dir=${BOARD_DIR}") -endif() +list(TRANSFORM BOARD_DIRECTORIES PREPEND "--board-dir=" OUTPUT_VARIABLE board_dir_arg) execute_process(${list_boards_commands} --board=${BOARD} ${board_dir_arg} --cmakeformat=${format_str} OUTPUT_VARIABLE ret_board @@ -200,29 +198,15 @@ endif() if(NOT "${ret_board}" STREQUAL "") string(STRIP "${ret_board}" ret_board) - string(FIND "${ret_board}" "\n" idx REVERSE) - if(idx GREATER -1) - while(TRUE) - math(EXPR start "${idx} + 1") - string(SUBSTRING "${ret_board}" ${start} -1 line) - string(SUBSTRING "${ret_board}" 0 ${idx} ret_board) - - cmake_parse_arguments(LIST_BOARD "" "DIR" "" ${line}) - set(board_dirs "${board_dirs}\n${LIST_BOARD_DIR}") - - if(idx EQUAL -1) - break() - endif() - string(FIND "${ret_board}" "\n" idx REVERSE) - endwhile() - message(FATAL_ERROR "Multiple boards named '${BOARD}' found in:${board_dirs}") - endif() - - set(single_val "NAME;DIR;HWM;REVISION_FORMAT;REVISION_DEFAULT;REVISION_EXACT") - set(multi_val "REVISIONS;SOCS;QUALIFIERS") + set(single_val "NAME;HWM;REVISION_FORMAT;REVISION_DEFAULT;REVISION_EXACT") + set(multi_val "DIR;REVISIONS;SOCS;QUALIFIERS") cmake_parse_arguments(LIST_BOARD "" "${single_val}" "${multi_val}" ${ret_board}) - set(BOARD_DIR ${LIST_BOARD_DIR} CACHE PATH "Board directory for board (${BOARD})" FORCE) - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${BOARD_DIR}/board.yml) + list(GET LIST_BOARD_DIR 0 BOARD_DIR) + set(BOARD_DIR ${BOARD_DIR} CACHE PATH "Main board directory for board (${BOARD})" FORCE) + set(BOARD_DIRECTORIES ${LIST_BOARD_DIR} CACHE INTERNAL "List of board directories for board (${BOARD})" FORCE) + foreach(dir ${BOARD_DIRECTORIES}) + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/board.yml) + endforeach() # Create two CMake variables identifying the hw model. # CMake variable: HWM=[v1,v2] diff --git a/cmake/modules/dts.cmake b/cmake/modules/dts.cmake index 16b497d5737..a2c56577cfa 100644 --- a/cmake/modules/dts.cmake +++ b/cmake/modules/dts.cmake @@ -76,9 +76,9 @@ find_package(Dtc 1.4.6) # # Optional variables: # - BOARD: board name to use when looking for DTS_SOURCE -# - BOARD_DIR: board directory to use when looking for DTS_SOURCE +# - BOARD_DIRECTORIES: list of board directories to use when looking for DTS_SOURCE # - BOARD_REVISION_STRING: used when looking for a board revision's -# devicetree overlay file in BOARD_DIR +# devicetree overlay file in one of the BOARD_DIRECTORIES # - CMAKE_DTS_PREPROCESSOR: the path to the preprocessor to use # for devicetree files # - DTC_OVERLAY_FILE: list of devicetree overlay files which will be @@ -94,7 +94,7 @@ find_package(Dtc 1.4.6) # C preprocessor when generating the devicetree from DTS_SOURCE # - DTS_SOURCE: the devicetree source file to use may be pre-set # with this variable; otherwise, it defaults to -# ${BOARD_DIR}/${BOARD}.dts +# ${BOARD_DIRECTORIES}/.dts # # Variables set by this module and not mentioned above are for internal # use only, and may be removed, renamed, or re-purposed without prior notice. @@ -137,28 +137,30 @@ if(NOT DEFINED DTS_SOURCE) zephyr_build_string(board_string SHORT shortened_board_string BOARD ${BOARD} BOARD_QUALIFIERS ${BOARD_QUALIFIERS} ) - if(EXISTS ${BOARD_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 ${BOARD_DIR}/${board_string}.dts AND EXISTS ${BOARD_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 ${BOARD_DIR}/${board_string}.dts) - set(DTS_SOURCE ${BOARD_DIR}/${board_string}.dts) - elseif(EXISTS ${BOARD_DIR}/${shortened_board_string}.dts) - set(DTS_SOURCE ${BOARD_DIR}/${shortened_board_string}.dts) - endif() + 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() if(EXISTS ${DTS_SOURCE}) # We found a devicetree. Append all relevant dts overlays we can find... - zephyr_file(CONF_FILES ${BOARD_DIR} DTS DTS_SOURCE) + zephyr_file(CONF_FILES ${BOARD_DIRECTORIES} DTS DTS_SOURCE) zephyr_file( - CONF_FILES ${BOARD_DIR} + CONF_FILES ${BOARD_DIRECTORIES} DTS no_rev_suffix_dts_board_overlays BOARD ${BOARD} BOARD_QUALIFIERS ${BOARD_QUALIFIERS} diff --git a/cmake/modules/hwm_v2.cmake b/cmake/modules/hwm_v2.cmake index 45238f212b3..a440c95c832 100644 --- a/cmake/modules/hwm_v2.cmake +++ b/cmake/modules/hwm_v2.cmake @@ -24,9 +24,11 @@ if(NOT HWMv2) endif() # Internal helper function for creation of Kconfig files. -function(kconfig_gen bin_dir file dirs) - file(MAKE_DIRECTORY "${bin_dir}") - set(kconfig_file ${bin_dir}/${file}) +function(kconfig_gen bin_dir file dirs comment) + set(kconfig_header "# Load ${comment} descriptions.\n") + set(kconfig_file ${KCONFIG_BINARY_DIR}/${bin_dir}/${file}) + file(WRITE ${kconfig_file} "${kconfig_header}") + foreach(dir ${dirs}) cmake_path(CONVERT "${dir}" TO_CMAKE_PATH_LIST dir) file(APPEND ${kconfig_file} "osource \"${dir}/${file}\"\n") @@ -71,19 +73,23 @@ while(TRUE) string(TOUPPER "${ARCH_V2_NAME}" ARCH_V2_NAME_UPPER) set(ARCH_V2_${ARCH_V2_NAME_UPPER}_DIR ${ARCH_V2_DIR}) elseif(HWM_TYPE MATCHES "^soc|^series|^family") - cmake_parse_arguments(SOC_V2 "" "NAME;DIR;HWM" "" ${line}) + cmake_parse_arguments(SOC_V2 "" "NAME;HWM" "DIR" ${line}) list(APPEND kconfig_soc_source_dir "${SOC_V2_DIR}") + string(TOUPPER "${SOC_V2_NAME}" SOC_V2_NAME_UPPER) + string(TOUPPER "${HWM_TYPE}" HWM_TYPE_UPPER) if(HWM_TYPE STREQUAL "soc") - set(setting_name SOC_${SOC_V2_NAME}_DIR) + # We support both SOC_foo_DIR and SOC_FOO_DIR. + set(SOC_${SOC_V2_NAME}_DIRECTORIES ${SOC_V2_DIR}) + set(SOC_${SOC_V2_NAME_UPPER}_DIRECTORIES ${SOC_V2_DIR}) + list(GET SOC_V2_DIR 0 SOC_${SOC_V2_NAME}_DIR) + list(GET SOC_V2_DIR 0 SOC_${SOC_V2_NAME_UPPER}_DIR) else() - set(setting_name SOC_${HWM_TYPE}_${SOC_V2_NAME}_DIR) + # We support both SOC_series_foo_DIR and SOC_SERIES_FOO_DIR (and family / FAMILY). + set(SOC_${HWM_TYPE}_${SOC_V2_NAME}_DIR ${SOC_V2_DIR}) + set(SOC_${HWM_TYPE_UPPER}_${SOC_V2_NAME_UPPER}_DIR ${SOC_V2_DIR}) endif() - # We support both SOC_foo_DIR and SOC_FOO_DIR. - set(${setting_name} ${SOC_V2_DIR}) - string(TOUPPER ${setting_name} setting_name) - set(${setting_name} ${SOC_V2_DIR}) endif() if(idx EQUAL -1) @@ -92,28 +98,16 @@ while(TRUE) endwhile() list(REMOVE_DUPLICATES kconfig_soc_source_dir) -# Support multiple ARCH_ROOT and SOC_ROOT -set(arch_kconfig_file Kconfig) -set(soc_defconfig_file Kconfig.defconfig) -set(soc_zephyr_file Kconfig) -set(soc_kconfig_file Kconfig.soc) -set(soc_sysbuild_file Kconfig.sysbuild) -set(arch_kconfig_header "# Load arch Kconfig descriptions.\n") -set(defconfig_header "# Load Zephyr SoC Kconfig defconfig.\n") -set(soc_zephyr_header "# Load Zephyr SoC Kconfig descriptions.\n") -set(soc_kconfig_header "# Load SoC Kconfig descriptions.\n") -set(soc_sysbuild_header "# Load SoC sysbuild Kconfig descriptions.\n") -file(WRITE ${KCONFIG_BINARY_DIR}/arch/${arch_kconfig_file} "${arch_kconfig_header}") -file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_defconfig_file} "${defconfig_header}") -file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_zephyr_file} "${soc_zephyr_header}") -file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_kconfig_file} "${soc_kconfig_header}") -file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_sysbuild_file} "${soc_sysbuild_header}") - -kconfig_gen("${KCONFIG_BINARY_DIR}/arch" "${arch_kconfig_file}" "${kconfig_arch_source_dir}") -kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_defconfig_file}" "${kconfig_soc_source_dir}") -kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_zephyr_file}" "${kconfig_soc_source_dir}") -kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_kconfig_file}" "${kconfig_soc_source_dir}") -kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_sysbuild_file}" "${kconfig_soc_source_dir}") +# Support multiple ARCH_ROOT, SOC_ROOT and BOARD_ROOT +kconfig_gen("arch" "Kconfig" "${kconfig_arch_source_dir}" "Zephyr Arch Kconfig") +kconfig_gen("soc" "Kconfig.defconfig" "${kconfig_soc_source_dir}" "Zephyr SoC defconfig") +kconfig_gen("soc" "Kconfig" "${kconfig_soc_source_dir}" "Zephyr SoC Kconfig") +kconfig_gen("soc" "Kconfig.soc" "${kconfig_soc_source_dir}" "SoC Kconfig") +kconfig_gen("soc" "Kconfig.sysbuild" "${kconfig_soc_source_dir}" "Sysbuild SoC Kconfig") +kconfig_gen("boards" "Kconfig.defconfig" "${BOARD_DIRECTORIES}" "Zephyr board defconfig") +kconfig_gen("boards" "Kconfig.${BOARD}" "${BOARD_DIRECTORIES}" "board Kconfig") +kconfig_gen("boards" "Kconfig" "${BOARD_DIRECTORIES}" "Zephyr board Kconfig") +kconfig_gen("boards" "Kconfig.sysbuild" "${BOARD_DIRECTORIES}" "Sysbuild board Kconfig") # Clear variables created by cmake_parse_arguments unset(SOC_V2_NAME) diff --git a/cmake/modules/kconfig.cmake b/cmake/modules/kconfig.cmake index 0273d39bf85..02bebbe0851 100644 --- a/cmake/modules/kconfig.cmake +++ b/cmake/modules/kconfig.cmake @@ -21,9 +21,12 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/kconfig/include/config) set_ifndef(KCONFIG_NAMESPACE "CONFIG") set_ifndef(KCONFIG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Kconfig) +set(KCONFIG_BOARD_DIR ${KCONFIG_BINARY_DIR}/boards) file(MAKE_DIRECTORY ${KCONFIG_BINARY_DIR}) if(HWMv1) + # HWMv1 only supoorts a single board dir which points directly to the board dir. + set(KCONFIG_BOARD_DIR ${BOARD_DIR}) # Support multiple SOC_ROOT file(MAKE_DIRECTORY ${KCONFIG_BINARY_DIR}/soc) set(kconfig_soc_root ${SOC_ROOT}) @@ -73,7 +76,7 @@ else() endif() if(NOT DEFINED BOARD_DEFCONFIG) - zephyr_file(CONF_FILES ${BOARD_DIR} DEFCONFIG BOARD_DEFCONFIG) + zephyr_file(CONF_FILES ${BOARD_DIRECTORIES} DEFCONFIG BOARD_DEFCONFIG) endif() if(DEFINED BOARD_REVISION) @@ -157,7 +160,7 @@ set(COMMON_KCONFIG_ENV_SETTINGS APP_VERSION_TWEAK_STRING=${APP_VERSION_TWEAK_STRING} CONFIG_=${KCONFIG_NAMESPACE}_ KCONFIG_CONFIG=${DOTCONFIG} - BOARD_DIR=${BOARD_DIR} + KCONFIG_BOARD_DIR=${KCONFIG_BOARD_DIR} BOARD=${BOARD} BOARD_REVISION=${BOARD_REVISION} BOARD_QUALIFIERS=${BOARD_QUALIFIERS} diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index 1946e2357ba..6a1a48b172d 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -173,7 +173,9 @@ if(CONFIG_LLEXT AND CONFIG_LLEXT_TYPE_ELF_SHAREDLIB) set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) endif() -include(${BOARD_DIR}/board.cmake OPTIONAL) +foreach(dir ${BOARD_DIRECTORIES}) + include(${dir}/board.cmake OPTIONAL) +endforeach() # If we are using a suitable ethernet driver inside qemu, then these options # must be set, otherwise a zephyr instance cannot receive any network packets. diff --git a/cmake/modules/soc_v2.cmake b/cmake/modules/soc_v2.cmake index 606ed690f77..f98d33e0011 100644 --- a/cmake/modules/soc_v2.cmake +++ b/cmake/modules/soc_v2.cmake @@ -28,5 +28,10 @@ if(HWMv2) set(SOC_FAMILY ${CONFIG_SOC_FAMILY}) set(SOC_V2_DIR ${SOC_${SOC_NAME}_DIR}) set(SOC_FULL_DIR ${SOC_V2_DIR} CACHE PATH "Path to the SoC directory." FORCE) - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${SOC_V2_DIR}/soc.yml) + set(SOC_DIRECTORIES ${SOC_${SOC_NAME}_DIRECTORIES} CACHE INTERNAL + "List of SoC directories for SoC (${SOC_NAME})" FORCE + ) + foreach(dir ${SOC_DIRECTORIES}) + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${dir}/soc.yml) + endforeach() endif() diff --git a/doc/_extensions/zephyr/kconfig/__init__.py b/doc/_extensions/zephyr/kconfig/__init__.py index 6052db638fa..905376d8168 100644 --- a/doc/_extensions/zephyr/kconfig/__init__.py +++ b/doc/_extensions/zephyr/kconfig/__init__.py @@ -91,7 +91,7 @@ def kconfig_load(app: Sphinx) -> Tuple[kconfiglib.Kconfig, Dict[str, str]]: root_args = argparse.Namespace(**{'soc_roots': [Path(ZEPHYR_BASE)]}) v2_systems = list_hardware.find_v2_systems(root_args) - soc_folders = {soc.folder for soc in v2_systems.get_socs()} + soc_folders = {soc.folder[0] for soc in v2_systems.get_socs()} with open(Path(td) / "soc" / "Kconfig.defconfig", "w") as f: f.write('') @@ -114,8 +114,9 @@ def kconfig_load(app: Sphinx) -> Tuple[kconfiglib.Kconfig, Dict[str, str]]: (Path(td) / 'boards').mkdir(exist_ok=True) root_args = argparse.Namespace(**{'board_roots': [Path(ZEPHYR_BASE)], - 'soc_roots': [Path(ZEPHYR_BASE)], 'board': None}) - v2_boards = list_boards.find_v2_boards(root_args) + 'soc_roots': [Path(ZEPHYR_BASE)], 'board': None, + 'board_dir': []}) + v2_boards = list_boards.find_v2_boards(root_args).values() with open(Path(td) / "boards" / "Kconfig.boards", "w") as f: for board in v2_boards: @@ -140,7 +141,7 @@ def kconfig_load(app: Sphinx) -> Tuple[kconfiglib.Kconfig, Dict[str, str]]: os.environ["HWM_SCHEME"] = "v2" os.environ["BOARD"] = "boards" - os.environ["BOARD_DIR"] = str(Path(td) / "boards") + os.environ["KCONFIG_BOARD_DIR"] = str(Path(td) / "boards") # insert external Kconfigs to the environment module_paths = dict() diff --git a/doc/_scripts/gen_boards_catalog.py b/doc/_scripts/gen_boards_catalog.py index 859f37c9ece..52be751e81f 100644 --- a/doc/_scripts/gen_boards_catalog.py +++ b/doc/_scripts/gen_boards_catalog.py @@ -70,7 +70,7 @@ def get_catalog(): arch_roots=module_settings["arch_root"], board_roots=module_settings["board_root"], soc_roots=module_settings["soc_root"], - board_dir=ZEPHYR_BASE / "boards", + board_dir=[], board=None, ) @@ -78,7 +78,7 @@ def get_catalog(): systems = list_hardware.find_v2_systems(args_find_boards) board_catalog = {} - for board in boards: + for board in boards.values(): # We could use board.vendor but it is often incorrect. Instead, deduce vendor from # containing folder. There are a few exceptions, like the "native" and "others" folders # which we know are not actual vendors so treat them as such. diff --git a/doc/hardware/porting/board_porting.rst b/doc/hardware/porting/board_porting.rst index 48c7c2e497e..5b0e52ade38 100644 --- a/doc/hardware/porting/board_porting.rst +++ b/doc/hardware/porting/board_porting.rst @@ -910,9 +910,67 @@ There are some extra things you'll need to do: #. Prepare a pull request adding your board which follows the :ref:`contribute_guidelines`. +.. _extend-board: + Board extensions **************** +The board hardware model in Zephyr allows you to extend an existing board with +new board variants. Such board extensions can be done in your custom repository +and thus outside of the Zephyr repository. + +Extending an existing board with an extra variant allows you to adjust an +existing board and thereby during build to select building for the existing, +unmodified board, or the new variant. + +To extend an existing board, first create a :file:`board.yml` in your extended +board. Make sure to use the directory structure described in +:ref:`create-your-board-directory`. + +The skeleton of the board YAML file for extending a board is: + +.. code-block:: yaml + + board: + extend: + variants: + - name: + qualifier: + +When extending a board, your board directory should look like: + +.. code-block:: none + + boards//plank + ├── board.yml + ├── plank__defconfig + └── plank_.dts + +Replace ``plank`` with the real name of the board you extend. + +In some cases you might want to also adjust additional settings, like the +:file:`Kconfig.defconfig` or :file:`Kconfig.{board}`. +Therefore it is also possible to provide the following in addition when +extending a board. + +.. code-block:: none + + boards//plank + ├── board.cmake + ├── Kconfig + ├── Kconfig.plank + ├── Kconfig.defconfig + └── plank_.yaml + +Board extensions (Old hardware model) +************************************* + +.. note:: + + This extension mechanism is intended for boards in old hardware description + format. For boards described in new hardware model format, use the extension + feature described in :ref:`extend-board`. + Boards already supported by Zephyr can be extended by downstream users, such as ``example-application`` or vendor SDKs. In some situations, certain hardware description or :ref:`choices ` can not be added in the diff --git a/drivers/adc/CMakeLists.txt b/drivers/adc/CMakeLists.txt index dce35036f43..0877adc5b3d 100644 --- a/drivers/adc/CMakeLists.txt +++ b/drivers/adc/CMakeLists.txt @@ -19,6 +19,7 @@ zephyr_library_sources_ifdef(CONFIG_ADC_NRFX_SAADC adc_nrfx_saadc.c) zephyr_library_sources_ifdef(CONFIG_ADC_SAM adc_sam.c) zephyr_library_sources_ifdef(CONFIG_ADC_SAM0 adc_sam0.c) zephyr_library_sources_ifdef(CONFIG_ADC_STM32 adc_stm32.c) +zephyr_library_sources_ifdef(CONFIG_ADC_STM32WB0 adc_stm32wb0.c) zephyr_library_sources_ifdef(CONFIG_ADC_XEC adc_mchp_xec.c) zephyr_library_sources_ifdef(CONFIG_ADC_LMP90XXX adc_lmp90xxx.c) zephyr_library_sources_ifdef(CONFIG_ADC_MCP320X adc_mcp320x.c) diff --git a/drivers/adc/Kconfig.stm32 b/drivers/adc/Kconfig.stm32 index 70be46acaef..0f567a635f9 100644 --- a/drivers/adc/Kconfig.stm32 +++ b/drivers/adc/Kconfig.stm32 @@ -5,6 +5,7 @@ # Copyright (c) 2019 Song Qiang # Copyright (c) 2021 Marius Scholtz, RIC Electronics # Copyright (c) 2022 Hein Wessels, Nobleo Technology +# Copyright (c) 2024 STMicroelectronics # SPDX-License-Identifier: Apache-2.0 config ADC_STM32 @@ -15,7 +16,15 @@ config ADC_STM32 help Enable the driver implementation for the stm32xx ADC -if ADC_STM32 +config ADC_STM32WB0 + bool "STM32WB0 ADC driver" + default y + depends on DT_HAS_ST_STM32WB0_ADC_ENABLED + select PINCTRL + help + Enable the driver implementation for the STM32WB0 series ADC + +if ADC_STM32 || ADC_STM32WB0 config ADC_STM32_DMA bool "STM32 MCU ADC DMA Support" diff --git a/drivers/adc/adc_esp32.c b/drivers/adc/adc_esp32.c index 740719901b3..1740d96b0cc 100644 --- a/drivers/adc/adc_esp32.c +++ b/drivers/adc/adc_esp32.c @@ -41,7 +41,7 @@ LOG_MODULE_REGISTER(adc_esp32, CONFIG_ADC_LOG_LEVEL); * clip the value instead of yet another correction. The IDF implementation * for ESP32-S2 is doing it, so we copy that approach in Zephyr driver */ -#define ADC_CLIP_MVOLT_11DB 2550 +#define ADC_CLIP_MVOLT_12DB 2550 #elif CONFIG_SOC_SERIES_ESP32S3 #define ADC_CALI_SCHEME ESP_ADC_CAL_VAL_EFUSE_TP_FIT #else @@ -95,7 +95,7 @@ static inline int gain_to_atten(enum adc_gain gain, adc_atten_t *atten) *atten = ADC_ATTEN_DB_6; break; case ADC_GAIN_1_4: - *atten = ADC_ATTEN_DB_11; + *atten = ADC_ATTEN_DB_12; break; default: return -ENOTSUP; @@ -117,7 +117,7 @@ static void atten_to_gain(adc_atten_t atten, uint32_t *val_mv) case ADC_ATTEN_DB_6: *val_mv = *val_mv >> 1; /* 1/ADC_GAIN_1_2 */ break; - case ADC_ATTEN_DB_11: + case ADC_ATTEN_DB_12: *val_mv = *val_mv / 4; /* 1/ADC_GAIN_1_4 */ break; case ADC_ATTEN_DB_0: /* 1/ADC_GAIN_1 */ @@ -458,9 +458,9 @@ static int adc_esp32_read(const struct device *dev, const struct adc_sequence *s cal = cal_mv = esp_adc_cal_raw_to_voltage(reading, &data->chars[channel_id]); #if CONFIG_SOC_SERIES_ESP32 - if (data->attenuation[channel_id] == ADC_ATTEN_DB_11) { - if (cal > ADC_CLIP_MVOLT_11DB) { - cal = ADC_CLIP_MVOLT_11DB; + if (data->attenuation[channel_id] == ADC_ATTEN_DB_12) { + if (cal > ADC_CLIP_MVOLT_12DB) { + cal = ADC_CLIP_MVOLT_12DB; } } #endif /* CONFIG_SOC_SERIES_ESP32 */ diff --git a/drivers/adc/adc_stm32wb0.c b/drivers/adc/adc_stm32wb0.c new file mode 100644 index 00000000000..e36cee7631c --- /dev/null +++ b/drivers/adc/adc_stm32wb0.c @@ -0,0 +1,1251 @@ +/* + * Copyright (c) 2024 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * Terminology used in this file: + * - sampling: a single analog-to-digital conversion performed by the ADC + * - sequence: one or more sampling(s) performed one after the other by the + * ADC after a single programmation. This is the meaning used in the + * STM32WB0 ADC documentation. + * - round: all ADC operations needed to read all channels in the adc_sequence passed + * to adc_read. Zephyr calls this a "sampling", but we use the term "round" to + * prevent confusion with STM32 terminology. A single round may require multiple + * sequences to be performed by the ADC to be completed, due to hardware limitations. + * + * When Zephyr's "sequence" feature is used, the same round is repeated multiple times. + * + * - idle mode: clock & ADC configuration that minimizes power consumption + * - Only the ADC digital domain clock is turned on: + * - ADC is powered off (CTRL.ADC_CTRL_ADC_ON_OFF = 0) + * - ADC analog domain clock is turned off + * - If applicable: + * - ADC LDO is disabled + * - ADC I/O Booster clock is turned off + * - ADC I/O Booster is disabled + * - ADC-SMPS clock synchronization is disabled + */ + +#define DT_DRV_COMPAT st_stm32wb0_adc + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef CONFIG_ADC_STM32_DMA +#include +#include +#include +#include +#endif + +#define ADC_CONTEXT_USES_KERNEL_TIMER +#define ADC_CONTEXT_ENABLE_ON_COMPLETE +#include "adc_context.h" + +#include +LOG_MODULE_REGISTER(adc_stm32wb0, CONFIG_ADC_LOG_LEVEL); + +/** + * Driver private definitions & assertions + */ +#define ADC_INSTANCE 0 +#define ADC_NODE DT_DRV_INST(ADC_INSTANCE) +#define ADC_USE_IO_BOOSTER DT_PROP_OR(ADC_NODE, io_booster, 0) + +#define LL_ADC_EXTERNAL_CHANNEL_NUM 12 /* must be a plain constant for LISTIFY */ +#define LL_ADC_EXTERNAL_CHANNEL_MAX (LL_ADC_CHANNEL_VINP3_VINM3 + 1U) +#define LL_ADC_CHANNEL_MAX (LL_ADC_CHANNEL_TEMPSENSOR + 1U) +#define LL_ADC_VIN_RANGE_INVALID ((uint8_t)0xFFU) + +#define NUM_CALIBRATION_POINTS 4 /* 4 calibration point registers (COMP_[0-3]) */ + +#if !defined(ADC_CONF_SAMPLE_RATE_MSB) +# define NUM_ADC_SAMPLE_RATES 4 /* SAMPLE_RATE on 2 bits */ +#else +# define NUM_ADC_SAMPLE_RATES 32 /* SAMPLE_RATE on 5 bits */ +#endif + +/* The STM32WB0 has a 12-bit ADC, but the resolution can be + * enhanced to 16-bit by oversampling (using the downsampler) + */ +#define ADC_MIN_RESOLUTION 12 +#define ADC_MAX_RESOLUTION 16 + +/* ADC channel type definitions are not provided by LL as + * it uses per-type functions instead. Bring our own. + */ +#define ADC_CHANNEL_TYPE_SINGLE_NEG (0x00U) /* Single-ended, positive */ +#define ADC_CHANNEL_TYPE_SINGLE_POS (0x01U) /* Single-ended, negative */ +#define ADC_CHANNEL_TYPE_DIFF (0x02U) /* Differential */ +#define ADC_CHANNEL_TYPE_INVALID (0xFFU) /* Invalid */ + +/** See RM0505 §6.2.1 "System clock details" */ +BUILD_ASSERT(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC >= (8 * 1000 * 1000), + "STM32WB0: system clock frequency must be at least 8MHz to use ADC"); + +/** + * Driver private structures + */ +struct adc_stm32wb0_data { + struct adc_context ctx; + const struct device *const dev; + + /** + * Bitmask of all channels requested as part of this round + * but not sampled yet. + */ + uint32_t unsampled_channels; + + /** + * Pointer in output buffer where the first data sample of the round + * is stored. This is used to reload next_sample_ptr when the user + * callback asks to repeat a round. + */ + uint16_t *round_buf_pointer; + + /** + * Pointer in output buffer where the next data sample from ADC should + * be stored. + */ + uint16_t *next_sample_ptr; + +#if defined(CONFIG_ADC_STM32_DMA) + /** Size of the sequence currently scheduled and executing */ + size_t sequence_length; + struct dma_config dmac_config; + struct dma_block_config dma_block_config; +#endif + + /** Channels configuration */ + struct adc_stm32wb0_channel_config { + /** Vinput range selection */ + uint8_t vinput_range; + } channel_config[LL_ADC_CHANNEL_MAX]; +}; + +struct adc_stm32wb0_config { + ADC_TypeDef *reg; + const struct pinctrl_dev_config *pinctrl_cfg; + /** ADC digital domain clock */ + struct stm32_pclken dig_clk; + /** ADC analog domain clock */ + struct stm32_pclken ana_clk; +#if defined(CONFIG_ADC_STM32_DMA) + const struct device *dmac; + uint32_t dma_channel; +#endif +}; + +/** + * Driver private utility functions + */ + +/** + * In STM32CubeWB0 v1.0.0, the LL_GetPackageType is buggy and returns wrong values. + * This bug is reported in the ST internal bugtracker under reference 185295. + * For now, implement the function ourselves. + */ +static inline uint32_t ll_get_package_type(void) +{ + return sys_read32(PACKAGE_BASE); +} + +static inline struct adc_stm32wb0_data *drv_data_from_adc_ctx(struct adc_context *adc_ctx) +{ + return CONTAINER_OF(adc_ctx, struct adc_stm32wb0_data, ctx); +} + +static inline uint8_t vinput_range_from_adc_ref(uint32_t reference) +{ + switch (reference) { + case ADC_REF_INTERNAL: + case ADC_REF_VDD_1: + return LL_ADC_VIN_RANGE_3V6; + case ADC_REF_VDD_1_2: + return LL_ADC_VIN_RANGE_2V4; + case ADC_REF_VDD_1_3: + return LL_ADC_VIN_RANGE_1V2; + default: + return LL_ADC_VIN_RANGE_INVALID; + } +} + +static inline uint32_t ds_width_from_adc_res(uint32_t resolution) +{ + /* + * 12 -> 0 (LL_ADC_DS_DATA_WIDTH_12_BIT) + * 13 -> 1 (LL_ADC_DS_DATA_WIDTH_13_BIT) + * 14 -> 2 (LL_ADC_DS_DATA_WIDTH_14_BIT) + * 15 -> 3 (LL_ADC_DS_DATA_WIDTH_15_BIT) + * 16 -> 4 (LL_ADC_DS_DATA_WIDTH_16_BIT) + */ + return resolution - 12; +} + +static inline uint8_t get_channel_type(uint32_t channel) +{ + switch (channel) { + case LL_ADC_CHANNEL_VINM0: + case LL_ADC_CHANNEL_VINM1: + case LL_ADC_CHANNEL_VINM2: + case LL_ADC_CHANNEL_VINM3: + case LL_ADC_CHANNEL_VBAT: + return ADC_CHANNEL_TYPE_SINGLE_NEG; + case LL_ADC_CHANNEL_VINP0: + case LL_ADC_CHANNEL_VINP1: + case LL_ADC_CHANNEL_VINP2: + case LL_ADC_CHANNEL_VINP3: + case LL_ADC_CHANNEL_TEMPSENSOR: + return ADC_CHANNEL_TYPE_SINGLE_POS; + case LL_ADC_CHANNEL_VINP0_VINM0: + case LL_ADC_CHANNEL_VINP1_VINM1: + case LL_ADC_CHANNEL_VINP2_VINM2: + case LL_ADC_CHANNEL_VINP3_VINM3: + return ADC_CHANNEL_TYPE_DIFF; + default: + __ASSERT_NO_MSG(0); + return ADC_CHANNEL_TYPE_INVALID; + } +} + +/** + * @brief Checks all fields of the adc_sequence and asserts they are + * valid and all configuration options are supported by the driver. + * + * @param sequence adc_sequence to validate + * @return 0 if the adc_sequence is valid, negative value otherwise + */ +static int validate_adc_sequence(const struct adc_sequence *sequence) +{ + const size_t round_size = sizeof(uint16_t) * POPCOUNT(sequence->channels); + size_t needed_buf_size; + + if (sequence->channels == 0 || + (sequence->channels & ~BIT_MASK(LL_ADC_CHANNEL_MAX)) != 0) { + LOG_ERR("invalid channels selection"); + return -EINVAL; + } + + CHECKIF(!sequence->buffer) { + LOG_ERR("storage buffer pointer is NULL"); + return -EINVAL; + } + + if (!IN_RANGE(sequence->resolution, ADC_MIN_RESOLUTION, ADC_MAX_RESOLUTION)) { + LOG_ERR("invalid resolution %u (must be between %u and %u)", + sequence->resolution, ADC_MIN_RESOLUTION, ADC_MAX_RESOLUTION); + return -EINVAL; + } + + /* N.B.: LL define is in the same log2(x) format as the Zephyr variable */ + if (sequence->oversampling > LL_ADC_DS_RATIO_128) { + LOG_ERR("oversampling unsupported by hardware (max: %lu)", LL_ADC_DS_RATIO_128); + return -ENOTSUP; + } + + if (sequence->options) { + const size_t samplings = (size_t)sequence->options->extra_samplings + 1; + + if (size_mul_overflow(round_size, samplings, &needed_buf_size)) { + return -ENOMEM; + } + } else { + needed_buf_size = round_size; + } + + if (needed_buf_size > sequence->buffer_size) { + return -ENOMEM; + } + + return 0; +} + +/** + * @brief Set which channel is sampled during a given conversion of the sequence. + * + * @param ADCx ADC registers pointer + * @param Conversion Target conversion index (0~15) + * @param Channel Channel to sample during specified conversion + * + * @note This function is a more convenient implementation of LL_ADC_SetSequencerRanks + */ +static inline void ll_adc_set_conversion_channel(ADC_TypeDef *ADCx, + uint32_t Conversion, uint32_t Channel) +{ + /** + * There are two registers to control the sequencer: + * - SEQ_1 holds channel selection for conversions 0~7 + * - SEQ_2 holds channel selection for conversions 8~15 + * + * Notice that all conversions in SEQ_2 have 3rd bit set, + * whereas all conversions in SEQ_1 have 3rd bit clear. + * + * In a SEQ_x register, each channel occupies 4 bits, so the + * field for conversion N is at bit offset (4 * (N % 7)). + */ + const uint32_t reg = (Conversion & 8) ? 1 : 0; + const uint32_t shift = 4 * (Conversion & 7); + + MODIFY_REG((&ADCx->SEQ_1)[reg], ADC_SEQ_1_SEQ0 << shift, Channel << shift); +} + +/** + * @brief Set the calibration point to use for a chosen channel type and Vinput range. + * + * @param ADCx ADC registers pointer + * @param Type Channel type + * @param Range Channel Vinput range + * @param Point Calibration point to use + * + * @note This is a generic version of the LL_ADC_SetCalibPointFor* functions. + */ +static inline void ll_adc_set_calib_point_for_any(ADC_TypeDef *ADCx, uint32_t Type, + uint32_t Range, uint32_t Point) +{ + __ASSERT(Range == LL_ADC_VIN_RANGE_1V2 + || Range == LL_ADC_VIN_RANGE_2V4 + || Range == LL_ADC_VIN_RANGE_3V6, "Range is not valid"); + + __ASSERT(Type == ADC_CHANNEL_TYPE_SINGLE_NEG + || Type == ADC_CHANNEL_TYPE_SINGLE_POS + || Type == ADC_CHANNEL_TYPE_DIFF, "Type is not valid"); + + __ASSERT(Point == LL_ADC_CALIB_POINT_1 + || Point == LL_ADC_CALIB_POINT_2 + || Point == LL_ADC_CALIB_POINT_3 + || Point == LL_ADC_CALIB_POINT_4, "Point is not valid"); + + /* Register organization is as follows: + * + * - Group for 1.2V Vinput range + * - Group for 2.4V Vinput range + * - Group for 3.6V Vinput range + * + * where Group is organized as: + * - Select for Single Negative mode + * - Select for Single Positive mode + * - Select for Differential mode + * + * Each select is 2 bits, and each group is thus 6 bits. + */ + + uint32_t type_shift, group_shift; + + switch (Type) { + case ADC_CHANNEL_TYPE_SINGLE_NEG: + type_shift = 0 * 2; + break; + case ADC_CHANNEL_TYPE_SINGLE_POS: + type_shift = 1 * 2; + break; + case ADC_CHANNEL_TYPE_DIFF: + type_shift = 2 * 2; + break; + default: + CODE_UNREACHABLE; + } + + switch (Range) { + case LL_ADC_VIN_RANGE_1V2: + group_shift = 0 * 6; + break; + case LL_ADC_VIN_RANGE_2V4: + group_shift = 1 * 6; + break; + case LL_ADC_VIN_RANGE_3V6: + group_shift = 2 * 6; + break; + default: + CODE_UNREACHABLE; + } + + const uint32_t shift = (group_shift + type_shift); + + MODIFY_REG(ADCx->COMP_SEL, (ADC_COMP_SEL_OFFSET_GAIN0 << shift), (Point << shift)); +} + +static void adc_acquire_pm_locks(void) +{ + pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES); + if (IS_ENABLED(CONFIG_PM_S2RAM)) { + pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_RAM, PM_ALL_SUBSTATES); + } +} + +static void adc_release_pm_locks(void) +{ + pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES); + if (IS_ENABLED(CONFIG_PM_S2RAM)) { + pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_RAM, PM_ALL_SUBSTATES); + } +} + +/** + * Driver private functions + */ + +static void configure_tempsensor_calib_point(ADC_TypeDef *adc, uint32_t calib_point) +{ + uint16_t gain; +#if defined(CONFIG_SOC_STM32WB09XX) || defined(CONFIG_SOC_STM32WB05XX) + /** RM0505/RM0529 §12.2.1 "Temperature sensor subsystem" */ + gain = 0xFFF; +#else + /** RM0530 §12.2.2 "Temperature sensor subsystem" */ + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINPX_1V2(); +#endif /* CONFIG_SOC_STM32WB09XX | CONFIG_SOC_STM32WB05XX */ + + LL_ADC_ConfigureCalibPoint(adc, calib_point, gain, 0x0); +} + +/** + * @brief Obtain calibration data for specified channel type and Vinput range + * from engineering flash, and write it to specified calibration point + * + * @param ADCx ADC registers pointer + * @param Point Calibration point to configure + * @param Type Target channel type + * @param Range Target channel Vinput range + */ +static void configure_calib_point_from_flash(ADC_TypeDef *ADCx, uint32_t Point, + uint32_t Type, uint32_t Range) +{ + int8_t offset = 0; + uint16_t gain = 0; + + switch (Range) { + case LL_ADC_VIN_RANGE_1V2: + switch (Type) { + case ADC_CHANNEL_TYPE_SINGLE_POS: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINPX_1V2(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINPX_1V2(); + break; + case ADC_CHANNEL_TYPE_SINGLE_NEG: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINMX_1V2(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINMX_1V2(); + break; + case ADC_CHANNEL_TYPE_DIFF: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINDIFF_1V2(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINDIFF_1V2(); + break; + } + break; + case LL_ADC_VIN_RANGE_2V4: + switch (Type) { + case ADC_CHANNEL_TYPE_SINGLE_POS: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINPX_2V4(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINPX_2V4(); + break; + case ADC_CHANNEL_TYPE_SINGLE_NEG: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINMX_2V4(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINMX_2V4(); + break; + case ADC_CHANNEL_TYPE_DIFF: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINDIFF_2V4(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINDIFF_2V4(); + break; + } + break; + case LL_ADC_VIN_RANGE_3V6: + switch (Type) { + case ADC_CHANNEL_TYPE_SINGLE_POS: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINPX_3V6(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINPX_3V6(); + break; + case ADC_CHANNEL_TYPE_SINGLE_NEG: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINMX_3V6(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINMX_3V6(); + break; + case ADC_CHANNEL_TYPE_DIFF: + gain = LL_ADC_GET_CALIB_GAIN_FOR_VINDIFF_3V6(); + offset = LL_ADC_GET_CALIB_OFFSET_FOR_VINDIFF_3V6(); + break; + } + break; + } + + LL_ADC_ConfigureCalibPoint(ADCx, Point, gain, offset); +} + +static void adc_enter_idle_mode(ADC_TypeDef *adc, const struct stm32_pclken *ana_clk) +{ + const struct device *clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE); + int err; + + /* Power down the ADC */ + LL_ADC_Disable(adc); + +#if SMPS_MODE != STM32WB0_SMPS_MODE_OFF + /* Disable SMPS synchronization */ + LL_ADC_SMPSSyncDisable(adc); +#endif /* SMPS_MODE != STM32WB0_SMPS_MODE_OFF */ + +#if ADC_USE_IO_BOOSTER + /* Disable ADC I/O booster */ + LL_RCC_IOBOOST_Disable(); + +# if defined(RCC_CFGR_IOBOOSTCLKEN) + /* Disable ADC I/O Booster clock if present */ + LL_RCC_IOBOOSTCLK_Disable(); +# endif +#endif /* ADC_USE_IO_BOOSTER */ + +#if defined(ADC_CTRL_ADC_LDO_ENA) + /* Disable ADC voltage regulator */ + LL_ADC_DisableInternalRegulator(adc); +#endif /* ADC_CTRL_ADC_LDO_ENA */ + + /* Turn off ADC analog domain clock */ + err = clock_control_off(clk, (clock_control_subsys_t)ana_clk); + if (err < 0) { + LOG_WRN("failed to turn off ADC analog clock (%d)", err); + } + + /* Release power management locks */ + adc_release_pm_locks(); +} + +static int adc_exit_idle_mode(ADC_TypeDef *adc, const struct stm32_pclken *ana_clk) +{ + const struct device *clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE); + int err; + + /* Acquire power management locks */ + adc_acquire_pm_locks(); + + /* Turn on ADC analog domain clock */ + err = clock_control_on(clk, + (clock_control_subsys_t)ana_clk); + if (err < 0) { + LOG_ERR("failed to turn on ADC analog clock: %d", err); + adc_release_pm_locks(); + return err; + } + +#if defined(ADC_CTRL_ADC_LDO_ENA) + /* RM0479 §12.6.3: bit ADC_LDO_ENA must not be set on QFN32 packages. + * Using an equality check with supported package types ensures that + * we never accidentally set the bit on an unsupported MCU. + */ + const uint32_t package_type = ll_get_package_type(); + + if (package_type == LL_UTILS_PACKAGETYPE_QFN48 + || package_type == LL_UTILS_PACKAGETYPE_CSP49) { + LL_ADC_EnableInternalRegulator(adc); + } +#endif /* ADC_CTRL_ADC_LDO_ENA */ + +#if ADC_USE_IO_BOOSTER +# if defined(RCC_CFGR_IOBOOSTCLKEN) + /* Enable ADC I/O Booster clock if needed by hardware */ + LL_RCC_IOBOOSTCLK_Enable(); +# endif + + /* Enable ADC I/O Booster */ + LL_RCC_IOBOOST_Enable(); +#endif /* ADC_USE_IO_BOOSTER*/ + +#if SMPS_MODE != STM32WB0_SMPS_MODE_OFF + /* RM0505 §6.2.2 "Peripherals clock details": + * To avoid SNR degradation of the ADC, + * SMPS and ADC clocks must be synchronous. + */ + LL_ADC_SMPSSyncEnable(adc); +#endif /* SMPS_MODE != STM32WB0_SMPS_MODE_OFF */ + + /* Power up the ADC */ + LL_ADC_Enable(adc); + + return err; +} + +/** + * @brief Schedule as many samplings as possible in a sequence + * then start the ADC conversion. + */ +static void schedule_and_start_adc_sequence(ADC_TypeDef *adc, struct adc_stm32wb0_data *data) +{ + uint32_t remaining_unsampled = data->unsampled_channels; + uint32_t allocated_calib_points = 0; + uint32_t sequence_length = 0; + bool temp_sensor_scheduled = false; + + /** + * These tables are used to keep track of which calibration + * point registers are used for what type of acquisition, in + * order to share the same calibration point for different + * channels if they use compatible configurations. + * + * Initialize only the first table with invalid values; since + * both tables are updated at the same time, this is sufficient + * to know when to stop programming calibration points. + */ + uint8_t calib_pt_ch_type[NUM_CALIBRATION_POINTS] = { + ADC_CHANNEL_TYPE_INVALID, ADC_CHANNEL_TYPE_INVALID, + ADC_CHANNEL_TYPE_INVALID, ADC_CHANNEL_TYPE_INVALID + }; + uint8_t calib_pt_vin_range[NUM_CALIBRATION_POINTS]; + + /* Schedule as many channels as possible for sampling */ + for (uint32_t channel = 0; + channel < LL_ADC_CHANNEL_MAX && remaining_unsampled != 0U; + channel++) { + const uint32_t ch_bit = BIT(channel); + + if ((remaining_unsampled & ch_bit) == 0) { + continue; + } + + /* Get channel information */ + const uint8_t ch_type = get_channel_type(channel); + const uint8_t ch_vin_range = data->channel_config[channel].vinput_range; + + /* Attempt to find a compatible calibration point */ + uint32_t calib_pt = 0; + + for (; calib_pt < allocated_calib_points; calib_pt++) { + if (calib_pt_ch_type[calib_pt] == ch_type + && calib_pt_vin_range[calib_pt] == ch_vin_range) { + break; + } + } + + if (calib_pt == allocated_calib_points) { + /* No compatible calibration point found. + * If an unallocated calibration point remains, use it. + * Otherwise, this channel cannot be scheduled; since we must + * perform samplings in order, exit the scheduling loop. + */ + if (allocated_calib_points < NUM_CALIBRATION_POINTS) { + allocated_calib_points++; + } else { + /* Exit scheduling loop */ + break; + } + } + + if (channel == LL_ADC_CHANNEL_TEMPSENSOR) { + if (calib_pt_ch_type[calib_pt] == ADC_CHANNEL_TYPE_INVALID) { + /** + * Temperature sensor is a special channel: it must be sampled + * with special gain/offset instead of the calibration values found + * in engineering flash. For this reason, it must NOT be scheduled + * with any other 1.2V Vinput range, single-ended positive channel. + * + * If this check succeeds, then no such channel is scheduled, and we + * can add the temperature sensor to this sequence. We're sure there + * won't be any conflict because the temperature sensor is the last + * channel. Otherwise, a channel with 1.2V Vinput range has been + * scheduled and we must delay the temperature sensor measurement to + * another sequence. + */ + temp_sensor_scheduled = true; + } else { + /* Exit scheduling loop before scheduling temperature sensor */ + break; + } + } + + /* Ensure calibration point tables are updated. + * This is unneeded if the entry was already filled up, + * but cheaper than checking for duplicate work. + */ + calib_pt_ch_type[calib_pt] = ch_type; + calib_pt_vin_range[calib_pt] = ch_vin_range; + + /* Remove channel from unscheduled list */ + remaining_unsampled &= ~ch_bit; + + /* Add channel to sequence */ + ll_adc_set_conversion_channel(adc, sequence_length, channel); + sequence_length++; + + /* Select the calibration point to use for channel */ + ll_adc_set_calib_point_for_any(adc, ch_type, ch_vin_range, calib_pt); + + /* Configure the channel Vinput range selection. + * This must not be done for internal channels, which + * use a hardwired Vinput range selection instead. + */ + if (channel < LL_ADC_EXTERNAL_CHANNEL_MAX) { + LL_ADC_SetChannelVoltageRange(adc, channel, ch_vin_range); + } +#if !defined(CONFIG_ADC_STM32_DMA) + /* If DMA is not enabled, only schedule one channel at a time. + * Otherwise, the ADC will overflow and everything will break. + */ + __ASSERT_NO_MSG(sequence_length == 1); + break; +#endif + } + + /* Configure all (used) calibration points */ + for (int i = 0; i < NUM_CALIBRATION_POINTS; i++) { + uint8_t type = calib_pt_ch_type[i]; + uint8_t range = calib_pt_vin_range[i]; + + if (type == ADC_CHANNEL_TYPE_INVALID) { + break; + } else if ((type == ADC_CHANNEL_TYPE_SINGLE_POS) + && (range == LL_ADC_VIN_RANGE_1V2) + && temp_sensor_scheduled) { + /* Configure special calibration point for temperature sensor */ + configure_tempsensor_calib_point(adc, i); + } else { + configure_calib_point_from_flash(adc, i, type, range); + } + } + + __ASSERT_NO_MSG(sequence_length > 0); + + /* Now that scheduling is done, we can set the sequence length */ + LL_ADC_SetSequenceLength(adc, sequence_length); + + /* Save unsampled channels (if any) for next sequence */ + data->unsampled_channels = remaining_unsampled; + +#if defined(CONFIG_ADC_STM32_DMA) + const struct adc_stm32wb0_config *config = data->dev->config; + int err; + + /* Save sequence length in driver data for later usage */ + data->sequence_length = sequence_length; + + /* Prepare the DMA controller for ADC->memory transfers */ + data->dma_block_config.source_address = (uint32_t)&adc->DS_DATAOUT; + data->dma_block_config.dest_address = (uint32_t)data->next_sample_ptr; + data->dma_block_config.block_size = data->sequence_length * sizeof(uint16_t); + + err = dma_config(config->dmac, config->dma_channel, &data->dmac_config); + if (err < 0) { + LOG_ERR("%s: FAIL - dma_config returns %d", __func__, err); + adc_context_complete(&data->ctx, err); + return; + } + + err = dma_start(config->dmac, config->dma_channel); + if (err < 0) { + LOG_ERR("%s: FAIL - dma_start returns %d", __func__, err); + adc_context_complete(&data->ctx, err); + return; + } +#endif + + /* Start conversion sequence */ + LL_ADC_StartConversion(adc); +} + +static inline void handle_end_of_sequence(ADC_TypeDef *adc, struct adc_stm32wb0_data *data) +{ + if (data->unsampled_channels != 0) { + /* Some channels requested for this round have + * not been sampled yet. Schedule and start another + * acquisition sequence. + */ + schedule_and_start_adc_sequence(adc, data); + } else { + /* All channels sampled: round is complete. */ + adc_context_on_sampling_done(&data->ctx, data->dev); + } +} + +static int initiate_read_operation(const struct device *dev, + const struct adc_sequence *sequence) +{ + const struct adc_stm32wb0_config *config = dev->config; + struct adc_stm32wb0_data *data = dev->data; + ADC_TypeDef *adc = (ADC_TypeDef *)config->reg; + int err; + + err = validate_adc_sequence(sequence); + if (err < 0) { + return err; + } + + /* Take ADC out of idle mode before getting to work */ + err = adc_exit_idle_mode(adc, &config->ana_clk); + if (err < 0) { + return err; + } + + /* Initialize output pointers to first byte of user buffer */ + data->next_sample_ptr = data->round_buf_pointer = sequence->buffer; + + /* Configure resolution */ + LL_ADC_SetDSDataOutputWidth(adc, ds_width_from_adc_res(sequence->resolution)); + + /* Configure oversampling */ + LL_ADC_SetDSDataOutputRatio(adc, sequence->oversampling); + + /* Start reading using the ADC */ + adc_context_start_read(&data->ctx, sequence); + + return 0; +} + +#if !defined(CONFIG_ADC_STM32_DMA) +void adc_stm32wb0_isr(const struct device *dev) +{ + const struct adc_stm32wb0_config *config = dev->config; + struct adc_stm32wb0_data *data = dev->data; + ADC_TypeDef *adc = config->reg; + + /* Down sampler output data available */ + if (LL_ADC_IsActiveFlag_EODS(adc)) { + /* Clear pending interrupt flag */ + LL_ADC_ClearFlag_EODS(adc); + + /* Write ADC data to output buffer and update pointer */ + *data->next_sample_ptr++ = LL_ADC_DSGetOutputData(adc); + } + + /* Down sampler overflow detected - return error */ + if (LL_ADC_IsActiveFlag_OVRDS(adc)) { + LL_ADC_ClearFlag_OVRDS(adc); + + LOG_ERR("ADC overflow\n"); + + adc_context_complete(&data->ctx, -EIO); + return; + } + + if (!LL_ADC_IsActiveFlag_EOS(adc)) { + /* ADC sequence not finished yet */ + return; + } + + /* Clear pending interrupt flag */ + LL_ADC_ClearFlag_EOS(adc); + + /* Execute end-of-sequence logic */ + handle_end_of_sequence(adc, data); +} +#else /* CONFIG_ADC_STM32_DMA */ +static void adc_stm32wb0_dma_callback(const struct device *dma, void *user_data, + uint32_t dma_channel, int dma_status) +{ + struct adc_stm32wb0_data *data = user_data; + const struct device *dev = data->dev; + const struct adc_stm32wb0_config *config = dev->config; + ADC_TypeDef *adc = config->reg; + int err; + + /* N.B.: some of this code is borrowed from existing ADC driver, + * but may be not applicable to STM32WB0 series' ADC. + */ + if (dma_channel == config->dma_channel) { + if (LL_ADC_IsActiveFlag_OVRDS(adc) || (dma_status >= 0)) { + /* Sequence finished - update driver data accordingly */ + data->next_sample_ptr += data->sequence_length; + + /* Stop the DMA controller */ + err = dma_stop(config->dmac, config->dma_channel); + LOG_DBG("%s: dma_stop returns %d", __func__, err); + + LL_ADC_ClearFlag_OVRDS(adc); + + /* Execute the common end-of-sequence logic */ + handle_end_of_sequence(adc, data); + } else { /* dma_status < 0 */ + LOG_ERR("%s: dma error %d", __func__, dma_status); + LL_ADC_StopConversion(adc); + + err = dma_stop(config->dmac, config->dma_channel); + + LOG_DBG("dma_stop returns %d", err); + + adc_context_complete(&data->ctx, dma_status); + } + } else { + LOG_DBG("dma_channel 0x%08X != config->dma_channel 0x%08X", + dma_channel, config->dma_channel); + } +} +#endif /* !CONFIG_ADC_STM32_DMA */ + +/** + * adc_context API implementation + */ +static void adc_context_start_sampling(struct adc_context *ctx) +{ + struct adc_stm32wb0_data *data = drv_data_from_adc_ctx(ctx); + const struct adc_stm32wb0_config *config = data->dev->config; + + /* Mark all channels of this round as unsampled */ + data->unsampled_channels = data->ctx.sequence.channels; + + /* Schedule and start first sequence of this round */ + schedule_and_start_adc_sequence(config->reg, data); +} + +static void adc_context_update_buffer_pointer( + struct adc_context *ctx, bool repeat_sampling) +{ + struct adc_stm32wb0_data *data = drv_data_from_adc_ctx(ctx); + + if (repeat_sampling) { + /* Roll back output pointer to address of first sample in round */ + data->next_sample_ptr = data->round_buf_pointer; + } else /* a new round is starting: */ { + /* Save address of first sample in round in case we have to repeat it */ + data->round_buf_pointer = data->next_sample_ptr; + } +} + +static void adc_context_on_complete(struct adc_context *ctx, int status) +{ + struct adc_stm32wb0_data *data = drv_data_from_adc_ctx(ctx); + const struct adc_stm32wb0_config *config = data->dev->config; + + ARG_UNUSED(status); + + /** + * All ADC operations are complete. + * Save power by placing ADC in idle mode. + */ + adc_enter_idle_mode(config->reg, &config->ana_clk); + + /* Prevent data corruption if something goes wrong. */ + data->next_sample_ptr = NULL; +} + +/** + * Driver subsystem API implementation + */ +int adc_stm32wb0_channel_setup(const struct device *dev, + const struct adc_channel_cfg *channel_cfg) +{ + CHECKIF(dev == NULL) { return -ENODEV; } + CHECKIF(channel_cfg == NULL) { return -EINVAL; } + const bool is_diff_channel = + (channel_cfg->channel_id == LL_ADC_CHANNEL_VINP0_VINM0 + || channel_cfg->channel_id == LL_ADC_CHANNEL_VINP1_VINM1 + || channel_cfg->channel_id == LL_ADC_CHANNEL_VINP2_VINM2 + || channel_cfg->channel_id == LL_ADC_CHANNEL_VINP3_VINM3); + const uint8_t vin_range = vinput_range_from_adc_ref(channel_cfg->reference); + const uint32_t channel_id = channel_cfg->channel_id; + struct adc_stm32wb0_data *data = dev->data; + int res; + + /* Forbid reconfiguration while operation in progress */ + res = k_sem_take(&data->ctx.lock, K_NO_WAIT); + if (res < 0) { + return res; + } + + /* Validate channel configuration parameters */ + if (channel_cfg->gain != ADC_GAIN_1) { + LOG_ERR("gain unsupported by hardware"); + res = -ENOTSUP; + goto unlock_and_return; + } + + if (vin_range == LL_ADC_VIN_RANGE_INVALID) { + LOG_ERR("invalid channel voltage reference"); + res = -EINVAL; + goto unlock_and_return; + } + + if (channel_id >= LL_ADC_CHANNEL_MAX) { + LOG_ERR("invalid channel id %d", channel_cfg->channel_id); + res = -EINVAL; + goto unlock_and_return; + } else if (is_diff_channel != channel_cfg->differential) { + /* channel_cfg->differential flag does not match + * with the selected channel's type + */ + LOG_ERR("differential flag does not match channel type"); + res = -EINVAL; + goto unlock_and_return; + } + + if (channel_cfg->acquisition_time != ADC_ACQ_TIME_DEFAULT) { + LOG_ERR("acquisition time unsupported by hardware"); + res = -ENOTSUP; + goto unlock_and_return; + } + + /* Verify that the correct reference is selected for special channels */ + if (channel_id == LL_ADC_CHANNEL_VBAT && vin_range != LL_ADC_VIN_RANGE_3V6) { + LOG_ERR("invalid reference for Vbat channel"); + res = -EINVAL; + goto unlock_and_return; + } else if (channel_id == LL_ADC_CHANNEL_TEMPSENSOR && vin_range != LL_ADC_VIN_RANGE_1V2) { + LOG_ERR("invalid reference for temperature sensor channel"); + res = -EINVAL; + goto unlock_and_return; + } + + /* Save the channel configuration in driver data. + * Note that the only configuration option available + * is the ADC channel reference (= Vinput range). + */ + data->channel_config[channel_id].vinput_range = vin_range; + +unlock_and_return: + /* Unlock the instance after updating configuration */ + k_sem_give(&data->ctx.lock); + + return res; +} + +int adc_stm32wb0_read(const struct device *dev, + const struct adc_sequence *sequence) +{ + CHECKIF(dev == NULL) { return -ENODEV; } + struct adc_stm32wb0_data *data = dev->data; + int err; + + adc_context_lock(&data->ctx, false, NULL); + + /* When context is locked in synchronous mode, this + * function blocks until the whole operation is complete. + */ + err = initiate_read_operation(dev, sequence); + + if (err >= 0) { + err = adc_context_wait_for_completion(&data->ctx); + } else { + adc_release_pm_locks(); + } + + adc_context_release(&data->ctx, err); + + return err; +} + +#if defined(CONFIG_ADC_ASYNC) +int adc_stm32wb0_read_async(const struct device *dev, + const struct adc_sequence *sequence, struct k_poll_signal *async) +{ + CHECKIF(dev == NULL) { return -ENODEV; } + struct adc_stm32wb0_data *data = dev->data; + int err; + + adc_context_lock(&data->ctx, true, async); + + /* When context is locked in synchronous mode, this + * function blocks until the whole operation is complete. + */ + err = initiate_read_operation(dev, sequence); + if (err < 0) { + adc_release_pm_locks(); + } + + adc_context_release(&data->ctx, err); + + return err; +} +#endif /* CONFIG_ADC_ASYNC */ + +static const struct adc_driver_api api_stm32wb0_driver_api = { + .channel_setup = adc_stm32wb0_channel_setup, + .read = adc_stm32wb0_read, +#if defined(CONFIG_ADC_ASYNC) + .read_async = adc_stm32wb0_read_async, +#endif /* CONFIG_ADC_ASYNC */ + .ref_internal = 3600U /* ADC_REF_INTERNAL is mapped to Vinput 3.6V range */ +}; + +int adc_stm32wb0_init(const struct device *dev) +{ + const struct device *clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE); + const struct adc_stm32wb0_config *config = dev->config; + struct adc_stm32wb0_data *data = dev->data; + ADC_TypeDef *adc = config->reg; + int err; + + if (!device_is_ready(clk)) { + LOG_ERR("clock control device not ready"); + return -ENODEV; + } + + /* Turn on ADC digital clock (always on) */ + err = clock_control_on(clk, + (clock_control_subsys_t)&config->dig_clk); + if (err < 0) { + LOG_ERR("failed to turn on ADC digital clock (%d)", err); + return err; + } + + /* Configure DT-provided signals when available */ + err = pinctrl_apply_state(config->pinctrl_cfg, PINCTRL_STATE_DEFAULT); + if (err < 0 && err != -ENOENT) { + /* ENOENT indicates no entry - should not be treated as failure */ + LOG_ERR("fail to apply ADC pinctrl state (%d)", err); + return err; + } + +#if defined(ADC_SUPPORT_AUDIO_FEATURES) + /* Configure ADC for analog sampling */ + LL_ADC_SetADCMode(adc, LL_ADC_OP_MODE_ADC); +#endif + +#if defined(PWR_CR2_ENTS) + /* Enable on-die temperature sensor */ + LL_PWR_EnableTempSens(); +#endif + + /* Set ADC sample rate to 1 Msps (maximum speed) */ + LL_ADC_SetSampleRate(adc, LL_ADC_SAMPLE_RATE_16); + + /* Keep new data on overrun, if it ever happens */ + LL_ADC_SetOverrunDS(adc, LL_ADC_NEW_DATA_IS_KEPT); + +#if !defined(CONFIG_ADC_STM32_DMA) + /* Attach ISR and enable ADC interrupt in NVIC */ + IRQ_CONNECT(DT_IRQN(ADC_NODE), DT_IRQ(ADC_NODE, priority), + adc_stm32wb0_isr, DEVICE_DT_GET(ADC_NODE), 0); + irq_enable(DT_IRQN(ADC_NODE)); + + /* Enable ADC interrupt after each sampling. + * NOTE: enabling EOS interrupt is not necessary because + * the EODS interrupt flag is also set to high when the + * EOS flag is being set to high. + */ + LL_ADC_EnableIT_EODS(adc); +#else + /* Check that DMA controller exists and is ready to be used */ + if (!config->dmac) { + LOG_ERR("no DMA assigned to ADC in DMA driver mode!"); + return -ENODEV; + } + + if (!device_is_ready(config->dmac)) { + LOG_ERR("DMA controller '%s' for ADC not ready", config->dmac->name); + return -ENODEV; + } + + /* Finalize DMA configuration structure in driver data */ + data->dmac_config.head_block = &data->dma_block_config; + data->dmac_config.user_data = data; + + /* Enable DMA datapath in ADC */ + LL_ADC_DMAModeDSEnable(adc); +#endif /* !CONFIG_ADC_STM32_DMA */ + + /* Unlock the ADC context to mark ADC as ready to use */ + adc_context_unlock_unconditionally(&data->ctx); + + /* Keep ADC powered down ("idle mode"). + * It will be awakened on-demand when a call to the ADC API + * is performed by the application. + */ + return 0; +} + +/** + * Driver power management implementation + */ +#ifdef CONFIG_PM_DEVICE +static int adc_stm32wb0_pm_action(const struct device *dev, + enum pm_device_action action) +{ + const struct adc_stm32wb0_config *config = dev->config; + ADC_TypeDef *adc = config->reg; + int res; + + switch (action) { + case PM_DEVICE_ACTION_RESUME: + return adc_stm32wb0_init(dev); + case PM_DEVICE_ACTION_SUSPEND: + adc_enter_idle_mode(adc, &config->ana_clk); + + /* Move pins to sleep state */ + res = pinctrl_apply_state(config->pinctrl_cfg, PINCTRL_STATE_SLEEP); + + /** + * -ENOENT is returned if there are no pins defined in DTS for sleep mode. + * This is fine and should not block PM from suspending the device. + * Silently ignore the error by returning 0 instead. + */ + if (res >= 0 || res == -ENOENT) { + return 0; + } else { + return res; + } + default: + return -ENOTSUP; + } +} +#endif /* CONFIG_PM_DEVICE */ + +/** + * Driver device instantiation + */ +PINCTRL_DT_DEFINE(ADC_NODE); + +static const struct adc_stm32wb0_config adc_config = { + .reg = (ADC_TypeDef *)DT_REG_ADDR(ADC_NODE), + .pinctrl_cfg = PINCTRL_DT_DEV_CONFIG_GET(ADC_NODE), + .dig_clk = STM32_CLOCK_INFO(0, ADC_NODE), + .ana_clk = STM32_CLOCK_INFO(1, ADC_NODE), +#if defined(CONFIG_ADC_STM32_DMA) + .dmac = DEVICE_DT_GET(DT_DMAS_CTLR_BY_IDX(ADC_NODE, 0)), + .dma_channel = DT_DMAS_CELL_BY_IDX(ADC_NODE, 0, channel), +#endif +}; + +static struct adc_stm32wb0_data adc_data = { + ADC_CONTEXT_INIT_TIMER(adc_data, ctx), + ADC_CONTEXT_INIT_LOCK(adc_data, ctx), + ADC_CONTEXT_INIT_SYNC(adc_data, ctx), + .dev = DEVICE_DT_GET(ADC_NODE), + .channel_config = { + /* Internal channels selection is hardwired */ + [LL_ADC_CHANNEL_VBAT] = { + .vinput_range = LL_ADC_VIN_RANGE_3V6 + }, + [LL_ADC_CHANNEL_TEMPSENSOR] = { + .vinput_range = LL_ADC_VIN_RANGE_1V2 + } + }, +#if defined(CONFIG_ADC_STM32_DMA) + .dmac_config = { + .dma_slot = DT_INST_DMAS_CELL_BY_IDX(ADC_INSTANCE, 0, slot), + .channel_direction = STM32_DMA_CONFIG_DIRECTION( + STM32_DMA_CHANNEL_CONFIG_BY_IDX(ADC_INSTANCE, 0)), + .channel_priority = STM32_DMA_CONFIG_PRIORITY( + STM32_DMA_CHANNEL_CONFIG_BY_IDX(ADC_INSTANCE, 0)), + .source_data_size = STM32_DMA_CONFIG_PERIPHERAL_DATA_SIZE( + STM32_DMA_CHANNEL_CONFIG_BY_IDX(ADC_INSTANCE, 0)), + .dest_data_size = STM32_DMA_CONFIG_MEMORY_DATA_SIZE( + STM32_DMA_CHANNEL_CONFIG_BY_IDX(ADC_INSTANCE, 0)), + .source_burst_length = 1, /* SINGLE transfer */ + .dest_burst_length = 1, /* SINGLE transfer */ + .block_count = 1, + .dma_callback = adc_stm32wb0_dma_callback, + /* head_block and user_data are initialized at runtime */ + }, + .dma_block_config = { + .source_addr_adj = DMA_ADDR_ADJ_NO_CHANGE, + .source_reload_en = 0, + .dest_addr_adj = DMA_ADDR_ADJ_INCREMENT, + .dest_reload_en = 0, + } +#endif +}; + +PM_DEVICE_DT_DEFINE(ADC_NODE, adc_stm32wb0_pm_action); + +DEVICE_DT_DEFINE(ADC_NODE, &adc_stm32wb0_init, PM_DEVICE_DT_GET(ADC_NODE), + &adc_data, &adc_config, POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, + &api_stm32wb0_driver_api); diff --git a/drivers/bluetooth/hci/Kconfig.esp32 b/drivers/bluetooth/hci/Kconfig.esp32 index cea379b046b..ad7a53d5de3 100644 --- a/drivers/bluetooth/hci/Kconfig.esp32 +++ b/drivers/bluetooth/hci/Kconfig.esp32 @@ -1,5 +1,4 @@ -# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. -# SPDX-License-Identifier: Apache-2.0 +# Copyright 2024 Espressif Systems (Shanghai) PTE LTD if BT_ESP32 @@ -16,4 +15,12 @@ choice ESP_BT_HEAP endchoice # ESP_BT_HEAP -endif +config ESP32_BT_CONTROLLER_STACK_SIZE + int "Bluetooth controller stack size" + default 4096 + +config ESP32_BT_CONTROLLER_TASK_PRIO + int "Bluetooth controller task priority level" + default 2 + +endif # BT_ESP32 diff --git a/drivers/dma/dma_esp32_gdma.c b/drivers/dma/dma_esp32_gdma.c index cc57f419efd..7fb5da72b43 100644 --- a/drivers/dma/dma_esp32_gdma.c +++ b/drivers/dma/dma_esp32_gdma.c @@ -33,11 +33,7 @@ LOG_MODULE_REGISTER(dma_esp32_gdma, CONFIG_DMA_LOG_LEVEL); #define ISR_HANDLER intr_handler_t #endif -#if defined(CONFIG_SOC_SERIES_ESP32C6) -#define DMA_MAX_CHANNEL SOC_GDMA_PAIRS_PER_GROUP_MAX -#else #define DMA_MAX_CHANNEL SOC_GDMA_PAIRS_PER_GROUP -#endif #define ESP_DMA_M2M_ON 0 #define ESP_DMA_M2M_OFF 1 diff --git a/drivers/wifi/esp32/Kconfig.esp32 b/drivers/wifi/esp32/Kconfig.esp32 index f6b37899a8f..6732bd5ff7e 100644 --- a/drivers/wifi/esp32/Kconfig.esp32 +++ b/drivers/wifi/esp32/Kconfig.esp32 @@ -175,6 +175,39 @@ config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM than WiFi layer can transmit. In these cases, we may run out of TX buffers. +choice ESP32_WIFI_MGMT_RX_BUFFER + prompt "Type of WiFi RX MGMT buffers" + default ESP32_WIFI_STATIC_RX_MGMT_BUFFER + help + Select type of WiFi RX MGMT buffers: + + If "Static" is selected, WiFi RX MGMT buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. The size of each static RX MGMT buffer is fixed to about 500 Bytes. + + If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated as needed when a MGMT data frame is + received. The MGMT buffer is freed after the MGMT data frame has been processed by the WiFi driver. + + config ESP32_WIFI_STATIC_RX_MGMT_BUFFER + bool "Static" + config ESP32_WIFI_DYNAMIC_RX_MGMT_BUFFER + bool "Dynamic" +endchoice + +config ESP32_WIFI_DYNAMIC_RX_MGMT_BUF + int + default 0 if ESP32_WIFI_STATIC_RX_MGMT_BUFFER + default 1 if ESP32_WIFI_DYNAMIC_RX_MGMT_BUFFER + +config ESP32_WIFI_RX_MGMT_BUF_NUM_DEF + int "Max number of WiFi RX MGMT buffers" + range 1 10 + default 5 + help + Set the number of WiFi RX_MGMT buffers. + + For Management buffers, the number of dynamic and static management buffers is the same. + In order to prevent memory fragmentation, the management buffer type should be set to static first. + config ESP32_WIFI_CSI_ENABLED bool "WiFi CSI(Channel State Information)" default n @@ -234,6 +267,13 @@ config ESP32_WIFI_AMSDU_TX_ENABLED help Select this option to enable AMSDU TX feature +config ESP32_WIFI_MGMT_SBUF_NUM + int "WiFi mgmt short buffer number" + range 6 32 + default 32 + help + Set the number of WiFi management short buffer. + config ESP32_WIFI_IRAM_OPT bool "WiFi IRAM speed optimization" default n if (BT && ESP_SPIRAM && SOC_SERIES_ESP32) @@ -251,10 +291,62 @@ config ESP32_WIFI_RX_IRAM_OPT When this option is disabled, more than 17Kbytes of IRAM memory will be saved but Wi-Fi performance will be reduced. +config ESP32_WIFI_MAX_THREAD_PRIORITY + int "Maximum work queue thread priority" + default 7 + help + Maximum priority of thread used for processing driver work queue items. + +config ESP32_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME + int "Minimum active time" + range 8 60 + default 50 + help + Only for station in WIFI_PS_MIN_MODEM or WIFI_PS_MAX_MODEM. When the station enters the active state, + it will work for at least ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME. If a data packet is received or sent + during this period, the time will be refreshed. If the time is up, but the station still has packets + to receive or send, the time will also be refreshed. unit: milliseconds. + +config ESP32_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME + int "Maximum keep alive time" + range 10 60 + default 10 + help + Only for station in WIFI_PS_MIN_MODEM or WIFI_PS_MAX_MODEM. If no packet has been + sent within ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME, a null data packet will be sent + to maintain the connection with the AP. unit: seconds. + +config ESP32_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME + int "Minimum wait broadcast data time" + range 10 30 + default 15 + help + Only for station in WIFI_PS_MIN_MODEM or WIFI_PS_MAX_MODEM. When the station knows through the beacon + that AP will send broadcast packet, it will wait for ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME + before entering the sleep process. If a broadcast packet is received with more data bits, the time + will refreshed. unit: milliseconds. + +choice ESP_WIFI_HEAP + prompt "Wifi adapter heap in use" + default ESP_WIFI_HEAP_RUNTIME + + config ESP_WIFI_HEAP_RUNTIME + bool "Wifi adapter use ESP runtime heap" + depends on ESP_HEAP_RUNTIME + + config ESP_WIFI_HEAP_SPIRAM + bool "Wifi adapter use SPIRAM heap" + depends on ESP_SPIRAM + + config ESP_WIFI_HEAP_SYSTEM + bool "Wifi adapter use system heap" + +endchoice # ESP_WIFI_HEAP + config ESP32_WIFI_FTM_ENABLE bool "WiFi FTM" default n - depends on SOC_SERIES_ESP32C2 || SOC_SERIES_ESP32C3 + depends on SOC_SERIES_ESP32C2 || SOC_SERIES_ESP32C3 || SOC_SERIES_ESP32C6 || SOC_SERIES_ESP32S2 || SOC_SERIES_ESP32S3 help Enable feature Fine Timing Measurement for calculating WiFi Round-Trip-Time (RTT). diff --git a/drivers/wifi/esp32/src/esp_wifi_drv.c b/drivers/wifi/esp32/src/esp_wifi_drv.c index fb8dd8577f0..56f8b92e51e 100644 --- a/drivers/wifi/esp32/src/esp_wifi_drv.c +++ b/drivers/wifi/esp32/src/esp_wifi_drv.c @@ -871,7 +871,6 @@ static int esp32_wifi_dev_init(const struct device *dev) adc2_init_code_calibration(); #endif /* CONFIG_SOC_SERIES_ESP32S2 || CONFIG_SOC_SERIES_ESP32C3 */ - esp_timer_init(); wifi_init_config_t config = WIFI_INIT_CONFIG_DEFAULT(); esp_err_t ret = esp_wifi_init(&config); @@ -883,7 +882,6 @@ static int esp32_wifi_dev_init(const struct device *dev) LOG_ERR("Unable to initialize the Wi-Fi: %d", ret); return -EIO; } - if (IS_ENABLED(CONFIG_ESP32_WIFI_STA_AUTO_DHCPV4)) { net_mgmt_init_event_callback(&esp32_dhcp_cb, wifi_event_handler, DHCPV4_MASK); net_mgmt_add_event_callback(&esp32_dhcp_cb); diff --git a/dts/arm/st/wb0/stm32wb0.dtsi b/dts/arm/st/wb0/stm32wb0.dtsi index 0532f0ba027..c6a43b37f23 100644 --- a/dts/arm/st/wb0/stm32wb0.dtsi +++ b/dts/arm/st/wb0/stm32wb0.dtsi @@ -218,6 +218,22 @@ status = "disabled"; }; + adc1: adc@41006000 { + compatible = "st,stm32wb0-adc"; + reg = <0x41006000 256>; + /* On STM32WB0, the two ADC clock domains (ANALOG / DIGITAL) + * can be controlled independently. Expose this feature to + * the driver by having two `clocks` property entries: + * - first entry is digital part of ADC block (always-on) + * - second entry is analog part of ADC block (on-demand) + */ + clocks = <&rcc STM32_CLOCK(APB1, 4)>, + <&rcc STM32_CLOCK(APB1, 5)>; + interrupts = <12 0>; + #io-channel-cells = <1>; + status = "disabled"; + }; + dma1: dma@48700000 { compatible = "st,stm32-dma-v2bis"; #dma-cells = <2>; diff --git a/dts/bindings/adc/st,stm32wb0-adc.yaml b/dts/bindings/adc/st,stm32wb0-adc.yaml new file mode 100644 index 00000000000..b2b6599c834 --- /dev/null +++ b/dts/bindings/adc/st,stm32wb0-adc.yaml @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: Apache-2.0 + +description: STM32WB0 series Analog-to-Digital Converter + +compatible: "st,stm32wb0-adc" + +include: [adc-controller.yaml, pinctrl-device.yaml] + +properties: + reg: + required: true + + clocks: + required: true + + interrupts: + required: true + + "#io-channel-cells": + const: 1 + + io-booster: + type: boolean + description: | + When set, the I/O Booster block is enabled during ADC usage. Otherwise, the + I/O Booster block is always disabled. This property MUST be set if VBAT voltage + may reach a value below 2.7V to guarantee that the ADC behavior remains correct. + +io-channel-cells: + - input diff --git a/dts/bindings/arm/nordic,nrf-uicr-v2.yaml b/dts/bindings/arm/nordic,nrf-uicr-v2.yaml index f509fdf4061..9000cce94c5 100644 --- a/dts/bindings/arm/nordic,nrf-uicr-v2.yaml +++ b/dts/bindings/arm/nordic,nrf-uicr-v2.yaml @@ -17,10 +17,3 @@ properties: description: | Domain ID of the domain associated with this UICR instance. Must be unique across all UICR instances in the system. - - ptr-ext-uicr: - type: phandle - required: true - description: | - Handle of a memory region reserved to contain an Extended UICR instance. - The address of that node will be stored in the UICR.PTREXTUICR register. diff --git a/dts/common/nordic/nrf54h20.dtsi b/dts/common/nordic/nrf54h20.dtsi index 5f48cfb6d5b..92a4880cf17 100644 --- a/dts/common/nordic/nrf54h20.dtsi +++ b/dts/common/nordic/nrf54h20.dtsi @@ -145,16 +145,8 @@ #address-cells = <1>; #size-cells = <1>; - suit_storage_partition: memory@e1eb000 { - reg = <0xe1eb000 DT_SIZE_K(24)>; - }; - - cpurad_uicr_ext: memory@e1ff000 { - reg = <0xe1ff000 DT_SIZE_K(2)>; - }; - - cpuapp_uicr_ext: memory@e1ff800 { - reg = <0xe1ff800 DT_SIZE_K(2)>; + suit_storage_partition: memory@e1ed000 { + reg = <0xe1ed000 DT_SIZE_K(20)>; }; }; @@ -217,14 +209,12 @@ compatible = "nordic,nrf-uicr-v2"; reg = <0xfff8000 DT_SIZE_K(2)>; domain = <2>; - ptr-ext-uicr = <&cpuapp_uicr_ext>; }; cpurad_uicr: uicr@fffa000 { compatible = "nordic,nrf-uicr-v2"; reg = <0xfffa000 DT_SIZE_K(2)>; domain = <3>; - ptr-ext-uicr = <&cpurad_uicr_ext>; }; ficr: ficr@fffe000 { diff --git a/dts/common/nordic/nrf9280.dtsi b/dts/common/nordic/nrf9280.dtsi index e0a34fc22f9..4fd64cd10be 100644 --- a/dts/common/nordic/nrf9280.dtsi +++ b/dts/common/nordic/nrf9280.dtsi @@ -74,14 +74,6 @@ reserved-memory { #address-cells = <1>; #size-cells = <1>; - - cpurad_uicr_ext: memory@e401000 { - reg = <0xe401000 DT_SIZE_K(2)>; - }; - - cpuapp_uicr_ext: memory@e401800 { - reg = <0xe401800 DT_SIZE_K(2)>; - }; }; clocks { @@ -113,14 +105,12 @@ compatible = "nordic,nrf-uicr-v2"; reg = <0xfff8000 DT_SIZE_K(2)>; domain = <2>; - ptr-ext-uicr = <&cpuapp_uicr_ext>; }; cpurad_uicr: uicr@fffa000 { compatible = "nordic,nrf-uicr-v2"; reg = <0xfffa000 DT_SIZE_K(2)>; domain = <3>; - ptr-ext-uicr = <&cpurad_uicr_ext>; }; ficr: ficr@fffe000 { diff --git a/include/zephyr/bluetooth/l2cap.h b/include/zephyr/bluetooth/l2cap.h index 0117da5ebb9..cdd162f9889 100644 --- a/include/zephyr/bluetooth/l2cap.h +++ b/include/zephyr/bluetooth/l2cap.h @@ -349,6 +349,11 @@ struct bt_l2cap_chan_ops { * @kconfig{CONFIG_BT_L2CAP_SEG_RECV} is enabled and seg_recv is * supplied. * + * If the application returns @c -EINPROGRESS, the application takes + * ownership of the reference in @p buf. (I.e. This pointer value can + * simply be given to @ref bt_l2cap_chan_recv_complete without any + * calls @ref net_buf_ref or @ref net_buf_unref.) + * * @return 0 in case of success or negative value in case of error. * @return -EINPROGRESS in case where user has to confirm once the data * has been processed by calling diff --git a/include/zephyr/bluetooth/testing.h b/include/zephyr/bluetooth/testing.h new file mode 100644 index 00000000000..3ac48c7b36e --- /dev/null +++ b/include/zephyr/bluetooth/testing.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @brief Internal testing interfaces for Bluetooth + * @file + * @internal + * + * The interfaces in this file are internal and not stable. + */ + +#ifndef ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ +#define ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ + +#include + +/** @brief Hook for `acl_in_pool.destroy` + * + * Weak-function interface. The user can simply define this + * function, and it will automatically become the event + * listener. + * + * @kconfig_dep{CONFIG_BT_TESTING} + */ +void bt_testing_trace_event_acl_pool_destroy(struct net_buf *buf); + +#endif /* ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ */ diff --git a/modules/hal_nordic/CMakeLists.txt b/modules/hal_nordic/CMakeLists.txt index a9384a03633..9be36d4998d 100644 --- a/modules/hal_nordic/CMakeLists.txt +++ b/modules/hal_nordic/CMakeLists.txt @@ -12,7 +12,7 @@ if(CONFIG_NRF_REGTOOL_GENERATE_UICR) list(APPEND nrf_regtool_components GENERATE:UICR) endif() if(DEFINED nrf_regtool_components) - find_package(nrf-regtool 5.6.0 REQUIRED + find_package(nrf-regtool 7.0.0 REQUIRED COMPONENTS ${nrf_regtool_components} PATHS ${CMAKE_CURRENT_LIST_DIR}/nrf-regtool NO_CMAKE_PATH diff --git a/samples/bluetooth/broadcaster_multiple/src/broadcaster_multiple.c b/samples/bluetooth/broadcaster_multiple/src/broadcaster_multiple.c index f2e7127b406..63834fa3852 100644 --- a/samples/bluetooth/broadcaster_multiple/src/broadcaster_multiple.c +++ b/samples/bluetooth/broadcaster_multiple/src/broadcaster_multiple.c @@ -77,13 +77,6 @@ int broadcaster_multiple(void) }; int err; - /* Initialize the Bluetooth Subsystem */ - err = bt_enable(NULL); - if (err) { - printk("Bluetooth init failed (err %d)\n", err); - return err; - } - for (int index = 0; index < CONFIG_BT_EXT_ADV_MAX_ADV_SET; index++) { /* Use advertising set instance index as SID */ adv_param.sid = index; diff --git a/samples/bluetooth/broadcaster_multiple/src/main.c b/samples/bluetooth/broadcaster_multiple/src/main.c index f30db217e86..4da680e4d8b 100644 --- a/samples/bluetooth/broadcaster_multiple/src/main.c +++ b/samples/bluetooth/broadcaster_multiple/src/main.c @@ -5,13 +5,23 @@ */ #include +#include int broadcaster_multiple(void); int main(void) { + int err; + printk("Starting Multiple Broadcaster Demo\n"); + /* Initialize the Bluetooth Subsystem */ + err = bt_enable(NULL); + if (err) { + printk("Bluetooth init failed (err %d)\n", err); + return 0; + } + (void)broadcaster_multiple(); printk("Exiting %s thread.\n", __func__); diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf index 0e4a20602b5..a7487118694 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_bis-bt_ll_sw_split.conf @@ -5,13 +5,10 @@ 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_OBSERVER=y CONFIG_BT_HCI_RAW=y -CONFIG_BT_MAX_CONN=2 # Workaround: Unable to allocate command buffer when using K_NO_WAIT since # Host number of completed commands does not follow normal flow control. @@ -24,11 +21,16 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Host features +# Host and Controller common dependencies +CONFIG_BT_BROADCASTER=y +CONFIG_BT_OBSERVER=y CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_PER_ADV_SYNC=y CONFIG_BT_PER_ADV_SYNC_MAX=2 +CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_MAX_CONN=2 # Broadcast and Connected ISO CONFIG_BT_ISO_BROADCASTER=y @@ -37,7 +39,9 @@ CONFIG_BT_ISO_CENTRAL=n CONFIG_BT_ISO_PERIPHERAL=n # ISO Streams -CONFIG_BT_ISO_MAX_CHAN=2 +CONFIG_BT_ISO_MAX_CHAN=4 +CONFIG_BT_ISO_TX_BUF_COUNT=1 +CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller CONFIG_BT_LL_SW_SPLIT=y @@ -77,21 +81,27 @@ CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=6 # ISO Broadcaster Controller CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_ADV_PERIODIC=y +CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER=y CONFIG_BT_CTLR_ADV_ISO=y -CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 +CONFIG_BT_CTLR_ADV_ISO_SET=2 +CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4 CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=2 +CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 # ISO Receive Controller CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_SYNC_PERIODIC=y +CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER=y CONFIG_BT_CTLR_SYNC_ISO=y -CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_SCAN_SYNC_ISO_SET=1 +CONFIG_BT_CTLR_SYNC_ISO_STREAM_COUNT=2 CONFIG_BT_CTLR_SYNC_ISO_STREAM_MAX=2 +CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 # ISO Transmissions -CONFIG_BT_CTLR_ISO_TX_BUFFERS=8 +CONFIG_BT_CTLR_ISOAL_SOURCES=4 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=12 CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 -CONFIG_BT_CTLR_ISOAL_SOURCES=2 # ISO Receptions CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf index af142bf7dc6..f7e1f8fc673 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf @@ -5,12 +5,10 @@ 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_MAX_CONN=2 # Workaround: Unable to allocate command buffer when using K_NO_WAIT since # Host number of completed commands does not follow normal flow control. @@ -23,12 +21,15 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Host features +# Host and Controller common dependencies +CONFIG_BT_BROADCASTER=y +CONFIG_BT_OBSERVER=y CONFIG_BT_EXT_ADV=y -CONFIG_BT_PERIPHERAL=y -CONFIG_BT_CENTRAL=y CONFIG_BT_PER_ADV=n CONFIG_BT_PER_ADV_SYNC=n +CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_MAX_CONN=3 # Broadcast and Connected ISO CONFIG_BT_ISO_BROADCASTER=n @@ -37,7 +38,9 @@ CONFIG_BT_ISO_CENTRAL=y CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams -CONFIG_BT_ISO_MAX_CHAN=2 +CONFIG_BT_ISO_MAX_CHAN=4 +CONFIG_BT_ISO_TX_BUF_COUNT=1 +CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller CONFIG_BT_LL_SW_SPLIT=y @@ -79,13 +82,17 @@ CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=6 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=y +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 +CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y # ISO Transmissions -CONFIG_BT_CTLR_ISO_TX_BUFFERS=8 -CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 CONFIG_BT_CTLR_ISOAL_SOURCES=2 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=12 +CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 # ISO Receptions CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf index 403501a5810..b183a4c9825 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_df-bt_ll_sw_split.conf @@ -5,12 +5,10 @@ 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_MAX_CONN=2 # Workaround: Unable to allocate command buffer when using K_NO_WAIT since # Host number of completed commands does not follow normal flow control. @@ -23,11 +21,16 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Host features +# Host and Controller common dependencies +CONFIG_BT_BROADCASTER=y +CONFIG_BT_OBSERVER=y CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_PER_ADV_SYNC=y CONFIG_BT_PER_ADV_SYNC_MAX=2 +CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_MAX_CONN=2 # Controller CONFIG_BT_LL_SW_SPLIT=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf index 62a0225b580..925eac8e34e 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf @@ -5,7 +5,6 @@ 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_CBPRINTF_REDUCED_INTEGRAL=y @@ -13,10 +12,7 @@ CONFIG_ISR_TABLES_LOCAL_DECLARATION=y CONFIG_LTO=y CONFIG_BT=y -CONFIG_BT_PERIPHERAL=y -CONFIG_BT_CENTRAL=y CONFIG_BT_HCI_RAW=y -CONFIG_BT_MAX_CONN=3 # Workaround: Unable to allocate command buffer when using K_NO_WAIT since # Host number of completed commands does not follow normal flow control. @@ -29,11 +25,16 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Host features +# Host and Controller common dependencies +CONFIG_BT_BROADCASTER=y +CONFIG_BT_OBSERVER=y CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_PER_ADV_SYNC=y CONFIG_BT_PER_ADV_SYNC_MAX=2 +CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_MAX_CONN=3 # Broadcast and Connected ISO CONFIG_BT_ISO_BROADCASTER=y @@ -42,7 +43,11 @@ CONFIG_BT_ISO_CENTRAL=y CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams +CONFIG_BT_ISO_TX_MTU=310 +CONFIG_BT_ISO_RX_MTU=310 CONFIG_BT_ISO_MAX_CHAN=4 +CONFIG_BT_ISO_TX_BUF_COUNT=1 +CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller CONFIG_BT_LL_SW_SPLIT=y @@ -71,8 +76,12 @@ CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=6 # Increase the below to receive interleaved advertising chains CONFIG_BT_CTLR_SCAN_AUX_SET=1 +# CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS=y +# CONFIG_BT_CTLR_SCAN_AUX_CHAIN_COUNT=1 CONFIG_BT_CTLR_ADV_RESERVE_MAX=n +CONFIG_BT_CTLR_ADV_ISO_RESERVE_MAX=y +CONFIG_BT_CTLR_SYNC_ISO_RESERVE_MAX=n CONFIG_BT_CTLR_CENTRAL_RESERVE_MAX=n CONFIG_BT_CTLR_PERIPHERAL_RESERVE_MAX=n CONFIG_BT_CTLR_PERIPHERAL_ISO_RESERVE_MAX=n @@ -89,38 +98,44 @@ CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=6 # ISO Broadcaster Controller CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_ADV_PERIODIC=y +CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER=y CONFIG_BT_CTLR_ADV_ISO=y -CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 +CONFIG_BT_CTLR_ADV_ISO_SET=2 +CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4 CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=2 -CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=2 +CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 # ISO Receive Controller CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_SYNC_PERIODIC=y +CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER=y CONFIG_BT_CTLR_SYNC_ISO=y -CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_SCAN_SYNC_ISO_SET=1 +CONFIG_BT_CTLR_SYNC_ISO_STREAM_COUNT=2 CONFIG_BT_CTLR_SYNC_ISO_STREAM_MAX=2 +CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=y CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 +CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y # ISO Transmissions -CONFIG_BT_ISO_TX_MTU=310 -CONFIG_BT_ISO_TX_BUF_COUNT=4 -CONFIG_BT_CTLR_ISO_TX_BUFFERS=8 +CONFIG_BT_CTLR_ISOAL_SOURCES=4 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=12 CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 -CONFIG_BT_CTLR_ISOAL_SOURCES=2 # ISO Receptions -CONFIG_BT_ISO_RX_MTU=310 -CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 CONFIG_BT_CTLR_ISOAL_SINKS=2 +CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 # Tx Power Dynamic Control CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y + +# Ignore HCI ISO data Tx sequence numbers +# CONFIG_BT_CTLR_ISOAL_PSN_IGNORE=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf index 05645663bc4..67c5854c9c0 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_broadcast-bt_ll_sw_split.conf @@ -5,7 +5,6 @@ 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 @@ -15,26 +14,30 @@ CONFIG_BT_HCI_RAW=y # Host number of completed commands does not follow normal flow control. CONFIG_BT_BUF_CMD_TX_COUNT=10 -# Host +# Host and Controller common dependencies CONFIG_BT_BROADCASTER=y -CONFIG_BT_PERIPHERAL=n CONFIG_BT_OBSERVER=n -CONFIG_BT_CENTRAL=n CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_ISO_BROADCASTER=y -CONFIG_BT_ISO_MAX_CHAN=2 +CONFIG_BT_ISO_MAX_CHAN=4 +CONFIG_BT_ISO_TX_BUF_COUNT=1 +CONFIG_BT_CENTRAL=n +CONFIG_BT_PERIPHERAL=n # ISO Broadcast Controller CONFIG_BT_LL_SW_SPLIT=y CONFIG_BT_CTLR_ADV_PERIODIC=y CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191 CONFIG_BT_CTLR_ADV_ISO=y -CONFIG_BT_CTLR_ISO_TX_BUFFERS=16 -CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 -CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 +CONFIG_BT_CTLR_ADV_ISO_SET=2 +CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4 CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=2 -CONFIG_BT_CTLR_ISOAL_SOURCES=2 +CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 +CONFIG_BT_CTLR_ISOAL_SOURCES=4 + +CONFIG_BT_CTLR_ISO_TX_BUFFERS=12 +CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 CONFIG_BT_CTLR_ADVANCED_FEATURES=y CONFIG_BT_CTLR_ADV_RESERVE_MAX=n diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf index 56e80860f32..505b9d352ba 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_central-bt_ll_sw_split.conf @@ -5,7 +5,6 @@ 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 @@ -20,21 +19,24 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Host +# Host and Controller common dependencies CONFIG_BT_BROADCASTER=n -CONFIG_BT_PERIPHERAL=n CONFIG_BT_OBSERVER=y -CONFIG_BT_CENTRAL=y CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=n CONFIG_BT_PER_ADV_SYNC=n CONFIG_BT_ISO_BROADCASTER=n CONFIG_BT_ISO_SYNC_RECEIVER=n +CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=n +CONFIG_BT_MAX_CONN=2 CONFIG_BT_ISO_CENTRAL=y CONFIG_BT_ISO_PERIPHERAL=n # ISO Streams CONFIG_BT_ISO_MAX_CHAN=2 +CONFIG_BT_ISO_TX_BUF_COUNT=1 +CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller CONFIG_BT_LL_SW_SPLIT=y @@ -44,17 +46,21 @@ CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=n +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 +CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y # ISO Transmissions -CONFIG_BT_CTLR_ISO_TX_BUFFERS=16 -CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 CONFIG_BT_CTLR_ISOAL_SOURCES=2 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=12 +CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 # ISO Receptions -CONFIG_BT_CTLR_ISO_RX_BUFFERS=16 CONFIG_BT_CTLR_ISOAL_SINKS=2 +CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 # Controller with minimum ACL event length and unreserved scanning CONFIG_BT_CTLR_ADVANCED_FEATURES=y diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf index b72aaa624f1..05c9a9d3903 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_peripheral-bt_ll_sw_split.conf @@ -5,7 +5,6 @@ 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 @@ -20,21 +19,24 @@ CONFIG_BT_BUF_ACL_RX_SIZE=255 CONFIG_BT_BUF_ACL_TX_SIZE=251 CONFIG_BT_BUF_CMD_TX_SIZE=255 -# Host +# Host and Controller common dependencies CONFIG_BT_BROADCASTER=y -CONFIG_BT_PERIPHERAL=y CONFIG_BT_OBSERVER=n -CONFIG_BT_CENTRAL=n CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=n CONFIG_BT_PER_ADV_SYNC=n CONFIG_BT_ISO_BROADCASTER=n CONFIG_BT_ISO_SYNC_RECEIVER=n +CONFIG_BT_CENTRAL=n +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_MAX_CONN=1 CONFIG_BT_ISO_CENTRAL=n CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams CONFIG_BT_ISO_MAX_CHAN=2 +CONFIG_BT_ISO_TX_BUF_COUNT=1 +CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller CONFIG_BT_LL_SW_SPLIT=y @@ -44,17 +46,21 @@ CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=n CONFIG_BT_CTLR_PERIPHERAL_ISO=y +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 +CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y # ISO Transmissions -CONFIG_BT_CTLR_ISO_TX_BUFFERS=16 -CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 CONFIG_BT_CTLR_ISOAL_SOURCES=2 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=12 +CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 # ISO Receptions -CONFIG_BT_CTLR_ISO_RX_BUFFERS=16 CONFIG_BT_CTLR_ISOAL_SINKS=2 +CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 CONFIG_BT_CTLR_ADVANCED_FEATURES=y CONFIG_BT_CTLR_ADV_RESERVE_MAX=n diff --git a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf index cc3b5adecdd..51ca53e83f2 100644 --- a/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_ipc/nrf5340_cpunet_iso_receive-bt_ll_sw_split.conf @@ -5,7 +5,6 @@ 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 @@ -15,22 +14,24 @@ CONFIG_BT_HCI_RAW=y # Host number of completed commands does not follow normal flow control. CONFIG_BT_BUF_CMD_TX_COUNT=10 -# Host +# Host and Controller common dependencies CONFIG_BT_BROADCASTER=n -CONFIG_BT_PERIPHERAL=n CONFIG_BT_OBSERVER=y -CONFIG_BT_CENTRAL=n CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV_SYNC=y CONFIG_BT_ISO_SYNC_RECEIVER=y -CONFIG_BT_ISO_MAX_CHAN=2 +CONFIG_BT_ISO_MAX_CHAN=4 +CONFIG_BT_CENTRAL=n +CONFIG_BT_PERIPHERAL=n # ISO Receive Controller CONFIG_BT_LL_SW_SPLIT=y CONFIG_BT_CTLR_SYNC_PERIODIC=y CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 CONFIG_BT_CTLR_SYNC_ISO=y -CONFIG_BT_CTLR_ISO_RX_BUFFERS=16 -CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_SCAN_SYNC_ISO_SET=1 +CONFIG_BT_CTLR_SYNC_ISO_STREAM_COUNT=2 CONFIG_BT_CTLR_SYNC_ISO_STREAM_MAX=2 +CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 CONFIG_BT_CTLR_ISOAL_SINKS=2 +CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 diff --git a/samples/bluetooth/hci_uart/overlay-all-bt_ll_sw_split.conf b/samples/bluetooth/hci_uart/overlay-all-bt_ll_sw_split.conf index 3b2a93aba04..a4054de0934 100644 --- a/samples/bluetooth/hci_uart/overlay-all-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_uart/overlay-all-bt_ll_sw_split.conf @@ -10,8 +10,8 @@ CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_PER_ADV_SYNC=y CONFIG_BT_PER_ADV_SYNC_MAX=2 -CONFIG_BT_PERIPHERAL=y CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=y # Broadcast and Connected ISO CONFIG_BT_ISO_BROADCASTER=y @@ -20,7 +20,11 @@ CONFIG_BT_ISO_CENTRAL=y CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams -CONFIG_BT_ISO_MAX_CHAN=2 +CONFIG_BT_ISO_TX_MTU=310 +CONFIG_BT_ISO_RX_MTU=310 +CONFIG_BT_ISO_MAX_CHAN=4 +CONFIG_BT_ISO_TX_BUF_COUNT=1 +CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller CONFIG_BT_LL_SW_SPLIT=y @@ -49,9 +53,16 @@ CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=6 # Increase the below to receive interleaved advertising chains CONFIG_BT_CTLR_SCAN_AUX_SET=1 +# CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS=y +# CONFIG_BT_CTLR_SCAN_AUX_CHAIN_COUNT=1 CONFIG_BT_CTLR_ADV_RESERVE_MAX=n +CONFIG_BT_CTLR_ADV_ISO_RESERVE_MAX=y +CONFIG_BT_CTLR_SYNC_ISO_RESERVE_MAX=n CONFIG_BT_CTLR_CENTRAL_RESERVE_MAX=n +CONFIG_BT_CTLR_PERIPHERAL_RESERVE_MAX=n +CONFIG_BT_CTLR_PERIPHERAL_ISO_RESERVE_MAX=n +CONFIG_BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX=y CONFIG_BT_CTLR_SLOT_RESERVATION_UPDATE=n CONFIG_BT_CTLR_SCAN_UNRESERVED=y CONFIG_BT_TICKER_NEXT_SLOT_GET_MATCH=y @@ -81,31 +92,44 @@ CONFIG_BT_CTLR_DF_CONN_CTE_REQ=y # ISO Broadcaster Controller CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_ADV_PERIODIC=y +CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER=y CONFIG_BT_CTLR_ADV_ISO=y -CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 +CONFIG_BT_CTLR_ADV_ISO_SET=2 +CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4 CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=2 +CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 # ISO Receive Controller CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_SYNC_PERIODIC=y +CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER=y CONFIG_BT_CTLR_SYNC_ISO=y -CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_SCAN_SYNC_ISO_SET=1 +CONFIG_BT_CTLR_SYNC_ISO_STREAM_COUNT=2 CONFIG_BT_CTLR_SYNC_ISO_STREAM_MAX=2 +CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=y +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 +CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y # ISO Transmissions -CONFIG_BT_CTLR_ISO_TX_BUFFERS=8 +CONFIG_BT_CTLR_ISOAL_SOURCES=4 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=18 CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 -CONFIG_BT_CTLR_ISOAL_SOURCES=2 # ISO Receptions -CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 CONFIG_BT_CTLR_ISOAL_SINKS=2 +CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 # Tx Power Dynamic Control CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y + +# Ignore HCI ISO data Tx sequence numbers +# CONFIG_BT_CTLR_ISOAL_PSN_IGNORE=y diff --git a/samples/bluetooth/hci_uart_3wire/overlay-all-bt_ll_sw_split.conf b/samples/bluetooth/hci_uart_3wire/overlay-all-bt_ll_sw_split.conf index 35ac7c6525b..8a0f9d3364a 100644 --- a/samples/bluetooth/hci_uart_3wire/overlay-all-bt_ll_sw_split.conf +++ b/samples/bluetooth/hci_uart_3wire/overlay-all-bt_ll_sw_split.conf @@ -10,8 +10,8 @@ CONFIG_BT_EXT_ADV=y CONFIG_BT_PER_ADV=y CONFIG_BT_PER_ADV_SYNC=y CONFIG_BT_PER_ADV_SYNC_MAX=2 -CONFIG_BT_PERIPHERAL=y CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=y # Broadcast and Connected ISO CONFIG_BT_ISO_BROADCASTER=y @@ -20,7 +20,11 @@ CONFIG_BT_ISO_CENTRAL=y CONFIG_BT_ISO_PERIPHERAL=y # ISO Streams -CONFIG_BT_ISO_MAX_CHAN=2 +CONFIG_BT_ISO_TX_MTU=310 +CONFIG_BT_ISO_RX_MTU=310 +CONFIG_BT_ISO_MAX_CHAN=4 +CONFIG_BT_ISO_TX_BUF_COUNT=1 +CONFIG_BT_ISO_RX_BUF_COUNT=1 # Controller CONFIG_BT_LL_SW_SPLIT=y @@ -48,9 +52,16 @@ CONFIG_BT_CTLR_ADV_DATA_BUF_MAX=6 # Increase the below to receive interleaved advertising chains CONFIG_BT_CTLR_SCAN_AUX_SET=1 +# CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS=y +# CONFIG_BT_CTLR_SCAN_AUX_CHAIN_COUNT=1 CONFIG_BT_CTLR_ADV_RESERVE_MAX=n +CONFIG_BT_CTLR_ADV_ISO_RESERVE_MAX=y +CONFIG_BT_CTLR_SYNC_ISO_RESERVE_MAX=n CONFIG_BT_CTLR_CENTRAL_RESERVE_MAX=n +CONFIG_BT_CTLR_PERIPHERAL_RESERVE_MAX=n +CONFIG_BT_CTLR_PERIPHERAL_ISO_RESERVE_MAX=n +CONFIG_BT_CTLR_EVENT_OVERHEAD_RESERVE_MAX=y CONFIG_BT_CTLR_SLOT_RESERVATION_UPDATE=n CONFIG_BT_CTLR_SCAN_UNRESERVED=y CONFIG_BT_TICKER_NEXT_SLOT_GET_MATCH=y @@ -80,31 +91,44 @@ CONFIG_BT_CTLR_DF_CONN_CTE_REQ=y # ISO Broadcaster Controller CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_ADV_PERIODIC=y +CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER=y CONFIG_BT_CTLR_ADV_ISO=y -CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_ADV_ISO_SET=2 +CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4 CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=2 +CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247 # ISO Receive Controller CONFIG_BT_CTLR_ADV_EXT=y CONFIG_BT_CTLR_SYNC_PERIODIC=y +CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER=y CONFIG_BT_CTLR_SYNC_ISO=y -CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_SCAN_SYNC_ISO_SET=1 +CONFIG_BT_CTLR_SYNC_ISO_STREAM_COUNT=2 CONFIG_BT_CTLR_SYNC_ISO_STREAM_MAX=2 +CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251 # ISO Connection Oriented CONFIG_BT_CTLR_CENTRAL_ISO=y CONFIG_BT_CTLR_PERIPHERAL_ISO=y -CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=251 +CONFIG_BT_CTLR_CONN_ISO_STREAMS=2 +CONFIG_BT_CTLR_CONN_ISO_GROUPS=1 +CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2 +CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247 CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251 +CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y # ISO Transmissions -CONFIG_BT_CTLR_ISO_TX_BUFFERS=8 -CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=251 -CONFIG_BT_CTLR_ISOAL_SOURCES=2 +CONFIG_BT_CTLR_ISOAL_SOURCES=4 +CONFIG_BT_CTLR_ISO_TX_BUFFERS=18 +CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255 # ISO Receptions -CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 CONFIG_BT_CTLR_ISOAL_SINKS=2 +CONFIG_BT_CTLR_ISO_RX_BUFFERS=8 # Tx Power Dynamic Control CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y + +# Ignore HCI ISO data Tx sequence numbers +# CONFIG_BT_CTLR_ISOAL_PSN_IGNORE=y diff --git a/samples/bluetooth/iso_broadcast/src/main.c b/samples/bluetooth/iso_broadcast/src/main.c index 85460d10fdd..0086a9786de 100644 --- a/samples/bluetooth/iso_broadcast/src/main.c +++ b/samples/bluetooth/iso_broadcast/src/main.c @@ -8,9 +8,9 @@ #include #include -#define BUF_ALLOC_TIMEOUT (10) /* milliseconds */ +#define BIG_SDU_INTERVAL_US (10000) +#define BUF_ALLOC_TIMEOUT_US (BIG_SDU_INTERVAL_US * 2U) /* milliseconds */ #define BIG_TERMINATE_TIMEOUT_US (60 * USEC_PER_SEC) /* microseconds */ -#define BIG_SDU_INTERVAL_US (10000) #define BIS_ISO_CHAN_COUNT 2 NET_BUF_POOL_FIXED_DEFINE(bis_tx_pool, BIS_ISO_CHAN_COUNT, @@ -163,16 +163,14 @@ int main(void) struct net_buf *buf; int ret; - buf = net_buf_alloc(&bis_tx_pool, - K_MSEC(BUF_ALLOC_TIMEOUT)); + buf = net_buf_alloc(&bis_tx_pool, K_USEC(BUF_ALLOC_TIMEOUT_US)); if (!buf) { printk("Data buffer allocate timeout on channel" " %u\n", chan); return 0; } - ret = k_sem_take(&sem_iso_data, - K_MSEC(BUF_ALLOC_TIMEOUT)); + ret = k_sem_take(&sem_iso_data, K_USEC(BUF_ALLOC_TIMEOUT_US)); if (ret) { printk("k_sem_take for ISO data sent failed\n"); net_buf_unref(buf); diff --git a/samples/bluetooth/iso_receive/src/main.c b/samples/bluetooth/iso_receive/src/main.c index 989694907b4..b7714e08b21 100644 --- a/samples/bluetooth/iso_receive/src/main.c +++ b/samples/bluetooth/iso_receive/src/main.c @@ -22,7 +22,7 @@ #define PA_RETRY_COUNT 6 -#define BIS_ISO_CHAN_COUNT 2 +#define BIS_ISO_CHAN_COUNT MIN(2U, CONFIG_BT_ISO_MAX_CHAN) static bool per_adv_found; static bool per_adv_lost; diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index f586b53d147..63e7fb948b7 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -511,8 +511,9 @@ def get_v2_model(self, kconfig_dir, settings_file): soc_roots = self.get_module_setting_root('soc', settings_file) soc_roots.insert(0, Path(ZEPHYR_BASE)) root_args = argparse.Namespace(**{'board_roots': board_roots, - 'soc_roots': soc_roots, 'board': None}) - v2_boards = list_boards.find_v2_boards(root_args) + 'soc_roots': soc_roots, 'board': None, + 'board_dir': []}) + v2_boards = list_boards.find_v2_boards(root_args).values() with open(kconfig_defconfig_file, 'w') as fp: for board in v2_boards: @@ -546,7 +547,7 @@ def get_v2_model(self, kconfig_dir, settings_file): root_args = argparse.Namespace(**{'soc_roots': soc_roots}) v2_systems = list_hardware.find_v2_systems(root_args) - soc_folders = {soc.folder for soc in v2_systems.get_socs()} + soc_folders = {soc.folder[0] for soc in v2_systems.get_socs()} with open(kconfig_defconfig_file, 'w') as fp: for folder in soc_folders: fp.write('osource "' + (Path(folder) / 'Kconfig.defconfig').as_posix() + '"\n') @@ -616,7 +617,7 @@ def parse_kconfig(self, filename="Kconfig", hwm=None): os.makedirs(os.path.join(kconfiglib_dir, 'soc'), exist_ok=True) os.makedirs(os.path.join(kconfiglib_dir, 'arch'), exist_ok=True) - os.environ["BOARD_DIR"] = kconfiglib_boards_dir + os.environ["KCONFIG_BOARD_DIR"] = kconfiglib_boards_dir self.get_v2_model(kconfiglib_dir, os.path.join(kconfiglib_dir, "settings_file.txt")) # Tells Kconfiglib to generate warnings for all references to undefined @@ -920,6 +921,9 @@ def check_no_undef_outside_kconfig(self, kconf): # Zephyr toolchain variant and therefore not # visible to compliance. "BOARD_", # Used as regex in scripts/utils/board_v1_to_v2.py + "BOARD_MPS2_AN521_CPUTEST", # Used for board and SoC extension feature tests + "BOARD_NATIVE_SIM_NATIVE_64_TWO", # Used for board and SoC extension feature tests + "BOARD_NATIVE_SIM_NATIVE_ONE", # Used for board and SoC extension feature tests "BOOT_DIRECT_XIP", # Used in sysbuild for MCUboot configuration "BOOT_DIRECT_XIP_REVERT", # Used in sysbuild for MCUboot configuration "BOOT_FIRMWARE_LOADER", # Used in sysbuild for MCUboot configuration diff --git a/scripts/ci/test_plan.py b/scripts/ci/test_plan.py index 326068ab715..dfc87368198 100755 --- a/scripts/ci/test_plan.py +++ b/scripts/ci/test_plan.py @@ -239,7 +239,7 @@ def find_boards(self): # Look for boards in monitored repositories lb_args = argparse.Namespace(**{'arch_roots': roots, 'board_roots': roots, 'board': None, 'soc_roots':roots, 'board_dir': None}) - known_boards = list_boards.find_v2_boards(lb_args) + known_boards = list_boards.find_v2_boards(lb_args).values() for changed in changed_boards: for board in known_boards: diff --git a/scripts/kconfig/lint.py b/scripts/kconfig/lint.py index 30064c34546..5a123ded42f 100755 --- a/scripts/kconfig/lint.py +++ b/scripts/kconfig/lint.py @@ -209,7 +209,7 @@ def init_kconfig(): ZEPHYR_BASE=TOP_DIR, SOC_DIR="soc", ARCH_DIR="arch", - BOARD_DIR="boards/*/*", + KCONFIG_BOARD_DIR="boards/*/*", ARCH="*") kconf = kconfiglib.Kconfig(suppress_traceback=True) diff --git a/scripts/list_boards.py b/scripts/list_boards.py index bf716584885..443e18a1980 100755 --- a/scripts/list_boards.py +++ b/scripts/list_boards.py @@ -4,13 +4,13 @@ # SPDX-License-Identifier: Apache-2.0 import argparse -from collections import defaultdict +from collections import defaultdict, Counter from dataclasses import dataclass, field import itertools from pathlib import Path import pykwalify.core import sys -from typing import List +from typing import List, Union import yaml import list_hardware from list_hardware import unique_paths @@ -91,7 +91,8 @@ def from_soc(soc, variants): @dataclass(frozen=True) class Board: name: str - dir: Path + # HWMv1 only supports a single Path, and requires Board dataclass to be hashable. + directories: Union[Path, List[Path]] hwm: str full_name: str = None arch: str = None @@ -103,6 +104,48 @@ class Board: socs: List[Soc] = field(default_factory=list, compare=False) variants: List[str] = field(default_factory=list, compare=False) + @property + def dir(self): + # Get the main board directory. + if isinstance(self.directories, Path): + return self.directories + return self.directories[0] + + def from_qualifier(self, qualifiers): + qualifiers_list = qualifiers.split('/') + + node = Soc(None) + n = len(qualifiers_list) + if n > 0: + soc_qualifier = qualifiers_list.pop(0) + for s in self.socs: + if s.name == soc_qualifier: + node = s + break + + if n > 1: + if node.cpuclusters: + cpu_qualifier = qualifiers_list.pop(0) + for c in node.cpuclusters: + if c.name == cpu_qualifier: + node = c + break + else: + node = Variant(None) + + for q in qualifiers_list: + for v in node.variants: + if v.name == q: + node = v + break + else: + node = Variant(None) + + if node in (Soc(None), Variant(None)): + sys.exit(f'ERROR: qualifiers {qualifiers} not found when extending board {self.name}') + + return node + def board_key(board): return board.name @@ -165,11 +208,10 @@ def find_arch2board_set_in(root, arches, board_dir): for arch in arches: if not (boards / arch).is_dir(): continue - for maybe_board in (boards / arch).iterdir(): if not maybe_board.is_dir(): continue - if board_dir is not None and board_dir != maybe_board: + if board_dir and maybe_board not in board_dir: continue for maybe_defconfig in maybe_board.iterdir(): file_name = maybe_defconfig.name @@ -181,7 +223,8 @@ def find_arch2board_set_in(root, arches, board_dir): def load_v2_boards(board_name, board_yml, systems): - boards = [] + boards = {} + board_extensions = [] if board_yml.is_file(): with board_yml.open('r', encoding='utf-8') as f: b = yaml.load(f.read(), Loader=SafeLoader) @@ -199,6 +242,18 @@ def load_v2_boards(board_name, board_yml, systems): board_array = b.get('boards', [b.get('board', None)]) for board in board_array: + mutual_exclusive = {'name', 'extend'} + if len(mutual_exclusive - board.keys()) < 1: + sys.exit(f'ERROR: Malformed "board" section in file: {board_yml.as_posix()}\n' + f'{mutual_exclusive} are mutual exclusive at this level.') + + # This is a extending an existing board, place in array to allow later processing. + if 'extend' in board: + board.update({'dir': board_yml.parent}) + board_extensions.append(board) + continue + + # Create board if board_name is not None: if board['name'] != board_name: # Not the board we're looking for, ignore. @@ -220,9 +275,9 @@ def load_v2_boards(board_name, board_yml, systems): socs = [Soc.from_soc(systems.get_soc(s['name']), s.get('variants', [])) for s in board.get('socs', {})] - board = Board( + boards[board['name']] = Board( name=board['name'], - dir=board_yml.parent, + directories=[board_yml.parent], vendor=board.get('vendor'), full_name=board.get('full_name'), revision_format=board.get('revision', {}).get('format'), @@ -234,8 +289,28 @@ def load_v2_boards(board_name, board_yml, systems): variants=[Variant.from_dict(v) for v in board.get('variants', [])], hwm='v2', ) - boards.append(board) - return boards + board_qualifiers = board_v2_qualifiers(boards[board['name']]) + duplicates = [q for q, n in Counter(board_qualifiers).items() if n > 1] + if duplicates: + sys.exit(f'ERROR: Duplicated board qualifiers detected {duplicates} for board: ' + f'{board["name"]}.\nPlease check content of: {board_yml.as_posix()}\n') + return boards, board_extensions + + +def extend_v2_boards(boards, board_extensions): + for e in board_extensions: + board = boards.get(e['extend']) + if board is None: + continue + board.directories.append(e['dir']) + + for v in e.get('variants', []): + node = board.from_qualifier(v['qualifier']) + if str(v['qualifier'] + '/' + v['name']) in board_v2_qualifiers(board): + board_yml = e['dir'] / BOARD_YML + sys.exit(f'ERROR: Variant: {v["name"]}, defined multiple times for board: ' + f'{board.name}.\nLast defined in {board_yml}') + node.variants.append(Variant.from_dict(v)) # Note that this does not share the args.board functionality of find_v2_boards @@ -253,14 +328,25 @@ def find_v2_boards(args): root_args = argparse.Namespace(**{'soc_roots': args.soc_roots}) systems = list_hardware.find_v2_systems(root_args) - boards = [] + boards = {} + board_extensions = [] board_files = [] - for root in unique_paths(args.board_roots): - board_files.extend((root / 'boards').rglob(BOARD_YML)) + if args.board_dir: + board_files = [d / BOARD_YML for d in args.board_dir] + else: + for root in unique_paths(args.board_roots): + board_files.extend((root / 'boards').rglob(BOARD_YML)) for board_yml in board_files: - b = load_v2_boards(args.board, board_yml, systems) - boards.extend(b) + b, e = load_v2_boards(args.board, board_yml, systems) + conflict_boards = set(boards.keys()).intersection(b.keys()) + if conflict_boards: + sys.exit(f'ERROR: Board(s): {conflict_boards}, defined multiple times.\n' + f'Last defined in {board_yml}') + boards.update(b) + board_extensions.extend(e) + + extend_v2_boards(boards, board_extensions) return boards @@ -285,7 +371,7 @@ def add_args(parser): help='add a soc root, may be given more than once') parser.add_argument("--board", dest='board', default=None, help='lookup the specific board, fail if not found') - parser.add_argument("--board-dir", default=None, type=Path, + parser.add_argument("--board-dir", default=[], type=Path, action='append', help='Only look for boards at the specific location') @@ -327,20 +413,16 @@ def board_v2_qualifiers_csv(board): def dump_v2_boards(args): - if args.board_dir: - root_args = argparse.Namespace(**{'soc_roots': args.soc_roots}) - systems = list_hardware.find_v2_systems(root_args) - boards = load_v2_boards(args.board, args.board_dir / BOARD_YML, systems) - else: - boards = find_v2_boards(args) + boards = find_v2_boards(args) - for b in boards: + for b in boards.values(): qualifiers_list = board_v2_qualifiers(b) if args.cmakeformat is not None: notfound = lambda x: x or 'NOTFOUND' info = args.cmakeformat.format( NAME='NAME;' + b.name, - DIR='DIR;' + str(b.dir.as_posix()), + DIR='DIR;' + ';'.join( + [str(x.as_posix()) for x in b.directories]), VENDOR='VENDOR;' + notfound(b.vendor), HWM='HWM;' + b.hwm, REVISION_DEFAULT='REVISION_DEFAULT;' + notfound(b.revision_default), diff --git a/scripts/list_hardware.py b/scripts/list_hardware.py index cce6fbe9831..0a446ad7fff 100755 --- a/scripts/list_hardware.py +++ b/scripts/list_hardware.py @@ -35,6 +35,7 @@ def __init__(self, folder='', soc_yaml=None): self._socs = [] self._series = [] self._families = [] + self._extended_socs = [] if soc_yaml is None: return @@ -47,12 +48,12 @@ def __init__(self, folder='', soc_yaml=None): sys.exit(f'ERROR: Malformed yaml {soc_yaml.as_posix()}', e) for f in data.get('family', []): - family = Family(f['name'], folder, [], []) + family = Family(f['name'], [folder], [], []) for s in f.get('series', []): - series = Series(s['name'], folder, f['name'], []) + series = Series(s['name'], [folder], f['name'], []) socs = [(Soc(soc['name'], [c['name'] for c in soc.get('cpuclusters', [])], - folder, s['name'], f['name'])) + [folder], s['name'], f['name'])) for soc in s.get('socs', [])] series.socs.extend(socs) self._series.append(series) @@ -61,26 +62,36 @@ def __init__(self, folder='', soc_yaml=None): family.socs.extend(socs) socs = [(Soc(soc['name'], [c['name'] for c in soc.get('cpuclusters', [])], - folder, None, f['name'])) + [folder], None, f['name'])) for soc in f.get('socs', [])] self._socs.extend(socs) self._families.append(family) for s in data.get('series', []): - series = Series(s['name'], folder, '', []) + series = Series(s['name'], [folder], '', []) socs = [(Soc(soc['name'], [c['name'] for c in soc.get('cpuclusters', [])], - folder, s['name'], '')) + [folder], s['name'], '')) for soc in s.get('socs', [])] series.socs.extend(socs) self._series.append(series) self._socs.extend(socs) - socs = [(Soc(soc['name'], - [c['name'] for c in soc.get('cpuclusters', [])], - folder, '', '')) - for soc in data.get('socs', [])] - self._socs.extend(socs) + for soc in data.get('socs', []): + mutual_exclusive = {'name', 'extend'} + if len(mutual_exclusive - soc.keys()) < 1: + sys.exit(f'ERROR: Malformed content in SoC file: {soc_yaml}\n' + f'{mutual_exclusive} are mutual exclusive at this level.') + if soc.get('name') is not None: + self._socs.append(Soc(soc['name'], [c['name'] for c in soc.get('cpuclusters', [])], + [folder], '', '')) + elif soc.get('extend') is not None: + self._extended_socs.append(Soc(soc['extend'], + [c['name'] for c in soc.get('cpuclusters', [])], + [folder], '', '')) + else: + sys.exit(f'ERROR: Malformed "socs" section in SoC file: {soc_yaml}\n' + f'Cannot find one of required keys {mutual_exclusive}.') # Ensure that any runner configuration matches socs and cpuclusters declared in the same # soc.yml file @@ -89,25 +100,13 @@ def __init__(self, folder='', soc_yaml=None): for item_data in data['runners']['run_once'][grp]: for group in item_data['groups']: for qualifiers in group['qualifiers']: - soc_name, *components = qualifiers.split('/') + soc_name = qualifiers.split('/')[0] found_match = False - # Allow 'ns' as final qualifier until "virtual" CPUs are ported to soc.yml - # https://github.com/zephyrproject-rtos/zephyr/issues/70721 - if components and components[-1] == 'ns': - components.pop() - - for soc in self._socs: + for soc in self._socs + self._extended_socs: if re.match(fr'^{soc_name}$', soc.name) is not None: - if soc.cpuclusters and components: - check_string = '/'.join(components) - for cpucluster in soc.cpuclusters: - if re.match(fr'^{check_string}$', cpucluster) is not None: - found_match = True - break - elif not soc.cpuclusters and not components: - found_match = True - break + found_match = True + break if found_match is False: sys.exit(f'ERROR: SoC qualifier match unresolved: {qualifiers}') @@ -133,8 +132,23 @@ def from_yaml(socs_yaml): def extend(self, systems): self._families.extend(systems.get_families()) self._series.extend(systems.get_series()) + + for es in self._extended_socs[:]: + for s in systems.get_socs(): + if s.name == es.name: + s.extend(es) + self._extended_socs.remove(es) + break self._socs.extend(systems.get_socs()) + for es in systems.get_extended_socs(): + for s in self._socs: + if s.name == es.name: + s.extend(es) + break + else: + self._extended_socs.append(es) + def get_families(self): return self._families @@ -144,6 +158,9 @@ def get_series(self): def get_socs(self): return self._socs + def get_extended_socs(self): + return self._extended_socs + def get_soc(self, name): try: return next(s for s in self._socs if s.name == name) @@ -156,15 +173,20 @@ def get_soc(self, name): class Soc: name: str cpuclusters: List[str] - folder: str + folder: List[str] series: str = '' family: str = '' + def extend(self, soc): + if self.name == soc.name: + self.cpuclusters.extend(soc.cpuclusters) + self.folder.extend(soc.folder) + @dataclass class Series: name: str - folder: str + folder: List[str] family: str socs: List[Soc] @@ -172,7 +194,7 @@ class Series: @dataclass class Family: name: str - folder: str + folder: List[str] series: List[Series] socs: List[Soc] @@ -289,7 +311,7 @@ def dump_v2_system(args, type, system): info = args.cmakeformat.format( TYPE='TYPE;' + type, NAME='NAME;' + system.name, - DIR='DIR;' + Path(system.folder).as_posix(), + DIR='DIR;' + ';'.join([Path(x).as_posix() for x in system.folder]), HWM='HWM;' + 'v2' ) else: diff --git a/scripts/pylib/twister/twisterlib/environment.py b/scripts/pylib/twister/twisterlib/environment.py index e0773878ddf..0ab3022729d 100644 --- a/scripts/pylib/twister/twisterlib/environment.py +++ b/scripts/pylib/twister/twisterlib/environment.py @@ -382,7 +382,7 @@ def add_parse_arguments(parser = None): parser.add_argument( "--filter", choices=['buildable', 'runnable'], - default='buildable', + default='runnable' if "--device-testing" in sys.argv else 'buildable', help="""Filter tests to be built and executed. By default everything is built and if a test is runnable (emulation or a connected device), it is run. This option allows for example to only build tests that can diff --git a/scripts/pylib/twister/twisterlib/testplan.py b/scripts/pylib/twister/twisterlib/testplan.py index 8731522c21e..377a0dab2bb 100755 --- a/scripts/pylib/twister/twisterlib/testplan.py +++ b/scripts/pylib/twister/twisterlib/testplan.py @@ -230,11 +230,21 @@ def load(self): # Get list of connected hardware and filter tests to only be run on connected hardware. # If the platform does not exist in the hardware map or was not specified by --platform, # just skip it. - connected_list = self.options.platform + + connected_list = [] + excluded_list = [] + for _cp in self.options.platform: + if _cp in self.platform_names: + connected_list.append(self.get_platform(_cp).name) + if self.options.exclude_platform: - for excluded in self.options.exclude_platform: + for _p in self.options.exclude_platform: + if _p in self.platform_names: + excluded_list.append(self.get_platform(_p).name) + for excluded in excluded_list: if excluded in connected_list: connected_list.remove(excluded) + self.load_from_file(last_run, filter_platform=connected_list) self.selected_platforms = set(p.platform.name for p in self.instances.values()) else: @@ -432,7 +442,7 @@ def init_and_add_platforms(data, board, target, qualifier, aliases): logger.debug(f"Adding platform {platform.name} with aliases {platform.aliases}") self.platforms.append(platform) - for board in known_boards: + for board in known_boards.values(): new_config_found = False # don't load the same board data twice if not bdirs.get(board.dir): @@ -644,9 +654,6 @@ def load_from_file(self, file, filter_platform=[]): if ts.get("run_id"): instance.run_id = ts.get("run_id") - if self.options.device_testing: - self.options.filter = 'runnable' - instance.run = instance.check_runnable( self.options, self.hwm diff --git a/scripts/pylib/twister/twisterlib/twister_main.py b/scripts/pylib/twister/twisterlib/twister_main.py index f5ee03b808a..310cdc7bfdd 100644 --- a/scripts/pylib/twister/twisterlib/twister_main.py +++ b/scripts/pylib/twister/twisterlib/twister_main.py @@ -181,6 +181,15 @@ def main(options: argparse.Namespace, default_options: argparse.Namespace): tplan.create_build_dir_links() runner = TwisterRunner(tplan.instances, tplan.testsuites, env) + # FIXME: This is a workaround for the fact that the hardware map can be usng + # the short name of the platform, while the testplan is using the full name. + # + # convert platform names coming from the hardware map to the full target + # name. + # this is needed to match the platform names in the testplan. + for d in hwm.duts: + if d.platform in tplan.platform_names: + d.platform = tplan.get_platform(d.platform).name runner.duts = hwm.duts runner.run() diff --git a/scripts/schemas/board-schema.yml b/scripts/schemas/board-schema.yml index 7a2afbd566d..4c86c9d000c 100644 --- a/scripts/schemas/board-schema.yml +++ b/scripts/schemas/board-schema.yml @@ -23,17 +23,33 @@ schema;variant-schema: required: false include: variant-schema +schema;extend-variant-schema: + required: false + type: seq + sequence: + - type: map + mapping: + name: + required: true + type: str + qualifier: + required: true + type: str + schema;board-schema: type: map mapping: name: - required: true + required: false # Note: either name or extend is required, but that is handled in python type: str desc: Name of the board full_name: required: false type: str desc: Full name of the board. Typically set to the commercial name of the board. + extend: + required: false # Note: either name or extend is required, but that is handled in python + type: str vendor: required: false type: str @@ -63,7 +79,7 @@ schema;board-schema: required: true type: str socs: - required: true + required: false # Required for name:, but not for extend. type: seq sequence: - type: map @@ -73,6 +89,8 @@ schema;board-schema: type: str variants: include: variant-schema + variants: + include: extend-variant-schema type: map mapping: @@ -85,6 +103,11 @@ mapping: runners: type: map mapping: + priority: + type: int + desc: | + Priority of this flash run once configuration. The highest value data will be used + instead of any with lower priorities. If omitted, will default to 10. run_once: type: map desc: | diff --git a/scripts/schemas/soc-schema.yml b/scripts/schemas/soc-schema.yml index c13b4a4f7e0..060afea3254 100644 --- a/scripts/schemas/soc-schema.yml +++ b/scripts/schemas/soc-schema.yml @@ -24,7 +24,22 @@ schema;soc-schema: - type: map mapping: name: - required: true + required: true # Note: either name or extend is required, but that is handled in python + type: str + cpuclusters: + include: cpucluster-schema + +schema;soc-extend-schema: + required: false + type: seq + sequence: + - type: map + mapping: + name: + required: false # Note: either name or extend is required, but that is handled in python + type: str + extend: + required: false # Note: either name or extend is required, but that is handled in python type: str cpuclusters: include: cpucluster-schema @@ -60,7 +75,7 @@ mapping: series: include: series-schema socs: - include: soc-schema + include: soc-extend-schema vendor: required: false type: str @@ -73,6 +88,11 @@ mapping: runners: type: map mapping: + priority: + type: int + desc: | + Priority of this flash run once configuration. The highest value data will be used + instead of any with lower priorities. If omitted, will default to 0. run_once: type: map desc: | diff --git a/scripts/tests/twister/test_testplan.py b/scripts/tests/twister/test_testplan.py index 7241633626f..de1c9595a21 100644 --- a/scripts/tests/twister/test_testplan.py +++ b/scripts/tests/twister/test_testplan.py @@ -594,7 +594,7 @@ def test_testplan_discover( (None, None, 'load_tests.json', None, '0/4', TwisterRuntimeError, set(['lt-p1', 'lt-p3', 'lt-p4', 'lt-p2']), []), ('suffix', None, None, True, '2/4', - None, set(['ts-p4', 'ts-p2', 'ts-p3']), [2, 4]), + None, set(['ts-p4', 'ts-p2', 'ts-p1', 'ts-p3']), [2, 4]), ] @pytest.mark.parametrize( diff --git a/scripts/west_commands/boards.py b/scripts/west_commands/boards.py index 9777d377f53..6c4ee168466 100644 --- a/scripts/west_commands/boards.py +++ b/scripts/west_commands/boards.py @@ -97,7 +97,7 @@ def do_run(self, args, _): log.inf(args.format.format(name=board.name, arch=board.arch, dir=board.dir, hwm=board.hwm, qualifiers='')) - for board in list_boards.find_v2_boards(args): + for board in list_boards.find_v2_boards(args).values(): if name_re is not None and not name_re.search(board.name): continue log.inf( diff --git a/scripts/west_commands/run_common.py b/scripts/west_commands/run_common.py index 82ec7a09b9b..adfd2922fb9 100644 --- a/scripts/west_commands/run_common.py +++ b/scripts/west_commands/run_common.py @@ -42,6 +42,10 @@ # Don't change this, or output from argparse won't match up. INDENT = ' ' * 2 +IGNORED_RUN_ONCE_PRIORITY = -1 +SOC_FILE_RUN_ONCE_DEFAULT_PRIORITY = 0 +BOARD_FILE_RUN_ONCE_DEFAULT_PRIORITY = 10 + if log.VERBOSE >= log.VERBOSE_NORMAL: # Using level 1 allows sub-DEBUG levels of verbosity. The # west.log module decides whether or not to actually print the @@ -96,6 +100,13 @@ class ImagesFlashed: flashed: int = 0 total: int = 0 +@dataclass +class SocBoardFilesProcessing: + filename: str + board: bool = False + priority: int = IGNORED_RUN_ONCE_PRIORITY + yaml: object = None + def command_verb(command): return "flash" if command.name == "flash" else "debug" @@ -178,6 +189,10 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None): # images for a given board. board_image_count = defaultdict(ImagesFlashed) + highest_priority = IGNORED_RUN_ONCE_PRIORITY + highest_entry = None + check_files = [] + if user_args.context: dump_context(command, user_args, user_runner_args) return @@ -223,48 +238,58 @@ def do_run_common(command, user_args, user_runner_args, domain_file=None): # Load board flash runner configuration (if it exists) and store # single-use commands in a dictionary so that they get executed # once per unique board name. - if cache['BOARD_DIR'] not in processed_boards and 'SOC_FULL_DIR' in cache: - soc_yaml_file = Path(cache['SOC_FULL_DIR']) / 'soc.yml' - board_yaml_file = Path(cache['BOARD_DIR']) / 'board.yml' - group_type = 'boards' - - # Search for flash runner configuration, board takes priority over SoC - try: - with open(board_yaml_file, 'r') as f: - data_yaml = yaml.safe_load(f.read()) - - except FileNotFoundError: - continue - - if 'runners' not in data_yaml: - # Check SoC file - group_type = 'qualifiers' - try: - with open(soc_yaml_file, 'r') as f: - data_yaml = yaml.safe_load(f.read()) - - except FileNotFoundError: + for directory in cache.get_list('SOC_DIRECTORIES'): + if directory not in processed_boards: + check_files.append(SocBoardFilesProcessing(Path(directory) / 'soc.yml')) + processed_boards.add(directory) + + for directory in cache.get_list('BOARD_DIRECTORIES'): + if directory not in processed_boards: + check_files.append(SocBoardFilesProcessing(Path(directory) / 'board.yml', True)) + processed_boards.add(directory) + + for check in check_files: + try: + with open(check.filename, 'r') as f: + check.yaml = yaml.safe_load(f.read()) + + if 'runners' not in check.yaml: + continue + elif check.board is False and 'run_once' not in check.yaml['runners']: continue - processed_boards.add(cache['BOARD_DIR']) - - if 'runners' not in data_yaml or 'run_once' not in data_yaml['runners']: - continue - - for cmd in data_yaml['runners']['run_once']: - for data in data_yaml['runners']['run_once'][cmd]: - for group in data['groups']: - run_first = bool(data['run'] == 'first') - if group_type == 'qualifiers': - targets = [] - for target in group[group_type]: - # For SoC-based qualifiers, prepend to the beginning of the - # match to allow for matching any board name - targets.append('([^/]+)/' + target) - else: - targets = group[group_type] - - used_cmds.append(UsedFlashCommand(cmd, targets, data['runners'], run_first)) + if 'priority' in check.yaml['runners']: + check.priority = check.yaml['runners']['priority'] + else: + check.priority = BOARD_FILE_RUN_ONCE_DEFAULT_PRIORITY if check.board is True else SOC_FILE_RUN_ONCE_DEFAULT_PRIORITY + + if check.priority == highest_priority: + log.die("Duplicate flash run once configuration found with equal priorities") + + elif check.priority > highest_priority: + highest_priority = check.priority + highest_entry = check + + except FileNotFoundError: + continue + + if highest_entry is not None: + group_type = 'boards' if highest_entry.board is True else 'qualifiers' + + for cmd in highest_entry.yaml['runners']['run_once']: + for data in highest_entry.yaml['runners']['run_once'][cmd]: + for group in data['groups']: + run_first = bool(data['run'] == 'first') + if group_type == 'qualifiers': + targets = [] + for target in group[group_type]: + # For SoC-based qualifiers, prepend to the beginning of the + # match to allow for matching any board name + targets.append('([^/]+)/' + target) + else: + targets = group[group_type] + + used_cmds.append(UsedFlashCommand(cmd, targets, data['runners'], run_first)) # Reduce entries to only those having matching board names (either exact or with regex) and # remove any entries with empty board lists diff --git a/share/sysbuild/Kconfig b/share/sysbuild/Kconfig index 556462af310..69f2d4cd396 100644 --- a/share/sysbuild/Kconfig +++ b/share/sysbuild/Kconfig @@ -6,7 +6,7 @@ rsource "Kconfig.$(HWM_SCHEME)" comment "Sysbuild image configuration" -osource "$(BOARD_DIR)/Kconfig.sysbuild" +osource "$(KCONFIG_BOARD_DIR)/Kconfig.sysbuild" osource "$(KCONFIG_BINARY_DIR)/soc/Kconfig.sysbuild" menu "Modules" diff --git a/soc/espressif/common/Kconfig b/soc/espressif/common/Kconfig index 05ba9901f6e..ccb37c6fff7 100644 --- a/soc/espressif/common/Kconfig +++ b/soc/espressif/common/Kconfig @@ -32,7 +32,32 @@ config ESP_HEAP_RUNTIME ending by a last memory location that can be safely accesed (depending on a boot mode). This is a memory pool used in runtime to create a new heap memory. +config ESP32_TIMER_TASK_STACK_SIZE + int "Stack size of the high resolution ESP Timer" + default 4096 + help + Set the stack size for the internal high resolution ESP Timer + used in Wi-Fi and BLE peripherals. + +config ESP32_TIMER_TASK_PRIO + int "Task priority of the high resolution ESP Timer" + default 3 + help + Set the task priority for the internal high resolution ESP Timer + used in Wi-Fi and BLE peripherals. + +if (BT_ESP32 || WIFI_ESP32) + +config ESP32_PHY_MAX_TX_POWER + int "Max Wi-Fi/BLE TX power (dBm)" + range 10 20 + default 20 + help + Set maximum transmit power for Wi-Fi radio. Actual transmit power for high + data rates may be lower than this setting. + +endif + rsource "Kconfig.spiram" rsource "Kconfig.esptool" rsource "Kconfig.flash" -rsource "Kconfig.wifi" diff --git a/soc/espressif/common/Kconfig.esptool b/soc/espressif/common/Kconfig.esptool index 5235a207f84..b4844371971 100644 --- a/soc/espressif/common/Kconfig.esptool +++ b/soc/espressif/common/Kconfig.esptool @@ -114,7 +114,7 @@ endchoice # ESPTOOLPY_FLASHFREQ config ESPTOOLPY_FLASHFREQ_80M_DEFAULT bool - default y if SOC_SERIES_ESP32S2 || SOC_SERIES_ESP32S3 || SOC_SERIES_ESP32C3 + default y if SOC_SERIES_ESP32S2 || SOC_SERIES_ESP32S3 || SOC_SERIES_ESP32C3 || SOC_SERIES_ESP32C6 help This is an invisible item, used to define the targets that defaults to use 80MHz Flash SPI speed. diff --git a/soc/espressif/common/Kconfig.wifi b/soc/espressif/common/Kconfig.wifi deleted file mode 100644 index a52cff48583..00000000000 --- a/soc/espressif/common/Kconfig.wifi +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. -# SPDX-License-Identifier: Apache-2.0 - -if SOC_FAMILY_ESPRESSIF_ESP32 - -menu "ESP32 Wi-Fi config" - -config ESP_WIFI_MAX_THREAD_PRIORITY - int "Maximum work queue thread priority" - default 7 - help - Maximum priority of thread used for processing driver work queue items. - -config ESP32_WIFI_TIMER_TASK_PRIO - int "Wi-Fi timer task priority" - default 2 - range 0 ESP_WIFI_MAX_THREAD_PRIORITY - - -config ESP32_PHY_MAX_WIFI_TX_POWER - int "Max Wi-Fi/BLE TX power (dBm)" - range 10 20 - default 20 - help - Set maximum transmit power for Wi-Fi radio. Actual transmit power for high - data rates may be lower than this setting. - -config ESP32_PHY_MAX_TX_POWER - int - default ESP32_PHY_MAX_WIFI_TX_POWER - -choice ESP_WIFI_HEAP - prompt "Wifi adapter heap in use" - default ESP_WIFI_HEAP_RUNTIME - - config ESP_WIFI_HEAP_RUNTIME - bool "Wifi adapter use ESP runtime heap" - depends on ESP_HEAP_RUNTIME - - config ESP_WIFI_HEAP_SPIRAM - bool "Wifi adapter use SPIRAM heap" - depends on ESP_SPIRAM - - config ESP_WIFI_HEAP_SYSTEM - bool "Wifi adapter use system heap" - -endchoice # ESP_WIFI_HEAP - -endmenu # ESP32 Wi-Fi config - -endif # SOC_FAMILY_ESPRESSIF_ESP32 diff --git a/soc/espressif/esp32/default.ld b/soc/espressif/esp32/default.ld index 593c895d61e..86a25901d03 100644 --- a/soc/espressif/esp32/default.ld +++ b/soc/espressif/esp32/default.ld @@ -285,16 +285,16 @@ SECTIONS *libc.a:*(.literal .text .literal.* .text.*) *libphy.a:( .phyiram .phyiram.*) *libgcov.a:(.literal .text .literal.* .text.*) - *libzephyr.a:spi_flash_rom_patch.*(.literal .text .literal.* .text.*) /* [mapping:esp_psram] */ *libzephyr.a:mmu_psram_flash.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_psram_impl_quad.*(.literal .literal.* .text .text.*) - *libzephyr.a:esp_psram_impl_octal.*(.literal .literal.* .text .text.*) /* [mapping:hal] */ *libzephyr.a:mmu_hal.*(.literal .literal.* .text .text.*) - *libzephyr.a:cache_hal.*(.literal .text .literal.* .text.*) + *libzephyr.a:cache_utils.*(.literal .text .literal.* .text.*) + *libzephyr.a:cache_esp32.*(.literal .text .literal.* .text.*) + *libzephyr.a:cache_hal_esp32.*(.literal .text .literal.* .text.*) *libzephyr.a:ledc_hal_iram.*(.literal .literal.* .text .text.*) *libzephyr.a:i2c_hal_iram.*(.literal .literal.* .text .text.*) *libzephyr.a:wdt_hal_iram.*(.literal .literal.* .text .text.*) @@ -325,7 +325,7 @@ SECTIONS *libzephyr.a:flash_brownout_hook.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_wrap.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_hpm_enable.*(.literal .literal.* .text .text.*) - *libzephyr.a:spi_flash_oct_flash_init*(.literal .literal.* .text .text.*) + *libzephyr.a:flash_ops.*(.literal .literal.* .text .text.*) /* [mapping:esp_system] */ *libzephyr.a:esp_err.*(.literal .literal.* .text .text.*) @@ -366,6 +366,7 @@ SECTIONS *libzephyr.a:esp_rom_spiflash.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_systimer.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_wdt.*(.literal .literal.* .text .text.*) + *libzephyr.a:esp_rom_efuse.*(.literal .literal.* .text .text.*) /* [mapping:esp_mm] */ *libzephyr.a:esp_cache.*(.literal .literal.* .text .text.*) @@ -376,8 +377,8 @@ SECTIONS *libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable) #if defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.* .wifiextrairam .wifiextrairam.*) /* [mapping:esp_wifi] */ *(.literal.wifi_clock_enable_wrapper .text.wifi_clock_enable_wrapper) @@ -520,20 +521,20 @@ SECTIONS *libzephyr.a:log_output.*(.rodata .rodata.*) *libzephyr.a:loader.*(.rodata .rodata.*) *libdrivers__flash.a:flash_esp32.*(.rodata .rodata.*) - *libzephyr.a:spi_flash_rom_patch.*(.rodata .rodata.*) *libdrivers__serial.a:uart_esp32.*(.rodata .rodata.*) *libzephyr.a:esp_memory_utils.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*) /* [mapping:esp_psram] */ *libzephyr.a:mmu_psram_flash.*(.rodata .rodata.*) - *libzephyr.a:esp_psram_impl_octal.*(.rodata .rodata.*) *libzephyr.a:esp_psram_impl_quad.*(.rodata .rodata.*) /* [mapping:hal] */ *libzephyr.a:mmu_hal.*(.rodata .rodata.*) *libzephyr.a:spi_flash_hal_iram.*(.rodata .rodata.*) *libzephyr.a:spi_flash_encrypt_hal_iram.*(.rodata .rodata.*) - *libzephyr.a:cache_hal.*(.rodata .rodata.*) + *libzephyr.a:cache_utils.*(.rodata .rodata.*) + *libzephyr.a:cache_esp32.*(.rodata .rodata.*) + *libzephyr.a:cache_hal_esp32.*(.rodata .rodata.*) *libzephyr.a:ledc_hal_iram.*(.rodata .rodata.*) *libzephyr.a:i2c_hal_iram.*(.rodata .rodata.*) *libzephyr.a:wdt_hal_iram.*(.rodata .rodata.*) @@ -564,7 +565,7 @@ SECTIONS *libzephyr.a:flash_brownout_hook.*(.rodata .rodata.*) *libzephyr.a:spi_flash_wrap.*(.rodata .rodata.*) *libzephyr.a:spi_flash_hpm_enable.*(.rodata .rodata.*) - *libzephyr.a:spi_flash_oct_flash_init.*(.rodata .rodata.*) + *libzephyr.a:flash_ops.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*) /* [mapping:esp_mm] */ *libzephyr.a:esp_cache.*(.rodata .rodata.*) @@ -609,6 +610,7 @@ SECTIONS *libzephyr.a:esp_rom_spiflash.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*) *libzephyr.a:esp_rom_systimer.*(.rodata .rodata.*) *libzephyr.a:esp_rom_wdt.*(.rodata .rodata.*) + *libzephyr.a:esp_rom_efuse.*(.rodata .rodata.*) KEEP(*(.jcr)) *(.dram1 .dram1.*) @@ -855,8 +857,8 @@ SECTIONS __rom_region_start = ABSOLUTE(.); #ifndef CONFIG_ESP32_WIFI_IRAM_OPT - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.* .wifiextrairam .wifiextrairam.*) #endif #ifndef CONFIG_ESP32_WIFI_RX_IRAM_OPT diff --git a/soc/espressif/esp32/mcuboot.ld b/soc/espressif/esp32/mcuboot.ld index 8fb1c25decc..b880e2c7b34 100644 --- a/soc/espressif/esp32/mcuboot.ld +++ b/soc/espressif/esp32/mcuboot.ld @@ -54,7 +54,6 @@ SECTIONS *libzephyr.a:cbprintf_nano.*(.literal .text .literal.* .text.*) *libzephyr.a:cpu.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) - *libzephyr.a:cache_esp32.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_map.*(.literal .text .literal.* .text.*) *libzephyr.a:esp_rom_spiflash.*(.literal .text .literal.* .text.*) @@ -65,9 +64,6 @@ SECTIONS *libkernel.a:device.*(.literal .text .literal.* .text.*) *libkernel.a:timeout.*(.literal .text .literal.* .text.*) - *(.literal.bootloader_mmap .text.bootloader_mmap) - *(.literal.bootloader_munmap .text.bootloader_munmap) - *libzephyr.a:esp_loader.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) diff --git a/soc/espressif/esp32c2/default.ld b/soc/espressif/esp32c2/default.ld index 1b6ec0e6377..1805d45a472 100644 --- a/soc/espressif/esp32c2/default.ld +++ b/soc/espressif/esp32c2/default.ld @@ -178,7 +178,6 @@ SECTIONS *libkernel.a:(.literal .text .literal.* .text.*) *libgcc.a:lib2funcs.*(.literal .text .literal.* .text.*) *libdrivers__flash.a:flash_esp32.*(.literal .text .literal.* .text.*) - *libzephyr.a:spi_flash_rom_patch.*(.literal .text .literal.* .text.*) *libzephyr.a:log_noos.*(.literal .text .literal.* .text.*) *libdrivers__timer.a:esp32c2_sys_timer.*(.literal .text .literal.* .text.*) *libzephyr.a:log_core.*(.literal .text .literal.* .text.*) @@ -276,8 +275,8 @@ SECTIONS *libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable) #if defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) *libcoexist.a:(.wifi_slp_iram .wifi_slp_iram.*) /* [mapping:esp_wifi] */ @@ -421,7 +420,6 @@ SECTIONS *libzephyr.a:log_output.*(.rodata .rodata.* .srodata .srodata.*) *libdrivers__flash.a:flash_esp32.*(.rodata .rodata.* .srodata .srodata.*) *libdrivers__serial.a:uart_esp32.*(.rodata .rodata.* .srodata .srodata.*) - *libzephyr.a:spi_flash_rom_patch.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:periph_ctrl.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:loader.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:cache_utils.*(.rodata .rodata.* .srodata .srodata.*) @@ -616,8 +614,8 @@ SECTIONS __rom_region_start = ABSOLUTE(.); #if !defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) #endif /* CONFIG_ESP32_WIFI_IRAM_OPT */ #if !defined(CONFIG_ESP32_WIFI_RX_IRAM_OPT) diff --git a/soc/espressif/esp32c2/mcuboot.ld b/soc/espressif/esp32c2/mcuboot.ld index 9bbbad889a5..54aff6076c4 100644 --- a/soc/espressif/esp32c2/mcuboot.ld +++ b/soc/espressif/esp32c2/mcuboot.ld @@ -50,7 +50,6 @@ SECTIONS *libzephyr.a:cbprintf_nano.*(.literal .text .literal.* .text.*) *libzephyr.a:cpu.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) - *libzephyr.a:cache_hal.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_map.*(.literal .text .literal.* .text.*) *libzephyr.a:esp_rom_spiflash.*(.literal .text .literal.* .text.*) @@ -59,9 +58,6 @@ SECTIONS *libkernel.a:kheap.*(.literal .text .literal.* .text.*) *libkernel.a:mempool.*(.literal .text .literal.* .text.*) - *(.literal.bootloader_mmap .text.bootloader_mmap) - *(.literal.bootloader_munmap .text.bootloader_munmap) - *libzephyr.a:esp_loader.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) diff --git a/soc/espressif/esp32c3/default.ld b/soc/espressif/esp32c3/default.ld index 042e2068366..50f41b6cd99 100644 --- a/soc/espressif/esp32c3/default.ld +++ b/soc/espressif/esp32c3/default.ld @@ -238,7 +238,6 @@ SECTIONS *libkernel.a:(.literal .text .literal.* .text.*) *libgcc.a:lib2funcs.*(.literal .text .literal.* .text.*) *libdrivers__flash.a:flash_esp32.*(.literal .text .literal.* .text.*) - *libzephyr.a:spi_flash_rom_patch.*(.literal .text .literal.* .text.*) *libzephyr.a:log_noos.*(.literal .text .literal.* .text.*) *libdrivers__timer.a:esp32c3_sys_timer.*(.literal .text .literal.* .text.*) *libzephyr.a:log_core.*(.literal .text .literal.* .text.*) @@ -293,7 +292,7 @@ SECTIONS *libzephyr.a:flash_brownout_hook.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_wrap.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_hpm_enable.*(.literal .literal.* .text .text.*) - *libzephyr.a:spi_flash_oct_flash_init*(.literal .literal.* .text .text.*) + *libzephyr.a:flash_ops.*(.literal .text .literal.* .text.*) /* [mapping:esp_system] */ *libzephyr.a:esp_err.*(.literal .literal.* .text .text.*) @@ -336,8 +335,8 @@ SECTIONS *libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable) #if defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) *libcoexist.a:(.wifi_slp_iram .wifi_slp_iram.*) /* [mapping:esp_wifi] */ @@ -381,8 +380,6 @@ SECTIONS *libzephyr.a:bootloader_console.*(.literal .text .literal.* .text.*) *libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*) - *libzephyr.a:flash_ops.*(.literal .text .literal.* .text.*) - *libzephyr.a:flash_ops_esp32c3.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_encrypt.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_encryption_secure_features.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_partitions.*(.literal .text .literal.* .text.*) @@ -481,7 +478,6 @@ SECTIONS *libzephyr.a:log_output.*(.rodata .rodata.* .srodata .srodata.*) *libdrivers__flash.a:flash_esp32.*(.rodata .rodata.* .srodata .srodata.*) *libdrivers__serial.a:uart_esp32.*(.rodata .rodata.* .srodata .srodata.*) - *libzephyr.a:spi_flash_rom_patch.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:periph_ctrl.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:loader.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:cache_utils.*(.rodata .rodata.* .srodata .srodata.*) @@ -521,7 +517,7 @@ SECTIONS *libzephyr.a:flash_brownout_hook.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:spi_flash_wrap.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:spi_flash_hpm_enable.*(.rodata .rodata.* .srodata .srodata.*) - *libzephyr.a:spi_flash_oct_flash_init.*(.rodata .rodata.* .srodata .srodata.*) + *libzephyr.a:flash_ops.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:flash_qio_mode.*(.rodata .rodata.* .srodata .srodata.*) /* [mapping:esp_mm] */ @@ -580,7 +576,6 @@ SECTIONS *libzephyr.a:esp_clk.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:flash_mmap.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:flash_ops.*(.rodata .rodata.* .srodata .srodata.*) - *libzephyr.a:flash_ops_esp32c3.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:esp_gpio_reserve.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:spi_flash_hal.*(.rodata .rodata.* .srodata .srodata.*) @@ -682,8 +677,8 @@ SECTIONS __rom_region_start = ABSOLUTE(.); #if !defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) #endif /* CONFIG_ESP32_WIFI_IRAM_OPT */ #if !defined(CONFIG_ESP32_WIFI_RX_IRAM_OPT) diff --git a/soc/espressif/esp32c3/mcuboot.ld b/soc/espressif/esp32c3/mcuboot.ld index 44f075893e5..cbc727faf0b 100644 --- a/soc/espressif/esp32c3/mcuboot.ld +++ b/soc/espressif/esp32c3/mcuboot.ld @@ -50,7 +50,6 @@ SECTIONS *libzephyr.a:cbprintf_nano.*(.literal .text .literal.* .text.*) *libzephyr.a:cpu.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) - *libzephyr.a:cache_hal.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_map.*(.literal .text .literal.* .text.*) *libzephyr.a:esp_rom_spiflash.*(.literal .text .literal.* .text.*) @@ -59,9 +58,6 @@ SECTIONS *libkernel.a:kheap.*(.literal .text .literal.* .text.*) *libkernel.a:mempool.*(.literal .text .literal.* .text.*) - *(.literal.bootloader_mmap .text.bootloader_mmap) - *(.literal.bootloader_munmap .text.bootloader_munmap) - *libzephyr.a:esp_loader.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) diff --git a/soc/espressif/esp32c6/Kconfig b/soc/espressif/esp32c6/Kconfig index 7c5c00e4777..88963c36cd8 100644 --- a/soc/espressif/esp32c6/Kconfig +++ b/soc/espressif/esp32c6/Kconfig @@ -18,18 +18,6 @@ config SOC_SERIES_ESP32C6 if SOC_SERIES_ESP32C6 -config ESP32_PHY_MAX_WIFI_TX_POWER - int "Max WiFi TX power (dBm)" - range 10 20 - default 20 - help - Set maximum transmit power for WiFi radio. Actual transmit power for high - data rates may be lower than this setting. - -config ESP32_PHY_MAX_TX_POWER - int - default ESP32_PHY_MAX_WIFI_TX_POWER - config MAC_BB_PD bool "Power down MAC and baseband of Wi-Fi and Bluetooth when PHY is disabled" depends on SOC_SERIES_ESP32C6 && TICKLESS_KERNEL diff --git a/soc/espressif/esp32c6/default.ld b/soc/espressif/esp32c6/default.ld index 514c7ef058b..9cd69db8e3a 100644 --- a/soc/espressif/esp32c6/default.ld +++ b/soc/espressif/esp32c6/default.ld @@ -68,9 +68,9 @@ MEMORY mmap0_0_seg (R): org = CACHED_ORG, len = CACHED_SIZE lp_ram_seg(RW): org = LPSRAM_IRAM_START, - len = 0x4000 - RESERVE_RTC_MEM + len = 0x2000 - RESERVE_RTC_MEM - lp_reserved_seg(RW) : org = LPSRAM_IRAM_START + 0x4000 - RESERVE_RTC_MEM, + lp_reserved_seg(RW) : org = LPSRAM_IRAM_START + 0x2000 - RESERVE_RTC_MEM, len = RESERVE_RTC_MEM #ifdef CONFIG_GEN_ISR_TABLES @@ -145,35 +145,65 @@ SECTIONS .rtc.text : { . = ALIGN(4); + _rtc_fast_start = ABSOLUTE(.); + _rtc_text_start = ABSOLUTE(.); + *(.rtc.entry.text) *(.rtc.literal .rtc.text) *rtc_wake_stub*.o(.literal .text .literal.* .text.*) + . = ALIGN(4); + + _rtc_text_end = ABSOLUTE(.); } GROUP_DATA_LINK_IN(rtc_iram_seg, ROMABLE_REGION) - /* This section is required to skip rtc.text area because the text and - * data segments reflect the same address space on different buses. + /* This section located in RTC FAST Memory area. + * It holds data marked with RTC_FAST_ATTR attribute. + * See the file "esp_attr.h" for more information. */ - .rtc.dummy (NOLOAD): + .rtc.force_fast : { - . = SIZEOF(.rtc.text); - } GROUP_LINK_IN(rtc_iram_seg) + . = ALIGN(4); + _rtc_force_fast_start = ABSOLUTE(.); + + *(.rtc.force_fast .rtc.force_fast.*) + . = ALIGN(4) ; + _rtc_force_fast_end = ABSOLUTE(.); + } GROUP_DATA_LINK_IN(rtc_data_seg, ROMABLE_REGION) + /* RTC data section holds data marked with + * RTC_DATA_ATTR, RTC_RODATA_ATTR attributes. + */ .rtc.data : { _rtc_data_start = ABSOLUTE(.); *(.rtc.data) *(.rtc.rodata) - *rtc_wake_stub*.o(.data .rodata .data.* .rodata.* .bss .bss.*) _rtc_data_end = ABSOLUTE(.); } GROUP_DATA_LINK_IN(rtc_iram_seg, ROMABLE_REGION) .rtc.bss (NOLOAD) : { _rtc_bss_start = ABSOLUTE(.); - *rtc_wake_stub*.o(.bss .bss.*) - *rtc_wake_stub*.o(COMMON) + + *(.rtc.data) + *(.rtc.rodata) + _rtc_bss_end = ABSOLUTE(.); } GROUP_LINK_IN(rtc_iram_seg) + /* This section holds data that should not be initialized at power up + * and will be retained during deep sleep. + * User data marked with RTC_NOINIT_ATTR will be placed + * into this section. See the file "esp_attr.h" for more information. + */ + .rtc_noinit (NOLOAD): + { + . = ALIGN(4); + _rtc_noinit_start = ABSOLUTE(.); + *(.rtc_noinit .rtc_noinit.*) + . = ALIGN(4) ; + _rtc_noinit_end = ABSOLUTE(.); + } GROUP_LINK_IN(rtc_slow_seg) + /* This section located in RTC SLOW Memory area. * It holds data marked with RTC_SLOW_ATTR attribute. * See the file "esp_attr.h" for more information. @@ -183,12 +213,33 @@ SECTIONS . = ALIGN(4); _rtc_force_slow_start = ABSOLUTE(.); *(.rtc.force_slow .rtc.force_slow.*) - . = ALIGN(4) ; + . = ALIGN(4); _rtc_force_slow_end = ABSOLUTE(.); - } > rtc_slow_seg + } GROUP_DATA_LINK_IN(rtc_slow_seg, ROMABLE_REGION) + + /** + * This section holds RTC data that should have fixed addresses. + * The data are not initialized at power-up and are retained during deep sleep. + */ + .rtc_reserved (NOLOAD): + { + . = ALIGN(4); + _rtc_reserved_start = ABSOLUTE(.); + /* New data can only be added here to ensure existing data are not moved. + Because data have adhered to the end of the segment and code is relied on it. + >> put new data here << */ + + *(.rtc_timer_data_in_rtc_mem .rtc_timer_data_in_rtc_mem.*) + KEEP(*(.bootloader_data_rtc_mem .bootloader_data_rtc_mem.*)) + _rtc_reserved_end = ABSOLUTE(.); + } GROUP_LINK_IN(rtc_reserved_seg) - /* Get size of rtc slow data */ + /* Get size of rtc slow data based on rtc_data_location alias */ _rtc_slow_length = (_rtc_force_slow_end - _rtc_data_start); + _rtc_fast_length = (_rtc_force_fast_end - _rtc_fast_start); + + ASSERT((_rtc_slow_length <= LENGTH(rtc_slow_seg)), "RTC_SLOW segment data does not fit.") + ASSERT((_rtc_fast_length <= LENGTH(rtc_data_seg)), "RTC_FAST segment data does not fit.") /* --- END OF RTC --- */ @@ -229,7 +280,6 @@ SECTIONS *libkernel.a:(.literal .text .literal.* .text.*) *libgcc.a:lib2funcs.*(.literal .text .literal.* .text.*) *libdrivers__flash.a:flash_esp32.*(.literal .text .literal.* .text.*) - *libzephyr.a:spi_flash_rom_patch.*(.literal .text .literal.* .text.*) *libzephyr.a:log_noos.*(.literal .text .literal.* .text.*) *libdrivers__timer.a:esp32c6_sys_timer.*(.literal .text .literal.* .text.*) *libzephyr.a:log_core.*(.literal .text .literal.* .text.*) @@ -259,6 +309,8 @@ SECTIONS *libzephyr.a:wdt_hal_iram.*(.literal .text .literal.* .text.*) *libzephyr.a:systimer_hal.*(.literal .text .literal.* .text.*) *libzephyr.a:spi_flash_hal_gpspi.*(.literal .literal.* .text .text.*) + *libzephyr.a:modem_clock_hal.*(.literal .literal.* .text .text.*) + *libzephyr.a:modem_clock.*(.literal .literal.* .text .text.*) /* [mapping:soc] */ *libzephyr.a:lldesc.*(.literal .literal.* .text .text.*) @@ -284,7 +336,7 @@ SECTIONS *libzephyr.a:flash_brownout_hook.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_wrap.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_hpm_enable.*(.literal .literal.* .text .text.*) - *libzephyr.a:spi_flash_oct_flash_init*(.literal .literal.* .text .text.*) + *libzephyr.a:flash_ops.*(.literal .literal.* .text .text.*) /* [mapping:esp_system] */ *libzephyr.a:reset_reason.*(.literal .literal.* .text .text.*) @@ -303,6 +355,7 @@ SECTIONS *(.literal.rtc_vddsdio_set_config .text.rtc_vddsdio_set_config) *libzephyr.a:esp_memory_utils.*(.literal .literal.* .text .text.*) *libzephyr.a:pmu_init.*(.literal .literal.* .text .text.*) + *libzephyr.a:pmu_param.*(.literal .literal.* .text .text.*) *libzephyr.a:rtc_clk.*(.literal .literal.* .text .text.*) *libzephyr.a:rtc_clk_init.*(.literal .literal.* .text .text.*) *libzephyr.a:rtc_time.*(.literal .literal.* .text .text.*) @@ -316,17 +369,14 @@ SECTIONS *(.literal.GPIO_HOLD_MASK .text.GPIO_HOLD_MASK) /* [mapping:esp_rom] */ - *libzephyr.a:esp_rom_spiflash.*(.literal .literal.* .text .text.*) - *libzephyr.a:esp_rom_systimer.*(.literal .literal.* .text .text.*) - *libzephyr.a:esp_rom_wdt.*(.literal .literal.* .text .text.*) - *libzephyr.a:esp_rom_crc.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_sys.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_uart.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_spiflash.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_efuse.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_systimer.*(.literal .literal.* .text .text.*) - *libzephyr.a:esp_rom_regi2c_esp32c6.*(.literal .literal.* .text .text.*) + *libzephyr.a:esp_rom_wdt.*(.literal .literal.* .text .text.*) + *libzephyr.a:esp_rom_hp_regi2c_esp32c6.*(.literal .literal.* .text .text.*) *libzephyr.a:efuse_hal.*(.literal .literal.* .text .text.*) /* [mapping:esp_mm] */ @@ -338,9 +388,8 @@ SECTIONS *libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable) #if defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libcoexist.a:(.wifi_slp_iram .wifi_slp_iram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) /* [mapping:esp_wifi] */ *(.literal.wifi_clock_enable_wrapper .text.wifi_clock_enable_wrapper) @@ -383,7 +432,6 @@ SECTIONS *libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_ops.*(.literal .text .literal.* .text.*) - *libzephyr.a:flash_ops_esp32c6.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_encrypt.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_encryption_secure_features.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_partitions.*(.literal .text .literal.* .text.*) @@ -402,6 +450,8 @@ SECTIONS *libzephyr.a:secure_boot_secure_features.*(.literal .text .literal.* .text.*) *libzephyr.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*) + *libzephyr.a:regi2c_ctrl.*(.literal .text .literal.* .text.*) + *libzephyr.a:cpu_region_protect.*(.literal .text .literal.* .text.*) /* TODO: optimise */ @@ -474,7 +524,6 @@ SECTIONS *libzephyr.a:log_output.*(.rodata .rodata.* .srodata .srodata.*) *libdrivers__flash.a:flash_esp32.*(.rodata .rodata.* .srodata .srodata.*) *libdrivers__serial.a:uart_esp32.*(.rodata .rodata.* .srodata .srodata.*) - *libzephyr.a:spi_flash_rom_patch.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:periph_ctrl.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:loader.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:cache_utils.*(.rodata .rodata.* .srodata .srodata.*) @@ -489,6 +538,8 @@ SECTIONS *libzephyr.a:wdt_hal_iram.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:systimer_hal.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:spi_flash_hal_gpspi.*(.rodata .rodata.* .srodata .srodata.*) + *libzephyr.a:modem_clock_hal.*(.rodata .rodata.* .srodata .srodata.*) + *libzephyr.a:modem_clock.*(.rodata .rodata.* .srodata .srodata.*) /* [mapping:soc] */ *libzephyr.a:lldesc.*(.rodata .rodata.* .srodata .srodata.*) @@ -514,7 +565,7 @@ SECTIONS *libzephyr.a:flash_brownout_hook.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:spi_flash_wrap.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:spi_flash_hpm_enable.*(.rodata .rodata.* .srodata .srodata.*) - *libzephyr.a:spi_flash_oct_flash_init.*(.rodata .rodata.* .srodata .srodata.*) + *libzephyr.a:flash_ops.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*) *libzephyr.a:flash_qio_mode.*(.rodata .rodata.* .srodata .srodata.*) /* [mapping:esp_mm] */ @@ -538,6 +589,7 @@ SECTIONS *libzephyr.a:mspi_timing_tuning.*(.rodata .rodata.* .srodata .srodata.*) *(.rodata.sar_periph_ctrl_power_enable) *libzephyr.a:pmu_init.*(.rodata .rodata.* .srodata .srodata.*) + *libzephyr.a:pmu_param.*(.rodata .rodata.* .srodata .srodata.*) /* [mapping:esp_system] */ *libzephyr.a:reset_reason.*(.rodata .rodata.*) @@ -551,7 +603,7 @@ SECTIONS *libzephyr.a:esp_rom_spiflash.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:esp_rom_efuse.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:esp_rom_systimer.*(.rodata .rodata.* .srodata .srodata.*) - *libzephyr.a:esp_rom_regi2c_esp32c6.*(.rodata .rodata.* .srodata .srodata.*) + *libzephyr.a:esp_rom_hp_regi2c_esp32c6.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:efuse_hal.*(.rodata .rodata.* .srodata .srodata.*) . = ALIGN(4); @@ -585,7 +637,6 @@ SECTIONS *libzephyr.a:esp_clk.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:flash_mmap.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:flash_ops.*(.rodata .rodata.* .srodata .srodata.*) - *libzephyr.a:flash_ops_esp32c6.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:esp_gpio_reserve.*(.rodata .rodata.* .srodata .srodata.*) *libzephyr.a:spi_flash_hal.*(.rodata .rodata.* .srodata .srodata.*) @@ -686,8 +737,8 @@ SECTIONS __rom_region_start = ABSOLUTE(.); #if !defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) #endif /* CONFIG_ESP32_WIFI_IRAM_OPT */ #if !defined(CONFIG_ESP32_WIFI_RX_IRAM_OPT) diff --git a/soc/espressif/esp32c6/mcuboot.ld b/soc/espressif/esp32c6/mcuboot.ld index a96d80471ac..8c76315ffe3 100644 --- a/soc/espressif/esp32c6/mcuboot.ld +++ b/soc/espressif/esp32c6/mcuboot.ld @@ -48,7 +48,6 @@ SECTIONS *libzephyr.a:cbprintf_nano.*(.literal .text .literal.* .text.*) *libzephyr.a:cpu.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) - *libzephyr.a:cache_hal.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_map.*(.literal .text .literal.* .text.*) *libzephyr.a:esp_rom_spiflash.*(.literal .text .literal.* .text.*) @@ -57,9 +56,6 @@ SECTIONS *libkernel.a:kheap.*(.literal .text .literal.* .text.*) *libkernel.a:mempool.*(.literal .text .literal.* .text.*) - *(.literal.bootloader_mmap .text.bootloader_mmap) - *(.literal.bootloader_munmap .text.bootloader_munmap) - *libzephyr.a:esp_loader.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) diff --git a/soc/espressif/esp32s2/default.ld b/soc/espressif/esp32s2/default.ld index f79ea789a08..f3dfcac5015 100644 --- a/soc/espressif/esp32s2/default.ld +++ b/soc/espressif/esp32s2/default.ld @@ -362,6 +362,7 @@ SECTIONS /* [mapping:hal] */ *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) *libzephyr.a:cache_hal.*(.literal .text .literal.* .text.*) + *libzephyr.a:cache_utils.*(.literal .text .literal.* .text.*) *libzephyr.a:ledc_hal_iram.*(.literal .text .literal.* .text.*) *libzephyr.a:i2c_hal_iram.*(.literal .text .literal.* .text.*) *libzephyr.a:wdt_hal_iram.*(.literal .text .literal.* .text.*) @@ -395,6 +396,7 @@ SECTIONS *libzephyr.a:spi_flash_wrap.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_hpm_enable.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_oct_flash_init*(.literal .literal.* .text .text.*) + *libzephyr.a:flash_ops.*(.literal .literal.* .text .text.*) /* [mapping:esp_system] */ *libzephyr.a:esp_err.*(.literal .literal.* .text .text.*) @@ -438,8 +440,8 @@ SECTIONS *libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable) #if defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.*) + *libnet80211.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.* .wifiextrairam .wifiextrairam.*) *libcoexist.a:(.wifi_slp_iram .wifi_slp_iram.*) /* [mapping:esp_wifi] */ @@ -603,6 +605,7 @@ SECTIONS *libzephyr.a:spi_flash_hal_iram.*(.rodata .rodata.*) *libzephyr.a:spi_flash_encrypt_hal_iram.*(.rodata .rodata.*) *libzephyr.a:cache_hal.*(.rodata .rodata.*) + *libzephyr.a:cache_utils.*(.rodata .rodata.*) *libzephyr.a:ledc_hal_iram.*(.rodata .rodata.*) *libzephyr.a:i2c_hal_iram.*(.rodata .rodata.*) *libzephyr.a:wdt_hal_iram.*(.rodata .rodata.*) @@ -634,6 +637,7 @@ SECTIONS *libzephyr.a:spi_flash_wrap.*(.rodata .rodata.*) *libzephyr.a:spi_flash_hpm_enable.*(.rodata .rodata.*) *libzephyr.a:spi_flash_oct_flash_init.*(.rodata .rodata.*) + *libzephyr.a:flash_ops.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*) *libzephyr.a:flash_qio_mode.*(.rodata .rodata.*) /* [mapping:esp_mm] */ @@ -833,8 +837,8 @@ SECTIONS __rom_region_start = ABSOLUTE(.); #if !defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.* .wifiextrairam .wifiextrairam.*) #endif diff --git a/soc/espressif/esp32s2/mcuboot.ld b/soc/espressif/esp32s2/mcuboot.ld index 23a15b858b5..bf14afeb6a3 100644 --- a/soc/espressif/esp32s2/mcuboot.ld +++ b/soc/espressif/esp32s2/mcuboot.ld @@ -54,7 +54,6 @@ SECTIONS *libzephyr.a:cbprintf_nano.*(.literal .text .literal.* .text.*) *libzephyr.a:cpu.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) - *libzephyr.a:cache_hal.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_map.*(.literal .text .literal.* .text.*) *libzephyr.a:esp_rom_spiflash.*(.literal .text .literal.* .text.*) *libzephyr.a:heap.*(.literal .text .literal.* .text.*) @@ -68,8 +67,6 @@ SECTIONS *libzephyr.a:rtc_clk.*(.literal .literal.* .text .text.*) *libzephyr.a:rtc_clk_init.*(.literal .literal.* .text .text.*) - *(.literal.bootloader_mmap .text.bootloader_mmap) - *(.literal.bootloader_munmap .text.bootloader_munmap) *(.literal.esp_intr_disable .literal.esp_intr_disable.* .text.esp_intr_disable .text.esp_intr_disable.*) *(.literal.default_intr_handler .text.default_intr_handler .iram1.*.default_intr_handler) *(.literal.esp_log_timestamp .text.esp_log_timestamp) diff --git a/soc/espressif/esp32s2/soc_cache.c b/soc/espressif/esp32s2/soc_cache.c index 658d0a5988a..8c4e45669bf 100644 --- a/soc/espressif/esp32s2/soc_cache.c +++ b/soc/espressif/esp32s2/soc_cache.c @@ -24,7 +24,9 @@ /* * Data Cache definitions */ -#if defined(CONFIG_ESP32S2_DATA_CACHE_8KB) +#if defined(CONFIG_ESP32S2_DATA_CACHE_0KB) +#define ESP32S2_DCACHE_SIZE CACHE_SIZE_0KB +#elif defined(CONFIG_ESP32S2_DATA_CACHE_8KB) #define ESP32S2_DCACHE_SIZE CACHE_SIZE_8KB #else #define ESP32S2_DCACHE_SIZE CACHE_SIZE_16KB @@ -66,7 +68,10 @@ void IRAM_ATTR esp_config_data_cache_mode(void) cache_line_size_t cache_line_size; #if CONFIG_ESP32S2_INSTRUCTION_CACHE_8KB -#if CONFIG_ESP32S2_DATA_CACHE_8KB +#if CONFIG_ESP32S2_DATA_CACHE_0KB + Cache_Allocate_SRAM(CACHE_MEMORY_ICACHE_LOW, CACHE_MEMORY_INVALID, CACHE_MEMORY_INVALID, + CACHE_MEMORY_INVALID); +#elif CONFIG_ESP32S2_DATA_CACHE_8KB esp_rom_Cache_Allocate_SRAM(CACHE_MEMORY_ICACHE_LOW, CACHE_MEMORY_DCACHE_LOW, CACHE_MEMORY_INVALID, CACHE_MEMORY_INVALID); #else @@ -74,7 +79,10 @@ void IRAM_ATTR esp_config_data_cache_mode(void) CACHE_MEMORY_DCACHE_HIGH, CACHE_MEMORY_INVALID); #endif #else -#if CONFIG_ESP32S2_DATA_CACHE_8KB +#if CONFIG_ESP32S2_DATA_CACHE_0KB + Cache_Allocate_SRAM(CACHE_MEMORY_ICACHE_LOW, CACHE_MEMORY_ICACHE_HIGH, CACHE_MEMORY_INVALID, + CACHE_MEMORY_INVALID); +#elif CONFIG_ESP32S2_DATA_CACHE_8KB esp_rom_Cache_Allocate_SRAM(CACHE_MEMORY_ICACHE_LOW, CACHE_MEMORY_ICACHE_HIGH, CACHE_MEMORY_DCACHE_LOW, CACHE_MEMORY_INVALID); #else diff --git a/soc/espressif/esp32s3/default.ld b/soc/espressif/esp32s3/default.ld index 487b084b03d..17d865cf526 100644 --- a/soc/espressif/esp32s3/default.ld +++ b/soc/espressif/esp32s3/default.ld @@ -160,7 +160,7 @@ SECTIONS . = ALIGN(4); _rtc_fast_start = ABSOLUTE(.); _rtc_text_start = ABSOLUTE(.); - *(.rtc.literal .rtc.text) + *(.rtc.entry.literal .rtc.text) *(.rtc.entry.text) _rtc_text_end = ABSOLUTE(.); } GROUP_DATA_LINK_IN(rtc_iram_seg, ROMABLE_REGION) @@ -350,7 +350,8 @@ SECTIONS *libzephyr.a:flash_brownout_hook.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_wrap.*(.literal .literal.* .text .text.*) *libzephyr.a:spi_flash_hpm_enable.*(.literal .literal.* .text .text.*) - *libzephyr.a:spi_flash_oct_flash_init*(.literal .literal.* .text .text.*) + *libzephyr.a:spi_flash_oct_flash_init.*(.literal .literal.* .text .text.*) + *libzephyr.a:flash_ops.*(.literal .literal.* .text .text.*) /* [mapping:esp_system] */ *libzephyr.a:esp_err.*(.literal .literal.* .text .text.*) @@ -381,9 +382,11 @@ SECTIONS /* [mapping:esp_rom] */ *libzephyr.a:esp_rom_cache_esp32s2_esp32s3.*(.literal .literal.* .text .text.*) + *libzephyr.a:cache_utils.*(.literal .text .literal.* .text.*) *libzephyr.a:esp_rom_spiflash.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_systimer.*(.literal .literal.* .text .text.*) *libzephyr.a:esp_rom_wdt.*(.literal .literal.* .text .text.*) + *libzephyr.a:esp_rom_efuse.*(.literal .literal.* .text .text.*) /* [mapping:esp_mm] */ *libzephyr.a:esp_cache.*(.literal .literal.* .text .text.*) @@ -393,8 +396,8 @@ SECTIONS *libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable) #if defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.*) + *libnet80211.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.* .wifiextrairam .wifiextrairam.*) *libcoexist.a:(.wifi_slp_iram .wifi_slp_iram.*) /* [mapping:esp_wifi] */ @@ -589,6 +592,7 @@ SECTIONS *libzephyr.a:spi_flash_hpm_enable.*(.rodata .rodata.*) *libzephyr.a:spi_flash_oct_flash_init.*(.rodata .rodata.*) *libzephyr.a:flash_qio_mode.*(.rodata .rodata.*) + *libzephyr.a:flash_ops.*(.rodata .rodata.*) /* [mapping:esp_mm] */ *libzephyr.a:esp_cache.*(.rodata .rodata.*) @@ -616,9 +620,11 @@ SECTIONS /* [mapping:esp_rom] */ *libzephyr.a:esp_rom_cache_esp32s2_esp32s3.*(.rodata .rodata.*) + *libzephyr.a:cache_utils.*(.rodata .rodata.*) *libzephyr.a:esp_rom_spiflash.*(.rodata .rodata.*) *libzephyr.a:esp_rom_systimer.*(.rodata .rodata.*) *libzephyr.a:esp_rom_wdt.*(.rodata .rodata.*) + *libzephyr.a:esp_rom_efuse.*(.rodata .rodata.*) /* [mapping:esp_system] */ *libzephyr.a:esp_err.*(.rodata .rodata.*) @@ -761,8 +767,8 @@ SECTIONS __rom_region_start = ABSOLUTE(.); #if !defined(CONFIG_ESP32_WIFI_IRAM_OPT) - *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.*) - *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.*) + *libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*) + *libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.* .wifiextrairam .wifiextrairam.*) #endif #if !defined(CONFIG_ESP32_WIFI_RX_IRAM_OPT) diff --git a/soc/espressif/esp32s3/mcuboot.ld b/soc/espressif/esp32s3/mcuboot.ld index 46a3c0c3168..f0fb717d5d9 100644 --- a/soc/espressif/esp32s3/mcuboot.ld +++ b/soc/espressif/esp32s3/mcuboot.ld @@ -57,7 +57,6 @@ SECTIONS *libzephyr.a:cbprintf_nano.*(.literal .text .literal.* .text.*) *libzephyr.a:cpu.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) - *libzephyr.a:cache_hal.*(.literal .text .literal.* .text.*) *libzephyr.a:flash_map.*(.literal .text .literal.* .text.*) *libzephyr.a:esp_rom_spiflash.*(.literal .text .literal.* .text.*) @@ -68,9 +67,6 @@ SECTIONS *libkernel.a:device.*(.literal .text .literal.* .text.*) *libkernel.a:timeout.*(.literal .text .literal.* .text.*) - *(.literal.bootloader_mmap .text.bootloader_mmap) - *(.literal.bootloader_munmap .text.bootloader_munmap) - *libzephyr.a:esp_loader.*(.literal .text .literal.* .text.*) *libzephyr.a:mmu_hal.*(.literal .text .literal.* .text.*) diff --git a/soc/espressif/esp32s3/soc.c b/soc/espressif/esp32s3/soc.c index 538a811aa6f..a1349b61db0 100644 --- a/soc/espressif/esp32s3/soc.c +++ b/soc/espressif/esp32s3/soc.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #if CONFIG_ESP_SPIRAM diff --git a/soc/espressif/esp32s3/soc.h b/soc/espressif/esp32s3/soc.h index 2cb247ca489..1d6d2204cf4 100644 --- a/soc/espressif/esp32s3/soc.h +++ b/soc/espressif/esp32s3/soc.h @@ -73,8 +73,4 @@ extern int esp_rom_Cache_Ibus_MMU_Set(uint32_t ext_ram, uint32_t vaddr, uint32_t extern uint8_t esp_rom_i2c_readReg(uint8_t block, uint8_t host_id, uint8_t reg_add); extern void esp_rom_i2c_writeReg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data); -/* cache initialization functions */ -void esp_config_instruction_cache_mode(void); -void esp_config_data_cache_mode(void); - #endif /* __SOC_H__ */ diff --git a/soc/espressif/esp32s3/soc_cache.c b/soc/espressif/esp32s3/soc_cache.c index 65330b2f939..a80d0ca8d87 100644 --- a/soc/espressif/esp32s3/soc_cache.c +++ b/soc/espressif/esp32s3/soc_cache.c @@ -26,12 +26,11 @@ void IRAM_ATTR esp_config_instruction_cache_mode(void) rom_config_instruction_cache_mode(CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE, CONFIG_ESP32S3_ICACHE_ASSOCIATED_WAYS, CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_SIZE); - - Cache_Suspend_DCache(); } void IRAM_ATTR esp_config_data_cache_mode(void) { + Cache_Suspend_DCache(); rom_config_data_cache_mode(CONFIG_ESP32S3_DATA_CACHE_SIZE, CONFIG_ESP32S3_DCACHE_ASSOCIATED_WAYS, CONFIG_ESP32S3_DATA_CACHE_LINE_SIZE); diff --git a/soc/st/stm32/stm32wb0x/soc.c b/soc/st/stm32/stm32wb0x/soc.c index 546ae1a6195..49e42f59d81 100644 --- a/soc/st/stm32/stm32wb0x/soc.c +++ b/soc/st/stm32/stm32wb0x/soc.c @@ -41,16 +41,9 @@ uint32_t SystemCoreClock = 16000000U; Z_GENERIC_SECTION("stm32wb0_RAM_VR") __used RAM_VR_TypeDef RAM_VR; -/** Power Controller node */ +/** Power Controller node (shorthand for upcoming macros) */ #define PWRC DT_INST(0, st_stm32wb0_pwr) -/** SMPS modes */ -#define STM32WB0_SMPS_MODE_OFF 0 -#define STM32WB0_SMPS_MODE_PRECHARGE 1 -#define STM32WB0_SMPS_MODE_RUN 2 - -#define SMPS_MODE _CONCAT(STM32WB0_SMPS_MODE_, DT_STRING_UNQUOTED(PWRC, smps_mode)) - /* Convert DTS properties to LL macros */ #define SMPS_PRESCALER _CONCAT(LL_RCC_SMPS_DIV_, DT_PROP(PWRC, smps_clock_prescaler)) diff --git a/soc/st/stm32/stm32wb0x/soc.h b/soc/st/stm32/stm32wb0x/soc.h index 57d14e761c3..8361f7258e8 100644 --- a/soc/st/stm32/stm32wb0x/soc.h +++ b/soc/st/stm32/stm32wb0x/soc.h @@ -17,6 +17,17 @@ #include +/** SMPS modes */ +#define STM32WB0_SMPS_MODE_OFF 0 +#define STM32WB0_SMPS_MODE_PRECHARGE 1 +#define STM32WB0_SMPS_MODE_RUN 2 + +/** Active SMPS mode (provided here for usage in drivers) */ +#define SMPS_MODE _CONCAT(STM32WB0_SMPS_MODE_, \ + DT_STRING_UNQUOTED( \ + DT_INST(0, st_stm32wb0_pwr), \ + smps_mode)) + #endif /* !_ASMLANGUAGE */ #endif /* _STM32WB0_SOC_H_ */ diff --git a/soc/st/stm32/stm32wbax/CMakeLists.txt b/soc/st/stm32/stm32wbax/CMakeLists.txt index 0c970756442..6872ff696f9 100644 --- a/soc/st/stm32/stm32wbax/CMakeLists.txt +++ b/soc/st/stm32/stm32wbax/CMakeLists.txt @@ -12,10 +12,10 @@ zephyr_sources_ifdef(CONFIG_PM if(CONFIG_BT_STM32WBA) zephyr_include_directories(hci_if) - zephyr_sources(hci_if/linklayer_plat.c) + zephyr_sources(hci_if/linklayer_plat_adapt.c) zephyr_sources(hci_if/bleplat.c) zephyr_sources(hci_if/host_stack_if.c) - zephyr_sources(hci_if/ll_sys_if.c) + zephyr_sources(hci_if/ll_sys_if_adapt.c) zephyr_sources(hci_if/stm32_timer.c) endif() diff --git a/soc/st/stm32/stm32wbax/Kconfig b/soc/st/stm32/stm32wbax/Kconfig index 1b1418e048a..cebc0fd7e22 100644 --- a/soc/st/stm32/stm32wbax/Kconfig +++ b/soc/st/stm32/stm32wbax/Kconfig @@ -14,5 +14,6 @@ config SOC_SERIES_STM32WBAX select CPU_CORTEX_M_HAS_DWT select HAS_STM32CUBE select USE_STM32_HAL_PWR_EX + select USE_STM32_HAL_CORTEX select HAS_PM select SOC_EARLY_INIT_HOOK diff --git a/soc/st/stm32/stm32wbax/hci_if/linklayer_plat.c b/soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c similarity index 81% rename from soc/st/stm32/stm32wbax/hci_if/linklayer_plat.c rename to soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c index 4f99a3e6848..b482c0b86fc 100644 --- a/soc/st/stm32/stm32wbax/hci_if/linklayer_plat.c +++ b/soc/st/stm32/stm32wbax/hci_if/linklayer_plat_adapt.c @@ -4,22 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include #include -#include -#include #include #include -#include - -#include - -#include #include "scm.h" #define LOG_LEVEL CONFIG_SOC_LOG_LEVEL -LOG_MODULE_REGISTER(linklayer_plat); +LOG_MODULE_REGISTER(linklayer_plat_adapt); #define RADIO_INTR_PRIO_HIGH_Z (RADIO_INTR_PRIO_HIGH + _IRQ_PRIO_OFFSET) #define RADIO_INTR_PRIO_LOW_Z (RADIO_INTR_PRIO_LOW + _IRQ_PRIO_OFFSET) @@ -36,52 +28,17 @@ extern const struct device *rng_dev; volatile int32_t prio_high_isr_counter; volatile int32_t prio_low_isr_counter; volatile int32_t prio_sys_isr_counter; -volatile int32_t irq_counter; volatile uint32_t local_basepri_value; /* Radio SW low ISR global variable */ volatile uint8_t radio_sw_low_isr_is_running_high_prio; -void LINKLAYER_PLAT_ClockInit(void) -{ - LL_PWR_EnableBkUpAccess(); - - /* Select LSE as Sleep CLK */ - __HAL_RCC_RADIOSLPTIM_CONFIG(RCC_RADIOSTCLKSOURCE_LSE); - - LL_PWR_DisableBkUpAccess(); - - /* Enable AHB5ENR peripheral clock (bus CLK) */ - __HAL_RCC_RADIO_CLK_ENABLE(); -} void LINKLAYER_PLAT_DelayUs(uint32_t delay) { k_busy_wait(delay); } -void LINKLAYER_PLAT_WaitHclkRdy(void) -{ - while (HAL_RCCEx_GetRadioBusClockReadiness() != RCC_RADIO_BUS_CLOCK_READY) { - } -} - -void LINKLAYER_PLAT_AclkCtrl(uint8_t enable) -{ - LOG_DBG("enable: %d", enable); - if (enable) { - /* Enable RADIO baseband clock (active CLK) */ - HAL_RCCEx_EnableRadioBBClock(); - - /* Polling on HSE32 activation */ - while (LL_RCC_HSE_IsReady() == 0) { - } - } else { - /* Disable RADIO baseband clock (active CLK) */ - HAL_RCCEx_DisableRadioBBClock(); - } -} - void LINKLAYER_PLAT_GetRNG(uint8_t *ptr_rnd, uint32_t len) { int ret; @@ -191,22 +148,6 @@ void LINKLAYER_PLAT_TriggerSwLowIT(uint8_t priority) NVIC_SetPendingIRQ((IRQn_Type)RADIO_SW_LOW_INTR_NUM); } -void LINKLAYER_PLAT_EnableIRQ(void) -{ - irq_counter = MAX(0, irq_counter - 1); - - if (irq_counter == 0) { - __enable_irq(); - } -} - -void LINKLAYER_PLAT_DisableIRQ(void) -{ - __disable_irq(); - - irq_counter++; -} - void LINKLAYER_PLAT_Assert(uint8_t condition) { __ASSERT_NO_MSG(condition); @@ -267,16 +208,6 @@ void LINKLAYER_PLAT_DisableSpecificIRQ(uint8_t isr_type) } } -void LINKLAYER_PLAT_EnableRadioIT(void) -{ - irq_enable((IRQn_Type)RADIO_INTR_NUM); -} - -void LINKLAYER_PLAT_DisableRadioIT(void) -{ - irq_disable((IRQn_Type)RADIO_INTR_NUM); -} - void LINKLAYER_PLAT_StartRadioEvt(void) { __HAL_RCC_RADIO_CLK_SLEEP_ENABLE(); diff --git a/soc/st/stm32/stm32wbax/hci_if/ll_sys_if.c b/soc/st/stm32/stm32wbax/hci_if/ll_sys_if_adapt.c similarity index 77% rename from soc/st/stm32/stm32wbax/hci_if/ll_sys_if.c rename to soc/st/stm32/stm32wbax/hci_if/ll_sys_if_adapt.c index 8607cbbafd8..df0342ff1f1 100644 --- a/soc/st/stm32/stm32wbax/hci_if/ll_sys_if.c +++ b/soc/st/stm32/stm32wbax/hci_if/ll_sys_if_adapt.c @@ -8,12 +8,9 @@ #include #define LOG_LEVEL CONFIG_SOC_LOG_LEVEL -LOG_MODULE_REGISTER(ll_sys_if); +LOG_MODULE_REGISTER(ll_sys_if_adapt); -#include "ll_intf.h" #include "ll_sys.h" -#include "linklayer_plat.h" -#include "app_conf.h" extern struct k_mutex ble_ctlr_stack_mutex; extern struct k_work_q ll_work_q; @@ -40,8 +37,3 @@ void ll_sys_bg_process_init(void) { k_work_init(&ll_sys_work, &ll_sys_bg_process_handler); } - -void ll_sys_config_params(void) -{ - ll_intf_config_ll_ctx_params(USE_RADIO_LOW_ISR, NEXT_EVENT_SCHEDULING_FROM_ISR); -} diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c index 42c57790516..2b17807f217 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync_iso.c @@ -526,6 +526,7 @@ static void isr_rx(void *param) uint16_t data_chan_id; uint8_t data_chan_use; uint8_t crc_init[3]; + uint8_t stream_curr; uint8_t rssi_ready; uint32_t start_us; uint8_t new_burst; @@ -553,6 +554,9 @@ static void isr_rx(void *param) /* BIS index */ bis_idx = lll->bis_curr - 1U; + /* Current stream */ + stream_curr = lll->stream_curr; + goto isr_rx_done; } @@ -587,6 +591,9 @@ static void isr_rx(void *param) /* BIS index */ bis_idx = lll->bis_curr - 1U; + /* Current stream */ + stream_curr = lll->stream_curr; + /* Check CRC and generate ISO Data PDU */ if (crc_ok) { struct lll_sync_iso_stream *sync_stream; @@ -648,14 +655,14 @@ static void isr_rx(void *param) } /* Get reference to stream context */ - stream_handle = lll->stream_handle[lll->stream_curr]; + stream_handle = lll->stream_handle[stream_curr]; sync_stream = ull_sync_iso_lll_stream_get(stream_handle); /* Store the received PDU if selected stream and not already * received (say in previous event as pre-transmitted PDU. */ if ((lll->bis_curr == sync_stream->bis_index) && pdu->len && - !lll->payload[bis_idx][payload_index]) { + !lll->payload[stream_curr][payload_index]) { uint16_t handle; if (IS_ENABLED(CONFIG_BT_CTLR_BROADCAST_ISO_ENC) && @@ -679,7 +686,7 @@ static void isr_rx(void *param) handle = LL_BIS_SYNC_HANDLE_FROM_IDX(stream_handle); isr_rx_iso_data_valid(lll, handle, node_rx); - lll->payload[bis_idx][payload_index] = node_rx; + lll->payload[stream_curr][payload_index] = node_rx; } } @@ -724,7 +731,7 @@ static void isr_rx(void *param) } /* Check if (bn_curr)th Rx PDU has been received */ - if (!lll->payload[bis_idx][payload_index]) { + if (!lll->payload[stream_curr][payload_index]) { /* Receive the (bn_curr)th Rx PDU of bis_curr */ bis = lll->bis_curr; @@ -767,7 +774,7 @@ static void isr_rx(void *param) /* Check if (irc_curr)th bn = 1 Rx PDU has been * received. */ - if (!lll->payload[bis_idx][payload_index]) { + if (!lll->payload[stream_curr][payload_index]) { /* Receive the (irc_curr)th bn = 1 Rx PDU of * bis_curr. */ @@ -816,14 +823,13 @@ static void isr_rx(void *param) /* Next BIS */ if (lll->bis_curr < lll->num_bis) { - const uint8_t stream_curr = lll->stream_curr + 1U; struct lll_sync_iso_stream *sync_stream; uint16_t stream_handle; /* Next selected stream */ - if (stream_curr < lll->stream_count) { - lll->stream_curr = stream_curr; - stream_handle = lll->stream_handle[lll->stream_curr]; + if ((lll->stream_curr + 1U) < lll->stream_count) { + stream_curr = ++lll->stream_curr; + stream_handle = lll->stream_handle[stream_curr]; sync_stream = ull_sync_iso_lll_stream_get(stream_handle); if (sync_stream->bis_index <= lll->num_bis) { uint32_t payload_offset; @@ -859,7 +865,7 @@ static void isr_rx(void *param) /* Check if (irc_curr)th bn = 1 Rx PDU has been * received. */ - if (!lll->payload[bis_idx_new][payload_index]) { + if (!lll->payload[stream_curr][payload_index]) { /* bn = 1 Rx PDU not received */ skipped = (bis_idx_new - bis_idx) * ((lll->bn * lll->irc) + @@ -1165,14 +1171,16 @@ static void isr_rx_done(void *param) /* Catchup with ISO event latencies */ latency_event = lll->latency_event; do { - lll->stream_curr = 0U; + uint8_t stream_curr; + + stream_curr = 0U; for (bis_idx = 0U; bis_idx < lll->num_bis; bis_idx++) { struct lll_sync_iso_stream *stream; - uint8_t payload_tail; - uint8_t stream_curr; + uint8_t stream_curr_inc; uint16_t stream_handle; + uint8_t payload_tail; - stream_handle = lll->stream_handle[lll->stream_curr]; + stream_handle = lll->stream_handle[stream_curr]; stream = ull_sync_iso_lll_stream_get(stream_handle); /* Skip BIS indices not synchronized. bis_index is 0x01 to 0x1F, * where as bis_idx is 0 indexed. @@ -1184,9 +1192,9 @@ static void isr_rx_done(void *param) payload_tail = lll->payload_tail; bn = lll->bn; while (bn--) { - if (lll->payload[bis_idx][payload_tail]) { - node_rx = lll->payload[bis_idx][payload_tail]; - lll->payload[bis_idx][payload_tail] = NULL; + if (lll->payload[stream_curr][payload_tail]) { + node_rx = lll->payload[stream_curr][payload_tail]; + lll->payload[stream_curr][payload_tail] = NULL; iso_rx_put(node_rx->hdr.link, node_rx); } else { @@ -1221,9 +1229,9 @@ static void isr_rx_done(void *param) payload_tail = payload_index; } - stream_curr = lll->stream_curr + 1U; - if (stream_curr < lll->stream_count) { - lll->stream_curr = stream_curr; + stream_curr_inc = stream_curr + 1U; + if (stream_curr_inc < lll->stream_count) { + stream_curr = stream_curr_inc; } } lll->payload_tail = payload_index; diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp.c b/subsys/bluetooth/controller/ll_sw/ull_llcp.c index 14754090934..0f9877ecc84 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp.c @@ -1072,7 +1072,7 @@ uint8_t ull_cp_periodic_sync(struct ll_conn *conn, struct ll_sync_set *sync, interval = sync->interval; addr_type = sync->peer_id_addr_type; - if (sync->peer_addr_resolved) { + if (IS_ENABLED(CONFIG_BT_CTLR_PRIVACY) && sync->peer_addr_resolved) { uint8_t rl_idx; /* peer_id_addr contains the identity address; Get the peers RPA */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_past.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_past.c index a1d3887d115..8b8f88147e0 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_past.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_past.c @@ -12,36 +12,42 @@ #include "hal/ccm.h" #include "hal/debug.h" -#include "util/memq.h" #include "util/util.h" +#include "util/memq.h" +#include "util/dbuf.h" #include "pdu_df.h" #include "lll/pdu_vendor.h" #include "pdu.h" + #include "lll.h" -#include "lll_conn.h" +#include "lll/lll_df_types.h" #include "lll_filter.h" +#include "lll_scan.h" +#include "lll_sync.h" +#include "lll_sync_iso.h" +#include "lll_conn.h" +#include "lll_conn_iso.h" + #include "ull_tx_queue.h" -#include "ull_conn_types.h" -#include "ull_llcp_internal.h" + #include "isoal.h" +#include "ull_scan_types.h" +#include "ull_sync_types.h" #include "ull_iso_types.h" -#include "lll_conn_iso.h" +#include "ull_conn_types.h" #include "ull_conn_iso_types.h" -#include "lll_sync.h" -#include "lll_sync_iso.h" -#include "ull_sync_types.h" -#include "lll_scan.h" -#include "ull_scan_types.h" -#include "ull_llcp.h" -#include "ull_internal.h" -#include "ull_conn_internal.h" -#include "ull_sync_internal.h" #include "ll_settings.h" #include "ll_feat.h" + +#include "ull_llcp.h" #include "ull_llcp_features.h" +#include "ull_internal.h" +#include "ull_sync_internal.h" +#include "ull_conn_internal.h" +#include "ull_llcp_internal.h" #if defined(CONFIG_BT_CTLR_SYNC_TRANSFER_RECEIVER) /* LLCP Remote Procedure FSM states */ diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 6a19f79c31b..4606c8c9b1f 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include #include +#include #if DT_HAS_CHOSEN(zephyr_bt_hci) #include #else @@ -263,6 +265,12 @@ void bt_send_one_host_num_completed_packets(uint16_t handle) BT_ASSERT_MSG(err == 0, "Unable to send Host NCP (err %d)", err); } +#if defined(CONFIG_BT_TESTING) +__weak void bt_testing_trace_event_acl_pool_destroy(struct net_buf *buf) +{ +} +#endif + #if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL) void bt_hci_host_num_completed_packets(struct net_buf *buf) { @@ -270,6 +278,10 @@ void bt_hci_host_num_completed_packets(struct net_buf *buf) struct bt_conn *conn; uint8_t index = acl(buf)->index; + if (IS_ENABLED(CONFIG_BT_TESTING)) { + bt_testing_trace_event_acl_pool_destroy(buf); + } + net_buf_destroy(buf); if (acl(buf)->host_ncp_sent) { diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index 3b5cfe82864..d280db5363c 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -2566,6 +2567,7 @@ static void l2cap_chan_le_recv_seg_direct(struct bt_l2cap_le_chan *chan, struct static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan, struct net_buf *buf) { + struct net_buf *owned_ref; uint16_t sdu_len; int err; @@ -2639,7 +2641,13 @@ static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan, return; } - err = chan->chan.ops->recv(&chan->chan, buf); + owned_ref = net_buf_ref(buf); + err = chan->chan.ops->recv(&chan->chan, owned_ref); + if (err != -EINPROGRESS) { + net_buf_unref(owned_ref); + owned_ref = NULL; + } + if (err < 0) { if (err != -EINPROGRESS) { LOG_ERR("err %d", err); @@ -3139,7 +3147,7 @@ static int bt_l2cap_dyn_chan_send(struct bt_l2cap_le_chan *le_chan, struct net_b /* Call `net_buf_reserve(buf, BT_L2CAP_SDU_CHAN_SEND_RESERVE)` * when allocating buffers intended for bt_l2cap_chan_send(). */ - LOG_DBG("Not enough headroom in buf %p", buf); + LOG_ERR("Not enough headroom in buf %p", buf); return -EINVAL; } @@ -3187,7 +3195,7 @@ int bt_l2cap_chan_send(struct bt_l2cap_chan *chan, struct net_buf *buf) LOG_DBG("chan %p buf %p len %zu", chan, buf, buf->len); if (buf->ref != 1) { - LOG_DBG("Expecting 1 ref, got %d", buf->ref); + LOG_WRN("Expecting 1 ref, got %d", buf->ref); return -EINVAL; } diff --git a/tests/bluetooth/common/testlib/include/testlib/addr.h b/tests/bluetooth/common/testlib/include/testlib/addr.h new file mode 100644 index 00000000000..2f9e49488b7 --- /dev/null +++ b/tests/bluetooth/common/testlib/include/testlib/addr.h @@ -0,0 +1,20 @@ +/* Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_TESTS_BLUETOOTH_COMMON_TESTLIB_INCLUDE_TESTLIB_ADDR_H_ +#define ZEPHYR_TESTS_BLUETOOTH_COMMON_TESTLIB_INCLUDE_TESTLIB_ADDR_H_ + +#include + +#include +#include + +/** Bluetooth LE static random address */ +#define BT_TESTLIB_ADDR_LE_RANDOM_C0_00_00_00_00_(last) \ + ((bt_addr_le_t){ \ + .type = BT_ADDR_LE_RANDOM, \ + .a = {{last, 0x00, 0x00, 0x00, 0x00, 0xc0}}, \ + }) + +#endif /* ZEPHYR_TESTS_BLUETOOTH_COMMON_TESTLIB_INCLUDE_TESTLIB_ADDR_H_ */ diff --git a/tests/bsim/bluetooth/host/adv/chain/src/main.c b/tests/bsim/bluetooth/host/adv/chain/src/main.c index dd7a400cb62..ad718125318 100644 --- a/tests/bsim/bluetooth/host/adv/chain/src/main.c +++ b/tests/bsim/bluetooth/host/adv/chain/src/main.c @@ -51,6 +51,14 @@ static void test_adv_main(void) extern int broadcaster_multiple(void); int err; + err = bt_enable(NULL); + if (err) { + FAIL("Bluetooth init failed\n"); + + bs_trace_silent_exit(err); + return; + } + err = broadcaster_multiple(); if (err) { FAIL("Adv tests failed\n"); diff --git a/tests/bsim/bluetooth/host/l2cap/compile.sh b/tests/bsim/bluetooth/host/l2cap/compile.sh index 71d41a7f2e7..ddb7f5d14bc 100755 --- a/tests/bsim/bluetooth/host/l2cap/compile.sh +++ b/tests/bsim/bluetooth/host/l2cap/compile.sh @@ -19,6 +19,7 @@ app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_nofrag.conf compile app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_syswq.conf compile run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/host/l2cap/split/compile.sh run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/host/l2cap/reassembly/compile.sh +run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/host/l2cap/einprogress/compile.sh run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/host/l2cap/ecred/compile.sh app=tests/bsim/bluetooth/host/l2cap/credits compile app=tests/bsim/bluetooth/host/l2cap/credits conf_file=prj_ecred.conf compile diff --git a/tests/bsim/bluetooth/host/l2cap/einprogress/CMakeLists.txt b/tests/bsim/bluetooth/host/l2cap/einprogress/CMakeLists.txt new file mode 100644 index 00000000000..b6d0135f936 --- /dev/null +++ b/tests/bsim/bluetooth/host/l2cap/einprogress/CMakeLists.txt @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +project(test_l2cap_einprogress) + +add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/common/testlib testlib) +target_link_libraries(app PRIVATE testlib) + +add_subdirectory(${ZEPHYR_BASE}/tests/bsim/babblekit babblekit) +target_link_libraries(app PRIVATE babblekit) + +zephyr_include_directories( + ${BSIM_COMPONENTS_PATH}/libUtilv1/src/ + ${BSIM_COMPONENTS_PATH}/libPhyComv1/src/ +) + +target_sources(app PRIVATE + src/main.c + src/dut.c + src/tester.c +) diff --git a/tests/bsim/bluetooth/host/l2cap/einprogress/compile.sh b/tests/bsim/bluetooth/host/l2cap/einprogress/compile.sh new file mode 100755 index 00000000000..e717a4b2bbe --- /dev/null +++ b/tests/bsim/bluetooth/host/l2cap/einprogress/compile.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Copyright 2023 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 +set -eu +: "${ZEPHYR_BASE:?ZEPHYR_BASE must be defined}" + +INCR_BUILD=1 + +source ${ZEPHYR_BASE}/tests/bsim/compile.source + +app="$(guess_test_relpath)" compile + +wait_for_background_jobs diff --git a/tests/bsim/bluetooth/host/l2cap/einprogress/prj.conf b/tests/bsim/bluetooth/host/l2cap/einprogress/prj.conf new file mode 100644 index 00000000000..e2540cd6f6a --- /dev/null +++ b/tests/bsim/bluetooth/host/l2cap/einprogress/prj.conf @@ -0,0 +1,25 @@ +CONFIG_LOG=y +CONFIG_ASSERT=y +CONFIG_THREAD_NAME=y +CONFIG_LOG_THREAD_ID_PREFIX=y +CONFIG_ARCH_POSIX_TRAP_ON_FATAL=y +CONFIG_BT_TESTING=y + +CONFIG_BT_HCI_ACL_FLOW_CONTROL=y + +CONFIG_BT=y +CONFIG_BT_CENTRAL=y +CONFIG_BT_PERIPHERAL=y + +# Dependency of testlib/adv and testlib/scan. +CONFIG_BT_EXT_ADV=y + +# Dynamic channel depends on SMP +CONFIG_BT_SMP=y +CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y + +# Disable auto-initiated procedures so they don't +# mess with the test's execution. +CONFIG_BT_AUTO_PHY_UPDATE=n +CONFIG_BT_AUTO_DATA_LEN_UPDATE=n +CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n diff --git a/tests/bsim/bluetooth/host/l2cap/einprogress/src/data.h b/tests/bsim/bluetooth/host/l2cap/einprogress/src/data.h new file mode 100644 index 00000000000..4920d909d08 --- /dev/null +++ b/tests/bsim/bluetooth/host/l2cap/einprogress/src/data.h @@ -0,0 +1,11 @@ +/* Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_TESTS_BSIM_BLUETOOTH_HOST_L2CAP_EINPROGRESS_SRC_DATA_H_ +#define ZEPHYR_TESTS_BSIM_BLUETOOTH_HOST_L2CAP_EINPROGRESS_SRC_DATA_H_ + +#define TEST_DATA_L2CAP_PSM 0x0080 +#define TEST_DATA_DUT_ADDR BT_TESTLIB_ADDR_LE_RANDOM_C0_00_00_00_00_(0x01) + +#endif /* ZEPHYR_TESTS_BSIM_BLUETOOTH_HOST_L2CAP_EINPROGRESS_SRC_DATA_H_ */ diff --git a/tests/bsim/bluetooth/host/l2cap/einprogress/src/dut.c b/tests/bsim/bluetooth/host/l2cap/einprogress/src/dut.c new file mode 100644 index 00000000000..2c026befd20 --- /dev/null +++ b/tests/bsim/bluetooth/host/l2cap/einprogress/src/dut.c @@ -0,0 +1,124 @@ +/* Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "data.h" + +LOG_MODULE_REGISTER(dut, LOG_LEVEL_INF); + +/** Here we keep track of the reference count in the test + * application. This allows us to notice if the stack has freed + * references that were ours. + */ +static atomic_t acl_pool_refs_held[CONFIG_BT_BUF_ACL_RX_COUNT]; + +BUILD_ASSERT(IS_ENABLED(CONFIG_BT_TESTING)); +BUILD_ASSERT(IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL)); +void bt_testing_trace_event_acl_pool_destroy(struct net_buf *destroyed_buf) +{ + int buf_id = net_buf_id(destroyed_buf); + + __ASSERT_NO_MSG(0 <= buf_id && buf_id < ARRAY_SIZE(acl_pool_refs_held)); + TEST_ASSERT(acl_pool_refs_held[buf_id] == 0, + "ACL buf was destroyed while tester still held a reference"); +} + +static void acl_pool_refs_held_add(struct net_buf *buf) +{ + int buf_id = net_buf_id(buf); + + __ASSERT_NO_MSG(0 <= buf_id && buf_id < CONFIG_BT_BUF_ACL_RX_COUNT); + atomic_inc(&acl_pool_refs_held[buf_id]); +} + +static void acl_pool_refs_held_remove(struct net_buf *buf) +{ + int buf_id = net_buf_id(buf); + + __ASSERT_NO_MSG(0 <= buf_id && buf_id < ARRAY_SIZE(acl_pool_refs_held)); + atomic_val_t old = atomic_dec(&acl_pool_refs_held[buf_id]); + + __ASSERT(old != 0, "Tester error: releasing a reference that was not held"); +} + +struct k_fifo ack_todo; + +static int dut_chan_recv_cb(struct bt_l2cap_chan *chan, struct net_buf *buf) +{ + /* Move buf. Ownership is ours if we return -EINPROGRESS. */ + acl_pool_refs_held_add(buf); + k_fifo_put(&ack_todo, buf); + + return -EINPROGRESS; +} + +static const struct bt_l2cap_chan_ops ops = { + .recv = dut_chan_recv_cb, +}; + +static struct bt_l2cap_le_chan le_chan = { + .chan.ops = &ops, +}; + +static int dut_server_accept_cb(struct bt_conn *conn, struct bt_l2cap_server *server, + struct bt_l2cap_chan **chan) +{ + *chan = &le_chan.chan; + return 0; +} + +static struct bt_l2cap_server test_l2cap_server = { + .accept = dut_server_accept_cb, + .psm = TEST_DATA_L2CAP_PSM, +}; + +void entrypoint_dut(void) +{ + struct net_buf *ack_buf; + struct bt_conn *conn = NULL; + int err; + + TEST_START("dut"); + + k_fifo_init(&ack_todo); + + err = bt_id_create(&TEST_DATA_DUT_ADDR, NULL); + __ASSERT_NO_MSG(!err); + + err = bt_enable(NULL); + __ASSERT_NO_MSG(!err); + + err = bt_l2cap_server_register(&test_l2cap_server); + __ASSERT_NO_MSG(!err); + + err = bt_testlib_adv_conn(&conn, BT_ID_DEFAULT, NULL); + __ASSERT_NO_MSG(!err); + + ack_buf = k_fifo_get(&ack_todo, K_FOREVER); + __ASSERT_NO_MSG(ack_buf); + + acl_pool_refs_held_remove(ack_buf); + err = bt_l2cap_chan_recv_complete(&le_chan.chan, ack_buf); + TEST_ASSERT(!err); + + TEST_PASS_AND_EXIT("dut"); +} diff --git a/tests/bsim/bluetooth/host/l2cap/einprogress/src/main.c b/tests/bsim/bluetooth/host/l2cap/einprogress/src/main.c new file mode 100644 index 00000000000..d6611e8f8dd --- /dev/null +++ b/tests/bsim/bluetooth/host/l2cap/einprogress/src/main.c @@ -0,0 +1,47 @@ +/* Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include "bstests.h" +#include "babblekit/testcase.h" + +extern void entrypoint_dut(void); +extern void entrypoint_tester(void); +extern enum bst_result_t bst_result; + +static void test_end_cb(void) +{ + if (bst_result != Passed) { + TEST_PRINT("Test has not passed."); + } +} + +static const struct bst_test_instance entrypoints[] = { + { + .test_id = "l2cap/einprogress/dut", + .test_delete_f = test_end_cb, + .test_main_f = entrypoint_dut, + }, + { + .test_id = "l2cap/einprogress/tester", + .test_delete_f = test_end_cb, + .test_main_f = entrypoint_tester, + }, + BSTEST_END_MARKER, +}; + +static struct bst_test_list *install(struct bst_test_list *tests) +{ + return bst_add_tests(tests, entrypoints); +}; + +bst_test_install_t test_installers[] = {install, NULL}; + +int main(void) +{ + bst_main(); + + return 0; +} diff --git a/tests/bsim/bluetooth/host/l2cap/einprogress/src/tester.c b/tests/bsim/bluetooth/host/l2cap/einprogress/src/tester.c new file mode 100644 index 00000000000..2e2d000aa9c --- /dev/null +++ b/tests/bsim/bluetooth/host/l2cap/einprogress/src/tester.c @@ -0,0 +1,72 @@ +/* Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "data.h" + +LOG_MODULE_REGISTER(tester, LOG_LEVEL_INF); + +static int tester_chan_recv_cb(struct bt_l2cap_chan *chan, struct net_buf *buf) +{ + __ASSERT(false, "Unexpected recv in tester"); + return 0; +}; + +static struct bt_l2cap_le_chan le_chan = { + .chan.ops = + &(const struct bt_l2cap_chan_ops){ + .recv = tester_chan_recv_cb, + }, +}; + +NET_BUF_POOL_DEFINE(test_pool, 1, BT_L2CAP_SDU_BUF_SIZE(0), CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL); + +void entrypoint_tester(void) +{ + struct net_buf *sdu; + struct bt_conn *conn = NULL; + int err; + + TEST_START("tester"); + + err = bt_enable(NULL); + __ASSERT_NO_MSG(!err); + + err = bt_testlib_connect(&TEST_DATA_DUT_ADDR, &conn); + __ASSERT_NO_MSG(!err); + + err = bt_l2cap_chan_connect(conn, &le_chan.chan, TEST_DATA_L2CAP_PSM); + __ASSERT_NO_MSG(!err); + + /* Wait for async L2CAP connect */ + while (!atomic_test_bit(le_chan.chan.status, BT_L2CAP_STATUS_OUT)) { + k_sleep(K_MSEC(100)); + } + + sdu = net_buf_alloc(&test_pool, K_NO_WAIT); + __ASSERT_NO_MSG(sdu); + net_buf_reserve(sdu, BT_L2CAP_SDU_CHAN_SEND_RESERVE); + + err = bt_l2cap_chan_send(&le_chan.chan, sdu); + __ASSERT(!err, "err: %d", err); + + TEST_PASS("tester"); +} diff --git a/tests/bsim/bluetooth/host/l2cap/einprogress/test_scripts/run.sh b/tests/bsim/bluetooth/host/l2cap/einprogress/test_scripts/run.sh new file mode 100755 index 00000000000..b86db52d9df --- /dev/null +++ b/tests/bsim/bluetooth/host/l2cap/einprogress/test_scripts/run.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Copyright (c) 2024 Nordic Semiconductor +# SPDX-License-Identifier: Apache-2.0 + +set -eu + +source ${ZEPHYR_BASE}/tests/bsim/sh_common.source + +test_name="$(guess_test_long_name)" +simulation_id=${test_name} +verbosity_level=2 +EXECUTE_TIMEOUT=120 +SIM_LEN_US=$((2 * 1000 * 1000)) + +test_exe="${BSIM_OUT_PATH}/bin/bs_${BOARD_TS}_${test_name}_prj_conf" + +cd ${BSIM_OUT_PATH}/bin + +Execute "${test_exe}" -v=${verbosity_level} -s=${simulation_id} -d=0 \ + -testid=l2cap/einprogress/dut +Execute "${test_exe}" -v=${verbosity_level} -s=${simulation_id} -d=1 \ + -testid=l2cap/einprogress/tester + +Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} -D=2 -sim_length=${SIM_LEN_US} $@ + +wait_for_background_jobs diff --git a/tests/cmake/hwm/board_extend/CMakeLists.txt b/tests/cmake/hwm/board_extend/CMakeLists.txt new file mode 100644 index 00000000000..20bd94d6af0 --- /dev/null +++ b/tests/cmake/hwm/board_extend/CMakeLists.txt @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (c) 2024 Nordic Semiconductor ASA + +cmake_minimum_required(VERSION 3.20.0) + +set(BOARD_ROOT ${CMAKE_CURRENT_LIST_DIR}/oot_root) +set(SOC_ROOT ${CMAKE_CURRENT_LIST_DIR}/oot_root) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(native_sim_extend) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/cmake/hwm/board_extend/Kconfig b/tests/cmake/hwm/board_extend/Kconfig new file mode 100644 index 00000000000..6bbf5b73227 --- /dev/null +++ b/tests/cmake/hwm/board_extend/Kconfig @@ -0,0 +1,15 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 + +config BASE_BOARD_SETTING + bool "Base board test string" + help + This kconfig is set when the base board config fragment is supposed to + be sourced, that is when oot variant defines + 'extends:' + ' board: native_sim' + ' qualifier: posix' + ' inherit: 1' + +source "Kconfig.zephyr" diff --git a/tests/cmake/hwm/board_extend/boards/native_sim.conf b/tests/cmake/hwm/board_extend/boards/native_sim.conf new file mode 100644 index 00000000000..71a2b211d0a --- /dev/null +++ b/tests/cmake/hwm/board_extend/boards/native_sim.conf @@ -0,0 +1 @@ +CONFIG_BASE_BOARD_SETTING=y diff --git a/tests/cmake/hwm/board_extend/boards/native_sim_native_64_two.conf b/tests/cmake/hwm/board_extend/boards/native_sim_native_64_two.conf new file mode 100644 index 00000000000..b2dfe184407 --- /dev/null +++ b/tests/cmake/hwm/board_extend/boards/native_sim_native_64_two.conf @@ -0,0 +1 @@ +CONFIG_EXTENDED_VARIANT_BOARD_SETTING=y diff --git a/tests/cmake/hwm/board_extend/boards/native_sim_native_one.conf b/tests/cmake/hwm/board_extend/boards/native_sim_native_one.conf new file mode 100644 index 00000000000..b2dfe184407 --- /dev/null +++ b/tests/cmake/hwm/board_extend/boards/native_sim_native_one.conf @@ -0,0 +1 @@ +CONFIG_EXTENDED_VARIANT_BOARD_SETTING=y diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/Kconfig.mps2 b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/Kconfig.mps2 new file mode 100644 index 00000000000..448c9cc1308 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/Kconfig.mps2 @@ -0,0 +1,5 @@ +# Copyright (c) 2017 Linaro Limited +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_MPS2 + select SOC_MPS2_AN521_CPUTEST if BOARD_MPS2_AN521_CPUTEST diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/board.cmake b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/board.cmake new file mode 100644 index 00000000000..27c74975756 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/board.cmake @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (c) 2024, Nordic Semiconductor ASA + +if(CONFIG_BOARD_MPS2_AN521_CPUTEST) + set(QEMU_CPU_TYPE_${ARCH} cortex-m33) + set(QEMU_FLAGS_${ARCH} + -cpu ${QEMU_CPU_TYPE_${ARCH}} + -machine mps2-an521 + -nographic + -m 16 + -vga none + ) +endif() diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/board.yml b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/board.yml new file mode 100644 index 00000000000..05982ac1bb8 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/board.yml @@ -0,0 +1,2 @@ +board: + extend: mps2 diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521-common.dtsi b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521-common.dtsi new file mode 100644 index 00000000000..5b1959ff5fe --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521-common.dtsi @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2019 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +sysclk: system-clock { + compatible = "fixed-clock"; + clock-frequency = <25000000>; + #clock-cells = <0>; +}; + +timer0: timer@0 { + compatible = "arm,cmsdk-timer"; + reg = <0x0 0x1000>; + interrupts = <3 3>; +}; + +timer1: timer@1000 { + compatible = "arm,cmsdk-timer"; + reg = <0x1000 0x1000>; + interrupts = <4 3>; +}; + +dtimer0: dtimer@2000 { + compatible = "arm,cmsdk-dtimer"; + reg = <0x2000 0x1000>; + interrupts = <5 3>; +}; + +mhu0: mhu@3000 { + compatible = "arm,mhu"; + reg = <0x3000 0x1000>; + interrupts = <6 3>; +}; + +mhu1: mhu@4000 { + compatible = "arm,mhu"; + reg = <0x4000 0x1000>; + interrupts = <7 3>; +}; + +gpio0: gpio@100000 { + compatible = "arm,cmsdk-gpio"; + reg = <0x100000 0x1000>; + interrupts = <68 3>; + gpio-controller; + #gpio-cells = <2>; +}; + +gpio1: gpio@101000 { + compatible = "arm,cmsdk-gpio"; + reg = <0x101000 0x1000>; + interrupts = <69 3>; + gpio-controller; + #gpio-cells = <2>; +}; + +gpio2: gpio@102000 { + compatible = "arm,cmsdk-gpio"; + reg = <0x102000 0x1000>; + interrupts = <70 3>; + gpio-controller; + #gpio-cells = <2>; +}; + +gpio3: gpio@103000 { + compatible = "arm,cmsdk-gpio"; + reg = <0x103000 0x1000>; + interrupts = <71 3>; + gpio-controller; + #gpio-cells = <2>; +}; + +wdog0: wdog@81000 { + compatible = "arm,cmsdk-watchdog"; + reg = <0x81000 0x1000>; + clocks = <&sysclk>; +}; + +uart0: uart@200000 { + compatible = "arm,cmsdk-uart"; + reg = <0x200000 0x1000>; + interrupts = <33 3 32 3>; + interrupt-names = "tx", "rx"; + clocks = <&sysclk>; + current-speed = <115200>; +}; + +uart1: uart@201000 { + compatible = "arm,cmsdk-uart"; + reg = <0x201000 0x1000>; + interrupts = <35 3 34 3>; + interrupt-names = "tx", "rx"; + clocks = <&sysclk>; + current-speed = <115200>; +}; + +uart2: uart@202000 { + compatible = "arm,cmsdk-uart"; + reg = <0x202000 0x1000>; + interrupts = <37 3 36 3>; + interrupt-names = "tx", "rx"; + clocks = <&sysclk>; + current-speed = <115200>; +}; + +uart3: uart@203000 { + compatible = "arm,cmsdk-uart"; + reg = <0x203000 0x1000>; + interrupts = <39 3 38 3>; + interrupt-names = "tx", "rx"; + clocks = <&sysclk>; + current-speed = <115200>; +}; + +uart4: uart@204000 { + compatible = "arm,cmsdk-uart"; + reg = <0x204000 0x1000>; + interrupts = <41 3 40 3>; + interrupt-names = "tx", "rx"; + clocks = <&sysclk>; + current-speed = <115200>; +}; + +i2c_touch: i2c@207000 { + compatible = "arm,versatile-i2c"; + clock-frequency = ; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x207000 0x1000>; +}; + +i2c_audio_conf: i2c@208000 { + compatible = "arm,versatile-i2c"; + clock-frequency = ; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x208000 0x1000>; +}; + +i2c_shield0: i2c@20c000 { + compatible = "arm,versatile-i2c"; + clock-frequency = ; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x20c000 0x1000>; +}; + +i2c_shield1: i2c@20d000 { + compatible = "arm,versatile-i2c"; + clock-frequency = ; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x20d000 0x1000>; +}; + +gpio_led0: mps2_fpgaio@302000 { + compatible = "arm,mps2-fpgaio-gpio"; + + reg = <0x302000 0x4>; + gpio-controller; + #gpio-cells = <1>; + ngpios = <2>; +}; + +gpio_button: mps2_fpgaio@302008 { + compatible = "arm,mps2-fpgaio-gpio"; + + reg = <0x302008 0x4>; + gpio-controller; + #gpio-cells = <1>; + ngpios = <2>; +}; + +gpio_misc: mps2_fpgaio@30204c { + compatible = "arm,mps2-fpgaio-gpio"; + + reg = <0x30204c 0x4>; + gpio-controller; + #gpio-cells = <1>; + ngpios = <10>; +}; + +eth0: eth@2000000 { + /* Linux has "smsc,lan9115" */ + compatible = "smsc,lan9220"; + /* Actual reg range is ~0x200 */ + reg = <0x2000000 0x100000>; + interrupts = <48 3>; +}; diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521_cputest.dts b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521_cputest.dts new file mode 100644 index 00000000000..2bb956645ca --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521_cputest.dts @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2018-2019 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include +#include +#include + +/ { + compatible = "arm,mps2"; + #address-cells = <1>; + #size-cells = <1>; + + aliases { + led0 = &led_0; + led1 = &led_1; + sw0 = &user_button_0; + sw1 = &user_button_1; + uart-1 = &uart1; + watchdog0 = &wdog0; + }; + + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + + /* + * These SRAM and flash settings give the entire available + * code and data memories to this secure firmware image. + * This may conflict with mps2_an521_remote firmware. Use + * caution when using both targets simultaneously. + */ + zephyr,sram = &ssram2_3; + zephyr,flash = &ssram1; + }; + + leds { + compatible = "gpio-leds"; + led_0: led_0 { + gpios = <&gpio_led0 0>; + label = "USERLED0"; + }; + led_1: led_1 { + gpios = <&gpio_led0 1>; + label = "USERLED1"; + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + user_button_0: button_0 { + label = "USERPB0"; + gpios = <&gpio_button 0>; + zephyr,code = ; + }; + user_button_1: button_1 { + label = "USERPB1"; + gpios = <&gpio_button 1>; + zephyr,code = ; + }; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-m33"; + reg = <0>; + #address-cells = <1>; + #size-cells = <1>; + + mpu: mpu@e000ed90 { + compatible = "arm,armv8m-mpu"; + reg = <0xe000ed90 0x40>; + }; + }; + }; + + /* + * The memory regions defined below are according to AN521: + * https://documentation-service.arm.com/static/5fa12fe9b1a7c5445f29017f + * + * Please see tables mentioned in individual comments below for details. + */ + + ssram1: memory@10000000 { + /* Table 3-2, row 6. */ + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x10000000 DT_SIZE_M(4)>; + zephyr,memory-region = "SSRAM1"; + }; + + ssram2_3: memory@38000000 { + /* Table 3-4, rows 16 and 17. */ + compatible = "zephyr,memory-region", "mmio-sram"; + reg = <0x38000000 DT_SIZE_M(4)>; + zephyr,memory-region = "SSRAM2_3"; + }; + + psram: memory@80000000 { + /* Table 3-6, row 1. */ + device_type = "memory"; + reg = <0x80000000 DT_SIZE_M(16)>; + }; + + soc { + peripheral@50000000 { + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x50000000 0x10000000>; + + #include "mps2_an521-common.dtsi" + }; + }; +}; + +&nvic { + arm,num-irq-priority-bits = <3>; +}; + +&uart1 { + status = "okay"; +}; diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521_cputest_defconfig b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521_cputest_defconfig new file mode 100644 index 00000000000..08949950a9e --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/arm/mps2/mps2_an521_cputest_defconfig @@ -0,0 +1,21 @@ +# +# Copyright (c) 2018-2019 Linaro Limited +# +# SPDX-License-Identifier: Apache-2.0 +# + +#CONFIG_RUNTIME_NMI=y +#CONFIG_ARM_TRUSTZONE_M=y +#CONFIG_ARM_MPU=y +CONFIG_QEMU_ICOUNT_SHIFT=6 +# +## GPIOs +CONFIG_GPIO=y + +# Serial +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_SERIAL=y + +# Build a non-secure firmware image +#CONFIG_TRUSTED_EXECUTION_NONSECURE=y diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/Kconfig b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/Kconfig new file mode 100644 index 00000000000..e724497c3b5 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/Kconfig @@ -0,0 +1,30 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config EXTENDED_VARIANT_BOARD_SETTING + bool "Extended variant board test string" + depends on BOARD_NATIVE_SIM_NATIVE_ONE || BOARD_NATIVE_SIM_NATIVE_64_TWO + help + This kconfig is set when the extended variant board config fragment + is supposed to be sourced, that is when oot variant defines 'extends:' + +config EXTENDED_VARIANT_BOARD_ONE_SETTING_PROMPTLESS + bool + depends on BOARD_NATIVE_SIM_NATIVE_ONE + help + This kconfig is promptless and is expected to be set through the + Kconfig.defconfig for the extended board. + +config EXTENDED_VARIANT_BOARD_TWO_SETTING_PROMPTLESS + bool + depends on BOARD_NATIVE_SIM_NATIVE_64_TWO + help + This kconfig is promptless and is expected to be set through the + Kconfig.defconfig for the extended board. + +config EXTENDED_VARIANT_BOARD_SETTING_DEFCONFIG + bool "Extended variant board test string defconfig" + depends on BOARD_NATIVE_SIM_NATIVE_ONE || BOARD_NATIVE_SIM_NATIVE_64_TWO + help + This kconfig is set when the extended variant board defconfig fragment + is supposed to be sourced, that is when oot variant defines 'extends:' diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/Kconfig.defconfig b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/Kconfig.defconfig new file mode 100644 index 00000000000..343daa1246a --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/Kconfig.defconfig @@ -0,0 +1,16 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NATIVE_SIM_NATIVE_ONE + +config EXTENDED_VARIANT_BOARD_ONE_SETTING_PROMPTLESS + default y + +endif # BOARD_NATIVE_SIM_NATIVE_ONE + +if BOARD_NATIVE_SIM_NATIVE_64_TWO + +config EXTENDED_VARIANT_BOARD_TWO_SETTING_PROMPTLESS + default y + +endif # BOARD_NATIVE_SIM_NATIVE_64_TWO diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/board.yml b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/board.yml new file mode 100644 index 00000000000..8df9cf3c433 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/board.yml @@ -0,0 +1,7 @@ +board: + extend: native_sim + variants: + - name: one + qualifier: native + - name: two + qualifier: native/64 diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two.dts b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two.dts new file mode 100644 index 00000000000..b3fc17d81fb --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two.dts @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "native_sim_native_one.dts" + +/ { + /delete-node/ added-by-native-one; + + added-by-native-two{ + }; +}; diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two.yaml b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two.yaml new file mode 100644 index 00000000000..190d4906cc8 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two.yaml @@ -0,0 +1,25 @@ +identifier: native_sim_native_64_two +name: Native Simulation port - 32-bit +type: native +simulation: native +arch: posix +ram: 65536 +flash: 65536 +toolchain: + - host + - llvm +supported: + - can + - counter + - dma + - eeprom + - netif:eth + - usb_device + - adc + - i2c + - spi + - gpio + - rtc +testing: + default: true +vendor: zephyr diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two_defconfig b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two_defconfig new file mode 100644 index 00000000000..d0de015b0df --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_64_two_defconfig @@ -0,0 +1,7 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_CONSOLE=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=1000000 + +CONFIG_EXTENDED_VARIANT_BOARD_SETTING_DEFCONFIG=y diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one.dts b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one.dts new file mode 100644 index 00000000000..652c7605f60 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one.dts @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2019 Jan Van Winkel (jan.van_winkel@dxplore.eu) + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include +#include +#include + +/ { + model = "Native Sim Board"; + compatible = "zephyr,posix"; + + chosen { + zephyr,console = &uart0; + zephyr,shell-uart = &uart0; + zephyr,uart-mcumgr = &uart0; + zephyr,flash = &flash0; + zephyr,entropy = &rng; + zephyr,flash-controller = &flashcontroller0; + zephyr,display = &sdl_dc; + zephyr,canbus = &can_loopback0; + zephyr,code-partition = &slot0_partition; + }; + + aliases { + eeprom-0 = &eeprom0; + i2c-0 = &i2c0; + spi-0 = &spi0; + led0 = &led0; + rtc = &rtc; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; + label = "Green LED"; + }; + }; + + lvgl_pointer { + compatible = "zephyr,lvgl-pointer-input"; + input = <&input_sdl_touch>; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu0: cpu@0 { + compatible = "zephyr,native-posix-cpu"; + reg = <0>; + }; + }; + + flashcontroller0: flash-controller@0 { + compatible = "zephyr,sim-flash"; + reg = <0x00000000 DT_SIZE_K(2048)>; + + #address-cells = <1>; + #size-cells = <1>; + erase-value = <0xff>; + + flash0: flash@0 { + status = "okay"; + compatible = "soc-nv-flash"; + erase-block-size = <4096>; + write-block-size = <1>; + reg = <0x00000000 DT_SIZE_K(2048)>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 0x0000C000>; + }; + slot0_partition: partition@c000 { + label = "image-0"; + reg = <0x0000C000 0x00069000>; + }; + slot1_partition: partition@75000 { + label = "image-1"; + reg = <0x00075000 0x00069000>; + }; + scratch_partition: partition@de000 { + label = "image-scratch"; + reg = <0x000de000 0x0001e000>; + }; + storage_partition: partition@fc000 { + label = "storage"; + reg = <0x000fc000 0x00004000>; + }; + }; + }; + }; + + eeprom0: eeprom { + status = "okay"; + compatible = "zephyr,sim-eeprom"; + size = ; + }; + + i2c0: i2c@100 { + status = "okay"; + compatible = "zephyr,i2c-emul-controller"; + clock-frequency = ; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x100 4>; + }; + + spi0: spi@200 { + status = "okay"; + compatible = "zephyr,spi-emul-controller"; + clock-frequency = <50000000>; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x200 4>; + }; + + espi0: espi@300 { + status = "okay"; + compatible = "zephyr,espi-emul-controller"; + reg = <0x300 4>; + #address-cells = <1>; + #size-cells = <0>; + }; + + uart0: uart { + status = "okay"; + compatible = "zephyr,native-posix-uart"; + /* Dummy current-speed entry to comply with serial + * DTS binding + */ + current-speed = <0>; + }; + + uart1: uart_1 { + status = "okay"; + compatible = "zephyr,native-posix-uart"; + /* Dummy current-speed entry to comply with serial + * DTS binding + */ + current-speed = <0>; + }; + + rng: rng { + status = "okay"; + compatible = "zephyr,native-posix-rng"; + }; + + counter0: counter { + status = "okay"; + compatible = "zephyr,native-posix-counter"; + }; + + gpio0: gpio@800 { + status = "okay"; + compatible = "zephyr,gpio-emul"; + reg = <0x800 0x4>; + rising-edge; + falling-edge; + high-level; + low-level; + gpio-controller; + #gpio-cells = <2>; + }; + + zephyr_udc0: udc0 { + compatible = "zephyr,native-posix-udc"; + }; + + sdl_dc: sdl_dc { + compatible = "zephyr,sdl-dc"; + height = <240>; + width = <320>; + }; + + input_sdl_touch: input-sdl-touch { + compatible = "zephyr,input-sdl-touch"; + }; + + can_loopback0: can_loopback0 { + status = "okay"; + compatible = "zephyr,can-loopback"; + }; + + can0: can { + status = "disabled"; + compatible = "zephyr,native-linux-can"; + /* adjust zcan0 to desired host interface or create an alternative + * name, e.g.: sudo ip link property add dev vcan0 altname zcan0 + */ + host-interface = "zcan0"; + }; + + rtc: rtc { + status = "okay"; + compatible = "zephyr,rtc-emul"; + alarms-count = <2>; + }; + + dma: dma { + compatible = "zephyr,dma-emul"; + #dma-cells = <1>; + stack-size = <4096>; + }; + + added-by-native-one { + }; +}; diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one.yaml b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one.yaml new file mode 100644 index 00000000000..ea2c2d856ae --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one.yaml @@ -0,0 +1,25 @@ +identifier: native_sim_native_one +name: Native Simulation port - 32-bit +type: native +simulation: native +arch: posix +ram: 65536 +flash: 65536 +toolchain: + - host + - llvm +supported: + - can + - counter + - dma + - eeprom + - netif:eth + - usb_device + - adc + - i2c + - spi + - gpio + - rtc +testing: + default: true +vendor: zephyr diff --git a/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one_defconfig b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one_defconfig new file mode 100644 index 00000000000..d0de015b0df --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/boards/native/native_sim_extend/native_sim_native_one_defconfig @@ -0,0 +1,7 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_CONSOLE=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=1000000 + +CONFIG_EXTENDED_VARIANT_BOARD_SETTING_DEFCONFIG=y diff --git a/tests/cmake/hwm/board_extend/oot_root/soc/arm/Kconfig.soc b/tests/cmake/hwm/board_extend/oot_root/soc/arm/Kconfig.soc new file mode 100644 index 00000000000..a699e8413a1 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/soc/arm/Kconfig.soc @@ -0,0 +1,6 @@ +# Copyright (c) 2024, Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config SOC_MPS2_AN521_CPUTEST + bool + select SOC_MPS2_AN521 diff --git a/tests/cmake/hwm/board_extend/oot_root/soc/arm/soc.yml b/tests/cmake/hwm/board_extend/oot_root/soc/arm/soc.yml new file mode 100644 index 00000000000..04b69c75ae4 --- /dev/null +++ b/tests/cmake/hwm/board_extend/oot_root/soc/arm/soc.yml @@ -0,0 +1,4 @@ +socs: + - extend: an521 + cpuclusters: + - name: cputest diff --git a/tests/cmake/hwm/board_extend/prj.conf b/tests/cmake/hwm/board_extend/prj.conf new file mode 100644 index 00000000000..9467c292689 --- /dev/null +++ b/tests/cmake/hwm/board_extend/prj.conf @@ -0,0 +1 @@ +CONFIG_ZTEST=y diff --git a/tests/cmake/hwm/board_extend/src/main.c b/tests/cmake/hwm/board_extend/src/main.c new file mode 100644 index 00000000000..9795bd8dcb8 --- /dev/null +++ b/tests/cmake/hwm/board_extend/src/main.c @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#ifdef CONFIG_EXTENDED_VARIANT_BOARD_SETTING +#define EXTENDED_BOARD_A 1 +#else +#define EXTENDED_BOARD_A 0 +#endif + +#ifdef CONFIG_EXTENDED_VARIANT_BOARD_ONE_SETTING_PROMPTLESS +#define EXTENDED_BOARD_ONE_B 1 +#else +#define EXTENDED_BOARD_ONE_B 0 +#endif + +#ifdef CONFIG_EXTENDED_VARIANT_BOARD_TWO_SETTING_PROMPTLESS +#define EXTENDED_BOARD_TWO_C 1 +#else +#define EXTENDED_BOARD_TWO_C 0 +#endif + +#ifdef CONFIG_EXTENDED_VARIANT_BOARD_SETTING_DEFCONFIG +#define EXTENDED_BOARD_D 1 +#else +#define EXTENDED_BOARD_D 0 +#endif + +#ifdef CONFIG_BASE_BOARD_SETTING +#define BASE_BOARD_CONFIG 1 +#else +#define BASE_BOARD_CONFIG 0 +#endif + +#ifdef CONFIG_SOC_MPS2_AN521_CPUTEST +#define EXTENDED_SOC 1 +#else +#define EXTENDED_SOC 0 +#endif + +ZTEST_SUITE(soc_board_extend, NULL, NULL, NULL, NULL, NULL); + +#if CONFIG_BOARD_NATIVE_SIM +ZTEST(soc_board_extend, test_native_sim_extend) +{ +#if CONFIG_BOARD_NATIVE_SIM_NATIVE_ONE + zassert_true(EXTENDED_BOARD_A, "Expected extended board to be set"); + zassert_true(EXTENDED_BOARD_ONE_B, "Expected extended board to be set"); + zassert_false(EXTENDED_BOARD_TWO_C, "Did not expect extended board two to be set"); + zassert_true(EXTENDED_BOARD_D, "Expected extended board to be set"); + zassert_false(BASE_BOARD_CONFIG, "Did not expect base board to be set"); + zassert_true(DT_NODE_EXISTS(DT_PATH(added_by_native_one))); + zassert_false(DT_NODE_EXISTS(DT_PATH(added_by_native_two))); + zassert_false(DT_NODE_EXISTS(DT_PATH(adc))); +#elif CONFIG_BOARD_NATIVE_SIM_NATIVE_64_TWO + zassert_true(EXTENDED_BOARD_A, "Expected extended board to be set"); + zassert_false(EXTENDED_BOARD_ONE_B, "Did not expect extended board one to be set"); + zassert_true(EXTENDED_BOARD_TWO_C, "Expected extended board to be set"); + zassert_true(EXTENDED_BOARD_D, "Expected extended board to be set"); + zassert_false(BASE_BOARD_CONFIG, "Did not expect base board to be set"); + zassert_false(DT_NODE_EXISTS(DT_PATH(added_by_native_one))); + zassert_true(DT_NODE_EXISTS(DT_PATH(added_by_native_two))); + zassert_false(DT_NODE_EXISTS(DT_PATH(adc))); +#else + zassert_true(false, "Did not expect to build for a base native_sim board"); +#endif +#elif CONFIG_BOARD_MPS2 +ZTEST(soc_board_extend, test_an521_soc_extend) +{ +#if CONFIG_BOARD_MPS2_AN521_CPUTEST + zassert_true(EXTENDED_SOC, "Expected extended SoC to be set"); +#elif CONFIG_BOARD_MPS2 + zassert_true(false, "Did not expect to build for a base mps2 board"); +#endif + +#else +ZTEST(soc_board_extend, test_failure) +{ + zassert_true(false, "Did not expect to build for a regular board"); +#endif +} diff --git a/tests/cmake/hwm/board_extend/testcase.yaml b/tests/cmake/hwm/board_extend/testcase.yaml new file mode 100644 index 00000000000..aae39ce6b2c --- /dev/null +++ b/tests/cmake/hwm/board_extend/testcase.yaml @@ -0,0 +1,33 @@ +common: + tags: + - cmake +tests: + cmake.board.extend_one: + extra_args: + # Twister can only lookup known board roots. + # Thus platform above is set to native_sim, while at this location + # we overrule with the native_sim/native/one board. + # Test will fail if we accidentially build for the base native_sim board. + - CACHED_BOARD=native_sim/native/one + platform_allow: + - native_sim + - native_sim/native/64 + integration_platforms: + - native_sim + - native_sim/native/64 + cmake.board.extend_two: + extra_args: + - CACHED_BOARD=native_sim/native/64/two + platform_allow: + - native_sim + - native_sim/native/64 + integration_platforms: + - native_sim + - native_sim/native/64 + cmake.soc.extend_cputest: + extra_args: + - CACHED_BOARD=mps2/an521/cputest + platform_allow: + - mps2/an521/cpu0 + integration_platforms: + - mps2/an521/cpu0 diff --git a/tests/drivers/adc/adc_api/boards/nucleo_wb05kz.overlay b/tests/drivers/adc/adc_api/boards/nucleo_wb05kz.overlay new file mode 100644 index 00000000000..65bb4e308f8 --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/nucleo_wb05kz.overlay @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2024 STMicroelectronics + */ + +/ { + zephyr,user { + io-channels = <&adc1 4>, <&adc1 12>, <&adc1 13>; + }; +}; + +&adc1 { + status = "okay"; + + pinctrl-0 = <&adc1_vinp0_pb3>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + + vinp0: channel@4 { + reg = <4>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + adc_vbat_ch: channel@c { + reg = <12>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_VDD_1"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + adc_tempsensor_ch: channel@d { + reg = <13>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_VDD_1_3"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; +}; diff --git a/tests/drivers/adc/adc_api/boards/nucleo_wb09ke.overlay b/tests/drivers/adc/adc_api/boards/nucleo_wb09ke.overlay new file mode 100644 index 00000000000..65bb4e308f8 --- /dev/null +++ b/tests/drivers/adc/adc_api/boards/nucleo_wb09ke.overlay @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2024 STMicroelectronics + */ + +/ { + zephyr,user { + io-channels = <&adc1 4>, <&adc1 12>, <&adc1 13>; + }; +}; + +&adc1 { + status = "okay"; + + pinctrl-0 = <&adc1_vinp0_pb3>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + + vinp0: channel@4 { + reg = <4>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + adc_vbat_ch: channel@c { + reg = <12>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_VDD_1"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; + + adc_tempsensor_ch: channel@d { + reg = <13>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_VDD_1_3"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; +}; diff --git a/west.yml b/west.yml index b1287ecabd6..f5a8923c458 100644 --- a/west.yml +++ b/west.yml @@ -34,7 +34,7 @@ manifest: path: modules/lib/acpica - name: bsim repo-path: babblesim-manifest - revision: 9ee22c707970f6621adba0375841c0a609e24628 + revision: 1f242f4ed7fc141fdfcfeca8d21c6d9e801179d7 path: tools/bsim groups: - babblesim @@ -42,21 +42,21 @@ manifest: remote: babblesim repo-path: base path: tools/bsim/components - revision: a3dff9a57f334fb25daa9625841cd64cbfe56681 + revision: 0cc70e78a88c1de9d8ec045a703b38134861e7e7 groups: - babblesim - name: babblesim_ext_2G4_libPhyComv1 remote: babblesim repo-path: ext_2G4_libPhyComv1 path: tools/bsim/components/ext_2G4_libPhyComv1 - revision: aa4951317cc7d84f24152ea38ac9ac21e6d78a76 + revision: 15ae0f87fa049e04cbec48a866f3bc37d903f950 groups: - babblesim - name: babblesim_ext_2G4_phy_v1 remote: babblesim repo-path: ext_2G4_phy_v1 path: tools/bsim/components/ext_2G4_phy_v1 - revision: 04eeb3c3794444122fbeeb3715f4233b0b50cfbb + revision: 62e797b2c518e5bb6123a198382ed2b64b8c068e groups: - babblesim - name: babblesim_ext_2G4_channel_NtNcable @@ -157,7 +157,7 @@ manifest: groups: - hal - name: hal_espressif - revision: 09676fc39bde2c38d6cd40912875cf78ee76126e + revision: 0f1874284f5dee0d49cb23f44f756e7be404e7b7 path: modules/hal/espressif west-commands: west/west-commands.yml groups: @@ -233,7 +233,7 @@ manifest: groups: - hal - name: hal_stm32 - revision: 6f0e5f70cb540c487e3e3678af2e95d0937f9863 + revision: 019d8255333f96bdd47d26b44049bd3e7af8ef55 path: modules/hal/stm32 groups: - hal