1*** Variables ***
2${UART}                       sysbus.usart2
3${RTC_32KHZ}=  SEPARATOR=
4...  """                                      ${\n}
5...  using "platforms/cpus/stm32f4.repl"      ${\n}
6...                                           ${\n}
7...  rtc:                                     ${\n}
8...  ${SPACE*4}wakeupTimerFrequency: 32000    ${\n}
9...  """
10
11*** Test Cases ***
12Run Zephyr Hello World
13    Execute Command           set bin @https://dl.antmicro.com/projects/renode/stm32f4_discovery--zephyr-hello_world.elf-s_515008-2180a4018e82fcbc8821ef4330c9b5f3caf2dcdb
14    Execute Command           include @scripts/single-node/stm32f4_discovery.resc
15
16    Execute Command           showAnalyzer ${UART}
17    Create Terminal Tester    ${UART}
18
19    Start Emulation
20
21    Wait For Line On Uart     Booting Zephyr OS
22    Wait For Line On Uart     Hello World! stm32f4_disco
23
24Configure RTC Alarm
25    Execute Command           mach create
26    # Use an RTC frequency of exactly 32 kHz as expected by the test binary
27    Execute Command           machine LoadPlatformDescriptionFromString ${RTC_32KHZ}
28    Execute Command           sysbus LoadELF @https://dl.antmicro.com/projects/renode/stm32f4_discovery--riot-tests_periph_rtc.elf-s_1249644-ca2effb6a0a8bcde39496b99bcb8b160a4ed292e
29
30    Execute Command           showAnalyzer ${UART}
31    Create Terminal Tester    ${UART}
32
33    Start Emulation
34
35    Wait For Line On Uart     Help: Press s to start test, r to print it is ready
36    Write Char On Uart        s
37
38    Wait For Line On Uart     This is RIOT!
39    Wait For Line On Uart     RIOT RTC low-level driver test
40    Wait For Line On Uart     This test will display 'Alarm!' every 2 seconds for 4 times
41
42    # "Alarm!" should be printed every 2 seconds, 4 times in total
43    Wait For Line On Uart     Alarm!
44    ${timeInfo}=              Execute Command    emulation GetTimeSourceInfo
45    Should Contain            ${timeInfo}        Elapsed Virtual Time: 00:00:02
46
47    Wait For Line On Uart     Alarm!
48    ${timeInfo}=              Execute Command    emulation GetTimeSourceInfo
49    Should Contain            ${timeInfo}        Elapsed Virtual Time: 00:00:04
50
51    Wait For Line On Uart     Alarm!
52    ${timeInfo}=              Execute Command    emulation GetTimeSourceInfo
53    Should Contain            ${timeInfo}        Elapsed Virtual Time: 00:00:06
54
55    Wait For Line On Uart     Alarm!
56    ${timeInfo}=              Execute Command    emulation GetTimeSourceInfo
57    Should Contain            ${timeInfo}        Elapsed Virtual Time: 00:00:08
58
59    # There should be no more alarms after the expected 4
60    Test If Uart Is Idle      3
61
62Should Fire Update Event When Counting Up
63    Execute Command         mach create
64    Execute Command         machine LoadPlatformDescription @platforms/cpus/stm32f4.repl
65    Execute Command         sysbus LoadELF @https://dl.antmicro.com/projects/renode/stm32f4disco-timer-upcount.elf-g2d98d1b-s_1021132-961284be838516abea9db8302c9af2dcb67b482a
66
67    Create Terminal Tester  sysbus.usart2
68
69    Start Emulation
70
71    Wait For Line On Uart   *** Timer2 Upcount Overflow Example ***
72    Wait For Line On Uart   Tim2 IRQ enabled
73    Wait For Line On Uart   Tim2 started
74    Wait For Line On Uart   period elapsed callback
75    Wait For Line On Uart   period elapsed callback
76    Wait For Line On Uart   period elapsed callback
77
78Should Fire Update Event When Counting Down
79    Execute Command         mach create
80    Execute Command         machine LoadPlatformDescription @platforms/cpus/stm32f4.repl
81    Execute Command         sysbus LoadELF @https://dl.antmicro.com/projects/renode/stm32f4disco-timer-downcount.elf-g2d98d1b-s_1021136-4995992fa219c49c38d7163da1381104c26c823a
82
83    Create Terminal Tester  sysbus.usart2
84
85    Start Emulation
86
87    Wait For Line On Uart   *** Timer2 Downcount Overflow Example ***
88    Wait For Line On Uart   Tim2 IRQ enabled
89    Wait For Line On Uart   Tim2 started
90    Wait For Line On Uart   period elapsed callback
91    Wait For Line On Uart   period elapsed callback
92    Wait For Line On Uart   period elapsed callback
93
94Should Print Hello World When Built With STM32CubeMX
95    Execute Command         mach create
96    Execute Command         machine LoadPlatformDescription @platforms/cpus/stm32f4.repl
97    Execute Command         sysbus LoadELF @https://dl.antmicro.com/projects/renode/stm32f4--cube_mx-hello_world.elf-s_625976-606092c29de896f3bd83a4e981f2c7f3a6ed3142
98
99    Create Terminal Tester  sysbus.usart2
100
101    Start Emulation
102
103    Wait For Line On Uart   Hello World!
104    Wait For Line On Uart   Hello World!
105    Wait For Line On Uart   Hello World!
106
107Should Print Hello World With Custom Flash Latency
108    Execute Command         mach create
109    Execute Command         machine LoadPlatformDescription @platforms/cpus/stm32f4.repl
110    Execute Command         sysbus LoadELF @https://dl.antmicro.com/projects/renode/stm32f4--cube_mx-hello_world.elf-s_625992-119d2b1d81ef6bb85498d1024c61736bb53cee4c
111
112    Create Terminal Tester  sysbus.usart2
113
114    Start Emulation
115
116    Wait For Line On Uart   Hello World!
117    Wait For Line On Uart   Hello World!
118    Wait For Line On Uart   Hello World!
119
120Should Block Timer Interrupt When Faultmask Is Set
121    Execute Command         mach create
122    Execute Command         machine LoadPlatformDescription @platforms/cpus/stm32f4.repl
123    Execute Command         sysbus LoadELF @https://dl.antmicro.com/projects/renode/stm32f4disco-faultmask.elf-s_434744-080256edf201b1e2f7c67bf15000ba1ffa031990
124
125    Create Terminal Tester  sysbus.usart2
126
127    Start Emulation
128
129    Wait For Line On Uart   Setting FAULTMASK to 1
130    Wait For Line On Uart   Timer IRQ enabled
131    Wait For Line On Uart   Sleeping
132    Test If Uart Is Idle    1
133    Wait For Line On Uart   Setting FAULTMASK to 0
134    Wait For Line On Uart   Timer interrupt
135    Wait For Line On Uart   Timer interrupt
136    Wait For Line On Uart   Timer interrupt
137
138Should Clear FAULTMASK On Exception Exit
139    Execute Command         mach create
140    Execute Command         machine LoadPlatformDescription @platforms/cpus/stm32f4.repl
141    Execute Command         sysbus LoadELF @https://dl.antmicro.com/projects/renode/stm32f4disco-faultmask-noclearing.elf-s_433676-802f85357028150b4586bb3a54a5e44e7a3c2ec5
142
143    Create Terminal Tester  sysbus.usart2
144
145    Start Emulation
146
147    # Each timer interrupt sets FAULTMASK, so if the field is not cleared by exception exit
148    # then this message would be only printed once
149    Wait For Line On Uart   Timer interrupt
150    Wait For Line On Uart   Timer interrupt
151    Wait For Line On Uart   Timer interrupt
152    Wait For Line On Uart   Timer interrupt
153