2 # For each named Cortex-M3 vector_catch flag VECTOR ...
7 # BUT NYET hard_err, int_err (their test cases don't yet work) ...
11 # - Test #1: verify that OpenOCD ignores exceptions by default
12 # + l_VECTOR (loads testcase to RAM)
13 # + fault triggers loop-to-self exception "handler"
15 # + observe fault "handling" -- loop-to-self from load_and_run (below)
17 # - Test #2: verify that "vector_catch" makes OpenOCD stops ignoring them
18 # + cortex_m vector_catch none
19 # + cortex_m vector_catch VECTOR
20 # + l_VECTOR (loads testcase to RAM)
21 # + fault triggers vector catch hardware
22 # + observe OpenOCD entering debug state with no assistance
24 # NOTE "reset" includes the NVIC, so that test case gets its reset vector
25 # from the flash, not from the vector table set up here. Which means that
26 # for that vector_catch option, the Test #1 (above) "observe" step won't
27 # use the SRAM address.
30 # we can fully automate test #2
31 proc vector_test {tag} {
33 # REVISIT -- annoying, we'd like to scrap vector_catch output
34 cortex_m vector_catch none
35 cortex_m vector_catch $tag
40 # Load and start one vector_catch test case.
42 # name -- tag for the vector_catch flag being tested
43 # halfwords -- array of instructions (some wide, some narrow)
44 # n_instr -- how many instructions are in $halfwords
46 proc load_and_run { name halfwords n_instr } {
49 # Load code at beginning of SRAM.
50 echo "# code to trigger $name vector"
53 # array2mem should be faster, though we'd need to
54 # compute the resulting $addr ourselves
55 foreach opcode $halfwords {
60 # create default loop-to-self at $addr ... it serves as
61 # (a) "main loop" on error
62 # (b) handler for all exceptions that get triggered
65 # disassemble, as sanity check and what's-happening trace
66 arm disassemble 0x20000000 [expr 1 + $n_instr ]
68 # Assume that block of code is at most 16 halfwords long.
69 # Create a basic table of loop-to-self exception handlers.
70 mww 0x20000020 $addr 16
71 # Store its address in VTOR
72 mww 0xe000ed08 0x20000020
73 # Use SHCSR to ensure nothing escalates to a HardFault
74 mww 0xe000ed24 0x00070000
76 # now start, trigering the $name vector catch logic
82 # FORCED -- escalate something to HardFault
87 # STKERR -- exception stack BusFault
90 # BusFault, escalates to HardFault
92 # PRECISERR -- assume less than 512 MBytes of SRAM
93 load_and_run bus_err {
99 # UsageFault, escalates to HardFault
100 proc l_state_err {} {
101 # UNDEFINSTR -- issue architecturally undefined instruction
102 load_and_run state_err {
107 # UsageFault, escalates to HardFault
109 # UNALIGNED -- LDM through unaligned pointer
110 load_and_run chk_err {
116 # UsageFault, escalates to HardFault
118 # NOCP -- issue cp14 DCC instruction
119 load_and_run nocp_err {
124 # MemManage, escalates to HardFault
126 # IACCVIOL -- instruction fetch from an XN region
127 load_and_run mm_err {
134 # issue SYSRESETREQ via AIRCR