Merge pull request #385 from JacobPease/main

Modified flash-sd to accept alternate device trees
This commit is contained in:
Ross Thompson 2023-08-22 16:24:27 -05:00 committed by GitHub
commit e3e1053dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 91 additions and 69 deletions

File diff suppressed because one or more lines are too long

View File

@ -6,20 +6,20 @@ dst := IP
#export board := vcu118 #export board := vcu118
# vcu108 # vcu108
#export XILINX_PART := xcvu095-ffva2104-2-e export XILINX_PART := xcvu095-ffva2104-2-e
#export XILINX_BOARD := xilinx.com:vcu108:part0:1.2 export XILINX_BOARD := xilinx.com:vcu108:part0:1.2
#export board := vcu108 export board := vcu108
# Arty A7 # Arty A7
export XILINX_PART := xc7a100tcsg324-1 # export XILINX_PART := xc7a100tcsg324-1
export XILINX_BOARD := digilentinc.com:arty-a7-100:part0:1.1 # export XILINX_BOARD := digilentinc.com:arty-a7-100:part0:1.1
export board := ArtyA7 # export board := ArtyA7
# for Arty A7 and S7 boards # for Arty A7 and S7 boards
all: FPGA_Arty # all: FPGA_Arty
# VCU 108 and VCU 118 boards # VCU 108 and VCU 118 boards
#all: FPGA_VCU all: FPGA_VCU
FPGA_Arty: PreProcessFiles IP_Arty FPGA_Arty: PreProcessFiles IP_Arty
vivado -mode tcl -source wally.tcl 2>&1 | tee wally.log vivado -mode tcl -source wally.tcl 2>&1 | tee wally.log

View File

@ -96,7 +96,7 @@ if {$board=="ArtyA7"} {
source ../constraints/small-debug.xdc source ../constraints/small-debug.xdc
} else { } else {
#source ../constraints/vcu-small-debug.xdc # source ../constraints/vcu-small-debug.xdc
source ../constraints/debug4.xdc source ../constraints/debug4.xdc
} }

View File

@ -95,41 +95,41 @@ module fpgaTop
// wire SDCCmdOE; // wire SDCCmdOE;
// wire SDCCmdOut; // wire SDCCmdOut;
wire [3:0] m_axi_awid; (* mark_debug = "true" *)wire [3:0] m_axi_awid;
wire [7:0] m_axi_awlen; (* mark_debug = "true" *)wire [7:0] m_axi_awlen;
wire [2:0] m_axi_awsize; (* mark_debug = "true" *)wire [2:0] m_axi_awsize;
wire [1:0] m_axi_awburst; (* mark_debug = "true" *)wire [1:0] m_axi_awburst;
wire [3:0] m_axi_awcache; (* mark_debug = "true" *)wire [3:0] m_axi_awcache;
wire [31:0] m_axi_awaddr; (* mark_debug = "true" *)wire [31:0] m_axi_awaddr;
wire [2:0] m_axi_awprot; (* mark_debug = "true" *)wire [2:0] m_axi_awprot;
wire m_axi_awvalid; (* mark_debug = "true" *)wire m_axi_awvalid;
wire m_axi_awready; (* mark_debug = "true" *)wire m_axi_awready;
wire m_axi_awlock; (* mark_debug = "true" *)wire m_axi_awlock;
wire [63:0] m_axi_wdata; (* mark_debug = "true" *)wire [63:0] m_axi_wdata;
wire [7:0] m_axi_wstrb; (* mark_debug = "true" *)wire [7:0] m_axi_wstrb;
wire m_axi_wlast; (* mark_debug = "true" *)wire m_axi_wlast;
wire m_axi_wvalid; (* mark_debug = "true" *)wire m_axi_wvalid;
wire m_axi_wready; (* mark_debug = "true" *)wire m_axi_wready;
wire [3:0] m_axi_bid; (* mark_debug = "true" *)wire [3:0] m_axi_bid;
wire [1:0] m_axi_bresp; (* mark_debug = "true" *)wire [1:0] m_axi_bresp;
wire m_axi_bvalid; (* mark_debug = "true" *)wire m_axi_bvalid;
wire m_axi_bready; (* mark_debug = "true" *)wire m_axi_bready;
wire [3:0] m_axi_arid; (* mark_debug = "true" *)wire [3:0] m_axi_arid;
wire [7:0] m_axi_arlen; (* mark_debug = "true" *)wire [7:0] m_axi_arlen;
wire [2:0] m_axi_arsize; (* mark_debug = "true" *)wire [2:0] m_axi_arsize;
wire [1:0] m_axi_arburst; (* mark_debug = "true" *)wire [1:0] m_axi_arburst;
wire [2:0] m_axi_arprot; (* mark_debug = "true" *)wire [2:0] m_axi_arprot;
wire [3:0] m_axi_arcache; (* mark_debug = "true" *)wire [3:0] m_axi_arcache;
wire m_axi_arvalid; (* mark_debug = "true" *)wire m_axi_arvalid;
wire [31:0] m_axi_araddr; (* mark_debug = "true" *)wire [31:0] m_axi_araddr;
wire m_axi_arlock; (* mark_debug = "true" *)wire m_axi_arlock;
wire m_axi_arready; (* mark_debug = "true" *)wire m_axi_arready;
wire [3:0] m_axi_rid; (* mark_debug = "true" *)wire [3:0] m_axi_rid;
wire [63:0] m_axi_rdata; (* mark_debug = "true" *)wire [63:0] m_axi_rdata;
wire [1:0] m_axi_rresp; (* mark_debug = "true" *)wire [1:0] m_axi_rresp;
wire m_axi_rvalid; (* mark_debug = "true" *)wire m_axi_rvalid;
wire m_axi_rlast; (* mark_debug = "true" *)wire m_axi_rlast;
wire m_axi_rready; (* mark_debug = "true" *)wire m_axi_rready;
// Extra Bus signals // Extra Bus signals
wire [3:0] BUS_axi_arregion; wire [3:0] BUS_axi_arregion;

