From 01a3232eebc2f711919d5a91b23979d7d0804e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Tue, 19 Nov 2024 18:08:06 +0100 Subject: [PATCH 001/118] doc: doxygen: improve formatting for kconfig alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit \verbatim is not giving the right output as we need an inline literal. Switch to \c instead. Fixes #81595. Signed-off-by: Benjamin Cabé (cherry picked from commit 83356e924a6e7f7d83c79b2942e66b855451dc6a) --- doc/zephyr.doxyfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" \ From 966da750e1d997182d1f3f5fa04a9132b3c86a94 Mon Sep 17 00:00:00 2001 From: Kapil Bhatt Date: Wed, 23 Oct 2024 18:02:32 +0530 Subject: [PATCH 002/118] drivers: wifi: Fix offloaded raw TX feature flags Pass passive scan and offloaded raw tx feature flags to OSAL. Signed-off-by: Kapil Bhatt (cherry picked from commit 62e06a50729a4890725716341743cb9e74df476f) --- drivers/wifi/nrfwifi/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/wifi/nrfwifi/CMakeLists.txt b/drivers/wifi/nrfwifi/CMakeLists.txt index 17ec7176cb269..2e04398c892a9 100644 --- a/drivers/wifi/nrfwifi/CMakeLists.txt +++ b/drivers/wifi/nrfwifi/CMakeLists.txt @@ -305,6 +305,14 @@ 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} From 07a0ae1a995e89caa3b5f14807c35f7c659ad1eb Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Mon, 28 Oct 2024 14:05:58 +0530 Subject: [PATCH 003/118] drivers: nrfwifi: Remove passing unused flag This flag is now unused in OSAL as it takes the input via the API. Signed-off-by: Chaitanya Tata (cherry picked from commit f537cf311d7ad19ba00221f9022b7dc4c2daef43) --- drivers/wifi/nrfwifi/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/wifi/nrfwifi/CMakeLists.txt b/drivers/wifi/nrfwifi/CMakeLists.txt index 2e04398c892a9..439263ec6151e 100644 --- a/drivers/wifi/nrfwifi/CMakeLists.txt +++ b/drivers/wifi/nrfwifi/CMakeLists.txt @@ -319,7 +319,6 @@ zephyr_compile_definitions( -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} From 371e3a6769c45f67fe7b6e053d31078c4565c8e4 Mon Sep 17 00:00:00 2001 From: Andrej Butok Date: Wed, 13 Nov 2024 12:56:59 +0100 Subject: [PATCH 004/118] boards: nxp: fix s26ks512s0 flash write-block-size - Sets s26ks512s0 flash write-block-size to correct 256KB. - Optimizes MCUboot partitions to fit the correct write-block-size. Fixes #80284 Signed-off-by: Andrej Butok (cherry picked from commit a730d9abad9241c0eb3fe0be64f42137692a6285) --- ...imxrt1050_evk_mimxrt1052_hyperflash.overlay | 18 +++++++++--------- ...imxrt1060_evk_mimxrt1062_hyperflash.overlay | 18 +++++++++--------- .../mimxrt1062_fmurt6/mimxrt1062_fmurt6.dts | 18 +++++++++--------- 3 files changed, 27 insertions(+), 27 deletions(-) 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))>; }; }; }; From f7edec7da6bdd7f3e7b1af8505c5b5fb6b54895b Mon Sep 17 00:00:00 2001 From: Matthias Alleman Date: Fri, 22 Nov 2024 16:39:29 +0100 Subject: [PATCH 005/118] posix: fpu: Fix compiler error when enabling fpu on posix boards Enabling CONFIG_FPU and CONFIG_FPU_SHARING requires the definition of `arch_float_disable` and `arch_float_enable`. Signed-off-by: Matthias Alleman (cherry picked from commit e7c353bf144f23ce010122cb4e9135a56d2e1033) --- arch/posix/core/thread.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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) { From aae851fdb560b70327acedeae29236e1fcf90bbb Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Thu, 14 Nov 2024 19:47:42 +0100 Subject: [PATCH 006/118] bluetooth: CTS: Fix includes to avoid build error with some libCs Remove unnecessary include in header and source file. gmtime_r() is an extension to the C library, and therefore one needs to explicitly ask for its prototype to have it exposed. This is done by defining _POSIX_C_SOURCE so let's do so. These two changes fix build errors with some libCs. Tested with pico, newlib, minimal and the host glibc. Signed-off-by: Alberto Escolar Piedras (cherry picked from commit a785548df6353dafe362579af6859d3d02458dbb) --- include/zephyr/bluetooth/services/cts.h | 1 - subsys/bluetooth/services/cts.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) 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/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; From 3b14973425d04d2e6dadd9afaaba2ac9ca29350a Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Fri, 15 Nov 2024 19:45:06 +0100 Subject: [PATCH 007/118] drivers: rtc: sam: Add platform on API test coverage The #81456 fixed the driver issue related to issue #81454. This add the RTC configurations on sam_v71_xult board to enable test coverage. Fixes #81454 Signed-off-by: Gerson Fernando Budke (cherry picked from commit cffb66f5c6862854a0f53657742077bd4ba32de0) --- boards/atmel/sam/sam_v71_xult/sam_v71_xult-common.dtsi | 7 ++++++- boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21.yaml | 1 + boards/atmel/sam/sam_v71_xult/sam_v71_xult_samv71q21b.yaml | 1 + .../drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21.conf | 3 +++ .../rtc/rtc_api/boards/sam_v71_xult_samv71q21b.conf | 3 +++ 5 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21.conf create mode 100644 tests/drivers/rtc/rtc_api/boards/sam_v71_xult_samv71q21b.conf 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/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 From 2c5fb2d916f09f0bf97e8488633d2b256d28c35b Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Wed, 20 Nov 2024 17:25:30 +0800 Subject: [PATCH 008/118] arch: riscv: reg: include required header Include `zephyr/sys/util.h` for the `STRINGIFY()` macro. Signed-off-by: Yong Cong Sin (cherry picked from commit 45ebd390cfd632055f11a8ac5be0c40e0d333a0c) --- include/zephyr/arch/riscv/reg.h | 2 ++ 1 file changed, 2 insertions(+) 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; \ From 98d9f3e551e310f8d29f36bb16ec9850fd80fc45 Mon Sep 17 00:00:00 2001 From: Jerzy Kasenberg Date: Mon, 18 Nov 2024 11:30:23 +0100 Subject: [PATCH 009/118] i2c: target: eeprom_target: Fix buffer write When larger buffer index was introduced only function: eeprom_target_write_received() was updated to handle address-width = 16 This adds the same functionality when buffered API is used, enabled by CONFIG_I2C_TARGET_BUFFER_MODE. Signed-off-by: Jerzy Kasenberg (cherry picked from commit e6c9e9a2dde2e038b6b81140ee27556d4b36dc78) --- drivers/i2c/target/eeprom_target.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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, From 8ac7bde2b16ac4e15d672cfb664ca3a017b82c7c Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Mon, 25 Nov 2024 22:27:54 +0100 Subject: [PATCH 010/118] bluetooth: mesh: proxy_msg: Fix extracting role from k_work Fix extracting role from k_work. Hot fix for #78914 Signed-off-by: Pavel Vasilyev (cherry picked from commit f5409bd3deba779263fb58bb06a0573e034795cf) --- subsys/bluetooth/mesh/proxy_msg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/subsys/bluetooth/mesh/proxy_msg.c b/subsys/bluetooth/mesh/proxy_msg.c index 861935f58ccf7..edee3ad384cde 100644 --- a/subsys/bluetooth/mesh/proxy_msg.c +++ b/subsys/bluetooth/mesh/proxy_msg.c @@ -252,11 +252,9 @@ 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; } From bd1db48d256707809f725a5b11263060ad1e1299 Mon Sep 17 00:00:00 2001 From: Jakub Rzeszutko Date: Tue, 19 Nov 2024 08:54:10 +0100 Subject: [PATCH 011/118] lib: shell: replace strtol with strtoul in cmd_load for address parsing Addresses in cmd_load() should always be unsigned. Previously, strtol() was used, which is limited to signed long values, causing issues with addresses >= 0x80000000. This commit replaces strtol() with strtoul(), ensuring proper handling of the full 32-bit address space. Fixes #81343 Signed-off-by: Aaron Fontaine Signed-off-by: Jakub Rzeszutko (cherry picked from commit 1aaf08f7f12699a8a68c897a5cb3552a46d1f98c) --- subsys/shell/modules/devmem_service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; From 9c63873db25793dc9d2d5419fd83251bffea9177 Mon Sep 17 00:00:00 2001 From: Steven Poon Date: Thu, 28 Nov 2024 21:16:23 +1100 Subject: [PATCH 012/118] net: lib: lwm2m: Fix missing mutex unlock lwm2m_engine_set() and lwm2m_engine_get() locks the registry_lock mutex, but this is not unlocked when setting or getting a time resource where the buffer lengths are invalid resulting in an early return without unlocking the mutex. This results in a deadlock when attempting to lock the registry in another thread. Signed-off-by: Steven Poon (cherry picked from commit 30b30c29a32da98beadb08ec3a92f65abe138e18) --- subsys/net/lib/lwm2m/lwm2m_registry.c | 2 ++ 1 file changed, 2 insertions(+) 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; } From 4d3a4eafd6de726cc5129c0d7d304e8d63df8bf4 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 27 Nov 2024 19:19:35 +0000 Subject: [PATCH 013/118] mgmt: mcumgr: grp: img_mgmt: Fix misplaced #endif Fixes a misplaced endif which wrongly excluded functions Signed-off-by: Jamie McCrae (cherry picked from commit 5437ded36c1c9011e77fa4069365097689751a81) --- subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From d4e329483f2bd51098c7bebc4d503372ee4143da Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 11:08:49 +0200 Subject: [PATCH 014/118] net: ethernet: bridge: Avoid null pointer access If the packet cloning failed, bail out in order to avoid null pointer access. Fixes #81992 Coverity-CID: 434493 Signed-off-by: Jukka Rissanen (cherry picked from commit ed0dcca2fb5006f4009633728ec7409ac08a219c) --- subsys/net/l2/ethernet/bridge.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subsys/net/l2/ethernet/bridge.c b/subsys/net/l2/ethernet/bridge.c index d497acc683397..905914a909de1 100644 --- a/subsys/net/l2/ethernet/bridge.c +++ b/subsys/net/l2/ethernet/bridge.c @@ -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); From 1e88982fe372d9cdba293a9b908dfe75b7d132ee Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 13:25:52 +0200 Subject: [PATCH 015/118] net: ethernet: bridge: Drop the cloned packet in error We need to drop the cloned packet that was fed to the bridge instead of returning directly from the function. Without this change we have a buffer leak. Signed-off-by: Jukka Rissanen (cherry picked from commit c6a1af5c17287414055f587ae01719f4faee358b) --- subsys/net/l2/ethernet/bridge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/net/l2/ethernet/bridge.c b/subsys/net/l2/ethernet/bridge.c index 905914a909de1..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); @@ -397,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) From ce695706c05c476b4e483158c24a885f5f99abe0 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 15:40:53 +0200 Subject: [PATCH 016/118] net: dns: Check parsing error properly for response If the packet parsing fails in dns_unpack_response_query(), then do not continue further but bail out early. Signed-off-by: Jukka Rissanen (cherry picked from commit eb2550a441dbfb62bf55d8b7095fd0db78c1f2d6) --- subsys/net/lib/dns/resolve.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subsys/net/lib/dns/resolve.c b/subsys/net/lib/dns/resolve.c index ff17b6b6257fe..040751e622c86 100644 --- a/subsys/net/lib/dns/resolve.c +++ b/subsys/net/lib/dns/resolve.c @@ -705,6 +705,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; From 1805b1579f72f87a752aa86d396f64b357388279 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 15:47:46 +0200 Subject: [PATCH 017/118] tests: net: dns: Add checking of malformed packet Make sure we test malformed packet parsing. Signed-off-by: Jukka Rissanen (cherry picked from commit 6f96915a1436845b1772af3e1dfb7174d4f219b6) --- tests/net/lib/dns_packet/src/main.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/net/lib/dns_packet/src/main.c b/tests/net/lib/dns_packet/src/main.c index e48477d0b03da..bdf55c611f3fc 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) From b912e674cf1832624c807608d9e7764c62bb7b32 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 16:40:28 +0200 Subject: [PATCH 018/118] net: dns: Validate source buffer length properly Make sure that when copying the qname, the source buffer is large enough for the data. Signed-off-by: Jukka Rissanen (cherry picked from commit 43c2b9cfe89f29ce41d0677cfd9eb4db71636026) --- subsys/net/lib/dns/dns_pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/lib/dns/dns_pack.c b/subsys/net/lib/dns/dns_pack.c index 34b3651a4f072..86bee64e7676e 100644 --- a/subsys/net/lib/dns/dns_pack.c +++ b/subsys/net/lib/dns/dns_pack.c @@ -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; } From aec5129706817fab8961ed69b468e37e3dbc4909 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 17:48:43 +0200 Subject: [PATCH 019/118] net: dns: Check DNS answer properly The dns_unpack_answer() did not check the length of the message properly which can cause out of bounds read. Signed-off-by: Jukka Rissanen (cherry picked from commit 6e7fcff579b9bbfa826319b9a166b25a24ab3173) --- subsys/net/lib/dns/dns_pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/lib/dns/dns_pack.c b/subsys/net/lib/dns/dns_pack.c index 86bee64e7676e..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; } From 2fe01e94009da6b529362684bf5406bf69a7c468 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 17:50:02 +0200 Subject: [PATCH 020/118] tests: net: dns: Add test for invalid DNS answer parsing Make sure we catch invalid answer during parsing. Signed-off-by: Jukka Rissanen (cherry picked from commit 16669ec4d5f8e0abbfadd06c1c5ec5584005efcd) --- tests/net/lib/dns_packet/src/main.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/net/lib/dns_packet/src/main.c b/tests/net/lib/dns_packet/src/main.c index bdf55c611f3fc..363bdf3d3b51b 100644 --- a/tests/net/lib/dns_packet/src/main.c +++ b/tests/net/lib/dns_packet/src/main.c @@ -1266,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) From b306b24ec401822d1b6b17859e8dcb7f988d45b8 Mon Sep 17 00:00:00 2001 From: Marek Matej Date: Thu, 24 Oct 2024 17:07:13 +0100 Subject: [PATCH 021/118] dts: espressif: Add flash size options to partition tables Update the partition table list with 16MB and 32MB options. Signed-off-by: Marek Matej (cherry picked from commit 2dc2cdea7580bc1362345891787c3455849f03d2) --- .../espressif/partitions_0x0_amp_16M.dtsi | 54 +++++++++++++++++++ .../espressif/partitions_0x0_amp_32M.dtsi | 54 +++++++++++++++++++ .../espressif/partitions_0x0_default_16M.dtsi | 44 +++++++++++++++ .../espressif/partitions_0x0_default_32M.dtsi | 44 +++++++++++++++ .../espressif/partitions_0x1000_amp_16M.dtsi | 54 +++++++++++++++++++ .../espressif/partitions_0x1000_amp_32M.dtsi | 54 +++++++++++++++++++ .../partitions_0x1000_default_16M.dtsi | 44 +++++++++++++++ .../partitions_0x1000_default_32M.dtsi | 44 +++++++++++++++ 8 files changed, 392 insertions(+) create mode 100644 dts/common/espressif/partitions_0x0_amp_16M.dtsi create mode 100644 dts/common/espressif/partitions_0x0_amp_32M.dtsi create mode 100644 dts/common/espressif/partitions_0x0_default_16M.dtsi create mode 100644 dts/common/espressif/partitions_0x0_default_32M.dtsi create mode 100644 dts/common/espressif/partitions_0x1000_amp_16M.dtsi create mode 100644 dts/common/espressif/partitions_0x1000_amp_32M.dtsi create mode 100644 dts/common/espressif/partitions_0x1000_default_16M.dtsi create mode 100644 dts/common/espressif/partitions_0x1000_default_32M.dtsi 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)>; + }; + }; +}; From 8fdf2216408250d476b48ab883f9087d71985cc7 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 13:37:29 +0200 Subject: [PATCH 022/118] net: wifi_cred: Check null before access We must do null check before trying to access the fields. Fixes #81980 Coverify-CID: 434549 Signed-off-by: Jukka Rissanen (cherry picked from commit 3aa0c8670e2654279ace6414fc8a1380ef39c731) --- subsys/net/lib/wifi_credentials/wifi_credentials.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subsys/net/lib/wifi_credentials/wifi_credentials.c b/subsys/net/lib/wifi_credentials/wifi_credentials.c index acc31767b8938..b3e50ca9e6a92 100644 --- a/subsys/net/lib/wifi_credentials/wifi_credentials.c +++ b/subsys/net/lib/wifi_credentials/wifi_credentials.c @@ -154,13 +154,13 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal { 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 set WiFi credentials, provided struct pointer cannot be NULL"); 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 set WiFi credentials, SSID has invalid format"); return -EINVAL; } From 18845d2bb5b3d7a86cff500f79b22c13edbbab32 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 13:41:44 +0200 Subject: [PATCH 023/118] net: wifi_cred: Introduce variables at the start of function Follow the net coding style and declare the variables at the start of the function. Signed-off-by: Jukka Rissanen (cherry picked from commit b2056e0966b23fd15b5c03abb9cda6815eff7df5) --- .../net/lib/wifi_credentials/wifi_credentials.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/subsys/net/lib/wifi_credentials/wifi_credentials.c b/subsys/net/lib/wifi_credentials/wifi_credentials.c index b3e50ca9e6a92..18c18be7e440c 100644 --- a/subsys/net/lib/wifi_credentials/wifi_credentials.c +++ b/subsys/net/lib/wifi_credentials/wifi_credentials.c @@ -104,6 +104,7 @@ 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) { @@ -119,7 +120,7 @@ int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_l 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"); @@ -152,6 +153,7 @@ 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 == NULL) { @@ -166,7 +168,7 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal 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(); @@ -199,6 +201,7 @@ 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"); @@ -219,7 +222,7 @@ int wifi_credentials_set_personal(const char *ssid, size_t ssid_len, enum wifi_s } /* 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); @@ -267,6 +270,7 @@ 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"); @@ -292,7 +296,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; @@ -327,6 +331,7 @@ 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) { @@ -335,7 +340,7 @@ int wifi_credentials_delete_by_ssid(const char *ssid, size_t ssid_len) } 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"); From e60954d54e72884a8395763f1a8b90641105b9a8 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 13:43:48 +0200 Subject: [PATCH 024/118] net: wifi_cred: Remove extra empty lines Follow net coding style and remove extra new lines between variable set and checking its value. Signed-off-by: Jukka Rissanen (cherry picked from commit 8deebcec21b0b1bc4a7883c55dd707da6e94d0a8) --- subsys/net/lib/wifi_credentials/wifi_credentials.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/subsys/net/lib/wifi_credentials/wifi_credentials.c b/subsys/net/lib/wifi_credentials/wifi_credentials.c index 18c18be7e440c..2f155b3f16664 100644 --- a/subsys/net/lib/wifi_credentials/wifi_credentials.c +++ b/subsys/net/lib/wifi_credentials/wifi_credentials.c @@ -121,7 +121,6 @@ int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_l k_mutex_lock(&wifi_credentials_mutex, K_FOREVER); idx = lookup_idx(ssid, ssid_len); - if (idx == -1) { LOG_DBG("Cannot retrieve WiFi credentials, no entry found for the provided SSID"); ret = -ENOENT; @@ -129,7 +128,6 @@ int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_l } 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); goto exit; @@ -169,7 +167,6 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal k_mutex_lock(&wifi_credentials_mutex, K_FOREVER); idx = lookup_idx(creds->header.ssid, creds->header.ssid_len); - if (idx == -1) { idx = lookup_unused_idx(); if (idx == -1) { @@ -180,7 +177,6 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal } 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); goto exit; @@ -340,15 +336,14 @@ int wifi_credentials_delete_by_ssid(const char *ssid, size_t ssid_len) } k_mutex_lock(&wifi_credentials_mutex, K_FOREVER); - 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); goto exit; From d6ec225075de51578c63dbbe5d3220347b694018 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 26 Nov 2024 14:00:16 +0200 Subject: [PATCH 025/118] net: wifi_cred: Decrease flash usage for error print strings As the error print strings are very similar, construct the final output at runtime to save some flash space. Signed-off-by: Jukka Rissanen (cherry picked from commit 3c59bd4fb571b04172b74f0ec6563b6a2784a318) --- .../lib/wifi_credentials/wifi_credentials.c | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/subsys/net/lib/wifi_credentials/wifi_credentials.c b/subsys/net/lib/wifi_credentials/wifi_credentials.c index 2f155b3f16664..a91ea8dd5428a 100644 --- a/subsys/net/lib/wifi_credentials/wifi_credentials.c +++ b/subsys/net/lib/wifi_credentials/wifi_credentials.c @@ -108,13 +108,12 @@ int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_l 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; } @@ -122,14 +121,14 @@ int wifi_credentials_get_by_ssid_personal_struct(const char *ssid, size_t ssid_l 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; } @@ -155,12 +154,12 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal int ret; if (creds == NULL) { - LOG_ERR("Cannot set WiFi credentials, provided struct pointer cannot be NULL"); + LOG_ERR("Cannot %s WiFi credentials, %s", "set", "credential not set"); return -EINVAL; } if (creds->header.ssid_len > WIFI_SSID_MAX_LEN || creds->header.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; } @@ -170,7 +169,7 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal 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; } @@ -178,7 +177,7 @@ int wifi_credentials_set_personal_struct(const struct wifi_credentials_personal 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; } @@ -200,20 +199,21 @@ int wifi_credentials_set_personal(const char *ssid, size_t ssid_len, enum wifi_s 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; } @@ -246,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; } @@ -269,18 +268,18 @@ int wifi_credentials_get_by_ssid_personal(const char *ssid, size_t ssid_len, 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; } @@ -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; } @@ -331,7 +330,7 @@ int wifi_credentials_delete_by_ssid(const char *ssid, size_t ssid_len) 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; } @@ -345,7 +344,7 @@ int wifi_credentials_delete_by_ssid(const char *ssid, size_t ssid_len) 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; } From 17df0f17489f2bcb14a2bda4ed164e8d50768daf Mon Sep 17 00:00:00 2001 From: Jilay Pandya Date: Thu, 19 Dec 2024 23:03:56 +0100 Subject: [PATCH 026/118] drivers: auxdisplay: jhd1313: fix Out-of-bounds read fix out of bounds read by doing the comparison with ARRAY_SIZE correctly Signed-off-by: Jilay Pandya (cherry picked from commit 3202773b112c53c635985f7b7744544fe7fea4d8) --- drivers/auxdisplay/auxdisplay_jhd1313.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From fe8dc82b168213ab08bf7e3b1411b57db79f685b Mon Sep 17 00:00:00 2001 From: Dominik Ermel Date: Fri, 22 Nov 2024 15:23:16 +0000 Subject: [PATCH 027/118] drivers/flash: Correct flash_erase userspace handler As the erase callback is optional, handler should not check if it is not NULL. Fixes #81777 Signed-off-by: Dominik Ermel (cherry picked from commit 486428951ba0975d05842209793b28e610bd2128) --- drivers/flash/flash_handlers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From d70bbe0eb6dbb6a87de5465c5d0651f450ab0eaf Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Mon, 16 Dec 2024 11:09:51 +0000 Subject: [PATCH 028/118] samples: mgmt: mcumgr: smp_svr: Fix re-advertise issue on connection Fixes an issue introduced with commit c6ad4a792724ed19e51c0a0d0f010490150d4eff which wrong restarts advertising after a device connects when it should only restart advertising if a device fails to connect Signed-off-by: Jamie McCrae (cherry picked from commit 655be99fa7ce01ddf84bd9e8333aa07661a01079) --- samples/subsys/mgmt/mcumgr/smp_svr/src/bluetooth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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) From 8e2f36cfcfb0f9dab2022e893fc87e4a0166434f Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 14 Dec 2024 13:00:44 +0100 Subject: [PATCH 029/118] dts: atmel: sam0: Normalize dtsi nodes Keep a consistent order on the nodes definitions to make it easy to read between all the SoC series. Signed-off-by: Gerson Fernando Budke (cherry picked from commit 6f1f598a72ae4e3bdc59c671acbd3d0bb38b4664) --- dts/arm/atmel/samc21.dtsi | 12 ++++-- dts/arm/atmel/samc2x.dtsi | 40 ++++++++++++++------ dts/arm/atmel/samd21.dtsi | 4 +- dts/arm/atmel/samd2x.dtsi | 33 +++++++++++----- dts/arm/atmel/samd5x.dtsi | 79 ++++++++++++++++++++++++++------------- dts/arm/atmel/same5x.dtsi | 10 +++-- dts/arm/atmel/saml21.dtsi | 4 +- dts/arm/atmel/saml2x.dtsi | 34 ++++++++++++----- dts/arm/atmel/samr21.dtsi | 10 +++-- dts/arm/atmel/samr34.dtsi | 14 ++++--- 10 files changed, 164 insertions(+), 76 deletions(-) diff --git a/dts/arm/atmel/samc21.dtsi b/dts/arm/atmel/samc21.dtsi index 095e98437f05b..979ca0683468e 100644 --- a/dts/arm/atmel/samc21.dtsi +++ b/dts/arm/atmel/samc21.dtsi @@ -15,15 +15,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 +53,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 +66,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..3c61d1d664a33 100644 --- a/dts/arm/atmel/samc2x.dtsi +++ b/dts/arm/atmel/samc2x.dtsi @@ -25,9 +25,10 @@ #size-cells = <0>; cpu0: cpu@0 { - device_type = "cpu"; compatible = "arm,cortex-m0+"; reg = <0>; + + device_type = "cpu"; }; }; @@ -63,13 +64,15 @@ 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,23 @@ compatible = "atmel,sam0-dmac"; reg = <0x41006000 0x50>; interrupts = <7 0>; + #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 { @@ -194,32 +202,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 +242,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/samd21.dtsi b/dts/arm/atmel/samd21.dtsi index f8b12ed570ae9..fa24b4b75b762 100644 --- a/dts/arm/atmel/samd21.dtsi +++ b/dts/arm/atmel/samd21.dtsi @@ -14,9 +14,10 @@ soc { usb0: usb@41005000 { compatible = "atmel,sam0-usb"; - status = "disabled"; reg = <0x41005000 0x1000>; interrupts = <7 0>; + status = "disabled"; + num-bidir-endpoints = <8>; }; @@ -24,6 +25,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x41004800 0x50>; interrupts = <6 0>; + #dma-cells = <2>; }; diff --git a/dts/arm/atmel/samd2x.dtsi b/dts/arm/atmel/samd2x.dtsi index c247daffc1a51..4e13589ec7d86 100644 --- a/dts/arm/atmel/samd2x.dtsi +++ b/dts/arm/atmel/samd2x.dtsi @@ -25,9 +25,10 @@ #size-cells = <0>; cpu0: cpu@0 { - device_type = "cpu"; compatible = "arm,cortex-m0+"; reg = <0>; + + device_type = "cpu"; }; }; @@ -63,13 +64,15 @@ 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 +81,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 +153,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,27 +188,30 @@ 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>; + #io-channel-cells = <1>; + /* * 2.1 MHz max, so clock it with the * 8 MHz GCLK / 4 = 2 MHz */ 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..16bc968151281 100644 --- a/dts/arm/atmel/samd5x.dtsi +++ b/dts/arm/atmel/samd5x.dtsi @@ -20,12 +20,14 @@ #size-cells = <0>; cpu0: cpu@0 { - device_type = "cpu"; 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>; @@ -91,12 +93,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 +108,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 +125,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x4100A000 0x50>; interrupts = <31 0>, <32 0>, <33 0>, <34 0>, <35 0>; + #dma-cells = <2>; }; @@ -161,118 +168,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 +303,9 @@ compatible = "atmel,sam0-rtc"; reg = <0x40002400 0x1C>; interrupts = <11 0>; - clock-generator = <0>; status = "disabled"; + + clock-generator = <0>; }; adc0: adc@43001c00 { @@ -295,6 +313,10 @@ reg = <0x43001C00 0x4A>; interrupts = <118 0>, <119 0>; interrupt-names = "overrun", "resrdy"; + clocks = <&gclk 40>, <&mclk 0x20 7>; + clock-names = "GCLK", "MCLK"; + + #io-channel-cells = <1>; /* * 16 MHz max, source clock must not exceed 100 MHz. @@ -304,9 +326,6 @@ */ gclk = <2>; prescaler = <4>; - #io-channel-cells = <1>; - clocks = <&gclk 40>, <&mclk 0x20 7>; - clock-names = "GCLK", "MCLK"; calib-offset = <0>; }; @@ -315,6 +334,10 @@ reg = <0x43002000 0x4A>; interrupts = <120 0>, <121 0>; interrupt-names = "overrun", "resrdy"; + clocks = <&gclk 41>, <&mclk 0x20 8>; + clock-names = "GCLK", "MCLK"; + + #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>; }; @@ -369,6 +389,7 @@ <90 0>, <91 0>; clocks = <&gclk 25>, <&mclk 0x18 11>; clock-names = "GCLK", "MCLK"; + channels = <6>; counter-size = <24>; }; @@ -379,6 +400,7 @@ interrupts = <92 0>, <93 0>, <94 0>, <95 0>, <96 0>; clocks = <&gclk 25>, <&mclk 0x18 12>; clock-names = "GCLK", "MCLK"; + channels = <4>; counter-size = <24>; }; @@ -389,6 +411,7 @@ interrupts = <97 0>, <98 0>, <99 0>, <100 0>; clocks = <&gclk 29>, <&mclk 0x1c 3>; clock-names = "GCLK", "MCLK"; + channels = <3>; counter-size = <16>; }; @@ -399,6 +422,7 @@ interrupts = <101 0>, <102 0>, <103 0>; clocks = <&gclk 29>, <&mclk 0x1c 4>; clock-names = "GCLK", "MCLK"; + channels = <2>; counter-size = <16>; }; @@ -409,6 +433,7 @@ interrupts = <104 0>, <105 0>, <106 0>; clocks = <&gclk 38>, <&mclk 0x20 4>; clock-names = "GCLK", "MCLK"; + 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..e41541750f1d9 100644 --- a/dts/arm/atmel/saml21.dtsi +++ b/dts/arm/atmel/saml21.dtsi @@ -10,9 +10,10 @@ soc { usb0: usb@41000000 { compatible = "atmel,sam0-usb"; - status = "disabled"; reg = <0x41000000 0x1000>; interrupts = <6 0>; + status = "disabled"; + num-bidir-endpoints = <8>; }; @@ -20,6 +21,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x44000400 0x50>; interrupts = <5 0>; + #dma-cells = <2>; }; diff --git a/dts/arm/atmel/saml2x.dtsi b/dts/arm/atmel/saml2x.dtsi index 2bad616c81af9..47ad26b78c2e3 100644 --- a/dts/arm/atmel/saml2x.dtsi +++ b/dts/arm/atmel/saml2x.dtsi @@ -26,9 +26,10 @@ #size-cells = <0>; cpu0: cpu@0 { - device_type = "cpu"; compatible = "arm,cortex-m0+"; reg = <0>; + + device_type = "cpu"; }; }; @@ -50,14 +51,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 +69,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 +91,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x44000400 0x400>; interrupts = <5 0>; + #dma-cells = <2>; }; @@ -143,25 +150,29 @@ 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,27 +180,30 @@ 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>; + #io-channel-cells = <1>; + /* * 16 MHz max, so clock it with the * 48 MHz DFLL / 2 / 2 = 12 MHz */ 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>; }; diff --git a/dts/arm/atmel/samr21.dtsi b/dts/arm/atmel/samr21.dtsi index 786597c3ca31f..ddf505ee798cd 100644 --- a/dts/arm/atmel/samr21.dtsi +++ b/dts/arm/atmel/samr21.dtsi @@ -14,9 +14,10 @@ soc { usb0: usb@41005000 { compatible = "atmel,sam0-usb"; - status = "disabled"; reg = <0x41005000 0x1000>; interrupts = <7 0>; + status = "disabled"; + num-bidir-endpoints = <8>; }; @@ -24,6 +25,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x41004800 0x50>; interrupts = <6 0>; + #dma-cells = <2>; }; @@ -33,9 +35,11 @@ portc: gpio@41004500 { compatible = "atmel,sam0-gpio"; reg = <0x41004500 0x80>; - gpio-controller; - #gpio-cells = <2>; + #atmel,pin-cells = <2>; + #gpio-cells = <2>; + + gpio-controller; }; }; diff --git a/dts/arm/atmel/samr34.dtsi b/dts/arm/atmel/samr34.dtsi index 17164005d9939..756f501e430c8 100644 --- a/dts/arm/atmel/samr34.dtsi +++ b/dts/arm/atmel/samr34.dtsi @@ -23,9 +23,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 +38,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 */ From 503d4588937b43a10e9d8e3b53c6443f471f2ecc Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 14 Dec 2024 13:06:53 +0100 Subject: [PATCH 030/118] dts: atmel: sam0: Explicity disable nodes When running tests on sam0 platform was detected that pinctrl for ADC were not defined for some boards. To force an error at build time nodes should be explicity disabled. This explicity disable nodes on devicetree that require some user configuration. In addition, the adc feature were excluded in some boards and samr21-xpro was correct updated. Signed-off-by: Gerson Fernando Budke (cherry picked from commit 162f728787976ed483886242915e8584ec79df41) --- boards/atmel/sam0/samd20_xpro/samd20_xpro.yaml | 4 +++- boards/atmel/sam0/samd21_xpro/samd21_xpro.yaml | 2 +- .../atmel/sam0/samr21_xpro/samr21_xpro-pinctrl.dtsi | 8 +++++++- boards/atmel/sam0/samr21_xpro/samr21_xpro.dts | 6 ++++++ boards/atmel/sam0/samr21_xpro/samr21_xpro.yaml | 3 ++- dts/arm/atmel/samc2x.dtsi | 4 ++++ dts/arm/atmel/samd20.dtsi | 3 +++ dts/arm/atmel/samd21.dtsi | 5 +++++ dts/arm/atmel/samd2x.dtsi | 1 + dts/arm/atmel/samd5x.dtsi | 12 ++++++++++++ dts/arm/atmel/saml21.dtsi | 4 ++++ dts/arm/atmel/saml2x.dtsi | 3 +++ dts/arm/atmel/samr21.dtsi | 3 +++ 13 files changed, 54 insertions(+), 4 deletions(-) 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/dts/arm/atmel/samc2x.dtsi b/dts/arm/atmel/samc2x.dtsi index 3c61d1d664a33..6709b456db16a 100644 --- a/dts/arm/atmel/samc2x.dtsi +++ b/dts/arm/atmel/samc2x.dtsi @@ -112,6 +112,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x41006000 0x50>; interrupts = <7 0>; + status = "disabled"; #dma-cells = <2>; }; @@ -173,6 +174,7 @@ interrupts = <17 0>; clocks = <&gclk 28>, <&mclk 0x1c 9>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -184,6 +186,7 @@ interrupts = <18 0>; clocks = <&gclk 28>, <&mclk 0x1c 10>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -195,6 +198,7 @@ interrupts = <19 0>; clocks = <&gclk 29>, <&mclk 0x1c 11>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <2>; counter-size = <16>; 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 fa24b4b75b762..3466b0ddd9a93 100644 --- a/dts/arm/atmel/samd21.dtsi +++ b/dts/arm/atmel/samd21.dtsi @@ -25,6 +25,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x41004800 0x50>; interrupts = <6 0>; + status = "disabled"; #dma-cells = <2>; }; @@ -35,6 +36,7 @@ interrupts = <21 0>; clocks = <&gclk 0x1d>, <&pm 0x20 14>; clock-names = "GCLK", "PM"; + status = "disabled"; }; tcc0: tcc@42002000 { @@ -43,6 +45,7 @@ interrupts = <15 0>; clocks = <&gclk 26>, <&pm 0x20 8>; clock-names = "GCLK", "PM"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -54,6 +57,7 @@ interrupts = <16 0>; clocks = <&gclk 26>, <&pm 0x20 9>; clock-names = "GCLK", "PM"; + status = "disabled"; channels = <2>; counter-size = <24>; @@ -65,6 +69,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 4e13589ec7d86..f0ffe58973468 100644 --- a/dts/arm/atmel/samd2x.dtsi +++ b/dts/arm/atmel/samd2x.dtsi @@ -196,6 +196,7 @@ adc: adc@42004000 { compatible = "atmel,sam0-adc"; reg = <0x42004000 0x2B>; + status = "disabled"; #io-channel-cells = <1>; diff --git a/dts/arm/atmel/samd5x.dtsi b/dts/arm/atmel/samd5x.dtsi index 16bc968151281..29d9c4474e4a7 100644 --- a/dts/arm/atmel/samd5x.dtsi +++ b/dts/arm/atmel/samd5x.dtsi @@ -125,6 +125,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x4100A000 0x50>; interrupts = <31 0>, <32 0>, <33 0>, <34 0>, <35 0>; + status = "disabled"; #dma-cells = <2>; }; @@ -315,6 +316,7 @@ interrupt-names = "overrun", "resrdy"; clocks = <&gclk 40>, <&mclk 0x20 7>; clock-names = "GCLK", "MCLK"; + status = "disabled"; #io-channel-cells = <1>; @@ -336,6 +338,7 @@ interrupt-names = "overrun", "resrdy"; clocks = <&gclk 41>, <&mclk 0x20 8>; clock-names = "GCLK", "MCLK"; + status = "disabled"; #io-channel-cells = <1>; @@ -356,6 +359,7 @@ interrupts = <107 0>; clocks = <&gclk 9>, <&mclk 0x14 14>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; tc2: tc@4101a000 { @@ -364,6 +368,7 @@ interrupts = <109 0>; clocks = <&gclk 26>, <&mclk 0x18 13>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; tc4: tc@42001400 { @@ -372,6 +377,7 @@ interrupts = <111 0>; clocks = <&gclk 30>, <&mclk 0x1c 5>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; tc6: tc@43001400 { @@ -380,6 +386,7 @@ interrupts = <113 0>; clocks = <&gclk 39>, <&mclk 0x20 5>; clock-names = "GCLK", "MCLK"; + status = "disabled"; }; tcc0: tcc@41016000 { @@ -389,6 +396,7 @@ <90 0>, <91 0>; clocks = <&gclk 25>, <&mclk 0x18 11>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <6>; counter-size = <24>; @@ -400,6 +408,7 @@ 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>; @@ -411,6 +420,7 @@ 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>; @@ -422,6 +432,7 @@ interrupts = <101 0>, <102 0>, <103 0>; clocks = <&gclk 29>, <&mclk 0x1c 4>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <2>; counter-size = <16>; @@ -433,6 +444,7 @@ 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/saml21.dtsi b/dts/arm/atmel/saml21.dtsi index e41541750f1d9..cfdc274dc8ff8 100644 --- a/dts/arm/atmel/saml21.dtsi +++ b/dts/arm/atmel/saml21.dtsi @@ -21,6 +21,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x44000400 0x50>; interrupts = <5 0>; + status = "disabled"; #dma-cells = <2>; }; @@ -31,6 +32,7 @@ interrupts = <14 0>; clocks = <&gclk 25>, <&mclk 0x1c 5>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -42,6 +44,7 @@ interrupts = <15 0>; clocks = <&gclk 25>, <&mclk 0x1c 6>; clock-names = "GCLK", "MCLK"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -53,6 +56,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 47ad26b78c2e3..4b58f1f4128a3 100644 --- a/dts/arm/atmel/saml2x.dtsi +++ b/dts/arm/atmel/saml2x.dtsi @@ -91,6 +91,7 @@ compatible = "atmel,sam0-dmac"; reg = <0x44000400 0x400>; interrupts = <5 0>; + status = "disabled"; #dma-cells = <2>; }; @@ -146,6 +147,7 @@ tc4: tc@43000800 { compatible = "atmel,sam0-tc32"; reg = <0x43000800 0x34>; + status = "disabled"; }; pinctrl: pinctrl@40002800 { @@ -188,6 +190,7 @@ adc: adc@43000c00 { compatible = "atmel,sam0-adc"; reg = <0x43000c00 0x30>; + status = "disabled"; #io-channel-cells = <1>; diff --git a/dts/arm/atmel/samr21.dtsi b/dts/arm/atmel/samr21.dtsi index ddf505ee798cd..f099f8a72082d 100644 --- a/dts/arm/atmel/samr21.dtsi +++ b/dts/arm/atmel/samr21.dtsi @@ -54,6 +54,7 @@ interrupts = <15 0>; clocks = <&gclk 26>, <&pm 0x20 8>; clock-names = "GCLK", "PM"; + status = "disabled"; channels = <4>; counter-size = <24>; @@ -65,6 +66,7 @@ interrupts = <16 0>; clocks = <&gclk 26>, <&pm 0x20 9>; clock-names = "GCLK", "PM"; + status = "disabled"; channels = <2>; counter-size = <24>; @@ -76,6 +78,7 @@ interrupts = <17 0>; clocks = <&gclk 27>, <&pm 0x20 10>; clock-names = "GCLK", "PM"; + status = "disabled"; channels = <2>; counter-size = <16>; From ba39f63957d571b8509e8e07e577b9bf2f4a3987 Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 14 Dec 2024 13:35:59 +0100 Subject: [PATCH 031/118] dts: atmel: sam0: Fix aliases and chosen nodes Reorder and add missing aliases and chosen nodes. Signed-off-by: Gerson Fernando Budke (cherry picked from commit 748bbd012b262d66308f7f8571c1179a9f5ced10) --- dts/arm/atmel/samc21.dtsi | 2 ++ dts/arm/atmel/samc2x.dtsi | 30 +++++++++++++------------- dts/arm/atmel/samd21.dtsi | 4 ++++ dts/arm/atmel/samd2x.dtsi | 29 ++++++++++++------------- dts/arm/atmel/samd5x.dtsi | 45 ++++++++++++++++++--------------------- dts/arm/atmel/saml21.dtsi | 6 ++++++ dts/arm/atmel/saml2x.dtsi | 14 ++++++++++++ dts/arm/atmel/samr21.dtsi | 4 ++++ dts/arm/atmel/samr34.dtsi | 2 ++ 9 files changed, 82 insertions(+), 54 deletions(-) diff --git a/dts/arm/atmel/samc21.dtsi b/dts/arm/atmel/samc21.dtsi index 979ca0683468e..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; }; diff --git a/dts/arm/atmel/samc2x.dtsi b/dts/arm/atmel/samc2x.dtsi index 6709b456db16a..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; }; @@ -44,21 +59,6 @@ <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"; diff --git a/dts/arm/atmel/samd21.dtsi b/dts/arm/atmel/samd21.dtsi index 3466b0ddd9a93..c4692ffa9e50b 100644 --- a/dts/arm/atmel/samd21.dtsi +++ b/dts/arm/atmel/samd21.dtsi @@ -9,6 +9,10 @@ / { aliases { tc-6 = &tc6; + + tcc-0 = &tcc0; + tcc-1 = &tcc1; + tcc-2 = &tcc2; }; soc { diff --git a/dts/arm/atmel/samd2x.dtsi b/dts/arm/atmel/samd2x.dtsi index f0ffe58973468..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; }; @@ -44,21 +58,6 @@ <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"; diff --git a/dts/arm/atmel/samd5x.dtsi b/dts/arm/atmel/samd5x.dtsi index 29d9c4474e4a7..12593682eaec7 100644 --- a/dts/arm/atmel/samd5x.dtsi +++ b/dts/arm/atmel/samd5x.dtsi @@ -11,30 +11,6 @@ #include / { - chosen { - 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>; - }; - }; - }; - aliases { adc-0 = &adc0; adc-1 = &adc1; @@ -69,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 { diff --git a/dts/arm/atmel/saml21.dtsi b/dts/arm/atmel/saml21.dtsi index cfdc274dc8ff8..bea13b3267b29 100644 --- a/dts/arm/atmel/saml21.dtsi +++ b/dts/arm/atmel/saml21.dtsi @@ -7,6 +7,12 @@ #include / { + aliases { + tcc-0 = &tcc0; + tcc-1 = &tcc1; + tcc-2 = &tcc2; + }; + soc { usb0: usb@41000000 { compatible = "atmel,sam0-usb"; diff --git a/dts/arm/atmel/saml2x.dtsi b/dts/arm/atmel/saml2x.dtsi index 4b58f1f4128a3..43fe94dd82ac6 100644 --- a/dts/arm/atmel/saml2x.dtsi +++ b/dts/arm/atmel/saml2x.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; }; diff --git a/dts/arm/atmel/samr21.dtsi b/dts/arm/atmel/samr21.dtsi index f099f8a72082d..774f42a18bcb3 100644 --- a/dts/arm/atmel/samr21.dtsi +++ b/dts/arm/atmel/samr21.dtsi @@ -9,6 +9,10 @@ / { aliases { port-c = &portc; + + tcc-0 = &tcc0; + tcc-1 = &tcc1; + tcc-2 = &tcc2; }; soc { diff --git a/dts/arm/atmel/samr34.dtsi b/dts/arm/atmel/samr34.dtsi index 756f501e430c8..351e02bb1e1d0 100644 --- a/dts/arm/atmel/samr34.dtsi +++ b/dts/arm/atmel/samr34.dtsi @@ -13,6 +13,8 @@ / { aliases { + port-c = &portc; + lora0 = &lora; }; From 3acaf7a069139bf6bedb72ffb88ac876f859f3fb Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 14 Dec 2024 14:42:48 +0100 Subject: [PATCH 032/118] dts: atmel: saml21: Exclude DMA node The DMA is already defined on the base header. This exclude the duplicated node. Signed-off-by: Gerson Fernando Budke (cherry picked from commit 2e7599eac61abb2feec0741a0106357e013e8f36) --- dts/arm/atmel/saml21.dtsi | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/dts/arm/atmel/saml21.dtsi b/dts/arm/atmel/saml21.dtsi index bea13b3267b29..e6e11dc75d6f9 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 */ @@ -23,15 +24,6 @@ num-bidir-endpoints = <8>; }; - dmac: dmac@44000400 { - compatible = "atmel,sam0-dmac"; - reg = <0x44000400 0x50>; - interrupts = <5 0>; - status = "disabled"; - - #dma-cells = <2>; - }; - tcc0: tcc@42001400 { compatible = "atmel,sam0-tcc"; reg = <0x42001400 0x80>; From ca7eba2f11b0a036d797d9f0affe435b3088deb4 Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 14 Dec 2024 14:45:06 +0100 Subject: [PATCH 033/118] dts: atmel: saml2x: Define USB node The saml2x series provide USB to all SoC series. This moves the USB node from saml21.dtsi to the base file saml2x.dtsi. Signed-off-by: Gerson Fernando Budke (cherry picked from commit 34fc01e0089620e340a1bc9cc9f76795f87acd01) --- dts/arm/atmel/saml21.dtsi | 9 --------- dts/arm/atmel/saml2x.dtsi | 10 ++++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dts/arm/atmel/saml21.dtsi b/dts/arm/atmel/saml21.dtsi index e6e11dc75d6f9..6e015b5772cc9 100644 --- a/dts/arm/atmel/saml21.dtsi +++ b/dts/arm/atmel/saml21.dtsi @@ -15,15 +15,6 @@ }; soc { - usb0: usb@41000000 { - compatible = "atmel,sam0-usb"; - reg = <0x41000000 0x1000>; - interrupts = <6 0>; - status = "disabled"; - - num-bidir-endpoints = <8>; - }; - tcc0: tcc@42001400 { compatible = "atmel,sam0-tcc"; reg = <0x42001400 0x80>; diff --git a/dts/arm/atmel/saml2x.dtsi b/dts/arm/atmel/saml2x.dtsi index 43fe94dd82ac6..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 */ @@ -229,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>; + }; }; }; From 578251beac552b07bfaefdcbd11fb7244edf830b Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 14 Dec 2024 14:47:50 +0100 Subject: [PATCH 034/118] dts: atmel: samr21: Use samd21 as base The samr21 is a samd21 with a builtin at86rf233 radio. Use the samd21 as base for these SoC and drop all duplicated nodes. Signed-off-by: Gerson Fernando Budke (cherry picked from commit 01fc0a750a6ecf8fec64d22908b1619dda7249f6) --- dts/arm/atmel/samr21.dtsi | 109 +------------------------------------- 1 file changed, 2 insertions(+), 107 deletions(-) diff --git a/dts/arm/atmel/samr21.dtsi b/dts/arm/atmel/samr21.dtsi index 774f42a18bcb3..85686c1d37bc6 100644 --- a/dts/arm/atmel/samr21.dtsi +++ b/dts/arm/atmel/samr21.dtsi @@ -1,38 +1,18 @@ /* * Copyright (c) 2019 Benjamin Valentin + * Copyright (c) 2024 Gerson Fernando Budke * * SPDX-License-Identifier: Apache-2.0 */ -#include +#include / { aliases { port-c = &portc; - - tcc-0 = &tcc0; - tcc-1 = &tcc1; - tcc-2 = &tcc2; }; soc { - usb0: usb@41005000 { - compatible = "atmel,sam0-usb"; - reg = <0x41005000 0x1000>; - interrupts = <7 0>; - status = "disabled"; - - 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>; @@ -51,90 +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"; - status = "disabled"; - - 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"; - status = "disabled"; - - 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"; - status = "disabled"; - - 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"; -}; From 8abda1d12f8407ccba72c6bb04433bd0bf98abb0 Mon Sep 17 00:00:00 2001 From: Djordje Nedic Date: Wed, 11 Dec 2024 20:56:20 +0100 Subject: [PATCH 035/118] fs: littlefs: Fix cache and lookahead size checks This fixes an issue where wrong values were checked against block device defaults. Kconfig values are used when no filesystem config values are provided, and the buffers are sized according to the Kconfig values, but the checks were only performed against filesystem config variables. Signed-off-by: Djordje Nedic (cherry picked from commit 2750492e86a078ef28506b4fdc33c0b224d68a40) --- subsys/fs/littlefs_fs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; From d8ab599ecf6f7c687e17b39722cef07d7f251b58 Mon Sep 17 00:00:00 2001 From: DEVER Emiel Date: Thu, 12 Dec 2024 09:50:58 +0100 Subject: [PATCH 036/118] fs: ext2: Fix ext2 read buffer overflow Keep track of the amount of bytes read so no buffer overflow occurs. Signed-off-by: DEVER Emiel (cherry picked from commit 336c650646581fd74fe22c0db0c6e9a702e95b5b) --- subsys/fs/ext2/ext2_impl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subsys/fs/ext2/ext2_impl.c b/subsys/fs/ext2/ext2_impl.c index f9e4d52769900..201e8cd92cbbc 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 -= read; offset += to_read; } From 6dc51290408e8791140932f05dd341a0830c7838 Mon Sep 17 00:00:00 2001 From: Marcio Ribeiro Date: Fri, 13 Dec 2024 10:13:22 -0300 Subject: [PATCH 037/118] drivers: uart: esp32: reset tx fifo during driver init Resets uart tx fifo during driver initialization to have a well defined initial condition mainly preventing unwanted characters being sent Signed-off-by: Marcio Ribeiro (cherry picked from commit f0516ead27f8af52463b68348588622f374292a0) --- drivers/serial/uart_esp32.c | 1 + 1 file changed, 1 insertion(+) 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: From 1d445685bfa738aca7dd2e0df3c0670ca683dc4b Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 9 Dec 2024 13:26:58 +0200 Subject: [PATCH 038/118] net: dns: Fix the debug print when dispatcher fails Depending on DNS type, print the output (mDNS vs DNS) correctly. Signed-off-by: Jukka Rissanen (cherry picked from commit efcfcfe29243c7235f7212dc461cdbcdaa0894dc) --- subsys/net/lib/dns/resolve.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsys/net/lib/dns/resolve.c b/subsys/net/lib/dns/resolve.c index 040751e622c86..59a20f865908c 100644 --- a/subsys/net/lib/dns/resolve.c +++ b/subsys/net/lib/dns/resolve.c @@ -477,7 +477,8 @@ 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); + NET_DBG("Cannot register dispatcher for %s (%d)", + ctx->servers[i].is_mdns ? "mDNS" : "DNS", ret); goto fail; } From fc639b6b27a2675dfd1b079935807e9cbb51ff49 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 9 Dec 2024 13:29:22 +0200 Subject: [PATCH 039/118] net: dns: Avoid errors when DNS dispatcher is already registered Skip error prints and extra DNS events if DNS dispatcher was already registered. Signed-off-by: Jukka Rissanen (cherry picked from commit c1103315076bdd1df0f641f960a842f319f73dd6) --- subsys/net/lib/dns/resolve.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subsys/net/lib/dns/resolve.c b/subsys/net/lib/dns/resolve.c index 59a20f865908c..cf5416549b5fb 100644 --- a/subsys/net/lib/dns/resolve.c +++ b/subsys/net/lib/dns/resolve.c @@ -477,6 +477,10 @@ 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) { + if (ret == -EALREADY) { + goto skip_event; + } + NET_DBG("Cannot register dispatcher for %s (%d)", ctx->servers[i].is_mdns ? "mDNS" : "DNS", ret); goto fail; @@ -491,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 From d58e1ea145712ada1023faa4ffb1f0366d393114 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 9 Dec 2024 14:57:06 +0200 Subject: [PATCH 040/118] net: dns: Close socket service properly from dispatcher We need to close the socket service context when dispatcher is unregistered. Fixes #82652 Signed-off-by: Jukka Rissanen (cherry picked from commit da148ab3bca534a624c3fd06d7e2aa5981ffb976) --- subsys/net/lib/dns/dispatcher.c | 5 +++++ 1 file changed, 5 insertions(+) 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; From 763665dcda1c495272d798e442074cdeab7b07c1 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 9 Dec 2024 15:04:13 +0200 Subject: [PATCH 041/118] tests: net: dns_dispatcher: Add tests for dispatcher Make sure that the socket service is properly unregistered when dispatcher is unregistered. Signed-off-by: Jukka Rissanen (cherry picked from commit d98fe736848a0c2157085959975035354181a68e) --- tests/net/lib/dns_dispatcher/CMakeLists.txt | 9 + tests/net/lib/dns_dispatcher/prj.conf | 25 +++ tests/net/lib/dns_dispatcher/src/main.c | 203 ++++++++++++++++++++ tests/net/lib/dns_dispatcher/testcase.yaml | 13 ++ 4 files changed, 250 insertions(+) create mode 100644 tests/net/lib/dns_dispatcher/CMakeLists.txt create mode 100644 tests/net/lib/dns_dispatcher/prj.conf create mode 100644 tests/net/lib/dns_dispatcher/src/main.c create mode 100644 tests/net/lib/dns_dispatcher/testcase.yaml 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 From 3f4037b951f07d929f292e1f064cac7332199f55 Mon Sep 17 00:00:00 2001 From: Erik Tamlin Date: Tue, 17 Dec 2024 17:02:00 +0100 Subject: [PATCH 042/118] manifest: update percepio Update the percepio module to use TraceRecorder v4.10.2 Signed-off-by: Erik Tamlin (cherry picked from commit 91b21563987b72cacfd7a23a778d999d5d56bcf3) --- west.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/west.yml b/west.yml index 87657ebf6df36..881b041aeaf10 100644 --- a/west.yml +++ b/west.yml @@ -310,7 +310,7 @@ manifest: path: modules/lib/openthread - name: percepio path: modules/debug/percepio - revision: b68d17993109b9bee6b45dc8c9794e7b7bce236d + revision: 0d44033c744978ca2505a06640b4f6964c5411e6 groups: - debug - name: picolibc From c861286bc0a407b0061955d3f151120acd01a36d Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Mon, 2 Dec 2024 12:23:53 -0600 Subject: [PATCH 043/118] drivers: flash: flash_mcux_flexspi_nor: check all 3 bytes of JEDEC ID The FlexSPI NOR driver should verify all 3 bytes of the JEDEC ID match the expected value before attempting to use a custom LUT table with a flash chip. This reduces the odds that an incompatible LUT will be used with a flash chip, as some flash chips may share the same first byte of their device ID but not be compatible with the custom LUT table. Signed-off-by: Daniel DeGrasse (cherry picked from commit c12030acb9d5815af290581099ba0b4b05a8910c) --- drivers/flash/flash_mcux_flexspi_nor.c | 34 +++++++++----------------- 1 file changed, 12 insertions(+), 22 deletions(-) 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); From 72a1c809df57526d1f82ee66d33df1b6fd0f3b78 Mon Sep 17 00:00:00 2001 From: Thomas Schranz Date: Fri, 13 Dec 2024 10:16:08 +0100 Subject: [PATCH 044/118] soc: sam0: samd5x: xosc32 configurable startup time Adds Kconfig option to configure the startup time of the external 32KHz crystal oscillator. Signed-off-by: Thomas Schranz (cherry picked from commit cd20154bc7f3e160edba6efb6c48dca55cbdb44e) --- soc/atmel/sam0/common/Kconfig.samd5x | 8 ++++++++ soc/atmel/sam0/common/soc_samd5x.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) 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) { } From 7d2ac022543dd98a2923c6e6a65d272ed2136356 Mon Sep 17 00:00:00 2001 From: Derek Snell Date: Tue, 31 Dec 2024 09:19:33 -0500 Subject: [PATCH 045/118] drivers: flash: soc_flash_mcux: remove CMD_MARGIN_CHECK The CMD_BLANK_CHECK can return errors when the flash is readable, and should only be used after programming, not in is_area_readable(). From the LPC55S69 datasheet: "As cells age and lose charge, a correctly programmed address will fail this check, while still being able to be read successfully for the remaining duration of the data retention time." Signed-off-by: Derek Snell (cherry picked from commit 88b9cb6efcb18cd91bbcbb440f455724a872c6b9) --- drivers/flash/soc_flash_mcux.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) 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); From fff6ad389e1d387d1b6d17587a979ce19661b588 Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Mon, 30 Dec 2024 10:26:20 +0100 Subject: [PATCH 046/118] drivers: entropy: fix native_posix driver for more than 3 byte requests Fix the native_posix fake entropy driver for more than 3 byte requests, and specially for native_sim//64 builds. The host random() provides a number between 0 and 2**31-1 (INT_MAX), so bit 32 was always 0. So when filling a buffer with more than 3 bytes we would be filling each 4th byte with a byte which always had its MSbit as 0. For LP64 native_sim//64 builds, this was even worse, as the driver had another bug where we assumed random() returned the whole long filled, and therefore all 4 upper bytes would be 0. Signed-off-by: Alberto Escolar Piedras (cherry picked from commit b3407f04e7a98f2c24feb03ec436f3f3f80a5dea) --- drivers/entropy/fake_entropy_native_posix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; From de825415d6b539863726bcbba8937bdc2b44b17e Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Mon, 30 Dec 2024 14:31:56 +0100 Subject: [PATCH 047/118] tests/subsys/lorawan/frag_decoder: Change random seed These tests are quite sensitive to the exact random sequence. After a change of the native_sim entropy generation 2 of them started failing. Let's set a random seed which avoids the failure. Signed-off-by: Alberto Escolar Piedras (cherry picked from commit 64d4fcd8cb601f75a7293112722a149f2d282421) --- tests/subsys/lorawan/frag_decoder/testcase.yaml | 2 ++ 1 file changed, 2 insertions(+) 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" From 7d59e9f11e76c39ae25fe269702fff18cf5d0c25 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Tue, 24 Dec 2024 08:50:45 +0100 Subject: [PATCH 048/118] drivers: spi: spi_mcux_ecspi: Ignore chip select channel with cs-gpios The internal chip selects are limited to 4, however when using GPIOS does not pose this limitation. Also set internal channel to 0 if GPIOS are used. Signed-off-by: Pieter De Gendt (cherry picked from commit 7250e987e5d6b970a044506ea9c095e74abc55dd) --- drivers/spi/spi_mcux_ecspi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi_mcux_ecspi.c b/drivers/spi/spi_mcux_ecspi.c index dfdfbcb4f670d..6bb1e2bffa796 100644 --- a/drivers/spi/spi_mcux_ecspi.c +++ b/drivers/spi/spi_mcux_ecspi.c @@ -163,7 +163,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 +181,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 From 2f0e67fee81dde9926e0ee47cbf21947dbea6e59 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Tue, 24 Dec 2024 08:52:54 +0100 Subject: [PATCH 049/118] drivers: spi: spi_mcux_ecspi: Fix data size when using 16/32 bit transfers The data size is set using a burst length, the data size for 8/16/32 is always 1 in those cases. Signed-off-by: Pieter De Gendt (cherry picked from commit 0e8aed7393596eda3949cb4973caefe2ef2b3ab9) --- drivers/spi/spi_mcux_ecspi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi_mcux_ecspi.c b/drivers/spi/spi_mcux_ecspi.c index 6bb1e2bffa796..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) { From 58b2b82b44da97ec7963eb7d8d12c2ab4707755e Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Thu, 19 Dec 2024 09:40:48 +0100 Subject: [PATCH 050/118] cmake: use GLOBAL property instead TARGET properties for scoping Targets are not available in script mode. To support the Zephyr scoping feature used by snippets and yaml module then this commit moves from using custom targets to use GLOBAL properties for scopes. A scope property is prefixed with `:` to avoid naming collisions. A `scope:` global property is used to track created scopes. Tracking valid scopes ensure that properties are only set on known scopes and thus catches typos / naming errors. Add zephyr_scope_exists() and zephyr_get_scoped() to abstract the implementation details of the scoped property retrieval and refactor current code to use them. Signed-off-by: Torsten Rasmussen Signed-off-by: Luca Burelli (cherry picked from commit 4e29a35b22d9370de1cc3d885f176c4ea6e7d4d8) --- cmake/modules/extensions.cmake | 66 +++++++++++++++++++++------ cmake/modules/yaml.cmake | 17 +++---- tests/cmake/zephyr_get/CMakeLists.txt | 3 +- 3 files changed, 64 insertions(+), 22 deletions(-) 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/tests/cmake/zephyr_get/CMakeLists.txt b/tests/cmake/zephyr_get/CMakeLists.txt index a6516bfba735c..c76d910e55406 100644 --- a/tests/cmake/zephyr_get/CMakeLists.txt +++ b/tests/cmake/zephyr_get/CMakeLists.txt @@ -490,7 +490,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() From adfc5b38636e7f7489eab6befbecb5df69c858cb Mon Sep 17 00:00:00 2001 From: Luca Burelli Date: Mon, 16 Dec 2024 16:47:22 +0100 Subject: [PATCH 051/118] tests: cmake: run zephyr_get() tests in script mode Re-run the zephyr_get() testsuite in script mode after the project mode testsuite has been executed. This is to ensure that the zephyr_get() function works correctly in script mode as well. Signed-off-by: Luca Burelli (cherry picked from commit d492c849a310562446803f78b7ca686b23a7d422) --- tests/cmake/zephyr_get/CMakeLists.txt | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/cmake/zephyr_get/CMakeLists.txt b/tests/cmake/zephyr_get/CMakeLists.txt index c76d910e55406..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() @@ -584,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() From 58491c40c0961d2993b237b5ae7f9194d4cc9917 Mon Sep 17 00:00:00 2001 From: Mayank Narang Date: Tue, 21 Jan 2025 23:51:32 +0530 Subject: [PATCH 052/118] drivers: sensor: lis2de12: fix read accel via spi The lis2de12 sensor driver spi interface was calling spi read api. This leads to a single byte operation on reading acceleration data which is a multi byte operation. Fix it by adding a call to spi read incr api instead. Added a length check to handle both single and multi byte read properly. Signed-off-by: Mayank Narang (cherry picked from commit 7b062f5b0916ebc32e9ec64147a07198d5246223) --- drivers/sensor/st/lis2de12/lis2de12.c | 2 +- drivers/sensor/st/stmemsc/stmemsc_spi.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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..568c3a84aae50 100644 --- a/drivers/sensor/st/stmemsc/stmemsc_spi.c +++ b/drivers/sensor/st/stmemsc/stmemsc_spi.c @@ -63,7 +63,10 @@ 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); } From a1eb85002ef299f989b47a11c1662c9801d2a277 Mon Sep 17 00:00:00 2001 From: Mayank Narang Date: Wed, 22 Jan 2025 22:50:43 +0530 Subject: [PATCH 053/118] drivers: sensor: lis2de12: add length check in spi write incr routine Added a length check in the spi write incr routine to handle both single and multi byte write operations properly. Signed-off-by: Mayank Narang (cherry picked from commit cb608812cfae2702bf244a77d945af07424cef2f) --- drivers/sensor/st/stmemsc/stmemsc_spi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/sensor/st/stmemsc/stmemsc_spi.c b/drivers/sensor/st/stmemsc/stmemsc_spi.c index 568c3a84aae50..66421f17ca000 100644 --- a/drivers/sensor/st/stmemsc/stmemsc_spi.c +++ b/drivers/sensor/st/stmemsc/stmemsc_spi.c @@ -73,6 +73,9 @@ int stmemsc_spi_read_incr(const struct spi_dt_spec *stmemsc, 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); } From 5fe9a7e6f9c732b1d833987708d6d81803d4ed62 Mon Sep 17 00:00:00 2001 From: Tomislav Milkovic Date: Tue, 21 Jan 2025 14:57:16 +0100 Subject: [PATCH 054/118] drivers: can: can_tcan4x5x: fix compiler build warning/error Fix compiler warning when optional property reset-gpios is not supplied in the ti,tcan4x5x-compatible device tree node Signed-off-by: Tomislav Milkovic (cherry picked from commit fb98387f4d67fcb60de064ea2d15bee4e0fdf7e9) --- drivers/can/can_tcan4x5x.c | 2 ++ 1 file changed, 2 insertions(+) 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); From 98a1a1510cac1e37930bc43f30ef02502a8861ea Mon Sep 17 00:00:00 2001 From: Jakub Rzeszutko Date: Tue, 21 Jan 2025 12:33:06 +0100 Subject: [PATCH 055/118] shell: add Kconfig option for configurable autoflush behavior Introduced a new Kconfig option `SHELL_PRINTF_AUTOFLUSH` to allow configuring the autoflush behavior of shell printing functions. Updated `Z_SHELL_FPRINTF_DEFINE` to use the `CONFIG_SHELL_PRINTF_AUTOFLUSH` setting instead of hardcoding the autoflush behavior to `true`. Signed-off-by: Jakub Rzeszutko (cherry picked from commit 8991b954bc8c1941ed52a075ce354e23545e61bc) --- include/zephyr/shell/shell.h | 2 +- subsys/shell/Kconfig | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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/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) From 4a1ffd8519129e8c8c8ea6a6958cab728b309877 Mon Sep 17 00:00:00 2001 From: Jakub Rzeszutko Date: Tue, 21 Jan 2025 12:36:52 +0100 Subject: [PATCH 056/118] shell: fix unsafe API calls and add configurable autoflush behavior Fixes an issue where the shell API could block indefinitely when called from threads other than the shell's processing thread, especially when the transport (e.g. USB CDC ACM) was unavailable or inactive. Replaced `k_mutex_lock` calls with an indefinite timeout (`K_FOREVER`) by using a fixed timeout (`K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)`) in shell API functions to prevent indefinite blocking. Link: https://github.com/zephyrproject-rtos/zephyr/issues/84274 Signed-off-by: Jakub Rzeszutko (cherry picked from commit b0a0febe589662bddb4bfe40c0faaf5795812fb1) --- subsys/shell/shell.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) 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); From 13e7d6501fd336421a60e10c847c5b4ad0ad3d2b Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Sat, 18 Jan 2025 08:06:40 +0100 Subject: [PATCH 057/118] Bluetooth: Controller: Fix uninitialized is_aborted in conn done event Fix uninitialized is_aborted in connection done event. Relates to commit cadef5a64fa5 ("Bluetooth: Controller: Introduce BT_CTLR_PERIPHERAL_RESERVE_MAX"). Signed-off-by: Vinayak Kariappa Chettimada (cherry picked from commit f3e398d64c451ea2b5b4fa4041655387b78caf5f) --- subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c | 2 ++ 1 file changed, 2 insertions(+) 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 */ From 5080ba8b0c3af43cd1b5c62cb955f624f099adb2 Mon Sep 17 00:00:00 2001 From: Chen Shu <751541594@qq.com> Date: Mon, 6 Jan 2025 09:35:16 +0800 Subject: [PATCH 058/118] fs: ext2: Fix nbytes_to_read calculation in ext2_inode_read() Fix incorrect nbytes_to_read calculation in ext2_inode_read() function. Previously nbytes_to_read was decremented by read value which caused incorrect calculation of bytes to read in subsequent iterations. Now nbytes_to_read is decremented by to_read value which represents the actual number of bytes read in current iteration. This fixes potential data corruption issues when reading files from ext2 filesystem. Signed-off-by: Chen Shu <751541594@qq.com> (cherry picked from commit 5a5f05ba4ef792ba2c1ef00c5cdfed1da2ec782e) --- subsys/fs/ext2/ext2_impl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/fs/ext2/ext2_impl.c b/subsys/fs/ext2/ext2_impl.c index 201e8cd92cbbc..507e72f971c26 100644 --- a/subsys/fs/ext2/ext2_impl.c +++ b/subsys/fs/ext2/ext2_impl.c @@ -630,7 +630,7 @@ ssize_t ext2_inode_read(struct ext2_inode *inode, void *buf, uint32_t offset, si memcpy((uint8_t *)buf + read, inode_current_block_mem(inode) + block_off, to_read); read += to_read; - nbytes_to_read -= read; + nbytes_to_read -= to_read; offset += to_read; } From 0429f17b764a041370110ee36e725f46b72fe42f Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Sat, 11 Jan 2025 13:29:14 -0500 Subject: [PATCH 059/118] sensor: adxl3xx: Move run-time modification of ODR from cfg to data Config struct is constant and attempting to modify it triggers a fault. Signed-off-by: Luis Ubieda (cherry picked from commit 5a9ff03c21dc2316a2c92cc2456586e480ec7bf8) --- drivers/sensor/adi/adxl345/adxl345.c | 4 ++-- drivers/sensor/adi/adxl345/adxl345.h | 1 + drivers/sensor/adi/adxl345/adxl345_stream.c | 2 +- drivers/sensor/adi/adxl372/adxl372.c | 4 ++-- drivers/sensor/adi/adxl372/adxl372.h | 1 + drivers/sensor/adi/adxl372/adxl372_stream.c | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/sensor/adi/adxl345/adxl345.c b/drivers/sensor/adi/adxl345/adxl345.c index d5f07bad26585..3403302d7a5b1 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; diff --git a/drivers/sensor/adi/adxl345/adxl345.h b/drivers/sensor/adi/adxl345/adxl345.h index 4fc55d307c1a3..d0ad0a0a2c601 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; 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) || From 50c415d3ee6a79da828d459186907cf38cf5f18f Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 28 Jan 2025 14:08:11 +0200 Subject: [PATCH 060/118] net: socket: Release packets in accepted socket in close If we have received data to the accepted socket, then release those before removing the accepted socket. This is a rare event as it requires that we get multiple simultaneous connections and there is a failure before the socket accept is called by the application. For example one such scenario is when HTTP server receives multiple connection attempts at the same time, and the server poll fails before socket accept is called. This leads to buffer leak as the socket close is not called for the accepted socket because the accepted is not yet created from application point of view. The solution is to flush the received queue of the accepted socket before removing the actual accepted socket. Fixes #84538 Signed-off-by: Jukka Rissanen (cherry picked from commit 535e70a298ce5da1660b9e81b874992c65f1871c) --- subsys/net/lib/sockets/sockets_inet.c | 5 +++++ 1 file changed, 5 insertions(+) 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); From 2b884a703ee0f649d6a0747636a5ff4989acfa86 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Tue, 31 Dec 2024 12:46:00 -0500 Subject: [PATCH 061/118] sensor: shell: Allow individual axis data to be processed For the supported channels, instead of just allowing 3-axis data being printed out, allow individual channels to be processed (e.g: accel_x, gyro_y, etc). Signed-off-by: Luis Ubieda (cherry picked from commit 36dfea121d9fb1b4476a9d95f5fba445949c7358) --- drivers/sensor/sensor_shell.c | 17 ----------------- 1 file changed, 17 deletions(-) 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", From 212d0c50f1db0500ff7bb050cc3c7918e6e55b9a Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Tue, 31 Dec 2024 12:48:06 -0500 Subject: [PATCH 062/118] sensor: default_rtio_sensor: fix: Treat individual axis data as q31_t Instead of assuming that an individual axis must contain all data-values. Additionally, for determining that there's XYZ data, all three channels must be present in the header. Signed-off-by: Luis Ubieda (cherry picked from commit 5a1dfc82c3c3d73621038e26e007f0d8fd85ab57) --- drivers/sensor/default_rtio_sensor.c | 69 +++++++++++++--------------- 1 file changed, 32 insertions(+), 37 deletions(-) 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, From c4210d749a8b7f43f2c4f85ce663ef8adcfb773c Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Thu, 2 Jan 2025 15:55:55 -0500 Subject: [PATCH 063/118] tests: sensor: generic_test: Remove special-handling for axis values Since now they're treated as q31 values when individually queried, as opposed to lump them in a triplet. Signed-off-by: Luis Ubieda (cherry picked from commit 19a4261517e951015fd383cf4bc96ab13e9b62a4) --- .../build_all/sensor/src/generic_test.c | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) 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 = From b1631a29132f5106260b0593da40c33617d205a1 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Thu, 2 Jan 2025 16:19:43 -0500 Subject: [PATCH 064/118] samples: sensor:shell: test all channels Loop through all of the channels and make sure that each channel has an output. Changes in patch originally present in #72972. Signed-off-by: Yong Cong Sin Signed-off-by: Luis Ubieda (cherry picked from commit 1e64d7bea1d45d580e62cde661408d597ade4331) --- .../sensor/sensor_shell/pytest/test_sensor_shell.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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') From e397b1b6579043cec484585bbb2d8823034ee93a Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Tue, 19 Nov 2024 09:35:03 +0100 Subject: [PATCH 065/118] drivers: ethernet: stm32: Use MDIO API only if enabled by DTS Not all STM32 series support Zephyr MDIO API yet, while the API is enabled by default. To preserve compatibility, put MDIO API related code under the condition of "st,stm32-mdio" compatible enablement. Signed-off-by: Erwan Gouriou (cherry picked from commit 2d81351517488c1e4ffa9fcc4fe2ea5f7991da54) --- drivers/ethernet/eth_stm32_hal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From 8c516c6d86c888b193839ef568d9973b876245f0 Mon Sep 17 00:00:00 2001 From: Dario Binacchi Date: Fri, 24 Jan 2025 12:57:57 +0100 Subject: [PATCH 066/118] dts: arm: st: re-enable master can gating clock for can2 Commit 57723cf40594 ("dts: arm: st: Refactor DTSI files to use macro"), which replaced raw hex codes by using STM32_CLOCK macro, causes regression in the case of the CAN device where the previous raw value contained more than one bit set to 1. The macro is in fact correct only for values with a single bit set. In all other cases, raw values must continue to be used. Tested on STM32F429I-DISC1 board Fixes: 57723cf40594545bbfc4aa36606ad9a838c4674a Co-authored-by: Michael Trimarchi Signed-off-by: Dario Binacchi (cherry picked from commit 2c3294b079cf084c0f00bd18fb11d18a125cc3bc) --- dts/arm/st/f1/stm32f105.dtsi | 2 +- dts/arm/st/f4/stm32f405.dtsi | 2 +- dts/arm/st/f4/stm32f412.dtsi | 2 +- dts/arm/st/f4/stm32f446.dtsi | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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"; }; From 37321f070251d0e46e5c27ac3d8032866afbca89 Mon Sep 17 00:00:00 2001 From: Mahesh Mahadevan Date: Thu, 21 Nov 2024 09:42:02 -0600 Subject: [PATCH 067/118] boards: frdm_mcxn947: Delete enable of GPIO5 clock There is no bit to enable GPIO5 clock in the clock control register. Signed-off-by: Mahesh Mahadevan (cherry picked from commit bda04093fbec70fb34c93a9bcb336d0a70a02c9b) --- boards/nxp/frdm_mcxn947/board.c | 4 ---- 1 file changed, 4 deletions(-) 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); From 41bafc5dbffe230fa1bf18a5dd059126f3b4871b Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 30 Jan 2025 08:42:03 +0000 Subject: [PATCH 068/118] mgmt: mcumgr: grp: img_mgmt: Fix calling confirm Fixes calling the registered callbacks for image being confirmed if the confirmation was not successful Signed-off-by: Jamie McCrae (cherry picked from commit 98d5aa3792a55859529fab737364322324ccd200) --- .../mgmt/mcumgr/grp/img_mgmt/src/img_mgmt_state.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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: From e104bf9a28926f18c60b7f6ed23b876ab9ad18e3 Mon Sep 17 00:00:00 2001 From: Michal Myczkowski Date: Tue, 19 Nov 2024 13:03:53 +0100 Subject: [PATCH 069/118] dts: atmel sam4s: fix sram address Changed Atmel SAM4S series sram adress from 0x20100000 to 0x20000000. Now it matches what is in Atmel SAM4S Series Datasheet chapter 8 section 1.1 Internal SRAM: https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/Atmel-11100-32-bitCortex-M4-Microcontroller-SAM4S_Datasheet.pdf#G1.1069257 Fixes #85211. Signed-off-by: Michal Myczkowski (cherry picked from commit 3a53845fadef986c91f45472458b3fba1b2727c7) --- dts/arm/atmel/sam4s.dtsi | 2 +- dts/arm/atmel/sam4s16b.dtsi | 4 ++-- dts/arm/atmel/sam4s16c.dtsi | 4 ++-- dts/arm/atmel/sam4s2a.dtsi | 4 ++-- dts/arm/atmel/sam4s2b.dtsi | 4 ++-- dts/arm/atmel/sam4s2c.dtsi | 4 ++-- dts/arm/atmel/sam4s4a.dtsi | 4 ++-- dts/arm/atmel/sam4s4b.dtsi | 4 ++-- dts/arm/atmel/sam4s4c.dtsi | 4 ++-- dts/arm/atmel/sam4s8b.dtsi | 4 ++-- dts/arm/atmel/sam4s8c.dtsi | 4 ++-- dts/arm/atmel/sam4sa16c.dtsi | 4 ++-- 12 files changed, 23 insertions(+), 23 deletions(-) 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)>; }; }; }; From b0e5803c0642150a3f24b2517d64a48abb704881 Mon Sep 17 00:00:00 2001 From: Nazar Palamar Date: Fri, 15 Nov 2024 21:04:34 +0200 Subject: [PATCH 070/118] Infineon: board: Add CONFIG_GPIO to defconfigs Add CONFIG_GPIO from defconfigs for Infineon boards. Revert pull/81377, which affect some ble samples which used GPIO. Signed-off-by: Nazar Palamar (cherry picked from commit 697efe8b5054a98010835a1b49384dfe06467549) --- .../infineon/cy8cproto_062_4343w/cy8cproto_062_4343w_defconfig | 3 +++ boards/infineon/cy8cproto_063_ble/cy8cproto_063_ble_defconfig | 3 +++ boards/infineon/cyw920829m2evk_02/cyw920829m2evk_02_defconfig | 3 +++ 3 files changed, 9 insertions(+) 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 From da7ec06d1294c7dddd52ebc342fee400f2cd6ed2 Mon Sep 17 00:00:00 2001 From: Nazar Palamar Date: Fri, 15 Nov 2024 21:12:13 +0200 Subject: [PATCH 071/118] test: arm: irq: Add overlays files for Infineon boards Changed interrupt priority for GPIO, default 6 is not suitable for for the ZERO_LATENCY_IRQS function used in this test. used in this test. Fixes for problem with arm_irq_zero_latency_levels refer to pull/81377 Signed-off-by: Nazar Palamar (cherry picked from commit 6172092730a88f93696f48983e65a18a9cabff00) --- .../boards/cy8cproto_062_4343w.overlay | 37 +++++++++++++++++++ .../boards/cy8cproto_063_ble.overlay | 33 +++++++++++++++++ .../boards/cyw920829m2evk_02.overlay | 21 +++++++++++ .../boards/cy8cproto_062_4343w.overlay | 37 +++++++++++++++++++ .../boards/cy8cproto_063_ble.overlay | 33 +++++++++++++++++ .../boards/cyw920829m2evk_02.overlay | 21 +++++++++++ 6 files changed, 182 insertions(+) create mode 100644 tests/arch/arm/arm_irq_advanced_features/boards/cy8cproto_062_4343w.overlay create mode 100644 tests/arch/arm/arm_irq_advanced_features/boards/cy8cproto_063_ble.overlay create mode 100644 tests/arch/arm/arm_irq_advanced_features/boards/cyw920829m2evk_02.overlay create mode 100644 tests/arch/arm/arm_irq_zero_latency_levels/boards/cy8cproto_062_4343w.overlay create mode 100644 tests/arch/arm/arm_irq_zero_latency_levels/boards/cy8cproto_063_ble.overlay create mode 100644 tests/arch/arm/arm_irq_zero_latency_levels/boards/cyw920829m2evk_02.overlay 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>; +}; From f001cf6de9c20e4f767bfb49d8e5112c6fbb4444 Mon Sep 17 00:00:00 2001 From: Lingao Meng Date: Tue, 14 Jan 2025 09:54:13 +0800 Subject: [PATCH 072/118] Bluetooth: Mesh: Fix Assert in bt_mesh_adv_unref when messages to a proxy Fixes:https://github.com/zephyrproject-rtos/zephyr/issues/83904 This solution fix is to define a separate variable for the each proxy FIFO. Signed-off-by: Lingao Meng (cherry picked from commit 6371080406eb0b621f7327be77d880d9d707800b) --- subsys/bluetooth/mesh/adv.h | 6 +++++- subsys/bluetooth/mesh/proxy_msg.c | 24 +++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) 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 edee3ad384cde..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); @@ -259,7 +277,7 @@ static void proxy_msg_send_pending(struct k_work *work) return; } - adv = k_fifo_get(&role->pending, K_NO_WAIT); + adv = proxy_queue_get(role); if (!adv) { return; } From c4cb9bd1af80f5e5bbc75c1a766bac8bab648b42 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Wed, 12 Feb 2025 12:46:02 +0100 Subject: [PATCH 073/118] net: ipv6: Fix neighbor registration based on received RA message When Router Advertisement with Source Link-Layer Address option is received, host should register a new neighbor marked as STALE (RFC 4861, ch. 6.3.4). This behavior was broken however, because we always added a new neighbor in INCOMPLETE state before processing SLLA option. In result, the entry was not updated to the STALE state, and a redundant Neighbor Solicitation was sent. Fix this by moving the code responsible for adding neighbor in INCOMPLETE state after options processing, and only as a fallback behavior if the SLLA option was not present. Signed-off-by: Robert Lubos (cherry picked from commit fce53922ef20c242b5f97e7e239078fca0456de4) --- subsys/net/ip/ipv6_nbr.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/subsys/net/ip/ipv6_nbr.c b/subsys/net/ip/ipv6_nbr.c index 86e6b1f2173b1..8f615774b84ec 100644 --- a/subsys/net/ip/ipv6_nbr.c +++ b/subsys/net/ip/ipv6_nbr.c @@ -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) { From e47c933b298d4ba5299883a1a8aa433c1f6ac174 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Wed, 12 Feb 2025 12:55:48 +0100 Subject: [PATCH 074/118] net: ipv6: Send Neighbor Solicitations in PROBE state as unicast According to RFC 4861, ch. 7.3.3: "Upon entering the PROBE state, a node sends a unicast Neighbor Solicitation message to the neighbor using the cached link-layer address." Zephyr's implementation was not compliant with behavior, as instead of sending a unicast probe for reachability confirmation, it was sending a multicast packet instead. This commit fixes it. Signed-off-by: Robert Lubos (cherry picked from commit 8cd213e84612430738ad884400e1f69030fbd514) --- subsys/net/ip/ipv6_nbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/ip/ipv6_nbr.c b/subsys/net/ip/ipv6_nbr.c index 8f615774b84ec..62c53b0c98711 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); From cd85e0ef82576cbc0929062ba13aabf97add182a Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Wed, 12 Feb 2025 13:08:41 +0100 Subject: [PATCH 075/118] net: ipv6: Fix Neighbor Advertisement processing w/o TLLA option According to RFC 4861, ch. 7.2.5: "If the Override flag is set, or the supplied link-layer address is the same as that in the cache, or no Target Link-Layer Address option was supplied, the received advertisement MUST update the Neighbor Cache entry as follows ... If the Solicited flag is set, the state of the entry MUST be set to REACHABLE" This indicates that Target Link-Layer Address option does not need to be present in the received solicited Neighbor Advertisement to confirm reachability. Therefore remove `tllao_offset` variable check from the if condition responsible for updating cache entry. No further changes in the logic are required because if TLLA option is missing, `lladdr_changed` will be set to false, so no LL address will be updated. Signed-off-by: Robert Lubos (cherry picked from commit 02c153c8b1898c21f55f5dc6d890f1534a227123) --- subsys/net/ip/ipv6_nbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/ip/ipv6_nbr.c b/subsys/net/ip/ipv6_nbr.c index 62c53b0c98711..b04c475d71754 100644 --- a/subsys/net/ip/ipv6_nbr.c +++ b/subsys/net/ip/ipv6_nbr.c @@ -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( From c1f3c446bcc74fcbd0875bf1d77fcf648e6b545d Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Tue, 4 Feb 2025 14:58:15 +0100 Subject: [PATCH 076/118] dts: stm32h7: Fix ltdc reset lines LTDC reset lines where off by 1. Fix it. Signed-off-by: Erwan Gouriou (cherry picked from commit 6f55a32da859e5da4deceb55eea48a76fd54f687) --- dts/arm/st/h7/stm32h723.dtsi | 2 +- dts/arm/st/h7/stm32h743.dtsi | 2 +- dts/arm/st/h7/stm32h745.dtsi | 2 +- dts/arm/st/h7/stm32h7a3.dtsi | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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"; }; From b40cacb67d417f6cee8f838ceb2d647bda88e647 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 10 Feb 2025 10:27:03 +0200 Subject: [PATCH 077/118] net: Update IP address refcount properly when address already exists If an IP address already exists when it is tried to be added to the network interface, then 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 and keeping the ref count > 0. In this case we must update the ref count so that the IP address is not removed if the connection is closed. Fixes #85380 Signed-off-by: Jukka Rissanen (cherry picked from commit ae052217625881a581e7585f3603e1dbbc298571) --- include/zephyr/net/net_if.h | 13 ++++++++---- subsys/net/ip/net_if.c | 40 ++++++++++++++++++++++++++++++++++--- subsys/net/ip/tcp.c | 3 ++- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/include/zephyr/net/net_if.h b/include/zephyr/net/net_if.h index 7795f56597662..35f5e8577ffd6 100644 --- a/include/zephyr/net/net_if.h +++ b/include/zephyr/net/net_if.h @@ -134,7 +134,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 +1186,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 +1201,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/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index f9f7f68b41428..e10ba637871d5 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -1907,6 +1907,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; @@ -1945,6 +1946,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; } @@ -2002,6 +2014,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 +2029,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)", @@ -4229,6 +4243,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 +4276,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]; @@ -4295,6 +4321,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 +4336,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)", @@ -5048,11 +5076,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 +5136,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; From f0c05671da1f64b7b9d6a7f90b3adc5710c5f767 Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Thu, 23 Jan 2025 16:20:41 +0100 Subject: [PATCH 078/118] lib: os: p4wq: add done handler Add an optional handler to the p4wq to give the submitting code (e.g. rtio workq) a possibility execute code after the work was succesfully executed. Signed-off-by: Florian Weber (cherry picked from commit 093b29fdb523e8b216565588a6515f8c3374ae77) --- include/zephyr/sys/p4wq.h | 41 +++++++++++++++++++++++++++++++++++++-- lib/os/p4wq.c | 19 ++++++++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) 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/p4wq.c b/lib/os/p4wq.c index d95de01d2f767..cb3e3918edada 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; @@ -301,7 +309,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); From c2ad663314b3012f07e04ba083c6d2737a494b5b Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Tue, 21 Jan 2025 19:50:34 +0100 Subject: [PATCH 079/118] rtio: workq: bugfix of memory allocation This commit fixes the bug that the memory of the work request is freed up in the work handler, before it is not needed anymore by the p4wq. This is fixed now, by using the new done_handler in the p4wq for freeing up that memory. Signed-off-by: Florian Weber (cherry picked from commit b55b9ae72bd4ae1ca3239d6dfb5631f6b26d0346) --- subsys/rtio/rtio_workq.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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) From 790bd7c44b770f7bd27969a0c795bae1d31edbe0 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Thu, 6 Feb 2025 09:35:56 +1000 Subject: [PATCH 080/118] bluetooth: host: hci_core: add missing `NULL` check Add check that the command buffer claimed in `bt_le_create_conn_cancel` is not `NULL`. Fixes a fault caused by providing the `NULL` buffer to `bt_hci_cmd_state_set_init`. Signed-off-by: Jordan Yates --- subsys/bluetooth/host/hci_core.c | 3 +++ 1 file changed, 3 insertions(+) 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); From f61d53d5b58cd100d47b410d8e95af45249c9212 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Thu, 6 Feb 2025 22:02:09 +1000 Subject: [PATCH 081/118] bluetooth: increment `BT_BUF_CMD_TX_COUNT` The extended advertising start procedure can consume both command buffers in a single API call, resulting in `bt_le_create_conn_cancel` being unable to claim a buffer to terminate the connection request. Increase the command count if both extended advertising and Bluetooth central are enabled in an application. Signed-off-by: Jordan Yates --- subsys/bluetooth/common/Kconfig | 1 + 1 file changed, 1 insertion(+) 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 From ae73df5621aff6e2b0b3cd7d0479fb921046108d Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Fri, 31 Jan 2025 14:57:56 +0800 Subject: [PATCH 082/118] logging: init backend id regardless of autostart The `id` is basically a compile-time constant. Setting it every time the backend is enabled is unnecessary. Instead, set it on `z_log_init()` regardless of whether or not it requires to be `autostart`ed. Fixes an issue where the `filter_get`/`filter_set` accessed the wrong index and displayed the wrong log level when user accesses the status of an uninitialized backend via: `log backend status`. Also fixes an issue when user tries to list the backends via: `log list_backends`, where all uninitialized backends will have ID = 0. Signed-off-by: Yong Cong Sin Signed-off-by: Yong Cong Sin (cherry picked from commit 8dd9d924fe012619f465ce0375df692ed26fd4fa) --- subsys/logging/log_core.c | 8 +++++++- subsys/logging/log_mgmt.c | 6 ------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index f2e5363e094b8..81bd3243e3fb9 100644 --- a/subsys/logging/log_core.c +++ b/subsys/logging/log_core.c @@ -328,8 +328,14 @@ static uint32_t z_log_init(bool blocking, bool can_sleep) int backend_index = 0; - /* Activate autostart backends */ 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); + + /* 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); From a50476ca00fc95607db833ebcd3e5f983ef98fde Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Fri, 31 Jan 2025 15:30:15 +0800 Subject: [PATCH 083/118] logging: log_cmds: init uninitialized backend on `log_go()` For backends that do not autostart themselves, initialize & enable them on `log backend go`, so that they function properly. Signed-off-by: Yong Cong Sin Signed-off-by: Yong Cong Sin (cherry picked from commit f840a35be3438abdc18619c1f0609e7d7f98b20c) --- include/zephyr/logging/log_backend.h | 2 ++ subsys/logging/log_cmds.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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/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; } From 7eab725dfb04785069bae447caf0e362d5235651 Mon Sep 17 00:00:00 2001 From: Derek Snell Date: Thu, 20 Feb 2025 17:15:17 -0500 Subject: [PATCH 084/118] soc: nxp: rw: Update system core clock frequency After updating the main_clk, need to update the frequency tracked in HAL MCUXpresso SDK framework for other drivers. Signed-off-by: Derek Snell (cherry picked from commit 793e44afddf65574f7bc905c88ae38432d0c6606) --- soc/nxp/rw/soc.c | 2 ++ 1 file changed, 2 insertions(+) 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); From 3410679046e5148574d8f407cbbfc95db21bf1c3 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Mon, 17 Feb 2025 17:17:25 +0100 Subject: [PATCH 085/118] tests: net: conn_mgr: Use valid LL address in tests Using L2 address of length 1 (invalid/unsupported one) confused IPv6 layer during LL address generation - since that length was not a valid one, the address was not initialized properly and a part of it was set semi-random. This could result for example in filling out the neighbor tables. Signed-off-by: Robert Lubos (cherry picked from commit 3089a5d116ab538a568c1617afccd481e274180a) --- tests/net/conn_mgr_conn/src/test_ifaces.c | 2 +- tests/net/conn_mgr_monitor/src/test_ifaces.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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); From aa48023434a61bebfe0ef176224cbdec29f74257 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Mon, 17 Feb 2025 17:32:52 +0100 Subject: [PATCH 086/118] net: if: Clear neighbor cache when removing IPv6 addr with active DAD DAD creates an entry in the neighbor cache for the queried (own) address. In case the address is removed from the interface while DAD is still incomplete, we need to remove the corresponding cache entry (just like in case of DAD timeout) to avoid stale entries in the cache. Signed-off-by: Robert Lubos (cherry picked from commit a09fd8e97fbeb7dfb28a50ebc2a165862eec263b) --- subsys/net/ip/net_if.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index e10ba637871d5..684ada8df29f1 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -4960,8 +4960,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 From 546386cd1f79d89b5c3d1ae2fe5e786c1fad2d5e Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Mon, 17 Feb 2025 17:37:17 +0100 Subject: [PATCH 087/118] net: if: Setup DAD timer regardless of DAD query result In rare occasions when sending DAD NS packet fails, we should still setup the DAD timer, unless we implement some kind of more advanced retry mechanism. If we don't do that, the IPv6 address added to the interface will never be usable in such cases. Signed-off-by: Robert Lubos (cherry picked from commit 008a7ca2024cd0c28bcfd3f4e5a0ca91503341dc) --- subsys/net/ip/net_if.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index 684ada8df29f1..3c1f4aa5382ce 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.", From af81a8ba3227e1079d4020e75523d9b32f8d1c56 Mon Sep 17 00:00:00 2001 From: Simon Guinot Date: Tue, 11 Feb 2025 11:45:21 +0100 Subject: [PATCH 088/118] drivers: led: lp50xx: check the number of LED colors The current code assumes (especially in the lp50xx_set_color function) that the number of LED colors defined in DT is not greater than 3. But since this is not checked, then this is not necessarily the case... This patch consolidates the initialization of the lp50xx LED driver by checking the number of colors for each LED found in DT. Signed-off-by: Simon Guinot (cherry picked from commit ffbb8f981ad5640627bac6bdfc2e84f154a25370) --- drivers/led/lp50xx.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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) { From 0c413db7ebc94a4cd8e2b0fe2f032b36395f3ec4 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Thu, 13 Feb 2025 20:06:37 -0500 Subject: [PATCH 089/118] p4wq: Add Kconfig to perform early init on threads In order to make them functional for devices during init. Default behavior is to keep late initialization, as before. Signed-off-by: Luis Ubieda (cherry picked from commit ec45b29ea305335f4dc8ebe6283719ed86ea515e) --- lib/os/Kconfig | 10 ++++++++++ lib/os/p4wq.c | 4 ++++ 2 files changed, 14 insertions(+) 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 cb3e3918edada..e4855de3cce5f 100644 --- a/lib/os/p4wq.c +++ b/lib/os/p4wq.c @@ -223,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) { From 7412674a3c47acdad8e2cb53f7bdd30c805ebaaa Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Thu, 13 Feb 2025 20:07:50 -0500 Subject: [PATCH 090/118] rtio: workq: Select Early P4WQ threads init Otherwise the RTIO Workqueue is not functional for devices during init. An example of this issue is devices using SPI transfers with default spi_rtio. Signed-off-by: Luis Ubieda (cherry picked from commit 2ce2794987049022e1f754f87d3c9b9bd098a3a8) --- subsys/rtio/Kconfig.workq | 1 + 1 file changed, 1 insertion(+) 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 From 43c79ba72c07dcc3efd93dc981d646d6e504767f Mon Sep 17 00:00:00 2001 From: Mathieu Choplain Date: Mon, 17 Feb 2025 14:21:46 +0100 Subject: [PATCH 091/118] dts: st: stm32u5: restore correct `clocks` on multi-bit devices During the transition to STM32_CLOCK macro (in 57723cf), the `clocks` property of peripherals requiring more than one bit to be set were mistakenly modified. Commit 2c3294b079cf084c0f00bd18fb11d18a125cc3bc partially fixed these errors, but some nodes for the U5 series are still wrong. Restore `clocks` on affected devices in corresponding STM32U5 DTSI. Fixes: 57723cf40594545bbfc4aa36606ad9a838c4674a Signed-off-by: Mathieu Choplain (cherry picked from commit 37bdc38ec6c687ec2468b14ce007c072867158d4) --- dts/arm/st/u5/stm32u5.dtsi | 2 +- dts/arm/st/u5/stm32u595.dtsi | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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"; From 94c7905e0196cc8e8ec67c58b2b18ac3d079cc3a Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Mon, 17 Feb 2025 14:14:42 -0500 Subject: [PATCH 092/118] spi_rtio: fix transactions for default handler This patch fixes transaction op items not performed within a single SPI transfer. This is common for Write + Read commands, that depend on the CS kept asserted until the end, otherwise the context will be lost. A similar fix was applied to i2c_rtio_default on #79890. Signed-off-by: Luis Ubieda (cherry picked from commit b5ca5b7b776cda673cc04651d27eb251bb1be4f7) --- drivers/spi/Kconfig | 18 +++++++ drivers/spi/spi_rtio.c | 115 +++++++++++++++++++++++++++-------------- 2 files changed, 94 insertions(+), 39 deletions(-) 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_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); } } From 83e99be7d1cf99dd3e4166a8b9fd5553c7878502 Mon Sep 17 00:00:00 2001 From: Alex An Date: Mon, 3 Mar 2025 05:00:06 -0600 Subject: [PATCH 093/118] drivers: retained_mem: Fix using multiple nRF retained memory regions Fixes an error when using multiple nRF retained memory regions caused by a missing separating comma. Signed-off-by: Alex An (cherry picked from commit fbb75862a1881610ebb4ef05565a57cc9d397356) --- drivers/retained_mem/retained_mem_nrf_ram_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 7ff8f6696c9fe65b09deca70580256ee1771f50a Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 7 May 2025 17:34:25 +0100 Subject: [PATCH 094/118] ci: update few workflows to use Python 3.12 The HTML doc build workflow and PR assigner recently started failing to install python packages, breaking all backports. Seems to work when using Python 3.12, this is already done in main in bacb99da6d4. Signed-off-by: Fabio Baltieri --- .github/workflows/assigner.yml | 5 +++++ .github/workflows/doc-build.yml | 10 ++++++++++ 2 files changed, 15 insertions(+) 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 From bbe7ab00de1a830c44460ea7d6e31cc915910d2c Mon Sep 17 00:00:00 2001 From: Sudan Landge Date: Thu, 10 Apr 2025 14:21:37 +0100 Subject: [PATCH 095/118] modules: mbedtls: update to 3.6.3 Update Mbed TLS to 3.6.3 as it has CVE fixes. Signed-off-by: Sudan Landge --- doc/releases/release-notes-4.0.rst | 36 ++++++++++++++++++++++++++++++ west.yml | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/doc/releases/release-notes-4.0.rst b/doc/releases/release-notes-4.0.rst index 8b9ede8f11eba..2f8bf9753d054 100644 --- a/doc/releases/release-notes-4.0.rst +++ b/doc/releases/release-notes-4.0.rst @@ -2,6 +2,42 @@ .. _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. + +.. _zephyr_4.0.0: + Zephyr 4.0.0 ############ diff --git a/west.yml b/west.yml index 881b041aeaf10..1d9181daa2c22 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 From 0a8f9bb61c5130966cc542c8754a1c24a7e319f3 Mon Sep 17 00:00:00 2001 From: Sudan Landge Date: Thu, 17 Apr 2025 15:18:35 +0100 Subject: [PATCH 096/118] modules: tf-m: update to 2.1.2 Update TF-M to 2.1.2 from version 2.1.1. This is required to use MbedTLS 3.6.3. Signed-off-by: Sudan Landge --- doc/releases/release-notes-4.0.rst | 6 ++++++ submanifests/optional.yaml | 2 +- west.yml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/releases/release-notes-4.0.rst b/doc/releases/release-notes-4.0.rst index 2f8bf9753d054..57b858fa75811 100644 --- a/doc/releases/release-notes-4.0.rst +++ b/doc/releases/release-notes-4.0.rst @@ -36,6 +36,12 @@ 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/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/west.yml b/west.yml index 1d9181daa2c22..fffb9c398f9e9 100644 --- a/west.yml +++ b/west.yml @@ -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 From 05dd94d1ddc433785c35c8f032cacc44668e098b Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 3 Mar 2025 13:03:24 +0200 Subject: [PATCH 097/118] net: if: Documentation missing for IPv6 DAD start time variable Add documentation for DAD start time variable as it was missing. Signed-off-by: Jukka Rissanen --- include/zephyr/net/net_if.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/zephyr/net/net_if.h b/include/zephyr/net/net_if.h index 35f5e8577ffd6..020efa2574b2b 100644 --- a/include/zephyr/net/net_if.h +++ b/include/zephyr/net/net_if.h @@ -94,6 +94,8 @@ struct net_if_addr { struct { /** Duplicate address detection (DAD) timer */ sys_snode_t dad_node; + + /** DAD start time */ uint32_t dad_start; /** How many times we have done DAD */ From 3af878f68e5f0e5bac5a39428b44ffa439eed975 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 3 Mar 2025 14:27:45 +0200 Subject: [PATCH 098/118] net: if: Documentation missing for IPv4 ACD timeout variable Add documentation for ACD timeout variable as it was missing. Signed-off-by: Jukka Rissanen --- include/zephyr/net/net_if.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/zephyr/net/net_if.h b/include/zephyr/net/net_if.h index 020efa2574b2b..083af75d96ddc 100644 --- a/include/zephyr/net/net_if.h +++ b/include/zephyr/net/net_if.h @@ -106,6 +106,8 @@ struct net_if_addr { struct { /** Address conflict detection (ACD) timer. */ sys_snode_t acd_node; + + /** ACD timeout value. */ k_timepoint_t acd_timeout; /** ACD probe/announcement counter. */ From f749a05200d0703f1b05993d45cd21b5c4c29d3e Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 3 Mar 2025 11:30:25 +0200 Subject: [PATCH 099/118] net: if: Release the interface lock early in IPv6 RS timeout handler The net_if.c:rs_timeout() is sending a new IPv6 router solicitation message to network by calling net_if_start_rs(). That function will then acquire iface->lock and call net_ipv6_start_rs() which will try to send the RS message and acquire TX send lock. During this RS send, we might receive TCP data that could try to send an ack to peer. This will then in turn cause also TX lock to be acquired. Depending on timing, the lock ordering between rx thread and system workq might mix which could lead to deadlock. Fix this issue by releasing the iface->lock before starting the RS sending process. The net_if_start_rs() does not really need to keep the interface lock for a long time as it is the only one sending the RS message. Fixes #86499 Signed-off-by: Jukka Rissanen --- subsys/net/ip/net_if.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index 3c1f4aa5382ce..7347a43a4f60f 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -1519,6 +1519,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)) { @@ -1534,6 +1536,7 @@ void net_if_start_rs(struct net_if *iface) } } + return; out: net_if_unlock(iface); } From 60190a93f48fc33e18bfe2ab045a7e1282cd50eb Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 3 Mar 2025 13:16:33 +0200 Subject: [PATCH 100/118] net: if: Release the interface lock early when starting IPv6 DAD In order to avoid any mutex deadlocks between iface->lock and TX lock, release the interface lock before calling a function that will acquire TX lock. See previous commit for similar issue in RS timer handling. Signed-off-by: Jukka Rissanen --- include/zephyr/net/net_if.h | 3 +++ subsys/net/ip/net_if.c | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/zephyr/net/net_if.h b/include/zephyr/net/net_if.h index 083af75d96ddc..dc23d80ca8415 100644 --- a/include/zephyr/net/net_if.h +++ b/include/zephyr/net/net_if.h @@ -95,6 +95,9 @@ struct net_if_addr { /** 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; diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index 7347a43a4f60f..cd952def6c365 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -1324,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; @@ -1357,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 || @@ -1366,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); } @@ -1415,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: @@ -1944,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); @@ -1995,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. @@ -2010,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); From 215737c229935edf8d7e8bc4bea71b8ddf76090e Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 3 Mar 2025 14:45:34 +0200 Subject: [PATCH 101/118] net: if: Release the interface lock early when starting IPv4 ACD In order to avoid any mutex deadlocks between iface->lock and TX lock, release the interface lock before calling a function that will acquire TX lock. See previous commit for similar issue in RS timer handling. So here we create a separate list of ACD addresses that are to be started when network interface comes up without iface->lock held. Signed-off-by: Jukka Rissanen --- include/zephyr/net/net_if.h | 3 +++ subsys/net/ip/net_if.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/zephyr/net/net_if.h b/include/zephyr/net/net_if.h index dc23d80ca8415..cfba714d6631a 100644 --- a/include/zephyr/net/net_if.h +++ b/include/zephyr/net/net_if.h @@ -110,6 +110,9 @@ struct net_if_addr { /** 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; diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index cd952def6c365..597ca39bb4aec 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -4208,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); @@ -4230,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. */ @@ -4241,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); } @@ -4335,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; } @@ -4343,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: From d5d5a7c7db05a6dd273084c9505bd039351aa082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Sat, 1 Mar 2025 12:39:19 +0100 Subject: [PATCH 102/118] doc: make graphviz diagrams look good in dark theme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add filter to invert colors in dark mode. Signed-off-by: Benjamin Cabé (cherry picked from commit fd919b5160d0c3a3b3722dac798b89c1fac1b804) --- doc/_static/css/custom.css | 4 ++++ doc/_static/css/dark.css | 2 ++ doc/_static/css/light.css | 2 ++ 3 files changed, 8 insertions(+) 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; } From 79696d420e776b5eecf972fcbe42a191e9f52252 Mon Sep 17 00:00:00 2001 From: Chekhov Ma Date: Wed, 5 Mar 2025 19:59:35 +0800 Subject: [PATCH 103/118] drivers: gpio: adp5585: fix wrong reg during pin configure The ADP5585_GPO_OUT_MODE_A is used when configuring initial output during pin configuration, causing pins configured HIGH is incorrectly configured as open-drain. Replacing the reg with ADP5585_GPO_DATA_OUT fixes the issue. Signed-off-by: Chekhov Ma (cherry picked from commit c87900aa4090fac09a7592e222d58c2c55a1979c) --- drivers/gpio/gpio_adp5585.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; From 64451449acce7e6261087896ee017367ddccd2f3 Mon Sep 17 00:00:00 2001 From: Dong Wang Date: Fri, 14 Mar 2025 15:51:05 +0800 Subject: [PATCH 104/118] logging: Ensure atomic update of log filter slot in LOG_FILTER_SLOT_SET Replaced the read-modify-write sequence with a single read and write operation, preventing the intermediate value is wrongly used to filter out logs of another thread with higher priority that preempts the current thread. Signed-off-by: Dong Wang (cherry picked from commit 872f363696a8879b17df34eb8ebfc8fb0b733f02) --- include/zephyr/logging/log_core.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 From 1cdd63e5babd7f71227a70712188191f48b3361b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Sat, 1 Mar 2025 07:55:41 +0100 Subject: [PATCH 105/118] doc: Update Graphviz font configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Customize Graphviz dot rendering to use same font stack as our Sphinx theme. Signed-off-by: Benjamin Cabé (cherry picked from commit c0f76d9363e69464850ebcb499fdcd3cd0dd15de) --- doc/conf.py | 3 +++ 1 file changed, 3 insertions(+) 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 ---------------------------------------- From 0fb81dec80a6e5bb9bc3fb38b303b55f92994c13 Mon Sep 17 00:00:00 2001 From: Dong Wang Date: Fri, 14 Mar 2025 13:35:10 +0800 Subject: [PATCH 106/118] logging: Assign IDs to log backends early during log_core_init This commit moves the assignment of backend IDs from the 'z_log_init' function to the earlier 'log_core_init' function. This ensures that backend IDs are assigned before they are used in the 'log_backend_enable' function, preventing incorrect settings of log dynamic filters. Signed-off-by: Dong Wang (cherry picked from commit 3fac83151db3ea6f8765c8f6514674f4ce939cd2) --- subsys/logging/log_core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index 81bd3243e3fb9..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) @@ -329,12 +337,6 @@ static uint32_t z_log_init(bool blocking, bool can_sleep) int backend_index = 0; 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); - /* Activate autostart backends */ if (backend->autostart) { log_backend_init(backend); From e465e6168e37699a157c814e8e9654dd2f1e586d Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Tue, 31 Dec 2024 17:25:10 -0500 Subject: [PATCH 107/118] sensor: adxl345: Add get_size_info API Used by the sensor-shell in order to retrieve values, otherwise it crashes. Signed-off-by: Luis Ubieda --- drivers/sensor/adi/adxl345/adxl345_decoder.c | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/sensor/adi/adxl345/adxl345_decoder.c b/drivers/sensor/adi/adxl345/adxl345_decoder.c index 7a1bf53cb0584..b6a661a681841 100644 --- a/drivers/sensor/adi/adxl345/adxl345_decoder.c +++ b/drivers/sensor/adi/adxl345/adxl345_decoder.c @@ -259,10 +259,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) From 80b607dd8fc7ba301704afcf62c926be3fd10c36 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Tue, 31 Dec 2024 17:26:12 -0500 Subject: [PATCH 108/118] sensor: adxl345: Fix decoder for non-streaming mode The following fixes have been applied to this decoder: - The Q-scale factor was fixed, both for full-scale and non full-scale modes. - The data-type decoded is struct sensor_three_axis_data, as it should for read/decode API. Signed-off-by: Luis Ubieda --- drivers/sensor/adi/adxl345/adxl345.c | 4 + drivers/sensor/adi/adxl345/adxl345.h | 1 + drivers/sensor/adi/adxl345/adxl345_decoder.c | 102 +++++++++++-------- 3 files changed, 67 insertions(+), 40 deletions(-) diff --git a/drivers/sensor/adi/adxl345/adxl345.c b/drivers/sensor/adi/adxl345/adxl345.c index 3403302d7a5b1..0281027aec4c1 100644 --- a/drivers/sensor/adi/adxl345/adxl345.c +++ b/drivers/sensor/adi/adxl345/adxl345.c @@ -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; } diff --git a/drivers/sensor/adi/adxl345/adxl345.h b/drivers/sensor/adi/adxl345/adxl345.h index d0ad0a0a2c601..eece90fd4887b 100644 --- a/drivers/sensor/adi/adxl345/adxl345.h +++ b/drivers/sensor/adi/adxl345/adxl345.h @@ -202,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 b6a661a681841..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, From 0f9a0f4d00774d17a4c867e6e25894a2462dbe94 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Tue, 14 Jan 2025 19:26:53 -0500 Subject: [PATCH 109/118] sensor: adxl345: Only enable FIFO Stream with Sensor Stream is enabled Otherwise with its default configuration (25-Hz, 32-level FIFO), getting individual samples could be up to 1-second old. Signed-off-by: Luis Ubieda --- drivers/sensor/adi/adxl345/adxl345.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/sensor/adi/adxl345/adxl345.c b/drivers/sensor/adi/adxl345/adxl345.c index 0281027aec4c1..0226a0c71c10b 100644 --- a/drivers/sensor/adi/adxl345/adxl345.c +++ b/drivers/sensor/adi/adxl345/adxl345.c @@ -457,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) { From d4374ed2cff71e516a91d018aa62b5f950ab3fe9 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Tue, 14 Jan 2025 19:31:20 -0500 Subject: [PATCH 110/118] sensor: adxl345: Disable Sensor Streaming by default Have the application enable this feature explicitcly, so that simple applications do not need to disable this to get the expected behavior. Signed-off-by: Luis Ubieda --- drivers/sensor/adi/adxl345/Kconfig | 1 - 1 file changed, 1 deletion(-) 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 From c08390df71eee260c1b273d69f8dadc0ffb1d730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Fri, 4 Apr 2025 15:06:56 +0200 Subject: [PATCH 111/118] drivers: serial: nrfx_uarte: Fix use of PM_DEVICE_ISR_SAFE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PM_DEVICE_ISR_SAFE shall not be used when non-asynchronous API is used because RX is disabled in suspend action and that takes relatively long time. In case of PM_DEVICE_ISR_SAFE it is done with interrupts disabled. RX is not used at all if disable-rx property is set and in that case PM_DEVICE_ISR_SAFE can be used. Added macro which determines if ISR safe mode can be used. Signed-off-by: Krzysztof Chruściński (cherry picked from commit e0f5241b282e3776d2d04a8bf95ae116774c7127) --- drivers/serial/uart_nrfx_uarte.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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, \ From 63d789ac0bc19f69d47679753a73cb22fc156e07 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Wed, 5 Mar 2025 10:25:21 +0200 Subject: [PATCH 112/118] net: http: server: The detail length of wildcard detail was wrong The path length of the detail resource was not set properly. Signed-off-by: Jukka Rissanen (cherry picked from commit 33cf7dc78a976677f8693018eae90c0d0024d07b) --- subsys/net/lib/http/http_server_core.c | 13 ++++++++++++- tests/net/lib/http_server/common/src/main.c | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) 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/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, From 7c48241e5e21e076073dbb1ad19b6df6782e0b64 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Wed, 5 Mar 2025 10:44:09 +0200 Subject: [PATCH 113/118] net: http: server: Select POSIX_C_LIB_EXT instead of FNMATCH The CONFIG_POSIX_C_LIB_EXT will get support for fnmatch() function. The old CONFIG_FNMATCH is deprecated. Signed-off-by: Jukka Rissanen (cherry picked from commit 0f90affcdfd376f0360317d34b44ce85f28c4294) --- subsys/net/lib/http/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 5bef9327b03aa730bf13c6e7bae10c31eb9ef3a8 Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Fri, 9 May 2025 09:27:22 +0000 Subject: [PATCH 114/118] tests: drivers: virtualization: qemu_kvm_arm64.overlay: fix SPDX license "UNLICENSED" is not a valid SPDX License Identifier. Remove it from the list and just keep "Apache-2.0". Fixes: #89413 Signed-off-by: Henrik Brix Andersen (cherry picked from commit b240f115921b1062837e5371831b5f2977de9c23) --- .../virtualization/ivshmem/plain/boards/qemu_kvm_arm64.overlay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From aabd3a1826d750f2ae4b271894837a91f42186bc Mon Sep 17 00:00:00 2001 From: Fabian Blatz Date: Wed, 28 May 2025 15:51:52 +0200 Subject: [PATCH 115/118] modules: lvgl: Register print callback after lv_init Move initialization of the print callback handler after calling lv_init, as the latter zeroes the global callback structure. Signed-off-by: Fabian Blatz (cherry picked from commit 5cffb8e5a6d6447174b62cc3a724b47161a2678f) --- modules/lvgl/lvgl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 6753a86f2770e04cec1cda13c3d4f7b9f810cc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Wed, 18 Jun 2025 10:07:26 +0200 Subject: [PATCH 116/118] doc: _templates: show correct version in sidebar in case of releases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that version indicator in sidebar is correct in case of releases. Fixes zephyrproject-rtos/zephyr#91799. Signed-off-by: Benjamin Cabé (cherry picked from commit bbfaf8adec9857a71b4c072d7cdcf66d0ddcf239) --- doc/_templates/zversions.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" }}
From 5e24e48342cb64afdcbc9c2b88eb54916dd01b58 Mon Sep 17 00:00:00 2001 From: Glenn Andrews Date: Sun, 13 Apr 2025 06:46:47 -0700 Subject: [PATCH 117/118] boards: disco_l475_iot1: fix arduino_i2c assignment https://github.com/zephyrproject-rtos/zephyr/commit/0f05f58bf51b1fa74413cac4522306321a1ecd2e assigned the `arduino_i2c` to the incorrect pins for the Arduino UNO connector. This assigns them back. signed-off-by: Glenn Andrews (cherry picked from commit a2da571172d097c837274b4989eda16e67dcdcde) --- boards/st/disco_l475_iot1/arduino_r3_connector.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 {}; From 4ebecae78ad969f2801e1dfcf453dc9dd2b288d3 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Thu, 13 Mar 2025 17:52:21 +0100 Subject: [PATCH 118/118] Bluetooth: Controller: Fix connection update interval_us variables Fix connection update microsecond interval variable data type, to use 32-bit so that a value upto 2000 seconds, i.e. 4 seconds interval and 499 peripheral latency can be stored. Regression in commit abfe5f17a949 ("Bluetooth: Controller: 1 ms connection"). Signed-off-by: Vinayak Kariappa Chettimada (cherry picked from commit 0a4480ce61020b351a8f553ec7345add390d0976) --- subsys/bluetooth/controller/ll_sw/ull_conn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;