diff --git a/.github/workflows/assigner.yml b/.github/workflows/assigner.yml index 6e4e01c8ea1b6..4712d0fe156c1 100644 --- a/.github/workflows/assigner.yml +++ b/.github/workflows/assigner.yml @@ -22,6 +22,11 @@ jobs: runs-on: ubuntu-22.04 steps: + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Install Python dependencies run: | sudo pip3 install -U setuptools wheel pip diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 7564d163f81d5..505bf736c9258 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -70,6 +70,11 @@ jobs: cancel-in-progress: true steps: + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: install-pkgs run: | sudo apt-get update @@ -202,6 +207,11 @@ jobs: - name: checkout uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: install-pkgs run: | apt-get update diff --git a/arch/posix/core/thread.c b/arch/posix/core/thread.c index 4e443e2283b4f..050d075fe570c 100644 --- a/arch/posix/core/thread.c +++ b/arch/posix/core/thread.c @@ -96,6 +96,25 @@ void posix_arch_thread_entry(void *pa_thread_status) z_thread_entry(ptr->entry_point, ptr->arg1, ptr->arg2, ptr->arg3); } +#if defined(CONFIG_FPU) && defined(CONFIG_FPU_SHARING) +int arch_float_disable(struct k_thread *thread) +{ + ARG_UNUSED(thread); + + /* Posix always has FPU enabled so cannot be disabled */ + return -ENOTSUP; +} + +int arch_float_enable(struct k_thread *thread, unsigned int options) +{ + ARG_UNUSED(thread); + ARG_UNUSED(options); + + /* Posix always has FPU enabled so nothing to do here */ + return 0; +} +#endif /* CONFIG_FPU && CONFIG_FPU_SHARING */ + #if defined(CONFIG_ARCH_HAS_THREAD_ABORT) void z_impl_k_thread_abort(k_tid_t thread) { diff --git a/boards/atmel/sam/sam_v71_xult/sam_v71_xult-common.dtsi b/boards/atmel/sam/sam_v71_xult/sam_v71_xult-common.dtsi index f6981455b5122..d5500da2bfc97 100644 --- a/boards/atmel/sam/sam_v71_xult/sam_v71_xult-common.dtsi +++ b/boards/atmel/sam/sam_v71_xult/sam_v71_xult-common.dtsi @@ -2,7 +2,7 @@ * Copyright (c) 2017 Piotr Mienkowski * Copyright (c) 2017 Justin Watson * Copyright (c) 2020 Stephanos Ioannidis - * Copyright (c) 2019-2022 Gerson Fernando Budke + * Copyright (c) 2019-2024 Gerson Fernando Budke * * SPDX-License-Identifier: Apache-2.0 */ @@ -17,6 +17,7 @@ led0 = &yellow_led1; pwm-led0 = &pwm_led0; pwm-0 = &pwm0; + rtc = &rtc; sw0 = &sw0_user_button; sw1 = &sw1_user_button; watchdog0 = &wdt; @@ -336,6 +337,10 @@ zephyr_udc0: &usbhs { }; }; +&rtc { + status = "okay"; +}; + ext1_spi: &spi0 { }; diff --git a/boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21.yaml b/boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21.yaml index 450c0e54ead85..271565dac2443 100644 --- a/boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21.yaml +++ b/boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21.yaml @@ -22,6 +22,7 @@ supported: - i2s - pwm - netif:eth + - rtc - spi - usb_device - watchdog diff --git a/boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21b.yaml b/boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21b.yaml index b1490e426deab..732d1de39e693 100644 --- a/boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21b.yaml +++ b/boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21b.yaml @@ -22,6 +22,7 @@ supported: - i2s - pwm - netif:eth + - rtc - spi - usb_device - watchdog diff --git a/boards/atmel/sam0/samd20_xpro/samd20_xpro.yaml b/boards/atmel/sam0/samd20_xpro/samd20_xpro.yaml index 548bd6c462a88..1db726120e147 100644 --- a/boards/atmel/sam0/samd20_xpro/samd20_xpro.yaml +++ b/boards/atmel/sam0/samd20_xpro/samd20_xpro.yaml @@ -1,3 +1,6 @@ +# Copyright (c) 2024 Gerson Fernando Budke +# SPDX-License-Identifier: Apache-2.0 + identifier: samd20_xpro name: SAM D20 Xplained Pro type: mcu @@ -9,7 +12,6 @@ toolchain: flash: 256 ram: 32 supported: - - adc - flash - gpio - i2c diff --git a/boards/atmel/sam0/samd21_xpro/samd21_xpro.yaml b/boards/atmel/sam0/samd21_xpro/samd21_xpro.yaml index c41c94432857c..e1e8e08bdbb78 100644 --- a/boards/atmel/sam0/samd21_xpro/samd21_xpro.yaml +++ b/boards/atmel/sam0/samd21_xpro/samd21_xpro.yaml @@ -1,6 +1,7 @@ # Copyright (c) 2018 Bryan O'Donoghue # Copyright (c) 2024 Gerson Fernando Budke # SPDX-License-Identifier: Apache-2.0 + identifier: samd21_xpro name: SAM D21 Xplained Pro type: mcu @@ -12,7 +13,6 @@ toolchain: flash: 256 ram: 32 supported: - - adc - counter - dma - gpio diff --git a/boards/atmel/sam0/samr21_xpro/samr21_xpro-pinctrl.dtsi b/boards/atmel/sam0/samr21_xpro/samr21_xpro-pinctrl.dtsi index de5b64f0f8cfd..81f7bce508abc 100644 --- a/boards/atmel/sam0/samr21_xpro/samr21_xpro-pinctrl.dtsi +++ b/boards/atmel/sam0/samr21_xpro/samr21_xpro-pinctrl.dtsi @@ -1,11 +1,17 @@ /* - * Copyright (c) 2022, Gerson Fernando Budke + * Copyright (c) 2022-2024, Gerson Fernando Budke * SPDX-License-Identifier: Apache-2.0 */ #include &pinctrl { + adc_default: adc_default { + group1 { + pinmux = ; + }; + }; + pwm_default: pwm_default { group1 { pinmux = ; diff --git a/boards/atmel/sam0/samr21_xpro/samr21_xpro.dts b/boards/atmel/sam0/samr21_xpro/samr21_xpro.dts index 01ed0e8826ce3..e53fdc80f554d 100644 --- a/boards/atmel/sam0/samr21_xpro/samr21_xpro.dts +++ b/boards/atmel/sam0/samr21_xpro/samr21_xpro.dts @@ -106,6 +106,12 @@ clock-frequency = <48000000>; }; +&adc { + status = "okay"; + pinctrl-0 = <&adc_default>; + pinctrl-names = "default"; +}; + &tcc0 { status = "okay"; compatible = "atmel,sam0-tcc-pwm"; diff --git a/boards/atmel/sam0/samr21_xpro/samr21_xpro.yaml b/boards/atmel/sam0/samr21_xpro/samr21_xpro.yaml index 25ce756d667c9..b61a8209edb27 100644 --- a/boards/atmel/sam0/samr21_xpro/samr21_xpro.yaml +++ b/boards/atmel/sam0/samr21_xpro/samr21_xpro.yaml @@ -1,6 +1,7 @@ # Copyright (c) 2019 Benjamin Valentin -# Copyright (c) 2019-2024 Gerson Fernando Budke +# Copyright (c) 2019-2024 Gerson Fernando Budke # SPDX-License-Identifier: Apache-2.0 + identifier: samr21_xpro name: SAM R21 Xplained Pro type: mcu diff --git a/boards/infineon/cy8cproto_062_4343w/cy8cproto_062_4343w_defconfig b/boards/infineon/cy8cproto_062_4343w/cy8cproto_062_4343w_defconfig index 2bda7847628ab..221643eca2791 100644 --- a/boards/infineon/cy8cproto_062_4343w/cy8cproto_062_4343w_defconfig +++ b/boards/infineon/cy8cproto_062_4343w/cy8cproto_062_4343w_defconfig @@ -17,6 +17,9 @@ CONFIG_UART_CONSOLE=y # Enable UART driver CONFIG_SERIAL=y +# Enable GPIO driver +CONFIG_GPIO=y + # Enable clock controller CONFIG_CLOCK_CONTROL=y diff --git a/boards/infineon/cy8cproto_063_ble/cy8cproto_063_ble_defconfig b/boards/infineon/cy8cproto_063_ble/cy8cproto_063_ble_defconfig index 98136255552ab..7d0d29ea39cc9 100644 --- a/boards/infineon/cy8cproto_063_ble/cy8cproto_063_ble_defconfig +++ b/boards/infineon/cy8cproto_063_ble/cy8cproto_063_ble_defconfig @@ -18,6 +18,9 @@ CONFIG_UART_CONSOLE=y # Enable UART driver CONFIG_SERIAL=y +# Enable GPIO +CONFIG_GPIO=y + # Enable clock controller CONFIG_CLOCK_CONTROL=y diff --git a/boards/infineon/cyw920829m2evk_02/cyw920829m2evk_02_defconfig b/boards/infineon/cyw920829m2evk_02/cyw920829m2evk_02_defconfig index 14c8035580030..426cd85d30f37 100644 --- a/boards/infineon/cyw920829m2evk_02/cyw920829m2evk_02_defconfig +++ b/boards/infineon/cyw920829m2evk_02/cyw920829m2evk_02_defconfig @@ -18,6 +18,9 @@ CONFIG_UART_CONSOLE=y # Enable UART driver CONFIG_SERIAL=y +# Enable GPIO driver +CONFIG_GPIO=y + # Enable clock controller CONFIG_CLOCK_CONTROL=y diff --git a/boards/nxp/frdm_mcxn947/board.c b/boards/nxp/frdm_mcxn947/board.c index abec73950be1d..26d0c9124d8e4 100644 --- a/boards/nxp/frdm_mcxn947/board.c +++ b/boards/nxp/frdm_mcxn947/board.c @@ -190,10 +190,6 @@ static int frdm_mcxn947_init(void) CLOCK_EnableClock(kCLOCK_Gpio4); #endif -#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(gpio5)) - CLOCK_EnableClock(kCLOCK_Gpio5); -#endif - #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(dac0)) SPC_EnableActiveModeAnalogModules(SPC0, kSPC_controlDac0); CLOCK_SetClkDiv(kCLOCK_DivDac0Clk, 1u); diff --git a/boards/nxp/mimxrt1050_evk/mimxrt1050_evk_mimxrt1052_hyperflash.overlay b/boards/nxp/mimxrt1050_evk/mimxrt1050_evk_mimxrt1052_hyperflash.overlay index cc31988f583dd..346aaca819f8c 100644 --- a/boards/nxp/mimxrt1050_evk/mimxrt1050_evk_mimxrt1052_hyperflash.overlay +++ b/boards/nxp/mimxrt1050_evk/mimxrt1050_evk_mimxrt1052_hyperflash.overlay @@ -39,7 +39,7 @@ ahb-write-wait-unit = <2>; ahb-write-wait-interval = <20>; status = "okay"; - erase-block-size = <4096>; + erase-block-size = ; write-block-size = <16>; partitions { @@ -48,22 +48,22 @@ #size-cells = <1>; boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 DT_SIZE_K(128)>; + reg = <0x00000000 DT_SIZE_K(256)>; }; - /* The MCUBoot swap-move algorithm uses the last 11 sectors + /* The MCUBoot swap-move algorithm uses the last 2 sectors * of the primary slot0 for swap status and move. */ - slot0_partition: partition@20000 { + slot0_partition: partition@40000 { label = "image-0"; - reg = <0x00020000 (DT_SIZE_M(3) + DT_SIZE_K(44))>; + reg = <0x00040000 (DT_SIZE_M(3) + DT_SIZE_K(512))>; }; - slot1_partition: partition@32B000 { + slot1_partition: partition@3C0000 { label = "image-1"; - reg = <0x0032B000 DT_SIZE_M(3)>; + reg = <0x003C0000 DT_SIZE_M(3)>; }; - storage_partition: partition@62B000 { + storage_partition: partition@6C0000 { label = "storage"; - reg = <0x0062B000 (DT_SIZE_M(58) - DT_SIZE_K(172))>; + reg = <0x006C0000 (DT_SIZE_M(58) - DT_SIZE_K(768))>; }; }; }; diff --git a/boards/nxp/mimxrt1060_evk/mimxrt1060_evk_mimxrt1062_hyperflash.overlay b/boards/nxp/mimxrt1060_evk/mimxrt1060_evk_mimxrt1062_hyperflash.overlay index 27e013f2cad8a..0a3bb58d33d7d 100644 --- a/boards/nxp/mimxrt1060_evk/mimxrt1060_evk_mimxrt1062_hyperflash.overlay +++ b/boards/nxp/mimxrt1060_evk/mimxrt1060_evk_mimxrt1062_hyperflash.overlay @@ -37,7 +37,7 @@ ahb-write-wait-unit = <2>; ahb-write-wait-interval = <20>; status = "okay"; - erase-block-size = <4096>; + erase-block-size = ; write-block-size = <16>; partitions { @@ -46,22 +46,22 @@ #size-cells = <1>; boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 DT_SIZE_K(128)>; + reg = <0x00000000 DT_SIZE_K(256)>; }; - /* The MCUBoot swap-move algorithm uses the last 11 sectors + /* The MCUBoot swap-move algorithm uses the last 2 sectors * of the primary slot0 for swap status and move. */ - slot0_partition: partition@20000 { + slot0_partition: partition@40000 { label = "image-0"; - reg = <0x00020000 (DT_SIZE_M(3) + DT_SIZE_K(44))>; + reg = <0x00040000 (DT_SIZE_M(3) + DT_SIZE_K(512))>; }; - slot1_partition: partition@32B000 { + slot1_partition: partition@3C0000 { label = "image-1"; - reg = <0x0032B000 DT_SIZE_M(3)>; + reg = <0x003C0000 DT_SIZE_M(3)>; }; - storage_partition: partition@62B000 { + storage_partition: partition@6C0000 { label = "storage"; - reg = <0x0062B000 (DT_SIZE_M(58) - DT_SIZE_K(172))>; + reg = <0x006C0000 (DT_SIZE_M(58) - DT_SIZE_K(768))>; }; }; }; diff --git a/boards/nxp/mimxrt1062_fmurt6/mimxrt1062_fmurt6.dts b/boards/nxp/mimxrt1062_fmurt6/mimxrt1062_fmurt6.dts index 44a00e72d9a36..de159e4ce240a 100644 --- a/boards/nxp/mimxrt1062_fmurt6/mimxrt1062_fmurt6.dts +++ b/boards/nxp/mimxrt1062_fmurt6/mimxrt1062_fmurt6.dts @@ -200,7 +200,7 @@ ahb-write-wait-unit = <2>; ahb-write-wait-interval = <20>; status = "okay"; - erase-block-size = <4096>; + erase-block-size = ; write-block-size = <16>; partitions { @@ -209,22 +209,22 @@ #size-cells = <1>; boot_partition: partition@0 { label = "mcuboot"; - reg = <0x00000000 DT_SIZE_K(128)>; + reg = <0x00000000 DT_SIZE_K(256)>; }; - /* The MCUBoot swap-move algorithm uses the last 11 sectors + /* The MCUBoot swap-move algorithm uses the last 2 sectors * of the primary slot0 for swap status and move. */ - slot0_partition: partition@20000 { + slot0_partition: partition@40000 { label = "image-0"; - reg = <0x00020000 (DT_SIZE_M(3) + DT_SIZE_K(44))>; + reg = <0x00040000 (DT_SIZE_M(3) + DT_SIZE_K(512))>; }; - slot1_partition: partition@32B000 { + slot1_partition: partition@3C0000 { label = "image-1"; - reg = <0x0032B000 DT_SIZE_M(3)>; + reg = <0x003C0000 DT_SIZE_M(3)>; }; - storage_partition: partition@62B000 { + storage_partition: partition@6C0000 { label = "storage"; - reg = <0x0062B000 (DT_SIZE_M(58) - DT_SIZE_K(172))>; + reg = <0x006C0000 (DT_SIZE_M(58) - DT_SIZE_K(768))>; }; }; }; diff --git a/boards/st/disco_l475_iot1/arduino_r3_connector.dtsi b/boards/st/disco_l475_iot1/arduino_r3_connector.dtsi index b48af67e2a162..05228c5ccb807 100644 --- a/boards/st/disco_l475_iot1/arduino_r3_connector.dtsi +++ b/boards/st/disco_l475_iot1/arduino_r3_connector.dtsi @@ -35,6 +35,6 @@ }; }; -arduino_i2c: &i2c3 {}; +arduino_i2c: &i2c1 {}; arduino_spi: &spi1 {}; arduino_serial: &uart4 {}; diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index d5cd84256d2e6..0d4c0b21a97e2 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -3251,8 +3251,9 @@ function(zephyr_get variable) set(sysbuild_global_${var}) endif() - if(TARGET snippets_scope) - get_property(snippets_${var} TARGET snippets_scope PROPERTY ${var}) + zephyr_scope_exists(scope_defined snippets) + if(scope_defined) + zephyr_get_scoped(snippets_${var} snippets ${var}) endif() endforeach() @@ -3317,11 +3318,54 @@ endfunction(zephyr_get variable) # : Name of new scope. # function(zephyr_create_scope scope) - if(TARGET ${scope}_scope) + zephyr_scope_exists(scope_defined ${scope}) + if(scope_defined) message(FATAL_ERROR "zephyr_create_scope(${scope}) already exists.") endif() - add_custom_target(${scope}_scope) + set_property(GLOBAL PROPERTY scope:${scope} TRUE) +endfunction() + +# Usage: +# zephyr_scope_exists( ) +# +# Check if exists. +# +# : Variable to set with result. +# TRUE if scope exists, FALSE otherwise. +# : Name of scope. +# +function(zephyr_scope_exists result scope) + get_property(scope_defined GLOBAL PROPERTY scope:${scope}) + if(scope_defined) + set(${result} TRUE PARENT_SCOPE) + else() + set(${result} FALSE PARENT_SCOPE) + endif() +endfunction() + +# Usage: +# zephyr_get_scoped( ) +# +# Get the current value of in a specific , as defined by a +# previous zephyr_set() call. The value will be stored in the var. +# +# : Variable to store the value in +# : Scope for the variable look up +# : Name to look up in the specific scope +# +function(zephyr_get_scoped output scope var) + zephyr_scope_exists(scope_defined ${scope}) + if(NOT scope_defined) + message(FATAL_ERROR "zephyr_get_scoped(): scope ${scope} doesn't exists.") + endif() + + get_property(value GLOBAL PROPERTY ${scope}_scope:${var}) + if(DEFINED value) + set(${output} "${value}" PARENT_SCOPE) + else() + unset(${output} PARENT_SCOPE) + endif() endfunction() # Usage: @@ -3342,7 +3386,8 @@ function(zephyr_set variable) zephyr_check_arguments_required_all(zephyr_set SET_VAR SCOPE) - if(NOT TARGET ${SET_VAR_SCOPE}_scope) + zephyr_scope_exists(scope_defined ${SET_VAR_SCOPE}) + if(NOT scope_defined) message(FATAL_ERROR "zephyr_set(... SCOPE ${SET_VAR_SCOPE}) doesn't exists.") endif() @@ -3350,8 +3395,8 @@ function(zephyr_set variable) set(property_args APPEND) endif() - set_property(TARGET ${SET_VAR_SCOPE}_scope ${property_args} - PROPERTY ${variable} ${SET_VAR_UNPARSED_ARGUMENTS} + set_property(GLOBAL ${property_args} PROPERTY + ${SET_VAR_SCOPE}_scope:${variable} ${SET_VAR_UNPARSED_ARGUMENTS} ) endfunction() @@ -5871,16 +5916,11 @@ if(CMAKE_SCRIPT_MODE_FILE) # This silence the error: 'set_target_properties command is not scriptable' endfunction() - function(zephyr_set variable) - # This silence the error: zephyr_set(... SCOPE ) doesn't exists. - endfunction() - # Build info creates a custom target for handling of build info. # build_info is not needed in script mode but still called by Zephyr CMake # modules. Therefore disable build_info(...) in when including # extensions.cmake in script mode. function(build_info) - # This silence the error: 'YAML context 'build_info' does not exist.' - # 'Remember to create a YAML context' + # This silence the error: 'Unknown CMake command "yaml_context"' endfunction() endif() diff --git a/cmake/modules/yaml.cmake b/cmake/modules/yaml.cmake index 50d6c7cc74622..9ab9b333fa46c 100644 --- a/cmake/modules/yaml.cmake +++ b/cmake/modules/yaml.cmake @@ -93,7 +93,8 @@ function(yaml_context) ) endif() - if(TARGET ${ARG_YAML_NAME}_scope) + zephyr_scope_exists(scope_defined ${ARG_YAML_NAME}) + if(scope_defined) list(POP_FRONT ARG_YAML_UNPARSED_ARGUMENTS out-var) set(${out-var} TRUE PARENT_SCOPE) else() @@ -183,7 +184,7 @@ function(yaml_get out_var) zephyr_check_arguments_required_all(${CMAKE_CURRENT_FUNCTION} ARG_YAML NAME KEY) internal_yaml_context_required(NAME ${ARG_YAML_NAME}) - get_property(json_content TARGET ${ARG_YAML_NAME}_scope PROPERTY JSON) + zephyr_get_scoped(json_content ${ARG_YAML_NAME} JSON) # We specify error variable to avoid a fatal error. # If key is not found, then type becomes '-NOTFOUND' and value handling is done below. @@ -224,7 +225,7 @@ function(yaml_length out_var) zephyr_check_arguments_required_all(${CMAKE_CURRENT_FUNCTION} ARG_YAML NAME KEY) internal_yaml_context_required(NAME ${ARG_YAML_NAME}) - get_property(json_content TARGET ${ARG_YAML_NAME}_scope PROPERTY JSON) + zephyr_get_scoped(json_content ${ARG_YAML_NAME} JSON) string(JSON type ERROR_VARIABLE error TYPE "${json_content}" ${ARG_YAML_KEY}) if(type STREQUAL ARRAY) @@ -262,7 +263,7 @@ function(yaml_set) zephyr_check_arguments_exclusive(${CMAKE_CURRENT_FUNCTION} ARG_YAML VALUE LIST) internal_yaml_context_required(NAME ${ARG_YAML_NAME}) - get_property(json_content TARGET ${ARG_YAML_NAME}_scope PROPERTY JSON) + zephyr_get_scoped(json_content ${ARG_YAML_NAME} JSON) set(yaml_key_undefined ${ARG_YAML_KEY}) foreach(k ${yaml_key_undefined}) @@ -335,7 +336,7 @@ function(yaml_remove) zephyr_check_arguments_required_all(${CMAKE_CURRENT_FUNCTION} ARG_YAML NAME KEY) internal_yaml_context_required(NAME ${ARG_YAML_NAME}) - get_property(json_content TARGET ${ARG_YAML_NAME}_scope PROPERTY JSON) + zephyr_get_scoped(json_content ${ARG_YAML_NAME} JSON) string(JSON json_content REMOVE "${json_content}" ${ARG_YAML_KEY}) zephyr_set(JSON "${json_content}" SCOPE ${ARG_YAML_NAME}) @@ -359,18 +360,18 @@ function(yaml_save) zephyr_check_arguments_required(${CMAKE_CURRENT_FUNCTION} ARG_YAML NAME) internal_yaml_context_required(NAME ${ARG_YAML_NAME}) - get_target_property(yaml_file ${ARG_YAML_NAME}_scope FILE) + zephyr_get_scoped(yaml_file ${ARG_YAML_NAME} FILE) if(NOT yaml_file) zephyr_check_arguments_required(${CMAKE_CURRENT_FUNCTION} ARG_YAML FILE) endif() - get_property(json_content TARGET ${ARG_YAML_NAME}_scope PROPERTY JSON) + zephyr_get_scoped(json_content ${ARG_YAML_NAME} JSON) to_yaml("${json_content}" 0 yaml_out) if(DEFINED ARG_YAML_FILE) set(yaml_file ${ARG_YAML_FILE}) else() - get_property(yaml_file TARGET ${ARG_YAML_NAME}_scope PROPERTY FILE) + zephyr_get_scoped(yaml_file ${ARG_YAML_NAME} FILE) endif() if(EXISTS ${yaml_file}) FILE(RENAME ${yaml_file} ${yaml_file}.bak) diff --git a/doc/_static/css/custom.css b/doc/_static/css/custom.css index 3713d09ea0870..4f6fef8b67a59 100644 --- a/doc/_static/css/custom.css +++ b/doc/_static/css/custom.css @@ -921,6 +921,10 @@ dark-mode-toggle::part(toggleLabel){ font-size: unset; } +div.graphviz > object { + filter: var(--graphviz-filter); +} + /* Home page grid display */ .grid { list-style-type: none !important; diff --git a/doc/_static/css/dark.css b/doc/_static/css/dark.css index 47d555242f6a8..bb1c20c0b5cdd 100644 --- a/doc/_static/css/dark.css +++ b/doc/_static/css/dark.css @@ -93,4 +93,6 @@ --btn-neutral-background-color: #404040; --btn-neutral-hover-background-color: #505050; --footer-color: #aaa; + + --graphviz-filter: invert(0.9) brightness(1.2); } diff --git a/doc/_static/css/light.css b/doc/_static/css/light.css index 0389650278c7c..757ec6f1e1b0c 100644 --- a/doc/_static/css/light.css +++ b/doc/_static/css/light.css @@ -91,4 +91,6 @@ --btn-neutral-background-color: #f3f6f6; --btn-neutral-hover-background-color: #e5ebeb; --footer-color: #808080; + + --graphviz-filter: none; } diff --git a/doc/_templates/zversions.html b/doc/_templates/zversions.html index 9bed578cce8d6..c24195a7b9cbe 100644 --- a/doc/_templates/zversions.html +++ b/doc/_templates/zversions.html @@ -2,7 +2,7 @@
Zephyr Project - v: latest + v: {{ current_version if is_release else "latest" }}
diff --git a/doc/conf.py b/doc/conf.py index 94068de899db8..fc7e20fd7b250 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -325,6 +325,9 @@ "-Ncolor=gray60", "-Nfontcolor=gray25", "-Ecolor=gray60", + "-Gfontname=system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif", + "-Nfontname=system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif", + "-Efontname=SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,Courier,monospace", ] # -- Options for sphinx_copybutton ---------------------------------------- diff --git a/doc/releases/release-notes-4.0.rst b/doc/releases/release-notes-4.0.rst index 8b9ede8f11eba..57b858fa75811 100644 --- a/doc/releases/release-notes-4.0.rst +++ b/doc/releases/release-notes-4.0.rst @@ -2,6 +2,48 @@ .. _zephyr_4.0: +.. _zephyr_4.0.1: + +Zephyr 4.0.1 +############ + +This is an LTS maintenance release with fixes. + +Security Vulnerability Related +****************************** + +The following CVEs are addressed by this release: + +* :cve:`2025-27809` `TLS clients may unwittingly skip server authentication + `_ +* :cve:`2025-27810` `Potential authentication bypass in TLS handshake + `_ + +More detailed information can be found in: +https://docs.zephyrproject.org/latest/security/vulnerabilities.html + +Issues fixed +************ + +These GitHub issues were addressed since the previous 4.0.0 tagged release: + +Mbed TLS +******** + +Mbed TLS was updated to version 3.6.3 (from 3.6.2). The release notes can be found at: +https://github.com/Mbed-TLS/mbedtls/releases/tag/mbedtls-3.6.3 + +Mbed TLS 3.6 is an LTS release that will be supported +with security and bug fixes until at least March 2027. + +Trusted Firmware-M (TF-M) +************************* + +TF-M was updated to version 2.1.2 (from 2.1.1). The release notes can be found at: +https://trustedfirmware-m.readthedocs.io/en/tf-mv2.1.2/releases/2.1.2.html + +.. _zephyr_4.0.0: + Zephyr 4.0.0 ############ diff --git a/doc/zephyr.doxyfile.in b/doc/zephyr.doxyfile.in index abd4440f5aa16..8e452493cf0b5 100644 --- a/doc/zephyr.doxyfile.in +++ b/doc/zephyr.doxyfile.in @@ -279,7 +279,7 @@ TAB_SIZE = 8 # with the commands \{ and \} for these it is advised to use the version @{ and # @} or use a double escape (\\{ and \\}) -ALIASES = "kconfig{1}=\verbatim \1 \endverbatim" \ +ALIASES = "kconfig{1}=\c \1" \ "req{1}=\ref ZEPH_\1 \"ZEPH-\1\"" \ "satisfy{1}=\xrefitem satisfy \"Satisfies requirement\" \"Requirement Implementation\" \1" \ "verify{1}=\xrefitem verify \"Verifies requirement\" \"Requirement Verification\" \1" \ diff --git a/drivers/auxdisplay/auxdisplay_jhd1313.c b/drivers/auxdisplay/auxdisplay_jhd1313.c index 9b4ef08e88b91..669c2653cd715 100644 --- a/drivers/auxdisplay/auxdisplay_jhd1313.c +++ b/drivers/auxdisplay/auxdisplay_jhd1313.c @@ -205,7 +205,7 @@ static int auxdisplay_jhd1313_backlight_set(const struct device *dev, uint8_t co const struct auxdisplay_jhd1313_config *config = dev->config; struct auxdisplay_jhd1313_data *data = dev->data; - if (colour > ARRAY_SIZE(colour_define)) { + if (colour >= ARRAY_SIZE(colour_define)) { LOG_WRN("Selected colour is too high a value"); return -EINVAL; } diff --git a/drivers/can/can_tcan4x5x.c b/drivers/can/can_tcan4x5x.c index a68ea5e22a485..74ad1168fb744 100644 --- a/drivers/can/can_tcan4x5x.c +++ b/drivers/can/can_tcan4x5x.c @@ -508,8 +508,10 @@ static int tcan4x5x_wake(const struct device *dev) static int tcan4x5x_reset(const struct device *dev) { +#if TCAN4X5X_RST_GPIO_SUPPORT const struct can_mcan_config *mcan_config = dev->config; const struct tcan4x5x_config *tcan_config = mcan_config->custom; +#endif /* TCAN4X5X_RST_GPIO_SUPPORT */ int err; err = tcan4x5x_wake(dev); diff --git a/drivers/entropy/fake_entropy_native_posix.c b/drivers/entropy/fake_entropy_native_posix.c index e9ee4ab92844d..a050a56f2d19f 100644 --- a/drivers/entropy/fake_entropy_native_posix.c +++ b/drivers/entropy/fake_entropy_native_posix.c @@ -42,7 +42,10 @@ static int entropy_native_posix_get_entropy(const struct device *dev, */ long value = nsi_host_random(); - size_t to_copy = MIN(length, sizeof(long int)); + /* The host random() provides a number between 0 and 2**31-1. Bit 32 is always 0. + * So let's just use the lower 3 bytes discarding the upper 7 bits + */ + size_t to_copy = MIN(length, 3); memcpy(buffer, &value, to_copy); buffer += to_copy; diff --git a/drivers/ethernet/eth_stm32_hal.c b/drivers/ethernet/eth_stm32_hal.c index 0c468f0fd7f33..224ce2f7876d4 100644 --- a/drivers/ethernet/eth_stm32_hal.c +++ b/drivers/ethernet/eth_stm32_hal.c @@ -56,7 +56,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #define PHY_ADDR CONFIG_ETH_STM32_HAL_PHY_ADDRESS -#if defined(CONFIG_MDIO) +#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_mdio) #define DEVICE_PHY_BY_NAME(n) \ DEVICE_DT_GET(DT_CHILD(DT_INST_CHILD(n, mdio), _CONCAT(ethernet_phy_, PHY_ADDR))) @@ -239,7 +239,7 @@ static HAL_StatusTypeDef read_eth_phy_register(ETH_HandleTypeDef *heth, uint32_t PHYReg, uint32_t *RegVal) { -#if defined(CONFIG_MDIO) +#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_mdio) return phy_read(eth_stm32_phy_dev, PHYReg, RegVal); #elif defined(CONFIG_ETH_STM32_HAL_API_V2) return HAL_ETH_ReadPHYRegister(heth, PHYAddr, PHYReg, RegVal); diff --git a/drivers/flash/flash_handlers.c b/drivers/flash/flash_handlers.c index b560ea8ae4baa..f8cdaaf8f233a 100644 --- a/drivers/flash/flash_handlers.c +++ b/drivers/flash/flash_handlers.c @@ -31,7 +31,7 @@ static inline int z_vrfy_flash_write(const struct device *dev, off_t offset, static inline int z_vrfy_flash_erase(const struct device *dev, off_t offset, size_t size) { - K_OOPS(K_SYSCALL_DRIVER_FLASH(dev, erase)); + K_OOPS(K_SYSCALL_OBJ(dev, K_OBJ_DRIVER_FLASH)); return z_impl_flash_erase((const struct device *)dev, offset, size); } #include diff --git a/drivers/flash/flash_mcux_flexspi_nor.c b/drivers/flash/flash_mcux_flexspi_nor.c index ac6fdac8223f6..2d536fdc53f16 100644 --- a/drivers/flash/flash_mcux_flexspi_nor.c +++ b/drivers/flash/flash_mcux_flexspi_nor.c @@ -944,8 +944,10 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data, } /* Switch on manufacturer and vendor ID */ - switch (vendor_id & 0xFFFF) { - case 0x609d: /* IS25LP flash, needs P[4:3] cleared with same method as IS25WP */ + switch (vendor_id & 0xFFFFFF) { + case 0x16609d: /* IS25LP032 flash, needs P[4:3] cleared with same method as IS25WP */ + case 0x17609d: /* IS25LP064 */ + case 0x18609d: /* IS25LP128 */ read_params = 0xE0U; ret = flash_flexspi_nor_is25_clear_read_param(data, flexspi_lut, &read_params); if (ret < 0) { @@ -959,7 +961,9 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data, } /* Still return an error- we want the JEDEC configuration to run */ return -ENOTSUP; - case 0x709d: + case 0x16709d: /* IS25WP032 */ + case 0x17709d: /* IS25WP064 */ + case 0x18709d: /* IS25WP128 */ /* * IS25WP flash. We can support this flash with the JEDEC probe, * but we need to insure P[6:3] are at the default value @@ -977,15 +981,8 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data, } /* Still return an error- we want the JEDEC configuration to run */ return -ENOTSUP; - case 0x40ef: - if ((vendor_id & 0xFFFFFF) != 0x2040ef) { - /* - * This is not the correct flash chip, and will not - * support the LUT table. Return here - */ - return -ENOTSUP; - } - /* W25Q512JV flash, use 4 byte read/write */ + case 0x2040ef: + /* W25Q512JV-IQ/IN flash, use 4 byte read/write */ flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ( kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 32); @@ -1015,14 +1012,7 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data, /* Device uses bit 1 of status reg 2 for QE */ return flash_flexspi_nor_quad_enable(data, flexspi_lut, JESD216_DW15_QER_VAL_S2B1v5); - case 0x60ef: - if ((vendor_id & 0xFFFFFF) != 0x2060ef) { - /* - * This is not the correct flash chip, and will not - * support the LUT table. Return here - */ - return -ENOTSUP; - } + case 0x2060ef: /* W25Q512NW-IQ/IN flash, use 4 byte read/write */ flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ( kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B, @@ -1053,8 +1043,8 @@ static int flash_flexspi_nor_check_jedec(struct flash_flexspi_nor_data *data, /* Device uses bit 1 of status reg 2 for QE */ return flash_flexspi_nor_quad_enable(data, flexspi_lut, JESD216_DW15_QER_VAL_S2B1v5); - case 0x25C2: - /* MX25 flash, use 4 byte read/write */ + case 0x3A25C2: + /* MX25U51245G flash, use 4 byte read/write */ flexspi_lut[READ][0] = FLEXSPI_LUT_SEQ( kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, SPI_NOR_CMD_4READ_4B, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_4PAD, 32); diff --git a/drivers/flash/soc_flash_mcux.c b/drivers/flash/soc_flash_mcux.c index 8351c12162d3a..d27e58f528fb5 100644 --- a/drivers/flash/soc_flash_mcux.c +++ b/drivers/flash/soc_flash_mcux.c @@ -93,7 +93,7 @@ static uint32_t get_cmd_status(uint32_t cmd, uint32_t addr, size_t len) } /* This function prevents erroneous reading. Some ECC enabled devices will - * crash when reading an erased or wrongly programmed area. + * crash when reading an erased area. */ static status_t is_area_readable(uint32_t addr, size_t len) { @@ -102,21 +102,13 @@ static status_t is_area_readable(uint32_t addr, size_t len) key = irq_lock(); - /* Check if the are is correctly programmed and can be read. */ - status = get_cmd_status(FMC_CMD_MARGIN_CHECK, addr, len); - if (status & FMC_STATUS_FAILURES) { - /* If the area was erased, ECC errors are triggered on read. */ - status = get_cmd_status(FMC_CMD_BLANK_CHECK, addr, len); - if (!(status & FMC_STATUS_FAIL)) { - LOG_DBG("read request on erased addr:0x%08x size:%d", - addr, len); - irq_unlock(key); - return -ENODATA; - } - LOG_DBG("read request error for addr:0x%08x size:%d", + /* If the area was erased, ECC errors are triggered on read. */ + status = get_cmd_status(FMC_CMD_BLANK_CHECK, addr, len); + if (!(status & FMC_STATUS_FAIL)) { + LOG_DBG("read request on erased addr:0x%08x size:%d", addr, len); irq_unlock(key); - return -EIO; + return -ENODATA; } irq_unlock(key); diff --git a/drivers/gpio/gpio_adp5585.c b/drivers/gpio/gpio_adp5585.c index 0a1da5e63f4aa..4ebadfeb15d29 100644 --- a/drivers/gpio/gpio_adp5585.c +++ b/drivers/gpio/gpio_adp5585.c @@ -143,14 +143,14 @@ static int gpio_adp5585_config(const struct device *dev, gpio_pin_t pin, gpio_fl data->output |= BIT(pin); } if (bank == 0) { - /* reg_value for ADP5585_GPO_OUT_MODE */ + /* reg_value for ADP5585_GPO_DATA_OUT */ reg_value = (uint8_t)data->output; } else { - /* reg_value for ADP5585_GPO_OUT_MODE */ + /* reg_value for ADP5585_GPO_DATA_OUT */ reg_value = (uint8_t)(data->output >> 8); } ret = i2c_reg_write_byte_dt(&parent_cfg->i2c_bus, - ADP5585_GPO_OUT_MODE_A + bank, + ADP5585_GPO_DATA_OUT_A + bank, reg_value); if (ret != 0) { goto out; diff --git a/drivers/i2c/target/eeprom_target.c b/drivers/i2c/target/eeprom_target.c index e2820749b206b..69ae35cfcd8d0 100644 --- a/drivers/i2c/target/eeprom_target.c +++ b/drivers/i2c/target/eeprom_target.c @@ -179,9 +179,19 @@ static void eeprom_target_buf_write_received(struct i2c_target_config *config, struct i2c_eeprom_target_data *data = CONTAINER_OF(config, struct i2c_eeprom_target_data, config); - /* The first byte is offset */ - data->buffer_idx = *ptr; - memcpy(&data->buffer[data->buffer_idx], ptr + 1, len - 1); + /* The first byte(s) is offset */ + uint32_t idx_write_cnt = 0; + + data->buffer_idx = 0; + while (idx_write_cnt < (data->address_width >> 3)) { + data->buffer_idx = (data->buffer_idx << 8) | *ptr++; + len--; + idx_write_cnt++; + } + + if (len > 0) { + memcpy(&data->buffer[data->buffer_idx], ptr, len); + } } static int eeprom_target_buf_read_requested(struct i2c_target_config *config, diff --git a/drivers/led/lp50xx.c b/drivers/led/lp50xx.c index 82333d6b14c4a..069ddc9ab05cc 100644 --- a/drivers/led/lp50xx.c +++ b/drivers/led/lp50xx.c @@ -153,7 +153,8 @@ static int lp50xx_set_color(const struct device *dev, uint32_t led, { const struct lp50xx_config *config = dev->config; const struct led_info *led_info = lp50xx_led_to_info(config, led); - uint8_t buf[4]; + uint8_t buf[LP50XX_COLORS_PER_LED + 1]; + uint8_t i; if (!led_info) { return -ENODEV; @@ -170,11 +171,11 @@ static int lp50xx_set_color(const struct device *dev, uint32_t led, buf[0] = LP50XX_OUT0_COLOR(config->num_modules); buf[0] += LP50XX_COLORS_PER_LED * led_info->index; - buf[1] = color[0]; - buf[2] = color[1]; - buf[3] = color[2]; + for (i = 0; i < led_info->num_colors; i++) { + buf[1 + i] = color[i]; + } - return i2c_write_dt(&config->bus, buf, sizeof(buf)); + return i2c_write_dt(&config->bus, buf, led_info->num_colors + 1); } static int lp50xx_write_channels(const struct device *dev, @@ -266,6 +267,7 @@ static int lp50xx_enable(const struct device *dev, bool enable) static int lp50xx_init(const struct device *dev) { const struct lp50xx_config *config = dev->config; + uint8_t led; int err; if (!i2c_is_ready_dt(&config->bus)) { @@ -273,6 +275,7 @@ static int lp50xx_init(const struct device *dev) return -ENODEV; } + /* Check LED configuration found in DT */ if (config->num_leds > config->max_leds) { LOG_ERR("%s: invalid number of LEDs %d (max %d)", dev->name, @@ -280,6 +283,16 @@ static int lp50xx_init(const struct device *dev) config->max_leds); return -EINVAL; } + for (led = 0; led < config->num_leds; led++) { + const struct led_info *led_info = + lp50xx_led_to_info(config, led); + + if (led_info->num_colors > LP50XX_COLORS_PER_LED) { + LOG_ERR("%s: LED %d: invalid number of colors (max %d)", + dev->name, led, LP50XX_COLORS_PER_LED); + return -EINVAL; + } + } /* Configure GPIO if present */ if (config->gpio_enable.port != NULL) { diff --git a/drivers/retained_mem/retained_mem_nrf_ram_ctrl.c b/drivers/retained_mem/retained_mem_nrf_ram_ctrl.c index 8be3d5c35a36c..35568ef4ec51d 100644 --- a/drivers/retained_mem/retained_mem_nrf_ram_ctrl.c +++ b/drivers/retained_mem/retained_mem_nrf_ram_ctrl.c @@ -11,7 +11,7 @@ #define _BUILD_MEM_REGION(node_id) \ {.dt_addr = DT_REG_ADDR(DT_PARENT(node_id)),\ - .dt_size = DT_REG_SIZE(DT_PARENT(node_id))} + .dt_size = DT_REG_SIZE(DT_PARENT(node_id))}, struct ret_mem_region { uintptr_t dt_addr; diff --git a/drivers/sensor/adi/adxl345/Kconfig b/drivers/sensor/adi/adxl345/Kconfig index 9463eb0c51cc4..7816378fba51a 100644 --- a/drivers/sensor/adi/adxl345/Kconfig +++ b/drivers/sensor/adi/adxl345/Kconfig @@ -37,7 +37,6 @@ endchoice config ADXL345_STREAM bool "Use FIFO to stream data" select ADXL345_TRIGGER - default y depends on SPI_RTIO depends on SENSOR_ASYNC_API help diff --git a/drivers/sensor/adi/adxl345/adxl345.c b/drivers/sensor/adi/adxl345/adxl345.c index d5f07bad26585..0226a0c71c10b 100644 --- a/drivers/sensor/adi/adxl345/adxl345.c +++ b/drivers/sensor/adi/adxl345/adxl345.c @@ -229,7 +229,7 @@ static int adxl345_attr_set_odr(const struct device *dev, const struct sensor_value *val) { enum adxl345_odr odr; - struct adxl345_dev_config *cfg = (struct adxl345_dev_config *)dev->config; + struct adxl345_dev_data *data = dev->data; switch (val->val1) { case 12: @@ -257,7 +257,7 @@ static int adxl345_attr_set_odr(const struct device *dev, int ret = adxl345_set_odr(dev, odr); if (ret == 0) { - cfg->odr = odr; + data->odr = odr; } return ret; @@ -281,6 +281,7 @@ int adxl345_read_sample(const struct device *dev, { int16_t raw_x, raw_y, raw_z; uint8_t axis_data[6], status1; + struct adxl345_dev_data *data = dev->data; if (!IS_ENABLED(CONFIG_ADXL345_TRIGGER)) { do { @@ -303,6 +304,9 @@ int adxl345_read_sample(const struct device *dev, sample->y = raw_y; sample->z = raw_z; + sample->selected_range = data->selected_range; + sample->is_full_res = data->is_full_res; + return 0; } @@ -453,11 +457,13 @@ static int adxl345_init(const struct device *dev) return -ENODEV; } +#if CONFIG_ADXL345_STREAM rc = adxl345_reg_write_byte(dev, ADXL345_FIFO_CTL_REG, ADXL345_FIFO_STREAM_MODE); if (rc < 0) { LOG_ERR("FIFO enable failed\n"); return -EIO; } +#endif rc = adxl345_reg_write_byte(dev, ADXL345_DATA_FORMAT_REG, ADXL345_RANGE_8G); if (rc < 0) { diff --git a/drivers/sensor/adi/adxl345/adxl345.h b/drivers/sensor/adi/adxl345/adxl345.h index 4fc55d307c1a3..eece90fd4887b 100644 --- a/drivers/sensor/adi/adxl345/adxl345.h +++ b/drivers/sensor/adi/adxl345/adxl345.h @@ -153,6 +153,7 @@ struct adxl345_dev_data { struct adxl345_fifo_config fifo_config; uint8_t is_full_res; uint8_t selected_range; + enum adxl345_odr odr; #ifdef CONFIG_ADXL345_TRIGGER struct gpio_callback gpio_cb; @@ -201,6 +202,7 @@ struct adxl345_sample { uint8_t res: 7; #endif /* CONFIG_ADXL345_STREAM */ uint8_t selected_range; + bool is_full_res; int16_t x; int16_t y; int16_t z; diff --git a/drivers/sensor/adi/adxl345/adxl345_decoder.c b/drivers/sensor/adi/adxl345/adxl345_decoder.c index 7a1bf53cb0584..1f39fb9d1d141 100644 --- a/drivers/sensor/adi/adxl345/adxl345_decoder.c +++ b/drivers/sensor/adi/adxl345/adxl345_decoder.c @@ -6,17 +6,42 @@ #include "adxl345.h" -#ifdef CONFIG_ADXL345_STREAM +/** The q-scale factor will always be the same, as the nominal LSB/g + * changes at the same rate the selected shift parameter per range: + * + * - At 2G: 256 LSB/g, 10-bits resolution. + * - At 4g: 128 LSB/g, 10-bits resolution. + * - At 8g: 64 LSB/g, 10-bits resolution. + * - At 16g 32 LSB/g, 10-bits resolution. + */ +static const uint32_t qscale_factor_no_full_res[] = { + /* (1.0 / Resolution-LSB-per-g * (2^31 / 2^5) * SENSOR_G / 1000000 */ + [ADXL345_RANGE_2G] = UINT32_C(2570754), + /* (1.0 / Resolution-LSB-per-g) * (2^31 / 2^6) * SENSOR_G / 1000000 */ + [ADXL345_RANGE_4G] = UINT32_C(2570754), + /* (1.0 / Resolution-LSB-per-g) * (2^31 / 2^7) ) * SENSOR_G / 1000000 */ + [ADXL345_RANGE_8G] = UINT32_C(2570754), + /* (1.0 / Resolution-LSB-per-g) * (2^31 / 2^8) ) * SENSOR_G / 1000000 */ + [ADXL345_RANGE_16G] = UINT32_C(2570754), +}; -#define SENSOR_SCALING_FACTOR (SENSOR_G / (16 * 1000 / 100)) -static const uint32_t accel_period_ns[] = { - [ADXL345_ODR_12HZ] = UINT32_C(1000000000) / 12, - [ADXL345_ODR_25HZ] = UINT32_C(1000000000) / 25, - [ADXL345_ODR_50HZ] = UINT32_C(1000000000) / 50, - [ADXL345_ODR_100HZ] = UINT32_C(1000000000) / 100, - [ADXL345_ODR_200HZ] = UINT32_C(1000000000) / 200, - [ADXL345_ODR_400HZ] = UINT32_C(1000000000) / 400, +/** Sensitivities based on Range: + * + * - At 2G: 256 LSB/g, 10-bits resolution. + * - At 4g: 256 LSB/g, 11-bits resolution. + * - At 8g: 256 LSB/g, 12-bits resolution. + * - At 16g 256 LSB/g, 13-bits resolution. + */ +static const uint32_t qscale_factor_full_res[] = { + /* (1.0 / Resolution-LSB-per-g) * (2^31 / 2^5) * SENSOR_G / 1000000 */ + [ADXL345_RANGE_2G] = UINT32_C(2570754), + /* (1.0 / Resolution-LSB-per-g) * (2^31 / 2^6) * SENSOR_G / 1000000 */ + [ADXL345_RANGE_4G] = UINT32_C(1285377), + /* (1.0 / Resolution-LSB-per-g) * (2^31 / 2^7) ) * SENSOR_G / 1000000 */ + [ADXL345_RANGE_8G] = UINT32_C(642688), + /* (1.0 / Resolution-LSB-per-g) * (2^31 / 2^8) ) * SENSOR_G / 1000000 */ + [ADXL345_RANGE_16G] = UINT32_C(321344), }; static const uint32_t range_to_shift[] = { @@ -26,30 +51,6 @@ static const uint32_t range_to_shift[] = { [ADXL345_RANGE_16G] = 8, }; -/* (1 / sensitivity) * (pow(2,31) / pow(2,shift)) * (unit_scaler) */ -static const uint32_t qscale_factor_no_full_res[] = { - /* (1.0 / ADXL362_ACCEL_2G_LSB_PER_G) * (2^31 / 2^5) * SENSOR_G / 1000000 */ - [ADXL345_RANGE_2G] = UINT32_C(2569011), - /* (1.0 / ADXL362_ACCEL_4G_LSB_PER_G) * (2^31 / 2^6) * SENSOR_G / 1000000 */ - [ADXL345_RANGE_4G] = UINT32_C(642253), - /* (1.0 / ADXL362_ACCEL_8G_LSB_PER_G) * (2^31 / 2^7) ) * SENSOR_G / 1000000 */ - [ADXL345_RANGE_8G] = UINT32_C(160563), - /* (1.0 / ADXL362_ACCEL_8G_LSB_PER_G) * (2^31 / 2^8) ) * SENSOR_G / 1000000 */ - [ADXL345_RANGE_16G] = UINT32_C(40141), -}; - -/* (1 / sensitivity) * (pow(2,31) / pow(2,shift)) * (unit_scaler) */ -static const uint32_t qscale_factor_full_res[] = { - /* (1.0 / ADXL362_ACCEL_2G_LSB_PER_G) * (2^31 / 2^5) * SENSOR_G / 1000000 */ - [ADXL345_RANGE_2G] = UINT32_C(2569011), - /* (1.0 / ADXL362_ACCEL_4G_LSB_PER_G) * (2^31 / 2^6) * SENSOR_G / 1000000 */ - [ADXL345_RANGE_4G] = UINT32_C(1284506), - /* (1.0 / ADXL362_ACCEL_8G_LSB_PER_G) * (2^31 / 2^7) ) * SENSOR_G / 1000000 */ - [ADXL345_RANGE_8G] = UINT32_C(642253), - /* (1.0 / ADXL362_ACCEL_8G_LSB_PER_G) * (2^31 / 2^8) ) * SENSOR_G / 1000000 */ - [ADXL345_RANGE_16G] = UINT32_C(321126), -}; - static inline void adxl345_accel_convert_q31(q31_t *out, int16_t sample, int32_t range, uint8_t is_full_res) { @@ -76,15 +77,28 @@ static inline void adxl345_accel_convert_q31(q31_t *out, int16_t sample, int32_t } break; } + *out = sample * qscale_factor_full_res[range]; } else { if (sample & BIT(9)) { sample |= ADXL345_COMPLEMENT; } + *out = sample * qscale_factor_no_full_res[range]; } - - *out = sample * qscale_factor_no_full_res[range]; } +#ifdef CONFIG_ADXL345_STREAM + +#define SENSOR_SCALING_FACTOR (SENSOR_G / (16 * 1000 / 100)) + +static const uint32_t accel_period_ns[] = { + [ADXL345_ODR_12HZ] = UINT32_C(1000000000) / 12, + [ADXL345_ODR_25HZ] = UINT32_C(1000000000) / 25, + [ADXL345_ODR_50HZ] = UINT32_C(1000000000) / 50, + [ADXL345_ODR_100HZ] = UINT32_C(1000000000) / 100, + [ADXL345_ODR_200HZ] = UINT32_C(1000000000) / 200, + [ADXL345_ODR_400HZ] = UINT32_C(1000000000) / 400, +}; + static int adxl345_decode_stream(const uint8_t *buffer, struct sensor_chan_spec chan_spec, uint32_t *fit, uint16_t max_count, void *data_out) { @@ -208,7 +222,12 @@ static int adxl345_decode_sample(const struct adxl345_sample *data, struct sensor_chan_spec chan_spec, uint32_t *fit, uint16_t max_count, void *data_out) { - struct sensor_value *out = (struct sensor_value *)data_out; + struct sensor_three_axis_data *out = (struct sensor_three_axis_data *)data_out; + + memset(out, 0, sizeof(struct sensor_three_axis_data)); + out->header.base_timestamp_ns = k_ticks_to_ns_floor64(k_uptime_ticks()); + out->header.reading_count = 1; + out->shift = range_to_shift[data->selected_range]; if (*fit > 0) { return -ENOTSUP; @@ -216,9 +235,12 @@ static int adxl345_decode_sample(const struct adxl345_sample *data, switch (chan_spec.chan_type) { case SENSOR_CHAN_ACCEL_XYZ: - adxl345_accel_convert(out++, data->x); - adxl345_accel_convert(out++, data->y); - adxl345_accel_convert(out, data->z); + adxl345_accel_convert_q31(&out->readings->x, data->x, data->selected_range, + data->is_full_res); + adxl345_accel_convert_q31(&out->readings->y, data->y, data->selected_range, + data->is_full_res); + adxl345_accel_convert_q31(&out->readings->z, data->z, data->selected_range, + data->is_full_res); break; default: return -ENOTSUP; @@ -226,7 +248,7 @@ static int adxl345_decode_sample(const struct adxl345_sample *data, *fit = 1; - return 0; + return 1; } static int adxl345_decoder_decode(const uint8_t *buffer, struct sensor_chan_spec chan_spec, @@ -259,10 +281,33 @@ static bool adxl345_decoder_has_trigger(const uint8_t *buffer, enum sensor_trigg } } +static int adxl345_get_size_info(struct sensor_chan_spec channel, size_t *base_size, + size_t *frame_size) +{ + __ASSERT_NO_MSG(base_size != NULL); + __ASSERT_NO_MSG(frame_size != NULL); + + if (channel.chan_type >= SENSOR_CHAN_ALL) { + return -ENOTSUP; + } + + switch (channel.chan_type) { + case SENSOR_CHAN_ACCEL_XYZ: + *base_size = sizeof(struct sensor_three_axis_data); + *frame_size = sizeof(struct sensor_three_axis_sample_data); + return 0; + default: + break; + } + + return -ENOTSUP; +} + SENSOR_DECODER_API_DT_DEFINE() = { .get_frame_count = adxl345_decoder_get_frame_count, .decode = adxl345_decoder_decode, .has_trigger = adxl345_decoder_has_trigger, + .get_size_info = adxl345_get_size_info, }; int adxl345_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder) diff --git a/drivers/sensor/adi/adxl345/adxl345_stream.c b/drivers/sensor/adi/adxl345/adxl345_stream.c index c07778dd3dabe..29ec65a6907ef 100644 --- a/drivers/sensor/adi/adxl345/adxl345_stream.c +++ b/drivers/sensor/adi/adxl345/adxl345_stream.c @@ -159,7 +159,7 @@ static void adxl345_process_fifo_samples_cb(struct rtio *r, const struct rtio_sq hdr->int_status = data->status1; hdr->is_full_res = data->is_full_res; hdr->selected_range = data->selected_range; - hdr->accel_odr = cfg->odr; + hdr->accel_odr = data->odr; hdr->sample_set_size = sample_set_size; uint32_t buf_avail = buf_len; diff --git a/drivers/sensor/adi/adxl372/adxl372.c b/drivers/sensor/adi/adxl372/adxl372.c index 8eb1ea643994c..c8310e1b49a65 100644 --- a/drivers/sensor/adi/adxl372/adxl372.c +++ b/drivers/sensor/adi/adxl372/adxl372.c @@ -550,7 +550,7 @@ static int adxl372_attr_set_odr(const struct device *dev, const struct sensor_value *val) { enum adxl372_odr odr; - struct adxl372_dev_config *cfg = (struct adxl372_dev_config *)dev->config; + struct adxl372_data *data = dev->data; switch (val->val1) { case 400: @@ -575,7 +575,7 @@ static int adxl372_attr_set_odr(const struct device *dev, int ret = adxl372_set_odr(dev, odr); if (ret == 0) { - cfg->odr = odr; + data->odr = odr; } return ret; diff --git a/drivers/sensor/adi/adxl372/adxl372.h b/drivers/sensor/adi/adxl372/adxl372.h index a3f93cebb3268..acfcf5fddb4fe 100644 --- a/drivers/sensor/adi/adxl372/adxl372.h +++ b/drivers/sensor/adi/adxl372/adxl372.h @@ -312,6 +312,7 @@ struct adxl372_data { const struct adxl372_transfer_function *hw_tf; struct adxl372_fifo_config fifo_config; enum adxl372_act_proc_mode act_proc_mode; + enum adxl372_odr odr; #ifdef CONFIG_ADXL372_TRIGGER struct gpio_callback gpio_cb; diff --git a/drivers/sensor/adi/adxl372/adxl372_stream.c b/drivers/sensor/adi/adxl372/adxl372_stream.c index a4dda2f2ce80b..4f7784b9d3768 100644 --- a/drivers/sensor/adi/adxl372/adxl372_stream.c +++ b/drivers/sensor/adi/adxl372/adxl372_stream.c @@ -213,7 +213,7 @@ static void adxl372_process_fifo_samples_cb(struct rtio *r, const struct rtio_sq hdr->is_fifo = 1; hdr->timestamp = data->timestamp; hdr->int_status = data->status1; - hdr->accel_odr = cfg->odr; + hdr->accel_odr = data->odr; hdr->sample_set_size = sample_set_size; if ((cfg->fifo_config.fifo_format == ADXL372_X_FIFO) || diff --git a/drivers/sensor/default_rtio_sensor.c b/drivers/sensor/default_rtio_sensor.c index 123d6b1ff955f..7a0117df66c54 100644 --- a/drivers/sensor/default_rtio_sensor.c +++ b/drivers/sensor/default_rtio_sensor.c @@ -318,25 +318,44 @@ static int get_frame_count(const uint8_t *buffer, struct sensor_chan_spec channe switch (channel.chan_type) { case SENSOR_CHAN_ACCEL_XYZ: - channel.chan_type = SENSOR_CHAN_ACCEL_X; - break; case SENSOR_CHAN_GYRO_XYZ: - channel.chan_type = SENSOR_CHAN_GYRO_X; - break; case SENSOR_CHAN_MAGN_XYZ: - channel.chan_type = SENSOR_CHAN_MAGN_X; - break; case SENSOR_CHAN_POS_DXYZ: - channel.chan_type = SENSOR_CHAN_POS_DX; + for (size_t i = 0 ; i < header->num_channels; ++i) { + /* For 3-axis channels, we need to verify we have each individual axis */ + struct sensor_chan_spec channel_x = { + .chan_type = channel.chan_type - 3, + .chan_idx = channel.chan_idx, + }; + struct sensor_chan_spec channel_y = { + .chan_type = channel.chan_type - 2, + .chan_idx = channel.chan_idx, + }; + struct sensor_chan_spec channel_z = { + .chan_type = channel.chan_type - 1, + .chan_idx = channel.chan_idx, + }; + + /** The three axes don't need to be at the beginning of the header, but + * they should be consecutive. + */ + if (((header->num_channels - i) >= 3) && + sensor_chan_spec_eq(header->channels[i], channel_x) && + sensor_chan_spec_eq(header->channels[i + 1], channel_y) && + sensor_chan_spec_eq(header->channels[i + 2], channel_z)) { + *frame_count = 1; + return 0; + } + } break; default: - break; - } - for (size_t i = 0; i < header->num_channels; ++i) { - if (sensor_chan_spec_eq(header->channels[i], channel)) { - *frame_count = 1; - return 0; + for (size_t i = 0; i < header->num_channels; ++i) { + if (sensor_chan_spec_eq(header->channels[i], channel)) { + *frame_count = 1; + return 0; + } } + break; } return -ENOTSUP; @@ -353,21 +372,9 @@ int sensor_natively_supported_channel_size_info(struct sensor_chan_spec channel, } switch (channel.chan_type) { - case SENSOR_CHAN_ACCEL_X: - case SENSOR_CHAN_ACCEL_Y: - case SENSOR_CHAN_ACCEL_Z: case SENSOR_CHAN_ACCEL_XYZ: - case SENSOR_CHAN_GYRO_X: - case SENSOR_CHAN_GYRO_Y: - case SENSOR_CHAN_GYRO_Z: case SENSOR_CHAN_GYRO_XYZ: - case SENSOR_CHAN_MAGN_X: - case SENSOR_CHAN_MAGN_Y: - case SENSOR_CHAN_MAGN_Z: case SENSOR_CHAN_MAGN_XYZ: - case SENSOR_CHAN_POS_DX: - case SENSOR_CHAN_POS_DY: - case SENSOR_CHAN_POS_DZ: case SENSOR_CHAN_POS_DXYZ: *base_size = sizeof(struct sensor_three_axis_data); *frame_size = sizeof(struct sensor_three_axis_sample_data); @@ -480,33 +487,21 @@ static int decode(const uint8_t *buffer, struct sensor_chan_spec chan_spec, /* Check for 3d channel mappings */ switch (chan_spec.chan_type) { - case SENSOR_CHAN_ACCEL_X: - case SENSOR_CHAN_ACCEL_Y: - case SENSOR_CHAN_ACCEL_Z: case SENSOR_CHAN_ACCEL_XYZ: count = decode_three_axis(header, q, data_out, SENSOR_CHAN_ACCEL_X, SENSOR_CHAN_ACCEL_Y, SENSOR_CHAN_ACCEL_Z, chan_spec.chan_idx); break; - case SENSOR_CHAN_GYRO_X: - case SENSOR_CHAN_GYRO_Y: - case SENSOR_CHAN_GYRO_Z: case SENSOR_CHAN_GYRO_XYZ: count = decode_three_axis(header, q, data_out, SENSOR_CHAN_GYRO_X, SENSOR_CHAN_GYRO_Y, SENSOR_CHAN_GYRO_Z, chan_spec.chan_idx); break; - case SENSOR_CHAN_MAGN_X: - case SENSOR_CHAN_MAGN_Y: - case SENSOR_CHAN_MAGN_Z: case SENSOR_CHAN_MAGN_XYZ: count = decode_three_axis(header, q, data_out, SENSOR_CHAN_MAGN_X, SENSOR_CHAN_MAGN_Y, SENSOR_CHAN_MAGN_Z, chan_spec.chan_idx); break; - case SENSOR_CHAN_POS_DX: - case SENSOR_CHAN_POS_DY: - case SENSOR_CHAN_POS_DZ: case SENSOR_CHAN_POS_DXYZ: count = decode_three_axis(header, q, data_out, SENSOR_CHAN_POS_DX, SENSOR_CHAN_POS_DY, SENSOR_CHAN_POS_DZ, diff --git a/drivers/sensor/sensor_shell.c b/drivers/sensor/sensor_shell.c index d10103a409db4..528e97627be61 100644 --- a/drivers/sensor/sensor_shell.c +++ b/drivers/sensor/sensor_shell.c @@ -354,23 +354,6 @@ void sensor_shell_processing_callback(int result, uint8_t *buf, uint32_t buf_len size_t frame_size; uint16_t frame_count; - /* Channels with multi-axis equivalents are skipped */ - switch (ch.chan_type) { - case SENSOR_CHAN_ACCEL_X: - case SENSOR_CHAN_ACCEL_Y: - case SENSOR_CHAN_ACCEL_Z: - case SENSOR_CHAN_GYRO_X: - case SENSOR_CHAN_GYRO_Y: - case SENSOR_CHAN_GYRO_Z: - case SENSOR_CHAN_MAGN_X: - case SENSOR_CHAN_MAGN_Y: - case SENSOR_CHAN_MAGN_Z: - case SENSOR_CHAN_POS_DX: - case SENSOR_CHAN_POS_DY: - case SENSOR_CHAN_POS_DZ: - continue; - } - rc = decoder->get_size_info(ch, &base_size, &frame_size); if (rc != 0) { LOG_DBG("skipping unsupported channel %s:%d", diff --git a/drivers/sensor/st/lis2de12/lis2de12.c b/drivers/sensor/st/lis2de12/lis2de12.c index 9cceccdeb2061..b417bccda393e 100644 --- a/drivers/sensor/st/lis2de12/lis2de12.c +++ b/drivers/sensor/st/lis2de12/lis2de12.c @@ -435,7 +435,7 @@ static int lis2de12_init(const struct device *dev) #define LIS2DE12_CONFIG_SPI(inst) \ { \ - STMEMSC_CTX_SPI(&lis2de12_config_##inst.stmemsc_cfg), \ + STMEMSC_CTX_SPI_INCR(&lis2de12_config_##inst.stmemsc_cfg), \ .stmemsc_cfg = { \ .spi = SPI_DT_SPEC_INST_GET(inst, LIS2DE12_SPI_OP, 0), \ }, \ diff --git a/drivers/sensor/st/stmemsc/stmemsc_spi.c b/drivers/sensor/st/stmemsc/stmemsc_spi.c index 3d728c78d8b18..66421f17ca000 100644 --- a/drivers/sensor/st/stmemsc/stmemsc_spi.c +++ b/drivers/sensor/st/stmemsc/stmemsc_spi.c @@ -63,13 +63,19 @@ int stmemsc_spi_write(const struct spi_dt_spec *stmemsc, int stmemsc_spi_read_incr(const struct spi_dt_spec *stmemsc, uint8_t reg_addr, uint8_t *value, uint8_t len) { - reg_addr |= STMEMSC_SPI_ADDR_AUTO_INCR; + if (len > 1) { + reg_addr |= STMEMSC_SPI_ADDR_AUTO_INCR; + } + return stmemsc_spi_read(stmemsc, reg_addr, value, len); } int stmemsc_spi_write_incr(const struct spi_dt_spec *stmemsc, uint8_t reg_addr, uint8_t *value, uint8_t len) { - reg_addr |= STMEMSC_SPI_ADDR_AUTO_INCR; + if (len > 1) { + reg_addr |= STMEMSC_SPI_ADDR_AUTO_INCR; + } + return stmemsc_spi_write(stmemsc, reg_addr, value, len); } diff --git a/drivers/serial/uart_esp32.c b/drivers/serial/uart_esp32.c index da2cfdb876b4e..da3af9b8df006 100644 --- a/drivers/serial/uart_esp32.c +++ b/drivers/serial/uart_esp32.c @@ -276,6 +276,7 @@ static int uart_esp32_configure(const struct device *dev, const struct uart_conf uart_hal_set_rxfifo_full_thr(&data->hal, UART_RX_FIFO_THRESH); uart_hal_set_txfifo_empty_thr(&data->hal, UART_TX_FIFO_THRESH); uart_hal_rxfifo_rst(&data->hal); + uart_hal_txfifo_rst(&data->hal); switch (cfg->parity) { case UART_CFG_PARITY_NONE: diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index e1af63b7993e7..def28c9cf21c5 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -2339,6 +2339,18 @@ static int uarte_instance_init(const struct device *dev, : UART_CFG_FLOW_CTRL_NONE, \ } +/* Macro determines if PM actions are interrupt safe. They are in case of + * asynchronous API (except for instance in fast power domain) and non-asynchronous + * API if RX is disabled. Macro must resolve to a literal 1 or 0. + */ +#define UARTE_PM_ISR_SAFE(idx) \ + COND_CODE_1(INSTANCE_IS_FAST_PD(_, /*empty*/, idx, _), \ + (0), \ + (COND_CODE_1(CONFIG_UART_##idx##_ASYNC, \ + (PM_DEVICE_ISR_SAFE), \ + (COND_CODE_1(UARTE_PROP(idx, disable_rx), \ + (PM_DEVICE_ISR_SAFE), (0)))))) \ + #define UART_NRF_UARTE_DEVICE(idx) \ NRF_DT_CHECK_NODE_HAS_PINCTRL_SLEEP(UARTE(idx)); \ UARTE_INT_DRIVEN(idx); \ @@ -2405,7 +2417,7 @@ static int uarte_instance_init(const struct device *dev, } \ \ PM_DEVICE_DT_DEFINE(UARTE(idx), uarte_nrfx_pm_action, \ - PM_DEVICE_ISR_SAFE); \ + UARTE_PM_ISR_SAFE(idx)); \ \ DEVICE_DT_DEFINE(UARTE(idx), \ uarte_##idx##_init, \ diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 1c4aaac2013a2..4f575affe9191 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -37,6 +37,24 @@ config SPI_RTIO This option enables the RTIO API calls. RTIO support is experimental as the API itself is unstable. +if SPI_RTIO + +config SPI_RTIO_FALLBACK_MSGS + int "Number of available spi_buf structs for the default handler to use" + default 4 + help + When RTIO is used with a driver that does not yet implement the submit API + natively the submissions are converted back to struct spi_buf values that + are given to spi_transfer. This requires some number of msgs be available to convert + the submissions into on the stack. MISRA rules dictate we must know this in + advance. + + In all likelihood 4 is going to work for everyone, but in case you do end up with + an issue where you are using RTIO, your driver does not implement submit natively, + and get an error relating to not enough spi msgs this is the Kconfig to manipulate. + +endif # SPI_RTIO + config SPI_SLAVE bool "Slave support [EXPERIMENTAL]" select EXPERIMENTAL diff --git a/drivers/spi/spi_mcux_ecspi.c b/drivers/spi/spi_mcux_ecspi.c index dfdfbcb4f670d..aacb089981f1c 100644 --- a/drivers/spi/spi_mcux_ecspi.c +++ b/drivers/spi/spi_mcux_ecspi.c @@ -93,7 +93,8 @@ static void spi_mcux_transfer_next_packet(const struct device *dev) transfer.txData = NULL; } - transfer.dataSize = data->dfs; + /* Burst length is set in the configure step */ + transfer.dataSize = 1; status = ECSPI_MasterTransferNonBlocking(base, &data->handle, &transfer); if (status != kStatus_Success) { @@ -163,7 +164,7 @@ static int spi_mcux_configure(const struct device *dev, return -ENOTSUP; } - if (spi_cfg->slave > kECSPI_Channel3) { + if (!spi_cs_is_gpio(spi_cfg) && spi_cfg->slave > kECSPI_Channel3) { LOG_ERR("Slave %d is greater than %d", spi_cfg->slave, kECSPI_Channel3); return -EINVAL; } @@ -181,7 +182,8 @@ static int spi_mcux_configure(const struct device *dev, ECSPI_MasterGetDefaultConfig(&master_config); - master_config.channel = (ecspi_channel_source_t)spi_cfg->slave; + master_config.channel = + spi_cs_is_gpio(spi_cfg) ? kECSPI_Channel0 : (ecspi_channel_source_t)spi_cfg->slave; master_config.channelConfig.polarity = (SPI_MODE_GET(spi_cfg->operation) & SPI_MODE_CPOL) ? kECSPI_PolarityActiveLow diff --git a/drivers/spi/spi_rtio.c b/drivers/spi/spi_rtio.c index 975636a098ab4..2526183e78a50 100644 --- a/drivers/spi/spi_rtio.c +++ b/drivers/spi/spi_rtio.c @@ -22,6 +22,7 @@ static void spi_rtio_iodev_default_submit_sync(struct rtio_iodev_sqe *iodev_sqe) { struct spi_dt_spec *dt_spec = iodev_sqe->sqe.iodev->data; const struct device *dev = dt_spec->bus; + uint8_t num_msgs = 0; int err = 0; LOG_DBG("Sync RTIO work item for: %p", (void *)dev); @@ -33,67 +34,103 @@ static void spi_rtio_iodev_default_submit_sync(struct rtio_iodev_sqe *iodev_sqe) struct rtio_iodev_sqe *txn_head = iodev_sqe; struct rtio_iodev_sqe *txn_curr = iodev_sqe; + /* We allocate the spi_buf's on the stack, to do so + * the count of messages needs to be determined to + * ensure we don't go over the statically sized array. + */ do { - struct rtio_sqe *sqe = &txn_curr->sqe; - struct spi_buf tx_buf = {0}; - struct spi_buf_set tx_buf_set = { - .buffers = &tx_buf, - }; + switch (txn_curr->sqe.op) { + case RTIO_OP_RX: + case RTIO_OP_TX: + case RTIO_OP_TINY_TX: + case RTIO_OP_TXRX: + num_msgs++; + break; + default: + LOG_ERR("Invalid op code %d for submission %p", txn_curr->sqe.op, + (void *)&txn_curr->sqe); + err = -EIO; + break; + } + txn_curr = rtio_txn_next(txn_curr); + } while (err == 0 && txn_curr != NULL); - struct spi_buf rx_buf = {0}; - struct spi_buf_set rx_buf_set = { - .buffers = &rx_buf, - }; + if (err != 0) { + rtio_iodev_sqe_err(txn_head, err); + return; + } + + /* Allocate msgs on the stack, MISRA doesn't like VLAs so we need a statically + * sized array here. It's pretty unlikely we have more than 4 spi messages + * in a transaction as we typically would only have 2, one to write a + * register address, and another to read/write the register into an array + */ + if (num_msgs > CONFIG_SPI_RTIO_FALLBACK_MSGS) { + LOG_ERR("At most CONFIG_SPI_RTIO_FALLBACK_MSGS" + " submissions in a transaction are" + " allowed in the default handler"); + rtio_iodev_sqe_err(txn_head, -ENOMEM); + return; + } + + struct spi_buf tx_bufs[CONFIG_SPI_RTIO_FALLBACK_MSGS]; + struct spi_buf rx_bufs[CONFIG_SPI_RTIO_FALLBACK_MSGS]; + struct spi_buf_set tx_buf_set = { + .buffers = tx_bufs, + .count = num_msgs, + }; + struct spi_buf_set rx_buf_set = { + .buffers = rx_bufs, + .count = num_msgs, + }; - LOG_DBG("Preparing transfer: %p", txn_curr); + txn_curr = txn_head; + + for (size_t i = 0 ; i < num_msgs ; i++) { + struct rtio_sqe *sqe = &txn_curr->sqe; switch (sqe->op) { case RTIO_OP_RX: - rx_buf.buf = sqe->rx.buf; - rx_buf.len = sqe->rx.buf_len; - rx_buf_set.count = 1; + rx_bufs[i].buf = sqe->rx.buf; + rx_bufs[i].len = sqe->rx.buf_len; + tx_bufs[i].buf = NULL; + tx_bufs[i].len = sqe->rx.buf_len; break; case RTIO_OP_TX: - tx_buf.buf = (uint8_t *)sqe->tx.buf; - tx_buf.len = sqe->tx.buf_len; - tx_buf_set.count = 1; + rx_bufs[i].buf = NULL; + rx_bufs[i].len = sqe->tx.buf_len; + tx_bufs[i].buf = (uint8_t *)sqe->tx.buf; + tx_bufs[i].len = sqe->tx.buf_len; break; case RTIO_OP_TINY_TX: - tx_buf.buf = (uint8_t *)sqe->tiny_tx.buf; - tx_buf.len = sqe->tiny_tx.buf_len; - tx_buf_set.count = 1; + rx_bufs[i].buf = NULL; + rx_bufs[i].len = sqe->tiny_tx.buf_len; + tx_bufs[i].buf = (uint8_t *)sqe->tiny_tx.buf; + tx_bufs[i].len = sqe->tiny_tx.buf_len; break; case RTIO_OP_TXRX: - rx_buf.buf = sqe->txrx.rx_buf; - rx_buf.len = sqe->txrx.buf_len; - tx_buf.buf = (uint8_t *)sqe->txrx.tx_buf; - tx_buf.len = sqe->txrx.buf_len; - rx_buf_set.count = 1; - tx_buf_set.count = 1; + rx_bufs[i].buf = sqe->txrx.rx_buf; + rx_bufs[i].len = sqe->txrx.buf_len; + tx_bufs[i].buf = (uint8_t *)sqe->txrx.tx_buf; + tx_bufs[i].len = sqe->txrx.buf_len; break; default: - LOG_ERR("Invalid op code %d for submission %p\n", sqe->op, (void *)sqe); err = -EIO; break; } - if (!err) { - struct spi_buf_set *tx_buf_ptr = tx_buf_set.count > 0 ? &tx_buf_set : NULL; - struct spi_buf_set *rx_buf_ptr = rx_buf_set.count > 0 ? &rx_buf_set : NULL; - - err = spi_transceive_dt(dt_spec, tx_buf_ptr, rx_buf_ptr); + txn_curr = rtio_txn_next(txn_curr); + } - /* NULL if this submission is not a transaction */ - txn_curr = rtio_txn_next(txn_curr); - } - } while (err >= 0 && txn_curr != NULL); + if (err == 0) { + __ASSERT_NO_MSG(num_msgs > 0); + err = spi_transceive_dt(dt_spec, &tx_buf_set, &rx_buf_set); + } - if (err < 0) { - LOG_ERR("Transfer failed: %d", err); + if (err != 0) { rtio_iodev_sqe_err(txn_head, err); } else { - LOG_DBG("Transfer OK: %d", err); - rtio_iodev_sqe_ok(txn_head, err); + rtio_iodev_sqe_ok(txn_head, 0); } } diff --git a/drivers/wifi/nrfwifi/CMakeLists.txt b/drivers/wifi/nrfwifi/CMakeLists.txt index 17ec7176cb269..439263ec6151e 100644 --- a/drivers/wifi/nrfwifi/CMakeLists.txt +++ b/drivers/wifi/nrfwifi/CMakeLists.txt @@ -305,13 +305,20 @@ zephyr_compile_definitions_ifdef(CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS -DWIFI_MGMT_RAW_SCAN_RESULTS=${CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS} ) +zephyr_compile_definitions_ifdef(CONFIG_NRF70_OFFLOADED_RAW_TX + -DNRF_NRF70_OFFLOADED_RAW_TX +) + +zephyr_compile_definitions_ifdef(CONFIG_NRF70_PASSIVE_SCAN_ONLY + -DNRF70_PASSIVE_SCAN_ONLY +) + zephyr_compile_definitions( -DNRF70_RX_NUM_BUFS=${CONFIG_NRF70_RX_NUM_BUFS} -DNRF70_MAX_TX_TOKENS=${CONFIG_NRF70_MAX_TX_TOKENS} -DNRF70_RX_MAX_DATA_SIZE=${CONFIG_NRF70_RX_MAX_DATA_SIZE} -DNRF70_MAX_TX_PENDING_QLEN=${CONFIG_NRF70_MAX_TX_PENDING_QLEN} -DNRF70_RPU_PS_IDLE_TIMEOUT_MS=${CONFIG_NRF70_RPU_PS_IDLE_TIMEOUT_MS} - -DNRF70_REG_DOMAIN=${CONFIG_NRF70_REG_DOMAIN} -DNRF70_BAND_2G_LOWER_EDGE_BACKOFF_DSSS=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_DSSS} -DNRF70_BAND_2G_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HT} -DNRF70_BAND_2G_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HE} diff --git a/dts/arm/atmel/sam4s.dtsi b/dts/arm/atmel/sam4s.dtsi index 64828f3a7d50c..fa41d53c5dab4 100644 --- a/dts/arm/atmel/sam4s.dtsi +++ b/dts/arm/atmel/sam4s.dtsi @@ -55,7 +55,7 @@ status = "okay"; }; - sram0: memory@20100000 { + sram0: memory@20000000 { compatible = "mmio-sram"; }; diff --git a/dts/arm/atmel/sam4s16b.dtsi b/dts/arm/atmel/sam4s16b.dtsi index f671f6fccc48e..ca158cfd915cf 100644 --- a/dts/arm/atmel/sam4s16b.dtsi +++ b/dts/arm/atmel/sam4s16b.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(128)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(128)>; }; }; }; diff --git a/dts/arm/atmel/sam4s16c.dtsi b/dts/arm/atmel/sam4s16c.dtsi index f671f6fccc48e..ca158cfd915cf 100644 --- a/dts/arm/atmel/sam4s16c.dtsi +++ b/dts/arm/atmel/sam4s16c.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(128)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(128)>; }; }; }; diff --git a/dts/arm/atmel/sam4s2a.dtsi b/dts/arm/atmel/sam4s2a.dtsi index b57ddb0cec65a..3855a903a4556 100644 --- a/dts/arm/atmel/sam4s2a.dtsi +++ b/dts/arm/atmel/sam4s2a.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(64)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(64)>; }; }; }; diff --git a/dts/arm/atmel/sam4s2b.dtsi b/dts/arm/atmel/sam4s2b.dtsi index b57ddb0cec65a..3855a903a4556 100644 --- a/dts/arm/atmel/sam4s2b.dtsi +++ b/dts/arm/atmel/sam4s2b.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(64)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(64)>; }; }; }; diff --git a/dts/arm/atmel/sam4s2c.dtsi b/dts/arm/atmel/sam4s2c.dtsi index b57ddb0cec65a..3855a903a4556 100644 --- a/dts/arm/atmel/sam4s2c.dtsi +++ b/dts/arm/atmel/sam4s2c.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(64)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(64)>; }; }; }; diff --git a/dts/arm/atmel/sam4s4a.dtsi b/dts/arm/atmel/sam4s4a.dtsi index 1ea079b054caf..16d6a850f83c0 100644 --- a/dts/arm/atmel/sam4s4a.dtsi +++ b/dts/arm/atmel/sam4s4a.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(64)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(64)>; }; }; }; diff --git a/dts/arm/atmel/sam4s4b.dtsi b/dts/arm/atmel/sam4s4b.dtsi index 959c4d591e203..b265de356ea53 100644 --- a/dts/arm/atmel/sam4s4b.dtsi +++ b/dts/arm/atmel/sam4s4b.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(64)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(64)>; }; }; }; diff --git a/dts/arm/atmel/sam4s4c.dtsi b/dts/arm/atmel/sam4s4c.dtsi index 1ea079b054caf..16d6a850f83c0 100644 --- a/dts/arm/atmel/sam4s4c.dtsi +++ b/dts/arm/atmel/sam4s4c.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(64)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(64)>; }; }; }; diff --git a/dts/arm/atmel/sam4s8b.dtsi b/dts/arm/atmel/sam4s8b.dtsi index 2e00a78b4d6da..44f376020091d 100644 --- a/dts/arm/atmel/sam4s8b.dtsi +++ b/dts/arm/atmel/sam4s8b.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(128)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(128)>; }; }; }; diff --git a/dts/arm/atmel/sam4s8c.dtsi b/dts/arm/atmel/sam4s8c.dtsi index 2e00a78b4d6da..44f376020091d 100644 --- a/dts/arm/atmel/sam4s8c.dtsi +++ b/dts/arm/atmel/sam4s8c.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(128)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(128)>; }; }; }; diff --git a/dts/arm/atmel/sam4sa16c.dtsi b/dts/arm/atmel/sam4sa16c.dtsi index 789e482b0f666..a413672ba1b50 100644 --- a/dts/arm/atmel/sam4sa16c.dtsi +++ b/dts/arm/atmel/sam4sa16c.dtsi @@ -16,8 +16,8 @@ }; }; - sram0: memory@20100000 { - reg = <0x20100000 DT_SIZE_K(160)>; + sram0: memory@20000000 { + reg = <0x20000000 DT_SIZE_K(160)>; }; }; }; diff --git a/dts/arm/atmel/samc21.dtsi b/dts/arm/atmel/samc21.dtsi index 095e98437f05b..f54b5672e750c 100644 --- a/dts/arm/atmel/samc21.dtsi +++ b/dts/arm/atmel/samc21.dtsi @@ -8,6 +8,8 @@ / { aliases { + adc-1 = &adc1; + sercom-4 = &sercom4; sercom-5 = &sercom5; }; @@ -15,15 +17,17 @@ soc { adc1: adc@42004800 { compatible = "atmel,sam0-adc"; - status = "disabled"; reg = <0x42004800 0x30>; interrupts = <26 0>; interrupt-names = "resrdy"; clocks = <&gclk 34>, <&mclk 0x1c 18>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + + #io-channel-cells = <1>; + gclk = <0>; prescaler = <4>; - #io-channel-cells = <1>; }; sercom4: sercom@42001400 { @@ -51,9 +55,10 @@ interrupt-names = "int0"; clocks = <&gclk 26>, <&mclk 0x10 8>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + bosch,mram-cfg = <0x0 28 8 3 3 0 1 1>; divider = <12>; - status = "disabled"; }; can1: can@42002000 { @@ -63,9 +68,10 @@ interrupt-names = "int0"; clocks = <&gclk 27>, <&mclk 0x10 9>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + bosch,mram-cfg = <0x0 28 8 3 3 0 1 1>; divider = <12>; - status = "disabled"; }; }; }; diff --git a/dts/arm/atmel/samc2x.dtsi b/dts/arm/atmel/samc2x.dtsi index a0e57c5c75f19..a1a78112487c2 100644 --- a/dts/arm/atmel/samc2x.dtsi +++ b/dts/arm/atmel/samc2x.dtsi @@ -13,6 +13,21 @@ / { aliases { + adc-0 = &adc0; + + port-a = &porta; + port-b = &portb; + port-c = &portc; + + sercom-0 = &sercom0; + sercom-1 = &sercom1; + sercom-2 = &sercom2; + sercom-3 = &sercom3; + + tcc-0 = &tcc0; + tcc-1 = &tcc1; + tcc-2 = &tcc2; + watchdog0 = &wdog; }; @@ -25,9 +40,10 @@ #size-cells = <0>; cpu0: cpu@0 { - device_type = "cpu"; compatible = "arm,cortex-m0+"; reg = <0>; + + device_type = "cpu"; }; }; @@ -43,33 +59,20 @@ <0x0080A048 0x4>; }; - aliases { - port-a = &porta; - port-b = &portb; - port-c = &portc; - - sercom-0 = &sercom0; - sercom-1 = &sercom1; - sercom-2 = &sercom2; - sercom-3 = &sercom3; - - tcc-0 = &tcc0; - tcc-1 = &tcc1; - tcc-2 = &tcc2; - }; - soc { nvmctrl: nvmctrl@41004000 { compatible = "atmel,sam0-nvmctrl"; reg = <0x41004000 0x22>; interrupts = <6 0>; - lock-regions = <16>; #address-cells = <1>; #size-cells = <1>; + lock-regions = <16>; + flash0: flash@0 { compatible = "soc-nv-flash"; + write-block-size = <4>; }; }; @@ -77,12 +80,14 @@ mclk: mclk@40000800 { compatible = "atmel,samc2x-mclk"; reg = <0x40000800 0x400>; + #clock-cells = <2>; }; gclk: gclk@40001c00 { compatible = "atmel,samc2x-gclk"; reg = <0x40001c00 0x400>; + #clock-cells = <1>; }; @@ -107,20 +112,24 @@ compatible = "atmel,sam0-dmac"; reg = <0x41006000 0x50>; interrupts = <7 0>; + status = "disabled"; + #dma-cells = <2>; }; adc0: adc@42004400 { compatible = "atmel,sam0-adc"; - status = "disabled"; reg = <0x42004400 0x30>; interrupts = <25 0>; interrupt-names = "resrdy"; clocks = <&gclk 33>, <&mclk 0x1c 17>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + + #io-channel-cells = <1>; + gclk = <0>; prescaler = <4>; - #io-channel-cells = <1>; }; sercom0: sercom@42000400 { @@ -165,6 +174,7 @@ interrupts = <17 0>; clocks = <&gclk 28>, <&mclk 0x1c 9>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -176,6 +186,7 @@ interrupts = <18 0>; clocks = <&gclk 28>, <&mclk 0x1c 10>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -187,6 +198,7 @@ interrupts = <19 0>; clocks = <&gclk 29>, <&mclk 0x1c 11>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <2>; counter-size = <16>; @@ -194,32 +206,39 @@ pinctrl: pinctrl@41000000 { compatible = "atmel,sam0-pinctrl"; + ranges = <0x41000000 0x41000000 0x180>; + #address-cells = <1>; #size-cells = <1>; - ranges = <0x41000000 0x41000000 0x180>; porta: gpio@41000000 { compatible = "atmel,sam0-gpio"; reg = <0x41000000 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; portb: gpio@41000080 { compatible = "atmel,sam0-gpio"; reg = <0x41000080 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; portc: gpio@41000100 { compatible = "atmel,sam0-gpio"; reg = <0x41000100 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; }; @@ -227,8 +246,9 @@ compatible = "atmel,sam0-rtc"; reg = <0x40002400 0x1C>; interrupts = <3 0>; - clock-generator = <0>; status = "disabled"; + + clock-generator = <0>; }; }; }; diff --git a/dts/arm/atmel/samd20.dtsi b/dts/arm/atmel/samd20.dtsi index 01af6c4e4503d..8e367d9fd9ad2 100644 --- a/dts/arm/atmel/samd20.dtsi +++ b/dts/arm/atmel/samd20.dtsi @@ -20,6 +20,7 @@ interrupts = <13 0>; clocks = <&gclk 0x13>, <&pm 0x20 8>; clock-names = "GCLK", "PM"; + status = "disabled"; }; tc2: tc@42002800 { @@ -28,6 +29,7 @@ interrupts = <15 0>; clocks = <&gclk 0x14>, <&pm 0x20 10>; clock-names = "GCLK", "PM"; + status = "disabled"; }; tc6: tc@42003800 { @@ -36,6 +38,7 @@ interrupts = <19 0>; clocks = <&gclk 0x16>, <&pm 0x20 14>; clock-names = "GCLK", "PM"; + status = "disabled"; }; }; }; diff --git a/dts/arm/atmel/samd21.dtsi b/dts/arm/atmel/samd21.dtsi index f8b12ed570ae9..c4692ffa9e50b 100644 --- a/dts/arm/atmel/samd21.dtsi +++ b/dts/arm/atmel/samd21.dtsi @@ -9,14 +9,19 @@ / { aliases { tc-6 = &tc6; + + tcc-0 = &tcc0; + tcc-1 = &tcc1; + tcc-2 = &tcc2; }; soc { usb0: usb@41005000 { compatible = "atmel,sam0-usb"; - status = "disabled"; reg = <0x41005000 0x1000>; interrupts = <7 0>; + status = "disabled"; + num-bidir-endpoints = <8>; }; @@ -24,6 +29,8 @@ compatible = "atmel,sam0-dmac"; reg = <0x41004800 0x50>; interrupts = <6 0>; + status = "disabled"; + #dma-cells = <2>; }; @@ -33,6 +40,7 @@ interrupts = <21 0>; clocks = <&gclk 0x1d>, <&pm 0x20 14>; clock-names = "GCLK", "PM"; + status = "disabled"; }; tcc0: tcc@42002000 { @@ -41,6 +49,7 @@ interrupts = <15 0>; clocks = <&gclk 26>, <&pm 0x20 8>; clock-names = "GCLK", "PM"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -52,6 +61,7 @@ interrupts = <16 0>; clocks = <&gclk 26>, <&pm 0x20 9>; clock-names = "GCLK", "PM"; + status = "disabled"; channels = <2>; counter-size = <24>; @@ -63,6 +73,7 @@ interrupts = <17 0>; clocks = <&gclk 27>, <&pm 0x20 10>; clock-names = "GCLK", "PM"; + status = "disabled"; channels = <2>; counter-size = <16>; diff --git a/dts/arm/atmel/samd2x.dtsi b/dts/arm/atmel/samd2x.dtsi index c247daffc1a51..d40e558f73283 100644 --- a/dts/arm/atmel/samd2x.dtsi +++ b/dts/arm/atmel/samd2x.dtsi @@ -13,6 +13,20 @@ / { aliases { + adc-0 = &adc; + + port-a = &porta; + port-b = &portb; + + sercom-0 = &sercom0; + sercom-1 = &sercom1; + sercom-2 = &sercom2; + sercom-3 = &sercom3; + sercom-4 = &sercom4; + sercom-5 = &sercom5; + + tc-4 = &tc4; + watchdog0 = &wdog; }; @@ -25,9 +39,10 @@ #size-cells = <0>; cpu0: cpu@0 { - device_type = "cpu"; compatible = "arm,cortex-m0+"; reg = <0>; + + device_type = "cpu"; }; }; @@ -43,33 +58,20 @@ <0x0080A048 0x4>; }; - aliases { - port-a = &porta; - port-b = &portb; - adc-0 = &adc; - - sercom-0 = &sercom0; - sercom-1 = &sercom1; - sercom-2 = &sercom2; - sercom-3 = &sercom3; - sercom-4 = &sercom4; - sercom-5 = &sercom5; - - tc-4 = &tc4; - }; - soc { nvmctrl: nvmctrl@41004000 { compatible = "atmel,sam0-nvmctrl"; reg = <0x41004000 0x22>; interrupts = <5 0>; - lock-regions = <16>; #address-cells = <1>; #size-cells = <1>; + lock-regions = <16>; + flash0: flash@0 { compatible = "soc-nv-flash"; + write-block-size = <4>; }; }; @@ -78,12 +80,14 @@ compatible = "atmel,samd2x-pm"; reg = <0x40000400 0x400>; interrupts = <0 0>; + #clock-cells = <2>; }; gclk: gclk@40000c00 { compatible = "atmel,samd2x-gclk"; reg = <0x40000c00 0x400>; + #clock-cells = <1>; }; @@ -148,29 +152,34 @@ tc4: tc@42003000 { compatible = "atmel,sam0-tc32"; reg = <0x42003000 0x20>; + status = "disabled"; }; pinctrl: pinctrl@41004400 { compatible = "atmel,sam0-pinctrl"; + ranges = <0x41004400 0x41004400 0x100>; + #address-cells = <1>; #size-cells = <1>; - ranges = <0x41004400 0x41004400 0x100>; porta: gpio@41004400 { compatible = "atmel,sam0-gpio"; reg = <0x41004400 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + gpio-controller; }; portb: gpio@41004480 { compatible = "atmel,sam0-gpio"; reg = <0x41004480 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; }; @@ -178,13 +187,17 @@ compatible = "atmel,sam0-rtc"; reg = <0x40001400 0x1C>; interrupts = <3 0>; - clock-generator = <0>; status = "disabled"; + + clock-generator = <0>; }; adc: adc@42004000 { compatible = "atmel,sam0-adc"; reg = <0x42004000 0x2B>; + status = "disabled"; + + #io-channel-cells = <1>; /* * 2.1 MHz max, so clock it with the @@ -192,13 +205,13 @@ */ gclk = <3>; prescaler = <4>; - #io-channel-cells = <1>; }; dac0: dac@42004800 { compatible = "atmel,sam0-dac"; - status = "disabled"; reg = <0x42004800 0x10>; + status = "disabled"; + #io-channel-cells = <0>; }; }; diff --git a/dts/arm/atmel/samd5x.dtsi b/dts/arm/atmel/samd5x.dtsi index b64abc5de4554..12593682eaec7 100644 --- a/dts/arm/atmel/samd5x.dtsi +++ b/dts/arm/atmel/samd5x.dtsi @@ -11,28 +11,6 @@ #include / { - chosen { - zephyr,flash-controller = &nvmctrl; - }; - - cpus { - #address-cells = <1>; - #size-cells = <0>; - - cpu0: cpu@0 { - device_type = "cpu"; - compatible = "arm,cortex-m4f"; - reg = <0>; - #address-cells = <1>; - #size-cells = <1>; - - mpu: mpu@e000ed90 { - compatible = "arm,armv7m-mpu"; - reg = <0xe000ed90 0x40>; - }; - }; - }; - aliases { adc-0 = &adc0; adc-1 = &adc1; @@ -67,6 +45,27 @@ chosen { zephyr,entropy = &trng; + zephyr,flash-controller = &nvmctrl; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu0: cpu@0 { + compatible = "arm,cortex-m4f"; + reg = <0>; + + #address-cells = <1>; + #size-cells = <1>; + + device_type = "cpu"; + + mpu: mpu@e000ed90 { + compatible = "arm,armv7m-mpu"; + reg = <0xe000ed90 0x40>; + }; + }; }; soc { @@ -91,12 +90,14 @@ mclk: mclk@40000800 { compatible = "atmel,samd5x-mclk"; reg = <0x40000800 0x400>; + #clock-cells = <2>; }; gclk: gclk@40001c00 { compatible = "atmel,samd5x-gclk"; reg = <0x40001c00 0x400>; + #clock-cells = <1>; }; @@ -104,13 +105,15 @@ compatible = "atmel,sam0-nvmctrl"; reg = <0x41004000 0x22>; interrupts = <29 0>, <30 0>; - lock-regions = <32>; #address-cells = <1>; #size-cells = <1>; + lock-regions = <32>; + flash0: flash@0 { compatible = "soc-nv-flash"; + write-block-size = <8>; }; }; @@ -119,6 +122,8 @@ compatible = "atmel,sam0-dmac"; reg = <0x4100A000 0x50>; interrupts = <31 0>, <32 0>, <33 0>, <34 0>, <35 0>; + status = "disabled"; + #dma-cells = <2>; }; @@ -161,118 +166,128 @@ compatible = "atmel,sam0-sercom"; reg = <0x40003000 0x40>; interrupts = <46 0>, <47 0>, <48 0>, <49 0>; - status = "disabled"; clocks = <&gclk 7>, <&mclk 0x14 12>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; sercom1: sercom@40003400 { compatible = "atmel,sam0-sercom"; reg = <0x40003400 0x40>; interrupts = <50 0>, <51 0>, <52 0>, <53 0>; - status = "disabled"; clocks = <&gclk 8>, <&mclk 0x14 13>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; sercom2: sercom@41012000 { compatible = "atmel,sam0-sercom"; reg = <0x41012000 0x40>; interrupts = <54 0>, <55 0>, <56 0>, <57 0>; - status = "disabled"; clocks = <&gclk 23>, <&mclk 0x18 9>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; sercom3: sercom@41014000 { compatible = "atmel,sam0-sercom"; reg = <0x41014000 0x40>; interrupts = <58 0>, <59 0>, <60 0>, <61 0>; - status = "disabled"; clocks = <&gclk 24>, <&mclk 0x18 10>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; sercom4: sercom@43000000 { compatible = "atmel,sam0-sercom"; reg = <0x43000000 0x40>; interrupts = <62 0>, <63 0>, <64 0>, <65 0>; - status = "disabled"; clocks = <&gclk 34>, <&mclk 0x20 0>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; sercom5: sercom@43000400 { compatible = "atmel,sam0-sercom"; reg = <0x43000400 0x40>; interrupts = <66 0>, <67 0>, <68 0>, <69 0>; - status = "disabled"; clocks = <&gclk 35>, <&mclk 0x20 1>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; sercom6: sercom@43000800 { compatible = "atmel,sam0-sercom"; reg = <0x43000800 0x40>; interrupts = <70 0>, <71 0>, <72 0>, <73 0>; - status = "disabled"; clocks = <&gclk 36>, <&mclk 0x20 2>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; sercom7: sercom@43000c00 { compatible = "atmel,sam0-sercom"; reg = <0x43000C00 0x40>; interrupts = <74 0>, <75 0>, <76 0>, <77 0>; - status = "disabled"; clocks = <&gclk 37>, <&mclk 0x20 3>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; pinctrl: pinctrl@41008000 { compatible = "atmel,sam0-pinctrl"; + ranges = <0x41008000 0x41008000 0x200>; + #address-cells = <1>; #size-cells = <1>; - ranges = <0x41008000 0x41008000 0x200>; porta: gpio@41008000 { compatible = "atmel,sam0-gpio"; reg = <0x41008000 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; portb: gpio@41008080 { compatible = "atmel,sam0-gpio"; reg = <0x41008080 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; portc: gpio@41008100 { compatible = "atmel,sam0-gpio"; reg = <0x41008100 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; portd: gpio@41008180 { compatible = "atmel,sam0-gpio"; reg = <0x41008180 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; }; usb0: usb@41000000 { compatible = "atmel,sam0-usb"; - status = "disabled"; reg = <0x41000000 0x1000>; interrupts = <80 0>, <81 0>, <82 0>, <83 0>; + status = "disabled"; + num-bidir-endpoints = <8>; }; @@ -286,8 +301,9 @@ compatible = "atmel,sam0-rtc"; reg = <0x40002400 0x1C>; interrupts = <11 0>; - clock-generator = <0>; status = "disabled"; + + clock-generator = <0>; }; adc0: adc@43001c00 { @@ -295,6 +311,11 @@ reg = <0x43001C00 0x4A>; interrupts = <118 0>, <119 0>; interrupt-names = "overrun", "resrdy"; + clocks = <&gclk 40>, <&mclk 0x20 7>; + clock-names = "GCLK", "MCLK"; + status = "disabled"; + + #io-channel-cells = <1>; /* * 16 MHz max, source clock must not exceed 100 MHz. @@ -304,9 +325,6 @@ */ gclk = <2>; prescaler = <4>; - #io-channel-cells = <1>; - clocks = <&gclk 40>, <&mclk 0x20 7>; - clock-names = "GCLK", "MCLK"; calib-offset = <0>; }; @@ -315,6 +333,11 @@ reg = <0x43002000 0x4A>; interrupts = <120 0>, <121 0>; interrupt-names = "overrun", "resrdy"; + clocks = <&gclk 41>, <&mclk 0x20 8>; + clock-names = "GCLK", "MCLK"; + status = "disabled"; + + #io-channel-cells = <1>; /* * 16 MHz max, source clock must not exceed 100 MHz. @@ -324,9 +347,6 @@ */ gclk = <2>; prescaler = <4>; - #io-channel-cells = <1>; - clocks = <&gclk 41>, <&mclk 0x20 8>; - clock-names = "GCLK", "MCLK"; calib-offset = <14>; }; @@ -336,6 +356,7 @@ interrupts = <107 0>; clocks = <&gclk 9>, <&mclk 0x14 14>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; tc2: tc@4101a000 { @@ -344,6 +365,7 @@ interrupts = <109 0>; clocks = <&gclk 26>, <&mclk 0x18 13>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; tc4: tc@42001400 { @@ -352,6 +374,7 @@ interrupts = <111 0>; clocks = <&gclk 30>, <&mclk 0x1c 5>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; tc6: tc@43001400 { @@ -360,6 +383,7 @@ interrupts = <113 0>; clocks = <&gclk 39>, <&mclk 0x20 5>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; tcc0: tcc@41016000 { @@ -369,6 +393,8 @@ <90 0>, <91 0>; clocks = <&gclk 25>, <&mclk 0x18 11>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + channels = <6>; counter-size = <24>; }; @@ -379,6 +405,8 @@ interrupts = <92 0>, <93 0>, <94 0>, <95 0>, <96 0>; clocks = <&gclk 25>, <&mclk 0x18 12>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + channels = <4>; counter-size = <24>; }; @@ -389,6 +417,8 @@ interrupts = <97 0>, <98 0>, <99 0>, <100 0>; clocks = <&gclk 29>, <&mclk 0x1c 3>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + channels = <3>; counter-size = <16>; }; @@ -399,6 +429,8 @@ interrupts = <101 0>, <102 0>, <103 0>; clocks = <&gclk 29>, <&mclk 0x1c 4>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + channels = <2>; counter-size = <16>; }; @@ -409,6 +441,8 @@ interrupts = <104 0>, <105 0>, <106 0>; clocks = <&gclk 38>, <&mclk 0x20 4>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + channels = <2>; counter-size = <16>; }; diff --git a/dts/arm/atmel/same5x.dtsi b/dts/arm/atmel/same5x.dtsi index 750094cfafef9..9df4876736a9c 100644 --- a/dts/arm/atmel/same5x.dtsi +++ b/dts/arm/atmel/same5x.dtsi @@ -14,15 +14,17 @@ reg = <0x42000800 0x400>; interrupts = <84 0>; interrupt-names = "gmac"; + status = "disabled"; + num-queues = <1>; local-mac-address = [00 00 00 00 00 00]; - status = "disabled"; }; mdio: mdio@42000800 { compatible = "atmel,sam-mdio"; reg = <0x42000800 0x400>; status = "disabled"; + #address-cells = <1>; #size-cells = <0>; }; @@ -34,9 +36,10 @@ interrupt-names = "int0", "int1"; clocks = <&gclk 27>, <&mclk 0x10 17>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; divider = <12>; - status = "disabled"; }; can1: can@42000400 { @@ -46,9 +49,10 @@ interrupt-names = "int0", "int1"; clocks = <&gclk 28>, <&mclk 0x10 18>; clock-names = "GCLK", "MCLK"; + status = "disabled"; + bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; divider = <12>; - status = "disabled"; }; }; }; diff --git a/dts/arm/atmel/saml21.dtsi b/dts/arm/atmel/saml21.dtsi index 524c28d3d2def..6e015b5772cc9 100644 --- a/dts/arm/atmel/saml21.dtsi +++ b/dts/arm/atmel/saml21.dtsi @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 Argentum Systems Ltd. + * Copyright (c) 2024 Gerson Fernando Budke * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,28 +8,20 @@ #include / { - soc { - usb0: usb@41000000 { - compatible = "atmel,sam0-usb"; - status = "disabled"; - reg = <0x41000000 0x1000>; - interrupts = <6 0>; - num-bidir-endpoints = <8>; - }; - - dmac: dmac@44000400 { - compatible = "atmel,sam0-dmac"; - reg = <0x44000400 0x50>; - interrupts = <5 0>; - #dma-cells = <2>; - }; + aliases { + tcc-0 = &tcc0; + tcc-1 = &tcc1; + tcc-2 = &tcc2; + }; + soc { tcc0: tcc@42001400 { compatible = "atmel,sam0-tcc"; reg = <0x42001400 0x80>; interrupts = <14 0>; clocks = <&gclk 25>, <&mclk 0x1c 5>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -40,6 +33,7 @@ interrupts = <15 0>; clocks = <&gclk 25>, <&mclk 0x1c 6>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -51,6 +45,7 @@ interrupts = <16 0>; clocks = <&gclk 26>, <&mclk 0x1c 7>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <2>; counter-size = <16>; diff --git a/dts/arm/atmel/saml2x.dtsi b/dts/arm/atmel/saml2x.dtsi index 2bad616c81af9..d9191c03a1321 100644 --- a/dts/arm/atmel/saml2x.dtsi +++ b/dts/arm/atmel/saml2x.dtsi @@ -1,5 +1,6 @@ /* * Copyright (c) 2021 Argentum Systems Ltd. + * Copyright (c) 2024 Gerson Fernando Budke * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,6 +14,20 @@ / { aliases { + adc-0 = &adc; + + port-a = &porta; + port-b = &portb; + + sercom-0 = &sercom0; + sercom-1 = &sercom1; + sercom-2 = &sercom2; + sercom-3 = &sercom3; + sercom-4 = &sercom4; + sercom-5 = &sercom5; + + tc-4 = &tc4; + watchdog0 = &wdog; }; @@ -26,9 +41,10 @@ #size-cells = <0>; cpu0: cpu@0 { - device_type = "cpu"; compatible = "arm,cortex-m0+"; reg = <0>; + + device_type = "cpu"; }; }; @@ -50,14 +66,16 @@ compatible = "atmel,sam0-nvmctrl"; reg = <0x41004000 0x22>; interrupts = <4 0>; - lock-regions = <16>; #address-cells = <1>; #size-cells = <1>; + lock-regions = <16>; + flash0: flash@0 { compatible = "soc-nv-flash"; reg = <0 0x40000>; + write-block-size = <4>; }; }; @@ -66,18 +84,21 @@ compatible = "atmel,saml2x-pm"; reg = <0x40000400 0x400>; interrupts = <0 0>; + #clock-cells = <2>; }; mclk: mclk@40000400 { compatible = "atmel,saml2x-mclk"; reg = <0x40000400 0x400>; + #clock-cells = <2>; }; gclk: gclk@40001800 { compatible = "atmel,saml2x-gclk"; reg = <0x40001800 0x400>; + #clock-cells = <1>; }; @@ -85,6 +106,8 @@ compatible = "atmel,sam0-dmac"; reg = <0x44000400 0x400>; interrupts = <5 0>; + status = "disabled"; + #dma-cells = <2>; }; @@ -139,29 +162,34 @@ tc4: tc@43000800 { compatible = "atmel,sam0-tc32"; reg = <0x43000800 0x34>; + status = "disabled"; }; pinctrl: pinctrl@40002800 { compatible = "atmel,sam0-pinctrl"; + ranges = <0x40002800 0x40002800 0x100>; + #address-cells = <1>; #size-cells = <1>; - ranges = <0x40002800 0x40002800 0x100>; porta: gpio@40002800 { compatible = "atmel,sam0-gpio"; reg = <0x40002800 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + gpio-controller; }; portb: gpio@40002880 { compatible = "atmel,sam0-gpio"; reg = <0x40002880 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; }; @@ -169,13 +197,17 @@ compatible = "atmel,sam0-rtc"; reg = <0x40002000 0x1c>; interrupts = <2 0>; - clock-generator = <0>; status = "disabled"; + + clock-generator = <0>; }; adc: adc@43000c00 { compatible = "atmel,sam0-adc"; reg = <0x43000c00 0x30>; + status = "disabled"; + + #io-channel-cells = <1>; /* * 16 MHz max, so clock it with the @@ -183,13 +215,13 @@ */ gclk = <3>; prescaler = <2>; - #io-channel-cells = <1>; }; dac: dac@42003000 { compatible = "atmel,sam0-dac"; - status = "disabled"; reg = <0x42003000 0x1a>; + status = "disabled"; + #io-channel-cells = <0>; }; @@ -198,6 +230,15 @@ reg = <0x42003800 0x24>; interrupts = <27 0>; }; + + usb0: usb@41000000 { + compatible = "atmel,sam0-usb"; + reg = <0x41000000 0x1000>; + interrupts = <6 0>; + status = "disabled"; + + num-bidir-endpoints = <8>; + }; }; }; diff --git a/dts/arm/atmel/samr21.dtsi b/dts/arm/atmel/samr21.dtsi index 786597c3ca31f..85686c1d37bc6 100644 --- a/dts/arm/atmel/samr21.dtsi +++ b/dts/arm/atmel/samr21.dtsi @@ -1,10 +1,11 @@ /* * Copyright (c) 2019 Benjamin Valentin + * Copyright (c) 2024 Gerson Fernando Budke * * SPDX-License-Identifier: Apache-2.0 */ -#include +#include / { aliases { @@ -12,30 +13,17 @@ }; soc { - usb0: usb@41005000 { - compatible = "atmel,sam0-usb"; - status = "disabled"; - reg = <0x41005000 0x1000>; - interrupts = <7 0>; - num-bidir-endpoints = <8>; - }; - - dmac: dmac@41004800 { - compatible = "atmel,sam0-dmac"; - reg = <0x41004800 0x50>; - interrupts = <6 0>; - #dma-cells = <2>; - }; - pinctrl: pinctrl@41004400 { ranges = <0x41004400 0x41004400 0x180>; portc: gpio@41004500 { compatible = "atmel,sam0-gpio"; reg = <0x41004500 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; }; @@ -43,87 +31,5 @@ compatible = "atmel,sam0-pinmux"; reg = <0x41004500 0x80>; }; - - tcc0: tcc@42002000 { - compatible = "atmel,sam0-tcc"; - reg = <0x42002000 0x80>; - interrupts = <15 0>; - clocks = <&gclk 26>, <&pm 0x20 8>; - clock-names = "GCLK", "PM"; - - channels = <4>; - counter-size = <24>; - }; - - tcc1: tcc@42002400 { - compatible = "atmel,sam0-tcc"; - reg = <0x42002400 0x80>; - interrupts = <16 0>; - clocks = <&gclk 26>, <&pm 0x20 9>; - clock-names = "GCLK", "PM"; - - channels = <2>; - counter-size = <24>; - }; - - tcc2: tcc@42002800 { - compatible = "atmel,sam0-tcc"; - reg = <0x42002800 0x80>; - interrupts = <17 0>; - clocks = <&gclk 27>, <&pm 0x20 10>; - clock-names = "GCLK", "PM"; - - channels = <2>; - counter-size = <16>; - }; }; }; - -&sercom0 { - interrupts = <9 0>; - clocks = <&gclk 0x14>, <&pm 0x20 2>; - clock-names = "GCLK", "PM"; -}; - -&sercom1 { - interrupts = <10 0>; - clocks = <&gclk 0x15>, <&pm 0x20 3>; - clock-names = "GCLK", "PM"; -}; - -&sercom2 { - interrupts = <11 0>; - clocks = <&gclk 0x16>, <&pm 0x20 4>; - clock-names = "GCLK", "PM"; -}; - -&sercom3 { - interrupts = <12 0>; - clocks = <&gclk 0x17>, <&pm 0x20 5>; - clock-names = "GCLK", "PM"; -}; - -&sercom4 { - interrupts = <13 0>; - clocks = <&gclk 0x18>, <&pm 0x20 6>; - clock-names = "GCLK", "PM"; -}; - -&sercom5 { - interrupts = <14 0>; - clocks = <&gclk 0x19>, <&pm 0x20 7>; - clock-names = "GCLK", "PM"; -}; - -&tc4 { - interrupts = <19 0>; - clocks = <&gclk 0x1c>, <&pm 0x20 12>; - clock-names = "GCLK", "PM"; -}; - -&adc { - clocks = <&gclk 0x1e>, <&pm 0x20 16>; - clock-names = "GCLK", "PM"; - interrupts = <23 0>; - interrupt-names = "resrdy"; -}; diff --git a/dts/arm/atmel/samr34.dtsi b/dts/arm/atmel/samr34.dtsi index 17164005d9939..351e02bb1e1d0 100644 --- a/dts/arm/atmel/samr34.dtsi +++ b/dts/arm/atmel/samr34.dtsi @@ -13,6 +13,8 @@ / { aliases { + port-c = &portc; + lora0 = &lora; }; @@ -23,9 +25,10 @@ portc: gpio@40002900 { compatible = "atmel,sam0-gpio"; reg = <0x40002900 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + gpio-controller; }; }; }; @@ -37,19 +40,22 @@ /* SERCOM4 is used to interface with the internal LoRa radio */ compatible = "atmel,sam0-spi"; status = "disabled"; + + #address-cells = <1>; + #size-cells = <0>; + dipo = <0>; dopo = <1>; cs-gpios = <&portb 31 GPIO_ACTIVE_LOW>; - #address-cells = <1>; - #size-cells = <0>; pinctrl-0 = <&sercom4_default>; pinctrl-names = "default"; lora: sx1276@0 { compatible = "semtech,sx1276"; - status = "disabled"; reg = <0>; + status = "disabled"; + reset-gpios = <&portb 15 GPIO_ACTIVE_LOW>; /* nRST */ dio-gpios = <&portb 16 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>, /* DIO0 */ diff --git a/dts/arm/st/f1/stm32f105.dtsi b/dts/arm/st/f1/stm32f105.dtsi index d4f05930a80e2..053ef6b2db60d 100644 --- a/dts/arm/st/f1/stm32f105.dtsi +++ b/dts/arm/st/f1/stm32f105.dtsi @@ -49,7 +49,7 @@ interrupts = <63 0>, <64 0>, <65 0>, <66 0>; interrupt-names = "TX", "RX0", "RX1", "SCE"; /* also enabling clock for can1 (master instance) */ - clocks = <&rcc STM32_CLOCK(APB1, 26U)>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x06000000>; status = "disabled"; }; diff --git a/dts/arm/st/f4/stm32f405.dtsi b/dts/arm/st/f4/stm32f405.dtsi index 9dbc4af8c57ef..0916495b013ba 100644 --- a/dts/arm/st/f4/stm32f405.dtsi +++ b/dts/arm/st/f4/stm32f405.dtsi @@ -220,7 +220,7 @@ interrupts = <63 0>, <64 0>, <65 0>, <66 0>; interrupt-names = "TX", "RX0", "RX1", "SCE"; /* also enabling clock for can1 (master instance) */ - clocks = <&rcc STM32_CLOCK(APB1, 26U)>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x06000000>; master-can-reg = <0x40006400>; status = "disabled"; }; diff --git a/dts/arm/st/f4/stm32f412.dtsi b/dts/arm/st/f4/stm32f412.dtsi index d250d167259d8..636bf85520e00 100644 --- a/dts/arm/st/f4/stm32f412.dtsi +++ b/dts/arm/st/f4/stm32f412.dtsi @@ -230,7 +230,7 @@ interrupts = <63 0>, <64 0>, <65 0>, <66 0>; interrupt-names = "TX", "RX0", "RX1", "SCE"; /* also enabling clock for can1 (master instance) */ - clocks = <&rcc STM32_CLOCK(APB1, 26U)>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x06000000>; master-can-reg = <0x40006400>; status = "disabled"; }; diff --git a/dts/arm/st/f4/stm32f446.dtsi b/dts/arm/st/f4/stm32f446.dtsi index 4aea609df1fcb..f1fbf91d47a0e 100644 --- a/dts/arm/st/f4/stm32f446.dtsi +++ b/dts/arm/st/f4/stm32f446.dtsi @@ -73,7 +73,7 @@ interrupts = <63 0>, <64 0>, <65 0>, <66 0>; interrupt-names = "TX", "RX0", "RX1", "SCE"; /* also enabling clock for can1 (master instance) */ - clocks = <&rcc STM32_CLOCK(APB1, 26U)>; + clocks = <&rcc STM32_CLOCK_BUS_APB1 0x06000000>; master-can-reg = <0x40006400>; status = "disabled"; }; diff --git a/dts/arm/st/h7/stm32h723.dtsi b/dts/arm/st/h7/stm32h723.dtsi index e4e7e4ee7acc4..63bf1f1cc2b3a 100644 --- a/dts/arm/st/h7/stm32h723.dtsi +++ b/dts/arm/st/h7/stm32h723.dtsi @@ -88,7 +88,7 @@ interrupts = <88 0>, <89 0>; interrupt-names = "ltdc", "ltdc_er"; clocks = <&rcc STM32_CLOCK(APB3, 3U)>; - resets = <&rctl STM32_RESET(APB3, 4U)>; + resets = <&rctl STM32_RESET(APB3, 3U)>; status = "disabled"; }; diff --git a/dts/arm/st/h7/stm32h743.dtsi b/dts/arm/st/h7/stm32h743.dtsi index 114db6e7c1ece..f6b285dd18acb 100644 --- a/dts/arm/st/h7/stm32h743.dtsi +++ b/dts/arm/st/h7/stm32h743.dtsi @@ -49,7 +49,7 @@ interrupts = <88 0>, <89 0>; interrupt-names = "ltdc", "ltdc_er"; clocks = <&rcc STM32_CLOCK(APB3, 3U)>; - resets = <&rctl STM32_RESET(APB3, 4U)>; + resets = <&rctl STM32_RESET(APB3, 3U)>; status = "disabled"; }; diff --git a/dts/arm/st/h7/stm32h745.dtsi b/dts/arm/st/h7/stm32h745.dtsi index 294fd02c502c0..0eb82817506d7 100644 --- a/dts/arm/st/h7/stm32h745.dtsi +++ b/dts/arm/st/h7/stm32h745.dtsi @@ -42,7 +42,7 @@ interrupts = <88 0>, <89 0>; interrupt-names = "ltdc", "ltdc_er"; clocks = <&rcc STM32_CLOCK(APB3, 3U)>; - resets = <&rctl STM32_RESET(APB3, 4U)>; + resets = <&rctl STM32_RESET(APB3, 3U)>; status = "disabled"; }; diff --git a/dts/arm/st/h7/stm32h7a3.dtsi b/dts/arm/st/h7/stm32h7a3.dtsi index 4721872a3b1d0..6427d73a1cbe2 100644 --- a/dts/arm/st/h7/stm32h7a3.dtsi +++ b/dts/arm/st/h7/stm32h7a3.dtsi @@ -52,7 +52,7 @@ interrupts = <88 0>, <89 0>; interrupt-names = "ltdc", "ltdc_er"; clocks = <&rcc STM32_CLOCK(APB3, 3U)>; - resets = <&rctl STM32_RESET(APB3, 4U)>; + resets = <&rctl STM32_RESET(APB3, 3U)>; status = "disabled"; }; diff --git a/dts/arm/st/u5/stm32u5.dtsi b/dts/arm/st/u5/stm32u5.dtsi index 9f694d600a3fd..c884a2063d11a 100644 --- a/dts/arm/st/u5/stm32u5.dtsi +++ b/dts/arm/st/u5/stm32u5.dtsi @@ -304,7 +304,7 @@ compatible = "zephyr,memory-region", "st,stm32-backup-sram"; reg = <0x40036400 DT_SIZE_K(2)>; /* BKPSRAMEN and RAMCFGEN clock enable */ - clocks = <&rcc STM32_CLOCK(AHB1, 28U)>; + clocks = <&rcc STM32_CLOCK_BUS_AHB1 ((1 << 28) | (1 << 17))>; zephyr,memory-region = "BACKUP_SRAM"; status = "disabled"; }; diff --git a/dts/arm/st/u5/stm32u595.dtsi b/dts/arm/st/u5/stm32u595.dtsi index c0c856dc27384..22fb5f8d308ea 100644 --- a/dts/arm/st/u5/stm32u595.dtsi +++ b/dts/arm/st/u5/stm32u595.dtsi @@ -106,7 +106,8 @@ num-bidir-endpoints = <9>; ram-size = <4096>; maximum-speed = "high-speed"; - clocks = <&rcc STM32_CLOCK(AHB2, 15U)>, + /* Enable OTG_HS PHY and peripheral clocks (OTGHSPHYEN | OTGEN) */ + clocks = <&rcc STM32_CLOCK_BUS_AHB2 ((1 << 15) | (1 << 14))>, <&rcc STM32_SRC_HSI48 ICKLK_SEL(0)>; phys = <&otghs_phy>; status = "disabled"; diff --git a/dts/common/espressif/partitions_0x0_amp_16M.dtsi b/dts/common/espressif/partitions_0x0_amp_16M.dtsi new file mode 100644 index 0000000000000..86088c3f5fe74 --- /dev/null +++ b/dts/common/espressif/partitions_0x0_amp_16M.dtsi @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* 16MB flash partition table */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x0 DT_SIZE_K(64)>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x20000 DT_SIZE_K(6080)>; + }; + + slot0_appcpu_partition: partition@610000 { + label = "image-0-appcpu"; + reg = <0x610000 DT_SIZE_K(1920)>; + }; + + slot1_partition: partition@7F0000 { + label = "image-1"; + reg = <0x7F0000 DT_SIZE_K(6080)>; + }; + + slot1_appcpu_partition: partition@DE0000 { + label = "image-1-appcpu"; + reg = <0xDE0000 DT_SIZE_K(1920)>; + }; + + storage_partition: partition@FC0000 { + label = "storage"; + reg = <0xFC0000 DT_SIZE_K(128)>; + }; + + scratch_partition: partition@FE0000 { + label = "image-scratch"; + reg = <0xFE0000 DT_SIZE_K(64)>; + }; + + coredump_partition: partition@FF0000 { + label = "coredump-partition"; + reg = <0xFF0000 DT_SIZE_K(4)>; + }; + }; +}; diff --git a/dts/common/espressif/partitions_0x0_amp_32M.dtsi b/dts/common/espressif/partitions_0x0_amp_32M.dtsi new file mode 100644 index 0000000000000..e5a95fc3bec0b --- /dev/null +++ b/dts/common/espressif/partitions_0x0_amp_32M.dtsi @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* 32MB flash partition table */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x0 DT_SIZE_K(64)>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x20000 DT_SIZE_K(12352)>; + }; + + slot0_appcpu_partition: partition@C30000 { + label = "image-0-appcpu"; + reg = <0xC30000 DT_SIZE_K(3840)>; + }; + + slot1_partition: partition@FF0000 { + label = "image-1"; + reg = <0xFF0000 DT_SIZE_K(12352)>; + }; + + slot1_appcpu_partition: partition@1C00000 { + label = "image-1-appcpu"; + reg = <0x1C00000 DT_SIZE_K(3840)>; + }; + + storage_partition: partition@1FC0000 { + label = "storage"; + reg = <0x1FC0000 DT_SIZE_K(128)>; + }; + + scratch_partition: partition@1FE0000 { + label = "image-scratch"; + reg = <0x1FE0000 DT_SIZE_K(64)>; + }; + + coredump_partition: partition@1FF0000 { + label = "coredump-partition"; + reg = <0x1FF0000 DT_SIZE_K(4)>; + }; + }; +}; diff --git a/dts/common/espressif/partitions_0x0_default_16M.dtsi b/dts/common/espressif/partitions_0x0_default_16M.dtsi new file mode 100644 index 0000000000000..d4b01753d0bd1 --- /dev/null +++ b/dts/common/espressif/partitions_0x0_default_16M.dtsi @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* 16MB flash partition table */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x0 DT_SIZE_K(64)>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x20000 DT_SIZE_K(8000)>; + }; + + slot1_partition: partition@7F0000 { + label = "image-1"; + reg = <0x7F0000 DT_SIZE_K(8000)>; + }; + + storage_partition: partition@FC0000 { + label = "storage"; + reg = <0xFC0000 DT_SIZE_K(128)>; + }; + + scratch_partition: partition@FE0000 { + label = "image-scratch"; + reg = <0xFE0000 DT_SIZE_K(64)>; + }; + + coredump_partition: partition@FF0000 { + label = "coredump-partition"; + reg = <0xFF0000 DT_SIZE_K(4)>; + }; + }; +}; diff --git a/dts/common/espressif/partitions_0x0_default_32M.dtsi b/dts/common/espressif/partitions_0x0_default_32M.dtsi new file mode 100644 index 0000000000000..710ea747eb91b --- /dev/null +++ b/dts/common/espressif/partitions_0x0_default_32M.dtsi @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* 32MB flash partition table */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x0 DT_SIZE_K(64)>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x20000 DT_SIZE_K(16192)>; + }; + + slot1_partition: partition@FF0000 { + label = "image-1"; + reg = <0xFF0000 DT_SIZE_K(16192)>; + }; + + storage_partition: partition@1FC0000 { + label = "storage"; + reg = <0x1FC0000 DT_SIZE_K(128)>; + }; + + scratch_partition: partition@1FE0000 { + label = "image-scratch"; + reg = <0x1FE0000 DT_SIZE_K(64)>; + }; + + coredump_partition: partition@1FF0000 { + label = "coredump-partition"; + reg = <0x1FF0000 DT_SIZE_K(4)>; + }; + }; +}; diff --git a/dts/common/espressif/partitions_0x1000_amp_16M.dtsi b/dts/common/espressif/partitions_0x1000_amp_16M.dtsi new file mode 100644 index 0000000000000..c994ddd762a67 --- /dev/null +++ b/dts/common/espressif/partitions_0x1000_amp_16M.dtsi @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* 16MB flash partition table */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@1000 { + label = "mcuboot"; + reg = <0x1000 DT_SIZE_K(60)>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x20000 DT_SIZE_K(6080)>; + }; + + slot0_appcpu_partition: partition@610000 { + label = "image-0-appcpu"; + reg = <0x610000 DT_SIZE_K(1920)>; + }; + + slot1_partition: partition@7F0000 { + label = "image-1"; + reg = <0x7F0000 DT_SIZE_K(6080)>; + }; + + slot1_appcpu_partition: partition@DE0000 { + label = "image-1-appcpu"; + reg = <0xDE0000 DT_SIZE_K(1920)>; + }; + + storage_partition: partition@FC0000 { + label = "storage"; + reg = <0xFC0000 DT_SIZE_K(128)>; + }; + + scratch_partition: partition@FE0000 { + label = "image-scratch"; + reg = <0xFE0000 DT_SIZE_K(64)>; + }; + + coredump_partition: partition@FF0000 { + label = "coredump-partition"; + reg = <0xFF0000 DT_SIZE_K(4)>; + }; + }; +}; diff --git a/dts/common/espressif/partitions_0x1000_amp_32M.dtsi b/dts/common/espressif/partitions_0x1000_amp_32M.dtsi new file mode 100644 index 0000000000000..7006269f994f2 --- /dev/null +++ b/dts/common/espressif/partitions_0x1000_amp_32M.dtsi @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* 32MB flash partition table */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@1000 { + label = "mcuboot"; + reg = <0x1000 DT_SIZE_K(60)>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x20000 DT_SIZE_K(12352)>; + }; + + slot0_appcpu_partition: partition@C30000 { + label = "image-0-appcpu"; + reg = <0xC24000 DT_SIZE_K(3840)>; + }; + + slot1_partition: partition@FF0000 { + label = "image-1"; + reg = <0xFF0000 DT_SIZE_K(12352)>; + }; + + slot1_appcpu_partition: partition@1C00000 { + label = "image-1-appcpu"; + reg = <0x1C00000 DT_SIZE_K(3840)>; + }; + + storage_partition: partition@1FC0000 { + label = "storage"; + reg = <0x1FC0000 DT_SIZE_K(128)>; + }; + + scratch_partition: partition@1FE0000 { + label = "image-scratch"; + reg = <0x1FE0000 DT_SIZE_K(64)>; + }; + + coredump_partition: partition@1FF0000 { + label = "coredump-partition"; + reg = <0x1FF0000 DT_SIZE_K(4)>; + }; + }; +}; diff --git a/dts/common/espressif/partitions_0x1000_default_16M.dtsi b/dts/common/espressif/partitions_0x1000_default_16M.dtsi new file mode 100644 index 0000000000000..84663ecafd187 --- /dev/null +++ b/dts/common/espressif/partitions_0x1000_default_16M.dtsi @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* 16MB flash partition table */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@1000 { + label = "mcuboot"; + reg = <0x1000 DT_SIZE_K(60)>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x20000 DT_SIZE_K(8000)>; + }; + + slot1_partition: partition@7F0000 { + label = "image-1"; + reg = <0x7F0000 DT_SIZE_K(8000)>; + }; + + storage_partition: partition@FC0000 { + label = "storage"; + reg = <0xFC0000 DT_SIZE_K(128)>; + }; + + scratch_partition: partition@FE0000 { + label = "image-scratch"; + reg = <0xFE0000 DT_SIZE_K(64)>; + }; + + coredump_partition: partition@FF0000 { + label = "coredump-partition"; + reg = <0xFF0000 DT_SIZE_K(4)>; + }; + }; +}; diff --git a/dts/common/espressif/partitions_0x1000_default_32M.dtsi b/dts/common/espressif/partitions_0x1000_default_32M.dtsi new file mode 100644 index 0000000000000..4e7cc4511bb96 --- /dev/null +++ b/dts/common/espressif/partitions_0x1000_default_32M.dtsi @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /* 32MB flash partition table */ +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@1000 { + label = "mcuboot"; + reg = <0x1000 DT_SIZE_K(60)>; + }; + + slot0_partition: partition@20000 { + label = "image-0"; + reg = <0x20000 DT_SIZE_K(16192)>; + }; + + slot1_partition: partition@FF0000 { + label = "image-1"; + reg = <0xFF0000 DT_SIZE_K(16192)>; + }; + + storage_partition: partition@1FC0000 { + label = "storage"; + reg = <0x1FC0000 DT_SIZE_K(128)>; + }; + + scratch_partition: partition@1FE0000 { + label = "image-scratch"; + reg = <0x1FE0000 DT_SIZE_K(64)>; + }; + + coredump_partition: partition@1FF0000 { + label = "coredump-partition"; + reg = <0x1FF0000 DT_SIZE_K(4)>; + }; + }; +}; diff --git a/include/zephyr/arch/riscv/reg.h b/include/zephyr/arch/riscv/reg.h index 6d3b2d88b1755..2c0650f0498f1 100644 --- a/include/zephyr/arch/riscv/reg.h +++ b/include/zephyr/arch/riscv/reg.h @@ -7,6 +7,8 @@ #ifndef ZEPHYR_INCLUDE_ZEPHYR_ARCH_RISCV_REG_H_ #define ZEPHYR_INCLUDE_ZEPHYR_ARCH_RISCV_REG_H_ +#include + #define reg_read(reg) \ ({ \ register unsigned long __rv; \ diff --git a/include/zephyr/bluetooth/services/cts.h b/include/zephyr/bluetooth/services/cts.h index 46fb7808cc4ee..5b1c780f68615 100644 --- a/include/zephyr/bluetooth/services/cts.h +++ b/include/zephyr/bluetooth/services/cts.h @@ -16,7 +16,6 @@ */ #include -#include #ifdef __cplusplus extern "C" { diff --git a/include/zephyr/logging/log_backend.h b/include/zephyr/logging/log_backend.h index e772ad2b9c82d..c68d210af7350 100644 --- a/include/zephyr/logging/log_backend.h +++ b/include/zephyr/logging/log_backend.h @@ -83,6 +83,7 @@ struct log_backend_control_block { void *ctx; uint8_t id; bool active; + bool initialized; /* Initialization level. */ uint8_t level; @@ -140,6 +141,7 @@ static inline void log_backend_init(const struct log_backend *const backend) if (backend->api->init) { backend->api->init(backend); } + backend->cb->initialized = true; } /** diff --git a/include/zephyr/logging/log_core.h b/include/zephyr/logging/log_core.h index 64cd2a6c9e573..8af082fd653fb 100644 --- a/include/zephyr/logging/log_core.h +++ b/include/zephyr/logging/log_core.h @@ -400,12 +400,12 @@ static inline char z_log_minimal_level_to_char(int level) #define LOG_FILTER_SLOT_GET(_filters, _id) \ ((*(_filters) >> LOG_FILTER_SLOT_SHIFT(_id)) & LOG_FILTER_SLOT_MASK) -#define LOG_FILTER_SLOT_SET(_filters, _id, _filter) \ - do { \ - *(_filters) &= ~(LOG_FILTER_SLOT_MASK << \ - LOG_FILTER_SLOT_SHIFT(_id)); \ - *(_filters) |= ((_filter) & LOG_FILTER_SLOT_MASK) << \ - LOG_FILTER_SLOT_SHIFT(_id); \ +#define LOG_FILTER_SLOT_SET(_filters, _id, _filter) \ + do { \ + uint32_t others = *(_filters) & ~(LOG_FILTER_SLOT_MASK << \ + LOG_FILTER_SLOT_SHIFT(_id)); \ + *(_filters) = others | (((_filter) & LOG_FILTER_SLOT_MASK) << \ + LOG_FILTER_SLOT_SHIFT(_id)); \ } while (false) #define LOG_FILTER_AGGR_SLOT_IDX 0 diff --git a/include/zephyr/net/net_if.h b/include/zephyr/net/net_if.h index 7795f56597662..cfba714d6631a 100644 --- a/include/zephyr/net/net_if.h +++ b/include/zephyr/net/net_if.h @@ -94,6 +94,11 @@ struct net_if_addr { struct { /** Duplicate address detection (DAD) timer */ sys_snode_t dad_node; + + /** DAD needed list node */ + sys_snode_t dad_need_node; + + /** DAD start time */ uint32_t dad_start; /** How many times we have done DAD */ @@ -104,6 +109,11 @@ struct net_if_addr { struct { /** Address conflict detection (ACD) timer. */ sys_snode_t acd_node; + + /** ACD needed list node */ + sys_snode_t acd_need_node; + + /** ACD timeout value. */ k_timepoint_t acd_timeout; /** ACD probe/announcement counter. */ @@ -134,7 +144,10 @@ struct net_if_addr { */ uint8_t is_temporary : 1; - uint8_t _unused : 4; + /** Was this address added or not */ + uint8_t is_added : 1; + + uint8_t _unused : 3; }; /** @@ -1183,9 +1196,10 @@ int net_if_set_link_addr_locked(struct net_if *iface, extern int net_if_addr_unref_debug(struct net_if *iface, sa_family_t family, const void *addr, + struct net_if_addr **ifaddr, const char *caller, int line); -#define net_if_addr_unref(iface, family, addr) \ - net_if_addr_unref_debug(iface, family, addr, __func__, __LINE__) +#define net_if_addr_unref(iface, family, addr, ifaddr) \ + net_if_addr_unref_debug(iface, family, addr, ifaddr, __func__, __LINE__) extern struct net_if_addr *net_if_addr_ref_debug(struct net_if *iface, sa_family_t family, @@ -1197,7 +1211,8 @@ extern struct net_if_addr *net_if_addr_ref_debug(struct net_if *iface, #else extern int net_if_addr_unref(struct net_if *iface, sa_family_t family, - const void *addr); + const void *addr, + struct net_if_addr **ifaddr); extern struct net_if_addr *net_if_addr_ref(struct net_if *iface, sa_family_t family, const void *addr); diff --git a/include/zephyr/shell/shell.h b/include/zephyr/shell/shell.h index e2a40b853286a..c175a149278cf 100644 --- a/include/zephyr/shell/shell.h +++ b/include/zephyr/shell/shell.h @@ -930,7 +930,7 @@ extern void z_shell_print_stream(const void *user_ctx, const char *data, static struct shell_ctx UTIL_CAT(_name, _ctx); \ Z_SHELL_HISTORY_DEFINE(_name##_history, CONFIG_SHELL_HISTORY_BUFFER); \ Z_SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _out_buf, CONFIG_SHELL_PRINTF_BUFF_SIZE, \ - true, z_shell_print_stream); \ + IS_ENABLED(CONFIG_SHELL_PRINTF_AUTOFLUSH), z_shell_print_stream); \ LOG_INSTANCE_REGISTER(shell, _name, CONFIG_SHELL_LOG_LEVEL); \ Z_SHELL_STATS_DEFINE(_name); \ static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \ diff --git a/include/zephyr/sys/p4wq.h b/include/zephyr/sys/p4wq.h index 8ddb8f0d7a781..967de8c877000 100644 --- a/include/zephyr/sys/p4wq.h +++ b/include/zephyr/sys/p4wq.h @@ -18,6 +18,13 @@ struct k_p4wq_work; */ typedef void (*k_p4wq_handler_t)(struct k_p4wq_work *work); +/** + * Optional P4 Queue done callback. + * Will be called after the memory structure is not used anymore by the p4wq. + * If it is not used it must be set to NULL. + */ +typedef void (*k_p4wq_done_handler_t)(struct k_p4wq_work *work); + /** * @brief P4 Queue Work Item * @@ -74,6 +81,11 @@ struct k_p4wq { /* K_P4WQ_* flags above */ uint32_t flags; + + /* done handler which is called every time after work was successfully executed + * and k_p4wq_work is not needed by p4wq anymore + */ + k_p4wq_done_handler_t done_handler; }; struct k_p4wq_initparam { @@ -83,6 +95,7 @@ struct k_p4wq_initparam { struct k_thread *threads; struct z_thread_stack_element *stacks; uint32_t flags; + k_p4wq_done_handler_t done_handler; }; /** @@ -95,8 +108,9 @@ struct k_p4wq_initparam { * @param name Symbol name of the struct k_p4wq that will be defined * @param n_threads Number of threads in the work queue pool * @param stack_sz Requested stack size of each thread, in bytes + * @param dn_handler Function pointer to handler of type k_p4wq_done_handler_t */ -#define K_P4WQ_DEFINE(name, n_threads, stack_sz) \ +#define K_P4WQ_DEFINE_WITH_DONE_HANDLER(name, n_threads, stack_sz, dn_handler) \ static K_THREAD_STACK_ARRAY_DEFINE(_p4stacks_##name, \ n_threads, stack_sz); \ static struct k_thread _p4threads_##name[n_threads]; \ @@ -109,8 +123,19 @@ struct k_p4wq_initparam { .stacks = &(_p4stacks_##name[0][0]), \ .queue = &name, \ .flags = 0, \ + .done_handler = dn_handler, \ } +/** + * @brief Statically initialize a P4 Work Queue + * + * Same like K_P4WQ_DEFINE_WITH_DONE_HANDLER but without an + * optional handler which is called everytime when work is executed + * and not used anymore by the p4wq + */ +#define K_P4WQ_DEFINE(name, n_threads, stack_sz) \ + K_P4WQ_DEFINE_WITH_DONE_HANDLER(name, n_threads, stack_sz, NULL) + /** * @brief Statically initialize an array of P4 Work Queues * @@ -122,8 +147,9 @@ struct k_p4wq_initparam { * @param n_threads Number of threads and work queues * @param stack_sz Requested stack size of each thread, in bytes * @param flg Flags + * @param dn_handler Function pointer to handler of type k_p4wq_done_handler_t */ -#define K_P4WQ_ARRAY_DEFINE(name, n_threads, stack_sz, flg) \ +#define K_P4WQ_ARRAY_DEFINE_WITH_DONE_HANDLER(name, n_threads, stack_sz, flg, dn_handler) \ static K_THREAD_STACK_ARRAY_DEFINE(_p4stacks_##name, \ n_threads, stack_sz); \ static struct k_thread _p4threads_##name[n_threads]; \ @@ -136,8 +162,19 @@ struct k_p4wq_initparam { .stacks = &(_p4stacks_##name[0][0]), \ .queue = name, \ .flags = K_P4WQ_QUEUE_PER_THREAD | flg, \ + .done_handler = dn_handler, \ } +/** + * @brief Statically initialize an array of P4 Work Queues + * + * Same like K_P4WQ_ARRAY_DEFINE_WITH_DONE_HANDLER but without an + * optional handler which is called everytime when work is executed + * and not used anymore by the p4wq + */ +#define K_P4WQ_ARRAY_DEFINE(name, n_threads, stack_sz, flg) \ + K_P4WQ_ARRAY_DEFINE_WITH_DONE_HANDLER(name, n_threads, stack_sz, flg, NULL) + /** * @brief Initialize P4 Queue * diff --git a/lib/os/Kconfig b/lib/os/Kconfig index 9ce3be2a66ebf..004df87ccf390 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -106,6 +106,16 @@ config MPSC_CLEAR_ALLOCATED When enabled packet space is zeroed before returning from allocation. endif +if SCHED_DEADLINE + +config P4WQ_INIT_STAGE_EARLY + bool "Early initialization of P4WQ threads" + help + Initialize P4WQ threads early so that the P4WQ can be used on devices + initialization sequence. + +endif + config REBOOT bool "Reboot functionality" help diff --git a/lib/os/p4wq.c b/lib/os/p4wq.c index d95de01d2f767..e4855de3cce5f 100644 --- a/lib/os/p4wq.c +++ b/lib/os/p4wq.c @@ -104,7 +104,14 @@ static FUNC_NORETURN void p4wq_loop(void *p0, void *p1, void *p2) if (!thread_was_requeued(_current)) { sys_dlist_remove(&w->dlnode); w->thread = NULL; - k_sem_give(&w->done_sem); + + if (queue->done_handler) { + k_spin_unlock(&queue->lock, k); + queue->done_handler(w); + k = k_spin_lock(&queue->lock); + } else { + k_sem_give(&w->done_sem); + } } } else { z_pend_curr(&queue->lock, k, &queue->waitq, K_FOREVER); @@ -152,6 +159,7 @@ static int static_init(void) if (!i || (pp->flags & K_P4WQ_QUEUE_PER_THREAD)) { k_p4wq_init(q); + q->done_handler = pp->done_handler; } q->flags = pp->flags; @@ -215,7 +223,11 @@ void k_p4wq_enable_static_thread(struct k_p4wq *queue, struct k_thread *thread, * so they can initialize in parallel instead of serially on the main * CPU. */ +#if defined(CONFIG_P4WQ_INIT_STAGE_EARLY) +SYS_INIT(static_init, POST_KERNEL, 1); +#else SYS_INIT(static_init, APPLICATION, 99); +#endif void k_p4wq_submit(struct k_p4wq *queue, struct k_p4wq_work *item) { @@ -301,7 +313,14 @@ bool k_p4wq_cancel(struct k_p4wq *queue, struct k_p4wq_work *item) if (ret) { rb_remove(&queue->queue, &item->rbnode); - k_sem_give(&item->done_sem); + + if (queue->done_handler) { + k_spin_unlock(&queue->lock, k); + queue->done_handler(item); + k = k_spin_lock(&queue->lock); + } else { + k_sem_give(&item->done_sem); + } } k_spin_unlock(&queue->lock, k); diff --git a/modules/lvgl/lvgl.c b/modules/lvgl/lvgl.c index 76df359e7fc73..d61d61da3efa2 100644 --- a/modules/lvgl/lvgl.c +++ b/modules/lvgl/lvgl.c @@ -209,12 +209,12 @@ static int lvgl_init(void) lvgl_heap_init(); #endif + lv_init(); + #if CONFIG_LV_Z_LOG_LEVEL != 0 lv_log_register_print_cb(lvgl_log); #endif - lv_init(); - #ifdef CONFIG_LV_Z_USE_FILESYSTEM lvgl_fs_init(); #endif diff --git a/samples/sensor/sensor_shell/pytest/test_sensor_shell.py b/samples/sensor/sensor_shell/pytest/test_sensor_shell.py index 7a01bec9978c7..9736b2e9eb8df 100644 --- a/samples/sensor/sensor_shell/pytest/test_sensor_shell.py +++ b/samples/sensor/sensor_shell/pytest/test_sensor_shell.py @@ -21,16 +21,12 @@ def test_sensor_shell_info(shell: Shell): def test_sensor_shell_get(shell: Shell): logger.info('send "sensor get" command') - lines = shell.exec_command('sensor get sensor@0 voltage') - assert any(['channel type=31(voltage)' in line for line in lines]), 'expected response not found' - - lines = shell.exec_command('sensor get sensor@1 53') - assert any(['channel type=53(gauge_state_of_health)' in line for line in lines]), 'expected response not found' - # Channel should be the last one before 'all' (because 'all' doesn't print anything) so that the # for-loop in `parse_named_int()` will go through everything - lines = shell.exec_command('sensor get sensor@0 gauge_desired_charging_current') - assert any(['channel type=59(gauge_desired_charging_current)' in line for line in lines]), 'expected response not found' + for channel in range(59): + logger.info(f'channel {channel}') + lines = shell.exec_command(f'sensor get sensor@0 {channel}') + assert any([f'channel type={channel}' in line for line in lines]), 'expected response not found' logger.info('response is valid') diff --git a/samples/subsys/mgmt/mcumgr/smp_svr/src/bluetooth.c b/samples/subsys/mgmt/mcumgr/smp_svr/src/bluetooth.c index 7c5723bf999f2..477494b9c24dd 100644 --- a/samples/subsys/mgmt/mcumgr/smp_svr/src/bluetooth.c +++ b/samples/subsys/mgmt/mcumgr/smp_svr/src/bluetooth.c @@ -43,11 +43,10 @@ static void connected(struct bt_conn *conn, uint8_t err) { if (err) { LOG_ERR("Connection failed, err 0x%02x %s", err, bt_hci_err_to_str(err)); + k_work_submit(&advertise_work); } else { LOG_INF("Connected"); } - - k_work_submit(&advertise_work); } static void disconnected(struct bt_conn *conn, uint8_t reason) diff --git a/soc/atmel/sam0/common/Kconfig.samd5x b/soc/atmel/sam0/common/Kconfig.samd5x index dd05fe605d1e4..969887e99da28 100644 --- a/soc/atmel/sam0/common/Kconfig.samd5x +++ b/soc/atmel/sam0/common/Kconfig.samd5x @@ -10,6 +10,14 @@ config SOC_ATMEL_SAMD5X_XOSC32K startup. This can then be selected as the main clock source for the SOC. +config SOC_ATMEL_SAMD5X_XOSC32K_STARTUP + depends on SOC_ATMEL_SAMD5X_XOSC32K + hex "Startup time external 32 kHz crystal oscillator" + range 0x0 0x6 + default 0x1 + help + Selects the startup time for the external 32 kHz crystal oscillator. + choice prompt "Main clock source" default SOC_ATMEL_SAMD5X_DEFAULT_AS_MAIN diff --git a/soc/atmel/sam0/common/soc_samd5x.c b/soc/atmel/sam0/common/soc_samd5x.c index f9f337f0f3b2f..a12d3891ea83f 100644 --- a/soc/atmel/sam0/common/soc_samd5x.c +++ b/soc/atmel/sam0/common/soc_samd5x.c @@ -18,13 +18,18 @@ #define SAM0_DFLL_FREQ_HZ (48000000U) #define SAM0_DPLL_FREQ_MIN_HZ (96000000U) #define SAM0_DPLL_FREQ_MAX_HZ (200000000U) +#define SAM0_XOSC32K_STARTUP_TIME CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_STARTUP #if CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_AS_MAIN static void osc32k_init(void) { - OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE | OSC32KCTRL_XOSC32K_XTALEN - | OSC32KCTRL_XOSC32K_EN32K | OSC32KCTRL_XOSC32K_RUNSTDBY - | OSC32KCTRL_XOSC32K_STARTUP(0) | OSC32KCTRL_XOSC32K_CGM_XT; + OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE + | OSC32KCTRL_XOSC32K_XTALEN + | OSC32KCTRL_XOSC32K_CGM_XT + | OSC32KCTRL_XOSC32K_EN32K + | OSC32KCTRL_XOSC32K_RUNSTDBY + | OSC32KCTRL_XOSC32K_STARTUP(SAM0_XOSC32K_STARTUP_TIME) + ; while (!OSC32KCTRL->STATUS.bit.XOSC32KRDY) { } diff --git a/soc/nxp/rw/soc.c b/soc/nxp/rw/soc.c index 9d3b6c548f155..44a8cdbf9aa3b 100644 --- a/soc/nxp/rw/soc.c +++ b/soc/nxp/rw/soc.c @@ -132,6 +132,8 @@ __ramfunc void clock_init(void) CLOCK_SetClkDiv(kCLOCK_DivSystickClk, 1U); CLOCK_AttachClk(kSYSTICK_DIV_to_SYSTICK_CLK); + SystemCoreClockUpdate(); + /* Set PLL FRG clock to 20MHz. */ CLOCK_SetClkDiv(kCLOCK_DivPllFrgClk, 13U); diff --git a/submanifests/optional.yaml b/submanifests/optional.yaml index c9e185d40c3d4..303d9a0b97dde 100644 --- a/submanifests/optional.yaml +++ b/submanifests/optional.yaml @@ -46,7 +46,7 @@ manifest: groups: - optional - name: tf-m-tests - revision: 502ea90105ee18f20c78f710e2ba2ded0fc0756e + revision: c712761dd5391bf3f38033643d28a736cae89a19 path: modules/tee/tf-m/tf-m-tests remote: upstream groups: diff --git a/subsys/bluetooth/common/Kconfig b/subsys/bluetooth/common/Kconfig index 8bec5ba90d5d8..a2ab25a99c571 100644 --- a/subsys/bluetooth/common/Kconfig +++ b/subsys/bluetooth/common/Kconfig @@ -173,6 +173,7 @@ config BT_BUF_CMD_TX_SIZE config BT_BUF_CMD_TX_COUNT int "Number of HCI command buffers" + default 3 if BT_EXT_ADV && BT_CENTRAL default 2 range 2 64 help diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c index 4f61cba9665bc..922799642db8b 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c @@ -263,6 +263,8 @@ void lll_conn_abort_cb(struct lll_prepare_param *prepare_param, void *param) e->type = EVENT_DONE_EXTRA_TYPE_CONN; e->trx_cnt = 0U; e->crc_valid = 0U; + e->is_aborted = 1U; + #if defined(CONFIG_BT_CTLR_LE_ENC) e->mic_state = LLL_CONN_MIC_NONE; #endif /* CONFIG_BT_CTLR_LE_ENC */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index 93a610fa705f5..73fcceb47776f 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -2220,8 +2220,8 @@ void ull_conn_update_parameters(struct ll_conn *conn, uint8_t is_cu_proc, uint8_ uint16_t conn_interval_unit_old; uint16_t conn_interval_unit_new; uint32_t ticks_win_offset = 0U; - uint16_t conn_interval_old_us; - uint16_t conn_interval_new_us; + uint32_t conn_interval_old_us; + uint32_t conn_interval_new_us; uint32_t ticks_slot_overhead; uint16_t conn_interval_old; uint16_t conn_interval_new; diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 4606c8c9b1f1c..61abec0af4ab1 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -891,6 +891,9 @@ int bt_le_create_conn_cancel(void) struct bt_hci_cmd_state_set state; buf = bt_hci_cmd_create(BT_HCI_OP_LE_CREATE_CONN_CANCEL, 0); + if (!buf) { + return -ENOBUFS; + } bt_hci_cmd_state_set_init(buf, &state, bt_dev.flags, BT_DEV_INITIATING, false); diff --git a/subsys/bluetooth/mesh/adv.h b/subsys/bluetooth/mesh/adv.h index 563a2118b711d..2db83d5921166 100644 --- a/subsys/bluetooth/mesh/adv.h +++ b/subsys/bluetooth/mesh/adv.h @@ -58,7 +58,11 @@ struct bt_mesh_adv_ctx { }; struct bt_mesh_adv { - sys_snode_t node; + void *adv_bearer; + +#if defined(CONFIG_BT_MESH_GATT) + void *gatt_bearer[CONFIG_BT_MAX_CONN]; +#endif struct bt_mesh_adv_ctx ctx; diff --git a/subsys/bluetooth/mesh/proxy_msg.c b/subsys/bluetooth/mesh/proxy_msg.c index 861935f58ccf7..a4d8c8c14b2ea 100644 --- a/subsys/bluetooth/mesh/proxy_msg.c +++ b/subsys/bluetooth/mesh/proxy_msg.c @@ -56,6 +56,24 @@ static struct bt_mesh_proxy_role roles[CONFIG_BT_MAX_CONN]; static int conn_count; +static void proxy_queue_put(struct bt_mesh_proxy_role *role, struct bt_mesh_adv *adv) +{ + k_fifo_put(&role->pending, &(adv->gatt_bearer[bt_conn_index(role->conn)])); +} + +static struct bt_mesh_adv *proxy_queue_get(struct bt_mesh_proxy_role *role) +{ + void *gatt_bearer; + + gatt_bearer = k_fifo_get(&role->pending, K_NO_WAIT); + if (!gatt_bearer) { + return NULL; + } + + return CONTAINER_OF(gatt_bearer, struct bt_mesh_adv, + gatt_bearer[bt_conn_index(role->conn)]); +} + static void proxy_sar_timeout(struct k_work *work) { struct bt_mesh_proxy_role *role; @@ -66,7 +84,7 @@ static void proxy_sar_timeout(struct k_work *work) role = CONTAINER_OF(dwork, struct bt_mesh_proxy_role, sar_timer); while (!k_fifo_is_empty(&role->pending)) { - struct bt_mesh_adv *adv = k_fifo_get(&role->pending, K_NO_WAIT); + struct bt_mesh_adv *adv = proxy_queue_get(role); __ASSERT_NO_MSG(adv); @@ -243,7 +261,7 @@ int bt_mesh_proxy_relay_send(struct bt_conn *conn, struct bt_mesh_adv *adv) { struct bt_mesh_proxy_role *role = &roles[bt_conn_index(conn)]; - k_fifo_put(&role->pending, bt_mesh_adv_ref(adv)); + proxy_queue_put(role, bt_mesh_adv_ref(adv)); bt_mesh_wq_submit(&role->work); @@ -252,16 +270,14 @@ int bt_mesh_proxy_relay_send(struct bt_conn *conn, struct bt_mesh_adv *adv) static void proxy_msg_send_pending(struct k_work *work) { - struct bt_mesh_proxy_role *role; - struct k_work_delayable *dwork = k_work_delayable_from_work(work); + struct bt_mesh_proxy_role *role = CONTAINER_OF(work, struct bt_mesh_proxy_role, work); struct bt_mesh_adv *adv; - role = CONTAINER_OF(dwork, struct bt_mesh_proxy_role, sar_timer); if (!role->conn) { return; } - adv = k_fifo_get(&role->pending, K_NO_WAIT); + adv = proxy_queue_get(role); if (!adv) { return; } diff --git a/subsys/bluetooth/services/cts.c b/subsys/bluetooth/services/cts.c index ce72f7728e019..d5744bc5a2480 100644 --- a/subsys/bluetooth/services/cts.c +++ b/subsys/bluetooth/services/cts.c @@ -7,9 +7,17 @@ * * SPDX-License-Identifier: Apache-2.0 */ + +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L /* To get gmtime_r()'s prototype */ + +#ifdef CONFIG_BT_CTS_HELPER_API +#include +#include +#endif + #include #include -#include #include #include @@ -26,9 +34,6 @@ static const struct bt_cts_cb *cts_cb; #ifdef CONFIG_BT_CTS_HELPER_API -#include -#include - int bt_cts_time_to_unix_ms(const struct bt_cts_time_format *ct_time, int64_t *unix_ms) { struct tm date_time; diff --git a/subsys/fs/ext2/ext2_impl.c b/subsys/fs/ext2/ext2_impl.c index f9e4d52769900..507e72f971c26 100644 --- a/subsys/fs/ext2/ext2_impl.c +++ b/subsys/fs/ext2/ext2_impl.c @@ -611,6 +611,7 @@ ssize_t ext2_inode_read(struct ext2_inode *inode, void *buf, uint32_t offset, si int rc = 0; ssize_t read = 0; uint32_t block_size = inode->i_fs->block_size; + size_t nbytes_to_read = nbytes; while (read < nbytes && offset < inode->i_size) { @@ -624,11 +625,12 @@ ssize_t ext2_inode_read(struct ext2_inode *inode, void *buf, uint32_t offset, si uint32_t left_on_blk = block_size - block_off; uint32_t left_in_file = inode->i_size - offset; - size_t to_read = MIN(nbytes, MIN(left_on_blk, left_in_file)); + size_t to_read = MIN(nbytes_to_read, MIN(left_on_blk, left_in_file)); memcpy((uint8_t *)buf + read, inode_current_block_mem(inode) + block_off, to_read); read += to_read; + nbytes_to_read -= to_read; offset += to_read; } diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index ff63770291be6..8840433b325a5 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -846,16 +846,16 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags) lcp->read_size = block_size; lcp->prog_size = block_size; - if (lcp->cache_size < new_cache_size) { - LOG_ERR("Configured cache size is too small: %d < %d", lcp->cache_size, + if (cache_size < new_cache_size) { + LOG_ERR("Configured cache size is too small: %d < %d", cache_size, new_cache_size); return -ENOMEM; } lcp->cache_size = new_cache_size; - if (lcp->lookahead_size < new_lookahead_size) { + if (lookahead_size < new_lookahead_size) { LOG_ERR("Configured lookahead size is too small: %d < %d", - lcp->lookahead_size, new_lookahead_size); + lookahead_size, new_lookahead_size); return -ENOMEM; } lcp->lookahead_size = new_lookahead_size; diff --git a/subsys/logging/log_cmds.c b/subsys/logging/log_cmds.c index fd7997a84bd42..cc23a843eafea 100644 --- a/subsys/logging/log_cmds.c +++ b/subsys/logging/log_cmds.c @@ -341,7 +341,19 @@ static int log_go(const struct shell *sh, char **argv) { if (backend || !IS_ENABLED(CONFIG_LOG_FRONTEND)) { - log_backend_activate(backend, backend->cb->ctx); + if (!backend->cb->initialized) { + log_backend_init(backend); + while (log_backend_is_ready(backend) != 0) { + if (IS_ENABLED(CONFIG_MULTITHREADING)) { + k_msleep(10); + } + } + if (log_backend_is_ready(backend) == 0) { + log_backend_enable(backend, backend->cb->ctx, CONFIG_LOG_MAX_LEVEL); + } + } else { + log_backend_activate(backend, backend->cb->ctx); + } return 0; } diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index f2e5363e094b8..3273c03e3722a 100644 --- a/subsys/logging/log_core.c +++ b/subsys/logging/log_core.c @@ -286,6 +286,14 @@ void log_core_init(void) if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) { z_log_runtime_filters_init(); } + + STRUCT_SECTION_FOREACH(log_backend, backend) { + uint32_t id; + /* As first slot in filtering mask is reserved, backend ID has offset.*/ + id = LOG_FILTER_FIRST_BACKEND_SLOT_IDX; + id += backend - log_backend_get(0); + log_backend_id_set(backend, id); + } } static uint32_t activate_foreach_backend(uint32_t mask) @@ -328,8 +336,8 @@ static uint32_t z_log_init(bool blocking, bool can_sleep) int backend_index = 0; - /* Activate autostart backends */ STRUCT_SECTION_FOREACH(log_backend, backend) { + /* Activate autostart backends */ if (backend->autostart) { log_backend_init(backend); diff --git a/subsys/logging/log_mgmt.c b/subsys/logging/log_mgmt.c index 85d5e578f477d..a004a4ab27c0d 100644 --- a/subsys/logging/log_mgmt.c +++ b/subsys/logging/log_mgmt.c @@ -560,12 +560,6 @@ void log_backend_enable(struct log_backend const *const backend, void *ctx, uint32_t level) { - /* As first slot in filtering mask is reserved, backend ID has offset.*/ - uint32_t id = LOG_FILTER_FIRST_BACKEND_SLOT_IDX; - - id += backend - log_backend_get(0); - - log_backend_id_set(backend, id); backend->cb->level = level; backend_filter_set(backend, level); log_backend_activate(backend, ctx); diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c index 63083c96fb97d..3c8995cd9e3d2 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c @@ -138,6 +138,7 @@ static bool img_mgmt_reset_zse(struct smp_streamer *ctxt) return zcbor_map_start_encode(zse, CONFIG_MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES); } +#endif #if defined(CONFIG_MCUMGR_GRP_IMG_TOO_LARGE_SYSBUILD) static bool img_mgmt_slot_max_size(size_t *area_sizes, zcbor_state_t *zse) @@ -178,7 +179,6 @@ static bool img_mgmt_slot_max_size(size_t *area_sizes, zcbor_state_t *zse) return ok; } #endif -#endif /** * Finds the TLVs in the specified image slot, if any. diff --git a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c index 52b2ed76f67bf..e32efd627c465 100644 --- a/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c +++ b/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c @@ -387,11 +387,6 @@ img_mgmt_state_confirm(void) { int rc; -#if defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS) - int32_t err_rc; - uint16_t err_group; -#endif - /* Confirm disallowed if a test is pending. */ if (img_mgmt_state_any_pending()) { rc = IMG_MGMT_ERR_IMAGE_ALREADY_PENDING; @@ -401,8 +396,13 @@ img_mgmt_state_confirm(void) rc = img_mgmt_write_confirmed(); #if defined(CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS) - (void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0, &err_rc, - &err_group); + if (!rc) { + int32_t err_rc; + uint16_t err_group; + + (void)mgmt_callback_notify(MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED, NULL, 0, &err_rc, + &err_group); + } #endif err: diff --git a/subsys/net/ip/ipv6_nbr.c b/subsys/net/ip/ipv6_nbr.c index 86e6b1f2173b1..b04c475d71754 100644 --- a/subsys/net/ip/ipv6_nbr.c +++ b/subsys/net/ip/ipv6_nbr.c @@ -1552,7 +1552,7 @@ static void ipv6_nd_reachable_timeout(struct k_work *work) data->ns_count); ret = net_ipv6_send_ns(nbr->iface, NULL, NULL, - NULL, &data->addr, + &data->addr, &data->addr, false); if (ret < 0) { NET_DBG("Cannot send NS (%d)", ret); @@ -1730,7 +1730,7 @@ static inline bool handle_na_neighbor(struct net_pkt *pkt, if (na_hdr->flags & NET_ICMPV6_NA_FLAG_OVERRIDE || (!(na_hdr->flags & NET_ICMPV6_NA_FLAG_OVERRIDE) && - tllao_offset && !lladdr_changed)) { + !lladdr_changed)) { if (lladdr_changed) { dbg_update_neighbor_lladdr_raw( @@ -2562,12 +2562,6 @@ static int handle_ra_input(struct net_icmp_ctx *ctx, nd_opt_hdr = (struct net_icmpv6_nd_opt_hdr *) net_pkt_get_data(pkt, &nd_access); - /* Add neighbor cache entry using link local address, regardless of link layer address - * presence in Router Advertisement. - */ - nbr = net_ipv6_nbr_add(net_pkt_iface(pkt), (struct in6_addr *)NET_IPV6_HDR(pkt)->src, NULL, - true, NET_IPV6_NBR_STATE_INCOMPLETE); - while (nd_opt_hdr) { net_pkt_acknowledge_data(pkt, &nd_access); @@ -2668,6 +2662,15 @@ static int handle_ra_input(struct net_icmp_ctx *ctx, net_pkt_get_data(pkt, &nd_access); } + if (nbr == NULL) { + /* Add neighbor cache entry using link local address, regardless + * of link layer address presence in Router Advertisement. + */ + nbr = net_ipv6_nbr_add(net_pkt_iface(pkt), + (struct in6_addr *)NET_IPV6_HDR(pkt)->src, + NULL, true, NET_IPV6_NBR_STATE_INCOMPLETE); + } + router = net_if_ipv6_router_lookup(net_pkt_iface(pkt), (struct in6_addr *)ip_hdr->src); if (router) { diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index f9f7f68b41428..597ca39bb4aec 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -1295,21 +1295,25 @@ void net_if_ipv6_start_dad(struct net_if *iface, ifaddr->dad_count = 1U; - if (!net_ipv6_start_dad(iface, ifaddr)) { - ifaddr->dad_start = k_uptime_get_32(); - ifaddr->ifindex = net_if_get_by_iface(iface); - - k_mutex_lock(&lock, K_FOREVER); - sys_slist_find_and_remove(&active_dad_timers, - &ifaddr->dad_node); - sys_slist_append(&active_dad_timers, &ifaddr->dad_node); - k_mutex_unlock(&lock); - - /* FUTURE: use schedule, not reschedule. */ - if (!k_work_delayable_remaining_get(&dad_timer)) { - k_work_reschedule(&dad_timer, - K_MSEC(DAD_TIMEOUT)); - } + if (net_ipv6_start_dad(iface, ifaddr) != 0) { + NET_ERR("Interface %p failed to send DAD query for %s", + iface, + net_sprint_ipv6_addr(&ifaddr->address.in6_addr)); + } + + ifaddr->dad_start = k_uptime_get_32(); + ifaddr->ifindex = net_if_get_by_iface(iface); + + k_mutex_lock(&lock, K_FOREVER); + sys_slist_find_and_remove(&active_dad_timers, + &ifaddr->dad_node); + sys_slist_append(&active_dad_timers, &ifaddr->dad_node); + k_mutex_unlock(&lock); + + /* FUTURE: use schedule, not reschedule. */ + if (!k_work_delayable_remaining_get(&dad_timer)) { + k_work_reschedule(&dad_timer, + K_MSEC(DAD_TIMEOUT)); } } else { NET_DBG("Interface %p is down, starting DAD for %s later.", @@ -1320,8 +1324,9 @@ void net_if_ipv6_start_dad(struct net_if *iface, void net_if_start_dad(struct net_if *iface) { - struct net_if_addr *ifaddr; + struct net_if_addr *ifaddr, *next; struct net_if_ipv6 *ipv6; + sys_slist_t dad_needed; struct in6_addr addr = { }; int ret; @@ -1353,6 +1358,8 @@ void net_if_start_dad(struct net_if *iface) /* Start DAD for all the addresses that were added earlier when * the interface was down. */ + sys_slist_init(&dad_needed); + ARRAY_FOR_EACH(ipv6->unicast, i) { if (!ipv6->unicast[i].is_used || ipv6->unicast[i].address.family != AF_INET6 || @@ -1362,9 +1369,21 @@ void net_if_start_dad(struct net_if *iface) continue; } - net_if_ipv6_start_dad(iface, &ipv6->unicast[i]); + sys_slist_prepend(&dad_needed, &ipv6->unicast[i].dad_need_node); + } + + net_if_unlock(iface); + + /* Start DAD for all the addresses without holding the iface lock + * to avoid any possible mutex deadlock issues. + */ + SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&dad_needed, + ifaddr, next, dad_need_node) { + net_if_ipv6_start_dad(iface, ifaddr); } + return; + out: net_if_unlock(iface); } @@ -1411,7 +1430,10 @@ void net_if_ipv6_dad_failed(struct net_if *iface, const struct in6_addr *addr) net_if_ipv6_addr_rm(iface, addr); if (IS_ENABLED(CONFIG_NET_IPV6_PE) && iface->pe_enabled) { + net_if_unlock(iface); + net_ipv6_pe_start(iface, addr, timeout, preferred_lifetime); + return; } out: @@ -1515,6 +1537,8 @@ void net_if_start_rs(struct net_if *iface) goto out; } + net_if_unlock(iface); + NET_DBG("Starting ND/RS for iface %p", iface); if (!net_ipv6_start_rs(iface)) { @@ -1530,6 +1554,7 @@ void net_if_start_rs(struct net_if *iface) } } + return; out: net_if_unlock(iface); } @@ -1907,6 +1932,7 @@ static inline void net_if_addr_init(struct net_if_addr *ifaddr, uint32_t vlifetime) { ifaddr->is_used = true; + ifaddr->is_added = true; ifaddr->is_temporary = false; ifaddr->address.family = AF_INET6; ifaddr->addr_type = addr_type; @@ -1936,6 +1962,7 @@ struct net_if_addr *net_if_ipv6_addr_add(struct net_if *iface, { struct net_if_addr *ifaddr = NULL; struct net_if_ipv6 *ipv6; + bool do_dad = false; net_if_lock(iface); @@ -1945,6 +1972,17 @@ struct net_if_addr *net_if_ipv6_addr_add(struct net_if *iface, ifaddr = ipv6_addr_find(iface, addr); if (ifaddr) { + /* Address already exists, just return it but update ref count + * if it was not updated. This could happen if the address was + * added and then removed but for example an active connection + * was still using it. In this case we must update the ref count + * so that the address is not removed if the connection is closed. + */ + if (!ifaddr->is_added) { + atomic_inc(&ifaddr->atomic_ref); + ifaddr->is_added = true; + } + goto out; } @@ -1976,8 +2014,7 @@ struct net_if_addr *net_if_ipv6_addr_add(struct net_if *iface, */ join_mcast_nodes(iface, &ipv6->unicast[i].address.in6_addr); - - net_if_ipv6_start_dad(iface, &ipv6->unicast[i]); + do_dad = true; } else { /* If DAD is not done for point-to-point links, then * the address is usable immediately. @@ -1991,9 +2028,17 @@ struct net_if_addr *net_if_ipv6_addr_add(struct net_if *iface, sizeof(struct in6_addr)); ifaddr = &ipv6->unicast[i]; - goto out; + break; } + net_if_unlock(iface); + + if (ifaddr != NULL && do_dad) { + net_if_ipv6_start_dad(iface, ifaddr); + } + + return ifaddr; + out: net_if_unlock(iface); @@ -2002,6 +2047,7 @@ struct net_if_addr *net_if_ipv6_addr_add(struct net_if *iface, bool net_if_ipv6_addr_rm(struct net_if *iface, const struct in6_addr *addr) { + struct net_if_addr *ifaddr; struct net_if_ipv6 *ipv6; bool result = true; int ret; @@ -2016,11 +2062,12 @@ bool net_if_ipv6_addr_rm(struct net_if *iface, const struct in6_addr *addr) goto out; } - ret = net_if_addr_unref(iface, AF_INET6, addr); + ret = net_if_addr_unref(iface, AF_INET6, addr, &ifaddr); if (ret > 0) { NET_DBG("Address %s still in use (ref %d)", net_sprint_ipv6_addr(addr), ret); result = false; + ifaddr->is_added = false; goto out; } else if (ret < 0) { NET_DBG("Address %s not found (%d)", @@ -4161,7 +4208,9 @@ void net_if_ipv4_start_acd(struct net_if *iface, struct net_if_addr *ifaddr) void net_if_start_acd(struct net_if *iface) { + struct net_if_addr *ifaddr, *next; struct net_if_ipv4 *ipv4; + sys_slist_t acd_needed; int ret; net_if_lock(iface); @@ -4183,6 +4232,11 @@ void net_if_start_acd(struct net_if *iface) ipv4->conflict_cnt = 0; + /* Start ACD for all the addresses that were added earlier when + * the interface was down. + */ + sys_slist_init(&acd_needed); + /* Start ACD for all the addresses that were added earlier when * the interface was down. */ @@ -4194,9 +4248,21 @@ void net_if_start_acd(struct net_if *iface) continue; } - net_if_ipv4_start_acd(iface, &ipv4->unicast[i].ipv4); + sys_slist_prepend(&acd_needed, &ipv4->unicast[i].ipv4.acd_need_node); + } + + net_if_unlock(iface); + + /* Start ACD for all the addresses without holding the iface lock + * to avoid any possible mutex deadlock issues. + */ + SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&acd_needed, + ifaddr, next, acd_need_node) { + net_if_ipv4_start_acd(iface, ifaddr); } + return; + out: net_if_unlock(iface); } @@ -4229,6 +4295,17 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface, ifaddr = ipv4_addr_find(iface, addr); if (ifaddr) { /* TODO: should set addr_type/vlifetime */ + /* Address already exists, just return it but update ref count + * if it was not updated. This could happen if the address was + * added and then removed but for example an active connection + * was still using it. In this case we must update the ref count + * so that the address is not removed if the connection is closed. + */ + if (!ifaddr->is_added) { + atomic_inc(&ifaddr->atomic_ref); + ifaddr->is_added = true; + } + goto out; } @@ -4251,6 +4328,7 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface, if (ifaddr) { ifaddr->is_used = true; + ifaddr->is_added = true; ifaddr->address.family = AF_INET; ifaddr->address.in_addr.s4_addr32[0] = addr->s4_addr32[0]; @@ -4276,7 +4354,8 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface, if (!(l2_flags_get(iface) & NET_L2_POINT_TO_POINT) && !net_ipv4_is_addr_loopback(addr)) { - net_if_ipv4_start_acd(iface, ifaddr); + /* ACD is started after the lock is released. */ + ; } else { ifaddr->addr_state = NET_ADDR_PREFERRED; } @@ -4284,7 +4363,12 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface, net_mgmt_event_notify_with_info(NET_EVENT_IPV4_ADDR_ADD, iface, &ifaddr->address.in_addr, sizeof(struct in_addr)); - goto out; + + net_if_unlock(iface); + + net_if_ipv4_start_acd(iface, ifaddr); + + return ifaddr; } out: @@ -4295,6 +4379,7 @@ struct net_if_addr *net_if_ipv4_addr_add(struct net_if *iface, bool net_if_ipv4_addr_rm(struct net_if *iface, const struct in_addr *addr) { + struct net_if_addr *ifaddr; struct net_if_ipv4 *ipv4; bool result = true; int ret; @@ -4309,11 +4394,12 @@ bool net_if_ipv4_addr_rm(struct net_if *iface, const struct in_addr *addr) goto out; } - ret = net_if_addr_unref(iface, AF_INET, addr); + ret = net_if_addr_unref(iface, AF_INET, addr, &ifaddr); if (ret > 0) { NET_DBG("Address %s still in use (ref %d)", net_sprint_ipv4_addr(addr), ret); result = false; + ifaddr->is_added = false; goto out; } else if (ret < 0) { NET_DBG("Address %s not found (%d)", @@ -4932,8 +5018,13 @@ static void remove_ipv6_ifaddr(struct net_if *iface, #if defined(CONFIG_NET_IPV6_DAD) if (!net_if_flag_is_set(iface, NET_IF_IPV6_NO_ND)) { k_mutex_lock(&lock, K_FOREVER); - sys_slist_find_and_remove(&active_dad_timers, - &ifaddr->dad_node); + if (sys_slist_find_and_remove(&active_dad_timers, + &ifaddr->dad_node)) { + /* Addreess with active DAD timer would still have + * stale entry in the neighbor cache. + */ + net_ipv6_nbr_rm(iface, &ifaddr->address.in6_addr); + } k_mutex_unlock(&lock); } #endif @@ -5048,11 +5139,13 @@ struct net_if_addr *net_if_addr_ref(struct net_if *iface, int net_if_addr_unref_debug(struct net_if *iface, sa_family_t family, const void *addr, + struct net_if_addr **ret_ifaddr, const char *caller, int line) #else int net_if_addr_unref(struct net_if *iface, sa_family_t family, - const void *addr) + const void *addr, + struct net_if_addr **ret_ifaddr) #endif /* NET_LOG_LEVEL >= LOG_LEVEL_DBG */ { struct net_if_addr *ifaddr; @@ -5106,6 +5199,10 @@ int net_if_addr_unref(struct net_if *iface, #endif if (ref > 1) { + if (ret_ifaddr) { + *ret_ifaddr = ifaddr; + } + return ref - 1; } diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index b7dd20d3ffdf8..136cf41cb441a 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -783,7 +783,8 @@ static void tcp_conn_release(struct k_work *work) net_if_addr_unref(conn->iface, conn->src.sa.sa_family, conn->src.sa.sa_family == AF_INET ? (const void *)&conn->src.sin.sin_addr : - (const void *)&conn->src.sin6.sin6_addr); + (const void *)&conn->src.sin6.sin6_addr, + NULL); } conn->context->tcp = NULL; diff --git a/subsys/net/l2/ethernet/bridge.c b/subsys/net/l2/ethernet/bridge.c index d497acc683397..4b883643c3a3f 100644 --- a/subsys/net/l2/ethernet/bridge.c +++ b/subsys/net/l2/ethernet/bridge.c @@ -345,7 +345,7 @@ static enum net_verdict bridge_iface_process(struct net_if *iface, /* Drop all link-local packets for now. */ if (is_link_local_addr((struct net_eth_addr *)net_pkt_lladdr_dst(pkt))) { NET_DBG("DROP: lladdr"); - return NET_DROP; + goto out; } lock_bridge(ctx); @@ -372,6 +372,11 @@ static enum net_verdict bridge_iface_process(struct net_if *iface, */ if (count > 2) { send_pkt = net_pkt_clone(pkt, K_NO_WAIT); + if (send_pkt == NULL) { + NET_DBG("DROP: clone failed"); + break; + } + net_pkt_ref(send_pkt); } else { send_pkt = net_pkt_ref(pkt); @@ -392,11 +397,11 @@ static enum net_verdict bridge_iface_process(struct net_if *iface, unlock_bridge(ctx); +out: /* The packet was cloned by the caller so remove it here. */ net_pkt_unref(pkt); return NET_OK; - } int bridge_iface_send(struct net_if *iface, struct net_pkt *pkt) diff --git a/subsys/net/lib/dns/dispatcher.c b/subsys/net/lib/dns/dispatcher.c index 6b81dbc37b096..c0803f093bd44 100644 --- a/subsys/net/lib/dns/dispatcher.c +++ b/subsys/net/lib/dns/dispatcher.c @@ -334,6 +334,11 @@ int dns_dispatcher_unregister(struct dns_socket_dispatcher *ctx) (void)sys_slist_find_and_remove(&sockets, &ctx->node); + (void)net_socket_service_unregister(ctx->svc); + + /* Mark the context as unregistered */ + ctx->sock = -1; + for (int i = 0; i < ctx->fds_len; i++) { CHECKIF((int)ctx->fds[i].fd >= (int)ARRAY_SIZE(dispatch_table)) { ret = -ERANGE; diff --git a/subsys/net/lib/dns/dns_pack.c b/subsys/net/lib/dns/dns_pack.c index 34b3651a4f072..3607514abf399 100644 --- a/subsys/net/lib/dns/dns_pack.c +++ b/subsys/net/lib/dns/dns_pack.c @@ -134,7 +134,7 @@ int dns_unpack_answer(struct dns_msg_t *dns_msg, int dname_ptr, uint32_t *ttl, * * See RFC-1035 4.1.3. Resource record format */ - rem_size = dns_msg->msg_size - dname_len; + rem_size = dns_msg->msg_size - dns_msg->answer_offset - dname_len; if (rem_size < 2 + 2 + 4 + 2) { return -EINVAL; } @@ -394,7 +394,7 @@ int dns_copy_qname(uint8_t *buf, uint16_t *len, uint16_t size, /* validate that the label (i.e. size + elements), * fits the current msg buffer */ - if (DNS_LABEL_LEN_SIZE + lb_size > size - *len) { + if (DNS_LABEL_LEN_SIZE + lb_size > MIN(size - *len, msg_size - pos)) { rc = -ENOMEM; break; } diff --git a/subsys/net/lib/dns/resolve.c b/subsys/net/lib/dns/resolve.c index ff17b6b6257fe..cf5416549b5fb 100644 --- a/subsys/net/lib/dns/resolve.c +++ b/subsys/net/lib/dns/resolve.c @@ -477,7 +477,12 @@ static int dns_resolve_init_locked(struct dns_resolve_context *ctx, ret = register_dispatcher(ctx, &resolve_svc, &ctx->servers[i], local_addr, addr6, addr4); if (ret < 0) { - NET_DBG("Cannot register dispatcher for %s (%d)", "mDNS", ret); + if (ret == -EALREADY) { + goto skip_event; + } + + NET_DBG("Cannot register dispatcher for %s (%d)", + ctx->servers[i].is_mdns ? "mDNS" : "DNS", ret); goto fail; } @@ -490,6 +495,8 @@ static int dns_resolve_init_locked(struct dns_resolve_context *ctx, net_mgmt_event_notify(NET_EVENT_DNS_SERVER_ADD, iface); } +skip_event: + #if defined(CONFIG_NET_IPV6) local_addr6.sin6_port = 0; #endif @@ -705,6 +712,11 @@ int dns_validate_msg(struct dns_resolve_context *ctx, ret = dns_unpack_response_query(dns_msg); if (ret < 0) { + if (ret == -ENOMEM) { + ret = DNS_EAI_FAIL; + goto quit; + } + /* Check mDNS like above */ if (*dns_id > 0) { ret = DNS_EAI_FAIL; diff --git a/subsys/net/lib/http/Kconfig b/subsys/net/lib/http/Kconfig index 98d8f72f0ded7..cecc4e6ac9d6d 100644 --- a/subsys/net/lib/http/Kconfig +++ b/subsys/net/lib/http/Kconfig @@ -163,7 +163,8 @@ config HTTP_SERVER_WEBSOCKET config HTTP_SERVER_RESOURCE_WILDCARD bool "Allow wildcard matching of resources" - select FNMATCH + # The POSIX_C_LIB_EXT will get fnmatch() support + select POSIX_C_LIB_EXT help Allow user to specify wildcards when setting up resource strings. This means that instead of specifying multiple resources with exact diff --git a/subsys/net/lib/http/http_server_core.c b/subsys/net/lib/http/http_server_core.c index 9b41d76d98339..dff004f8e0686 100644 --- a/subsys/net/lib/http/http_server_core.c +++ b/subsys/net/lib/http/http_server_core.c @@ -678,6 +678,17 @@ static int compare_strings(const char *s1, const char *s2) return 1; /* Strings are not equal */ } +static int path_len_without_query(const char *path) +{ + int len = 0; + + while ((path[len] != '\0') && (path[len] != '?')) { + len++; + } + + return len; +} + static bool skip_this(struct http_resource_desc *resource, bool is_websocket) { struct http_resource_detail *detail; @@ -713,7 +724,7 @@ struct http_resource_detail *get_resource_detail(const char *path, ret = fnmatch(resource->resource, path, (FNM_PATHNAME | FNM_LEADING_DIR)); if (ret == 0) { - *path_len = strlen(resource->resource); + *path_len = path_len_without_query(path); return resource->detail; } } diff --git a/subsys/net/lib/lwm2m/lwm2m_registry.c b/subsys/net/lib/lwm2m/lwm2m_registry.c index 14635277d2ce6..be7b49212eebc 100644 --- a/subsys/net/lib/lwm2m/lwm2m_registry.c +++ b/subsys/net/lib/lwm2m/lwm2m_registry.c @@ -648,6 +648,7 @@ static int lwm2m_engine_set(const struct lwm2m_obj_path *path, const void *value if (!lwm2m_validate_time_resource_lenghts(max_data_len, len)) { LOG_ERR("Time Set: buffer length %u max data len %zu not supported", len, max_data_len); + k_mutex_unlock(®istry_lock); return -EINVAL; } @@ -924,6 +925,7 @@ static int lwm2m_engine_get(const struct lwm2m_obj_path *path, void *buf, uint16 if (!lwm2m_validate_time_resource_lenghts(data_len, buflen)) { LOG_ERR("Time get buffer length %u data len %zu not supported", buflen, data_len); + k_mutex_unlock(®istry_lock); return -EINVAL; } diff --git a/subsys/net/lib/sockets/sockets_inet.c b/subsys/net/lib/sockets/sockets_inet.c index acb9d470a5ea9..7bc4019c225f3 100644 --- a/subsys/net/lib/sockets/sockets_inet.c +++ b/subsys/net/lib/sockets/sockets_inet.c @@ -63,6 +63,11 @@ static void zsock_flush_queue(struct net_context *ctx) while ((p = k_fifo_get(&ctx->recv_q, K_NO_WAIT)) != NULL) { if (is_listen) { NET_DBG("discarding ctx %p", p); + + /* Note that we must release all the packets we + * might have received to the accepted socket. + */ + zsock_flush_queue(p); net_context_put(p); } else { NET_DBG("discarding pkt %p", p); diff --git a/subsys/net/lib/wifi_credentials/wifi_credentials.c b/subsys/net/lib/wifi_credentials/wifi_credentials.c index acc31767b8938..a91ea8dd5428a 100644 --- a/subsys/net/lib/wifi_credentials/wifi_credentials.c +++ b/subsys/net/lib/wifi_credentials/wifi_credentials.c @@ -104,33 +104,31 @@ void wifi_credentials_uncache_ssid(size_t idx) int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_len, struct wifi_credentials_personal *buf) { + ssize_t idx; int ret; if (ssid == NULL || ssid_len > WIFI_SSID_MAX_LEN || ssid_len == 0) { - LOG_ERR("Cannot retrieve WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "retrieve", "SSID has invalid format"); return -EINVAL; } if (buf == NULL) { - LOG_ERR("Cannot retrieve WiFi credentials, " - "destination struct pointer cannot be NULL"); + LOG_ERR("Cannot %s WiFi credentials, %s", "retrieve", "destination is NULL"); return -EINVAL; } k_mutex_lock(&wifi_credentials_mutex, K_FOREVER); - ssize_t idx = lookup_idx(ssid, ssid_len); - + idx = lookup_idx(ssid, ssid_len); if (idx == -1) { - LOG_DBG("Cannot retrieve WiFi credentials, no entry found for the provided SSID"); + LOG_DBG("Cannot %s WiFi credentials, %s", "retrieve", "SSID not found"); ret = -ENOENT; goto exit; } ret = wifi_credentials_load_entry(idx, buf, sizeof(struct wifi_credentials_personal)); - if (ret) { - LOG_ERR("Failed to load WiFi credentials at index %d, err: %d", idx, ret); + LOG_ERR("Failed to %s WiFi credentials at index %d, err: %d", "load", idx, ret); goto exit; } @@ -152,35 +150,34 @@ int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_l int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal *creds) { + ssize_t idx; int ret; - if (creds->header.ssid_len > WIFI_SSID_MAX_LEN || creds->header.ssid_len == 0) { - LOG_ERR("Cannot set WiFi credentials, SSID has invalid format"); + if (creds == NULL) { + LOG_ERR("Cannot %s WiFi credentials, %s", "set", "credential not set"); return -EINVAL; } - if (creds == NULL) { - LOG_ERR("Cannot set WiFi credentials, provided struct pointer cannot be NULL"); + if (creds->header.ssid_len > WIFI_SSID_MAX_LEN || creds->header.ssid_len == 0) { + LOG_ERR("Cannot %s WiFi credentials, %s", "set", "SSID has invalid format"); return -EINVAL; } k_mutex_lock(&wifi_credentials_mutex, K_FOREVER); - ssize_t idx = lookup_idx(creds->header.ssid, creds->header.ssid_len); - + idx = lookup_idx(creds->header.ssid, creds->header.ssid_len); if (idx == -1) { idx = lookup_unused_idx(); if (idx == -1) { - LOG_ERR("Cannot store WiFi credentials, no space left"); + LOG_ERR("Cannot %s WiFi credentials, %s", "store", "no space left"); ret = -ENOBUFS; goto exit; } } ret = wifi_credentials_store_entry(idx, creds, sizeof(struct wifi_credentials_personal)); - if (ret) { - LOG_ERR("Failed to store WiFi credentials at index %d, err: %d", idx, ret); + LOG_ERR("Failed to %s WiFi credentials at index %d, err: %d", "store", idx, ret); goto exit; } @@ -199,27 +196,29 @@ int wifi_credentials_set_personal(const char *ssid, size_t ssid_len, enum wifi_s { int ret = 0; uint8_t buf[ENTRY_MAX_LEN] = {0}; + struct wifi_credentials_header *header; if (ssid == NULL || ssid_len > WIFI_SSID_MAX_LEN || ssid_len == 0) { - LOG_ERR("Cannot set WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", "SSID has invalid format"); return -EINVAL; } if (flags & WIFI_CREDENTIALS_FLAG_BSSID && (bssid_len != WIFI_MAC_ADDR_LEN || bssid == NULL)) { - LOG_ERR("Cannot set WiFi credentials, " - "provided flags indicated BSSID, but no BSSID provided"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", + "provided flags indicated BSSID but no BSSID provided"); return -EINVAL; } if ((type != WIFI_SECURITY_TYPE_NONE && (password_len == 0 || password == NULL)) || (password_len > WIFI_CREDENTIALS_MAX_PASSWORD_LEN)) { - LOG_ERR("Cannot set WiFi credentials, password not provided or invalid"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", + "password not provided or invalid"); return -EINVAL; } /* pack entry */ - struct wifi_credentials_header *header = (struct wifi_credentials_header *)buf; + header = (struct wifi_credentials_header *)buf; header->type = type; memcpy(header->ssid, ssid, ssid_len); @@ -247,9 +246,8 @@ int wifi_credentials_set_personal(const char *ssid, size_t ssid_len, enum wifi_s break; } default: - LOG_ERR("Cannot set WiFi credentials, " - "provided security type %d is unsupported", - type); + LOG_ERR("Cannot %s WiFi credentials, provided security type %d is unsupported", + "set", type); return -ENOTSUP; } @@ -267,20 +265,21 @@ int wifi_credentials_get_by_ssid_personal(const char *ssid, size_t ssid_len, { int ret = 0; uint8_t buf[ENTRY_MAX_LEN] = {0}; + struct wifi_credentials_header *header; if (ssid == NULL || ssid_len > WIFI_SSID_MAX_LEN || ssid_len == 0) { - LOG_ERR("Cannot retrieve WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "retrieve", "SSID has invalid format"); return -EINVAL; } if (bssid_buf_len != WIFI_MAC_ADDR_LEN || bssid_buf == NULL) { - LOG_ERR("BSSID buffer needs to be provided"); + LOG_ERR("%s buffer needs to be provided", "BSSID"); return -EINVAL; } if (password_buf == NULL || password_buf_len > WIFI_CREDENTIALS_MAX_PASSWORD_LEN || password_buf_len == 0) { - LOG_ERR("WiFi password buffer needs to be provided"); + LOG_ERR("%s buffer needs to be provided", "WiFi password"); return -EINVAL; } @@ -292,7 +291,7 @@ int wifi_credentials_get_by_ssid_personal(const char *ssid, size_t ssid_len, } /* unpack entry*/ - struct wifi_credentials_header *header = (struct wifi_credentials_header *)buf; + header = (struct wifi_credentials_header *)buf; *type = header->type; *flags = header->flags; @@ -318,7 +317,7 @@ int wifi_credentials_get_by_ssid_personal(const char *ssid, size_t ssid_len, break; } default: - LOG_ERR("Cannot get WiFi credentials, " + LOG_ERR("Cannot %s WiFi credentials, %s", "get", "the requested credentials have invalid WIFI_SECURITY_TYPE"); ret = -EPROTO; } @@ -327,25 +326,25 @@ int wifi_credentials_get_by_ssid_personal(const char *ssid, size_t ssid_len, int wifi_credentials_delete_by_ssid(const char *ssid, size_t ssid_len) { + ssize_t idx; int ret = 0; if (ssid == NULL || ssid_len > WIFI_SSID_MAX_LEN || ssid_len == 0) { - LOG_ERR("Cannot delete WiFi credentials, SSID has invalid format"); + LOG_ERR("Cannot %s WiFi credentials, %s", "delete", "SSID has invalid format"); return -EINVAL; } k_mutex_lock(&wifi_credentials_mutex, K_FOREVER); - ssize_t idx = lookup_idx(ssid, ssid_len); + idx = lookup_idx(ssid, ssid_len); if (idx == -1) { LOG_DBG("WiFi credentials entry was not found"); goto exit; } ret = wifi_credentials_delete_entry(idx); - if (ret) { - LOG_ERR("Failed to delete WiFi credentials index %d, err: %d", idx, ret); + LOG_ERR("Failed to %s WiFi credentials index %d, err: %d", "delete", idx, ret); goto exit; } @@ -393,8 +392,8 @@ int wifi_credentials_delete_all(void) if (is_entry_used(i)) { ret = wifi_credentials_delete_entry(i); if (ret) { - LOG_ERR("Failed to delete WiFi credentials index %d, err: %d", i, - ret); + LOG_ERR("Failed to %s WiFi credentials index %d, err: %d", + "delete", i, ret); break; } diff --git a/subsys/rtio/Kconfig.workq b/subsys/rtio/Kconfig.workq index af85220415692..ad8dcd8ffdf7e 100644 --- a/subsys/rtio/Kconfig.workq +++ b/subsys/rtio/Kconfig.workq @@ -4,6 +4,7 @@ config RTIO_WORKQ bool "RTIO Work-queues service to process Sync operations" select SCHED_DEADLINE + select P4WQ_INIT_STAGE_EARLY select RTIO_CONSUME_SEM help Enable RTIO Work-queues to allow processing synchronous operations diff --git a/subsys/rtio/rtio_workq.c b/subsys/rtio/rtio_workq.c index b063ead71a420..f04acb46525c7 100644 --- a/subsys/rtio/rtio_workq.c +++ b/subsys/rtio/rtio_workq.c @@ -11,15 +11,24 @@ #define RTIO_WORKQ_PRIO_HIGH RTIO_WORKQ_PRIO_MED - 1 #define RTIO_WORKQ_PRIO_LOW RTIO_WORKQ_PRIO_MED + 1 -K_P4WQ_DEFINE(rtio_workq, - CONFIG_RTIO_WORKQ_THREADS_POOL, - CONFIG_RTIO_WORKQ_STACK_SIZE); - K_MEM_SLAB_DEFINE_STATIC(rtio_work_items_slab, sizeof(struct rtio_work_req), CONFIG_RTIO_WORKQ_POOL_ITEMS, 4); +static void rtio_work_req_done_handler(struct k_p4wq_work *work) +{ + struct rtio_work_req *req = CONTAINER_OF(work, + struct rtio_work_req, + work); + k_mem_slab_free(&rtio_work_items_slab, req); +} + +K_P4WQ_DEFINE_WITH_DONE_HANDLER(rtio_workq, + CONFIG_RTIO_WORKQ_THREADS_POOL, + CONFIG_RTIO_WORKQ_STACK_SIZE, + rtio_work_req_done_handler); + static void rtio_work_handler(struct k_p4wq_work *work) { struct rtio_work_req *req = CONTAINER_OF(work, @@ -28,8 +37,6 @@ static void rtio_work_handler(struct k_p4wq_work *work) struct rtio_iodev_sqe *iodev_sqe = req->iodev_sqe; req->handler(iodev_sqe); - - k_mem_slab_free(&rtio_work_items_slab, req); } struct rtio_work_req *rtio_work_req_alloc(void) diff --git a/subsys/shell/Kconfig b/subsys/shell/Kconfig index 696d070a7e46d..9d1b807c8ba47 100644 --- a/subsys/shell/Kconfig +++ b/subsys/shell/Kconfig @@ -89,6 +89,13 @@ config SHELL_PRINTF_BUFF_SIZE It is working like stdio buffering in Linux systems to limit number of peripheral access calls. +config SHELL_PRINTF_AUTOFLUSH + bool "Indicate if the buffer should be automatically flushed" + default y + help + Specify whether the shell's printing functions should automatically + flush the printf buffer. + config SHELL_DEFAULT_TERMINAL_WIDTH int "Default terminal width" range 1 $(UINT16_MAX) diff --git a/subsys/shell/modules/devmem_service.c b/subsys/shell/modules/devmem_service.c index c2c37215d3a36..7856ab8f86203 100644 --- a/subsys/shell/modules/devmem_service.c +++ b/subsys/shell/modules/devmem_service.c @@ -247,8 +247,8 @@ static int cmd_load(const struct shell *sh, size_t argc, char **argv) argc--; } - bytes = (unsigned char *)strtol(argv[1], NULL, 0); - data = (uint32_t *)strtol(argv[1], NULL, 0); + bytes = (unsigned char *)strtoul(argv[1], NULL, 0); + data = (uint32_t *)strtoul(argv[1], NULL, 0); set_bypass(sh, bypass_cb); return 0; diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 0032fed7f7890..8ce5f9c3afb8e 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -31,6 +31,7 @@ "WARNING: A print request was detected on not active shell backend.\n" #define SHELL_MSG_TOO_MANY_ARGS "Too many arguments in the command.\n" #define SHELL_INIT_OPTION_PRINTER (NULL) +#define SHELL_TX_MTX_TIMEOUT_MS 50 #define SHELL_THREAD_PRIORITY \ COND_CODE_1(CONFIG_SHELL_THREAD_PRIORITY_OVERRIDE, \ @@ -1350,7 +1351,9 @@ void shell_thread(void *shell_handle, void *arg_log_backend, K_FOREVER); if (err != 0) { - k_mutex_lock(&sh->ctx->wr_mtx, K_FOREVER); + if (k_mutex_lock(&sh->ctx->wr_mtx, K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)) != 0) { + return; + } z_shell_fprintf(sh, SHELL_ERROR, "Shell thread error: %d", err); k_mutex_unlock(&sh->ctx->wr_mtx); @@ -1441,7 +1444,9 @@ int shell_start(const struct shell *sh) z_shell_log_backend_enable(sh->log_backend, (void *)sh, sh->ctx->log_level); } - k_mutex_lock(&sh->ctx->wr_mtx, K_FOREVER); + if (k_mutex_lock(&sh->ctx->wr_mtx, K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)) != 0) { + return -EBUSY; + } if (IS_ENABLED(CONFIG_SHELL_VT100_COLORS)) { z_shell_vt100_color_set(sh, SHELL_NORMAL); @@ -1543,7 +1548,10 @@ void shell_vfprintf(const struct shell *sh, enum shell_vt100_color color, return; } - k_mutex_lock(&sh->ctx->wr_mtx, K_FOREVER); + if (k_mutex_lock(&sh->ctx->wr_mtx, K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)) != 0) { + return; + } + if (!z_flag_cmd_ctx_get(sh) && !sh->ctx->bypass && z_flag_use_vt100_get(sh)) { z_shell_cmd_line_erase(sh); } @@ -1552,6 +1560,7 @@ void shell_vfprintf(const struct shell *sh, enum shell_vt100_color color, z_shell_print_prompt_and_cmd(sh); } z_transport_buffer_flush(sh); + k_mutex_unlock(&sh->ctx->wr_mtx); } @@ -1677,10 +1686,9 @@ int shell_prompt_change(const struct shell *sh, const char *prompt) return -EINVAL; } - static const size_t mtx_timeout_ms = 20; size_t prompt_length = z_shell_strlen(prompt); - if (k_mutex_lock(&sh->ctx->wr_mtx, K_MSEC(mtx_timeout_ms))) { + if (k_mutex_lock(&sh->ctx->wr_mtx, K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)) != 0) { return -EBUSY; } @@ -1703,7 +1711,9 @@ int shell_prompt_change(const struct shell *sh, const char *prompt) void shell_help(const struct shell *sh) { - k_mutex_lock(&sh->ctx->wr_mtx, K_FOREVER); + if (k_mutex_lock(&sh->ctx->wr_mtx, K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)) != 0) { + return; + } shell_internal_help_print(sh); k_mutex_unlock(&sh->ctx->wr_mtx); } @@ -1736,7 +1746,9 @@ int shell_execute_cmd(const struct shell *sh, const char *cmd) sh->ctx->cmd_buff_len = cmd_len; sh->ctx->cmd_buff_pos = cmd_len; - k_mutex_lock(&sh->ctx->wr_mtx, K_FOREVER); + if (k_mutex_lock(&sh->ctx->wr_mtx, K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)) != 0) { + return -ENOEXEC; + } ret_val = execute(sh); k_mutex_unlock(&sh->ctx->wr_mtx); diff --git a/tests/arch/arm/arm_irq_advanced_features/boards/cy8cproto_062_4343w.overlay b/tests/arch/arm/arm_irq_advanced_features/boards/cy8cproto_062_4343w.overlay new file mode 100644 index 0000000000000..bd164a6bf2885 --- /dev/null +++ b/tests/arch/arm/arm_irq_advanced_features/boards/cy8cproto_062_4343w.overlay @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Cypress Semiconductor Corporation. + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Changed default interrupts priority for GPIO to 4 */ +&gpio_prt0 { + interrupts = <0 4>; +}; + +&gpio_prt2 { + interrupts = <2 4>; +}; + +&gpio_prt3 { + interrupts = <3 4>; +}; + +&gpio_prt5 { + interrupts = <5 4>; +}; + +&gpio_prt6 { + interrupts = <6 4>; +}; + +&gpio_prt9 { + interrupts = <9 4>; +}; + +&gpio_prt12 { + interrupts = <12 4>; +}; + +&gpio_prt13 { + interrupts = <13 4>; +}; diff --git a/tests/arch/arm/arm_irq_advanced_features/boards/cy8cproto_063_ble.overlay b/tests/arch/arm/arm_irq_advanced_features/boards/cy8cproto_063_ble.overlay new file mode 100644 index 0000000000000..155992e9cc52f --- /dev/null +++ b/tests/arch/arm/arm_irq_advanced_features/boards/cy8cproto_063_ble.overlay @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Cypress Semiconductor Corporation. + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Changed default interrupts priority for GPIO to 4 */ +&gpio_prt0 { + interrupts = <0 4>; +}; + +&gpio_prt5 { + interrupts = <5 4>; +}; + +&gpio_prt6 { + interrupts = <6 4>; +}; + +&gpio_prt7 { + interrupts = <7 4>; +}; + +&gpio_prt9 { + interrupts = <9 4>; +}; + +&gpio_prt10 { + interrupts = <10 4>; +}; + +&gpio_prt12 { + interrupts = <12 4>; +}; diff --git a/tests/arch/arm/arm_irq_advanced_features/boards/cyw920829m2evk_02.overlay b/tests/arch/arm/arm_irq_advanced_features/boards/cyw920829m2evk_02.overlay new file mode 100644 index 0000000000000..6ddd801888659 --- /dev/null +++ b/tests/arch/arm/arm_irq_advanced_features/boards/cyw920829m2evk_02.overlay @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Cypress Semiconductor Corporation. + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Changed default interrupts priority for GPIO to 4 */ +&gpio_prt0 { + interrupts = <0 4>; +}; + +&gpio_prt1 { + interrupts = <1 4>; +}; + +&gpio_prt3 { + interrupts = <3 4>; +}; + +&gpio_prt5 { + interrupts = <5 4>; +}; diff --git a/tests/arch/arm/arm_irq_zero_latency_levels/boards/cy8cproto_062_4343w.overlay b/tests/arch/arm/arm_irq_zero_latency_levels/boards/cy8cproto_062_4343w.overlay new file mode 100644 index 0000000000000..bd164a6bf2885 --- /dev/null +++ b/tests/arch/arm/arm_irq_zero_latency_levels/boards/cy8cproto_062_4343w.overlay @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Cypress Semiconductor Corporation. + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Changed default interrupts priority for GPIO to 4 */ +&gpio_prt0 { + interrupts = <0 4>; +}; + +&gpio_prt2 { + interrupts = <2 4>; +}; + +&gpio_prt3 { + interrupts = <3 4>; +}; + +&gpio_prt5 { + interrupts = <5 4>; +}; + +&gpio_prt6 { + interrupts = <6 4>; +}; + +&gpio_prt9 { + interrupts = <9 4>; +}; + +&gpio_prt12 { + interrupts = <12 4>; +}; + +&gpio_prt13 { + interrupts = <13 4>; +}; diff --git a/tests/arch/arm/arm_irq_zero_latency_levels/boards/cy8cproto_063_ble.overlay b/tests/arch/arm/arm_irq_zero_latency_levels/boards/cy8cproto_063_ble.overlay new file mode 100644 index 0000000000000..155992e9cc52f --- /dev/null +++ b/tests/arch/arm/arm_irq_zero_latency_levels/boards/cy8cproto_063_ble.overlay @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Cypress Semiconductor Corporation. + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Changed default interrupts priority for GPIO to 4 */ +&gpio_prt0 { + interrupts = <0 4>; +}; + +&gpio_prt5 { + interrupts = <5 4>; +}; + +&gpio_prt6 { + interrupts = <6 4>; +}; + +&gpio_prt7 { + interrupts = <7 4>; +}; + +&gpio_prt9 { + interrupts = <9 4>; +}; + +&gpio_prt10 { + interrupts = <10 4>; +}; + +&gpio_prt12 { + interrupts = <12 4>; +}; diff --git a/tests/arch/arm/arm_irq_zero_latency_levels/boards/cyw920829m2evk_02.overlay b/tests/arch/arm/arm_irq_zero_latency_levels/boards/cyw920829m2evk_02.overlay new file mode 100644 index 0000000000000..6ddd801888659 --- /dev/null +++ b/tests/arch/arm/arm_irq_zero_latency_levels/boards/cyw920829m2evk_02.overlay @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Cypress Semiconductor Corporation. + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Changed default interrupts priority for GPIO to 4 */ +&gpio_prt0 { + interrupts = <0 4>; +}; + +&gpio_prt1 { + interrupts = <1 4>; +}; + +&gpio_prt3 { + interrupts = <3 4>; +}; + +&gpio_prt5 { + interrupts = <5 4>; +}; diff --git a/tests/cmake/zephyr_get/CMakeLists.txt b/tests/cmake/zephyr_get/CMakeLists.txt index a6516bfba735c..43c2e204ec257 100644 --- a/tests/cmake/zephyr_get/CMakeLists.txt +++ b/tests/cmake/zephyr_get/CMakeLists.txt @@ -2,9 +2,17 @@ cmake_minimum_required(VERSION 3.20.0) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(zephyr_get_test) -target_sources(app PRIVATE ${ZEPHYR_BASE}/misc/empty_file.c) +if(CMAKE_SCRIPT_MODE_FILE) + # Script mode initialization (re-run) + set(ZEPHYR_BASE ${CMAKE_CURRENT_LIST_DIR}/../../../) + list(APPEND CMAKE_MODULE_PATH "${ZEPHYR_BASE}/cmake/modules") + include(extensions) +else() + # Project mode initialization (main CMake invocation) + find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + project(zephyr_get_test) + target_sources(app PRIVATE ${ZEPHYR_BASE}/misc/empty_file.c) +endif() if(SYSBUILD) get_property(IMAGE_NAME TARGET sysbuild_cache PROPERTY SYSBUILD_NAME) @@ -73,6 +81,9 @@ function(assert_equal variable expected_value) endif() set(info "${TEST_NAME}: ${variable} == '${actual_value}'") + if(CMAKE_SCRIPT_MODE_FILE) + string(PREPEND info "script mode ") + endif() if("${actual_value}" STREQUAL "${expected_value}") message("PASS: ${info}") else() @@ -490,7 +501,8 @@ endfunction() function(test_snippets_scope) - if(NOT TARGET snippets_scope) + zephyr_scope_exists(snippets_defined snippets) + if(NOT snippets_defined) zephyr_create_scope(snippets) endif() @@ -583,3 +595,8 @@ run_suite( test_merge_reverse test_snippets_scope ) + +if (NOT CMAKE_SCRIPT_MODE_FILE AND NOT SYSBUILD) + # Re-run this testsuite in plain script mode + execute_process(COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_FILE}) +endif() diff --git a/tests/drivers/build_all/sensor/src/generic_test.c b/tests/drivers/build_all/sensor/src/generic_test.c index b8500b4006d56..841b5142ac7fc 100644 --- a/tests/drivers/build_all/sensor/src/generic_test.c +++ b/tests/drivers/build_all/sensor/src/generic_test.c @@ -217,33 +217,8 @@ static void run_generic_test(const struct device *dev) q31_t q; int8_t shift; - switch (ch) { - /* Special handling to break out triplet samples. */ - case SENSOR_CHAN_MAGN_X: - case SENSOR_CHAN_ACCEL_X: - case SENSOR_CHAN_GYRO_X: - q = decoded_data.three_axis.readings[0].x; - shift = decoded_data.three_axis.shift; - break; - case SENSOR_CHAN_MAGN_Y: - case SENSOR_CHAN_ACCEL_Y: - case SENSOR_CHAN_GYRO_Y: - q = decoded_data.three_axis.readings[0].y; - shift = decoded_data.three_axis.shift; - break; - case SENSOR_CHAN_MAGN_Z: - case SENSOR_CHAN_ACCEL_Z: - case SENSOR_CHAN_GYRO_Z: - q = decoded_data.three_axis.readings[0].z; - shift = decoded_data.three_axis.shift; - break; - - /* Default case for single Q31 samples */ - default: - q = decoded_data.q31.readings[0].value; - shift = decoded_data.q31.shift; - break; - } + q = decoded_data.q31.readings[0].value; + shift = decoded_data.q31.shift; /* Align everything to be a 64-bit Q32.32 number for comparison */ int64_t expected_shifted = diff --git a/tests/drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21.conf b/tests/drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21.conf new file mode 100644 index 0000000000000..10768b5fc1280 --- /dev/null +++ b/tests/drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21.conf @@ -0,0 +1,3 @@ +CONFIG_RTC_ALARM=y +CONFIG_RTC_UPDATE=y +CONFIG_RTC_CALIBRATION=y diff --git a/tests/drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21b.conf b/tests/drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21b.conf new file mode 100644 index 0000000000000..10768b5fc1280 --- /dev/null +++ b/tests/drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21b.conf @@ -0,0 +1,3 @@ +CONFIG_RTC_ALARM=y +CONFIG_RTC_UPDATE=y +CONFIG_RTC_CALIBRATION=y diff --git a/tests/drivers/virtualization/ivshmem/plain/boards/qemu_kvm_arm64.overlay b/tests/drivers/virtualization/ivshmem/plain/boards/qemu_kvm_arm64.overlay index 46b906a70c33a..ff491f1170680 100644 --- a/tests/drivers/virtualization/ivshmem/plain/boards/qemu_kvm_arm64.overlay +++ b/tests/drivers/virtualization/ivshmem/plain/boards/qemu_kvm_arm64.overlay @@ -2,6 +2,6 @@ * Copyright (c) 2021 Intel Corporation * Copyright (c) 2022 Huawei France Technologies SASU * - * SPDX-License-Identifier: Apache-2.0 and UNLICENSED + * SPDX-License-Identifier: Apache-2.0 */ #include "pcie_ivshmem.dtsi" diff --git a/tests/net/conn_mgr_conn/src/test_ifaces.c b/tests/net/conn_mgr_conn/src/test_ifaces.c index 535eee07de80c..bd21197160a50 100644 --- a/tests/net/conn_mgr_conn/src/test_ifaces.c +++ b/tests/net/conn_mgr_conn/src/test_ifaces.c @@ -16,7 +16,7 @@ static void test_iface_init(struct net_if *iface) { /* Fake link layer address is needed to silence assertions inside the net core */ - static uint8_t fake_lladdr[] = { 0x01 }; + static uint8_t fake_lladdr[] = { 0x00, 0x00, 0x5E, 0x00, 0x53, 0x01 }; net_if_set_link_addr(iface, fake_lladdr, sizeof(fake_lladdr), NET_LINK_DUMMY); diff --git a/tests/net/conn_mgr_monitor/src/test_ifaces.c b/tests/net/conn_mgr_monitor/src/test_ifaces.c index 1b7a5080ec1f4..05eda78dfcf77 100644 --- a/tests/net/conn_mgr_monitor/src/test_ifaces.c +++ b/tests/net/conn_mgr_monitor/src/test_ifaces.c @@ -15,7 +15,7 @@ static void test_iface_init(struct net_if *iface) { /* Fake link layer address is needed to silence assertions inside the net core */ - static uint8_t fake_lladdr[] = { 0x01 }; + static uint8_t fake_lladdr[] = { 0x00, 0x00, 0x5E, 0x00, 0x53, 0x01 }; net_if_set_link_addr(iface, fake_lladdr, sizeof(fake_lladdr), NET_LINK_DUMMY); diff --git a/tests/net/lib/dns_dispatcher/CMakeLists.txt b/tests/net/lib/dns_dispatcher/CMakeLists.txt new file mode 100644 index 0000000000000..d6a70f1b8d3ca --- /dev/null +++ b/tests/net/lib/dns_dispatcher/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(dns_dispatcher) + +target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/net/ip) +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/net/lib/dns_dispatcher/prj.conf b/tests/net/lib/dns_dispatcher/prj.conf new file mode 100644 index 0000000000000..035c73e9b3b6e --- /dev/null +++ b/tests/net/lib/dns_dispatcher/prj.conf @@ -0,0 +1,25 @@ +CONFIG_NETWORKING=y +CONFIG_NET_TEST=y +CONFIG_ENTROPY_GENERATOR=y +CONFIG_TEST_RANDOM_GENERATOR=y +CONFIG_NET_L2_DUMMY=y +CONFIG_DNS_RESOLVER=y +CONFIG_DNS_RESOLVER_MAX_SERVERS=2 +CONFIG_DNS_NUM_CONCUR_QUERIES=1 +CONFIG_NET_LOG=y +CONFIG_NET_MGMT=y +CONFIG_NET_MGMT_EVENT=y +CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=5 +CONFIG_NET_IPV4=y +CONFIG_NET_IPV6=y +CONFIG_PRINTK=y +CONFIG_ZTEST=y +CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_ZVFS_OPEN_MAX=10 +CONFIG_ZVFS_POLL_MAX=10 +CONFIG_MDNS_RESPONDER=n +CONFIG_MDNS_RESOLVER=n +CONFIG_DNS_SERVER_IP_ADDRESSES=y +CONFIG_DNS_RESOLVER_MAX_SERVERS=2 +CONFIG_DNS_SERVER1="192.0.2.1" +CONFIG_DNS_SERVER2="2001:db8::1" diff --git a/tests/net/lib/dns_dispatcher/src/main.c b/tests/net/lib/dns_dispatcher/src/main.c new file mode 100644 index 0000000000000..21e6046606660 --- /dev/null +++ b/tests/net/lib/dns_dispatcher/src/main.c @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +LOG_MODULE_REGISTER(net_test, CONFIG_DNS_RESOLVER_LOG_LEVEL); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NET_LOG_ENABLED 1 +#include "net_private.h" + +#if defined(CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG) +#define DBG(fmt, ...) printk(fmt, ##__VA_ARGS__) +#else +#define DBG(fmt, ...) +#endif + +#define NAME4 "4.zephyr.test" +#define NAME6 "6.zephyr.test" +#define NAME_IPV4 "192.0.2.1" +#define NAME_IPV6 "2001:db8::1" + +#define DNS_NAME_IPV4 "192.0.2.4" +#define DNS2_NAME_IPV4 "192.0.2.5" +#define DNS_NAME_IPV6 "2001:db8::4" + +#define DNS_TIMEOUT 500 /* ms */ + +#if defined(CONFIG_NET_IPV6) +/* Interface 1 addresses */ +static struct in6_addr my_addr1 = { { { 0x20, 0x01, 0x0d, 0xb8, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0x1 } } }; +#endif + +#if defined(CONFIG_NET_IPV4) +/* Interface 1 addresses */ +static struct in_addr my_addr2 = { { { 192, 0, 2, 1 } } }; +#endif + +static struct net_if *iface1; + +/* this must be higher that the DNS_TIMEOUT */ +#define WAIT_TIME K_MSEC((DNS_TIMEOUT + 300) * 3) + +struct net_if_test { + uint8_t idx; + uint8_t mac_addr[sizeof(struct net_eth_addr)]; +}; + +static uint8_t *net_iface_get_mac(const struct device *dev) +{ + struct net_if_test *data = dev->data; + + if (data->mac_addr[2] == 0x00) { + /* 00-00-5E-00-53-xx Documentation RFC 7042 */ + data->mac_addr[0] = 0x00; + data->mac_addr[1] = 0x00; + data->mac_addr[2] = 0x5E; + data->mac_addr[3] = 0x00; + data->mac_addr[4] = 0x53; + data->mac_addr[5] = sys_rand8_get(); + } + + return data->mac_addr; +} + +static void net_iface_init(struct net_if *iface) +{ + uint8_t *mac = net_iface_get_mac(net_if_get_device(iface)); + + net_if_set_link_addr(iface, mac, sizeof(struct net_eth_addr), + NET_LINK_ETHERNET); +} + +static int sender_iface(const struct device *dev, struct net_pkt *pkt) +{ + if (!pkt->frags) { + DBG("No data to send!\n"); + return -ENODATA; + } + + return 0; +} + +struct net_if_test net_iface1_data; + +static struct dummy_api net_iface_api = { + .iface_api.init = net_iface_init, + .send = sender_iface, +}; + +#define _ETH_L2_LAYER DUMMY_L2 +#define _ETH_L2_CTX_TYPE NET_L2_GET_CTX_TYPE(DUMMY_L2) + +NET_DEVICE_INIT_INSTANCE(net_iface1_test, + "iface1", + iface1, + NULL, + NULL, + &net_iface1_data, + NULL, + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, + &net_iface_api, + _ETH_L2_LAYER, + _ETH_L2_CTX_TYPE, + 127); + +static void *test_init(void) +{ + struct net_if_addr *ifaddr; + + iface1 = net_if_get_by_index(0); + zassert_is_null(iface1, "iface1"); + + iface1 = net_if_get_by_index(1); + + ((struct net_if_test *) net_if_get_device(iface1)->data)->idx = + net_if_get_by_iface(iface1); + +#if defined(CONFIG_NET_IPV6) + ifaddr = net_if_ipv6_addr_add(iface1, &my_addr1, + NET_ADDR_MANUAL, 0); + if (!ifaddr) { + DBG("Cannot add IPv6 address %s\n", + net_sprint_ipv6_addr(&my_addr1)); + zassert_not_null(ifaddr, "addr1"); + + return NULL; + } + + /* For testing purposes we need to set the adddresses preferred */ + ifaddr->addr_state = NET_ADDR_PREFERRED; +#endif + +#if defined(CONFIG_NET_IPV4) + ifaddr = net_if_ipv4_addr_add(iface1, &my_addr2, + NET_ADDR_MANUAL, 0); + if (!ifaddr) { + DBG("Cannot add IPv4 address %s\n", + net_sprint_ipv4_addr(&my_addr2)); + zassert_not_null(ifaddr, "addr2"); + + return NULL; + } + + ifaddr->addr_state = NET_ADDR_PREFERRED; +#endif + + net_if_up(iface1); + + return NULL; +} + +ZTEST(dns_dispatcher, test_dns_dispatcher) +{ + struct dns_resolve_context *ctx; + int sock1, sock2 = -1; + + ctx = dns_resolve_get_default(); + + dns_resolve_init_default(ctx); + + sock1 = ctx->servers[0].sock; + + for (int i = 0; i < ctx->servers[0].dispatcher.fds_len; i++) { + if (ctx->servers[0].dispatcher.fds[i].fd == sock1) { + sock2 = i; + break; + } + } + + zassert_not_equal(sock2, -1, "Cannot find socket"); + + k_sleep(K_MSEC(10)); + + dns_resolve_close(ctx); + + zassert_equal(ctx->servers[0].dispatcher.fds[sock2].fd, -1, "Socket not closed"); + zassert_equal(ctx->servers[0].dispatcher.sock, -1, "Dispatcher still registered"); +} + +ZTEST_SUITE(dns_dispatcher, NULL, test_init, NULL, NULL, NULL); diff --git a/tests/net/lib/dns_dispatcher/testcase.yaml b/tests/net/lib/dns_dispatcher/testcase.yaml new file mode 100644 index 0000000000000..45337949f8fbb --- /dev/null +++ b/tests/net/lib/dns_dispatcher/testcase.yaml @@ -0,0 +1,13 @@ +common: + tags: + - dns + - net + depends_on: netif + min_ram: 21 + timeout: 600 + platform_exclude: + - native_posix + - native_posix/native/64 +tests: + net.dns.dispatch: + min_ram: 21 diff --git a/tests/net/lib/dns_packet/src/main.c b/tests/net/lib/dns_packet/src/main.c index e48477d0b03da..363bdf3d3b51b 100644 --- a/tests/net/lib/dns_packet/src/main.c +++ b/tests/net/lib/dns_packet/src/main.c @@ -709,6 +709,24 @@ static uint8_t resp_truncated_response_ipv4_5[] = { 0x00, 0x04, }; +static uint8_t resp_truncated_response_ipv4_6[] = { + /* DNS msg header (12 bytes) */ + /* Id (0) */ + 0x00, 0x00, + /* Flags (response, rcode = 1) */ + 0x80, 0x01, + /* Number of questions */ + 0x00, 0x01, + /* Number of answers */ + 0x00, 0x00, + /* Number of authority RRs */ + 0x00, 0x00, + /* Number of additional RRs */ + 0x00, 0x00, + + /* Rest of the data is missing */ +}; + static uint8_t resp_valid_response_ipv4_6[] = { /* DNS msg header (12 bytes) */ 0xb0, 0x41, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, @@ -1093,8 +1111,13 @@ static void run_dns_malformed_response(const char *test_case, dns_id = dns_unpack_header_id(dns_msg.msg); - setup_dns_context(&dns_ctx, 0, dns_id, query, sizeof(query), - DNS_QUERY_TYPE_A); + /* If the message is longer than 12 bytes, it could be a valid DNS message + * in which case setup the context for the reply. + */ + if (len > 12) { + setup_dns_context(&dns_ctx, 0, dns_id, query, sizeof(query), + DNS_QUERY_TYPE_A); + } ret = dns_validate_msg(&dns_ctx, &dns_msg, &dns_id, &query_idx, NULL, &query_hash); @@ -1198,6 +1221,7 @@ static void test_dns_malformed_responses(void) RUN_MALFORMED_TEST(resp_truncated_response_ipv4_3); RUN_MALFORMED_TEST(resp_truncated_response_ipv4_4); RUN_MALFORMED_TEST(resp_truncated_response_ipv4_5); + RUN_MALFORMED_TEST(resp_truncated_response_ipv4_6); } ZTEST(dns_packet, test_dns_malformed_and_valid_responses) @@ -1242,6 +1266,27 @@ ZTEST(dns_packet, test_dns_flags_len) "DNS message length check failed (%d)", ret); } +static uint8_t invalid_answer_resp_ipv4[18] = { + /* DNS msg header (12 bytes) */ + 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x01, +}; + +ZTEST(dns_packet, test_dns_invalid_answer) +{ + struct dns_msg_t dns_msg = { 0 }; + enum dns_rr_type type; + uint32_t ttl; + int ret; + + dns_msg.msg = invalid_answer_resp_ipv4; + dns_msg.msg_size = sizeof(invalid_answer_resp_ipv4); + dns_msg.answer_offset = 12; + + ret = dns_unpack_answer(&dns_msg, 0, &ttl, &type); + zassert_equal(ret, -EINVAL, "DNS message answer check succeed (%d)", ret); +} + ZTEST_SUITE(dns_packet, NULL, NULL, NULL, NULL, NULL); /* TODO: * 1) add malformed DNS data (mostly done) diff --git a/tests/net/lib/http_server/common/src/main.c b/tests/net/lib/http_server/common/src/main.c index 5c4ab204873a0..a0c46fd08151a 100644 --- a/tests/net/lib/http_server/common/src/main.c +++ b/tests/net/lib/http_server/common/src/main.c @@ -77,6 +77,8 @@ HTTP_RESOURCE_DEFINE(resource_6, service_D, "/fo*", RES(1)); HTTP_RESOURCE_DEFINE(resource_7, service_D, "/f[ob]o3.html", RES(1)); HTTP_RESOURCE_DEFINE(resource_8, service_D, "/fb?3.htm", RES(0)); HTTP_RESOURCE_DEFINE(resource_9, service_D, "/f*4.html", RES(3)); +HTTP_RESOURCE_DEFINE(resource_11, service_D, "/foo/*", RES(3)); +HTTP_RESOURCE_DEFINE(resource_12, service_D, "/foo/b?r", RES(3)); ZTEST(http_service, test_HTTP_SERVICE_DEFINE) { @@ -345,6 +347,25 @@ ZTEST(http_service, test_HTTP_RESOURCE_WILDCARD) zassert_not_null(res, "Cannot find resource"); zassert_true(len > 0, "Length not set"); zassert_equal(res, RES(5), "Resource mismatch"); + + res = CHECK_PATH("/foo/bar", &len); + zassert_not_null(res, "Resource not found"); + zassert_true(len == (sizeof("/foo/bar") - 1), "Length not set correctly"); + zassert_equal(res, RES(3), "Resource mismatch"); + + res = CHECK_PATH("/foo/bar?param=value", &len); + zassert_not_null(res, "Resource not found"); + zassert_true(len == (sizeof("/foo/bar") - 1), "Length not set correctly"); + zassert_equal(res, RES(3), "Resource mismatch"); + + res = CHECK_PATH("/bar?foo=value", &len); + zassert_is_null(res, "Resource found"); + zassert_equal(len, 0, "Length set"); + + res = CHECK_PATH("/foo/bar?param=value", &len); + zassert_not_null(res, "Resource not found"); + zassert_true(len == (sizeof("/foo/bar") - 1), "Length not set correctly"); + zassert_equal(res, RES(3), "Resource mismatch"); } extern void http_server_get_content_type_from_extension(char *url, char *content_type, diff --git a/tests/subsys/lorawan/frag_decoder/testcase.yaml b/tests/subsys/lorawan/frag_decoder/testcase.yaml index 7182fd3cfe628..d5ea2f8d7141f 100644 --- a/tests/subsys/lorawan/frag_decoder/testcase.yaml +++ b/tests/subsys/lorawan/frag_decoder/testcase.yaml @@ -7,6 +7,7 @@ tests: - native_sim extra_configs: - CONFIG_LORAWAN_FRAG_TRANSPORT_DECODER_SEMTECH=y + - CONFIG_NATIVE_EXTRA_CMDLINE_ARGS="seed=1" lorawan.frag_decoder.lowmem.high_redundancy: platform_allow: - native_sim @@ -19,3 +20,4 @@ tests: extra_configs: - CONFIG_LORAWAN_FRAG_TRANSPORT_DECODER_LOWMEM=y - CONFIG_LORAWAN_FRAG_TRANSPORT_MAX_REDUNDANCY=10 + - CONFIG_NATIVE_EXTRA_CMDLINE_ARGS="seed=1" diff --git a/west.yml b/west.yml index 87657ebf6df36..fffb9c398f9e9 100644 --- a/west.yml +++ b/west.yml @@ -280,7 +280,7 @@ manifest: revision: 2b498e6f36d6b82ae1da12c8b7742e318624ecf5 path: modules/lib/gui/lvgl - name: mbedtls - revision: a78176c6ff0733ba08018cba4447bd3f20de7978 + revision: 5f889934359deccf421554c7045a8381ef75298f path: modules/crypto/mbedtls groups: - crypto @@ -310,7 +310,7 @@ manifest: path: modules/lib/openthread - name: percepio path: modules/debug/percepio - revision: b68d17993109b9bee6b45dc8c9794e7b7bce236d + revision: 0d44033c744978ca2505a06640b4f6964c5411e6 groups: - debug - name: picolibc @@ -327,7 +327,7 @@ manifest: groups: - crypto - name: trusted-firmware-m - revision: 8134106ef9cb3df60e8bd22b172532558e936bd2 + revision: e2288c13ee0abc16163186523897e7910b03dd31 path: modules/tee/tf-m/trusted-firmware-m groups: - tee