Skip to content

Commit 8fd5083

Browse files
committed
Test: Bugfix for psa arch test in an521
psa arch test read memory value without initializing it. Change-Id: Id125919563c434d86946bc97c2be3cc0377af91d Signed-off-by: Summer Qin <[email protected]>
1 parent 45bdb4e commit 8fd5083

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
From c82920457b1e971e13a98d9937c9656ec600c5dc Mon Sep 17 00:00:00 2001
2+
From: Summer Qin <[email protected]>
3+
Date: Mon, 11 Apr 2022 11:20:35 +0800
4+
Subject: [PATCH] Init non-volatile memory before using in an521 dev apis
5+
6+
psa arch test read data from non-volatile memory directly
7+
without initializing it. The data maybe randomly which may
8+
cause test fail.
9+
10+
Signed-off-by: Summer Qin <[email protected]>
11+
---
12+
api-tests/val/nspe/val_entry.c | 19 +++++++++++++++++++
13+
api-tests/val/nspe/val_framework.c | 8 +++++++-
14+
api-tests/val/val_nspe.cmake | 6 +++++-
15+
3 files changed, 31 insertions(+), 2 deletions(-)
16+
17+
diff --git a/api-tests/val/nspe/val_entry.c b/api-tests/val/nspe/val_entry.c
18+
index 15aefb9..3b708ea 100644
19+
--- a/api-tests/val/nspe/val_entry.c
20+
+++ b/api-tests/val/nspe/val_entry.c
21+
@@ -20,6 +20,11 @@
22+
#include "val_peripherals.h"
23+
#include "val_dispatcher.h"
24+
25+
+#ifdef TGT_DEV_APIS_TFM_AN521
26+
+int intermediate_boot = 0;
27+
+#define NVMEM_USED_SIZE 16
28+
+#endif
29+
+
30+
/**
31+
@brief - PSA C main function, does VAL init and calls test dispatcher
32+
@param - None
33+
@@ -36,6 +41,20 @@ int32_t val_entry(void)
34+
goto exit;
35+
}
36+
37+
+#ifdef TGT_DEV_APIS_TFM_AN521
38+
+ int32_t init_value[NVMEM_USED_SIZE] = {0};
39+
+
40+
+ if (!intermediate_boot)
41+
+ {
42+
+ status = val_nvmem_write(VAL_NVMEM_OFFSET(NV_BOOT), init_value, NVMEM_USED_SIZE);
43+
+ if (VAL_ERROR(status))
44+
+ {
45+
+ val_print(PRINT_ERROR, "\n\tNVMEM initialization error", 0);
46+
+ goto exit;
47+
+ }
48+
+ }
49+
+#endif
50+
+
51+
status = val_get_last_run_test_id(&test_id);
52+
if (VAL_ERROR(status))
53+
{
54+
diff --git a/api-tests/val/nspe/val_framework.c b/api-tests/val/nspe/val_framework.c
55+
index 54e5dbd..14c6333 100644
56+
--- a/api-tests/val/nspe/val_framework.c
57+
+++ b/api-tests/val/nspe/val_framework.c
58+
@@ -24,6 +24,9 @@
59+
60+
extern val_api_t val_api;
61+
extern psa_api_t psa_api;
62+
+#ifdef TGT_DEV_APIS_TFM_AN521
63+
+extern int intermediate_boot;
64+
+#endif
65+
66+
/* globals */
67+
test_status_buffer_t g_status_buffer;
68+
@@ -598,7 +601,10 @@ val_status_t val_get_last_run_test_id(test_id_t *test_id)
69+
val_status_t status;
70+
test_count_t test_count;
71+
boot_t boot;
72+
- int i = 0, intermediate_boot = 0;
73+
+ int i = 0;
74+
+#ifndef TGT_DEV_APIS_TFM_AN521
75+
+ int intermediate_boot = 0;
76+
+#endif
77+
boot_state_t boot_state[] = {BOOT_NOT_EXPECTED,
78+
BOOT_EXPECTED_NS,
79+
BOOT_EXPECTED_S,
80+
diff --git a/api-tests/val/val_nspe.cmake b/api-tests/val/val_nspe.cmake
81+
index 355ca68..ae0af8d 100644
82+
--- a/api-tests/val/val_nspe.cmake
83+
+++ b/api-tests/val/val_nspe.cmake
84+
@@ -56,4 +56,8 @@ target_include_directories(${PSA_TARGET_VAL_NSPE_LIB} PRIVATE
85+
if(${WATCHDOG_AVAILABLE} EQUAL 1)
86+
target_compile_definitions(${PSA_TARGET_VAL_NSPE_LIB} PRIVATE WATCHDOG_AVAILABLE)
87+
endif()
88+
-target_compile_definitions(${PSA_TARGET_VAL_NSPE_LIB} PRIVATE VAL_NSPE_BUILD)
89+
+target_compile_definitions(${PSA_TARGET_VAL_NSPE_LIB}
90+
+ PRIVATE
91+
+ VAL_NSPE_BUILD
92+
+ $<$<STREQUAL:${TARGET},tgt_dev_apis_tfm_an521>:TGT_DEV_APIS_TFM_AN521>
93+
+)
94+
--
95+
2.17.1
96+

0 commit comments

Comments
 (0)