diff --git a/drivers/wifi/nrfwifi/CMakeLists.txt b/drivers/wifi/nrfwifi/CMakeLists.txt index 91818f65582..c3b0efef82b 100644 --- a/drivers/wifi/nrfwifi/CMakeLists.txt +++ b/drivers/wifi/nrfwifi/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 # -zephyr_library() +zephyr_library_named(nrfwifi) set(OS_AGNOSTIC_BASE ${ZEPHYR_HAL_NORDIC_MODULE_DIR}/drivers/nrf_wifi) set(FW_BINS_BASE ${ZEPHYR_HAL_NORDIC_MODULE_DIR}/zephyr/blobs/wifi_fw_bins) @@ -63,7 +63,7 @@ zephyr_library_sources( src/qspi/src/ficr_prog.c ) -zephyr_library_sources_ifndef(CONFIG_NRF_WIFI_BUILD_ONLY_MODE +zephyr_library_sources_ifdef(CONFIG_NRF_WIFI_PATCHES_BUILTIN src/fw_load.c ) @@ -136,39 +136,44 @@ zephyr_compile_definitions_ifdef(CONFIG_NRF70_ON_QSPI ) if (CONFIG_NRF_WIFI_BUILD_ONLY_MODE) -message(WARNING " ------------------------------------------------------------------------- -Building only the nRF70 driver, skipping firmware patch. -This is only for building (CI) purposes and will not work on a real device. ------------------------------------------------------------------------- -") + message(WARNING " + ------------------------------------------------------------------------ + Building only the nRF70 driver, skipping firmware patch. + This is only for building (CI) purposes and will not work on a real device. + ------------------------------------------------------------------------ + ") else() -# RPU FW patch binaries based on the selected configuration -if(CONFIG_NRF70_SYSTEM_MODE) - set(NRF70_PATCH ${FW_BINS_BASE}/default/nrf70.bin) -elseif(CONFIG_NRF70_RADIO_TEST) - set(NRF70_PATCH ${FW_BINS_BASE}/radio_test/nrf70.bin) -elseif(CONFIG_NRF70_SCAN_ONLY) - set(NRF70_PATCH ${FW_BINS_BASE}/scan_only/nrf70.bin) -elseif (CONFIG_NRF70_SYSTEM_WITH_RAW_MODES) - set(NRF70_PATCH ${FW_BINS_BASE}/system_with_raw/nrf70.bin) -else() - # Error - message(FATAL_ERROR "Unsupported nRF70 patch configuration") -endif() - -if(NOT EXISTS ${NRF70_PATCH}) - message(FATAL_ERROR " - ------------------------------------------------------------------------ - Missing blobs for nRF70 device driver, please install by running: - $ west update - $ west blobs fetch hal_nordic - ------------------------------------------------------------------------") -endif() - -zephyr_compile_definitions( - -DCONFIG_NRF_WIFI_FW_BIN=${NRF70_PATCH} -) + # RPU FW patch binaries based on the selected configuration + if(CONFIG_NRF70_SYSTEM_MODE) + set(NRF70_PATCH ${FW_BINS_BASE}/default/nrf70.bin) + elseif(CONFIG_NRF70_RADIO_TEST) + set(NRF70_PATCH ${FW_BINS_BASE}/radio_test/nrf70.bin) + elseif(CONFIG_NRF70_SCAN_ONLY) + set(NRF70_PATCH ${FW_BINS_BASE}/scan_only/nrf70.bin) + elseif (CONFIG_NRF70_SYSTEM_WITH_RAW_MODES) + set(NRF70_PATCH ${FW_BINS_BASE}/system_with_raw/nrf70.bin) + else() + # Error + message(FATAL_ERROR "Unsupported nRF70 patch configuration") + endif() + + if(NOT EXISTS ${NRF70_PATCH}) + message(FATAL_ERROR " + ------------------------------------------------------------------------ + Missing blobs for nRF70 device driver, please install by running: + $ west update + $ west blobs fetch hal_nordic + ------------------------------------------------------------------------") + endif() + + set(gen_inc_dir ${ZEPHYR_BINARY_DIR}/misc/generated) + zephyr_include_directories(${gen_inc_dir}) + set(gen_dir ${gen_inc_dir}/nrf70_fw_patch) + generate_inc_file_for_target( + nrfwifi + ${NRF70_PATCH} + ${gen_dir}/nrf70.bin.inc + ) endif() diff --git a/drivers/wifi/nrfwifi/Kconfig.nrfwifi b/drivers/wifi/nrfwifi/Kconfig.nrfwifi index e7ee0169300..3096dd7c76e 100644 --- a/drivers/wifi/nrfwifi/Kconfig.nrfwifi +++ b/drivers/wifi/nrfwifi/Kconfig.nrfwifi @@ -131,14 +131,11 @@ config NRF_WIFI_IF_AUTO_START config NRF_WIFI_PATCHES_BUILTIN bool "Store nRF70 FW patches as part of the driver" default y + depends on !NRF_WIFI_BUILD_ONLY_MODE help Select this option to store nRF70 FW patches as part of the driver. This option impacts the code memory footprint of the driver. -config CUSTOM_LINKER_SCRIPT - string "Custom linker script for nRF70 FW patches" - default "${ZEPHYR_BASE}/../nrf/drivers/wifi/nrf70/rpu_fw_patches.ld" - config NRF_WIFI_LOW_POWER bool "low power mode in nRF Wi-Fi chipsets" default y @@ -700,37 +697,4 @@ config NRF_WIFI_BUILD_ONLY_MODE dependency on firmware binary and patches. This is useful to check the build and link errors. -# TODO: Temporary WAR, implement these options in the future -config NRF_WIFI_PATCHES_EXT_FLASH_DISABLED - bool "nRF70 firmware patch external flash support" - help - Select this option to disable external flash support for nRF70 firmware patches - -config NRF_WIFI_FW_PATCH_DFU - bool "nRF70 firmware patch DFU" - help - Select this option to enable DFU for nRF70 firmware patches - -config NRF_WIFI_PATCHES_EXT_FLASH_STORE - bool "nRF70 firmware patch external flash store" - help - Select this option to enable external flash store for nRF70 firmware patches - -config NRF_WIFI_FW_FLASH_CHUNK_SIZE - int "nRF70 firmware patch flash chunk size" - default 8192 - help - Select this option to set the flash chunk size for nRF70 firmware patches - -config NRF_WIFI_PATCHES_EXT_FLASH_XIP - bool "nRF70 firmware patch external flash XIP" - help - Select this option to enable external flash XIP for nRF70 firmware patches - -config NRF_WIFI_FEAT_WMM - bool "WMM/QoS support" - default y - help - This option controls disable/enable of the WMM(Wireless Multi-Media) feature. - endif # WIFI_NRF70 diff --git a/drivers/wifi/nrfwifi/rpu_fw_patches.ld b/drivers/wifi/nrfwifi/rpu_fw_patches.ld deleted file mode 100644 index 4ecbaedb096..00000000000 --- a/drivers/wifi/nrfwifi/rpu_fw_patches.ld +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2024 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @file - * @brief Custom Linker command/script file - * - * Custom Linker script for the Cortex-M platforms. - */ - -#include -#include - -#include -#include - -#if CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP || CONFIG_BOARD_NRF52840DK_NRF52840 -/* - * nRF53/52 series ship an external flash that can be used for XIP using QSPI/SPI. - * - * Note: In nRF7002 external flash using is accessible only using SPI but there is no - * support for XIP, so, relocation cannot be used. - */ -#if CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP -#define EXTFLASH_BASE_ADDR 0x10000000 -#define EXTFLASH_SIZE 0x800000 -#elif CONFIG_BOARD_NRF52840DK_NRF52840 -#define EXTFLASH_BASE_ADDR 0x12000000 -#define EXTFLASH_SIZE 0x800000 -#endif /* CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP */ - -#if USE_PARTITION_MANAGER && PM_EXTERNAL_FLASH_ADDRESS -#include -#define EXTFLASH_ADDRESS (EXTFLASH_BASE_ADDR + PM_EXTERNAL_FLASH_ADDRESS) -#undef EXTFLASH_SIZE -#define EXTFLASH_SIZE (PM_EXTERNAL_FLASH_SIZE) -#else -#define EXTFLASH_ADDRESS (EXTFLASH_BASE_ADDR) -#endif /* USE_PARTITION_MANAGER && PM_EXTERNAL_FLASH_ADDRESS */ - -MEMORY -{ - EXTFLASH (wx) : ORIGIN = EXTFLASH_ADDRESS, LENGTH = EXTFLASH_SIZE -} - -#endif /* CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP || CONFIG_BOARD_NRF52840DK_NRF52840 */ - -#include diff --git a/drivers/wifi/nrfwifi/src/fw_load.c b/drivers/wifi/nrfwifi/src/fw_load.c index 14087a7d35c..9204d295d30 100644 --- a/drivers/wifi/nrfwifi/src/fw_load.c +++ b/drivers/wifi/nrfwifi/src/fw_load.c @@ -17,59 +17,16 @@ LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL); #include - -#ifdef CONFIG_NRF_WIFI_PATCHES_BUILTIN -/* INCBIN macro Taken from https://gist.github.com/mmozeiko/ed9655cf50341553d282 */ -#define STR2(x) #x -#define STR(x) STR2(x) - -#ifdef __APPLE__ -#define USTR(x) "_" STR(x) -#else -#define USTR(x) STR(x) -#endif - -#ifdef _WIN32 -#define INCBIN_SECTION ".rdata, \"dr\"" -#elif defined __APPLE__ -#define INCBIN_SECTION "__TEXT,__const" -#else -#define INCBIN_SECTION ".rodata.*" -#endif - -/* this aligns start address to 16 and terminates byte array with explicit 0 - * which is not really needed, feel free to change it to whatever you want/need - */ -#define INCBIN(prefix, name, file) \ - __asm__(".section " INCBIN_SECTION "\n" \ - ".global " USTR(prefix) "_" STR(name) "_start\n" \ - ".balign 16\n" \ - USTR(prefix) "_" STR(name) "_start:\n" \ - ".incbin \"" file "\"\n" \ - \ - ".global " STR(prefix) "_" STR(name) "_end\n" \ - ".balign 1\n" \ - USTR(prefix) "_" STR(name) "_end:\n" \ - ".byte 0\n" \ - ); \ - extern __aligned(16) const char prefix ## _ ## name ## _start[]; \ - extern const char prefix ## _ ## name ## _end[]; - -INCBIN(_bin, nrf70_fw, STR(CONFIG_NRF_WIFI_FW_BIN)); -#endif /* CONFIG_NRF_WIFI_PATCHES_BUILTIN */ +static const char fw_patch[] = { + #include +}; enum nrf_wifi_status nrf_wifi_fw_load(void *rpu_ctx) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; struct nrf_wifi_fmac_fw_info fw_info = { 0 }; - uint8_t *fw_start; - uint8_t *fw_end; - - fw_start = (uint8_t *)_bin_nrf70_fw_start; - fw_end = (uint8_t *)_bin_nrf70_fw_end; - status = nrf_wifi_fmac_fw_parse(rpu_ctx, fw_start, fw_end - fw_start, - &fw_info); + status = nrf_wifi_fmac_fw_parse(rpu_ctx, fw_patch, sizeof(fw_patch), &fw_info); if (status != NRF_WIFI_STATUS_SUCCESS) { LOG_ERR("%s: nrf_wifi_fmac_fw_parse failed", __func__); return status; diff --git a/samples/net/wifi/Kconfig.sysbuild b/samples/net/wifi/Kconfig.sysbuild new file mode 100644 index 00000000000..158551060c5 --- /dev/null +++ b/samples/net/wifi/Kconfig.sysbuild @@ -0,0 +1,13 @@ +# +# Copyright (c) 2024 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: Apache-2.0 +# + +config WIFI_NRF70 + default y if BOARD_NRF7002DK_NRF5340_CPUAPP || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NS || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001 || \ + BOARD_NRF7002DK_NRF5340_CPUAPP_NRF7001_NS + +source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" diff --git a/samples/net/wifi/sample.yaml b/samples/net/wifi/sample.yaml index 1c106e4897a..51c52edbd6f 100644 --- a/samples/net/wifi/sample.yaml +++ b/samples/net/wifi/sample.yaml @@ -53,6 +53,7 @@ tests: - nrf7002dk/nrf5340/cpuapp/nrf7001 sample.net.wifi.nrf7002ek: extra_args: + - SB_CONFIG_WIFI_NRF70=y - CONFIG_NRF_WIFI_BUILD_ONLY_MODE=y - SHIELD=nrf7002ek platform_allow: @@ -64,6 +65,7 @@ tests: - nucleo_h723zg sample.net.wifi.nrf7002eb: extra_args: + - SB_CONFIG_WIFI_NRF70=y - CONFIG_NRF_WIFI_BUILD_ONLY_MODE=y - SHIELD=nrf7002eb platform_allow: