Skip to content
Draft
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
54 changes: 52 additions & 2 deletions boards/nordic/nrf7120pdk/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
#include "nrf7120_enga_types.h"
#include "nrf7120_enga_global.h"

/* Wi-Fi core defines (not part of MDK) */
#define LRC0_POWERON (0x4800B000UL + 0x00000490UL)
#define LMAC_VPR_INITPC (0x48000000UL + 0x00000808UL)
#define LMAC_VPR_CPURUN (0x48000000UL + 0x00000800UL)

static inline void write_reg32(uintptr_t addr, uint32_t value)
{
*((volatile uint32_t *)addr) = value;
}

#if CONFIG_BOARD_EARLY_INIT_HOOK
/* Temporary workaround while VPR does not handle starting clocks */
void board_early_init_hook(void)
Expand All @@ -24,8 +34,48 @@

/* Wait for event */
while (NRF_CLOCK_S->EVENTS_LFCLKSTARTED !=
CLOCK_EVENTS_LFCLKSTARTED_EVENTS_LFCLKSTARTED_Generated) {

CLOCK_EVENTS_LFCLKSTARTED_EVENTS_LFCLKSTARTED_Generated) {
/* busy-wait */
}

/* Make entire RAM accessible to the Wi-Fi domain */
NRF_MPC00->OVERRIDE[0].STARTADDR = 0x20000000;
NRF_MPC00->OVERRIDE[0].ENDADDR = 0x20100000;
NRF_MPC00->OVERRIDE[0].PERM = 0x7; /* 0-NS R,W,X =1 */
NRF_MPC00->OVERRIDE[0].PERMMASK = 0xF;
NRF_MPC00->OVERRIDE[0].CONFIG = 0x1200;

/* MRAM MPC overrides for wifi */
NRF_MPC00->OVERRIDE[1].STARTADDR = 0x00000000;
NRF_MPC00->OVERRIDE[1].ENDADDR = 0x01000000;
NRF_MPC00->OVERRIDE[1].PERM = 0x7;
NRF_MPC00->OVERRIDE[1].PERMMASK = 0xF;
NRF_MPC00->OVERRIDE[1].CONFIG = 0x1200;

/* Make GRTC accessable from the WIFI-Core */

Check warning on line 55 in boards/nordic/nrf7120pdk/board.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TYPO_SPELLING

boards/nordic/nrf7120pdk/board.c:55 'accessable' may be misspelled - perhaps 'accessible'?
NRF_SPU20->PERIPH[34].PERM = (SPU_PERIPH_PERM_SECATTR_NonSecure << SPU_PERIPH_PERM_SECATTR_Pos);

Check warning on line 56 in boards/nordic/nrf7120pdk/board.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

boards/nordic/nrf7120pdk/board.c:56 line length of 104 exceeds 100 columns

/* Wi-Fi VPR uses UART 20 (PORT 2 Pin 2 is for the TX) */
#define UARTE20_ID ((NRF_UARTE20_S_BASE >> 12) & 0x1F)
NRF_SPU20->PERIPH[UARTE20_ID].PERM =
(SPU_PERIPH_PERM_SECATTR_NonSecure << SPU_PERIPH_PERM_SECATTR_Pos);
NRF_SPU00->FEATURE.GPIO[2].PIN[2] =
(SPU_FEATURE_GPIO_PIN_SECATTR_NonSecure << SPU_FEATURE_GPIO_PIN_SECATTR_Pos);
/* Set permission for TXD */
NRF_SPU20->FEATURE.GPIO[1].PIN[4] =
(SPU_FEATURE_GPIO_PIN_SECATTR_NonSecure << SPU_FEATURE_GPIO_PIN_SECATTR_Pos);

/* Split security configuration to let Wi-Fi access GRTC */
NRF_SPU20->FEATURE.GRTC.CC[15] = 0;
NRF_SPU20->FEATURE.GRTC.CC[14] = 0;
NRF_SPU20->FEATURE.GRTC.INTERRUPT[4] = 0;
NRF_SPU20->FEATURE.GRTC.INTERRUPT[5] = 0;
NRF_SPU20->FEATURE.GRTC.SYSCOUNTER = 0;

