diff --git a/nrf70_bm_lib/CMakeLists.txt b/nrf70_bm_lib/CMakeLists.txt index 537f700..f8cc2bb 100644 --- a/nrf70_bm_lib/CMakeLists.txt +++ b/nrf70_bm_lib/CMakeLists.txt @@ -27,13 +27,13 @@ if (CONFIG_NRF70_BM_LIB) target_compile_definitions_ifndef(CONFIG_NRF70_RADIO_TEST nrf70-bm-lib PRIVATE - -DCONFIG_NRF_WIFI_FW_BIN=${NRF_WIFI_BINS_DIR}/scan_only/nrf70.bin + -DCONFIG_NRF_WIFI_SYS_FW_BIN=${NRF_WIFI_BINS_DIR}/scan_only/nrf70.bin ) target_compile_definitions_ifdef(CONFIG_NRF70_RADIO_TEST nrf70-bm-lib PRIVATE - -DCONFIG_NRF_WIFI_FW_BIN=${NRF_WIFI_BINS_DIR}/radio_test/nrf70.bin + -DCONFIG_NRF_WIFI_RT_FW_BIN=${NRF_WIFI_BINS_DIR}/radio_test/nrf70.bin ) target_compile_definitions_ifdef(CONFIG_NRF70_RADIO_TEST diff --git a/nrf70_bm_lib/include/common/nrf70_bm_core.h b/nrf70_bm_lib/include/common/nrf70_bm_core.h index b41aa40..8daeee5 100644 --- a/nrf70_bm_lib/include/common/nrf70_bm_core.h +++ b/nrf70_bm_lib/include/common/nrf70_bm_core.h @@ -20,8 +20,46 @@ #include "common/nrf70_bm_lib.h" #include +/* 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[]; + void nrf70_bm_conf_board_dep_params(struct nrf_wifi_board_params *board_params); void nrf70_bm_conf_tx_pwr_settings(struct nrf_wifi_tx_pwr_ctrl_params *tx_pwr_ctrl_params, struct nrf_wifi_tx_pwr_ceil_params *tx_pwr_ceil_params); -enum nrf_wifi_status nrf70_bm_fw_load(void *rpu_ctx); +enum nrf_wifi_status nrf70_bm_fw_load(void *rpu_ctx, + const uint8_t *fw_start, + const uint8_t *fw_end); #endif /* NRF70_BM_COMMON_CORE_H__ */ diff --git a/nrf70_bm_lib/include/radio_test/nrf70_bm_core.h b/nrf70_bm_lib/include/radio_test/nrf70_bm_core.h index 9800828..7e5ae1b 100644 --- a/nrf70_bm_lib/include/radio_test/nrf70_bm_core.h +++ b/nrf70_bm_lib/include/radio_test/nrf70_bm_core.h @@ -35,5 +35,6 @@ struct nrf70_bm_rt_wifi_drv_priv { int nrf70_bm_rt_fmac_init(void); int nrf70_bm_rt_fmac_deinit(void); +enum nrf_wifi_status nrf70_bm_rt_fw_load(void *rpu_ctx); #endif /* NRF70_BM_RT_CORE_H__ */ diff --git a/nrf70_bm_lib/include/system/nrf70_bm_core.h b/nrf70_bm_lib/include/system/nrf70_bm_core.h index 5bc1420..ce178d8 100644 --- a/nrf70_bm_lib/include/system/nrf70_bm_core.h +++ b/nrf70_bm_lib/include/system/nrf70_bm_core.h @@ -50,5 +50,6 @@ int nrf70_bm_sys_fmac_get_reg(struct nrf70_bm_regulatory_info *reg_info); int nrf70_bm_sys_fmac_set_reg(struct nrf70_bm_regulatory_info *reg_info); int nrf70_bm_sys_fmac_add_vif_sta(uint8_t *mac_addr); int nrf70_bm_sys_fmac_del_vif_sta(void); +enum nrf_wifi_status nrf70_bm_sys_fw_load(void *rpu_ctx); #endif /* NRF70_BM_SYS_CORE_H__ */ diff --git a/nrf70_bm_lib/source/common/nrf70_bm_core.c b/nrf70_bm_lib/source/common/nrf70_bm_core.c index 8232a94..8ed6873 100644 --- a/nrf70_bm_lib/source/common/nrf70_bm_core.c +++ b/nrf70_bm_lib/source/common/nrf70_bm_core.c @@ -20,63 +20,15 @@ #error "Please prepare tx power ceiling header file for your board" #endif -/* 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)); - - -enum nrf_wifi_status nrf70_bm_fw_load(void *rpu_ctx) +enum nrf_wifi_status nrf70_bm_fw_load(void *rpu_ctx, + const uint8_t *fw_start, + const uint8_t *fw_end) { 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); - if (status != NRF_WIFI_STATUS_SUCCESS) { - NRF70_LOG_ERR("%s: nrf_wifi_fmac_fw_parse failed", __func__); - return status; - } /* Load the FW patches to the RPU */ - status = nrf_wifi_fmac_fw_load(rpu_ctx, &fw_info); + status = nrf_wifi_fmac_fw_parse(rpu_ctx, fw_start, fw_end - fw_start, &fw_info); if (status != NRF_WIFI_STATUS_SUCCESS) { NRF70_LOG_ERR("%s: nrf_wifi_fmac_fw_load failed", __func__); diff --git a/nrf70_bm_lib/source/radio_test/nrf70_bm_core.c b/nrf70_bm_lib/source/radio_test/nrf70_bm_core.c index 8b446e8..b11c1e1 100644 --- a/nrf70_bm_lib/source/radio_test/nrf70_bm_core.c +++ b/nrf70_bm_lib/source/radio_test/nrf70_bm_core.c @@ -14,6 +14,7 @@ struct nrf70_bm_rt_wifi_drv_priv nrf70_bm_priv; extern const struct nrf_wifi_osal_ops nrf_wifi_os_bm_ops; +INCBIN(_bin, nrf70_bm_rt_fw, STR(CONFIG_NRF_WIFI_RT_FW_BIN)); int nrf70_bm_rt_fmac_init(void) { @@ -51,7 +52,7 @@ int nrf70_bm_rt_fmac_init(void) nrf70_bm_priv.rpu_ctx_bm.rpu_ctx = rpu_ctx; - status = nrf70_bm_fw_load(rpu_ctx); + status = nrf70_bm_rt_fw_load(rpu_ctx); if (status != NRF_WIFI_STATUS_SUCCESS) { NRF70_LOG_ERR("Failed to load firmware\n"); goto deinit; @@ -125,4 +126,21 @@ int nrf70_bm_rt_fmac_deinit(void) NRF70_LOG_DBG("FMAC module deinitialized"); return 0; -} \ No newline at end of file +} + +enum nrf_wifi_status nrf70_bm_rt_fw_load(void *rpu_ctx) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + const uint8_t *fw_start = NULL; + const uint8_t *fw_end = NULL; + + fw_start = _bin_nrf70_bm_rt_fw_start; + fw_end = _bin_nrf70_bm_rt_fw_end; + + status = nrf70_bm_fw_load(rpu_ctx, fw_start, fw_end); + if (status != NRF_WIFI_STATUS_SUCCESS) { + NRF70_LOG_ERR("%s: nrf_wifi_fw_load failed", __func__); + } + + return status; +} diff --git a/nrf70_bm_lib/source/system/nrf70_bm_core.c b/nrf70_bm_lib/source/system/nrf70_bm_core.c index 80ce72f..24b2f0f 100644 --- a/nrf70_bm_lib/source/system/nrf70_bm_core.c +++ b/nrf70_bm_lib/source/system/nrf70_bm_core.c @@ -15,6 +15,7 @@ struct nrf70_bm_sys_wifi_drv_priv nrf70_bm_priv; extern const struct nrf_wifi_osal_ops nrf_wifi_os_bm_ops; +INCBIN(_bin, nrf70_bm_sys_fw, STR(CONFIG_NRF_WIFI_SYS_FW_BIN)); #ifdef CONFIG_NRF70_RANDOM_MAC_ADDRESS static void generate_random_mac_address(uint8_t *mac_addr) @@ -352,7 +353,7 @@ int nrf70_bm_sys_fmac_init(void) nrf70_bm_priv.rpu_ctx_bm.rpu_ctx = rpu_ctx; - status = nrf70_bm_fw_load(rpu_ctx); + status = nrf70_bm_sys_fw_load(rpu_ctx); if (status != NRF_WIFI_STATUS_SUCCESS) { NRF70_LOG_ERR("Failed to load firmware\n"); goto deinit; @@ -602,3 +603,20 @@ int nrf70_bm_sys_fmac_deinit(void) return 0; } + +enum nrf_wifi_status nrf70_bm_sys_fw_load(void *rpu_ctx) +{ + enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; + const uint8_t *fw_start = NULL; + const uint8_t *fw_end = NULL; + + fw_start = _bin_nrf70_bm_sys_fw_start; + fw_end = _bin_nrf70_bm_sys_fw_end; + + status = nrf70_bm_fw_load(rpu_ctx, fw_start, fw_end); + if (status != NRF_WIFI_STATUS_SUCCESS) { + NRF70_LOG_ERR("%s: nrf_wifi_fw_load failed", __func__); + } + + return status; +}