diff options
Diffstat (limited to 'alt-rootfs-installer/socs.d/SiFive-riscv64.sh')
| -rw-r--r-- | alt-rootfs-installer/socs.d/SiFive-riscv64.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/alt-rootfs-installer/socs.d/SiFive-riscv64.sh b/alt-rootfs-installer/socs.d/SiFive-riscv64.sh new file mode 100644 index 0000000..dd42613 --- /dev/null +++ b/alt-rootfs-installer/socs.d/SiFive-riscv64.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# vim:sw=8:noet + +BBL=2E54B353-1271-4842-806F-E436D6AF6985 +FSBL=5B193300-FC78-40CD-8002-E86C45580B47 +SPL=$FSBL +UBOOT_CODE=$BBL + +MEDIATABLE=gpt +ROOTPART_NUM=1 +# ~1 MiB for U-Boot SPL +# ~4 MiB for OpenSBI + U-Boot +# + some overhead for future usage +START_SECTOR=34 # MiB +[ -n "$EFI" ] || BOOTFLAG=legacy_boot +[ -n "$VNC" ] || + case "$TARGET" in + sifive_unleashed) VNC=1;; + *) VNC=0;; + esac +CONSOLE=1 +[ -n "$SYSCON" ] || SYSCON=ttySIF0,115200n8 + +soc_write_bootloader() { + unmount_partition + [ -n "$ROOTFS" ] || clear_riscv64_bootloader_partition + + print_message "Creating partitions for U-Boot SPL and OpenSBI + U-Boot..." + LASTPART_NUM=$(sgdisk -p "$MEDIA" | tail -n1 | tr -s ' ' | cut -f 2 -d ' ') + let 'SPLPART_NUM = LASTPART_NUM + 1' + let 'UBOOTPART_NUM = LASTPART_NUM + 2' + sgdisk -a 1 \ + --new=$SPLPART_NUM:34:2081 --change-name=$SPLPART_NUM:spl \ + --typecode=$SPLPART_NUM:"$SPL" \ + --new=$UBOOTPART_NUM:2082:10273 --change-name=$UBOOTPART_NUM:uboot \ + --typecode=$UBOOTPART_NUM:"$UBOOT_CODE" \ + "$MEDIA" || + fatal_error "failed to create U-Boot SPL and OpenSBI + U-Boot partitions" + print_done + + sync_partitions + mount_partition + + set_path_to_uboot + print_message "Writing U-Boot SPL for ${TARGET-}..." + SPL_BLOB="$(readlink -e "$UBOOT/u-boot-spl.bin")" + [ -f "${SPL_BLOB-}" ] || fatal_error "${SPL_BLOB-} was not found" + SPLPART="${MEDIA}${partsuffix-}${SPLPART_NUM}" + [ -b "${SPLPART-}" ] || fatal_error "${SPLPART-} is not a block device or does not exist" + dd if="$SPL_BLOB" of="$SPLPART" bs=4M status=none || fatal_error "failed to write U-Boot SPL" + print_done + + print_message "Writing OpenSBI + U-Boot for ${TARGET-}..." + UBOOT_BLOB="$(readlink -e "$UBOOT/u-boot.itb")" + [ -f "${UBOOT_BLOB-}" ] || fatal_error "${UBOOT_BLOB-}} was not found" + UBOOTPART="${MEDIA}${partsuffix-}${UBOOTPART_NUM}" + [ -b "${UBOOTPART-}" ] || fatal_error "${UBOOTPART-} is not a block device or does not exist" + dd if="$UBOOT_BLOB" of="$UBOOTPART" bs=4M status=none || fatal_error "failed to write OpenSBI+U-Boot" + sync + print_done +} |