diff --git a/JOURNAL.md b/JOURNAL.md index 4f78f26..eeb79f3 100644 --- a/JOURNAL.md +++ b/JOURNAL.md @@ -855,3 +855,10 @@ loading it on each baud rate: Let's keep the bitstream files in a repository, so I can carefully track them with git too. + +### OBSERVATION: The new bitstream requires a bootrom to start + +I added it to the bitstream repository, as it is a binary blob too. Now I need +to update the load addresses: + +https://gitlab.bsc.es/hwdesign/fpga/integration-lab/fpga-tools/-/blob/6a63bcea6d1d59df3c7d62311aa4935efd54d3a3/boot_riscv/boot_sa.sh#L36-40 diff --git a/flake.nix b/flake.nix index e54b84c..ed621bf 100644 --- a/flake.nix +++ b/flake.nix @@ -108,6 +108,7 @@ ROOTFS = build.sdImage; UBOOT_ENV = syspkgs.uboot-env; BITSTREAM = syspkgs.bitstream; + BOOTROM = syspkgs.bootrom; shellHook = '' echo "Here are the current system pieces:" echo " TOPLEVEL = $TOPLEVEL" @@ -117,6 +118,7 @@ echo " ROOTFS = $ROOTFS" echo " UBOOT_ENV = $UBOOT_ENV" echo " BITSTREAM = $BITSTREAM" + echo " BOOTROM = $BOOTROM" ''; }; diff --git a/fpga/boot.sh b/fpga/boot.sh index 2de91b4..41a6813 100755 --- a/fpga/boot.sh +++ b/fpga/boot.sh @@ -7,6 +7,6 @@ source ./env.sh #bitstream="-w system-acme_ea-4h2v.bit" -./fpgactl $bitstream -b opensbi.bin -k kernel.bin -i initrd.bin -r rootfs.img +./fpgactl $bitstream -b opensbi.bin -k kernel.bin -i initrd.bin -r rootfs.img -R bootrom.bin picocom -b 115200 /dev/ttyUSB2 diff --git a/fpga/env.sh b/fpga/env.sh index ac62ed5..3768b63 100644 --- a/fpga/env.sh +++ b/fpga/env.sh @@ -37,11 +37,14 @@ function setup_meep() # Setup mappings # Delta between where we load in the dma device and RAM - local delta_addr=-0x60000000 + local delta_addr=-0x5ffe0000 + + # See https://gitlab.bsc.es/hwdesign/fpga/integration-lab/fpga-tools/-/blob/6a63bcea6d1d59df3c7d62311aa4935efd54d3a3/boot_riscv/boot_sa.sh#L36-40 export FPGACTL_BOOTLOADER_ADDR=$((0x80000000+$delta_addr)) export FPGACTL_KERNEL_ADDR=$((0x84000000+$delta_addr)) export FPGACTL_INITRD_ADDR=$((0x8c300000+$delta_addr)) export FPGACTL_ROOTFS_ADDR=$((0x100000000+$delta_addr)) + export FPGACTL_BOOTROM_ADDR=$((0x00000100)) } hostname=$(hostname) diff --git a/fpga/fpgactl b/fpga/fpgactl index 78b9c1b..6a2540e 100755 --- a/fpga/fpgactl +++ b/fpga/fpgactl @@ -370,6 +370,7 @@ bootloader= kernel= initrd= rootfs= +bootrom= resetcpu= verbose= pcidev= @@ -383,6 +384,7 @@ bootloader_addr="${FPGACTL_BOOTLOADER_ADDR:-0x80000000}" kernel_addr="${FPGACTL_KERNEL_ADDR:-0x84000000}" initrd_addr="${FPGACTL_INITRD_ADDR:-0x8c300000}" rootfs_addr="${FPGACTL_ROOTFS_ADDR:-0x140000000}" +bootrom_addr="${FPGACTL_BOOTROM_ADDR:-0x60000100}" hostname="${hostname:-$(hostname)}" echo "hostname=$hostname" @@ -390,7 +392,7 @@ echo "hostname=$hostname" function usage() { echo "" >&2 - echo "Usage: $0 [-p pcidev] [-v] [-w bitstream] [-j serial] [-b bootloader] [-k kernel] [-i initrd]" >&2 + echo "Usage: $0 [-p pcidev] [-v] [-w bitstream] [-j serial] [-b bootloader] [-k kernel] [-i initrd] [-R bootroom] " >&2 echo "" >&2 echo "First writes the bitstream if given. Then loads the rest of files" >&2 echo "into memory and restarts the CPU." >&2 @@ -405,13 +407,14 @@ function usage() echo " -k kernel Load the kernel file in $kernel_addr" >&2 echo " -i initrd Load the initrd file in $initrd_addr" >&2 echo " -r rootfs Load the rootfs file in $rootfs_addr" >&2 + echo " -R bootrom Load the bootrom file in $bootrom_addr" >&2 echo " -m model CPU model: Either 'hun' or 'ox' (default ox)" >&2 echo " -v Be verbose" >&2 echo "" >&2 exit 1 } -while getopts "hvw:b:k:i:r:p:j:m:" opt; do +while getopts "hvw:b:k:i:r:p:j:m:R:" opt; do case "${opt}" in v) verbose=1 ;; w) bitstream="${OPTARG}" ;; @@ -419,6 +422,7 @@ while getopts "hvw:b:k:i:r:p:j:m:" opt; do k) kernel="${OPTARG}"; resetcpu=1 ;; i) initrd="${OPTARG}"; resetcpu=1 ;; r) rootfs="${OPTARG}"; resetcpu=1 ;; + R) bootrom="${OPTARG}"; resetcpu=1 ;; p) pcidev="${OPTARG}" ;; j) jtagserial="${OPTARG}" ;; m) model="${OPTARG}" ;; @@ -441,6 +445,7 @@ test "$bootloader" && load_file_in_memory "$bootloader" $bootloader_addr test "$kernel" && load_file_in_memory "$kernel" $kernel_addr test "$initrd" && load_file_in_memory "$initrd" $initrd_addr test "$rootfs" && load_file_in_memory "$rootfs" $rootfs_addr +test "$bootrom" && load_file_in_memory "$bootrom" $bootrom_addr test "$resetcpu" && do_cpu_release exit 0 diff --git a/fpga/upload.sh b/fpga/upload.sh index e136f3f..67ee05b 100755 --- a/fpga/upload.sh +++ b/fpga/upload.sh @@ -22,6 +22,7 @@ else echo "Skipping rootfs" fi rsync "$BITSTREAM" "$dst/bitstream.bit" +rsync "$BOOTROM" "$dst/bootrom.bin" rsync "$UBOOT_ENV" "$dst/uboot.env" echo "Now go to $dst and run ./boot.sh" diff --git a/lagarto-ox.nix b/lagarto-ox.nix index 2672017..f222110 100644 --- a/lagarto-ox.nix +++ b/lagarto-ox.nix @@ -180,6 +180,8 @@ #bitstream = "${final.bitstreams}/lagarto-3-ox/gold.bit"; bitstream = "${final.bitstreams}/lagarto-3-ox/ox_u55c_a234c132_two_uarts.bit"; + bootrom = "${final.bitstreams}/lagarto-3-ox/large_bootrom.bin"; + uboot = prev.ubootQemuRiscv64Smode.override { filesToInstall = [ "u-boot.bin" "u-boot-nodtb.bin" ]; #version = "2023.07.02-print-cpu-probe"; diff --git a/overlay.nix b/overlay.nix index 19ca0ec..0ad4189 100644 --- a/overlay.nix +++ b/overlay.nix @@ -39,6 +39,6 @@ final: prev: bitstreams = builtins.fetchGit { url = "git@bscpm03.bsc.es:rarias/bitstreams.git"; - rev = "57876cea158d8a4a63f7d35d715000092609d88c"; + rev = "ad901b0c21ffbdb310ff1dfb269f169f6ac6bde6"; }; }