Skip to content

Commit b40cb4c

Browse files
krish2718dleach02
authored andcommitted
drivers: nrfwifi: Use Zephyr tooling to load nRF70 FW file
Instead of relying on INCBIN macros which do not properly add dependencies, e.g., modifying FW file doesn't trigger rebuild. Use the Zephyr cmake tooling to load the FW patch file as a header. This also improves memory report where the patch target is clearly visible instead of a hidden section. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 7f9be54 commit b40cb4c

File tree

2 files changed

+12
-48
lines changed

2 files changed

+12
-48
lines changed

drivers/wifi/nrfwifi/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

7-
zephyr_library()
7+
zephyr_library_named(nrfwifi)
88

99
set(OS_AGNOSTIC_BASE ${ZEPHYR_HAL_NORDIC_MODULE_DIR}/drivers/nrf_wifi)
1010
set(FW_BINS_BASE ${ZEPHYR_HAL_NORDIC_MODULE_DIR}/zephyr/blobs/wifi_fw_bins)
@@ -166,8 +166,13 @@ else()
166166
------------------------------------------------------------------------")
167167
endif()
168168

169-
zephyr_compile_definitions(
170-
-DCONFIG_NRF_WIFI_FW_BIN=${NRF70_PATCH}
169+
set(gen_inc_dir ${ZEPHYR_BINARY_DIR}/misc/generated)
170+
zephyr_include_directories(${gen_inc_dir})
171+
set(gen_dir ${gen_inc_dir}/nrf70_fw_patch)
172+
generate_inc_file_for_target(
173+
nrfwifi
174+
${NRF70_PATCH}
175+
${gen_dir}/nrf70.bin.inc
171176
)
172177
endif()
173178

drivers/wifi/nrfwifi/src/fw_load.c

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,57 +17,16 @@
1717
LOG_MODULE_DECLARE(wifi_nrf, CONFIG_WIFI_NRF70_LOG_LEVEL);
1818

1919
#include <fmac_main.h>
20-
21-
/* INCBIN macro Taken from https://gist.github.com/mmozeiko/ed9655cf50341553d282 */
22-
#define STR2(x) #x
23-
#define STR(x) STR2(x)
24-
25-
#ifdef __APPLE__
26-
#define USTR(x) "_" STR(x)
27-
#else
28-
#define USTR(x) STR(x)
29-
#endif
30-
31-
#ifdef _WIN32
32-
#define INCBIN_SECTION ".rdata, \"dr\""
33-
#elif defined __APPLE__
34-
#define INCBIN_SECTION "__TEXT,__const"
35-
#else
36-
#define INCBIN_SECTION ".rodata.*"
37-
#endif
38-
39-
/* this aligns start address to 16 and terminates byte array with explicit 0
40-
* which is not really needed, feel free to change it to whatever you want/need
41-
*/
42-
#define INCBIN(prefix, name, file) \
43-
__asm__(".section " INCBIN_SECTION "\n" \
44-
".global " USTR(prefix) "_" STR(name) "_start\n" \
45-
".balign 16\n" \
46-
USTR(prefix) "_" STR(name) "_start:\n" \
47-
".incbin \"" file "\"\n" \
48-
\
49-
".global " STR(prefix) "_" STR(name) "_end\n" \
50-
".balign 1\n" \
51-
USTR(prefix) "_" STR(name) "_end:\n" \
52-
".byte 0\n" \
53-
); \
54-
extern __aligned(16) const char prefix ## _ ## name ## _start[]; \
55-
extern const char prefix ## _ ## name ## _end[];
56-
57-
INCBIN(_bin, nrf70_fw, STR(CONFIG_NRF_WIFI_FW_BIN));
20+
static const char fw_patch[] = {
21+
#include <nrf70_fw_patch/nrf70.bin.inc>
22+
};
5823

5924
enum nrf_wifi_status nrf_wifi_fw_load(void *rpu_ctx)
6025
{
6126
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
6227
struct nrf_wifi_fmac_fw_info fw_info = { 0 };
63-
uint8_t *fw_start;
64-
uint8_t *fw_end;
65-
66-
fw_start = (uint8_t *)_bin_nrf70_fw_start;
67-
fw_end = (uint8_t *)_bin_nrf70_fw_end;
6828

69-
status = nrf_wifi_fmac_fw_parse(rpu_ctx, fw_start, fw_end - fw_start,
70-
&fw_info);
29+
status = nrf_wifi_fmac_fw_parse(rpu_ctx, fw_patch, sizeof(fw_patch), &fw_info);
7130
if (status != NRF_WIFI_STATUS_SUCCESS) {
7231
LOG_ERR("%s: nrf_wifi_fmac_fw_parse failed", __func__);
7332
return status;

0 commit comments

Comments
 (0)