-
Notifications
You must be signed in to change notification settings - Fork 39
samples: radio_test #751
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
Merged
Merged
samples: radio_test #751
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # | ||
| # Copyright (c) 2026 Nordic Semiconductor | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(peripheral_radio_test) | ||
|
|
||
| FILE(GLOB app_sources src/*.c) | ||
|
|
||
| target_sources(app PRIVATE | ||
| ${app_sources} | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # | ||
| # Copyright (c) 2026 Nordic Semiconductor | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| mainmenu "Nordic Radio test sample" | ||
|
|
||
| config SAMPLE_RADIO_TEST_RX_TIMEOUT | ||
| int "RX packet reception timeout in seconds" | ||
| default 10 | ||
| help | ||
| Specifies the time in seconds that the application waits for the first packet to be | ||
| received in RX mode when a specified number of packets are set to be received. | ||
| If the timeout is reached before the first packet is received, the radio will be disabled. | ||
|
|
||
| source "Kconfig.zephyr" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| .. _radio_test: | ||
|
|
||
| Radio test | ||
| ######################## | ||
|
|
||
| .. contents:: | ||
| :local: | ||
| :depth: 2 | ||
|
|
||
| The Radio test sample demonstrates how to configure the 2.4 GHz short-range radio (Bluetooth® LE, IEEE 802.15.4 and proprietary) in a specific mode and then test its performance. | ||
| The sample provides a set of predefined commands that allow you to configure the radio in three modes: | ||
|
|
||
| * Constant RX or TX carrier | ||
| * Modulated TX carrier | ||
| * RX or TX sweep | ||
|
|
||
| Requirements | ||
| ************ | ||
|
|
||
| The sample supports the following development kits: | ||
|
|
||
| .. tabs:: | ||
|
|
||
| .. group-tab:: Simple board variants | ||
|
|
||
| The following board variants do **not** have DFU capabilities: | ||
|
ivaniushkov marked this conversation as resolved.
|
||
|
|
||
| .. include:: /includes/supported_boards_all_non-mcuboot_variants_s115.txt | ||
|
|
||
| .. include:: /includes/supported_boards_all_non-mcuboot_variants_s145.txt | ||
|
|
||
| .. group-tab:: MCUboot board variants | ||
|
|
||
| The following board variants have DFU capabilities: | ||
|
|
||
| .. include:: /includes/supported_boards_all_mcuboot_variants_s115.txt | ||
|
|
||
| .. include:: /includes/supported_boards_all_mcuboot_variants_s145.txt | ||
|
|
||
|
|
||
| The sample also requires one of the following testing devices: | ||
|
|
||
| * Another development kit with the same sample. | ||
| * Another development kit connected to a PC with the `RSSI Viewer app`_ (available in the `nRF Connect for Desktop`_). | ||
|
|
||
| .. note:: | ||
| You can perform the radio test also using a spectrum analyzer. | ||
| This method of testing is not covered by this documentation. | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| To run the tests, connect to the development kit through the serial port and send shell commands. | ||
| The shell subsystem is used to handle the commands. | ||
| At any time during the tests, you can dynamically set the radio parameters, such as output power, bit rate, and channel. | ||
| In sweep mode, you can set the time for which the radio scans each channel from one millisecond to 99 milliseconds, in steps of one millisecond. | ||
| The sample also allows you to send a data pattern to another development kit. | ||
|
|
||
| The sample first enables the high frequency crystal oscillator and configures the shell. | ||
| You can then start running commands to set up and control the radio. | ||
| See :ref:`radio_test_ui` for a list of available commands. | ||
|
|
||
| .. note:: | ||
| For the IEEE 802.15.4 mode, the start channel and the end channel must be within the channel range of 11 to 26. | ||
| Use the ``start_channel`` and ``end_channel`` commands to control this setting. | ||
|
|
||
| .. _radio_test_ui: | ||
|
|
||
| User interface | ||
| ************** | ||
|
ivaniushkov marked this conversation as resolved.
|
||
|
|
||
| .. list-table:: Main shell commands (in alphabetical order) | ||
| :header-rows: 1 | ||
|
|
||
| * - Command | ||
| - Argument | ||
| - Description | ||
| * - cancel | ||
| - | ||
| - Cancel the sweep or the carrier. | ||
| * - data_rate | ||
| - <sub_cmd> | ||
| - Set the data rate. | ||
| * - end_channel | ||
| - <channel> | ||
| - End channel for the sweep (in MHz, as difference from 2400 MHz). | ||
| * - output_power | ||
| - <sub_cmd> | ||
| - Output power set. | ||
| * - parameters_print | ||
| - | ||
| - Print current delay, channel, and other parameters. | ||
| * - print_rx | ||
| - | ||
| - Print the received RX payload. | ||
| * - start_channel | ||
| - <channel> | ||
| - Start channel for the sweep or the channel for the constant carrier (in MHz, as difference from 2400 MHz). | ||
| * - start_duty_cycle_modulated_tx | ||
| - <duty_cycle> | ||
| - Duty cycle as a percentage (two decimal digits, ranging from 01 to 90). | ||
| * - start_rx | ||
| - <packet_num> | ||
| - Start RX (continuous RX mode is used if no argument is provided). | ||
| * - start_rx_sweep | ||
| - | ||
| - Start the RX sweep. | ||
| * - start_tx_carrier | ||
| - | ||
| - Start the TX carrier. | ||
| * - start_tx_modulated_carrier | ||
| - <packet_num> | ||
| - Start the modulated TX carrier (continuous TX mode is used if no argument is provided). | ||
| * - start_tx_sweep | ||
| - | ||
| - Start the TX sweep. | ||
| * - time_on_channel | ||
| - <time> | ||
| - Time on each channel in ms (between 1 and 99). | ||
| * - toggle_dcdc_state | ||
| - <state> | ||
| - Toggle DC/DC converter state. | ||
| * - transmit_pattern | ||
| - <sub_cmd> | ||
| - Set transmission pattern. | ||
|
|
||
|
|
||
| Building and running | ||
| ******************** | ||
|
|
||
| This sample can be found under :file:`samples/peripherals/radio_test/` in the |BMshort| folder structure. | ||
|
|
||
| For details on how to create, configure, and program a sample, see :ref:`getting_started_with_the_samples`. | ||
|
|
||
| Testing | ||
| ======= | ||
|
|
||
| After programming the sample to your development kit, complete the following steps to test it: | ||
|
|
||
| .. tabs:: | ||
|
|
||
| .. group-tab:: Testing with another development kit | ||
|
|
||
| 1. Connect both development kits to the computer using a USB cable. | ||
| The kits are assigned COM ports (Windows) or ttyACM devices (Linux), which are visible in the Device Manager. | ||
| #. Connect to both kits with a terminal emulator that supports VT100/ANSI escape characters (for example, the `Serial Terminal app`_). | ||
| #. Run the following commands on one of the kits: | ||
|
|
||
| a. Set the data rate with the ``data_rate`` command to ``ble_2Mbit``. | ||
| #. Set the transmission pattern with the ``transmit_pattern`` command to ``pattern_11110000``. | ||
| #. Set the radio channel with the ``start_channel`` command to 40. | ||
|
|
||
| #. Repeat all steps for the second kit. | ||
| #. On both kits, run the ``parameters_print`` command to confirm that the radio configuration is the same on both kits. | ||
| #. Set one kit in the Modulated TX Carrier mode using the ``start_tx_modulated_carrier`` command. | ||
| #. Set the other kit in the RX Carrier mode using the ``start_rx`` command. | ||
| #. Print the received data with the ``print_rx`` command and confirm that they match the transmission pattern (0xF0). | ||
|
|
||
| .. group-tab:: Testing with the RSSI Viewer app | ||
|
|
||
| 1. Connect the kit to the computer using a USB cable. | ||
| The kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager. | ||
| #. Open a serial port connection to the kit using a terminal emulator that supports VT100/ANSI escape characters (for example, the `Serial Terminal app`_). | ||
| #. Set the start channel with the ``start_channel`` command to 20. | ||
| #. Set the end channel with the ``end_channel`` command to 60. | ||
| #. Set the time on channel with the ``time_on_channel`` command to 50 ms. | ||
| #. Set the kit in the TX sweep mode using the ``start_tx_sweep`` command. | ||
| #. Start the `RSSI Viewer app`_ and select the kit to communicate with. | ||
| #. On the application chart, observe the TX sweep in the form of a wave that starts at 2420 MHz frequency and ends with 2480 MHz. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # | ||
| # Copyright (c) 2026 Nordic Semiconductor | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| # Logging | ||
| CONFIG_LOG=y | ||
| CONFIG_LOG_BACKEND_BM_UARTE=y | ||
|
|
||
| # Shell | ||
| CONFIG_SHELL=y | ||
| CONFIG_SHELL_BACKEND_BM_UARTE=y | ||
|
|
||
| # Optional shell features | ||
| CONFIG_SHELL_HELP=y | ||
| CONFIG_SHELL_TAB=y | ||
| CONFIG_SHELL_TAB_AUTOCOMPLETION=y | ||
| CONFIG_SHELL_HISTORY=y | ||
|
|
||
| # HW used by radio_test | ||
| CONFIG_NRFX_TIMER=y | ||
| CONFIG_NRFX_GPPI=y | ||
|
|
||
| # Use fake PRNG to reduce HW dependencies | ||
| CONFIG_TEST_RANDOM_GENERATOR=y | ||
|
|
||
| # Disable SoftDevice. | ||
| # The radio_test sample needs to control radio and other relevant periperhals on its own. | ||
| CONFIG_SOFTDEVICE=n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| sample: | ||
| name: radio_test sample | ||
| tests: | ||
| sample.radio_test: | ||
| sysbuild: true | ||
| build_only: true | ||
| integration_platforms: | ||
| - bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice | ||
| platform_allow: | ||
| - bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice | ||
| - bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice/mcuboot | ||
| - bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice | ||
| - bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice/mcuboot | ||
| - bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice | ||
| - bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice/mcuboot | ||
| - bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice | ||
| - bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice/mcuboot | ||
| - bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice | ||
| - bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice/mcuboot | ||
| - bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice | ||
| - bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice/mcuboot | ||
| - bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice | ||
| - bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice/mcuboot | ||
| - bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice | ||
| - bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice/mcuboot | ||
| - bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevice | ||
| - bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevice/mcuboot | ||
| - bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice | ||
| - bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice/mcuboot | ||
| - bm_nrf54lv10dk/nrf54lv10a/cpuapp/s115_softdevice | ||
| - bm_nrf54lv10dk/nrf54lv10a/cpuapp/s115_softdevice/mcuboot | ||
| - bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice | ||
| - bm_nrf54lv10dk/nrf54lv10a/cpuapp/s145_softdevice/mcuboot | ||
|
ivaniushkov marked this conversation as resolved.
|
||
| tags: ci_build | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /* | ||
| * Copyright (c) 2026 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| #include <zephyr/shell/shell.h> | ||
| #include <bm/shell/backend_bm_uarte.h> | ||
| #include <nrfx.h> | ||
| #include <hal/nrf_clock.h> | ||
| /* TODO: DRGN-27733 Remove the alternative condition for nRF54LS05B | ||
| * when the errata has been applied to this chip and the errata | ||
| * check can be used instead. | ||
| */ | ||
| #if NRF54L_ERRATA_20_PRESENT || defined(NRF54LS05B_ENGA_XXAA) | ||
| #include <hal/nrf_power.h> | ||
| #endif /* NRF54L_ERRATA_20_PRESENT */ | ||
|
|
||
| #include "radio_test.h" | ||
|
|
||
| const struct shell *sh; | ||
|
|
||
| static void clock_init(void) | ||
| { | ||
| nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED); | ||
| nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTART); | ||
| while (!nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED)) { | ||
| /* spin until HFXO is up */ | ||
| } | ||
| nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED); | ||
|
|
||
| #if NRF54L_ERRATA_20_PRESENT | ||
| if (nrf54l_errata_20()) { | ||
| nrf_power_task_trigger(NRF_POWER, NRF_POWER_TASK_CONSTLAT); | ||
| } | ||
| /* TODO: DRGN-27733 Remove the elif block for nRF54LS05B when the errata has | ||
| * been applied to this chip and the errata check can be used instead. | ||
| */ | ||
| #elif defined(NRF54LS05B_ENGA_XXAA) | ||
| nrf_power_task_trigger(NRF_POWER, NRF_POWER_TASK_CONSTLAT); | ||
| #endif /* NRF54L_ERRATA_20_PRESENT */ | ||
|
|
||
| #if defined(NRF54LM20A_XXAA) | ||
| /* MLTPAN-39 */ | ||
| nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART); | ||
| #endif /* defined(NRF54LM20A_XXAA) */ | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| sh = shell_backend_bm_uarte_get_ptr(); | ||
| const struct shell_backend_config_flags cfg_flags = | ||
| SHELL_DEFAULT_BACKEND_CONFIG_FLAGS; | ||
|
|
||
| shell_init(sh, NULL, cfg_flags, false, 0); | ||
| shell_start(sh); | ||
|
|
||
| shell_print(sh, "Starting Radio Test sample"); | ||
|
|
||
| clock_init(); | ||
|
|
||
| struct radio_test_config *radio_test_conf = radio_cmd_get_test_config(); | ||
| int err = radio_test_init(radio_test_conf); | ||
|
|
||
| if (err) { | ||
| shell_error(sh, "radio_test_init() failed: %d", err); | ||
| } | ||
|
|
||
| while (true) { | ||
| /* | ||
| * Process all received data from the shell backend, calling registered command | ||
| * handlers like sample_terminate_cmd if the command and arguments match. | ||
| */ | ||
| shell_process(sh); | ||
|
|
||
| /* | ||
| * Ensure no events are missed while we check if there is pending RX data to | ||
| * be processed. | ||
| */ | ||
| unsigned int key = irq_lock(); | ||
|
|
||
| radio_test_process_rx_timeout(); | ||
|
|
||
| if (shell_backend_bm_uarte_rx_ready()) { | ||
| /* Process pending RX data */ | ||
| irq_unlock(key); | ||
| continue; | ||
| } | ||
|
|
||
| /* Idle until next event */ | ||
| k_cpu_atomic_idle(key); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.