Skip to content

Use mode specific APIs #40

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
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ The source directory structure shall look like this:
samples/ # Sample applications
radio_test_bm/ # Radio test sample application
scan_bm/ # Scan sample application
scan_rt_bm/ # Scan and Radio test combo sample application
nrf70_zephyr_shim/ # Zephyr shim for nRF70, reference for third-party boards


Expand Down Expand Up @@ -130,7 +131,7 @@ To build the documentation in a Linux environment, follow the below steps:
Build the documentation using the following command:

```sh
./build_docs.sh
./build-docs.sh
```

The generated HTML files will be available in `nrf70_bm_lib/docs/build/html`.
Expand All @@ -141,11 +142,13 @@ To build the documentation in a Linux environment, follow the below steps:
Example code
============

The repository includes two sample applications for testing and evaluation of the nRF70 Bare Metal library:
The repository includes the below sample applications for the testing and the evaluation of the nRF70 Bare Metal library:

1. `BM radio test` sample to perform basic RF testing of the nRF70 Series device, as well as
Factory Information Configuration Registers (FICR) programming.

2. `BM scan` sample to test Wi-Fi SSID scanning with the nRF70 Series devices.

Both samples can be found under the ``samples/`` directory. The samples can be built using `west`, as explained above.
3. `BM scan and radio test combo` sample to demonstrate runtime switching capability between scan and radio test operational modes for the BM library

The samples can be found under the ``samples/`` directory. The samples can be built using `west`, as explained above.
37 changes: 27 additions & 10 deletions nrf70_bm_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,54 @@ if (CONFIG_NRF70_BM_LIB)
${ZEPHYR_BASE}/include/zephyr
)

