Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 39 additions & 34 deletions drivers/wifi/nrfwifi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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()


Expand Down
38 changes: 1 addition & 37 deletions drivers/wifi/nrfwifi/Kconfig.nrfwifi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
51 changes: 0 additions & 51 deletions drivers/wifi/nrfwifi/rpu_fw_patches.ld

This file was deleted.

51 changes: 4 additions & 47 deletions drivers/wifi/nrfwifi/src/fw_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,16 @@
LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);

#include <fmac_main.h>

#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 <nrf70_fw_patch/nrf70.bin.inc>
};

Check notice on line 22 in drivers/wifi/nrfwifi/src/fw_load.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/wifi/nrfwifi/src/fw_load.c:22 - #include <nrf70_fw_patch/nrf70.bin.inc> +#include <nrf70_fw_patch/nrf70.bin.inc>

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;
Expand Down
13 changes: 13 additions & 0 deletions samples/net/wifi/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions samples/net/wifi/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ tests:
- nrf7002dk/nrf5340/cpuapp/nrf7001
sample.net.wifi.nrf7002ek:
extra_args:
- SB_CONFIG_WIFI_NRF70=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PerMac can this instead be reworked to use the alt config root?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I need to checkout this alt feature, I will take it up in a separate PR, thanks.

- CONFIG_NRF_WIFI_BUILD_ONLY_MODE=y
- SHIELD=nrf7002ek
platform_allow:
Expand All @@ -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:
Expand Down
Loading