From 874cc315a5939960374f48e0c29f4bdadaf9f6d6 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Mon, 17 Mar 2025 23:41:30 +0530 Subject: [PATCH 1/3] Add init and deinit nRF70 shell commands This is helpful in trying multiple iterations and having finer control over nRF70 init rather esp. when switching modes or recovery. Signed-off-by: Chaitanya Tata --- .../src/nrf_wifi_radio_test_shell.c | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c b/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c index 72e3f5b..b872c4a 100644 --- a/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c +++ b/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c @@ -196,6 +196,52 @@ static int check_channel_settings(unsigned char tput_mode, return 0; } +static int nrf_wifi_init(size_t argc, const char *argv[]) +{ + int ret = 0; + struct nrf70_bm_regulatory_info reg_info = { 0 }; + + ARG_UNUSED(argc); + ARG_UNUSED(argv); + + memcpy(reg_info.country_code, CONFIG_WIFI_RT_REG_DOMAIN, 2); + reg_info.force = true; + + /* Initialize the Wi-Fi module */ + ret = nrf70_bm_rt_init(®_info); + if (ret) { + printf("Failed to initialize WiFi module\n"); + goto cleanup; + } + printf("Initialized WiFi module, ready for radio test\n"); + +cleanup: + if (ret) { + nrf70_bm_rt_deinit(); + printf("Exiting WiFi radio test sample application with error: %d\n", ret); + } + return ret; +} + +static int nrf_wifi_deinit(size_t argc, const char *argv[]) +{ + int ret; + + ARG_UNUSED(argc); + ARG_UNUSED(argv); + + ret = nrf70_bm_rt_deinit(); + if (ret) { + printf("Failed to deinitialize WiFi module\n"); + return ret; + } + + printf("Deinitialized WiFi module\n"); + + return 0; +} + + enum nrf_wifi_status nrf_wifi_radio_test_conf_init(struct rpu_conf_params *conf_params) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; @@ -1674,6 +1720,8 @@ DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_tx_power) DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_ru_tone) DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_ru_index) DEFINE_CMD_HANDLER(nrf_wifi_radio_test_init) +DEFINE_CMD_HANDLER(nrf_wifi_init); +DEFINE_CMD_HANDLER(nrf_wifi_deinit); DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_tx) DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_rx) #ifdef CONFIG_NRF70_SR_COEX_RF_SWITCH @@ -1791,6 +1839,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE( RTSH(nrf_wifi_radio_test_set_ru_index), 2, 0), SHELL_CMD_ARG(init, NULL, " - Primary channel number", RTSH(nrf_wifi_radio_test_init), 2, 0), + SHELL_CMD_ARG(nrf70_init, NULL, "Initialize nRF70", + RTSH(nrf_wifi_init), 0, 0), + SHELL_CMD_ARG(nrf70_deinit, NULL, "Deinitialize nRF70", + RTSH(nrf_wifi_deinit), 0, 0), SHELL_CMD_ARG(tx, NULL, "0 - Disable TX\n" "1 - Enable TX", From 524550c32d1992f6c66ef80a6f3b92eed0d27c68 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Mon, 17 Mar 2025 23:45:10 +0530 Subject: [PATCH 2/3] Reset flags only if test stop is successful Clear only on success, helps in dealing with multiple tests in a sequence. Signed-off-by: Chaitanya Tata --- .../radio_test_bm/src/nrf_wifi_radio_test_shell.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c b/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c index b872c4a..c92e66c 100644 --- a/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c +++ b/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c @@ -907,26 +907,22 @@ static int nrf_wifi_radio_test_init(size_t argc, const char *argv[]) { if (ctx->conf_params.rx) { RT_SHELL_PRINTF_INFO("Disabling ongoing RX test\n"); - ctx->conf_params.rx = 0; - status = nrf_wifi_rt_fmac_prog_rx(ctx->rpu_ctx, &ctx->conf_params); - if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Disabling RX failed\n"); + ctx->conf_params.rx = 1; return -ENOEXEC; } } if (ctx->conf_params.tx) { RT_SHELL_PRINTF_INFO("Disabling ongoing TX test\n"); - ctx->conf_params.tx = 0; - status = nrf_wifi_rt_fmac_prog_tx(ctx->rpu_ctx, &ctx->conf_params); - if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Disabling TX failed\n"); + ctx->conf_params.tx = 1; return -ENOEXEC; } } @@ -934,16 +930,13 @@ static int nrf_wifi_radio_test_init(size_t argc, const char *argv[]) { if (ctx->rf_test_run) { if (ctx->rf_test != NRF_WIFI_RF_TEST_TX_TONE) { RT_SHELL_PRINTF_ERROR("Unexpected: RF Test (%d) running\n", ctx->rf_test); - return -ENOEXEC; } RT_SHELL_PRINTF_INFO("Disabling ongoing TX tone test\n"); - status = nrf_wifi_rt_fmac_rf_test_tx_tone(ctx->rpu_ctx, 0, ctx->conf_params.tx_tone_freq, - ctx->conf_params.tx_power); - + ctx->conf_params.tx_power); if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Disabling TX tone test failed\n"); return -ENOEXEC; @@ -1042,6 +1035,7 @@ static int nrf_wifi_radio_test_set_tx(size_t argc, const char *argv[]) { if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Programming TX failed\n"); + ctx->conf_params.tx = !val; return -ENOEXEC; } @@ -1073,6 +1067,7 @@ static int nrf_wifi_radio_test_set_rx(size_t argc, const char *argv[]) { if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Programming RX failed\n"); + ctx->conf_params.rx = !val; return -ENOEXEC; } From 37e43db506e330d2db60b6abaf1e43c6725b32ea Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Mon, 17 Mar 2025 23:47:23 +0530 Subject: [PATCH 3/3] Reset config params in deinit Only nRF70 is deinitialized then the config is no longer relevant. Signed-off-by: Chaitanya Tata --- samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c b/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c index c92e66c..04f5f52 100644 --- a/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c +++ b/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c @@ -236,6 +236,9 @@ static int nrf_wifi_deinit(size_t argc, const char *argv[]) return ret; } + memset(&ctx->conf_params, 0, sizeof(ctx->conf_params)); + ctx->rf_test_run = false; + printf("Deinitialized WiFi module\n"); return 0;