Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Kulkarni committed Jan 31, 2025
1 parent f61678e commit 2476275
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 58 deletions.
4 changes: 2 additions & 2 deletions nrf70_bm_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 39 additions & 1 deletion nrf70_bm_lib/include/common/nrf70_bm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,46 @@
#include "common/nrf70_bm_lib.h"
#include <fmac_api.h>

/* 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__ */
1 change: 1 addition & 0 deletions nrf70_bm_lib/include/radio_test/nrf70_bm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
1 change: 1 addition & 0 deletions nrf70_bm_lib/include/system/nrf70_bm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
56 changes: 4 additions & 52 deletions nrf70_bm_lib/source/common/nrf70_bm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand Down
22 changes: 20 additions & 2 deletions nrf70_bm_lib/source/radio_test/nrf70_bm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -125,4 +126,21 @@ int nrf70_bm_rt_fmac_deinit(void)
NRF70_LOG_DBG("FMAC module deinitialized");

return 0;
}
}

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;
}
20 changes: 19 additions & 1 deletion nrf70_bm_lib/source/system/nrf70_bm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

0 comments on commit 2476275

Please sign in to comment.