Skip to content

Commit

Permalink
suit: Split fetch tests into app and SDFW
Browse files Browse the repository at this point in the history
Add tests that verify fetching into MEM component from both Application
and SDFW contexts.
Add smoke tests for IPUCs as MEM driver as well as cache backend.

Ref: NCSDK-30809

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
  • Loading branch information
tomchy committed Feb 11, 2025
1 parent a345d42 commit 6a97488
Show file tree
Hide file tree
Showing 12 changed files with 952 additions and 278 deletions.
10 changes: 8 additions & 2 deletions tests/subsys/suit/fetch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(integration_test_fetch)
include(../cmake/test_template.cmake)

target_include_directories(app PRIVATE mocks)

zephyr_library_link_libraries(suit_memptr_storage_interface)
zephyr_library_link_libraries(suit_platform_interface)
zephyr_library_link_libraries(suit_ipuc)
zephyr_library_link_libraries(suit_stream_filters_interface)
zephyr_library_link_libraries(suit_decrypt_test_utils)

zephyr_library_link_libraries_ifdef(CONFIG_TEST_SUIT_PLATFORM_FETCH_VARIANT_APP suit_memory_layout_interface)
zephyr_library_link_libraries_ifdef(CONFIG_TEST_SUIT_PLATFORM_FETCH_VARIANT_SDFW suit_decrypt_test_utils)
zephyr_library_link_libraries_ifdef(CONFIG_TEST_SUIT_PLATFORM_FETCH_VARIANT_SDFW suit_stream_filters_interface)

zephyr_compile_definitions(CONFIG_SOC_NRF54H20_CPUAPP)
35 changes: 35 additions & 0 deletions tests/subsys/suit/fetch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,39 @@
rsource "../mocks/Kconfig"
rsource "../tests/Kconfig"

choice TEST_SUIT_PLATFORM_FETCH_VARIANT
prompt "SUIT platform implementation variant to test"
default TEST_SUIT_PLATFORM_FETCH_VARIANT_SDFW

config TEST_SUIT_PLATFORM_FETCH_VARIANT_APP
bool "Local or application"
depends on SUIT_PLATFORM_VARIANT_APP
select FLASH_IPUC
select SUIT_ENVELOPE_INFO
select SUIT_CACHE_RW
select SUIT_STREAM_SINK_CACHE
select SUIT_STREAM_FETCH_SOURCE_MGR

config TEST_SUIT_PLATFORM_FETCH_VARIANT_SDFW
bool "Bootloader or SDFW"
depends on SUIT_PLATFORM_VARIANT_SDFW
select MOCK_SDFW_ARBITER
select SUIT_EXECUTION_MODE
select SUIT_MCI
select SUIT_STREAM_FILTER_DECRYPT
select SUIT_CRYPTO
select SUIT_STORAGE

endchoice # TEST_SUIT_PLATFORM_FETCH_VARIANT

if TEST_SUIT_PLATFORM_FETCH_VARIANT_APP

config SUIT_CACHE_SDFW_IPUC_ID
default 254

config SUIT_CACHE_APP_IPUC_ID
default 255

endif # TEST_SUIT_PLATFORM_FETCH_VARIANT_APP

source "Kconfig.zephyr"
28 changes: 23 additions & 5 deletions tests/subsys/suit/fetch/boards/native_sim.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,30 @@
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
#address-cells = < 0x1 >;
#size-cells = < 0x1 >;

/* Use the last 48KB of NVM as suit storage. */
suit_storage: partition@f4000 {
reg = <0xf4000 DT_SIZE_K(48)>;
suit_storage: partition@e9000 {
reg = <0xe9000 DT_SIZE_K(48)>;
};

dfu_partition: partition@f5000 {
reg = < 0xf5000 DT_SIZE_K(4) >;
};

dfu_cache_partition_1: partition@f6000 {
reg = <0xf6000 DT_SIZE_K(4)>;
};

dfu_cache_partition_3: partition@f7000 {
reg = <0xf7000 DT_SIZE_K(4)>;
};
};
};

/ {
sram0: memory@20000000 {
compatible = "mmio-sram";
reg = <0x20000000 DT_SIZE_K(256)>;
};
};
28 changes: 23 additions & 5 deletions tests/subsys/suit/fetch/boards/native_sim_64.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,30 @@
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
#address-cells = < 0x1 >;
#size-cells = < 0x1 >;