View File

@ -1,4 +1,4 @@
BUILDROOT := ${RISCV}/buildroot BUILDROOT := ${RISCV}/buildroot2023
IMAGES := ${BUILDROOT}/output/images IMAGES := ${BUILDROOT}/output/images
DIS := ${IMAGES}/disassembly DIS := ${IMAGES}/disassembly

View File

@ -3,42 +3,47 @@
# Exit on any error (return code != 0) # Exit on any error (return code != 0)
# set -e # set -e
usage() { echo "Usage: $0 [-zh] [-b <path/to/buildroot>] <device>" 1>&2; exit 1; }
help() {
echo "Usage: $0 [OPTIONS] <device>"
echo " -z wipes card with zeros"
echo " -b <path/to/buildroot> get images from given buildroot"
echo " -d <device tree name> specify device tree to use"
exit 0;
}
# Output colors # Output colors
GREEN="\e[32m" GREEN="\e[32m"
RED="\e[31m" RED="\e[31m"
BOLDRED="\e[1;91m" BOLDRED="\e[1;91m"
BOLDGREEN="\e[1;32m" BOLDGREEN="\e[1;32m"
BOLDYELLOW="\e[1;33m"
NC="\e[0m" NC="\e[0m"
NAME="$BOLDGREEN"${0:2}:"$NC" NAME="$BOLDGREEN"${0:2}:"$NC"
ERRORTEXT="$BOLDRED"ERROR:"$NC" ERRORTEXT="$BOLDRED"ERROR:"$NC"
# File location variables # Default values for buildroot and device tree
RISCV=/opt/riscv RISCV=/opt/riscv
BUILDROOT=$RISCV/buildroot BUILDROOT=$RISCV/buildroot
IMAGES=$BUILDROOT/output/images DEVICE_TREE=wally-vcu108.dtb
FW_JUMP=$IMAGES/fw_jump.bin
LINUX_KERNEL=$IMAGES/Image
DEVICE_TREE=$IMAGES/wally-vcu108.dtb
# Mount Directory
MNT_DIR=wallyimg MNT_DIR=wallyimg
# Usage function
usage() { echo "Usage: $0 [-z] [-b <path/to/buildroot>] <device>" 1>&2; exit 1; }
# Process options and arguments. The following code grabs the single # Process options and arguments. The following code grabs the single
# sdcard device argument no matter where it is in the positional # sdcard device argument no matter where it is in the positional
# parameters list. # parameters list.
ARGS=() ARGS=()
while [ $OPTIND -le "$#" ] ; do while [ $OPTIND -le "$#" ] ; do
if getopts "hzb:" arg ; then if getopts "hzb:d:" arg ; then
case "${arg}" in case "${arg}" in
h) usage h) help
;; ;;
z) WIPECARD=y z) WIPECARD=y
;; ;;
b) BUILDROOT=${OPTARG} b) BUILDROOT=${OPTARG}
;; ;;
d) DEVICE_TREE=${OPTARG}
;;
esac esac
else else
ARGS+=("${!OPTIND}") ARGS+=("${!OPTIND}")
@ -46,14 +51,21 @@ while [ $OPTIND -le "$#" ] ; do
fi fi
done done
# File location variables
IMAGES=$BUILDROOT/output/images
FW_JUMP=$IMAGES/fw_jump.bin
LINUX_KERNEL=$IMAGES/Image
DEVICE_TREE=$IMAGES/$DEVICE_TREE
SDCARD=${ARGS[0]} SDCARD=${ARGS[0]}
# User Error Checks ===================================================
if [ "$#" -eq "0" ] ; then if [ "$#" -eq "0" ] ; then
usage usage
fi fi
# Check to make sure sd card device exists # Check to make sure sd card device exists
if [ ! -e "$SDCARD" ] ; then if [ ! -e "$SDCARD" ] ; then
echo -e "$NAME $ERRORTEXT SD card device does not exist." echo -e "$NAME $ERRORTEXT SD card device does not exist."
exit 1 exit 1
@ -76,10 +88,13 @@ fi
# Ensure device tree binaries exist # Ensure device tree binaries exist
if [ ! -e $DEVICE_TREE ] ; then if [ ! -e $DEVICE_TREE ] ; then
echo -e '$ERRORTEXT Missing device tree files' echo -e "$NAME $ERRORTEXT Missing device tree files"
echo -e "$NAME generating all device tree files into buildroot"
make -C ../ generate BUILDROOT=$BUILDROOT make -C ../ generate BUILDROOT=$BUILDROOT
fi fi
# Calculate partition information =====================================
# Size of OpenSBI and the Kernel in 512B blocks # Size of OpenSBI and the Kernel in 512B blocks
DST_SIZE=$(ls -la --block-size=512 $DEVICE_TREE | cut -d' ' -f 5 ) DST_SIZE=$(ls -la --block-size=512 $DEVICE_TREE | cut -d' ' -f 5 )
FW_JUMP_SIZE=$(ls -la --block-size=512 $FW_JUMP | cut -d' ' -f 5 ) FW_JUMP_SIZE=$(ls -la --block-size=512 $FW_JUMP | cut -d' ' -f 5 )

