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
12 changes: 12 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(multicore_soc_flash)

target_sources(app PRIVATE src/main.c)
8 changes: 8 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "Kconfig.zephyr"

config READ_FROM_SOC_FLASH
bool "Enable reading from SOC flash"
default y

config WRITE_TO_SOC_FLASH
bool "Enable writing to SOC flash"
12 changes: 12 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "share/sysbuild/Kconfig"

config REMOTE_BOARD
string
default "$(BOARD)/nrf54h20/cpurad" if SOC_NRF54H20_CPUAPP
default "$(BOARD)/nrf54h20/cpuapp" if SOC_NRF54H20_CPURAD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
&storage_partition {
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
&storage_partition {
status = "okay";
};
9 changes: 9 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_FLASH=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FCB=y
CONFIG_FLASH_MAP=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_FCB=y

CONFIG_ASSERT=y
12 changes: 12 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(remote)

target_sources(app PRIVATE ../src/main.c)
8 changes: 8 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/remote/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "Kconfig.zephyr"

config READ_FROM_SOC_FLASH
bool "Enable reading from SOC flash"
default y

config WRITE_TO_SOC_FLASH
bool "Enable writing to SOC flash"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_SOC_NRF54H20_CPURAD_ENABLE=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
&storage_partition {
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
&storage_partition {
status = "okay";
};
9 changes: 9 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_FLASH=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_FCB=y
CONFIG_FLASH_MAP=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_FCB=y

CONFIG_ASSERT=y
107 changes: 107 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include <zephyr/kernel.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/storage/flash_map.h>

#define TEST_DATA_PARTITION storage_partition
#define TEST_DATA_PARTITION_OFFSET FIXED_PARTITION_OFFSET(TEST_DATA_PARTITION)
#define TEST_DATA_PARTITION_DEVICE FIXED_PARTITION_DEVICE(TEST_DATA_PARTITION)

#define FLASH_PAGE_SIZE 4096
#define FLASH_WORD_SIZE 16
#define FLASH_PAGE_ID 0

#define SLEEP_TIME_MS 150
#define MAX_REPETITIONS 10

const struct device *const soc_flash_dev = TEST_DATA_PARTITION_DEVICE;

#if defined(CONFIG_SOC_NRF54H20_CPUAPP)
uint8_t test_data_pattern[FLASH_WORD_SIZE] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8,
0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10};
#else
uint8_t test_data_pattern[FLASH_WORD_SIZE] = {0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x20};
#endif

static int soc_flash_setup(const struct device *flash_dev)
{
if (!device_is_ready(flash_dev)) {
printk("Internal storage device not ready\n");
return -1;
}

return 0;
}

#if defined(CONFIG_WRITE_TO_SOC_FLASH)
static int write_soc_flash(const struct device *flash_dev, uint32_t offset, uint8_t *buffer)
{
printk("Write SoC flash, base address: %x, offset: %x\n", TEST_DATA_PARTITION_OFFSET,
offset * FLASH_WORD_SIZE);
return flash_write(flash_dev, TEST_DATA_PARTITION_OFFSET + offset * FLASH_WORD_SIZE, buffer,
FLASH_WORD_SIZE);
}
#endif

#if defined(CONFIG_READ_FROM_SOC_FLASH)
static int read_soc_flash(const struct device *flash_dev, uint32_t offset, uint8_t *buffer)
{
printk("Read SoC flash, base address: %x, offset: %x\n", TEST_DATA_PARTITION_OFFSET,
offset * FLASH_WORD_SIZE);
return flash_read(flash_dev, TEST_DATA_PARTITION_OFFSET + offset * FLASH_WORD_SIZE, buffer,
FLASH_WORD_SIZE);
}
#endif

int main(void)
{
int err;
int repetition_counter = MAX_REPETITIONS;
#if defined(CONFIG_SOC_NRF54H20_CPUAPP)
uint32_t offset = 0;
#else
uint32_t offset = FLASH_WORD_SIZE * MAX_REPETITIONS;
#endif
uint8_t test_data_buffer[FLASH_WORD_SIZE];

printk("Hello World! %s\n", CONFIG_BOARD_TARGET);

if (soc_flash_setup(soc_flash_dev) != 0) {
return -1;
}

while (repetition_counter--) {

#if defined(CONFIG_WRITE_TO_SOC_FLASH)
err = write_soc_flash(soc_flash_dev, offset, test_data_pattern);
if (err != 0) {
printk("Writing to SoC flash failed: %d\n", err);
return -1;
}
#endif

#if defined(CONFIG_READ_FROM_SOC_FLASH)
err = read_soc_flash(soc_flash_dev, offset, test_data_buffer);
if (err != 0) {
printk("Reading from SoC flash failed: %d\n", err);
return -1;
}
#endif

#if defined(CONFIG_WRITE_TO_SOC_FLASH) && defined(CONFIG_READ_FROM_SOC_FLASH)
if (memcmp(test_data_buffer, test_data_pattern, FLASH_WORD_SIZE)) {
printk("Data read does not match data written\n");
return -1;
} else {
printk("Data read matches data written\n");
}
#endif

k_msleep(SLEEP_TIME_MS);
offset += FLASH_WORD_SIZE;
}

printk("Tests status: PASS\n");

return 0;
}
14 changes: 14 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/sysbuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

if(SB_CONFIG_REMOTE_BOARD)
ExternalZephyrProject_Add(
APPLICATION remote
SOURCE_DIR ${APP_DIR}/remote
BOARD ${SB_CONFIG_REMOTE_BOARD}
BOARD_REVISION ${BOARD_REVISION}
)
endif()
44 changes: 44 additions & 0 deletions tests/drivers/flash/multicore_soc_flash/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
common:
sysbuild: true
tags:
- drivers
- flash
- ci_tests_drivers_flash
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
- nrf54h20dk/nrf54h20/cpurad
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
- nrf54h20dk/nrf54h20/cpurad
harness: console
harness_config:
type: multi_line
regex:
- "Tests status: PASS"

tests:
drivers.flash.multicore_soc_flash.app_read_rad_read: {}
drivers.flash.multicore_soc_flash.app_read_rad_write:
extra_args:
- remote_CONFIG_WRITE_TO_SOC_FLASH=y
drivers.flash.multicore_soc_flash.app_write_rad_read:
extra_args:
- CONFIG_WRITE_TO_SOC_FLASH=y
drivers.flash.multicore_soc_flash.app_write_rad_write:
extra_args:
- CONFIG_WRITE_TO_SOC_FLASH=y
- remote_CONFIG_WRITE_TO_SOC_FLASH=y
drivers.flash.multicore_soc_flash.app_write_rad_write.s2ram:
extra_args:
- CONFIG_WRITE_TO_SOC_FLASH=y
- CONFIG_PM=y
- CONFIG_PM_S2RAM=y
- CONFIG_PM_S2RAM_CUSTOM_MARKING=y
- CONFIG_PM_DEVICE=y
- CONFIG_PM_DEVICE_RUNTIME=y
- CONFIG_POWEROFF=y
- remote_CONFIG_WRITE_TO_SOC_FLASH=y
- remote_CONFIG_PM=y
- remote_CONFIG_PM_DEVICE=y
- remote_CONFIG_PM_DEVICE_RUNTIME=y
- remote_CONFIG_POWEROFF=y
2 changes: 1 addition & 1 deletion 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: ccefb2a9e3a6bc5541d56eb34b822df184c8cb60
revision: pull/3314/head
import:
# In addition to the zephyr repository itself, NCS also
# imports the contents of zephyr/west.yml at the above
Expand Down