From d42c7c5989644dff7e431bc3d966207210c733aa Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 23 Feb 2023 09:52:37 +0100 Subject: [PATCH] Add image for StarFive VisionFive 2 SUBARCH=visionfive2 is used to build images for the StarFive VisionFive 2 boards. For the device-tree we assume board revision 1.3B. Signed-off-by: Heinrich Schuchardt --- live-build/auto/config | 9 +++- .../hooks.d/base/disk-image-uefi.binary | 47 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/live-build/auto/config b/live-build/auto/config index 628f4d16..db1da0d8 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -352,7 +352,14 @@ fi # one also must request disk1-img-xz image format if [ "$IMAGEFORMAT" = "ext4" ] && [ "$PROJECT" = "ubuntu-cpc" ]; then case $ARCH:$SUBARCH in - armhf:raspi2|riscv64:sifive_*|riscv64:nezha|riscv64:visionfive|riscv64:licheerv|riscv64:icicle|*:generic) + armhf:raspi2 | \ + riscv64:icicle | \ + riscv64:nezha | \ + riscv64:licheerv | \ + riscv64:sifive_* | \ + riscv64:visionfive | \ + riscv64:visionfive2 | \ + *:generic) IMAGE_HAS_HARDCODED_PASSWORD=1 if [ -z "${IMAGE_TARGETS:-}" ]; then export IMAGE_TARGETS="disk1-img-xz" diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary index bbe271ad..c77305a2 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary @@ -128,6 +128,23 @@ create_partitions() { --change-name=3:uEnv \ --new=1:: \ --attributes=1:set:2 + elif [ "${SUBARCH:-}" = "visionfive2" ]; then + # VisionFive 2 + sgdisk "${disk_image}" \ + --set-alignment=4096 \ + --new=13:4096:8191 \ + --typecode=13:2E54B353-1271-4842-806F-E436D6AF6985 \ + --change-name=13:loader1 \ + --new=2:8192:16383 \ + --typecode=2:7a097280-70d2-44bc-886c-ff5ffbb7b098 \ + --change-name=2:loader2 \ + --new=12:16384:24575 \ + --change-name=12:CIDATA \ + --new=15:24576:229375 \ + --typecode=15:ef00 \ + --change-name=15:ESP \ + --new=1:229376: \ + --attributes=1:set:2 else # preinstalled server, currently FU540 # FU740 too in the future @@ -373,8 +390,32 @@ EOF # without a cloud datasource. setup_cinocloud mountpoint ;; + "visionfive2") + echo "Installing GRUB for ${SUBARCH} board" + cp ${my_d}/riscv64/grub/90_watchdog-thresh.cfg mountpoint/etc/default/grub.d/ + # flash-kernel is needed to install the dtb for update-grub: it uses the + # /proc/device-tree/model value to pick the correct dtb and as we are in a chroot, + # the model value is wrong and we need to use /etc/flash-kernel/machine instead. + # This explains why we install flash-kernel here. + chroot mountpoint mkdir -p /etc/flash-kernel/ + chroot mountpoint bash -c "echo 'StarFive VisionFive 2 v1.3B' > /etc/flash-kernel/machine" + chroot mountpoint bash -c 'FK_FORCE=yes apt-get install -qqy grub-efi-riscv64 flash-kernel' + efi_target=riscv64-efi + # Provide end-user modifyable CIDATA + cidata_dev="/dev/mapper${loop_device///dev/}p12" + setup_cidata "${cidata_dev}" + # Provide stock nocloud datasource + # Allow interactive login on baremetal board, + # without a cloud datasource. + setup_cinocloud mountpoint + # Flash-kernel creates boot.scr if it believes we did + # not boot in UEFi mode. Remove it so that we can boot + # via GRUB. + chroot mountpoint rm -f /boot/boot.scr + ;; *) cp ${my_d}/riscv64/grub/90_watchdog-thresh.cfg mountpoint/etc/default/grub.d/ + echo "Installing u-boot-menu for ${SUBARCH} board" chroot mountpoint apt-get install -qqy u-boot-menu #grub-efi-riscv64 mkdir -p mountpoint/etc/u-boot-menu/conf.d/ cp ${my_d}/riscv64/u-boot-menu/*.conf mountpoint/etc/u-boot-menu/conf.d/ @@ -408,7 +449,11 @@ EOF chroot mountpoint u-boot-update fi - if [ "${SUBARCH:-}" != "visionfive" ] && [ "${SUBARCH:-}" != "nezha" ] && [ "${SUBARCH:-}" != "licheerv" ] && [ "${SUBARCH:-}" != "icicle" ]; then + if [ "${SUBARCH:-}" != "nezha" ] && \ + [ "${SUBARCH:-}" != "licheerv" ] && \ + [ "${SUBARCH:-}" != "icicle" ] \ + [ "${SUBARCH:-}" != "visionfive" ] && \ + [ "${SUBARCH:-}" != "visionfive2" ]; then ## TODO remove below once we have grub-efi-riscv64 for the platforms rm mountpoint/tmp/device.map umount mountpoint/boot/efi