1*** Variables *** 2${SCRIPT} ${CURDIR}/../../scripts/single-node/hifive_unleashed.resc 3${UART} sysbus.uart0 4 5*** Keywords *** 6Prepare Machine 7 # we use special FDT that contains spi sensors 8 Execute Command \$fdt?=@https://dl.antmicro.com/projects/renode/hifive-unleashed--devicetree-tests.dtb-s_8718-ba79c50f59ec31c6317ba31d1eeebee2b4fb3d89 9 Execute Script ${SCRIPT} 10 11 # attach SPI sensor 12 Execute Command machine LoadPlatformDescriptionFromString "lm74_1: Sensors.TI_LM74 @ qspi1 0x0" 13 Execute Command machine LoadPlatformDescriptionFromString "lm74_2: Sensors.TI_LM74 @ qspi1 0x1" 14 15 # attach I2C sensors 16 Execute Command machine LoadPlatformDescriptionFromString "si7021: Sensors.SI70xx @ i2c 0x40 { model: Model.SI7021 }" 17 18 # create gpio analyzer and connect pwm0 to it 19 Execute Command machine LoadPlatformDescriptionFromString "pt: PWMTester @ pwm0 2" 20 Execute Command machine LoadPlatformDescriptionFromString "pwm0: { 2 -> pt@0 }" 21 22*** Test Cases *** 23Should Boot Linux 24 [Documentation] Boots Linux on SiFive Freedom U540 platform. 25 [Tags] linux uart interrupts 26 Prepare Machine 27 28 Create Terminal Tester ${UART} 29 Start Emulation 30 31 Wait For Prompt On Uart buildroot login 32 Write Line To Uart root 33 Wait For Prompt On Uart Password 34 Write Line To Uart root waitForEcho=false 35 Wait For Prompt On Uart \# 36 37 # This platform must use an old approach as it fails to deserialize on Windows and macOS 38 Provides booted-linux Reexecution 39 40Should Ls 41 [Documentation] Tests shell responsiveness in Linux on SiFive Freedom U540 platform. 42 [Tags] linux uart interrupts 43 Requires booted-linux 44 45 Write Line To Uart ls / 46 Wait For Line On Uart proc 47 48Should Read Temperature From SPI sensors 49 [Documentation] Reads temperature from SPI sensor in Linux on SiFive Freedom U540 platform. 50 [Tags] linux uart spi sensors 51 Requires booted-linux 52 53 Execute Command qspi1.lm74_1 Temperature 36.5 54 Execute Command qspi1.lm74_2 Temperature 73 55 56 Write Line To Uart cd /sys/class/spi_master/spi0/spi0.0/hwmon/hwmon0 57 Write Line To Uart cat temp1_input 58 Wait For Line On Uart 36500 59 60 Write Line To Uart cd /sys/class/spi_master/spi0/spi0.1/hwmon/hwmon1 61 Write Line To Uart cat temp1_input 62 Wait For Line On Uart 73000 63 64Should Detect I2C sensor 65 [Documentation] Tests I2C controller in Linux on SiFive Freedom U540 platform. 66 [Tags] linux uart i2c 67 Requires booted-linux 68 69 Write Line To Uart i2cdetect 0 70 Wait For Prompt On Uart Continue? [y/N] 71 Write Line To Uart y 72 73 Wait For Line On Uart 40: 40 -- 74 75Should Read Temperature From I2C sensor 76 [Documentation] Reads temperature from I2C sensor in Linux on SiFive Freedom U540 platform. 77 [Tags] linux uart i2c sensors 78 Requires booted-linux 79 80 Execute Command i2c.si7021 Temperature 36.6 81 82 Write Line To Uart echo "si7020 0x40" > /sys/class/i2c-dev/i2c-0/device/new_device 83 Wait For Line On Uart Instantiated device si7020 at 0x40 84 85 Write Line To Uart cd /sys/class/i2c-dev/i2c-0/device/0-0040/iio:device0 86 # here we read a RAW value from the device 87 # warning: the driver uses different equation to calculate the actual value than the documentation says, so it will differ from what we set in the peripheral 88 Write Line To Uart cat in_temp_raw 89 Wait For Line On Uart 7780 90 91# there is some bug in PWM implementation or the PWM tester and this tests fails non-deterministically 92Should Generate Proper PWM Pulses 93 [Tags] non_critical 94 Requires booted-linux 95 96 Write Line To Uart echo 5 > /sys/class/leds/netdev/brightness 97 Execute Command pwm0.pt Reset 98 Sleep 3 99 ${hp}= Execute Command pwm0.pt HighPercentage 100 ${hpn}= Convert To Number ${hp} 101 Should Be True ${hpn} < 10 102 Should Be True ${hpn} > 0 103 104 Write Line To Uart echo 127 > /sys/class/leds/netdev/brightness 105 Execute Command pwm0.pt Reset 106 Sleep 3 107 ${hp}= Execute Command pwm0.pt HighPercentage 108 ${hpn}= Convert To Number ${hp} 109 Should Be True ${hpn} < 55 110 Should Be True ${hpn} > 45 111 112 Write Line To Uart echo 250 > /sys/class/leds/netdev/brightness 113 Execute Command pwm0.pt Reset 114 Sleep 3 115 ${hp}= Execute Command pwm0.pt HighPercentage 116 ${hpn}= Convert To Number ${hp} 117 Should Be True ${hpn} < 100 118 Should Be True ${hpn} > 90 119 120Should Ping Linux 121 Execute Command emulation CreateSwitch "switch" 122 123 Execute Command $name="unleashed-1" 124 Prepare Machine 125 Execute Command connector Connect ethernet switch 126 ${u1}= Create Terminal Tester ${UART} machine=unleashed-1 127 128 Execute Command mach clear 129 Execute Command $name="unleashed-2" 130 Prepare Machine 131 Execute Command connector Connect ethernet switch 132 ${u2}= Create Terminal Tester ${UART} machine=unleashed-2 133 Execute Command mach clear 134 135 Start Emulation 136 137 Wait For Prompt On Uart buildroot login testerId=${u1} 138 Write Line To Uart root testerId=${u1} 139 Wait For Prompt On Uart Password testerId=${u1} 140 Write Line To Uart root waitForEcho=false testerId=${u1} 141 Wait For Prompt On Uart \# testerId=${u1} 142 143 Wait For Prompt On Uart buildroot login testerId=${u2} 144 Write Line To Uart root testerId=${u2} 145 Wait For Prompt On Uart Password testerId=${u2} 146 Write Line To Uart root waitForEcho=false testerId=${u2} 147 Wait For Prompt On Uart \# testerId=${u2} 148 149 Write Line To Uart ifconfig eth0 hw ether 02:01:03:05:04:06 testerId=${u1} 150 Write Line To Uart ifconfig eth0 192.168.0.1 netmask 255.255.255.0 testerId=${u1} 151 Write Line To Uart ifconfig eth0 192.168.0.2 netmask 255.255.255.0 testerId=${u2} 152 153 Write Line To Uart ping 192.168.0.1 testerId=${u2} 154 Wait For Line On Uart 64 bytes from 192.168.0.1 testerId=${u2} 155 156