Add support for UEFI booting on riscv64

This commit is contained in:
Aurelien Jarno 2024-09-22 14:03:56 +00:00 committed by Steve McIntyre
parent 62844c08d4
commit 88a82cae73
2 changed files with 88 additions and 7 deletions

View File

@ -70,7 +70,7 @@ DEBOOTSTRAP_OPTS=--no-check-gpg
endif
## Additional packages required for Debian Ports
DEBIAN_PORTS_ARCHES=alpha hppa ia64 hurd-amd64 hurd-i386 m68k powerpc powerpcspe ppc64 riscv64 sh4 sparc sparc64 x32
DEBIAN_PORTS_ARCHES=alpha hppa ia64 hurd-amd64 hurd-i386 m68k powerpc powerpcspe ppc64 sh4 sparc sparc64 x32
ifneq (,$(filter $(DEBIAN_PORTS_ARCHES),$(ARCHES)))
export BASE_INCLUDE := $(BASEDIR)/data/debian_ports $(BASE_INCLUDE)
endif

View File

@ -1,14 +1,22 @@
#!/bin/bash
# Do install stuff for riscv64
# Should work with debian-installer (?)
# Based on boot-arm64
#
# Do install stuff for riscv64, including making bootable CDs
# Works with debian-installer
#
# $1 is the CD number
# $2 is the temporary CD build dir
#
. $BASEDIR/tools/boot/$DI_CODENAME/common.sh
set -e
#set -x
N=$1
CDDIR=$2
INSTALLDIR="install"
# Common options for all disks
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J -joliet-long"
@ -27,7 +35,80 @@ else
DI_WWW_HOME=$(echo $DI_WWW_HOME | sed "s,%ARCH%,$ARCH,")
fi
# Not doing anything special here in terms of setting up bootable
# media *yet*. Let's see what we can do about UEFI boot from USB or
# similar?
copy_arch_images
case "$MKISOFS" in
*xorriso*)
XORRISO_VER=$(xorriso_version)
;;
*)
echo "ERROR: debian-cd depends on xorriso for making $ARCH bootable CDs."
exit 1;
;;
esac
cd $CDDIR/..
BOOT_IMAGES="cdrom/initrd.gz cdrom/vmlinux cdrom/debian-cd_info.tar.gz"
# Download boot images.
for image in $BOOT_IMAGES; do
if [ ! -e "$image" ]; then
dir=$(dirname $image)
mkdir -p $dir
if [ -n "$LOCAL" -a -f "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" ]; then
cp "${LOCALDEBS:-$MIRROR}/dists/$DI_DIST/local/installer-$ARCH/current/images/$image" "$image"
elif [ ! "$DI_WWW_HOME" ];then
if [ ! "$DI_DIR" ];then
DI_DIR="$MIRROR/dists/$DI_DIST/main/installer-$ARCH/current/images"
fi
cp "$DI_DIR/$image" "$image"
else
$WGET "$DI_WWW_HOME/$image" -O "$image"
fi
fi
done
mkdir -p $CDDIR/$INSTALLDIR
cp -lf cdrom/vmlinux $CDDIR/$INSTALLDIR/
cp -lf cdrom/initrd.gz $CDDIR/$INSTALLDIR/
# Boot setup including config and help files comes from d-i.
mkdir -pv $PWD/boot$N
cat cdrom/debian-cd_info.tar.gz | (cd boot$N/; tar zx)
if [ -d boot$N/grub ] ; then
echo " Adding EFI boot code for $ARCH on CD$N"
# Extract DTB files
mkdir -p $CDDIR/dtb
mcopy -n -s -i boot$N/grub/efi.img '::dtb/*' $CDDIR/dtb
# Extract GRUB files
mkdir -p $CDDIR/EFI/boot
mcopy -n -s -i boot$N/grub/efi.img '::efi/*' $CDDIR/EFI
mkdir -p $CDDIR/boot/grub
mv boot$N/grub/* $CDDIR/boot/grub/
rmdir boot$N/grub
# Do not repack efi.img, the version provided by d-i is suitable to create a bootable CD
# Location of the EFI boot image, and don't emulate a floppy or HD
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-e boot/grub/efi.img -no-emul-boot"
# Add an *extra* partition on the end for the EFI bits
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-append_partition 2 0xef $CDDIR/boot/grub/efi.img"
# And force alignment
add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-partition_cyl_align all"
# Finally, belt and braces - fix up the %install% entries in grub
# in case they're still there
sed -i "s|\%install\%|$INSTALLDIR|g" $CDDIR/boot/grub/grub.cfg
# Substitute custom KERNEL_PARAMS into grub.cfg
sed -i "s|/vmlinux |/vmlinux $KERNEL_PARAMS |g" $CDDIR/boot/grub/grub.cfg
else
echo " No EFI boot code for $ARCH on CD$N"
fi
# th,th, thats all