Software APIs
sw
device
tests
example_test_from_flash.c
1
// Copyright lowRISC contributors (OpenTitan project).
2
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
// SPDX-License-Identifier: Apache-2.0
4
5
/**
6
* This template serves as a starting point for writing software top-level
7
* tests that use the OpenTitan Test Framework (OTTF), and run at the flash
8
* boot stage. This template is intended to be copied and modified according to
9
* the instructions below.
10
*
11
* Plese delete all instructional comments after editing this template.
12
*/
13
14
/**
15
* Uncomment if you want to log messages with `LOG_{INFO,WARNING,ERROR,FATAL()`.
16
*/
17
// #include "sw/device/lib/runtime/log.h"
18
#include "sw/device/lib/testing/test_framework/check.h"
19
#include "
sw/device/lib/testing/test_framework/ottf_main.h
"
20
21
/**
22
* The OTTF expects the `kOttfTestConfig` symbol to be present, as it contains
23
* configuration settings for running the test implemented in this file. DO NOT
24
* delete this macro. However, you may modify the member assignments below
25
* according to the instructions above each configuration member.
26
*
27
* Set `enable_concurrency` to true if this test should run as a FreeRTOS
28
* task (enabling the test to spawn additional concurrent FreeRTOS tasks).
29
* When `enable_concurrency` is set to false, this test will run as a
30
* bare-metal program. Note, for the majority of top-level tests, this
31
* should be set to false.
32
*
33
* Set `console.test_may_clobber` to true if this test will reconfigure the UART
34
* in any way, since the OTTF uses the UART to communicate test results on
35
* Verilator and FPGA platforms, it must be reconfigured by the OTTF before
36
* test results are printed.
37
*/
38
OTTF_DEFINE_TEST_CONFIG(.enable_concurrency =
false
,
39
.console.test_may_clobber =
false
, );
40
41
/**
42
* Override any of the default OTTF exception handlers (by uncommenting and
43
* implementing them) if this test requires non-default exeception handling
44
* logic. Delete those that do not need to be overridden.
45
*
46
* See `sw/device/lib/testing/test_framework/ottf_isrs.c` for implementation
47
* details of the default OTTF exception handlers.
48
*
49
* Note, the `ottf_machine_ecall_handler` cannot be overridden when using the
50
* full OTTF, as it used to implement FreeRTOS context switching. See its
51
* implementation in `sw/device/lib/testing/test_framework/ottf_main.c`.
52
*/
53
// void ottf_exception_handler(uint32_t *exc_info) {}
54
// void ottf_instr_misaligned_fault_handler(uint32_t *exc_info) {}
55
// void ottf_instr_access_fault_handler(uint32_t *exc_info) {}
56
// void ottf_illegal_instr_fault_handler(uint32_t *exc_info) {}
57
// void ottf_breakpoint_handler(uint32_t *exc_info) {}
58
// void ottf_load_store_fault_handler(uint32_t *exc_info) {}
59
// void ottf_user_ecall_handler(uint32_t *exc_info) {}
60
61
/**
62
* Override any of the default OTTF ISRs (by uncommenting and implementing them)
63
* if this test requires non-default ISR logic. Delete those that do not need to
64
* be overridden.
65
*
66
* See `sw/device/lib/testing/test_framework/ottf_isrs.c` for implementation
67
* details of the default OTTF ISRs.
68
*/
69
// void ottf_software_isr(uint32_t *exc_info) {}
70
// void ottf_timer_isr(uint32_t *exc_info) {}
71
// void ottf_external_isr(uint32_t *exc_info) {}
72
73
/**
74
* Save data that will need to persist across resets by placing it in the
75
* ".non_volatile_scratch" section. OpenTitan's flash is mapped to its address
76
* space for reads. Thus, these variables can be read as usual. Write to this
77
* region with the flash controller DIFs, obeying flash constraints. Since the
78
* non-volatile scratch region is NOLOAD and bootstrap erases all flash, initial
79
* values of variables in this section are always `0xff`, regardless of any
80
* initialization in the source code. In order to avoid confusion, don't
81
* initialize or assign to these values. If needed, they can be initialized at
82
* runtime via flash controller DIFs.
83
*/
84
// OT_SECTION(".non_volatile_scratch") uint32_t non_volatile_data[2];
85
86
bool
test_main
(
void
) {
87
/**
88
* Place test code here.
89
*/
90
91
/**
92
* Return true if the test succeeds. Return false if it should fail.
93
*/
94
return
true
;
95
}
Return to
OpenTitan Documentation