1*** Settings *** 2Library String 3 4*** Variables *** 5${URL} https://dl.antmicro.com/projects/renode 6${GPT_ELF} ${URL}/renesas-rzg2l_evk--fsp-gpt_rzg2l_evk_ep.elf-s_450148-fec1da811a52fa94d39db555d0dccc28e246d28e 7${GTM_ELF} ${URL}/renesas-rzg2l_evk--fsp-gtm_rzg2l_evk_ep.elf-s_415532-a907c69248cf6f695c717ee7dd83cc29d6fff3b4 8${SCIF_UART_ELF} ${URL}/renesas-rzg2l_evk--fsp-scif_uart_rzg2l_evk_ep.elf-s_494948-c7ab4fdc0f2f8e62b8d99f194aab234ab1a50a32 9${RSPI_ELF} ${URL}/renesas-rzg2l_evk--fsp-rspi_rzg2l_evk_ep.elf-s_431540-f07dc0ce78537eda672af3a028c50dcb3f21f3a5 10${FREERTOS_BLINKY_ELF} ${URL}/renesas-rz_g2l--fsp-blinky_freertos.elf-s_612428-2a79e42c3efdbc19207a7c1b2b3b3824e450b2ef 11${IIC_MASTER_ELF} ${URL}/renesas-rzg2l_evk--fsp-riic_master_rzg2l_evk_ep.elf-s_522620-d57490521dd2e4dfcd4ca4a6cade57ce58228375 12${UBOOT_ELF} ${URL}/uboot.elf-s_4151104-c5de311d27f0823c3d888309795fdc0a5b31473b 13${MHU_ELF} ${URL}/renesas-rz_g2l--fsp-mhu_sample.elf-s_381944-3550734db5aa723c25c77142de4b7ebdeca0f1ba 14${INTC_IRQ_ELF} ${URL}/renesas-rzg2l_evk--fsp-intc_irq_rzg2l_evk_ep.elf-s_413044-05d74d1def85e983f80165ae13f125cf302507d0 15${LED_REPL} SEPARATOR=\n 16... """ 17... led: Miscellaneous.LED @ gpio 0 18... 19... gpio: 20... ${SPACE*4}100 -> led@0 21... """ 22${BUTTON_REPL} SEPARATOR=\n 23... """ 24... button: Miscellaneous.Button @ gpio 1 25... ${SPACE*4}-> gpio@7 26... """ 27 28*** Keywords *** 29Prepare Machine 30 [Arguments] ${elf} 31 Execute Command mach create "Renesas RZ/G2L" 32 Execute Command machine LoadPlatformDescription @platforms/cpus/renesas_rz_g2l.repl 33 Execute Command macro reset "cpu0 IsHalted true; cpu1 IsHalted true; sysbus LoadELF @${elf} cpu=cpu_m33" 34 Execute Command runMacro $reset 35 36Prepare Segger RTT 37 [Arguments] ${pauseEmulation}=true 38 Execute Command machine CreateVirtualConsole "segger_rtt" 39 Execute Command include @scripts/single-node/segger-rtt.py 40 Execute Command setup_segger_rtt sysbus.segger_rtt 41 Create Terminal Tester sysbus.segger_rtt defaultPauseEmulation=${pauseEmulation} 42 43Elapsed Time Equals 44 [Arguments] ${start} ${end} ${value} ${margin}=0.8 45 ${diff}= Evaluate ${end} - ${start} 46 Should Be True ${diff} >= ${value} - ${margin} 47 Should Be True ${diff} <= ${value} + ${margin} 48 49Prepare LED Tester 50 Execute Command machine LoadPlatformDescriptionFromString ${LED_REPL} 51 Create Led Tester sysbus.gpio.led 52 53*** Test Cases *** 54Should Run The Timer In One Shot Mode 55 Prepare Machine ${GPT_ELF} 56 Prepare Segger RTT 57 58 Wait For Prompt On Uart User Input: 59 Write Line To Uart 3 waitForEcho=false 60 61 Wait For Line On Uart Opened Timer in ONE-SHOT Mode 62 Wait For Line On Uart Started Timer in ONE-SHOT Mode 63 Wait For Line On Uart Timer Expired in One-Shot Mode 64 65Should Run GTM Sample 66 Prepare Machine ${GTM_ELF} 67 Prepare Segger RTT 68 Prepare LED Tester 69 70 Wait For Prompt On Uart One-shot mode: 71 Write Line To Uart 10 waitForEcho=false 72 Wait For Prompt On Uart Periodic mode: 73 Write Line To Uart 5 waitForEcho=false 74 75 Wait For Prompt On Uart Enter any key to start or stop the timers 76 ${one_shot_start}= Write Line To Uart waitForEcho=false 77 ${one_shot_end}= Wait For Line On Uart One-shot mode GTM timer elapsed 78 Elapsed Time Equals ${one_shot_start.timestamp} ${one_shot_end.timestamp} 10 79 80 Wait For Line On Uart GTM1 is Enabled in Periodic mode 81 FOR ${i} IN RANGE 0 3 82 ${periodic_start}= Wait For Line On Uart Leds are: Off 83 Assert Led State False timeout=0.01 84 85 ${periodic_end}= Wait For Line On Uart Leds are: On 86 Assert Led State True timeout=0.01 87 Elapsed Time Equals ${periodic_start.timestamp} ${periodic_end.timestamp} 5 0.3 88 END 89 90Should Run SCIF UART Sample 91 Prepare Machine ${SCIF_UART_ELF} 92 Create Terminal Tester sysbus.scif2 93 Execute Command showAnalyzer sysbus.scif2 94 95 # Let software initialize SCIF before we write to it 96 Execute Command emulation RunFor "0.01s" 97 Start Emulation 98 99 Write Line To Uart 10 waitForEcho=false 100 Wait For Line On Uart Accepted value, the led is blinking with that value 101 Wait For Line On Uart Please set the next value 102 103 Write Line To Uart -1 waitForEcho=false 104 Wait For Line On Uart Invalid input. Input range is from 1 - 2000 105 106 Write Line To Uart 2001 waitForEcho=false 107 Wait For Line On Uart Invalid input. Input range is from 1 - 2000 108 109Should Run SPI WriteRead Sample 110 Prepare Machine ${RSPI_ELF} 111 Execute Command spi0 Register spi1 0 112 Prepare Segger RTT 113 114 Wait For Line On Uart ** RSPI INIT SUCCESSFUL ** 115 Wait For Line On Uart Press 1 for Write() and Read() 116 Wait For Line On Uart Press 2 for WriteRead() 117 Wait For Line On Uart Press 3 to Exit 118 Write Line To Uart 2 119 120 Wait For Line On Uart Enter text input for Master buffer. Data size should not exceed 64 bytes. 121 Write Line To Uart 0123456789 122 123 Wait For Line On Uart Enter text input for Slave buffer. Data size should not exceed 64 bytes. 124 Write Line To Uart abcdefghij 125 126 Wait For Line On Uart Master received data: abcdefghij 127 Wait For Line On Uart Slave received data: 0123456789 128 Wait For Line On Uart ** RSPI WRITE_READ Demo Successful** 129 130Should Run FreeRTOS Blinky Sample 131 Prepare Machine ${FREERTOS_BLINKY_ELF} 132 Prepare LED Tester 133 134 Assert LED Is Blinking testDuration=5 onDuration=1 offDuration=1 pauseEmulation=true 135 136Should Communicate Over IIC 137 Prepare Machine ${IIC_MASTER_ELF} 138 Execute Command machine LoadPlatformDescriptionFromString "adxl345: Sensors.ADXL345 @ riic3 0x1D" 139 Prepare Segger RTT 140 141 # Sample displays raw data from the sensor, so printed values are different from loaded samples 142 Execute Command riic3.adxl345 FeedSample 1000 1000 1000 143 Wait For Line On Uart X-axis = 250.00, Y-axis = 250.00, Z-axis = 250.00 144 145 Execute Command riic3.adxl345 FeedSample 2000 3000 4000 146 Wait For Line On Uart X-axis = 500.00, Y-axis = 750.00, Z-axis = 1000.00 147 148 Execute Command riic3.adxl345 FeedSample 1468 745 8921 149 Wait For Line On Uart X-axis = 367.00, Y-axis = 186.00, Z-axis = 2230.00 150 151 Execute Command riic3.adxl345 FeedSample 3912 8888 5456 152 Wait For Line On Uart X-axis = 978.00, Y-axis = 2222.00, Z-axis = 1364.00 153 154 Execute Command riic3.adxl345 FeedSample 0 5000 0 155 Wait For Line On Uart X-axis = 0.00, Y-axis = 1250.00, Z-axis = 0.00 156 157 Wait For Line On Uart X-axis = 0.00, Y-axis = 0.00, Z-axis = 0.00 158 159Should Copy Memory With DMA 160 ${source}= Set Variable 0x60000100 161 ${destination}= Set Variable 0x60000200 162 ${expected_value}= Set Variable 0xAABBCCDD 163 ${channel_base}= Set Variable 0x41800000 164 ${channel_status}= Evaluate ${channel_base} + 0x24 165 ${prog}= Catenate SEPARATOR=\n 166 ... str r1, [r0, #0xC] # N1SA register offset 167 ... str r2, [r0, #0x10] # N1DA register offset 168 ... str r3, [r0, #0x14] # N1TB register offset 169 ... str r4, [r0, #0x2C] # CHCFG register offset 170 ... str r5, [r0, #0x28] # CHCTRL register offset 171 ... str r6, [r0, #0x28] # CHCTRL register offset 172 173 Execute Command mach create "Renesas RZ/G2L" 174 Execute Command machine LoadPlatformDescription @platforms/cpus/renesas_rz_g2l.repl 175 Execute Command cluster IsHalted true 176 177 Execute Command sysbus WriteDoubleWord ${source} ${expected_value} cpu_m33 178 Execute Command cpu_m33 SetRegister 0 ${channel_base} # DMA Channel address 179 Execute Command cpu_m33 SetRegister 1 ${source} # Source address 180 Execute Command cpu_m33 SetRegister 2 ${destination} # Destination address 181 Execute Command cpu_m33 SetRegister 3 0x4 # Transfer 4 bytes 182 Execute Command cpu_m33 SetRegister 4 0x10403000 # Read access: double word, full transfer, select register bank 1 183 Execute Command cpu_m33 SetRegister 5 0x8 # Reset DMA 184 Execute Command cpu_m33 SetRegister 6 0x5 # Perform transaction 185 186 Execute Command cpu_m33 AssembleBlock 0x60000000 "${prog}" 187 Execute Command cpu_m33 PC 0x60000000 188 Execute Command cpu_m33 Step 6 189 ${flags}= Execute Command sysbus ReadDoubleWord ${channel_status} cpu_m33 190 Should Be Equal As Integers ${flags} 0xE0 # Terminal count, DMA interrupt and register select are set 191 ${result}= Execute Command sysbus ReadDoubleWord ${destination} cpu_m33 192 Should Be Equal As Integers ${expected_value} ${result} 193 194Should Run U-Boot 195 Execute Command set bin @${UBOOT_ELF} 196 Execute Command include @scripts/single-node/rzg2l_uboot.resc 197 Create Terminal Tester sysbus.scif0 5 defaultPauseEmulation=true 198 199 Wait For Prompt On Uart Hit any key to stop autoboot 200 Send Key To Uart 0x10 201 202 Wait For Prompt On Uart > 203 Write Line To Uart version 204 205 Wait For Line On Uart U-Boot 206 Wait For Prompt On Uart > 207 208Should Communicate Between Cores Using MHU 209 Prepare Machine ${MHU_ELF} 210 Prepare Segger RTT 211 212 ${mhu_channel}= Set Variable 1 213 ${expected_data}= Set Variable 0xAABBCCDD 214 ${shared_mem_base}= Execute Command sysbus GetSymbolAddress "__mhu_shmem_start" cpu_m33 215 ${shared_mem_base}= Strip String ${shared_mem_base} 216 ${receive_data}= Evaluate ${shared_mem_base} + ${mhu_channel} * 0x8 + 0x4 # Each channel has 8 bytes available 4 for transmission and 4 for reception 217 ${irq_trigger_register}= Evaluate 0x010400000 + ${mhu_channel} * 0x20 + 0x4 # MSG_INT_SETn register visible from Cortex-A55 218 219 Wait For Line On Uart MHU initialized correctly 220 Execute Command sysbus WriteDoubleWord ${receive_data} ${expected_data} cpu_m33 221 Execute Command sysbus WriteDoubleWord ${irq_trigger_register} 0x1 cpu0 # Trigger MHU interrupt 222 Wait For Line On Uart MHU message received! (Channel: ${mhu_channel}, Data: ${expected_data}) 223 224Should Detect External Interrupt 225 Prepare Machine ${INTC_IRQ_ELF} 226 Execute Command machine LoadPlatformDescriptionFromString ${BUTTON_REPL} 227 Prepare LED Tester 228 Prepare Segger RTT 229 230 Wait For Line On Uart On pressing the user push button, an external IRQ is triggered, which toggles on-board LED. 231 232 Execute Command sysbus.gpio.button PressAndRelease 233 Wait For Line On Uart LED State: High{ON} 234 Assert Led State True timeout=0.01 235 236 Execute Command sysbus.gpio.button PressAndRelease 237 Wait For Line On Uart LED State: Low{OFF} 238 Assert Led State False timeout=0.01 239 240Should Boot Linux 241 Execute Command include @scripts/single-node/rzg2l_linux.resc 242 Create Terminal Tester sysbus.scif0 defaultPauseEmulation=true 243 244 # Boot with ATF 245 Wait For Line On Uart NOTICE:${SPACE*2}BL31: v2.9(release):v2.9 246 247 # Boot with U-Boot 248 Wait For Line On Uart U-Boot 2024.10 249 # Manually trigger boot to speed up test 250 Wait For Prompt On Uart Hit any key to stop autoboot:${SPACE*2}2 251 Write Line To Uart ${EMPTY} 252 Write Line To Uart boot 253 Wait For Line On Uart Starting kernel ... 254 255 # Boot Linux 256 Wait For Line On Uart Booting Linux on physical CPU 0x0000000000 [0x411fd050] 257 Wait For Prompt On Uart buildroot login: timeout=140 258 Write Line To Uart root 259 260 # Run command in userspace 261 Wait For Prompt On Uart \#${SPACE} 262 Write Line To Uart uname 263 Wait For Line On Uart Linux 264