target_compile_definitions_ifndef(CONFIG_NRF70_RADIO_TEST
target_compile_definitions_ifdef(CONFIG_NRF70_BM_SCAN_ONLY
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
target_compile_definitions_ifdef(CONFIG_NRF70_BM_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
target_compile_definitions_ifdef(CONFIG_NRF70_BM_RADIO_TEST
nrf70-bm-lib
PRIVATE
-DCONFIG_NRF70_RADIO_TEST
-DCONFIG_NRF70_BM_RADIO_TEST
)

target_compile_definitions_ifdef(CONFIG_NRF70_SCAN_ONLY
target_compile_definitions_ifdef(CONFIG_NRF70_BM_SCAN_ONLY
nrf70-bm-lib
PRIVATE
-DCONFIG_NRF70_SCAN_ONLY
-DCONFIG_NRF70_BM_SCAN_ONLY
)


target_sources(
nrf70-bm-lib
PRIVATE
source/nrf70_bm_lib.c
source/nrf70_bm_core.c
source/common/nrf70_bm_core.c
)

if(CONFIG_NRF70_BM_RADIO_TEST)
target_sources(
nrf70-bm-lib
PRIVATE
source/radio_test/nrf70_bm_lib.c
source/radio_test/nrf70_bm_core.c
)
endif()

if(CONFIG_NRF70_BM_SCAN_ONLY)
target_sources(
nrf70-bm-lib
PRIVATE
source/system/nrf70_bm_lib.c
source/system/nrf70_bm_core.c
)
endif()

target_link_libraries(nrf70-bm-lib PRIVATE nrf70-zep-shim nrf-wifi-osal)
endif()
16 changes: 5 additions & 11 deletions nrf70_bm_lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -363,26 +363,20 @@ config NRF_WIFI_DISPLAY_SCAN_BSS_LIMIT
# Display scan BSS entries limit
# By default, the limit is 250 in scan-only mode and 150 in regular mode.
int "Display scan bss limit"
range 1 450 if NRF70_SCAN_ONLY
def_int 250 if NRF70_SCAN_ONLY
range 1 450 if NRF70_BM_SCAN_ONLY
def_int 250 if NRF70_BM_SCAN_ONLY
range 1 160
def_int 150
help
Number of BSS entries in scan result.

choice NRF70_OPER_MODES
bool "nRF70 operating modes"
default NRF70_SCAN_ONLY
help
Select the operating mode of the nRF70 driver

config NRF70_SCAN_ONLY
config NRF70_BM_SCAN_ONLY
bool "nRF70 scan only mode"
default y
help
Select this option to enable scan only mode of the nRF70 driver

config NRF70_RADIO_TEST
config NRF70_BM_RADIO_TEST
bool "Radio test mode of the nRF70 driver"
endchoice

endmenu
12 changes: 7 additions & 5 deletions nrf70_bm_lib/docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -864,11 +864,13 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = ../include/nrf70_bm_lib.h \
../include/nrf70_tx_pwr_ceil_dk.h \
../../../modules/lib//nrf_wifi/fw_if/umac_if/inc \
../../../modules/lib//nrf_wifi/fw_if/umac_if/inc/radio_test \
../../../modules/lib//nrf_wifi/fw_if/umac_if/inc/default
INPUT = ../include/common/nrf70_bm_lib.h \
../include/system/nrf70_bm_lib.h \
../include/radio_test/nrf70_bm_lib.h \
../include/common/nrf70_bm_tx_pwr_ceil_dk.h \
../../../modules/lib/nrf_wifi/fw_if/umac_if/inc/common \
../../../modules/lib/nrf_wifi/fw_if/umac_if/inc/radio_test \
../../../modules/lib/nrf_wifi/fw_if/umac_if/inc/system

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
2 changes: 1 addition & 1 deletion nrf70_bm_lib/docs/source/nrf70_bm_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
API documentation
=================

.. doxygenfile:: nrf70_bm_lib.h
.. doxygenfile:: common/nrf70_bm_lib.h radio_test/nrf70_bm_lib.h system/nrf70_bm_lib.h
:project: nrf70_bm_lib
10 changes: 10 additions & 0 deletions nrf70_bm_lib/docs/source/nrf70_bm_lib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ Design essentials
The nRF70 BM library is designed to be portable to any platform and OS environment.
The following design essentials are important to understand when porting the library to a third-party platform.

Modes of operation
******************

The nRF70 BM library supports two modes of operation:

* **Scan only**: The library is configured to perform Wi-Fi scans only in this mode.
* **Radio test**: The library is configured to perform radio tests only in this mode, primarily for production/manufacturing use.

The above modes can also be combined into a single build configuration, allowing the user to switch between the two modes at runtime.

MAC address configuration
*************************

Expand Down
19 changes: 17 additions & 2 deletions nrf70_bm_lib/docs/source/nrf70_bm_lib_migration_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,32 @@ API changes

* The following APIs were added to the library:

* ``nrf70_bm_get_reg()``
* ``nrf70_bm_sys_get_reg()``
* ``nrf70_bm_rt_init()``
* ``nrf70_bm_rt_deinit()``

* The following APIs were modified in the library:

* ``nrf70_bm_init()``
* ``nrf70_bm_init()`` is now renamed to ``nrf70_bm_sys_init()``.
- added a new parameter ``mac_addr`` to allow the user to set the MAC address of the device.
- added a new parameter ``reg_info`` to allow the user to set the regulatory information of the device.
* ``nrf70_bm_deinit()`` is now renamed to ``nrf70_bm_sys_deinit()``.
* ``nrf70_bm_scan_start()`` is now renamed to ``nrf70_bm_sys_scan_start()``.
* ``nrf70_bm_set_reg()`` is now renamed to ``nrf70_bm_sys_set_reg()``.
* ``nrf70_bm_mac_txt()`` is now renamed to ``nrf70_bm_sys_mac_txt``.
* ``nrf70_bm_dump_stats()`` is now renamed to ``nrf70_bm_sys_dump_stats()``.

Configuration changes
=====================

* The following configuration options were added to the library:

* ``CONFIG_NRF70_REG_DOMAIN``

Build system changes
====================

* For the build system changes refer to the following links:

* <https://github.com/zephyrproject-rtos/nrf_wifi/commit/cc1008dea1d8171f3996c4185acabdc0f9f18e62>
* <>
6 changes: 3 additions & 3 deletions nrf70_bm_lib/docs/source/nrf70_bm_porting_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ The reference header files are located in the `nrf70_bm_lib/include` directory.

The following files are used to configure the TX power ceilings for the official Nordic development and evaluation boards:

- `nrf70_tx_pwr_ceil_dk.h`: Contains the TX power configuration for the nRF7002 Development Kit (DK).
- `nrf70_bm_tx_pwr_ceil_dk.h`: Contains the TX power configuration for the nRF7002 Development Kit (DK).

- `nrf70_tx_pwr_ceil_ek.h`: Contains the TX power configuration for the nRF7002 Evaluation Kit (EK).
- `nrf70_bm_tx_pwr_ceil_ek.h`: Contains the TX power configuration for the nRF7002 Evaluation Kit (EK).

For a new nRF70-based PCB design, the developer may create a new header file with the same structure as the reference files and replace the values with the appropriate values for the designed PCB.
The appropriate TX power ceiling values may be derived by running the radio test sample on the board and using a spectrum/vector signal analyzer to measure the output power, spectral mask, EVM and other parameters and then adjusting the TX power ceiling values to meet the requirements.
Expand All @@ -131,7 +131,7 @@ For more information on TX power calculation, refer to the section `nRF70 TX pow
Reference header file structure
-------------------------------

.. doxygenfile:: nrf70_tx_pwr_ceil_dk.h
.. doxygenfile:: nrf70_bm_tx_pwr_ceil_dk.h


nRF70 OS agnostic layers API documentation
Expand Down
5 changes: 5 additions & 0 deletions nrf70_bm_lib/docs/source/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ Radio test

The Radio test sample demonstrates how to use the Nordic Semiconductor's Wi-Fi® chipset to test the radio functionality.
For more information, see https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/wifi/radio_test/README.html

Scan and Radio test combo
+++++++++++++++++++++++++

The Scan and Radio test combo sample demonstrates how to switch between the Scan and Radio test operational modes at runtime.
65 changes: 65 additions & 0 deletions nrf70_bm_lib/include/common/nrf70_bm_core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/** @file
* @brief nRF70 Bare Metal library initialization.
*/
#ifndef NRF70_BM_COMMON_CORE_H__
#define NRF70_BM_COMMON_CORE_H__

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>

#include "host_rpu_sys_if.h"
#include "common/nrf70_bm_lib.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,
const uint8_t *fw_start,
const uint8_t *fw_end);
#endif /* NRF70_BM_COMMON_CORE_H__ */
81 changes: 81 additions & 0 deletions nrf70_bm_lib/include/common/nrf70_bm_lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/** @file
* @brief nRF70 Bare Metal library.
* @defgroup nrf70_bm nRF70 Bare Metal library
*/

#ifndef NRF70_BM_COMMON_LIB_H__
#define NRF70_BM_COMMON_LIB_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>

/** @brief Log levels */
#if CONFIG_NRF70_BM_LOG_LEVEL > 0
#define NRF70_LOG_ERR(...) printf(__VA_ARGS__); printf("\n")
#else
#define NRF70_LOG_ERR(...)
#endif

#if CONFIG_NRF70_BM_LOG_LEVEL > 1
#define NRF70_LOG_WRN(...) printf(__VA_ARGS__); printf("\n")
#else
#define NRF70_LOG_WRN(...)
#endif

#if CONFIG_NRF70_BM_LOG_LEVEL > 2
#define NRF70_LOG_INF(...) printf(__VA_ARGS__); printf("\n")
#else
#define NRF70_LOG_INF(...)
#endif

#if CONFIG_NRF70_BM_LOG_LEVEL > 3
#define NRF70_LOG_DBG(...) printf(__VA_ARGS__); printf("\n")
#else
#define NRF70_LOG_DBG(...)
#endif


/** @brief Per-channel regulatory attributes */
struct nrf70_bm_reg_chan_info {
/** Center frequency in MHz */
unsigned short center_frequency;
/** Maximum transmission power (in dBm) */
unsigned short max_power:8;
/** Is channel supported or not */
unsigned short supported:1;
/** Passive transmissions only */
unsigned short passive_only:1;
/** Is a DFS channel */
unsigned short dfs:1;
};



/** @brief Regulatory information */
struct nrf70_bm_regulatory_info {
/** Country code - ISO/IEC 3166-1 alpha-2 */
char country_code[2];
/** Force - ignore 802.11d beacon hints (only used in SET) */
bool force;
/** Number of channels supported (only used in GET) */
unsigned int num_channels;
/** Channels information (only used in GET) */
struct nrf70_bm_reg_chan_info *chan_info;
};

#ifdef __cplusplus
}
#endif

#endif /* NRF70_BM_COMMON_LIB_H__ */
Loading