2022-02-08 11:45:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
tcpPort=1234
|
|
|
|
imageDir=$RISCV/buildroot/output/images
|
|
|
|
outDir=$RISCV/linux-testvectors
|
|
|
|
recordFile="$outDir/all.qemu"
|
|
|
|
traceFile="$outDir/all.txt"
|
2022-02-09 02:29:47 +00:00
|
|
|
interruptsFile="$outDir/interrupts.txt"
|
2022-02-08 11:45:42 +00:00
|
|
|
|
|
|
|
read -p "Warning: running this script will overwrite the contents of:
|
|
|
|
* $recordFile
|
|
|
|
* $traceFile
|
2022-02-09 02:29:47 +00:00
|
|
|
* $interruptsFile
|
2022-02-08 11:45:42 +00:00
|
|
|
Would you like to proceed? (y/n) " -n 1 -r
|
|
|
|
echo
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
|
|
then
|
|
|
|
# Create Output Directory
|
|
|
|
sudo mkdir -p $outDir
|
|
|
|
sudo chown cad $outDir
|
|
|
|
sudo touch $recordFile
|
|
|
|
sudo touch $traceFile
|
2022-02-09 02:29:47 +00:00
|
|
|
sudo touch $interruptsFile
|
2022-02-08 11:45:42 +00:00
|
|
|
sudo chmod a+rw $recordFile
|
|
|
|
sudo chmod a+rw $traceFile
|
2022-02-09 02:29:47 +00:00
|
|
|
sudo chmod a+rw $interruptsFile
|
2022-02-08 11:45:42 +00:00
|
|
|
|
|
|
|
# Compile Devicetree from Source
|
2022-02-10 00:07:29 +00:00
|
|
|
dtc -I dts -O dtb ../devicetree/wally-virt.dts > ../devicetree/wally-virt.dtb
|
2022-02-08 11:45:42 +00:00
|
|
|
|
|
|
|
# QEMU Simulation
|
|
|
|
(qemu-system-riscv64 \
|
2022-02-10 00:07:29 +00:00
|
|
|
-M virt -dtb ../devicetree/wally-virt.dtb \
|
2022-02-08 11:45:42 +00:00
|
|
|
-nographic -serial /dev/null \
|
|
|
|
-bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio \
|
|
|
|
-singlestep -rtc clock=vm -icount shift=0,align=off,sleep=on,rr=record,rrfile=$recordFile \
|
2022-02-09 02:29:47 +00:00
|
|
|
-d nochain,cpu,in_asm,int \
|
2022-02-08 11:45:42 +00:00
|
|
|
-gdb tcp::$tcpPort -S \
|
2022-02-09 02:29:47 +00:00
|
|
|
2>&1 >/dev/null | ./parseQemuToGDB.py | ./parseGDBtoTrace.py $interruptsFile | ./remove_dup.awk > $traceFile) \
|
2022-02-08 11:45:42 +00:00
|
|
|
& riscv64-unknown-elf-gdb -quiet -x genTrace.gdb -ex "genTrace $tcpPort \"$imageDir/vmlinux\""
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
sudo chown cad $recordFile
|
|
|
|
sudo chown cad $traceFile
|
2022-02-09 02:29:47 +00:00
|
|
|
sudo chown cad $interruptsFile
|
2022-02-08 11:45:42 +00:00
|
|
|
sudo chmod o-w $recordFile
|
|
|
|
sudo chmod o-w $traceFile
|
2022-02-09 02:29:47 +00:00
|
|
|
sudo chmod o-w $interruptsFile
|
2022-02-08 11:45:42 +00:00
|
|
|
fi
|
|
|
|
|