1*** Variables ***
2${SHELL_PROMPT}                $
3
4*** Keywords ***
5Create Platform
6    [Arguments]                ${device_tree}        ${sdcard_image}
7    Execute Command            using sysbus
8    Execute Command            mach create
9    Execute Command            machine LoadPlatformDescription @platforms/cpus/litex_linux_vexriscv_sdcard.repl
10
11    Execute Command            set device_tree @https://dl.antmicro.com/projects/renode/${device_tree}
12
13    Execute Command            set kernel @https://dl.antmicro.com/projects/renode/litex_vexriscv-sdcard--kernel.bin-s_6934900-7a7291fdb880ad8e2aa75276807f8adf5fb8303a
14    Execute Command            set emulator @https://dl.antmicro.com/projects/renode/litex_vexriscv-sdcard--opensbi.bin-s_45360-71c1954133f6589f34fcb00554be44195e23e9d5
15
16    Execute Command            sysbus LoadBinary $kernel 0x40000000
17    Execute Command            sysbus LoadBinary $device_tree 0x40ef0000
18    Execute Command            sysbus LoadBinary $emulator 0x40f00000
19
20    Execute Command            cpu PC 0x40f00000
21
22    Execute Command            machine SdCardFromFile @https://dl.antmicro.com/projects/renode/${sdcard_image} mmc_controller 0x4000000 False
23
24Load Rootfs To Ram
25    Execute Command            set rootfs @https://dl.antmicro.com/projects/renode/litex_vexriscv-sdcard--rootfs.cpio-s_4064768-3107c4884136bce0fccb40193416da6b179fd8cd
26    Execute Command            sysbus LoadBinary $rootfs 0x40800000
27
28*** Test Cases ***
29Should Mount Filesystem From SD Card
30    Create Platform            litex_vexriscv-sdcard--rv32.dtb-s_3323-fdafbb56af0ba66f1b6eb0f6c847238cb77f4095
31    ...                        fat16_sdcard.image-s_64000000-8a919aa2199e1a1cf086e67546b539295d2d9d8f
32    Load Rootfs To Ram
33
34    Create Terminal Tester     sysbus.uart
35    Execute Command            showAnalyzer sysbus.uart
36
37    Start Emulation
38
39    Wait For Line On Uart      mmc0: new SD card at address 0000
40    Wait For Line On Uart      blk_queue_max_hw_sectors: set to minimum 8
41    Wait For Line On Uart      blk_queue_max_segment_size: set to minimum 4096
42    Wait For Line On Uart      mmcblk0: mmc0:0000 RENOD 64.0 MiB
43    Wait For Line On Uart      mmcblk0: p1
44
45    Wait For Prompt On Uart    buildroot login:
46    Write Line To Uart         root
47
48    Wait For Line On Uart      32-bit VexRiscv CPU with MMU integrated in a LiteX SoC
49
50    Write Line To Uart         export PS1="$ "
51
52    Wait For Prompt On Uart    ${SHELL_PROMPT}
53    Write Line To Uart         mount /dev/mmcblk0p1 /mnt
54
55    Wait For Prompt On Uart    ${SHELL_PROMPT}
56    Write Line To Uart         ls /mnt
57    Wait For Line On Uart      readme.txt
58
59    Wait For Prompt On Uart    ${SHELL_PROMPT}
60    Write Line To Uart         cat /mnt/readme.txt
61    Wait For Line On Uart      This is a test file
62
63    Wait For Prompt On Uart    ${SHELL_PROMPT}
64    Write Line To Uart         echo "This is a write test" > /mnt/readme2.txt
65
66    Wait For Prompt On Uart    ${SHELL_PROMPT}
67    Write Line To Uart         ls /mnt
68    Wait For Line On Uart      readme2.txt
69
70    Wait For Prompt On Uart    ${SHELL_PROMPT}
71    Write Line To Uart         sync
72
73    Wait For Prompt On Uart    ${SHELL_PROMPT}
74    Write Line To Uart         umount /mnt
75
76    Wait For Prompt On Uart    ${SHELL_PROMPT}
77    Write Line To Uart         mount /dev/mmcblk0p1 /mnt
78
79    Wait For Prompt On Uart    ${SHELL_PROMPT}
80    Write Line To Uart         ls /mnt
81    Wait For Line On Uart      readme2.txt
82
83    Wait For Prompt On Uart    ${SHELL_PROMPT}
84    Write Line To Uart         cat /mnt/readme2.txt
85    Wait For Line On Uart      This is a write test
86
87Should Load RootFS From SD Card
88    Create Platform            litex_vexriscv-sdcard--rootfs_from_sdcard-rv32.dtb-s_3255-8305d2b80955418e53f5400c492dc74dccf05ac8
89    ...                        riscv32-buildroot--busybox-rootfs.ext4.image-s_67108864-cd5badff81b32092c010d683c471821d4ea99af6
90
91    Create Terminal Tester     sysbus.uart
92    Execute Command            showAnalyzer sysbus.uart
93
94    Start Emulation
95
96    Wait For Line On Uart      mmc0: new SD card at address 0000
97    Wait For Line On Uart      blk_queue_max_hw_sectors: set to minimum 8
98    Wait For Line On Uart      blk_queue_max_segment_size: set to minimum 4096
99    Wait For Line On Uart      mmcblk0: mmc0:0000 RENOD
100
101    Wait For Line On Uart      VFS: Mounted root (ext4 filesystem) readonly
102    Wait For Line On Uart      Run /sbin/init as init process
103
104    Wait For Prompt On Uart    buildroot login:
105    Write Line To Uart         root
106
107    Wait For Prompt On Uart    root@buildroot
108
109    Write Line To Uart         export PS1="$ "
110
111    Wait For Prompt On Uart    ${SHELL_PROMPT}
112    Write Line To Uart         ls -la /
113    Wait For Line On Uart      linuxrc -> bin/busybox
114
115