Skip to content

Commit 775d525

Browse files
jaz1-nordicrlubos
authored andcommitted
tests: drivers: mspi: hpf: Add App fault handler test
Add test case for app fault to check timeout handler Signed-off-by: Jakub Zymelka <[email protected]>
1 parent e5b09ec commit 775d525

File tree

6 files changed

+142
-0
lines changed

6 files changed

+142
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@
847847
/tests/drivers/flash_patch/ @nrfconnect/ncs-pluto
848848
/tests/drivers/fprotect/ @nrfconnect/ncs-pluto
849849
/tests/drivers/lpuart/ @nordic-krch
850+
/tests/drivers/mspi/app_fault_timer/ @nrfconnect/ncs-low-level-test @nrfconnect/ncs-ll-ursus
850851
/tests/drivers/nrfx_integration_test/ @nrfconnect/ncs-co-drivers
851852
/tests/drivers/pwm/gpio_loopback/ @nrfconnect/ncs-low-level-test
852853
/tests/drivers/uart/ @nrfconnect/ncs-low-level-test
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(hpf_app_fault_timer)
11+
12+
target_sources(app PRIVATE src/main.c)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
CONFIG_TEST=y
8+
CONFIG_ZTEST=y
9+
CONFIG_FLASH=y
10+
CONFIG_FLASH_PAGE_LAYOUT=y
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/ztest.h>
9+
#include <zephyr/drivers/counter.h>
10+
#include <zephyr/drivers/flash.h>
11+
#include <zephyr/devicetree.h>
12+
13+
#define TEST_AREA_DEV_NODE DT_INST(0, jedec_mspi_nor)
14+
#define TEST_AREA_OFFSET 0x0
15+
#define EXPECTED_SIZE 64
16+
#define TIMEOUT 15000000
17+
18+
static const struct device *const flash_dev = DEVICE_DT_GET(TEST_AREA_DEV_NODE);
19+
static const struct device *const flpr_fault_timer = DEVICE_DT_GET(DT_NODELABEL(fault_timer));
20+
static volatile bool timer_irq;
21+
22+
static void timer_irq_handler(const struct device *dev, void *user_data)
23+
{
24+
ARG_UNUSED(dev);
25+
ARG_UNUSED(user_data);
26+
27+
timer_irq = true;
28+
}
29+
30+
static void fault_timer_before(void *arg)
31+
{
32+
ARG_UNUSED(arg);
33+
34+
int rc;
35+
const struct counter_top_cfg top_cfg = {
36+
.callback = timer_irq_handler,
37+
.user_data = NULL,
38+
.flags = 0,
39+
.ticks = counter_us_to_ticks(flpr_fault_timer, CONFIG_MSPI_NRFE_FAULT_TIMEOUT)
40+
};
41+
42+
zassert_true(device_is_ready(flash_dev));
43+
zassert_true(device_is_ready(flpr_fault_timer));
44+
rc = counter_set_top_value(flpr_fault_timer, &top_cfg);
45+
zassert_equal(rc, 0, "Cannot set top value");
46+
47+
timer_irq = false;
48+
}
49+
50+
/**
51+
* @brief Check if the timer is not triggered when the flash is being read.
52+
* When we send commands to the flash the timer should be reset and stopped by FLPR.
53+
* If it is not then we will get an IRQ after CONFIG_MSPI_NRFE_FAULT_TIMEOUT.
54+
*/
55+
ZTEST(hpf_fault_timer, test_timer_timeout)
56+
{
57+
int rc;
58+
uint8_t buf[EXPECTED_SIZE];
59+
volatile uint32_t count;
60+
61+
/* 1. The timer is started and the flash is read. */
62+
rc = counter_start(flpr_fault_timer);
63+
zassert_equal(rc, 0, "Cannot start timer");
64+
65+
rc = flash_read(flash_dev, TEST_AREA_OFFSET, buf, EXPECTED_SIZE);
66+
zassert_equal(rc, 0, "Cannot read flash");
67+
68+
while (timer_irq == false && count < TIMEOUT) {
69+
count++;
70+
}
71+
count = 0;
72+
73+
/* 2. The timer should not trigger an IRQ. */
74+
zassert_false(timer_irq, "Timer IRQ triggered");
75+
76+
/* 3. The timer is started again and the flash is not read. */
77+
rc = counter_start(flpr_fault_timer);
78+
zassert_equal(rc, 0, "Cannot start timer");
79+
80+
zassert_false(timer_irq, "Timer IRQ triggered");
81+
82+
while (timer_irq == false && count < TIMEOUT) {
83+
count++;
84+
}
85+
86+
/* 4. FLPR is not supposed to stop the counter here,
87+
* because it does not receive any message.
88+
* The timer should trigger an IRQ.
89+
*/
90+
zassert_true(timer_irq, "Timer IRQ not triggered");
91+
92+
rc = counter_stop(flpr_fault_timer);
93+
zassert_equal(rc, 0, "Cannot stop timer");
94+
}
95+
96+
ZTEST_SUITE(hpf_fault_timer, NULL, NULL, fault_timer_before, NULL, NULL);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
SB_CONFIG_VPR_LAUNCHER=n
8+
SB_CONFIG_PARTITION_MANAGER=n
9+
SB_CONFIG_SDP=y
10+
SB_CONFIG_SDP_MSPI=y
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
common:
2+
tags:
3+
- ci_tests_drivers_sdp
4+
- drivers
5+
- mspi
6+
harness: ztest
7+
8+
tests:
9+
drivers.mspi.hpf_app_fault_timer:
10+
platform_allow:
11+
- nrf54l15dk/nrf54l15/cpuapp
12+
integration_platforms:
13+
- nrf54l15dk/nrf54l15/cpuapp

0 commit comments

Comments
 (0)