write_reg32(LRC0_POWERON,
(LRCCONF_POWERON_MAIN_AlwaysOn << LRCCONF_POWERON_MAIN_Pos));
write_reg32(LMAC_VPR_INITPC, 0x28080000);
write_reg32(LMAC_VPR_CPURUN,
(VPR_CPURUN_EN_Running << VPR_CPURUN_EN_Pos));
}
#endif
96 changes: 96 additions & 0 deletions tests/drivers/nrf_wifi/raw_tx_rx/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
K_THREAD_DEFINE(receiver_thread_id, STACK_SIZE, rx_thread_oneshot, NULL, NULL, NULL,
THREAD_PRIORITY, 0, -1);

#define NRF_WIFICORE_RPURFBUS_BASE 0x48020000UL
#define NRF_WIFICORE_RPURFBUS_RFCTRL ((NRF_WIFICORE_RPURFBUS_BASE) + 0x00010000UL)
#define NRF_WIFICORE_RPURFBUS_RFCTRL_AXIMASTERACCESS ((NRF_WIFICORE_RPURFBUS_RFCTRL) + 0x00000000UL)

#define RDW(addr) (*(volatile unsigned int *)(addr))
#define WRW(addr, data) (*(volatile unsigned int *)(addr) = (data))

struct beacon {
uint16_t frame_control;
uint16_t duration;
Expand Down Expand Up @@ -91,6 +98,73 @@
unsigned char raw_tx_flag;
};


/* RF Playout Capture Register Configuration Structure */
struct rf_pocap_reg_config {
uint32_t offset; /* Register offset from base */
uint32_t value; /* Register value to write */
const char *reg_name; /* Register name for logging */
const char *desc; /* Description of what this register does */
};

void configurePlayoutCapture(uint32_t rx_mode, uint32_t tx_mode, uint32_t rx_holdoff_length, uint32_t rx_wrap_length, uint32_t back_to_back_mode)

Check warning on line 110 in tests/drivers/nrf_wifi/raw_tx_rx/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE

tests/drivers/nrf_wifi/raw_tx_rx/src/main.c:110 line length of 145 exceeds 100 columns
{
#if (CONFIG_BOARD_NRF7120PDK_NRF7120_CPUAPP || CONFIG_BOARD_NRF7120PDK_NRF7120_CPUAPP_EMU)
unsigned int value;
LOG_INF("%s: Setting RF Playout Capture Config", __func__);

Check warning on line 114 in tests/drivers/nrf_wifi/raw_tx_rx/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LINE_SPACING

tests/drivers/nrf_wifi/raw_tx_rx/src/main.c:114 Missing a blank line after declarations

// Set AXI Master to APP so we can access the RF

Check failure on line 116 in tests/drivers/nrf_wifi/raw_tx_rx/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

C99_COMMENTS

tests/drivers/nrf_wifi/raw_tx_rx/src/main.c:116 do not use C99 // comments
WRW(NRF_WIFICORE_RPURFBUS_RFCTRL_AXIMASTERACCESS, 0x31);
while(RDW(NRF_WIFICORE_RPURFBUS_RFCTRL_AXIMASTERACCESS) != 0x31);

Check warning on line 118 in tests/drivers/nrf_wifi/raw_tx_rx/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

BRACES

tests/drivers/nrf_wifi/raw_tx_rx/src/main.c:118 braces {} are required around if/while/for/else

Check failure on line 118 in tests/drivers/nrf_wifi/raw_tx_rx/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_STATEMENTS

tests/drivers/nrf_wifi/raw_tx_rx/src/main.c:118 trailing statements should be on next line

Check failure on line 118 in tests/drivers/nrf_wifi/raw_tx_rx/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACING

tests/drivers/nrf_wifi/raw_tx_rx/src/main.c:118 space required before the open parenthesis '('

/* Data-driven register configuration */
struct rf_pocap_reg_config reg_configs[] = {
{
.offset = 0x0000,
.value = (tx_mode << 1) | rx_mode,
.reg_name = "WLAN_RF_POCAP_CONFIG",
.desc = "RX/TX mode configuration"
},
{
.offset = 0x0004,
.value = rx_holdoff_length & 0xFF,
.reg_name = "WLAN_RF_POCAP_RX_HOLDOFF_CONFIG",
.desc = "RX holdoff length configuration"
},
{
.offset = 0x0008,
.value = rx_wrap_length,
.reg_name = "WLAN_RF_POCAP_RX_WRAP_CONFIG",
.desc = "RX wrap length configuration"
},
{
.offset = 0x000C,
.value = (back_to_back_mode << 1), /* WLAN_POCAP_BACK_TO_BACK_MODE [1..1] */
.reg_name = "WLAN_POCAP_VERSION_CONFIG",
.desc = "Version and back-to-back mode configuration"
}
};

/* Process register configurations - skip other configs if back-to-back mode is active */
for (int i = 0; i < sizeof(reg_configs) / sizeof(reg_configs[0]); i++) {

Check warning on line 149 in tests/drivers/nrf_wifi/raw_tx_rx/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

ARRAY_SIZE

tests/drivers/nrf_wifi/raw_tx_rx/src/main.c:149 Prefer ARRAY_SIZE(reg_configs)
struct rf_pocap_reg_config *cfg = &reg_configs[i];

/* If back-to-back mode is active, only configure the version register */
if (back_to_back_mode && cfg->offset != 0x000C) {
continue;
}

WRW(NRF_WIFICORE_RPURFBUS_BASE + cfg->offset, cfg->value);
value = RDW(NRF_WIFICORE_RPURFBUS_BASE + cfg->offset);
LOG_INF("%s: %s (0x%04x) = 0x%x - %s",
__func__, cfg->reg_name, cfg->offset, value, cfg->desc);
}

LOG_INF("%s: RF Playout Capture Config completed", __func__);
#endif /* (CONFIG_BOARD_NRF7120PDK_NRF7120_CPUAPP && CONFIG_EMULATOR_SYSTEMC) || (CONFIG_BOARD_NRF7120PDK_NRF7120_CPUAPP_EMU) */

Check warning on line 164 in tests/drivers/nrf_wifi/raw_tx_rx/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE_COMMENT

tests/drivers/nrf_wifi/raw_tx_rx/src/main.c:164 line length of 128 exceeds 100 columns
}


