1*** Variables *** 2${SPI_FLASH}= SEPARATOR= 3... """ ${\n} 4... spiFlashMemory: Memory.MappedMemory ${\n} 5... ${SPACE*4}size: 0x100000 ${\n} 6... ${\n} 7... spiFlash: SPI.Micron_MT25Q @ spi2 ${\n} 8... ${SPACE*4}underlyingMemory: spiFlashMemory ${\n} 9... ${\n} 10... gpioPortB: ${\n} 11... ${SPACE*4}12 -> spiFlash@0 ${\n} 12... """ 13 14*** Keywords *** 15Check Zephyr Version 16 Wait For Prompt On Uart $ 17 Write Line To Uart version 18 Wait For Line On Uart Zephyr version 2.6.99 19 20Should Be Equal Within Range 21 [Arguments] ${value0} ${value1} ${range} 22 23 ${diff}= Evaluate abs(${value0} - ${value1}) 24 25 Should Be True ${diff} <= ${range} 26 27Set PWM And Check Duty 28 [Arguments] ${pwm} ${channel} ${period} ${pulse} ${expected_duty} 29 30 Write Line To Uart pwm cycles ${pwm} ${channel} ${period} ${pulse} 31 Execute Command gpioPortB.pt Reset 32 Execute Command pause 33 Execute Command emulation RunFor "5" 34 # Go back to continuous running so the next iteration can run UART commands 35 Start Emulation 36 ${hp}= Execute Command gpioPortB.pt HighPercentage 37 ${hpn}= Convert To Number ${hp} 38 Should Be Equal Within Range ${expected_duty} ${hpn} 10 39 40Run Command 41 [Arguments] ${command} 42 Write Line To Uart ${command} 43 Wait For Prompt On Uart $ 44 45Flash Should Contain 46 [Arguments] ${address} ${value} 47 ${res}= Execute Command flash ReadDoubleWord ${address} 48 Should Be Equal As Numbers ${res} ${value} 49 50*** Test Cases *** 51Should Handle Version Command In Zephyr Shell 52 Execute Command include @scripts/single-node/stm32l072.resc 53 54 Create Terminal Tester sysbus.usart2 55 56 Start Emulation 57 58 Check Zephyr Version 59 60Should Handle Version Command In Zephyr Shell On Lpuart 61 Execute Command include @scripts/single-node/stm32l072.resc 62 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/bl072z_lrwan1--zephyr-shell_module_lpuart.elf-s_1197384-aea9caa07fddc35583bd09cb47563a11a2f90935 63 64 Create Terminal Tester sysbus.lpuart1 65 66 Start Emulation 67 68 Check Zephyr Version 69 70Should Handle DMA Memory To Memory Transfer 71 Execute Command include @scripts/single-node/stm32l072.resc 72 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-chan_blen_transfer.elf-s_669628-623c4f2b14cad8e52db12d8b1b46effd1a89b644 73 74 # The test takes 8 seconds virtual time 75 Create Terminal Tester sysbus.usart2 timeout=10 76 77 Wait For Line On Uart PASS - [dma_m2m.test_dma_m2m_chan0_burst16] 78 Wait For Line On Uart PASS - [dma_m2m.test_dma_m2m_chan0_burst8] 79 Wait For Line On Uart PASS - [dma_m2m.test_dma_m2m_chan1_burst16] 80 Wait For Line On Uart PASS - [dma_m2m.test_dma_m2m_chan1_burst8] 81 82 83Should Handle DMA Memory To Memory Loop Transfer 84 Execute Command include @scripts/single-node/stm32l072.resc 85 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-loop_transfer.elf-s_692948-f182b72146a77daeb4b73ece0aff2498aeaa5876 86 87 Create Terminal Tester sysbus.usart2 88 89 Start Emulation 90 91 Wait For Line On Uart PASS - [dma_m2m_loop.test_dma_m2m_loop] 92 Wait For Line On Uart PASS - [dma_m2m_loop.test_dma_m2m_loop_suspend_resume] 93 94Independent Watchdog Should Trigger Reset 95 # We can't use stm32l072.resc in this test because it defines a reset macro 96 # that loads a Zephyr ELF which gets triggered by the watchdog reset. This 97 # would obviously make the test fail because it would suddenly start running 98 # a different Zephyr application, but even if it reloaded the same ELF the 99 # test would still fail because `m_state` would be reset. We manually define 100 # a reset macro that only resets PC and SP to their initial values. 101 Execute Command mach create 102 Execute Command using sysbus 103 Execute Command machine LoadPlatformDescription @platforms/cpus/stm32l072.repl 104 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/zephyr-drivers_watchdog_wdt_basic_api-test.elf-s_463344-248e7e6eb8a681a33c4bf8fdb45c6bf95bcb57fd 105 106 ${pc}= Execute Command sysbus GetSymbolAddress "z_arm_reset" 107 ${sp}= Execute Command sysbus GetSymbolAddress "z_idle_stacks" 108 109 Execute Command macro reset "cpu PC ${pc}; cpu SP ${sp}" 110 111 Create Terminal Tester sysbus.usart2 112 113 Start Emulation 114 115 Wait For Line On Uart PROJECT EXECUTION SUCCESSFUL 116 117PWM Should Support GPIO Output 118 Execute Command include @scripts/single-node/stm32l072.resc 119 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-custom_shell_pwm.elf-s_884872-f36f63ef9435aaf89f37922d3c78428c52be1320 120 121 # create a PWM analyzer and connect gpiob.10 to it 122 Execute Command machine LoadPlatformDescriptionFromString "pt: PWMTester @ gpioPortB 10" 123 Execute Command machine LoadPlatformDescriptionFromString "gpioPortB: { 10 -> pt@0 }" 124 125 Create Terminal Tester sysbus.usart2 126 127 Start Emulation 128 129 ${pwm}= Wait For Line On Uart pwm device: (\\w+) treatAsRegex=true 130 ${pwm}= Set Variable ${pwm.groups[0]} 131 132 # The expected percentage in each test is approximately duty/period 133 # pwm ch period duty expected % 134 Set PWM And Check Duty ${pwm} 3 256 5 0 135 Set PWM And Check Duty ${pwm} 3 256 85 33 136 Set PWM And Check Duty ${pwm} 3 256 127 50 137 Set PWM And Check Duty ${pwm} 3 256 250 100 138 139Should Handle Flash Operations 140 Execute Command include @scripts/single-node/stm32l072.resc 141 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-flash_shell.elf-s_1199160-dad825e98576f82198b759a75e5d0aeafcb00443 142 143 Create Terminal Tester sysbus.usart2 144 145 Start Emulation 146 147 # Page 1504 (0x0002f000) and the surrounding area is empty so we can use it 148 Flash Should Contain 0x0002f000 0x00000000 149 Run Command flash write 0x0002f000 0x11 0x22 0x33 0x44 150 Flash Should Contain 0x0002f000 0x44332211 151 152 Run Command flash page_erase 1504 153 Flash Should Contain 0x0002f000 0x00000000 154 155 # Pages are 128 bytes long, so this pattern will cover 3 pages 156 Run Command flash write_pattern 0x0002f000 384 157 Flash Should Contain 0x0002f020 0x23222120 158 Flash Should Contain 0x0002f0a0 0xa3a2a1a0 159 Flash Should Contain 0x0002f120 0x23222120 160 161 # Erasing a page should set the whole page to 0 but not affect adjacent pages 162 Run Command flash page_erase 1505 163 Flash Should Contain 0x0002f020 0x23222120 164 # Check the first word of the page, a word within it and the last word of the page 165 Flash Should Contain 0x0002f080 0x00000000 166 Flash Should Contain 0x0002f0a0 0x00000000 167 Flash Should Contain 0x0002f0fc 0x00000000 168 Flash Should Contain 0x0002f120 0x23222120 169 170Should Handle EEPROM Operations 171 Execute Command include @scripts/single-node/stm32l072.resc 172 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-eeprom.elf-s_526436-c574c036e4003e7b79923c7a3076809baa645826 173 174 Create Terminal Tester sysbus.usart2 175 176 Start Emulation 177 178 Wait For Line On Uart PASS - test_size 179 Wait For Line On Uart PASS - test_out_of_bounds 180 Wait For Line On Uart PASS - test_write_rewrite 181 Wait For Line On Uart PASS - test_write_at_fixed_address 182 Wait For Line On Uart PASS - test_write_byte 183 Wait For Line On Uart PASS - test_write_at_increasing_address 184 Wait For Line On Uart PASS - test_zero_length_write 185 Wait For Line On Uart PROJECT EXECUTION SUCCESSFUL 186 187RTC Should Support Alarms 188 Execute Command include @scripts/single-node/stm32l072.resc 189 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-alarm.elf-s_457324-fab62a573e2ce5b6cad2dfccfd6931021319cadc 190 191 Create Terminal Tester sysbus.usart2 192 193 Start Emulation 194 195 Wait For Line On Uart Set alarm in 2 sec (2 ticks) 196 Wait For Line On Uart !!! Alarm !!! 197 # This output seems off by one but it is correct 198 # See https://github.com/zephyrproject-rtos/zephyr/commit/55594306544cddb5077923758485503fd723d2ae 199 # and https://github.com/zephyrproject-rtos/zephyr/commit/507ebecffc325c2234419907884b3164950056d2 200 Wait For Line On Uart Now: 3 201 202RTC Should Support Wakeup 203 Execute Command include @scripts/single-node/stm32l072.resc 204 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-custom_rtc_wakeup.elf-s_430288-709ea60e0de053b3d693718d80fd3afb9e090221 205 206 Create Terminal Tester sysbus.usart2 207 208 Start Emulation 209 210 # This sample configures the RTC wakeup in 4 different ways, one after another: 211 # - prescaler /2, autoreload 410 212 # - prescaler /16, autoreload 410 213 # - prescaler /16, autoreload 10 214 # - 1Hz clock, autoreload 1 215 # and expects the correct time to pass before the next time the wakeup callback 216 # is triggered after each configuration. The wakeup callback prints the time 217 # since the previous call in milliseconds. 218 # The autoreload value of 410 comes from 25 ms * (32768 Hz / 2) = 409.6 219 Wait For Line On Uart RTC configured, waiting for wakeup interrupt 220 Wait For Line On Uart RTC wakeup callback triggered, wakeup flag is set, ticks=25 221 Wait For Line On Uart RTC wakeup callback triggered, wakeup flag is set, ticks=200 222 Wait For Line On Uart RTC wakeup callback triggered, wakeup flag is set, ticks=5 223 Wait For Line On Uart RTC wakeup callback triggered, wakeup flag is set, ticks=1000 224 225Should Run Philosophers Demo On LpTimer 226 Execute Command include @scripts/single-node/stm32l072.resc 227 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-philosophers_lptimer.elf-s_579864-a8786745129b9aa4431c85138c0dcc65bd0543e4 228 229 Create Terminal Tester sysbus.usart2 230 231 Start Emulation 232 233 Wait For Line On Uart Philosopher 5.*THINKING treatAsRegex=true 234 Wait For Line On Uart Philosopher 5.*HOLDING treatAsRegex=true 235 Wait For Line On Uart Philosopher 5.*EATING treatAsRegex=true 236 237SPI Should Work In Interrupt-Driven Mode 238 Execute Command include @scripts/single-node/stm32l072.resc 239 Execute Command machine LoadPlatformDescriptionFromString ${SPI_FLASH} 240 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-spi_flash.elf-s_540832-09b987ec67ea619d0330963ef9d35ab561d04430 241 242 Create Terminal Tester sysbus.usart2 243 244 Start Emulation 245 246 Wait For Line On Uart Flash erase succeeded! 247 Wait For Line On Uart Data read matches data written. Good!! 248 249PVD Should Fire Interrupt 250 Execute Command include @scripts/single-node/stm32l072.resc 251 Execute Command sysbus LoadELF @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1-zephyr-custom_pwr_pvd.elf-s_871128-6822cb7346d2171c2b170b74701144d59b36199c 252 253 Create Terminal Tester sysbus.usart2 254 255 Start Emulation 256 257 Run Command pvd configure 3.1 rising 258 Execute Command pwr Voltage 2.9 259 Wait For Line On Uart PVD callback triggered, PVDO is set 260 261DMA Transfer Should Write To UART 262 Execute Command $bin = @https://dl.antmicro.com/projects/renode/b_l072z_lrwan1--zephyr-custom_dma_hello_world.elf-s_591108-c4351f75c230563f429aadffb53f294fa7738406 263 Execute Command include @scripts/single-node/stm32l072.resc 264 265 Create Terminal Tester sysbus.usart2 266 267 Start Emulation 268 269 Wait For Line On Uart Hello world from DMA! 270 271DMA Transfer Should Write To And Read From UART 272 Execute Command $bin = @https://dl.antmicro.com/projects/renode/stm32l073--cubemx-USART_Communication_TxRx_DMA.elf-s_179016-cae1f7f14ab8ddb7db17cc1e8a8ee2826bc0da81 273 Execute Command include @scripts/single-node/stm32l072.resc 274 Execute Command machine LoadPlatformDescriptionFromString "gpioPortA: { 5 -> led@0 }; led: Miscellaneous.LED @ gpioPortA 5" 275 Execute Command machine LoadPlatformDescriptionFromString "button: Miscellaneous.Button @ gpioPortC 13 { invert: true; -> gpioPortC@13 }" 276 Execute Command machine LoadPlatformDescriptionFromString "usart2: { ReceiveDmaRequest -> dma1@6 }" 277 278 Create Terminal Tester sysbus.usart2 279 Create LED Tester sysbus.gpioPortA.led defaultTimeout=2 280 281 Assert LED State true pauseEmulation=true 282 283 Execute Command gpioPortC.button Press 284 Assert LED State false pauseEmulation=true 285 Wait For Line On Uart STM32L0xx USART LL API Example : TX/RX in DMA mode pauseEmulation=true 286 Wait For Line On Uart Configuration UART 115200 bps, 8 data bit/1 stop bit/No parity/No HW flow control pauseEmulation=true 287 Wait For Line On Uart Please enter 'END' string ... pauseEmulation=true 288 289 Write Line To Uart END waitForEcho=false 290 Assert And Hold LED State true timeoutAssert=0.1 timeoutHold=2 291