View File

@ -68,12 +68,19 @@ if [ ! -e $1 ] ; then
# --new=3:$FS_START:-0 --change-name=3:'filesystem' \ # --new=3:$FS_START:-0 --change-name=3:'filesystem' \
# $1 # $1
# echo -e "$NAME: Creating GUID Partition Table"
# sudo sgdisk -g --clear --set-alignment=1 \
# --new=1:34:+$DST_SIZE: --change-name=1:'fdt' \
# --new=2:$FW_JUMP_START:+$FW_JUMP_SIZE --change-name=2:'opensbi' --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985 \
# --new=3:$KERNEL_START:+$KERNEL_SIZE --change-name=3:'kernel' \
# --new=4:$FS_START:-0 --change-name=4:'filesystem' \
# $1
echo -e "$NAME: Creating GUID Partition Table" echo -e "$NAME: Creating GUID Partition Table"
sudo sgdisk -g --clear --set-alignment=1 \ sudo sgdisk -g --clear --set-alignment=1 \
--new=1:34:+$DST_SIZE: --change-name=1:'fdt' \ --new=1:34:+$DST_SIZE: --change-name=1:'fdt' \
--new=2:$FW_JUMP_START:+$FW_JUMP_SIZE --change-name=2:'opensbi' --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985 \ --new=2:$FW_JUMP_START:+$FW_JUMP_SIZE --change-name=2:'opensbi' --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985 \
--new=3:$KERNEL_START:+$KERNEL_SIZE --change-name=3:'kernel' \ --new=3:$KERNEL_START:+$KERNEL_SIZE --change-name=3:'kernel' \
--new=4:$FS_START:-0 --change-name=4:'filesystem' \
$1 $1
LOOPDEVICE=$(sudo losetup -f) LOOPDEVICE=$(sudo losetup -f)
@ -94,14 +101,14 @@ if [ ! -e $1 ] ; then
echo -e "$NAME: Copying Kernel" echo -e "$NAME: Copying Kernel"
sudo dd if=$LINUX_KERNEL of="$LOOPDEVICE"p3 $DD_FLAGS sudo dd if=$LINUX_KERNEL of="$LOOPDEVICE"p3 $DD_FLAGS
sudo mkfs.ext4 "$LOOPDEVICE"p4 # sudo mkfs.ext4 "$LOOPDEVICE"p4
sudo mkdir /mnt/$MNT_DIR # sudo mkdir /mnt/$MNT_DIR
sudo mount -v "$LOOPDEVICE"p4 /mnt/$MNT_DIR # sudo mount -v "$LOOPDEVICE"p4 /mnt/$MNT_DIR
sudo umount -v /mnt/$MNT_DIR # sudo umount -v /mnt/$MNT_DIR
sudo rmdir /mnt/$MNT_DIR # sudo rmdir /mnt/$MNT_DIR
sudo losetup -d $LOOPDEVICE sudo losetup -d $LOOPDEVICE
fi fi

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
tcpPort=1235 tcpPort=1235
imageDir=/home/ross/repos/buildroot/output/images imageDir=/home/jpease/repos/buildroot3/output/images
tvDir=linux-testvectors tvDir=linux-testvectors
rawRamFile="$tvDir/ramGDB.bin" rawRamFile="$tvDir/ramGDB.bin"
ramFile="$tvDir/ram.bin" ramFile="$tvDir/ram.bin"
@ -36,7 +36,7 @@ then
echo "Launching QEMU in replay mode!" echo "Launching QEMU in replay mode!"
(qemu-system-riscv64 \ (qemu-system-riscv64 \
-M virt -dtb /home/ross/repos/buildroot/output/images/wally-artya7.dtb \ -M virt -dtb /home/jpease/repos/buildroot3/output/images/wally-artya7.dtb \
-nographic \ -nographic \
-bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio \ -bios $imageDir/fw_jump.elf -kernel $imageDir/Image -append "root=/dev/vda ro" -initrd $imageDir/rootfs.cpio \
-gdb tcp::$tcpPort -S) \ -gdb tcp::$tcpPort -S) \