From bc6eb9ee819095d41ecb106c0024f324229c081a Mon Sep 17 00:00:00 2001 From: Piotr Kosycarz Date: Fri, 15 Mar 2024 15:02:42 +0100 Subject: [PATCH 001/504] [nrf fromlist] scripts: pylib: twister: twisterlib: prevent empty gcda files In case of problem with parsing hex data from coverage dump, do not create empty gcda file. Such empty file will break gcovr parsing. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/70297 Signed-off-by: Piotr Kosycarz (cherry picked from commit 38cf979136ece17b1e42010384e449645c268be5) --- scripts/pylib/twister/twisterlib/coverage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/pylib/twister/twisterlib/coverage.py b/scripts/pylib/twister/twisterlib/coverage.py index 26ffefec997..1cc870f652e 100644 --- a/scripts/pylib/twister/twisterlib/coverage.py +++ b/scripts/pylib/twister/twisterlib/coverage.py @@ -92,8 +92,9 @@ def create_gcda_files(extracted_coverage_info): continue try: + hex_bytes = bytes.fromhex(hexdump_val) with open(filename, 'wb') as fp: - fp.write(bytes.fromhex(hexdump_val)) + fp.write(hex_bytes) except ValueError: logger.exception("Unable to convert hex data for file: {}".format(filename)) gcda_created = False From d89bc2f15c8658b2f307ec57c4d2cbcd5c441de0 Mon Sep 17 00:00:00 2001 From: Adam Kondraciuk Date: Mon, 29 Jan 2024 15:04:01 +0100 Subject: [PATCH 002/504] [nrf fromlist] drivers: timer: grtc: Fix ticks calculation for GRTC Fixed calculation of GRTC ticks inside `z_nrf_grtc_timer_get_ticks()` function. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/71688 Signed-off-by: Adam Kondraciuk (cherry picked from commit 2570119b1097b0dd688f34aab1383cea9aef3c4a) --- drivers/timer/nrf_grtc_timer.c | 7 +++++-- include/zephyr/drivers/timer/nrf_grtc_timer.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index a5c41a63ab9..281cdf9ea1f 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -327,18 +327,21 @@ uint64_t z_nrf_grtc_timer_get_ticks(k_timeout_t t) int64_t curr_tick; int64_t result; int64_t abs_ticks; + int64_t grtc_ticks; curr_time = counter(); curr_tick = sys_clock_tick_get(); + grtc_ticks = t.ticks * CYC_PER_TICK; abs_ticks = Z_TICK_ABS(t.ticks); if (abs_ticks < 0) { /* relative timeout */ - return (t.ticks > (int64_t)COUNTER_SPAN) ? -EINVAL : (curr_time + t.ticks); + return (grtc_ticks > (int64_t)COUNTER_SPAN) ? + -EINVAL : (curr_time + grtc_ticks); } /* absolute timeout */ - result = abs_ticks - curr_tick; + result = (abs_ticks - curr_tick) * CYC_PER_TICK; if (result > (int64_t)COUNTER_SPAN) { return -EINVAL; diff --git a/include/zephyr/drivers/timer/nrf_grtc_timer.h b/include/zephyr/drivers/timer/nrf_grtc_timer.h index 036d5851725..4cd3f8d14cb 100644 --- a/include/zephyr/drivers/timer/nrf_grtc_timer.h +++ b/include/zephyr/drivers/timer/nrf_grtc_timer.h @@ -113,7 +113,7 @@ int z_nrf_grtc_timer_compare_read(int32_t chan, uint64_t *val); * * @param chan Channel ID. * - * @param target_time Absolute target time in ticks. + * @param target_time Absolute target time in GRTC ticks. * * @param handler User function called in the context of the GRTC interrupt. * From ec3b3010a5098d5bbabfc1e4d24c491dd017c263 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Mon, 15 Apr 2024 14:12:11 +0200 Subject: [PATCH 003/504] [nrf fromlist] scripts: support soc/boards in Zephyr modules Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/71519 Extend check_compliance with support for soc and boards defined Zephyr modules. Signed-off-by: Torsten Rasmussen (cherry picked from commit 24663df1abb2af207fdfba31e025229350231b31) --- scripts/ci/check_compliance.py | 45 +++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index e82e7f95ac1..f1b2a8af5e7 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -363,7 +363,7 @@ def get_modules(self, modules_file, settings_file): )) fp_module_file.write(content) - def get_kconfig_dts(self, kconfig_dts_file, settings_file): + def get_module_setting_root(self, root, settings_file): """ Generate the Kconfig.dts using dts/bindings as the source. @@ -372,10 +372,7 @@ def get_kconfig_dts(self, kconfig_dts_file, settings_file): """ # Invoke the script directly using the Python executable since this is # not a module nor a pip-installed Python utility - zephyr_drv_kconfig_path = os.path.join(ZEPHYR_BASE, "scripts", "dts", - "gen_driver_kconfig_dts.py") - binding_paths = [] - binding_paths.append(os.path.join(ZEPHYR_BASE, "dts", "bindings")) + root_paths = [] if os.path.exists(settings_file): with open(settings_file, 'r') as fp_setting_file: @@ -383,9 +380,29 @@ def get_kconfig_dts(self, kconfig_dts_file, settings_file): lines = content.strip().split('\n') for line in lines: - if line.startswith('"DTS_ROOT":'): - _, dts_root_path = line.split(":", 1) - binding_paths.append(os.path.join(dts_root_path.strip('"'), "dts", "bindings")) + root = root.upper() + if line.startswith(f'"{root}_ROOT":'): + _, root_path = line.split(":", 1) + root_paths.append(Path(root_path.strip('"'))) + return root_paths + + def get_kconfig_dts(self, kconfig_dts_file, settings_file): + """ + Generate the Kconfig.dts using dts/bindings as the source. + + This is needed to complete Kconfig compliance tests. + + """ + # Invoke the script directly using the Python executable since this is + # not a module nor a pip-installed Python utility + zephyr_drv_kconfig_path = os.path.join(ZEPHYR_BASE, "scripts", "dts", + "gen_driver_kconfig_dts.py") + binding_paths = [] + binding_paths.append(os.path.join(ZEPHYR_BASE, "dts", "bindings")) + + dts_root_paths = self.get_module_setting_root('dts', settings_file) + for p in dts_root_paths: + binding_paths.append(p / "dts" / "bindings") cmd = [sys.executable, zephyr_drv_kconfig_path, '--kconfig-out', kconfig_dts_file, '--bindings-dirs'] @@ -423,7 +440,7 @@ def get_v1_model_syms(self, kconfig_v1_file, kconfig_v1_syms_file): fp_kconfig_v1_syms_file.write('\n\t' + kconfiglib.TYPE_TO_STR[s.type]) fp_kconfig_v1_syms_file.write('\n\n') - def get_v2_model(self, kconfig_dir): + def get_v2_model(self, kconfig_dir, settings_file): """ Get lists of v2 boards and SoCs and put them in a file that is parsed by Kconfig @@ -435,8 +452,12 @@ def get_v2_model(self, kconfig_dir): kconfig_boards_file = os.path.join(kconfig_dir, 'boards', 'Kconfig.boards') kconfig_defconfig_file = os.path.join(kconfig_dir, 'boards', 'Kconfig.defconfig') - root_args = argparse.Namespace(**{'board_roots': [Path(ZEPHYR_BASE)], - 'soc_roots': [Path(ZEPHYR_BASE)], 'board': None}) + board_roots = self.get_module_setting_root('board', settings_file) + board_roots.insert(0, Path(ZEPHYR_BASE)) + soc_roots = self.get_module_setting_root('soc', settings_file) + soc_roots.insert(0, Path(ZEPHYR_BASE)) + root_args = argparse.Namespace(**{'board_roots': board_roots, + 'soc_roots': soc_roots, 'board': None}) v2_boards = list_boards.find_v2_boards(root_args) with open(kconfig_defconfig_file, 'w') as fp: @@ -542,7 +563,7 @@ def parse_kconfig(self, filename="Kconfig", hwm=None): os.makedirs(os.path.join(kconfiglib_dir, 'arch'), exist_ok=True) os.environ["BOARD_DIR"] = kconfiglib_boards_dir - self.get_v2_model(kconfiglib_dir) + self.get_v2_model(kconfiglib_dir, os.path.join(kconfiglib_dir, "settings_file.txt")) # Tells Kconfiglib to generate warnings for all references to undefined # symbols within Kconfig files From 2dfa0f5e61050aaa9c4f7911c0b047efa867a2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Thu, 4 Apr 2024 10:24:12 +0200 Subject: [PATCH 004/504] [nrf fromlist] tests: drivers: uart: async_api: Add nrf54h20 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add overlays for nrf54h20dk. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/71260 Signed-off-by: Krzysztof Chruściński (cherry picked from commit e51431446b8c5b324a04beed4681529d64ccdef9) --- .../boards/nrf54h20dk_nrf54h20_common.dtsi | 25 +++++++++++++++++++ .../boards/nrf54h20dk_nrf54h20_cpuapp.overlay | 11 ++++++++ .../boards/nrf54h20dk_nrf54h20_cpurad.overlay | 11 ++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_common.dtsi create mode 100644 tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay create mode 100644 tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay diff --git a/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_common.dtsi b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_common.dtsi new file mode 100644 index 00000000000..172d75904e4 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_common.dtsi @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +&pinctrl { + uart135_default_alt: uart135_default_alt { + group1 { + psels = , + ; + }; + }; + + uart135_sleep_alt: uart135_sleep_alt { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +dut: &uart135 { + status = "okay"; + pinctrl-0 = <&uart135_default_alt>; + pinctrl-1 = <&uart135_sleep_alt>; + pinctrl-names = "default", "sleep"; +}; diff --git a/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 00000000000..a8fe36d37bb --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include "nrf54h20dk_nrf54h20_common.dtsi" + +&cpuapp_dma_region { + status = "okay"; +}; + +&dut { + memory-regions = <&cpuapp_dma_region>; +}; diff --git a/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay new file mode 100644 index 00000000000..32f95625201 --- /dev/null +++ b/tests/drivers/uart/uart_async_api/boards/nrf54h20dk_nrf54h20_cpurad.overlay @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include "nrf54h20dk_nrf54h20_common.dtsi" + +&cpurad_dma_region { + status = "okay"; +}; + +&dut { + memory-regions = <&cpurad_dma_region>; +}; From eac356d34483400ae61b7e743dcbd022e406079a Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Tue, 7 May 2024 08:27:09 +0100 Subject: [PATCH 005/504] [nrf fromlist] kernel: banner: Make function weak Makes the boot banner function weak, this resolves an issue when building with llext enabled which uses different build options than a normal zephyr build Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/72400 Signed-off-by: Jamie McCrae (cherry picked from commit d22aedea308baaf64dea1da3b21bbb7f2410293d) --- kernel/banner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/banner.c b/kernel/banner.c index dc2506fb9b1..061e57048d1 100644 --- a/kernel/banner.c +++ b/kernel/banner.c @@ -24,7 +24,7 @@ #endif /* BUILD_VERSION */ #endif /* !BANNER_VERSION */ -void boot_banner(void) +__weak void boot_banner(void) { #if defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0) printk("***** delaying boot " DELAY_STR "ms (per build configuration) *****\n"); From 80f445f2103f0b6c93a640df238a5bb49c3d27fb Mon Sep 17 00:00:00 2001 From: Adam Kondraciuk Date: Thu, 1 Feb 2024 09:46:02 +0100 Subject: [PATCH 006/504] [nrf fromlist] tests: drivers: timer: grtc: Fix GRTC test Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/71688 The `z_nrf_grtc_timer_get_ticks()` function converts system ticks to GRTC ticks. It gets the current system tick to calculate an absolute GRTC value. The same does the test function to provide an argument to be converted. If the system tick occurs between those `sys_clock_tick_get()` calls the `z_nrf_grtc_timer_get_ticks()` will take into account the newer tick while the test estimate bases on the old tick value. Due to that the maximum result error is 1 system tick minus 1 GRTC tick which equals (`CYC_PER_TICK` - 1) for GRTC ticks. Signed-off-by: Adam Kondraciuk (cherry picked from commit d0b6a48b63f61087f2a0eb6b6ffc3f0918c1aa70) --- tests/drivers/timer/nrf_grtc_timer/src/main.c | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/tests/drivers/timer/nrf_grtc_timer/src/main.c b/tests/drivers/timer/nrf_grtc_timer/src/main.c index 197270cc6a4..e6621316666 100644 --- a/tests/drivers/timer/nrf_grtc_timer/src/main.c +++ b/tests/drivers/timer/nrf_grtc_timer/src/main.c @@ -8,12 +8,15 @@ #include #define GRTC_SLEW_TICKS 10 +#define NUMBER_OF_TRIES 2000 +#define CYC_PER_TICK \ + ((uint64_t)sys_clock_hw_cycles_per_sec() / (uint64_t)CONFIG_SYS_CLOCK_TICKS_PER_SEC) ZTEST(nrf_grtc_timer, test_get_ticks) { k_timeout_t t = K_MSEC(1); - uint64_t exp_ticks = z_nrf_grtc_timer_read() + t.ticks; + uint64_t exp_ticks = z_nrf_grtc_timer_read() + t.ticks * CYC_PER_TICK; int64_t ticks; /* Relative 1ms from now timeout converted to GRTC */ @@ -21,20 +24,26 @@ ZTEST(nrf_grtc_timer, test_get_ticks) zassert_true((ticks >= exp_ticks) && (ticks <= (exp_ticks + GRTC_SLEW_TICKS)), "Unexpected result %" PRId64 " (expected: %" PRId64 ")", ticks, exp_ticks); - /* Absolute timeout 1ms in the past */ - t = Z_TIMEOUT_TICKS(Z_TICK_ABS(sys_clock_tick_get() - K_MSEC(1).ticks)); - - exp_ticks = z_nrf_grtc_timer_read() - K_MSEC(1).ticks; - ticks = z_nrf_grtc_timer_get_ticks(t); - zassert_true((ticks >= exp_ticks) && (ticks <= (exp_ticks + GRTC_SLEW_TICKS)), - "Unexpected result %" PRId64 " (expected: %" PRId64 ")", ticks, exp_ticks); - - /* Absolute timeout 10ms in the future */ - t = Z_TIMEOUT_TICKS(Z_TICK_ABS(sys_clock_tick_get() + K_MSEC(10).ticks)); - exp_ticks = z_nrf_grtc_timer_read() + K_MSEC(10).ticks; - ticks = z_nrf_grtc_timer_get_ticks(t); - zassert_true((ticks >= exp_ticks) && (ticks <= (exp_ticks + GRTC_SLEW_TICKS)), - "Unexpected result %" PRId64 " (expected: %" PRId64 ")", ticks, exp_ticks); + for (uint32_t i = 0; i < NUMBER_OF_TRIES; i++) { + /* Absolute timeout 1ms in the past */ + t = Z_TIMEOUT_TICKS(Z_TICK_ABS(sys_clock_tick_get() - K_MSEC(1).ticks)); + + exp_ticks = z_nrf_grtc_timer_read() - K_MSEC(1).ticks * CYC_PER_TICK; + ticks = z_nrf_grtc_timer_get_ticks(t); + zassert_true((ticks >= (exp_ticks - CYC_PER_TICK + 1)) && + (ticks <= (exp_ticks + GRTC_SLEW_TICKS)), + "Unexpected result %" PRId64 " (expected: %" PRId64 ")", ticks, + exp_ticks); + + /* Absolute timeout 10ms in the future */ + t = Z_TIMEOUT_TICKS(Z_TICK_ABS(sys_clock_tick_get() + K_MSEC(10).ticks)); + exp_ticks = z_nrf_grtc_timer_read() + K_MSEC(10).ticks * CYC_PER_TICK; + ticks = z_nrf_grtc_timer_get_ticks(t); + zassert_true((ticks >= (exp_ticks - CYC_PER_TICK + 1)) && + (ticks <= (exp_ticks + GRTC_SLEW_TICKS)), + "Unexpected result %" PRId64 " (expected: %" PRId64 ")", ticks, + exp_ticks); + } } ZTEST_SUITE(nrf_grtc_timer, NULL, NULL, NULL, NULL, NULL); From d49407f1900ece3c4b1fb446f889fbc58a8bcf45 Mon Sep 17 00:00:00 2001 From: Adam Kondraciuk Date: Thu, 1 Feb 2024 09:46:02 +0100 Subject: [PATCH 007/504] [nrf fromlist] tests: drivers: timer: grtc: Fix GRTC test The `z_nrf_grtc_timer_get_ticks()` function converts system ticks to GRTC ticks. It gets the current system tick to calculate an absolute GRTC value. The same does the test function to provide an argument to be converted. If the system tick occurs between those `sys_clock_tick_get()` calls the `z_nrf_grtc_timer_get_ticks()` will take into account the newer tick while the test estimate bases on the old tick value. Due to that the maximum result error is 1 system tick minus 1 GRTC tick which equals (`CYC_PER_TICK` - 1) for GRTC ticks. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/71688 Signed-off-by: Adam Kondraciuk (cherry picked from commit 1a8f9cb0b324a6dde08ee7a9f544b97d2cbc8a1b) --- tests/drivers/timer/nrf_grtc_timer/src/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/drivers/timer/nrf_grtc_timer/src/main.c b/tests/drivers/timer/nrf_grtc_timer/src/main.c index e6621316666..f8d33d8c53a 100644 --- a/tests/drivers/timer/nrf_grtc_timer/src/main.c +++ b/tests/drivers/timer/nrf_grtc_timer/src/main.c @@ -24,6 +24,8 @@ ZTEST(nrf_grtc_timer, test_get_ticks) zassert_true((ticks >= exp_ticks) && (ticks <= (exp_ticks + GRTC_SLEW_TICKS)), "Unexpected result %" PRId64 " (expected: %" PRId64 ")", ticks, exp_ticks); + k_msleep(1); + for (uint32_t i = 0; i < NUMBER_OF_TRIES; i++) { /* Absolute timeout 1ms in the past */ t = Z_TIMEOUT_TICKS(Z_TICK_ABS(sys_clock_tick_get() - K_MSEC(1).ticks)); From 249a7ad5af21888cf6fa19e273dbc258683b6cfc Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 15 May 2024 12:49:43 +0200 Subject: [PATCH 008/504] [nrf fromlist] dt-bindings: pinctrl: nrf: allow for more ports New nRF54H20 SoC series expose more ports, e.g. P9, so reserve more bits for the Port+Pin field. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73097 Signed-off-by: Gerard Marull-Paretas (cherry picked from commit 155bb98540633afb1c8b588397c67ea86409dbbd) --- .../zephyr/dt-bindings/pinctrl/nrf-pinctrl.h | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h b/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h index a50233ab38c..cbd92c73460 100644 --- a/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h +++ b/include/zephyr/dt-bindings/pinctrl/nrf-pinctrl.h @@ -10,13 +10,12 @@ * The whole nRF pin configuration information is encoded in a 32-bit bitfield * organized as follows: * - * - 31..16: Pin function. - * - 15: Reserved. - * - 14: Pin inversion mode. - * - 13: Pin low power mode. - * - 12..9: Pin output drive configuration. - * - 8..7: Pin pull configuration. - * - 6..0: Pin number (combination of port and pin). + * - 31..17: Pin function. + * - 16: Pin inversion mode. + * - 15: Pin low power mode. + * - 14..11: Pin output drive configuration. + * - 10..9: Pin pull configuration. + * - 8..0: Pin number (combination of port and pin). */ /** @@ -25,29 +24,29 @@ */ /** Position of the function field. */ -#define NRF_FUN_POS 16U +#define NRF_FUN_POS 17U /** Mask for the function field. */ -#define NRF_FUN_MSK 0xFFFFU +#define NRF_FUN_MSK 0x7FFFU /** Position of the invert field. */ -#define NRF_INVERT_POS 14U +#define NRF_INVERT_POS 16U /** Mask for the invert field. */ #define NRF_INVERT_MSK 0x1U /** Position of the low power field. */ -#define NRF_LP_POS 13U +#define NRF_LP_POS 15U /** Mask for the low power field. */ #define NRF_LP_MSK 0x1U /** Position of the drive configuration field. */ -#define NRF_DRIVE_POS 9U +#define NRF_DRIVE_POS 11U /** Mask for the drive configuration field. */ #define NRF_DRIVE_MSK 0xFU /** Position of the pull configuration field. */ -#define NRF_PULL_POS 7U +#define NRF_PULL_POS 9U /** Mask for the pull configuration field. */ #define NRF_PULL_MSK 0x3U /** Position of the pin field. */ #define NRF_PIN_POS 0U /** Mask for the pin field. */ -#define NRF_PIN_MSK 0x7FU +#define NRF_PIN_MSK 0x1FFU /** @} */ @@ -218,7 +217,7 @@ * @brief Utility macro to build nRF psels property entry. * * @param fun Pin function configuration (see NRF_FUNC_{name} macros). - * @param port Port (0 or 1). + * @param port Port (0 or 15). * @param pin Pin (0..31). */ #define NRF_PSEL(fun, port, pin) \ From 1404fdc09ad243f9bf6640a9ea1330f0be751f2d Mon Sep 17 00:00:00 2001 From: Tomasz Chyrowicz Date: Wed, 15 May 2024 15:19:01 +0200 Subject: [PATCH 009/504] [nrf fromlist] boards: nrf54h20dk: Add SUIT storage definition Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/72810 Add a definition of SUIT storage, so there will be a common source of the SUIT storage location for both SDFW and scripts generating SUIT storage areas, assigned to local domains. Signed-off-by: Tomasz Chyrowicz (cherry picked from commit 41095df79d11e081ea96d150fbe3dbd93f73af6c) --- dts/common/nordic/nrf54h20.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dts/common/nordic/nrf54h20.dtsi b/dts/common/nordic/nrf54h20.dtsi index 4e71c0be769..0e429ab3a9d 100644 --- a/dts/common/nordic/nrf54h20.dtsi +++ b/dts/common/nordic/nrf54h20.dtsi @@ -74,6 +74,10 @@ #address-cells = <1>; #size-cells = <1>; + suit_storage_partition: memory@e1eb000 { + reg = <0xe1eb000 DT_SIZE_K(24)>; + }; + cpurad_uicr_ext: memory@e1ff000 { reg = <0xe1ff000 DT_SIZE_K(2)>; }; From 70b2886a8c9829e2ba606bfcdf0378058e3c6b0f Mon Sep 17 00:00:00 2001 From: Maciej Perkowski Date: Tue, 19 Dec 2023 15:28:24 +0100 Subject: [PATCH 010/504] [nrf fromtree] scripts: Allow using quarantine mechanism with test_plan.py script In twister, applying quarantine is a part of apply_filters() function. However, this function is not called when --load-test is used. Therefore, if one wants to use quarantines in combination with dynamic scope from the test_plan.py script, one has to pass such info through the script. Signed-off-by: Maciej Perkowski (cherry picked from commit 48665f2636208e71892f5203f39d427f74d19901) Signed-off-by: Robert Lubos (cherry picked from commit a60e90d82f5e0f3f59b56e0babe4349b25c0412b) --- scripts/ci/test_plan.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/ci/test_plan.py b/scripts/ci/test_plan.py index 1bbfd331deb..edbbbf2d923 100755 --- a/scripts/ci/test_plan.py +++ b/scripts/ci/test_plan.py @@ -95,7 +95,7 @@ def __repr__(self): class Filters: def __init__(self, modified_files, ignore_path, alt_tags, testsuite_root, - pull_request=False, platforms=[], detailed_test_id=True, tc_roots_th=20): + pull_request=False, platforms=[], detailed_test_id=True, quarantine_list=None, tc_roots_th=20): self.modified_files = modified_files self.testsuite_root = testsuite_root self.resolved_files = [] @@ -108,6 +108,7 @@ def __init__(self, modified_files, ignore_path, alt_tags, testsuite_root, self.detailed_test_id = detailed_test_id self.ignore_path = ignore_path self.tag_cfg_file = alt_tags + self.quarantine_list = quarantine_list self.tc_roots_th = tc_roots_th def process(self): @@ -129,6 +130,9 @@ def get_plan(self, options, integration=False, use_testsuite_root=True): cmd+=["-T", root] if integration: cmd.append("--integration") + if self.quarantine_list: + for q in self.quarantine_list: + cmd += ["--quarantine-list", q] logging.info(" ".join(cmd)) _ = subprocess.call(cmd) @@ -414,6 +418,12 @@ def parse_args(): "testcase.yaml files under here will be processed. May be " "called multiple times. Defaults to the 'samples/' and " "'tests/' directories at the base of the Zephyr tree.") + parser.add_argument( + "--quarantine-list", action="append", metavar="FILENAME", + help="Load list of test scenarios under quarantine. The entries in " + "the file need to correspond to the test scenarios names as in " + "corresponding tests .yaml files. These scenarios " + "will be skipped with quarantine as the reason.") # Include paths in names by default. parser.set_defaults(detailed_test_id=True) @@ -442,7 +452,7 @@ def parse_args(): print("=========") f = Filters(files, args.ignore_path, args.alt_tags, args.testsuite_root, - args.pull_request, args.platform, args.detailed_test_id, + args.pull_request, args.platform, args.detailed_test_id, args.quarantine_list, args.testcase_roots_threshold) f.process() From 1351b7f209a8556269bab8d188348dcc0f5984f2 Mon Sep 17 00:00:00 2001 From: Grzegorz Swiderski Date: Wed, 17 Apr 2024 13:51:37 +0200 Subject: [PATCH 011/504] [nrf fromlist] dts: nordic: Add RESETINFO Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/71609 Add devicetree nodes for the Reset Information registers on nRF54H20, along with a new binding. Signed-off-by: Grzegorz Swiderski (cherry picked from commit 1c902bc9b57ac72d398182730e8e5b3c53963c75) --- dts/bindings/arm/nordic,nrf-resetinfo.yaml | 12 ++++++++++++ dts/common/nordic/nrf54h20.dtsi | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100644 dts/bindings/arm/nordic,nrf-resetinfo.yaml diff --git a/dts/bindings/arm/nordic,nrf-resetinfo.yaml b/dts/bindings/arm/nordic,nrf-resetinfo.yaml new file mode 100644 index 00000000000..c8585e5897e --- /dev/null +++ b/dts/bindings/arm/nordic,nrf-resetinfo.yaml @@ -0,0 +1,12 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: Nordic RESETINFO (Reset Information) + +compatible: "nordic,nrf-resetinfo" + +include: base.yaml + +properties: + reg: + required: true diff --git a/dts/common/nordic/nrf54h20.dtsi b/dts/common/nordic/nrf54h20.dtsi index 0e429ab3a9d..7c5a990563c 100644 --- a/dts/common/nordic/nrf54h20.dtsi +++ b/dts/common/nordic/nrf54h20.dtsi @@ -187,6 +187,11 @@ compatible = "nordic,nrf-ieee802154"; status = "disabled"; }; + + cpuapp_resetinfo: resetinfo@1e000 { + compatible = "nordic,nrf-resetinfo"; + reg = <0x1e000 0x1000>; + }; }; cpurad_peripherals: peripheral@53000000 { @@ -221,6 +226,11 @@ interrupts = <20 NRF_DEFAULT_IRQ_PRIORITY>; }; + cpurad_resetinfo: resetinfo@1e000 { + compatible = "nordic,nrf-resetinfo"; + reg = <0x1e000 0x1000>; + }; + dppic020: dppic@22000 { compatible = "nordic,nrf-dppic-local"; reg = <0x22000 0x1000>; From 01c17529e0e8aa94011711bf112b448f99cdbea7 Mon Sep 17 00:00:00 2001 From: Adam Kondraciuk Date: Tue, 19 Dec 2023 15:25:08 +0100 Subject: [PATCH 012/504] [nrf fromlist] drivers: timer: grtc: Update GRTC driver Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/71688 This commit aligns the GRTC driver to changes introduced in hal_nordic. Some of the features regarding GRTC sleep/wakeup functionality has been modified and moved out to the nrfx driver's code. Signed-off-by: Adam Kondraciuk (cherry picked from commit ab47b86c62854f2c71933f2f54d64aff48bb9691) --- drivers/timer/Kconfig.nrf_grtc | 13 ++- drivers/timer/nrf_grtc_timer.c | 87 +++++-------------- include/zephyr/drivers/timer/nrf_grtc_timer.h | 1 + modules/hal_nordic/nrfx/CMakeLists.txt | 15 +++- 4 files changed, 46 insertions(+), 70 deletions(-) diff --git a/drivers/timer/Kconfig.nrf_grtc b/drivers/timer/Kconfig.nrf_grtc index 0436c071fa2..cda39ae8b1c 100644 --- a/drivers/timer/Kconfig.nrf_grtc +++ b/drivers/timer/Kconfig.nrf_grtc @@ -41,9 +41,20 @@ config NRF_GRTC_TIMER_CLOCK_MANAGEMENT the GRTC. Usually this is only needed by the processor that is starting the SYSCOUNTER, but can be shared by multiple processors in the system. -config NRF_GRTC_SLEEP_MINIMUM_LATENCY +config NRF_GRTC_SYSCOUNTER_SLEEP_MINIMUM_LATENCY int default 1000 depends on NRF_GRTC_SLEEP_ALLOWED + help + The value (in us) ensures that the wakeup event will not fire + too early. In other words, applying SYSCOUNTER sleep state for less than + NRF_GRTC_SYSCOUNTER_SLEEP_MINIMUM_LATENCY period makes no sense. + +config NRF_GRTC_TIMER_AUTO_KEEP_ALIVE + bool + default y if NRF_GRTC_START_SYSCOUNTER + help + This feature prevents the SYSCOUNTER to sleep when any core is in + active state. endif # NRF_GRTC_TIMER diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index 281cdf9ea1f..a8b29b9dcc7 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -29,12 +29,6 @@ #define CHAN_COUNT NRFX_GRTC_CONFIG_NUM_OF_CC_CHANNELS #define EXT_CHAN_COUNT (CHAN_COUNT - 1) -/* The reset value of waketime is 1, which doesn't seem to work. - * It's being looked into, but for the time being use 4. - * Timeout must always be higher than waketime, so setting that to 5. - */ -#define WAKETIME (4) -#define TIMEOUT (WAKETIME + 1) #ifndef GRTC_SYSCOUNTERL_VALUE_Msk #define GRTC_SYSCOUNTERL_VALUE_Msk GRTC_SYSCOUNTER_SYSCOUNTERL_VALUE_Msk @@ -55,9 +49,6 @@ #define MAX_CYCLES (MAX_TICKS * CYC_PER_TICK) -/* The maximum SYSCOUNTERVALID settling time equals 1x32k cycles + 20x1MHz cycles. */ -#define GRTC_SYSCOUNTERVALID_SETTLE_MAX_TIME_US 51 - #if defined(CONFIG_TEST) const int32_t z_sys_timer_irq_for_test = DT_IRQN(GRTC_NODE); #endif @@ -78,36 +69,6 @@ static nrfx_grtc_channel_t system_clock_channel_data = { __ASSERT_NO_MSG((NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK & (1UL << (chan))) && \ ((chan) != system_clock_channel_data.channel)) -static inline void grtc_active_set(void) -{ -#if defined(NRF_GRTC_HAS_SYSCOUNTER_ARRAY) && (NRF_GRTC_HAS_SYSCOUNTER_ARRAY == 1) - nrfy_grtc_sys_counter_active_set(NRF_GRTC, true); - while (!nrfy_grtc_sys_conter_ready_check(NRF_GRTC)) { - } -#else - nrfy_grtc_sys_counter_active_state_request_set(NRF_GRTC, true); - k_busy_wait(GRTC_SYSCOUNTERVALID_SETTLE_MAX_TIME_US); -#endif -} - -static inline void grtc_wakeup(void) -{ - if (IS_ENABLED(CONFIG_NRF_GRTC_SLEEP_ALLOWED)) { - grtc_active_set(); - } -} - -static inline void grtc_sleep(void) -{ - if (IS_ENABLED(CONFIG_NRF_GRTC_SLEEP_ALLOWED)) { -#if defined(NRF_GRTC_HAS_SYSCOUNTER_ARRAY) && (NRF_GRTC_HAS_SYSCOUNTER_ARRAY == 1) - nrfy_grtc_sys_counter_active_set(NRF_GRTC, false); -#else - nrfy_grtc_sys_counter_active_state_request_set(NRF_GRTC, false); -#endif - } -} - static inline uint64_t counter_sub(uint64_t a, uint64_t b) { return (a - b); @@ -116,10 +77,7 @@ static inline uint64_t counter_sub(uint64_t a, uint64_t b) static inline uint64_t counter(void) { uint64_t now; - - grtc_wakeup(); nrfx_grtc_syscounter_get(&now); - grtc_sleep(); return now; } @@ -143,10 +101,8 @@ static inline int get_comparator(uint32_t chan, uint64_t *cc) static void system_timeout_set_relative(uint64_t value) { if (value <= NRF_GRTC_SYSCOUNTER_CCADD_MASK) { - grtc_wakeup(); nrfx_grtc_syscounter_cc_relative_set(&system_clock_channel_data, value, true, NRFX_GRTC_CC_RELATIVE_SYSCOUNTER); - grtc_sleep(); } else { nrfx_grtc_syscounter_cc_absolute_set(&system_clock_channel_data, value + counter(), true); @@ -381,6 +337,7 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time) */ uint64_t capt_time; + nrfx_err_t result; IS_CHANNEL_ALLOWED_ASSERT(chan); @@ -391,8 +348,10 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time) */ return -EBUSY; } - - capt_time = nrfy_grtc_sys_counter_cc_get(NRF_GRTC, chan); + result = nrfx_grtc_syscounter_cc_value_read(chan, &capt_time); + if (result != NRFX_SUCCESS) { + return -EPERM; + } __ASSERT_NO_MSG(capt_time < COUNTER_SPAN); @@ -407,16 +366,22 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) nrfx_err_t err_code; static uint8_t systemoff_channel; uint64_t now = counter(); + nrfx_grtc_sleep_config_t sleep_cfg; /* Minimum time that ensures valid execution of system-off procedure. */ - uint32_t minimum_latency_us = nrfy_grtc_waketime_get(NRF_GRTC) + - nrfy_grtc_timeout_get(NRF_GRTC) + - CONFIG_NRF_GRTC_SLEEP_MINIMUM_LATENCY; + uint32_t minimum_latency_us; uint32_t chan; int ret; + nrfx_grtc_sleep_configuration_get(&sleep_cfg); + minimum_latency_us = (sleep_cfg.waketime + sleep_cfg.timeout) * USEC_PER_SEC / 32768 + + CONFIG_NRF_GRTC_SYSCOUNTER_SLEEP_MINIMUM_LATENCY; + sleep_cfg.auto_mode = false; + nrfx_grtc_sleep_configure(&sleep_cfg); + if (minimum_latency_us > wake_time_us) { return -EINVAL; } + k_spinlock_key_t key = k_spin_lock(&lock); err_code = nrfx_grtc_channel_alloc(&systemoff_channel); @@ -425,7 +390,9 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) return -ENOMEM; } (void)nrfx_grtc_syscounter_cc_int_disable(systemoff_channel); - ret = compare_set(systemoff_channel, now + wake_time_us, NULL, NULL); + ret = compare_set(systemoff_channel, + now + wake_time_us * sys_clock_hw_cycles_per_sec() / USEC_PER_SEC, NULL, + NULL); if (ret < 0) { k_spin_unlock(&lock, key); return ret; @@ -441,7 +408,7 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) } /* Make sure that wake_time_us was not triggered yet. */ - if (nrfy_grtc_sys_counter_compare_event_check(NRF_GRTC, systemoff_channel)) { + if (nrfx_grtc_syscounter_compare_event_check(systemoff_channel)) { k_spin_unlock(&lock, key); return -EINVAL; } @@ -452,7 +419,7 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) MAX_CC_LATCH_WAIT_TIME_US; k_busy_wait(wait_time); #if NRF_GRTC_HAS_CLKSEL - nrfy_grtc_clksel_set(NRF_GRTC, NRF_GRTC_CLKSEL_LFXO); + nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFXO); #endif k_spin_unlock(&lock, key); return 0; @@ -493,16 +460,9 @@ static int sys_clock_driver_init(void) #if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && \ (defined(NRF_GRTC_HAS_CLKSEL) && (NRF_GRTC_HAS_CLKSEL == 1)) /* Use System LFCLK as the low-frequency clock source. */ - nrfy_grtc_clksel_set(NRF_GRTC, NRF_GRTC_CLKSEL_LFCLK); + nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFCLK); #endif -#if defined(CONFIG_NRF_GRTC_START_SYSCOUNTER) - /* SYSCOUNTER needs to be turned off before initialization. */ - nrfy_grtc_sys_counter_set(NRF_GRTC, false); - nrfy_grtc_timeout_set(NRF_GRTC, TIMEOUT); - nrfy_grtc_waketime_set(NRF_GRTC, WAKETIME); -#endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */ - IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr, nrfx_grtc_irq_handler, 0); @@ -516,9 +476,6 @@ static int sys_clock_driver_init(void) if (err_code != NRFX_SUCCESS) { return err_code == NRFX_ERROR_NO_MEM ? -ENOMEM : -EPERM; } - if (IS_ENABLED(CONFIG_NRF_GRTC_SLEEP_ALLOWED)) { - nrfy_grtc_sys_counter_auto_mode_set(NRF_GRTC, false); - } #else err_code = nrfx_grtc_channel_alloc(&system_clock_channel_data.channel); if (err_code != NRFX_SUCCESS) { @@ -526,10 +483,6 @@ static int sys_clock_driver_init(void) } #endif /* CONFIG_NRF_GRTC_START_SYSCOUNTER */ - if (!IS_ENABLED(CONFIG_NRF_GRTC_SLEEP_ALLOWED)) { - grtc_active_set(); - } - int_mask = NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK; if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) { system_timeout_set_relative(CYC_PER_TICK); diff --git a/include/zephyr/drivers/timer/nrf_grtc_timer.h b/include/zephyr/drivers/timer/nrf_grtc_timer.h index 4cd3f8d14cb..f8b69d7ddf0 100644 --- a/include/zephyr/drivers/timer/nrf_grtc_timer.h +++ b/include/zephyr/drivers/timer/nrf_grtc_timer.h @@ -171,6 +171,7 @@ int z_nrf_grtc_timer_capture_prepare(int32_t chan); * * @retval 0 if the timestamp was successfully caught and read. * @retval -EBUSY if capturing has not been triggered. + * @retval -EPERM if either channel is unavailable or SYSCOUNTER is not running. */ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time); diff --git a/modules/hal_nordic/nrfx/CMakeLists.txt b/modules/hal_nordic/nrfx/CMakeLists.txt index e46e458ccab..2313c3f311d 100644 --- a/modules/hal_nordic/nrfx/CMakeLists.txt +++ b/modules/hal_nordic/nrfx/CMakeLists.txt @@ -131,8 +131,19 @@ if(CONFIG_NRFX_TWI OR CONFIG_NRFX_TWIM) zephyr_library_sources(${SRC_DIR}/nrfx_twi_twim.c) endif() -if (CONFIG_NRF_GRTC_TIMER AND CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) - zephyr_compile_definitions(NRF_GRTC_HAS_EXTENDED=1) +if (CONFIG_NRF_GRTC_TIMER) + if (CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) + zephyr_compile_definitions(NRF_GRTC_HAS_EXTENDED=1) + endif() + if (CONFIG_NRF_GRTC_SLEEP_ALLOWED) + zephyr_compile_definitions(NRFX_GRTC_CONFIG_SLEEP_ALLOWED=1) + endif() + if (CONFIG_NRF_GRTC_TIMER_AUTO_KEEP_ALIVE) + zephyr_compile_definitions(NRFX_GRTC_CONFIG_AUTOEN=1) + endif() + if (CONFIG_NRF_GRTC_START_SYSCOUNTER) + zephyr_compile_definitions(NRFX_GRTC_CONFIG_AUTOSTART=1) + endif() endif() # Inject HAL "CONFIG_NFCT_PINS_AS_GPIOS" definition if user requests to From 6b33424fb3505e64be3459f667a84f723e0a79a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Tue, 21 May 2024 14:20:46 +0200 Subject: [PATCH 013/504] [nrf fromlist] usb: device_next: Fix string descriptors response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 2f31ee63b5c5 ("usb: device_next: convert ASCII7 strings to UTF16LE on the fly") made string descriptors respond with twice as much of the actual string data. Fix the issue by taking into account that USB string descriptor length is already multiplied by two. Additionally, make it possible to return odd number of bytes if host requested so. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73079 Signed-off-by: Tomasz Moń Signed-off-by: Robert Lubos (cherry picked from commit afdb974203a2729b7b884ba91575312b1897706d) --- subsys/usb/device_next/usbd_ch9.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/subsys/usb/device_next/usbd_ch9.c b/subsys/usb/device_next/usbd_ch9.c index 8e7db0b756e..459340500ac 100644 --- a/subsys/usb/device_next/usbd_ch9.c +++ b/subsys/usb/device_next/usbd_ch9.c @@ -563,6 +563,7 @@ static void string_ascii7_to_utf16le(struct usbd_desc_node *const dn, }; uint8_t *ascii7_str; size_t len; + size_t i; if (dn->str.utype == USBD_DUT_STRING_SERIAL_NUMBER && dn->str.use_hwinfo) { ssize_t hwid_len = get_sn_from_hwid(hwid_sn); @@ -588,12 +589,16 @@ static void string_ascii7_to_utf16le(struct usbd_desc_node *const dn, net_buf_add_mem(buf, &head, MIN(len, sizeof(head))); len -= MIN(len, sizeof(head)); - for (size_t i = 0; i < len; i++) { + for (i = 0; i < len / 2; i++) { __ASSERT(ascii7_str[i] > 0x1F && ascii7_str[i] < 0x7F, "Only printable ascii-7 characters are allowed in USB " "string descriptors"); net_buf_add_le16(buf, ascii7_str[i]); } + + if (len & 1) { + net_buf_add_u8(buf, ascii7_str[i]); + } } static int sreq_get_desc_dev(struct usbd_contex *const uds_ctx, From 15532d4a6ee203f94468615c829e2f17f7188c1a Mon Sep 17 00:00:00 2001 From: Johann Fischer Date: Mon, 20 May 2024 12:26:01 +0200 Subject: [PATCH 014/504] [nrf fromlist] usb: device_next: fix BOS descriptor request Return protocol error if bcdUSB is less than 0x0201. Fix typo in number of capabilities. Fixes: b0d7d70834ab ("usb: device_next: add initial BOS support") Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73018 Signed-off-by: Johann Fischer Signed-off-by: Robert Lubos (cherry picked from commit 3ac76d3747d24754804f517175fc85785e65b126) --- subsys/usb/device_next/usbd_ch9.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/subsys/usb/device_next/usbd_ch9.c b/subsys/usb/device_next/usbd_ch9.c index 459340500ac..2b6897e5567 100644 --- a/subsys/usb/device_next/usbd_ch9.c +++ b/subsys/usb/device_next/usbd_ch9.c @@ -708,7 +708,7 @@ static void desc_fill_bos_root(struct usbd_contex *const uds_ctx, SYS_DLIST_FOR_EACH_CONTAINER(&uds_ctx->descriptors, desc_nd, node) { if (desc_nd->bDescriptorType == USB_DESC_BOS) { root->wTotalLength += desc_nd->bLength; - root->bNumDeviceCaps += desc_nd->bLength; + root->bNumDeviceCaps++; } } } @@ -717,10 +717,28 @@ static int sreq_get_desc_bos(struct usbd_contex *const uds_ctx, struct net_buf *const buf) { struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx); + struct usb_device_descriptor *dev_dsc; struct usb_bos_descriptor bos; struct usbd_desc_node *desc_nd; size_t len; + switch (usbd_bus_speed(uds_ctx)) { + case USBD_SPEED_FS: + dev_dsc = uds_ctx->fs_desc; + break; + case USBD_SPEED_HS: + dev_dsc = uds_ctx->hs_desc; + break; + default: + errno = -ENOTSUP; + return 0; + } + + if (sys_le16_to_cpu(dev_dsc->bcdUSB) < 0x0201U) { + errno = -ENOTSUP; + return 0; + } + desc_fill_bos_root(uds_ctx, &bos); len = MIN(net_buf_tailroom(buf), MIN(setup->wLength, bos.wTotalLength)); From e014330c2f4e2776987d3c00092d3beb4100f99b Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Thu, 16 May 2024 21:47:35 +0530 Subject: [PATCH 015/504] [nrf fromlist] tests: spi_loopback: Fix high RAM usage Display diff of contents for large buffers is not quite helpful and takes up huge RAM, and if a board has less RAM then this causes the test module build failures. So, disable display of diff and just log a failure, small buffer tests can be used to debug such basic issues and large buffer tests can act as a smoke test for debugging other issues. This saves about 80K of RAM. Fixes #72792. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/72895 Signed-off-by: Chaitanya Tata Signed-off-by: Robert Lubos (cherry picked from commit 481440f01ac1fd164f34e1338379f92e0646836b) --- tests/drivers/spi/spi_loopback/src/spi.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/drivers/spi/spi_loopback/src/spi.c b/tests/drivers/spi/spi_loopback/src/spi.c index ea76f8e4f7b..f091f436396 100644 --- a/tests/drivers/spi/spi_loopback/src/spi.c +++ b/tests/drivers/spi/spi_loopback/src/spi.c @@ -88,9 +88,6 @@ static uint8_t buffer_print_rx[BUF_SIZE * 5 + 1]; static uint8_t buffer_print_tx2[BUF2_SIZE * 5 + 1]; static uint8_t buffer_print_rx2[BUF2_SIZE * 5 + 1]; -static uint8_t large_buffer_print_tx[BUF3_SIZE * 5 + 1]; -static uint8_t large_buffer_print_rx[BUF3_SIZE * 5 + 1]; - static void to_display_format(const uint8_t *src, size_t size, char *dst) { size_t i; @@ -558,10 +555,6 @@ static int spi_complete_large_transfers(struct spi_dt_spec *spec) } if (memcmp(large_buffer_tx, large_buffer_rx, BUF3_SIZE)) { - to_display_format(large_buffer_tx, BUF3_SIZE, large_buffer_print_tx); - to_display_format(large_buffer_rx, BUF3_SIZE, large_buffer_print_rx); - LOG_ERR("Large Buffer contents are different: %s", large_buffer_print_tx); - LOG_ERR(" vs: %s", large_buffer_print_rx); zassert_false(1, "Large Buffer contents are different"); return -1; } @@ -691,10 +684,6 @@ static int spi_async_call(struct spi_dt_spec *spec) } if (memcmp(large_buffer_tx, large_buffer_rx, BUF3_SIZE)) { - to_display_format(large_buffer_tx, BUF3_SIZE, large_buffer_print_tx); - to_display_format(large_buffer_rx, BUF3_SIZE, large_buffer_print_rx); - LOG_ERR("Buffer 3 contents are different: %s", large_buffer_print_tx); - LOG_ERR(" vs: %s", large_buffer_print_rx); zassert_false(1, "Buffer 3 contents are different"); return -1; } From 335ed9e3d94f86a4ef994480f8b6173a74f80595 Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Wed, 22 May 2024 09:27:10 +0200 Subject: [PATCH 016/504] [nrf fromtree] samples: Bluetooth: hci_vs_scan_req: Build for BT_LL_SW_SPLIT only Build the vendor specific sample hci_vs_scan_req for BT_LL_SW_SPLIT variant of the Controller only. Signed-off-by: Vinayak Kariappa Chettimada (cherry picked from commit 68bd4da4c64ca0c19cee0334bee6496ec8cde2b9) Signed-off-by: Robert Lubos (cherry picked from commit b953fbb2ab19247f94bb52e28bea2762e4145b01) --- samples/bluetooth/hci_vs_scan_req/sample.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/bluetooth/hci_vs_scan_req/sample.yaml b/samples/bluetooth/hci_vs_scan_req/sample.yaml index 9f2aad6f363..245a83aa0d9 100644 --- a/samples/bluetooth/hci_vs_scan_req/sample.yaml +++ b/samples/bluetooth/hci_vs_scan_req/sample.yaml @@ -5,8 +5,8 @@ tests: harness: bluetooth platform_allow: - nrf52dk/nrf52832 - - qemu_cortex_m3 - - qemu_x86 - tags: bluetooth integration_platforms: - - qemu_cortex_m3 + - nrf52dk/nrf52832 + extra_configs: + - CONFIG_BT_LL_SW_SPLIT=y + tags: bluetooth From 78d181936d65fa1271bd3644af2a4e29062bc74a Mon Sep 17 00:00:00 2001 From: Maciej Perkowski Date: Wed, 22 May 2024 13:38:01 +0200 Subject: [PATCH 017/504] [nrf fromtree] requirements: Set min version of pylint to 3 PR #72592 made pylint to use json2 output format. However, this format is introduced in pylint v3. This commit adds an appropriate setting in the requirements file. Signed-off-by: Maciej Perkowski (cherry picked from commit 3a3f25c9a683562dcf09232eb754fa544affac3b) Signed-off-by: Robert Lubos (cherry picked from commit c65c95f5559b197dedf80781481d4c7a958ea336) --- scripts/requirements-compliance.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/requirements-compliance.txt b/scripts/requirements-compliance.txt index 31c395ac4f0..68469fc80ea 100644 --- a/scripts/requirements-compliance.txt +++ b/scripts/requirements-compliance.txt @@ -5,5 +5,5 @@ python-magic python-magic-bin; sys_platform == "win32" lxml junitparser>=2 -pylint +pylint>=3 yamllint From 3045b24aa33e067ea570e7342dd15bfd7f2d2e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Wed, 22 May 2024 15:11:33 +0200 Subject: [PATCH 018/504] [nrf fromtree] boards: nordic: 54l: use wdt31 instead of wdt30 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use wdt31 instead of wdt30 as wdt30 is hardware fixed to secure. Signed-off-by: Sebastian Bøe (cherry picked from commit 9ef16f55cdc8254ca3490ffac83f6b31aef5a781) Signed-off-by: Robert Lubos (cherry picked from commit 8d7f0694bfb199a40fa6c37553a36450b2fb0d21) --- boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15-common.dtsi | 2 +- .../drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay | 2 +- .../watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay | 2 +- .../watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay | 2 +- .../wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15-common.dtsi b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15-common.dtsi index 028bcfccd54..75dbe784097 100644 --- a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15-common.dtsi +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15-common.dtsi @@ -60,7 +60,7 @@ sw1 = &button1; sw2 = &button2; sw3 = &button3; - watchdog0 = &wdt30; + watchdog0 = &wdt31; }; }; diff --git a/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay index 66157d79fb3..5c765a8a896 100644 --- a/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay +++ b/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -3,6 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -&wdt30 { +&wdt31 { status = "okay"; }; diff --git a/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay b/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay index 66157d79fb3..5c765a8a896 100644 --- a/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay +++ b/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay @@ -3,6 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -&wdt30 { +&wdt31 { status = "okay"; }; diff --git a/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay b/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay index 66157d79fb3..5c765a8a896 100644 --- a/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay +++ b/samples/drivers/watchdog/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay @@ -3,6 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -&wdt30 { +&wdt31 { status = "okay"; }; diff --git a/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay index aa2789dd45e..8d3dce3b380 100644 --- a/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay +++ b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay @@ -4,6 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -&wdt30 { +&wdt31 { status = "okay"; }; From 7d674e8958fd1e267487246fb9b7413b548a87ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Fri, 24 May 2024 11:43:08 +0200 Subject: [PATCH 019/504] [nrf fromtree] samples: wdt_basic_api: nrf: Add missing nrf overlays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing nrf overlays to fix the sample at build time. Copied from samples/drivers/watchdog/boards. It is not clear why the build failure was not detected earlier. Signed-off-by: Sebastian Bøe (cherry picked from commit afbaaf241d87262136c367e1df54241468bb6d70) Signed-off-by: Robert Lubos (cherry picked from commit b21fbb55e6d602e1c4d18a4a47cd663e749c49b7) --- .../boards/nrf54h20dk_nrf54h20_cpuapp.overlay | 8 ++++++++ .../boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay | 8 ++++++++ .../boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay create mode 100644 tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay create mode 100644 tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay diff --git a/tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 00000000000..94e0d719af4 --- /dev/null +++ b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,8 @@ +/* + * Copyright 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +&wdt010 { + status = "okay"; +}; diff --git a/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay new file mode 100644 index 00000000000..5c765a8a896 --- /dev/null +++ b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuflpr.overlay @@ -0,0 +1,8 @@ +/* + * Copyright 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +&wdt31 { + status = "okay"; +}; diff --git a/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay new file mode 100644 index 00000000000..5c765a8a896 --- /dev/null +++ b/tests/drivers/watchdog/wdt_basic_api/boards/nrf54l15pdk_nrf54l15_cpuflpr_xip.overlay @@ -0,0 +1,8 @@ +/* + * Copyright 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +&wdt31 { + status = "okay"; +}; From 36ff72f6cfcb2ab35f86a22a60f627fccd318deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Wed, 22 May 2024 15:12:17 +0200 Subject: [PATCH 020/504] [nrf fromtree] dts: nordic: 54l: Don't define wdt30 for the non-secure domain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't define wdt30 for the non-secure domain as it is hardware fixed to secure. Signed-off-by: Sebastian Bøe (cherry picked from commit 50aaaa30c28c49fb5b79ff7236989992ebc484b2) Signed-off-by: Robert Lubos (cherry picked from commit 97d39cdeca22b55a584746266b3b8ee4881ce7b1) --- dts/common/nordic/nrf54l15.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dts/common/nordic/nrf54l15.dtsi b/dts/common/nordic/nrf54l15.dtsi index a15ead43953..b3c44f4c6b7 100644 --- a/dts/common/nordic/nrf54l15.dtsi +++ b/dts/common/nordic/nrf54l15.dtsi @@ -567,12 +567,16 @@ status = "disabled"; }; +#ifdef USE_NON_SECURE_ADDRESS_MAP + /* intentionally empty because WDT30 is hardware fixed to Secure */ +#else wdt30: watchdog@108000 { compatible = "nordic,nrf-wdt"; reg = <0x108000 0x620>; interrupts = <264 NRF_DEFAULT_IRQ_PRIORITY>; status = "disabled"; }; +#endif wdt31: watchdog@109000 { compatible = "nordic,nrf-wdt"; From 371f75762e57dab8288fd6df089aacb19705da5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Wed, 22 May 2024 15:12:57 +0200 Subject: [PATCH 021/504] [nrf fromtree] dts: nordic: 54l: Don't define UICR for the non-secure domain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't define UICR for the non-secure domain as it is hardware fixed to secure. Signed-off-by: Sebastian Bøe (cherry picked from commit 2c19d3ea9240a3508b63424f1aad28521c5c67ab) Signed-off-by: Robert Lubos (cherry picked from commit 258fef2984736479f94585650b447966130e8062) --- dts/common/nordic/nrf54l15.dtsi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dts/common/nordic/nrf54l15.dtsi b/dts/common/nordic/nrf54l15.dtsi index b3c44f4c6b7..93bfaa5db53 100644 --- a/dts/common/nordic/nrf54l15.dtsi +++ b/dts/common/nordic/nrf54l15.dtsi @@ -104,11 +104,14 @@ #address-cells = <1>; #size-cells = <1>; +#ifdef USE_NON_SECURE_ADDRESS_MAP + /* intentionally empty because UICR is hardware fixed to Secure */ +#else uicr: uicr@ffd000 { compatible = "nordic,nrf-uicr"; reg = <0xffd000 0x1000>; }; - +#endif ficr: ficr@ffc000 { compatible = "nordic,nrf-ficr"; reg = <0xffc000 0x1000>; From 6145e18a77f39eb54554fd8c8df3e9256e0347f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Wed, 22 May 2024 15:13:58 +0200 Subject: [PATCH 022/504] [nrf fromtree] dts: nordic: 54l: Change the peripheral address map for ns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Define peripherals with the 0x4000_0000 address range when building for non-secure. Signed-off-by: Sebastian Bøe (cherry picked from commit 90332b9a0b3d800c2fe28ab7672e36598e204113) Signed-off-by: Robert Lubos (cherry picked from commit 3f449c6ac29821d29001915fee27d7928ebd5b19) --- dts/common/nordic/nrf54l15.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dts/common/nordic/nrf54l15.dtsi b/dts/common/nordic/nrf54l15.dtsi index 93bfaa5db53..0b8eb1c549a 100644 --- a/dts/common/nordic/nrf54l15.dtsi +++ b/dts/common/nordic/nrf54l15.dtsi @@ -134,10 +134,17 @@ ranges = <0x0 0x2002f000 0x11000>; }; +#ifdef USE_NON_SECURE_ADDRESS_MAP + global_peripherals: peripheral@40000000 { + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x40000000 0x10000000>; +#else global_peripherals: peripheral@50000000 { #address-cells = <1>; #size-cells = <1>; ranges = <0x0 0x50000000 0x10000000>; +#endif dppic00: dppic@42000 { compatible = "nordic,nrf-dppic"; From 2a78f1d63f6e0fc8325b7d2d821636d15bf5c49a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Wed, 22 May 2024 15:14:35 +0200 Subject: [PATCH 023/504] [nrf fromtree] boards: nordic: 54L: Refactor the board DT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor the 54L board file to be able to better support out-of-tree non-secure boards. This aligns better with nrf53's DT. Signed-off-by: Sebastian Bøe (cherry picked from commit 80209e4fd0b217d8587704cab7ed82999f6549ef) Signed-off-by: Robert Lubos (cherry picked from commit f24cfb1491be0d09d36e57e528f66507733ca774) --- .../nrf54l15pdk/nrf54l15_cpuapp_common.dtsi | 150 ++++++++++++++++++ .../nrf54l15pdk_nrf54l15_cpuapp.dts | 139 +--------------- 2 files changed, 152 insertions(+), 137 deletions(-) create mode 100644 boards/nordic/nrf54l15pdk/nrf54l15_cpuapp_common.dtsi diff --git a/boards/nordic/nrf54l15pdk/nrf54l15_cpuapp_common.dtsi b/boards/nordic/nrf54l15pdk/nrf54l15_cpuapp_common.dtsi new file mode 100644 index 00000000000..2fa2ec36428 --- /dev/null +++ b/boards/nordic/nrf54l15pdk/nrf54l15_cpuapp_common.dtsi @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* This file is common to the secure and non-secure domain */ + +#include +#include "nrf54l15pdk_nrf54l15-common.dtsi" + +/ { + chosen { + zephyr,console = &uart20; + zephyr,shell-uart = &uart20; + zephyr,uart-mcumgr = &uart20; + zephyr,flash-controller = &rram_controller; + zephyr,flash = &cpuapp_rram; + zephyr,ieee802154 = &ieee802154; + }; + + aliases { + spi-flash0 = &mx25r64; + }; +}; + +&cpuapp_sram { + status = "okay"; +}; + +&lfxo { + load-capacitors = "internal"; + load-capacitance-femtofarad = <15500>; +}; + +&hfxo { + load-capacitors = "internal"; + load-capacitance-femtofarad = <15000>; +}; + +&grtc { + owned-channels = <0 1 2 3 4 5 6 7 8 9 10 11>; + /* Channels 7-11 reserved for Zero Latency IRQs, 3-4 for FLPR */ + child-owned-channels = <3 4 7 8 9 10 11>; + status = "okay"; +}; + +&cpuapp_rram { + 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@10000 { + label = "image-0"; + reg = <0x10000 DT_SIZE_K(324)>; + }; + slot0_ns_partition: partition@61000 { + label = "image-0-nonsecure"; + reg = <0x61000 DT_SIZE_K(324)>; + }; + slot1_partition: partition@b2000 { + label = "image-1"; + reg = <0xb2000 DT_SIZE_K(324)>; + }; + slot1_ns_partition: partition@103000 { + label = "image-1-nonsecure"; + reg = <0x103000 DT_SIZE_K(324)>; + }; + /* 32k from 0x154000 to 0x15bfff reserved for TF-M partitions */ + storage_partition: partition@15c000 { + label = "storage"; + reg = <0x15c000 DT_SIZE_K(36)>; + }; + }; +}; + +&uart20 { + status = "okay"; + hw-flow-control; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpiote20 { + status = "okay"; +}; + +&gpiote30 { + status = "okay"; +}; + +&radio { + status = "okay"; +}; + +&ieee802154 { + status = "okay"; +}; + +&temp { + status = "okay"; +}; + +&clock { + status = "okay"; +}; + +&spi00 { + status = "okay"; + cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&spi00_default>; + pinctrl-1 = <&spi00_sleep>; + pinctrl-names = "default", "sleep"; + + mx25r64: mx25r6435f@0 { + compatible = "jedec,spi-nor"; + status = "disabled"; + reg = <0>; + spi-max-frequency = <8000000>; + jedec-id = [c2 28 17]; + sfdp-bfp = [ + e5 20 f1 ff ff ff ff 03 44 eb 08 6b 08 3b 04 bb + ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52 + 10 d8 00 ff 23 72 f5 00 82 ed 04 cc 44 83 48 44 + 30 b0 30 b0 f7 c4 d5 5c 00 be 29 ff f0 d0 ff ff + ]; + size = <67108864>; + has-dpd; + t-enter-dpd = <10000>; + t-exit-dpd = <35000>; + }; +}; + +&adc { + status = "okay"; +}; diff --git a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts index 24b15763bdc..831479ea950 100644 --- a/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts +++ b/boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts @@ -5,150 +5,15 @@ */ /dts-v1/; -#include -#include "nrf54l15pdk_nrf54l15-common.dtsi" + +#include "nrf54l15_cpuapp_common.dtsi" / { compatible = "nordic,nrf54l15pdk_nrf54l15-cpuapp"; model = "Nordic nRF54L15 PDK nRF54L15 Application MCU"; chosen { - zephyr,console = &uart20; - zephyr,shell-uart = &uart20; - zephyr,uart-mcumgr = &uart20; - zephyr,flash-controller = &rram_controller; - zephyr,flash = &cpuapp_rram; zephyr,code-partition = &slot0_partition; zephyr,sram = &cpuapp_sram; - zephyr,ieee802154 = &ieee802154; - }; - - aliases { - spi-flash0 = &mx25r64; - }; -}; - -&cpuapp_sram { - status = "okay"; -}; - -&lfxo { - load-capacitors = "internal"; - load-capacitance-femtofarad = <15500>; -}; - -&hfxo { - load-capacitors = "internal"; - load-capacitance-femtofarad = <15000>; -}; - -&grtc { - owned-channels = <0 1 2 3 4 5 6 7 8 9 10 11>; - /* Channels 7-11 reserved for Zero Latency IRQs, 3-4 for FLPR */ - child-owned-channels = <3 4 7 8 9 10 11>; - status = "okay"; -}; - -&cpuapp_rram { - 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@10000 { - label = "image-0"; - reg = <0x10000 DT_SIZE_K(324)>; - }; - slot0_ns_partition: partition@61000 { - label = "image-0-nonsecure"; - reg = <0x61000 DT_SIZE_K(324)>; - }; - slot1_partition: partition@b2000 { - label = "image-1"; - reg = <0xb2000 DT_SIZE_K(324)>; - }; - slot1_ns_partition: partition@103000 { - label = "image-1-nonsecure"; - reg = <0x103000 DT_SIZE_K(324)>; - }; - /* 32k from 0x154000 to 0x15bfff reserved for TF-M partitions */ - storage_partition: partition@15c000 { - label = "storage"; - reg = <0x15c000 DT_SIZE_K(36)>; - }; - }; -}; - -&uart20 { - status = "okay"; - hw-flow-control; -}; - -&gpio0 { - status = "okay"; -}; - -&gpio1 { - status = "okay"; -}; - -&gpio2 { - status = "okay"; -}; - -&gpiote20 { - status = "okay"; -}; - -&gpiote30 { - status = "okay"; -}; - -&radio { - status = "okay"; -}; - -&ieee802154 { - status = "okay"; -}; - -&temp { - status = "okay"; -}; - -&clock { - status = "okay"; -}; - -&spi00 { - status = "okay"; - cs-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>; - pinctrl-0 = <&spi00_default>; - pinctrl-1 = <&spi00_sleep>; - pinctrl-names = "default", "sleep"; - - mx25r64: mx25r6435f@0 { - compatible = "jedec,spi-nor"; - status = "disabled"; - reg = <0>; - spi-max-frequency = <8000000>; - jedec-id = [c2 28 17]; - sfdp-bfp = [ - e5 20 f1 ff ff ff ff 03 44 eb 08 6b 08 3b 04 bb - ee ff ff ff ff ff 00 ff ff ff 00 ff 0c 20 0f 52 - 10 d8 00 ff 23 72 f5 00 82 ed 04 cc 44 83 48 44 - 30 b0 30 b0 f7 c4 d5 5c 00 be 29 ff f0 d0 ff ff - ]; - size = <67108864>; - has-dpd; - t-enter-dpd = <10000>; - t-exit-dpd = <35000>; }; }; - -&adc { - status = "okay"; -}; From 01e0f7d0c096e935e9d234ba1a1b1df6759b9ab5 Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Wed, 22 May 2024 15:56:44 +0300 Subject: [PATCH 024/504] [nrf fromlist] net: lwm2m: Fix null dereference when post-write cb is set When opaque resources have post-write callback set, but the write is not a Block-Wise write, there is no block_ctx and the code causes null pointer dereference when calculating the offset of the data. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73162 Signed-off-by: Seppo Takalo Signed-off-by: Robert Lubos (cherry picked from commit 33173b012bd70849b974d419a40f5e38a7b0946b) --- subsys/net/lib/lwm2m/lwm2m_message_handling.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subsys/net/lib/lwm2m/lwm2m_message_handling.c b/subsys/net/lib/lwm2m/lwm2m_message_handling.c index f7e79dc40aa..41165ef4063 100644 --- a/subsys/net/lib/lwm2m/lwm2m_message_handling.c +++ b/subsys/net/lib/lwm2m/lwm2m_message_handling.c @@ -996,10 +996,10 @@ static int lwm2m_write_handler_opaque(struct lwm2m_engine_obj_inst *obj_inst, #endif /* CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE > 0 */ if (res->post_write_cb) { - ret = res->post_write_cb(obj_inst->obj_inst_id, res->res_id, - res_inst->res_inst_id, data_ptr, len, - last_pkt_block && last_block, opaque_ctx.len, - msg->in.block_ctx->ctx.current); + ret = res->post_write_cb( + obj_inst->obj_inst_id, res->res_id, res_inst->res_inst_id, data_ptr, + len, last_pkt_block && last_block, opaque_ctx.len, + (msg->in.block_ctx ? msg->in.block_ctx->ctx.current : 0)); if (ret < 0) { return ret; } From 13df1dda8e87f75b0b7d2d22c3b8fcf2104bcf74 Mon Sep 17 00:00:00 2001 From: Tomi Fontanilles Date: Wed, 22 May 2024 15:41:00 +0300 Subject: [PATCH 025/504] [nrf fromtree] modules: tf-m: nordic: remove problematic include path It made the build of `samples/tfm_integration/tfm_psa_test/sample.tfm.psa_test_crypto` break since the update of Mbed TLS to 3.6.0 (#71118), apparently because `${ZEPHYR_BASE}` wasn't set, and the include doesn't seem to be needed. Signed-off-by: Tomi Fontanilles (cherry picked from commit d830446c91b1c819fa58b5ecb6fc5f31e8064f85) Signed-off-by: Robert Lubos (cherry picked from commit e47e2a08744790741330978ecf43eab9f7c39ce0) --- modules/trusted-firmware-m/nordic/CMakeLists.txt | 1 - modules/trusted-firmware-m/nordic/ns/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/trusted-firmware-m/nordic/CMakeLists.txt b/modules/trusted-firmware-m/nordic/CMakeLists.txt index d75b34a8109..c351f97f906 100644 --- a/modules/trusted-firmware-m/nordic/CMakeLists.txt +++ b/modules/trusted-firmware-m/nordic/CMakeLists.txt @@ -14,7 +14,6 @@ set(partition_includes set(board_includes ${CMAKE_BINARY_DIR}/../zephyr/misc/generated/syscalls_links/include - ${ZEPHYR_BASE}/include ) target_include_directories(platform_region_defs diff --git a/modules/trusted-firmware-m/nordic/ns/CMakeLists.txt b/modules/trusted-firmware-m/nordic/ns/CMakeLists.txt index 5bb8cb5bd94..67ee755c25e 100644 --- a/modules/trusted-firmware-m/nordic/ns/CMakeLists.txt +++ b/modules/trusted-firmware-m/nordic/ns/CMakeLists.txt @@ -17,7 +17,6 @@ set(partition_includes set(board_includes ${CMAKE_BINARY_DIR}/../zephyr/misc/generated/syscalls_links/include - ${ZEPHYR_BASE}/include ) target_include_directories(platform_region_defs From 25c7897a3b277051b44c8c52d672775667f28350 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Fri, 24 May 2024 10:43:53 +0200 Subject: [PATCH 026/504] [nrf fromlist] samples: net: Exclude native_posix when socket service lib is used Socket service library uses eventfd, which does not work with native_posix platform, hence need to exclude it from samples that now rely on socket services. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73256 Signed-off-by: Robert Lubos (cherry picked from commit b0630e599e06502da9b9e755d54dd495db9f2784) --- samples/net/dns_resolve/sample.yaml | 3 +++ samples/net/sockets/big_http_download/sample.yaml | 3 +++ samples/net/sockets/http_get/sample.yaml | 3 +++ samples/posix/gettimeofday/sample.yaml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/samples/net/dns_resolve/sample.yaml b/samples/net/dns_resolve/sample.yaml index f5808607b57..cafc9beac83 100644 --- a/samples/net/dns_resolve/sample.yaml +++ b/samples/net/dns_resolve/sample.yaml @@ -4,6 +4,9 @@ common: tags: - net - dns + platform_exclude: + - native_posix + - native_posix/native/64 sample: description: DNS resolver, mDNS and LLMNR responder name: DNS resolver and responder sample application diff --git a/samples/net/sockets/big_http_download/sample.yaml b/samples/net/sockets/big_http_download/sample.yaml index b8777a4e871..683b8c5c52c 100644 --- a/samples/net/sockets/big_http_download/sample.yaml +++ b/samples/net/sockets/big_http_download/sample.yaml @@ -9,6 +9,9 @@ common: tags: - net - socket + platform_exclude: + - native_posix + - native_posix/native/64 tests: sample.net.sockets.big_http_download: extra_configs: diff --git a/samples/net/sockets/http_get/sample.yaml b/samples/net/sockets/http_get/sample.yaml index 4e454da50a7..2d584cf5e99 100644 --- a/samples/net/sockets/http_get/sample.yaml +++ b/samples/net/sockets/http_get/sample.yaml @@ -8,6 +8,9 @@ common: tags: - net - socket + platform_exclude: + - native_posix + - native_posix/native/64 tests: sample.net.sockets.http_get: filter: not CONFIG_NET_SOCKETS_OFFLOAD and not CONFIG_NATIVE_LIBC diff --git a/samples/posix/gettimeofday/sample.yaml b/samples/posix/gettimeofday/sample.yaml index a71d29f09c5..88748aab2a6 100644 --- a/samples/posix/gettimeofday/sample.yaml +++ b/samples/posix/gettimeofday/sample.yaml @@ -10,6 +10,9 @@ common: tags: - posix - net + platform_exclude: + - native_posix + - native_posix/native/64 tests: sample.posix.gettimeofday: harness: net From 90eb29043304d473f311295e8604ed4438e6bb03 Mon Sep 17 00:00:00 2001 From: Piotr Koziar Date: Mon, 6 May 2024 12:14:15 +0200 Subject: [PATCH 027/504] [nrf fromlist] dts: nrf54h20: add grtc channel 15 to the pool. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73156 Adds channel 15 to the pool of grtc channels available for allocation (i.e. with 'z_nrf_grtc_timer_chan_alloc') on nRF54H20. The change is motivated by lack of available channels for the nrf_802154_timestamper when building for nRF54H20. Signed-off-by: Piotr Koziar (cherry picked from commit 61b8c9bf8ac8e44fe29b5f6a3b0e0528845fad50) --- dts/arm/nordic/nrf54h20_cpurad.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dts/arm/nordic/nrf54h20_cpurad.dtsi b/dts/arm/nordic/nrf54h20_cpurad.dtsi index e4a7469dac5..b426d660f3d 100644 --- a/dts/arm/nordic/nrf54h20_cpurad.dtsi +++ b/dts/arm/nordic/nrf54h20_cpurad.dtsi @@ -50,7 +50,7 @@ wdt011: &cpurad_wdt011 {}; }; &grtc { - owned-channels = <7 8 9 10 11 12 13 14>; + owned-channels = <7 8 9 10 11 12 13 14 15>; child-owned-channels = <8 9 10 11 12>; nonsecure-channels = <8 9 10 11 12>; interrupts = <109 NRF_DEFAULT_IRQ_PRIORITY>, From 447372a29e92fe444025ab8022e29679688b9364 Mon Sep 17 00:00:00 2001 From: Piotr Koziar Date: Mon, 13 May 2024 22:17:47 +0200 Subject: [PATCH 028/504] [nrf fromlist] modules: hal_nordic: implement hfclk start/stop for cases when clock_control is not available. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73156 Clock_control is currently not supported on nRF54H20. This commit adds new way of handling the hfclk targeted for nRF54H20. This solution shall be replaced once the clock_control is supported for nRF54H20. Signed-off-by: Piotr Koziar (cherry picked from commit 4f8c7a62a375b4b2295f04facc9d47b055be43f1) --- .../platform/nrf_802154_clock_zephyr.c | 80 +++++++++---------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c b/modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c index 3a3d9501d0c..1db86f5ad14 100644 --- a/modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c +++ b/modules/hal_nordic/nrf_802154/sl_opensource/platform/nrf_802154_clock_zephyr.c @@ -4,18 +4,21 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include #include +#include +#if defined(CONFIG_CLOCK_CONTROL_NRF) #include #include +#elif !defined(NRF54H_SERIES) +#error No implementation to start or stop HFCLK due to missing clock_control. +#endif static bool hfclk_is_running; -static bool lfclk_is_running; -static struct onoff_client hfclk_cli; -static struct onoff_client lfclk_cli; void nrf_802154_clock_init(void) { @@ -27,6 +30,15 @@ void nrf_802154_clock_deinit(void) /* Intentionally empty. */ } +bool nrf_802154_clock_hfclk_is_running(void) +{ + return hfclk_is_running; +} + +#if defined(CONFIG_CLOCK_CONTROL_NRF) + +static struct onoff_client hfclk_cli; + static void hfclk_on_callback(struct onoff_manager *mgr, struct onoff_client *cli, uint32_t state, @@ -63,53 +75,39 @@ void nrf_802154_clock_hfclk_stop(void) hfclk_is_running = false; } -bool nrf_802154_clock_hfclk_is_running(void) -{ - return hfclk_is_running; -} +#elif defined(NRF54H_SERIES) -static void lfclk_on_callback(struct onoff_manager *mgr, - struct onoff_client *cli, - uint32_t state, - int res) -{ - lfclk_is_running = true; - nrf_802154_clock_lfclk_ready(); -} +#define NRF_LRCCONF_RADIO_PD NRF_LRCCONF010 +#define MAX_HFXO_RAMP_UP_TIME_US 1000 -void nrf_802154_clock_lfclk_start(void) +static void hfclk_started_timer_handler(struct k_timer *dummy) { - int ret; - struct onoff_manager *mgr = - z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_LF); - - __ASSERT_NO_MSG(mgr != NULL); - - sys_notify_init_callback(&lfclk_cli.notify, lfclk_on_callback); - - ret = onoff_request(mgr, &lfclk_cli); - __ASSERT_NO_MSG(ret >= 0); + hfclk_is_running = true; + nrf_802154_clock_hfclk_ready(); } -void nrf_802154_clock_lfclk_stop(void) -{ - int ret; - struct onoff_manager *mgr = - z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_LF); +K_TIMER_DEFINE(hfclk_started_timer, hfclk_started_timer_handler, NULL); - __ASSERT_NO_MSG(mgr != NULL); +void nrf_802154_clock_hfclk_start(void) +{ + /* Use register directly, there is no support for that task in nrf_lrcconf_task_trigger. + * This code might cause troubles if there are other HFXO users in this CPU. + */ + NRF_LRCCONF_RADIO_PD->EVENTS_HFXOSTARTED = 0x0; + NRF_LRCCONF_RADIO_PD->TASKS_REQHFXO = 0x1; - ret = onoff_cancel_or_release(mgr, &lfclk_cli); - __ASSERT_NO_MSG(ret >= 0); - lfclk_is_running = false; + k_timer_start(&hfclk_started_timer, K_USEC(MAX_HFXO_RAMP_UP_TIME_US), K_NO_WAIT); } -bool nrf_802154_clock_lfclk_is_running(void) +void nrf_802154_clock_hfclk_stop(void) { - return lfclk_is_running; -} + /* Use register directly, there is no support for that task in nrf_lrcconf_task_trigger. + * This code might cause troubles if there are other HFXO users in this CPU. + */ + NRF_LRCCONF_RADIO_PD->TASKS_STOPREQHFXO = 0x1; + NRF_LRCCONF_RADIO_PD->EVENTS_HFXOSTARTED = 0x0; -__WEAK void nrf_802154_clock_lfclk_ready(void) -{ - /* Intentionally empty. */ + hfclk_is_running = false; } + +#endif From 5cf176e7e1818f5a818f2213aeff99a09cfa6b1f Mon Sep 17 00:00:00 2001 From: Piotr Koziar Date: Wed, 15 May 2024 16:10:59 +0200 Subject: [PATCH 029/504] [nrf fromlist] ipc: fix return code of icbmsg backend send operation. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73156 This commit fixes the issue where a serialization error was reported after properly sending a data with 'icbmsg' backend. The icbmsg send function's return code is set to the sent data's len as in other backends. The related docs were fixed and updated. Signed-off-by: Piotr Koziar (cherry picked from commit 78995ff7ca0a16cace6e59d08f5eb18eee12c607) --- include/zephyr/ipc/icmsg.h | 2 +- subsys/ipc/ipc_service/backends/ipc_icbmsg.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/zephyr/ipc/icmsg.h b/include/zephyr/ipc/icmsg.h index 3bc03804ca8..80e3412095a 100644 --- a/include/zephyr/ipc/icmsg.h +++ b/include/zephyr/ipc/icmsg.h @@ -111,7 +111,7 @@ int icmsg_close(const struct icmsg_config_t *conf, * @param[in] len Size of data in the @p msg buffer. * * - * @retval 0 on success. + * @retval Number of sent bytes. * @retval -EBUSY when the instance has not finished handshake with the remote * instance. * @retval -ENODATA when the requested data to send is empty. diff --git a/subsys/ipc/ipc_service/backends/ipc_icbmsg.c b/subsys/ipc/ipc_service/backends/ipc_icbmsg.c index 37594025313..4a3fdad1adf 100644 --- a/subsys/ipc/ipc_service/backends/ipc_icbmsg.c +++ b/subsys/ipc/ipc_service/backends/ipc_icbmsg.c @@ -501,7 +501,7 @@ static int send_control_message(struct backend_data *dev_data, enum msg_type msg r = icmsg_send(&conf->control_config, &dev_data->control_data, &message, sizeof(message)); k_mutex_unlock(&dev_data->mutex); - if (r < 0) { + if (r < sizeof(message)) { LOG_ERR("Cannot send over ICMsg, err %d", r); } return r; @@ -541,7 +541,7 @@ static int send_release(struct backend_data *dev_data, const uint8_t *buffer, * @param[in] size Actual size of the data, can be smaller than allocated, * but it cannot change number of required blocks. * - * @return O or negative error code. + * @return number of bytes sent in the message or negative error code. */ static int send_block(struct backend_data *dev_data, enum msg_type msg_type, uint8_t ept_addr, size_t tx_block_index, size_t size) @@ -656,7 +656,7 @@ static int match_bound_msg(struct backend_data *dev_data, size_t rx_block_index, * * @param[in] ept Endpoint to use. * - * @return O or negative error code. + * @return non-negative value in case of success or negative error code. */ static int send_bound_message(struct backend_data *dev_data, struct ept_data *ept) { @@ -992,7 +992,12 @@ static int send(const struct device *instance, void *token, const void *msg, siz memcpy(buffer, msg, len); /* Send data message. */ - return send_block(dev_data, MSG_DATA, ept->addr, r, len); + r = send_block(dev_data, MSG_DATA, ept->addr, r, len); + if (r < 0) { + return r; + } + + return len; } /** From e9d916e77f0deb80ee03b249364e5db2eb2e2bd8 Mon Sep 17 00:00:00 2001 From: Piotr Koziar Date: Tue, 21 May 2024 14:03:42 +0200 Subject: [PATCH 030/504] [nrf fromlist] modules: hal_nordic: turn off temperature update by default for nRF54H20. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73156 Adds an appropriate condition to the Kconfig as the temperature driver is not supported for nRF54H20 devices yet. Without this change, a build with NRF 802.15.4 libraries produces Kconfig error. Signed-off-by: Piotr Koziar (cherry picked from commit e41c78ce8e55e76619666a9cf71dc288863b9207) --- modules/hal_nordic/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hal_nordic/Kconfig b/modules/hal_nordic/Kconfig index a7d55e4620a..13ab8d9cd2f 100644 --- a/modules/hal_nordic/Kconfig +++ b/modules/hal_nordic/Kconfig @@ -55,7 +55,7 @@ endchoice config NRF_802154_TEMPERATURE_UPDATE bool "nRF 802.15.4 temperature update" - default y + default y if !SOC_NRF54H20 help Enable temperature update for nRF 802.15.4 driver From f3e496016708a5dfcf32dec4fd6f780e993ec260 Mon Sep 17 00:00:00 2001 From: Piotr Koziar Date: Wed, 22 May 2024 15:14:53 +0200 Subject: [PATCH 031/504] [nrf fromlist] drivers: ieee802154_nrf5: Use BLE.ADDR instead of FICR to create EUI64. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73156 Use BLE.ADDR to create unique (to some extent) EUI64 on nRF54H20 in some cases inside the IEEE 802.15.4 driver. The amount of EUI64-s available in such a way is very limited (~16 million). However, currently there does not seem to be another feasible way to get device identifiers on nRF54H20 (such are kept in SICR, to which the radio core has no access). Signed-off-by: Piotr Koziar (cherry picked from commit b8be35e1845520a4722866c313ba30760ae9691d) --- drivers/ieee802154/ieee802154_nrf5.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index 4cbdd9eb607..77993ac9fbb 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -126,7 +126,11 @@ static void nrf5_get_eui64(uint8_t *mac) mac[index++] = (IEEE802154_NRF5_VENDOR_OUI >> 8) & 0xff; mac[index++] = IEEE802154_NRF5_VENDOR_OUI & 0xff; -#if defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && defined(NRF_FICR_S) +#if defined(NRF54H_SERIES) + /* Can't access SICR with device id on a radio core. Use BLE.ADDR. */ + deviceid[0] = NRF_FICR->BLE.ADDR[0]; + deviceid[1] = NRF_FICR->BLE.ADDR[1]; +#elif defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) && defined(NRF_FICR_S) soc_secure_read_deviceid(deviceid); #else deviceid[0] = nrf_ficr_deviceid_get(NRF_FICR, 0); From 5507ce9275939448bf1fd49481fa653b8a872c98 Mon Sep 17 00:00:00 2001 From: Kapil Bhatt Date: Wed, 22 May 2024 14:45:28 +0530 Subject: [PATCH 032/504] [nrf fromtree] net: wifi: Add disconnection success code When disconnect request is successful, the status was taking as WIFI_REASON_DISCONN_UNSPECIFIED only. Adding WIFI_REASON_DISCONN_SUCCESS which can be help to determine status of disconnect request. If this status is failed then reason can be useful. Signed-off-by: Kapil Bhatt (cherry picked from commit cc42d16b1c6bb26dcabe754a485a7b2d0ca8ac02) Signed-off-by: Robert Lubos (cherry picked from commit a1769aba631b078769d182eaaea13aafc09039bc) --- include/zephyr/net/wifi_mgmt.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index 0442a91c2f2..8c2b61fa936 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -427,8 +427,10 @@ enum wifi_conn_status { * in the disconnect result event for detailed reason. */ enum wifi_disconn_reason { + /** Success, overload status as reason */ + WIFI_REASON_DISCONN_SUCCESS = 0, /** Unspecified reason */ - WIFI_REASON_DISCONN_UNSPECIFIED = WIFI_STATUS_DISCONN_FIRST_STATUS, + WIFI_REASON_DISCONN_UNSPECIFIED, /** Disconnected due to user request */ WIFI_REASON_DISCONN_USER_REQUEST, /** Disconnected due to AP leaving */ From 7d251fa9e300be60bfa9f9003b9837051216e77b Mon Sep 17 00:00:00 2001 From: Yuxuan Cai Date: Tue, 28 May 2024 07:19:48 -0700 Subject: [PATCH 033/504] [nrf fromlist] samples: Bluetooth: use correct periodic advertising intervals BT_GAP_ADV_SLOW_INT_MIN and BT_GAP_ADV_SLOW_INT_MAX represent 1s and 1.2s, respectively, in the extended advertising context, where the bit interval is 0.625 ms. Using them for periodic advertising will result in a range of [2s, 2.4s], as the bit interval for periodic advertising is 1.25ms. Instead, BT_GAP_PER_ADV_SLOW_INT_MIN and BT_GAP_PER_ADV_SLOW_INT_MAX should be used in this sample, and the range will become [1s, 1.2s]. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73418 Signed-off-by: Yuxuan Cai (cherry picked from commit dd4f7c3c8934f80151731cfc64dc1513adec6852) --- .../bluetooth/direction_finding_connectionless_tx/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/bluetooth/direction_finding_connectionless_tx/src/main.c b/samples/bluetooth/direction_finding_connectionless_tx/src/main.c index ef6a89b8852..f827e39a657 100644 --- a/samples/bluetooth/direction_finding_connectionless_tx/src/main.c +++ b/samples/bluetooth/direction_finding_connectionless_tx/src/main.c @@ -42,8 +42,8 @@ static struct bt_le_ext_adv_start_param ext_adv_start_param = { }; static struct bt_le_per_adv_param per_adv_param = { - .interval_min = BT_GAP_ADV_SLOW_INT_MIN, - .interval_max = BT_GAP_ADV_SLOW_INT_MAX, + .interval_min = BT_GAP_PER_ADV_SLOW_INT_MIN, + .interval_max = BT_GAP_PER_ADV_SLOW_INT_MAX, .options = BT_LE_ADV_OPT_USE_TX_POWER, }; From f725746179bbb13be9cdb972c56abfcec44f90a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ku=C5=BAnia?= Date: Tue, 28 May 2024 11:43:42 +0200 Subject: [PATCH 034/504] [nrf fromlist] scripts: west_commands: runners: nrf_common: optional UICR cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The flasher was unconditionally cleaning the UICR area, even when the application didn't have a new configuration generated. This can happen, when CONFIG_NRF_REGTOOL_GENERATE_UICR=n. In such case, keep the old UICR configuration on the device. A real scenario where we should set CONFIG_NRF_REGTOOL_GENERATE_UICR=n is when building multiple firmware images that are meant to run one domain. The primary application build generates the UICR configuration and secondary images don't. Before this change, the flashing process of the primary application would write new UICR configuration, but the flashing process of secondary images would erase it. Upstream PR: https://github.com/zephyrproject-rtos/zephyr/pull/73391 Signed-off-by: Rafał Kuźnia (cherry picked from commit 78d3dec9f93725fd453e1a3a960a1a4a6a12c483) --- scripts/west_commands/runners/nrf_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/west_commands/runners/nrf_common.py b/scripts/west_commands/runners/nrf_common.py index 1ea09f8f595..1d7b9706741 100644 --- a/scripts/west_commands/runners/nrf_common.py +++ b/scripts/west_commands/runners/nrf_common.py @@ -261,13 +261,13 @@ def program_hex(self): self.exec_op('erase', core='NRFDL_DEVICE_CORE_NETWORK') if self.build_conf.getboolean('CONFIG_SOC_NRF54H20_CPUAPP'): - if not self.erase: + if not self.erase and self.build_conf.getboolean('CONFIG_NRF_REGTOOL_GENERATE_UICR'): self.exec_op('erase', core='NRFDL_DEVICE_CORE_APPLICATION', chip_erase_mode='ERASE_UICR', qspi_erase_mode='ERASE_NONE') core = 'NRFDL_DEVICE_CORE_APPLICATION' elif self.build_conf.getboolean('CONFIG_SOC_NRF54H20_CPURAD'): - if not self.erase: + if not self.erase and self.build_conf.getboolean('CONFIG_NRF_REGTOOL_GENERATE_UICR'): self.exec_op('erase', core='NRFDL_DEVICE_CORE_NETWORK', chip_erase_mode='ERASE_UICR', qspi_erase_mode='ERASE_NONE') From e0bdc788498452efb2ccaaf5f2a2884e5128d413 Mon Sep 17 00:00:00 2001 From: Kapil Bhatt Date: Tue, 28 May 2024 15:47:02 +0530 Subject: [PATCH 035/504] [nrf fromtree] net: shell: Add random MAC address generation Add option for setting a random MAC address to the net iface set_mac command. With random option a random MAC address can be assigned to an interface. [SHEL-2352]. Signed-off-by: Kapil Bhatt (cherry picked from commit 8a52b6487529ee5d1fb73eb773ec46abf18370b8) (cherry picked from commit 0cfb2afa8178313403a5c28140a8d667905b8dc3) --- subsys/net/lib/shell/iface.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/subsys/net/lib/shell/iface.c b/subsys/net/lib/shell/iface.c index 00c681784ed..97533ecbccf 100644 --- a/subsys/net/lib/shell/iface.c +++ b/subsys/net/lib/shell/iface.c @@ -6,6 +6,8 @@ */ #include +#include +#include LOG_MODULE_DECLARE(net_shell); #if defined(CONFIG_NET_L2_ETHERNET) @@ -20,6 +22,9 @@ LOG_MODULE_DECLARE(net_shell); #include "net_shell_private.h" +#define UNICAST_MASK GENMASK(7, 1) +#define LOCAL_BIT BIT(1) + #if defined(CONFIG_NET_L2_ETHERNET) && defined(CONFIG_NET_NATIVE) struct ethernet_capabilities { enum ethernet_hw_caps capability; @@ -536,10 +541,15 @@ static int cmd_net_set_mac(const struct shell *sh, size_t argc, char *argv[]) goto err; } - if ((net_bytes_from_str(mac_addr, sizeof(params.mac_address), argv[2]) < 0) || - !net_eth_is_addr_valid(¶ms.mac_address)) { - PR_WARNING("Invalid MAC address: %s\n", argv[2]); - goto err; + if (!strncasecmp(argv[2], "random", 6)) { + sys_rand_get(mac_addr, NET_ETH_ADDR_LEN); + mac_addr[0] = (mac_addr[0] & UNICAST_MASK) | LOCAL_BIT; + } else { + if ((net_bytes_from_str(mac_addr, sizeof(params.mac_address), argv[2]) < 0) || + !net_eth_is_addr_valid(¶ms.mac_address)) { + PR_WARNING("Invalid MAC address: %s\n", argv[2]); + goto err; + } } ret = net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, iface, ¶ms, sizeof(params)); From 8f78d28936642c42f2e1118b4458e99bcb008666 Mon Sep 17 00:00:00 2001 From: Ajay Parida Date: Tue, 28 May 2024 14:52:15 +0530 Subject: [PATCH 036/504] [nrf fromtree] net: wifi: shell: Support to print name Support to print name of the argument along with the value. Signed-off-by: Ajay Parida (cherry picked from commit 180c22a4fcbae1d2f640200d3a11bb36e132998a) (cherry picked from commit 1f925799a3f1c2a327d4192918ffe5093d1b77b1) --- subsys/net/l2/wifi/wifi_shell.c | 47 +++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index ab2637a1271..7bdd9801650 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -75,7 +75,8 @@ struct wifi_ap_sta_node { }; static struct wifi_ap_sta_node sta_list[CONFIG_WIFI_SHELL_MAX_AP_STA]; -static bool parse_number(const struct shell *sh, long *param, char *str, long min, long max) +static bool parse_number(const struct shell *sh, long *param, char *str, + char *pname, long min, long max) { char *endptr; char *str_tmp = str; @@ -94,7 +95,13 @@ static bool parse_number(const struct shell *sh, long *param, char *str, long mi } if ((num) < (min) || (num) > (max)) { - PR_WARNING("Value out of range: %s, (%ld-%ld)", str_tmp, min, max); + if (pname) { + PR_WARNING("%s value out of range: %s, (%ld-%ld)", + pname, str_tmp, min, max); + } else { + PR_WARNING("Value out of range: %s, (%ld-%ld)", + str_tmp, min, max); + } return false; } *param = num; @@ -1067,12 +1074,12 @@ static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc, params.setup.trigger = 0; params.setup.announce = 0; - if (!parse_number(sh, &value, argv[idx++], 1, WIFI_MAX_TWT_WAKE_INTERVAL_US)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 1, WIFI_MAX_TWT_WAKE_INTERVAL_US)) { return -EINVAL; } params.setup.twt_wake_interval = (uint32_t)value; - if (!parse_number(sh, &value, argv[idx++], 1, WIFI_MAX_TWT_INTERVAL_US)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 1, WIFI_MAX_TWT_INTERVAL_US)) { return -EINVAL; } params.setup.twt_interval = (uint64_t)value; @@ -1105,59 +1112,59 @@ static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc, params.operation = WIFI_TWT_SETUP; - if (!parse_number(sh, &value, argv[idx++], WIFI_TWT_INDIVIDUAL, + if (!parse_number(sh, &value, argv[idx++], NULL, WIFI_TWT_INDIVIDUAL, WIFI_TWT_WAKE_TBTT)) { return -EINVAL; } params.negotiation_type = (enum wifi_twt_negotiation_type)value; - if (!parse_number(sh, &value, argv[idx++], WIFI_TWT_SETUP_CMD_REQUEST, + if (!parse_number(sh, &value, argv[idx++], NULL, WIFI_TWT_SETUP_CMD_REQUEST, WIFI_TWT_SETUP_CMD_DEMAND)) { return -EINVAL; } params.setup_cmd = (enum wifi_twt_setup_cmd)value; - if (!parse_number(sh, &value, argv[idx++], 1, 255)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 1, 255)) { return -EINVAL; } params.dialog_token = (uint8_t)value; - if (!parse_number(sh, &value, argv[idx++], 0, (WIFI_MAX_TWT_FLOWS - 1))) { + if (!parse_number(sh, &value, argv[idx++], NULL, 0, (WIFI_MAX_TWT_FLOWS - 1))) { return -EINVAL; } params.flow_id = (uint8_t)value; - if (!parse_number(sh, &value, argv[idx++], 0, 1)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 0, 1)) { return -EINVAL; } params.setup.responder = (bool)value; - if (!parse_number(sh, &value, argv[idx++], 0, 1)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 0, 1)) { return -EINVAL; } params.setup.trigger = (bool)value; - if (!parse_number(sh, &value, argv[idx++], 0, 1)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 0, 1)) { return -EINVAL; } params.setup.implicit = (bool)value; - if (!parse_number(sh, &value, argv[idx++], 0, 1)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 0, 1)) { return -EINVAL; } params.setup.announce = (bool)value; - if (!parse_number(sh, &value, argv[idx++], 1, WIFI_MAX_TWT_WAKE_INTERVAL_US)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 1, WIFI_MAX_TWT_WAKE_INTERVAL_US)) { return -EINVAL; } params.setup.twt_wake_interval = (uint32_t)value; - if (!parse_number(sh, &value, argv[idx++], 1, WIFI_MAX_TWT_INTERVAL_US)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 1, WIFI_MAX_TWT_INTERVAL_US)) { return -EINVAL; } params.setup.twt_interval = (uint64_t)value; - if (!parse_number(sh, &value, argv[idx++], 0, WIFI_MAX_TWT_WAKE_AHEAD_DURATION_US)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 0, WIFI_MAX_TWT_WAKE_AHEAD_DURATION_US)) { return -EINVAL; } params.setup.twt_wake_ahead_duration = (uint32_t)value; @@ -1190,24 +1197,24 @@ static int cmd_wifi_twt_teardown(const struct shell *sh, size_t argc, params.operation = WIFI_TWT_TEARDOWN; - if (!parse_number(sh, &value, argv[idx++], WIFI_TWT_INDIVIDUAL, + if (!parse_number(sh, &value, argv[idx++], NULL, WIFI_TWT_INDIVIDUAL, WIFI_TWT_WAKE_TBTT)) { return -EINVAL; } params.negotiation_type = (enum wifi_twt_negotiation_type)value; - if (!parse_number(sh, &value, argv[idx++], WIFI_TWT_SETUP_CMD_REQUEST, + if (!parse_number(sh, &value, argv[idx++], NULL, WIFI_TWT_SETUP_CMD_REQUEST, WIFI_TWT_SETUP_CMD_DEMAND)) { return -EINVAL; } params.setup_cmd = (enum wifi_twt_setup_cmd)value; - if (!parse_number(sh, &value, argv[idx++], 1, 255)) { + if (!parse_number(sh, &value, argv[idx++], NULL, 1, 255)) { return -EINVAL; } params.dialog_token = (uint8_t)value; - if (!parse_number(sh, &value, argv[idx++], 0, (WIFI_MAX_TWT_FLOWS - 1))) { + if (!parse_number(sh, &value, argv[idx++], NULL, 0, (WIFI_MAX_TWT_FLOWS - 1))) { return -EINVAL; } params.flow_id = (uint8_t)value; @@ -1441,7 +1448,7 @@ static int cmd_wifi_listen_interval(const struct shell *sh, size_t argc, char *a context.sh = sh; - if (!parse_number(sh, &interval, argv[1], + if (!parse_number(sh, &interval, argv[1], NULL, WIFI_LISTEN_INTERVAL_MIN, WIFI_LISTEN_INTERVAL_MAX)) { return -EINVAL; From 4561e4171c47986c382081f602d7429b68871f31 Mon Sep 17 00:00:00 2001 From: Ajay Parida Date: Wed, 8 May 2024 12:50:48 +0530 Subject: [PATCH 037/504] [nrf fromtree] net: wifi_mgmt: Support to configure AP mode parameter Support to set BSS parameter at compile and run time. Added support to configure `max_inactivity` BSS parameter. Station inactivity timeout is the period for which AP may keep a client in associated state while there is no traffic from that particular client. If a non-zero value is set, AP may choose to disassociate the client after the timeout. Signed-off-by: Ajay Parida (cherry picked from commit c6d1a91372082028b3e153a1246fde6f113eda80) (cherry picked from commit 975bfdeb143131f49c6a86568b0a2f824e61bbf5) --- include/zephyr/net/wifi.h | 6 +++ include/zephyr/net/wifi_mgmt.h | 30 ++++++++++++++- subsys/net/l2/wifi/Kconfig | 9 +++++ subsys/net/l2/wifi/wifi_mgmt.c | 25 +++++++++++++ subsys/net/l2/wifi/wifi_shell.c | 65 +++++++++++++++++++++++++++++++++ 5 files changed, 133 insertions(+), 2 deletions(-) diff --git a/include/zephyr/net/wifi.h b/include/zephyr/net/wifi.h index 5f47209b83f..ab00980a69c 100644 --- a/include/zephyr/net/wifi.h +++ b/include/zephyr/net/wifi.h @@ -494,6 +494,12 @@ static inline const char *wifi_ps_get_config_err_code_str(int16_t err_no) return ""; } +/** @brief Wi-Fi AP mode configuration parameter */ +enum wifi_ap_config_param { + /** Used for AP mode configuration parameter ap_max_inactivity */ + WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY = BIT(0), +}; + #ifdef __cplusplus } #endif diff --git a/include/zephyr/net/wifi_mgmt.h b/include/zephyr/net/wifi_mgmt.h index 8c2b61fa936..910ee030651 100644 --- a/include/zephyr/net/wifi_mgmt.h +++ b/include/zephyr/net/wifi_mgmt.h @@ -88,7 +88,8 @@ enum net_request_wifi_cmd { NET_REQUEST_WIFI_CMD_VERSION, /** Set RTS threshold */ NET_REQUEST_WIFI_CMD_RTS_THRESHOLD, - + /** Configure AP parameter */ + NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM, /** @cond INTERNAL_HIDDEN */ NET_REQUEST_WIFI_CMD_MAX /** @endcond */ @@ -190,6 +191,12 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION); NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD); +/** Request a Wi-Fi AP parameters configuration */ +#define NET_REQUEST_WIFI_AP_CONFIG_PARAM \ + (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM) + +NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM); + /** @brief Wi-Fi management events */ enum net_event_wifi_cmd { /** Scan results available */ @@ -746,6 +753,18 @@ struct wifi_channel_info { enum wifi_mgmt_op oper; }; +/** @cond INTERNAL_HIDDEN */ +#define WIFI_AP_STA_MAX_INACTIVITY (LONG_MAX - 1) +/** @endcond */ + +/** @brief Wi-Fi AP configuration parameter */ +struct wifi_ap_config_params { + /** Parameter used to identify the different AP parameters */ + enum wifi_ap_config_param type; + /** Parameter used for setting maximum inactivity duration for stations */ + uint32_t max_inactivity; +}; + #include /** Scan result callback @@ -919,7 +938,14 @@ struct wifi_mgmt_ops { * @return 0 if ok, < 0 if error */ int (*set_rts_threshold)(const struct device *dev, unsigned int rts_threshold); - + /** Configure AP parameter + * + * @param dev Pointer to the device structure for the driver instance. + * @param params AP mode parameter configuration parameter info + * + * @return 0 if ok, < 0 if error + */ + int (*ap_config_params)(const struct device *dev, struct wifi_ap_config_params *params); }; /** Wi-Fi management offload API */ diff --git a/subsys/net/l2/wifi/Kconfig b/subsys/net/l2/wifi/Kconfig index 2816be56d74..0ad0858fab2 100644 --- a/subsys/net/l2/wifi/Kconfig +++ b/subsys/net/l2/wifi/Kconfig @@ -93,3 +93,12 @@ module-str = Log level for Wi-Fi Network manager module module-help = Enables using the Wi-Fi Network managers to manage the Wi-Fi network interfaces. source "subsys/net/Kconfig.template.log_config.net" endif # WIFI_NM + +config WIFI_MGMT_AP_STA_INACTIVITY_TIMEOUT + int "Station inactivity timeout in seconds" + default 300 + help + Station inactivity timeout is the period for which AP may keep a client + in associated state while there is no traffic from that particular + client. If a non-zero value is set, AP may choose to disassociate the + client after the timeout. diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index 51e76aec5fb..b6f4a6cd2c6 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -435,6 +435,31 @@ static int wifi_ap_sta_disconnect(uint32_t mgmt_request, struct net_if *iface, NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_STA_DISCONNECT, wifi_ap_sta_disconnect); +static int wifi_ap_config_params(uint32_t mgmt_request, struct net_if *iface, + void *data, size_t len) +{ + const struct device *dev = net_if_get_device(iface); + const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface); + struct wifi_ap_config_params *params = data; + + if (dev == NULL) { + return -ENODEV; + } + + if (wifi_mgmt_api == NULL || + wifi_mgmt_api->ap_config_params == NULL) { + return -ENOTSUP; + } + + if (!data || len != sizeof(*params)) { + return -EINVAL; + } + + return wifi_mgmt_api->ap_config_params(dev, params); +} + +NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM, wifi_ap_config_params); + static int wifi_iface_status(uint32_t mgmt_request, struct net_if *iface, void *data, size_t len) { diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 7bdd9801650..87930f7cbaf 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -1370,6 +1370,65 @@ static int cmd_wifi_ap_sta_disconnect(const struct shell *sh, size_t argc, return 0; } +static int wifi_ap_config_args_to_params(const struct shell *sh, size_t argc, char *argv[], + struct wifi_ap_config_params *params) +{ + struct getopt_state *state; + int opt; + static struct option long_options[] = {{"max_inactivity", required_argument, 0, 'i'}, + {"help", no_argument, 0, 'h'}, + {0, 0, 0, 0}}; + int opt_index = 0; + long val; + + while ((opt = getopt_long(argc, argv, "i:h", long_options, &opt_index)) != -1) { + state = getopt_state_get(); + switch (opt) { + case 'i': + if (!parse_number(sh, &val, optarg, "max_inactivity", + 0, WIFI_AP_STA_MAX_INACTIVITY)) { + return -EINVAL; + } + params->max_inactivity = (uint32_t)val; + params->type |= WIFI_AP_CONFIG_PARAM_MAX_INACTIVITY; + break; + case 'h': + shell_help(sh); + return SHELL_CMD_HELP_PRINTED; + default: + PR_ERROR("Invalid option %c\n", optopt); + shell_help(sh); + return SHELL_CMD_HELP_PRINTED; + } + } + + return 0; +} + +static int cmd_wifi_ap_config_params(const struct shell *sh, size_t argc, + char *argv[]) +{ + struct net_if *iface = net_if_get_first_wifi(); + struct wifi_ap_config_params ap_config_params = { 0 }; + int ret = -1; + + context.sh = sh; + + if (wifi_ap_config_args_to_params(sh, argc, argv, &ap_config_params)) { + return -ENOEXEC; + } + + ret = net_mgmt(NET_REQUEST_WIFI_AP_CONFIG_PARAM, iface, + &ap_config_params, sizeof(struct wifi_ap_config_params)); + if (ret) { + PR_WARNING("Setting AP parameter failed: %s\n", + strerror(-ret)); + return -ENOEXEC; + } + + return 0; +} + static int cmd_wifi_reg_domain(const struct shell *sh, size_t argc, char *argv[]) { @@ -1893,6 +1952,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_cmd_ap, "\n", cmd_wifi_ap_sta_disconnect, 2, 0), + SHELL_CMD_ARG(config, NULL, + "Configure AP parameters.\n" + "-i --max_inactivity=