static void wifi_set_mode(int mode_val)
{
int ret;
Expand Down Expand Up @@ -300,13 +374,35 @@

ZTEST(nrf_wifi, test_single_raw_tx_rx)
{
struct net_if *iface;
struct wifi_filter_info filter_info = {0};
int ret;
/* MONITOR mode */
int mode = BIT(1);

wifi_set_mode(mode);
zassert_false(wifi_set_tx_injection_mode(), "Failed to set TX injection mode");
zassert_equal(wifi_set_channel(), 0, "Failed to set channel");
/* Configure packet filter with buffer size 1550 */
iface = net_if_get_first_wifi();
if (iface == NULL) {
LOG_ERR("Failed to get Wi-Fi iface for packet filter");
return;
}

filter_info.oper = WIFI_MGMT_SET;
filter_info.if_index = net_if_get_by_iface(iface);
filter_info.filter = WIFI_PACKET_FILTER_ALL;
filter_info.buffer_size = 1550;

ret = net_mgmt(NET_REQUEST_WIFI_PACKET_FILTER, iface, &filter_info, sizeof(filter_info));
if (ret) {
LOG_ERR("Packet filter setting failed %d", ret);
} else {
LOG_INF("Packet filter set with buffer size %d", filter_info.buffer_size);
}
zassert_false(setup_raw_pkt_socket(&sa), "Setting socket for raw pkt transmission failed");
configurePlayoutCapture(0, 1, 0x7F, 0xCA60, 0);
k_thread_start(receiver_thread_id);
/* TODO: Wait for interface to be operationally UP */
k_sleep(K_MSEC(50));
Expand Down
4 changes: 2 additions & 2 deletions west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ manifest:
# https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html
- name: zephyr
repo-path: sdk-zephyr
revision: c539d475b659949cf96c1638cf7fbafbf64d33f3
revision: pull/3338/head
import:
# In addition to the zephyr repository itself, NCS also
# imports the contents of zephyr/west.yml at the above
Expand Down Expand Up @@ -145,7 +145,7 @@ manifest:
- name: nrfxlib
repo-path: sdk-nrfxlib
path: nrfxlib
revision: 697969e76e88c57ee1d6733f37723b07463286c8
revision: pull/1866/head
- name: trusted-firmware-m
repo-path: sdk-trusted-firmware-m
path: modules/tee/tf-m/trusted-firmware-m
Expand Down
Loading