We need to add the functionality of radio test to a BLE Application. Normally, BLE is active, but we need the ability to stop BLE and execute radio tests upon command. When radio testing is complete it is acceptable to reset the device to return to normal BLE operation. devzone.nordicsemi.com/.../modified-radio-test-firmware is a similar ticket, but I do not see a solution in that ticket. It seems that the solution is to shut down the BLE stack, and also shut down MPSL, but the details on how to do this are not provided. Please provide guidance on how to do this. I have tired bt_le_adv_stop(), bt_disable(), sdc_disable(), and mpsl_uninit(). mpsl_uninit() causes the device to hang.
Using nRF Connect SDK 1.8.0 and 2.1.2, I have experimented with adding the functionality from nrf/samples/peripheral/radio_test to the sample project nrf/samples/Bluetooth/shell_bt_nus on an nrf52840dk_nrf52840. I created a command “radio_test_mode” to shut down Bluetooth so that the radio tests can be run.
static int cmd_radio_test_mode(const struct shell *shell, size_t argc, char **argv)
{
shell_print(shell, "Enable radio test mode");
bt_le_adv_stop();
k_sleep(K_MSEC(100));
bt_disable();
k_sleep(K_MSEC(100));
//sdc_disable();
//k_sleep(K_MSEC(1000));
//mpsl_uninit(); //This results in a reset when running modulated carrier test.
k_sleep(K_MSEC(800));
radio_test_init(&test_config);
radio_test_clock_init();
return 0;
}
SHELL_CMD_REGISTER(radio_test_mode, NULL, "Enable radio test mode", cmd_radio_test_mode);
The tx carrier test works and was verified with a spectrum analyzer.
uart:~$ help
Please press the <Tab> button to see all available commands.
You can also use the <Tab> button to prompt or auto-complete all commands or its subcommands.
You can try to call commands with <-h> or <--help> parameter for more information.
Shell supports following meta-keys:
Ctrl + (a key from: abcdefklnpuw)
Alt + (a key from: bf)
Please refer to shell documentation for more details.
Available commands:
cancel :Cancel the sweep or the carrier
clear :Clear screen.
data_rate :Set data rate <sub_cmd>
device :Device commands
devmem :Read/write physical memory"devmem address
[width [value]]
end_channel :End channel for the sweep (in MHz as
difference from 2400 MHz) <channel>
help :Prints the help message.
history :Command history.
kernel :Kernel commands
nrf_clock_control :Clock control commands
output_power :Output power set <sub_cmd>
parameters_print :Print current delay, channel and so on
print_rx :Print RX payload
radio_test_mode :Enable radio test mode
resize :Console gets terminal screen size or assumes
default in case the readout fails. It must be
executed after each terminal width change to
ensure correct text display.
shell :Useful, not Unix-like shell commands.
start_channel :Start channel for the sweep or the channel for
the constant carrier (in MHz as difference
from 2400 MHz) <channel>
start_duty_cycle_modulated_tx :Duty cycle in percent (two decimal digits,
between 01 and 90) <duty_cycle>
start_rx :Start RX
start_rx_sweep :Start RX sweep
start_tx_carrier :Start the TX carrier
start_tx_modulated_carrier :Start the modulated TX carrier
start_tx_sweep :Start TX sweep
time_on_channel :Time on each channel in ms (between 1 and 99)
<time>
toggle_dcdc_state :Toggle DCDC state <state>, if state = 1 then
toggle DC/DC state, or if state = 0 then
toggle DC/DC VDDH state
transmit_pattern :Set the transmission pattern
uart:~$
uart:~$ radio_test_mode
Enable radio test mode
Clock has started
uart:~$
uart:~$ start_tx_carrier
Start the TX carrier
uart:~$
However, the tx modulated carrier test does not work. I have tried combinations of sdc_disable() and mpsl_uninit(), but cannot get this test to work. The shell hangs with
uart:~$ radio_test_mode
Enable radio test mode
Clock has started
uart:~$
uart:~$ start_tx_modulated_carrier
The following MPSL ASSERT, HARD FAULT, and reset also occurs
uart:~$ radio_test_mode
Enable radio test mode
Clock has started
uart:~$ transmit_pattern pattern_11001100
Transmission pattern: TRANSMIT_PATTERN_11001100
uart:~$ start_tx_modulated_carrier
E: MPSL ASSERT: 112, 2183
E: ***** HARD FAULT *****
E: Fault escalation (see below)
E: ARCH_EXCEPT with reason 3
E: r0/a1: 0x00000003 r1/a2: 0x00000000 r2/a3: 0x00000001
E: r3/a4: 0x0001dcb1 r12/ip: 0x00000000 r14/lr: 0x0001fa13
E: xpsr: 0x41000011
E: Faulting instruction address (r15/pc): 0x0001fa1e
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
E: Fault during interrupt handling
E: Current thread: 0x20001a88 (shell_uart)
*** Booting Zephyr OS build v3.1.99-ncs1-1 ***
Starting Bluetooth NUS shell transport example
I: SoftDevice Controller build revision:
I: 29 5c 92 f1 36 81 92 d1 |)\..6...
I: b7 a9 f0 f1 99 e9 4c 19 |......L.
I: 1f 23 83 4a |.#.J
uart:~$