Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

radio test improements #50

Merged
merged 3 commits into from
Mar 21, 2025
Merged
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
70 changes: 60 additions & 10 deletions samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,55 @@ 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(&reg_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;
}

memset(&ctx->conf_params, 0, sizeof(ctx->conf_params));
ctx->rf_test_run = false;

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;
Expand Down Expand Up @@ -861,43 +910,36 @@ 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;
}
}

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;
Expand Down Expand Up @@ -996,6 +1038,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;
Copy link
Contributor

Choose a reason for hiding this comment

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

This might cause an issue where a test is NOT running and the user issues a TX stop (erroneously). We seem to be missing a check in the beginning to catch this scenario. If now the nrf_wifi_rt_fmac_prog_tx too fails then the state will get set to TX running.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will still work, as the API won't fail if the test is not running, no? (we can add a check independent to this).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to do wifi_radio_test tx_tone 0 without starting and the command timeout, like most other commands FW doesn't send an event if its a no-op, so, we need a fix in OSAL code for that to avoid sending CMD if it's a no-op, but this is unrelated to the issue that customer has reported.

return -ENOEXEC;
}

Expand Down Expand Up @@ -1027,6 +1070,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;
}

Expand Down Expand Up @@ -1674,6 +1718,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
Expand Down Expand Up @@ -1791,6 +1837,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
RTSH(nrf_wifi_radio_test_set_ru_index), 2, 0),
SHELL_CMD_ARG(init, NULL, "<val> - 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",
Expand Down