/* Use the last 48KB of NVM as suit storage. */
suit_storage: partition@f4000 {
reg = <0xf4000 DT_SIZE_K(48)>;
suit_storage: partition@e9000 {
reg = <0xe9000 DT_SIZE_K(48)>;
};

dfu_partition: partition@f5000 {
reg = < 0xf5000 DT_SIZE_K(4) >;
};

dfu_cache_partition_1: partition@f6000 {
reg = <0xf6000 DT_SIZE_K(4)>;
};

dfu_cache_partition_3: partition@f7000 {
reg = <0xf7000 DT_SIZE_K(4)>;
};
};
};

/ {
sram0: memory@20000000 {
compatible = "mmio-sram";
reg = <0x20000000 DT_SIZE_K(256)>;
};
};
16 changes: 16 additions & 0 deletions tests/subsys/suit/fetch/boards/nrf54h20dk_nrf54h20_cpuapp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

#Logging and printk is using standard UART.
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_PRINTK=y
CONFIG_LOG_BUFFER_SIZE=8192
38 changes: 38 additions & 0 deletions tests/subsys/suit/fetch/boards/nrf54h20dk_nrf54h20_cpuapp.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/* Split DFU partition into a smaller one and DFU caches. */
/delete-node/ &dfu_partition;

&mram1x {
erase-block-size = < 0x10 >;
/* Hardcoded inside the soc_flash_nrf_mram.c (MRAM_WORD_SIZE) */
write-block-size = < 0x10 >;

cpuapp_rw_partitions: cpuapp-rw-partitions {
compatible = "nordic,owned-partitions", "fixed-partitions";
status = "okay";
nordic,access = <NRF_OWNER_ID_APPLICATION NRF_PERM_RW>;
#address-cells = < 0x1 >;
#size-cells = < 0x1 >;

dfu_partition: partition@19d000 {
reg = < 0x19d000 DT_SIZE_K(1) >;
};

dfu_cache_partition_1: partition@19d400 {
reg = <0x19d400 DT_SIZE_K(1)>;
};

dfu_cache_partition_3: partition@19d800 {
reg = <0x19d800 DT_SIZE_K(1)>;
};

__mpc_override_align: partition@19dc00 {
reg = <0x19dc00 DT_SIZE_K(1)>;
};
};
};
29 changes: 29 additions & 0 deletions tests/subsys/suit/fetch/mocks/mock_suit_ipuc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef MOCK_SUIT_IPUC_H__
#define MOCK_SUIT_IPUC_H__

#include <suit_ipuc.h>
#include <zephyr/fff.h>

DEFINE_FFF_GLOBALS;

FAKE_VALUE_FUNC(int, suit_ipuc_get_count, size_t *);
FAKE_VALUE_FUNC(int, suit_ipuc_get_info, size_t, struct zcbor_string *, suit_manifest_role_t *);
FAKE_VALUE_FUNC(int, suit_ipuc_write_setup, struct zcbor_string *, struct zcbor_string *,
struct zcbor_string *);
FAKE_VALUE_FUNC(int, suit_ipuc_write, struct zcbor_string *, size_t, uintptr_t, size_t, bool);

static inline void mock_suit_ipuc_reset(void)
{
RESET_FAKE(suit_ipuc_get_count);
RESET_FAKE(suit_ipuc_get_info);
RESET_FAKE(suit_ipuc_write_setup);
RESET_FAKE(suit_ipuc_write);
}

#endif /* MOCK_SUIT_IPUC_H__ */
9 changes: 2 additions & 7 deletions tests/subsys/suit/fetch/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@ CONFIG_SUIT_UTILS=y
CONFIG_SUIT_CACHE=y
CONFIG_SUIT_MEMPTR_STORAGE=y

CONFIG_SUIT_LOG_LEVEL_DBG=y

CONFIG_ZCBOR=y
CONFIG_ZCBOR_CANONICAL=y

CONFIG_FLASH=y
CONFIG_FLASH_MAP=y

CONFIG_SUIT_IPUC=y
CONFIG_MOCK_SDFW_ARBITER=y
CONFIG_SUIT_STORAGE=y

CONFIG_SUIT_EXECUTION_MODE=y
CONFIG_SUIT_MCI=y
CONFIG_SUIT_STREAM_FILTER_DECRYPT=y
CONFIG_SUIT_CRYPTO=y
Loading

0 comments on commit 6a97488

Please sign in to comment.