1*** Variables ***
2${SHELL_PROMPT}                $
3
4*** Keywords ***
5Create Platform
6    Execute Command            using sysbus
7    Execute Command            mach create
8    # This line must use the "path" notation to handle paths with spaces
9    Execute Command            machine LoadPlatformDescription "${CURDIR}${/}litex_linux_vexriscv.repl"
10
11    Execute Command            set kernel @https://dl.antmicro.com/projects/renode/litex_linux_vexriscv--kernel.bin-s_4578292-f63a4736100b5ff79a8d72429c1b79718ec7a446
12    Execute Command            set rootfs @https://dl.antmicro.com/projects/renode/litex_linux_vexriscv--rootfs.cpio-s_4163584-c44ad487ba1f73c00430a1bb108ceef84007274f
13    Execute Command            set device_tree @https://dl.antmicro.com/projects/renode/litex_linux_vexriscv--rv32.dtb-s_2609-9a915b47b8e31d0d3f268c4a297dc0b0555e8cd0
14    Execute Command            set emulator @https://dl.antmicro.com/projects/renode/litex_vexriscv--emulator.bin-s_9028-796a4227b806997c6629462fdf0dcae73de06929
15
16    Execute Command            sysbus LoadBinary $emulator 0x20000000
17    Execute Command            sysbus LoadBinary $kernel 0xc0000000
18    Execute Command            sysbus LoadBinary $rootfs 0xc0800000
19    Execute Command            sysbus LoadBinary $device_tree 0xc1000000
20
21    Execute Command            cpu PC 0x20000000
22
23*** Test Cases ***
24Should Boot
25    Create Platform
26    Create Terminal Tester     sysbus.uart
27    Execute Command            showAnalyzer sysbus.uart
28
29    Start Emulation
30
31    Wait For Prompt On Uart    buildroot login:
32    Write Line To Uart         root
33
34    Wait For Line On Uart      root login on 'console'
35
36    Write Line To Uart         export PS1="$ "
37
38    Provides                   booted-image
39
40Should Control LED
41    Requires                   booted-image
42
43    Create LED Tester          sysbus.gpio_out.led
44    Assert LED State           false
45
46    Write Line To Uart         cd /sys/class/gpio
47    Wait For Prompt On Uart    ${SHELL_PROMPT}
48    Write Line To Uart         echo 508 > export
49    Wait For Prompt On Uart    ${SHELL_PROMPT}
50    Write Line To Uart         cd gpio508
51    Wait For Prompt On Uart    ${SHELL_PROMPT}
52
53    Assert LED State           false
54    Write Line To Uart         echo 1 > value
55    Wait For Prompt On Uart    ${SHELL_PROMPT}
56    Assert LED State           true
57
58    Write Line To Uart         echo 0 > value
59    Wait For Prompt On Uart    ${SHELL_PROMPT}
60    Assert LED State           false
61
62Should Read Button
63    Requires                   booted-image
64
65    Write Line To Uart         cd /sys/class/gpio
66    Wait For Prompt On Uart    ${SHELL_PROMPT}
67    Write Line To Uart         echo 504 > export
68    Wait For Prompt On Uart    ${SHELL_PROMPT}
69    Write Line To Uart         cd gpio504
70    Wait For Prompt On Uart    ${SHELL_PROMPT}
71
72    Write Line To Uart         cat value
73    Wait For Line On Uart      0
74    Wait For Prompt On Uart    ${SHELL_PROMPT}
75
76    Execute Command            gpio_in.button Toggle
77    Write Line To Uart         cat value
78    Wait For Line On Uart      1
79    Wait For Prompt On Uart    ${SHELL_PROMPT}
80
81    Execute Command            gpio_in.button Toggle
82    Write Line To Uart         cat value
83    Wait For Line On Uart      0
84    Wait For Prompt On Uart    ${SHELL_PROMPT}
85
86Should Handle SPI
87    Requires                   booted-image
88
89    Write Line To Uart         spidev_test -D /dev/spidev0.0 --speed 1000000
90    Wait For Line On Uart      spi mode: 0x0
91    Wait For Line On Uart      bits per word: 8
92    Wait For Line On Uart      max speed: 1000000 Hz (1000 KHz)
93    Wait For Line On Uart      RX | FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF F0 0D
94
95Should Handle I2C
96    Requires                   booted-image
97
98    Write Line To Uart         i2cdetect -y 0
99
100    Wait For Line On Uart      00:${SPACE*10}-- -- UU -- -- -- -- -- -- -- -- -- --
101    Wait For Line On Uart      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
102    Wait For Line On Uart      20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
103    Wait For Line On Uart      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
104    Wait For Line On Uart      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
105    Wait For Line On Uart      50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
106    Wait For Line On Uart      60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
107    Wait For Line On Uart      70: -- -- -- -- -- -- -- --
108
109    Write Line To Uart         cd /sys/class/i2c-dev/i2c-0/device/0-0005/iio:device0
110
111    Write Line To Uart         cat in_temp_raw
112    Wait For Line On Uart      4368
113    Wait For Prompt On Uart    ${SHELL_PROMPT}
114
115    Execute Command            i2c.si7021 Temperature 36
116    Write Line To Uart         cat in_temp_raw
117    Wait For Line On Uart      7724
118    Wait For Prompt On Uart    ${SHELL_PROMPT}
119
120