aboutsummaryrefslogtreecommitdiff
path: root/tools/boot
diff options
context:
space:
mode:
Diffstat (limited to 'tools/boot')
-rwxr-xr-xtools/boot/ci-qemu-test.sh4
-rw-r--r--tools/boot/full-test.sh118
-rwxr-xr-xtools/boot/install-boot.sh52
-rwxr-xr-xtools/boot/lua-lint.sh2
-rw-r--r--tools/boot/smbios/Makefile1
-rwxr-xr-xtools/boot/universe.sh2
6 files changed, 124 insertions, 55 deletions
diff --git a/tools/boot/ci-qemu-test.sh b/tools/boot/ci-qemu-test.sh
index faa360db1a2c..63f0fc2c64b2 100755
--- a/tools/boot/ci-qemu-test.sh
+++ b/tools/boot/ci-qemu-test.sh
@@ -125,8 +125,8 @@ timeout 300 \
-snapshot -hda $hda 2>&1 | tee ${BOOTLOG}
# Check whether we succesfully booted...
-if grep -q 'Hello world.' ${BOOTLOG}; then
- echo "OK"
+if grep -q 'Hello world.' ${BOOTLOG} && egrep -q '^Uptime: ' ${BOOTLOG}; then
+ echo "Boot successful"
else
die "Did not boot successfully, see ${BOOTLOG}"
fi
diff --git a/tools/boot/full-test.sh b/tools/boot/full-test.sh
index 89d2ac3b7277..1160861316dc 100644
--- a/tools/boot/full-test.sh
+++ b/tools/boot/full-test.sh
@@ -19,8 +19,8 @@
# What version of FreeBSD to we snag the ISOs from to extract the binaries
# we are testing
-FREEBSD_VERSION=13.1
-# eg https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/FreeBSD-13.1-RELEASE-amd64-bootonly.iso.xz
+FREEBSD_VERSION=14.2
+# eg https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/14.2/FreeBSD-14.2-RELEASE-amd64-bootonly.iso.xz
URLBASE="https://download.freebsd.org/releases"
: ${STAND_ROOT:="${HOME}/stand-test-root"}
CACHE=${STAND_ROOT}/cache
@@ -30,23 +30,59 @@ BIOS=${STAND_ROOT}/bios
SCRIPTS=${STAND_ROOT}/scripts
OVERRIDE=${STAND_ROOT}/override
-# hack -- I have extra junk in my qemu, but it's not needed to recreate things
-if [ $(whoami) = imp ]; then
- qemu_bin=/home/imp/git/qemu/00-build
-else
- qemu_bin=/usr/local/bin
-fi
+# Find make
+case $(uname) in
+ Darwin)
+ t=$(realpath $(dirname $0)/../..)
+ # Use the python wrapper to find make
+ if [ -f ${t}/tools/build/make.py ]; then
+ MAKE="${t}/tools/build/make.py"
+ case $(uname -m) in
+ arm64)
+ DEFARCH="TARGET_ARCH=aarch64 TARGET=arm64"
+ ;;
+ x86_64)
+ DEFARCH="TARGET_ARCH=amd64 TARGET=amd64"
+ ;;
+ *)
+ die "Do not know about $(uanme -p)"
+ ;;
+ esac
+ else
+ die "Can't find the make wrapper"
+ fi
+ qemu_bin=/opt/homebrew/bin
+ ;;
+ FreeBSD)
+ MAKE=make
+ qemu_bin=/usr/local/bin
+ ;;
+ # linux) not yet
+ *)
+ die "Do not know about system $(uname)"
+ ;;
+esac
+
+SRCTOP=$(${MAKE} ${DEFARCH} -v SRCTOP)
+echo $SRCTOP
+
+# Find makefs and mkimg
+MAKEFS=$(SHELL="which makefs" ${MAKE} ${DEFARCH} buildenv | tail -1) || die "No makefs try WITH_DISK_IMAGE_TOOLS_BOOTSTRAP=y"
+MKIMG=$(SHELL="which mkimg" ${MAKE} ${DEFARCH} buildenv | tail -1) || die "No mkimg, try buildworld first"
+MTREE=$(SHELL="which mtree" ${MAKE} ${DEFARCH} buildenv | tail -1) || die "No mtree, try buildworld first"
+
+# MAKE=$(SHELL="which make" ${MAKE} ${DEFARCH} buildenv | tail -1) || die "No make, try buildworld first"
+
# All the architectures under test
# Note: we can't yet do armv7 because we don't have a good iso for it and would
# need root to extract the files.
-ARCHES="amd64:amd64 i386:i386 powerpc:powerpc powerpc:powerpc64 powerpc:powerpc64le powerpc:powerpcspe arm64:aarch64 riscv:riscv64"
+#ARCHES="amd64:amd64 i386:i386 powerpc:powerpc powerpc:powerpc64 powerpc:powerpc64le powerpc:powerpcspe arm64:aarch64 riscv:riscv64"
+ARCHES="amd64:amd64 arm64:aarch64"
# The smallest FAT32 filesystem is 33292 KB
espsize=33292
-SRCTOP=$(make -v SRCTOP)
-
mkdir -p ${CACHE} ${TREES} ${IMAGES} ${BIOS}
die()
@@ -123,9 +159,8 @@ make_minimal_freebsd_tree()
# Pretend we don't have a separate /usr
ln -s . ${dir}/usr
# snag the binaries for my simple /etc/rc file
- tar -C ${dir} -xf ${CACHE}/$file sbin/reboot sbin/halt sbin/init bin/sh sbin/sysctl \
- lib/libncursesw.so.9 lib/libc.so.7 lib/libedit.so.8 libexec/ld-elf.so.1
-
+ tar -C ${dir} -xf ${CACHE}/$file sbin/fastboot sbin/reboot sbin/halt sbin/init bin/sh sbin/sysctl \
+ lib/libtinfow.so.9 lib/libncursesw.so.9 lib/libc.so.7 lib/libedit.so.8 libexec/ld-elf.so.1
# My simple etc/rc
cat > ${dir}/etc/rc <<EOF
#!/bin/sh
@@ -173,6 +208,10 @@ autoboot_delay=2
zfs_load="YES"
boot_verbose=yes
kern.cfg.order="acpi,fdt"
+boot_serial="YES"
+hw.uart.console="io:1016,br:115200"
+vfs.root.mountfrom="ufs:/dev/ufs/root"
+vfs.root.mountfrom.options="rw"
EOF
}
@@ -196,14 +235,15 @@ make_freebsd_test_trees()
[ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
dir=${TREES}/${ma_combo}/test-stand
mkdir -p ${dir}
- mtree -deUW -f ${SRCTOP}/etc/mtree/BSD.root.dist -p ${dir}
+ ${MTREE} -deUW -f ${SRCTOP}/etc/mtree/BSD.root.dist -p ${dir}
echo "Creating tree for ${m}:${ma}"
- cd ${SRCTOP}/stand
+ cd ${SRCTOP}
# Indirection needed because our build system is too complex
-# SHELL="make clean" make buildenv TARGET=${m} TARGET_ARCH=${ma}
- SHELL="make -j 100 all" make buildenv TARGET=${m} TARGET_ARCH=${ma}
- SHELL="make install DESTDIR=${dir} MK_MAN=no MK_INSTALL_AS_USER=yes WITHOUT_DEBUG_FILES=yes" \
- make buildenv TARGET=${m} TARGET_ARCH=${ma}
+ # Also, bare make for 'inside' the buildenv ${MAKE} for outside
+# SHELL="make clean" ${MAKE} buildenv TARGET=${m} TARGET_ARCH=${ma}
+ SHELL="sh -c 'cd stand ; make -j 100 all'" ${MAKE} TARGET=${m} TARGET_ARCH=${ma} buildenv
+ DESTDIR=${dir} SHELL="sh -c 'cd stand ; make install MK_MAN=no MK_INSTALL_AS_USER=yes WITHOUT_DEBUG_FILES=yes'" \
+ ${MAKE} buildenv TARGET=${m} TARGET_ARCH=${ma}
rm -rf ${dir}/bin ${dir}/[ac-z]* # Don't care about anything here
done
}
@@ -278,14 +318,14 @@ make_linuxboot_images()
img2=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-zfs.img
pool="linuxboot"
mkdir -p ${IMAGES}/${ma_combo}
- makefs -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
+ ${MAKEFS} -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
-o volume_label=EFISYS -s80m ${esp} ${src}
- makefs -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
- mkimg -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
- makefs -t zfs -s 200m \
+ ${MAKEFS} -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
+ ${MKIMG} -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
+ ${MAKEFS} -t zfs -s 200m \
-o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
${zfs} ${dir} ${dir2}
- mkimg -s gpt \
+ ${MKIMG} -s gpt \
-p efi:=${esp} \
-p freebsd-zfs:=${zfs} -o ${img2}
rm -f ${esp} # Don't need to keep this around
@@ -325,7 +365,7 @@ make_linuxboot_scripts()
if [ ${bios_code} -ot /usr/local/share/qemu/edk2-x86_64-code.fd ]; then
cp /usr/local/share/qemu/edk2-x86_64-code.fd ${bios_code}
# vars file works on both 32 and 64 bit x86
- cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
+# cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
fi
;;
aarch64)
@@ -407,7 +447,8 @@ EOF
make_freebsd_esps()
{
# At the moment, we have just three (armv7 could also be here too, but we're not doing that)
- for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
+# for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
+ for a in amd64:amd64 arm64:aarch64; do
m=${a%%:*}
ma=${a##*:}
ma_combo="${m}"
@@ -429,7 +470,8 @@ make_freebsd_images()
{
# ESP variant: In this variant, riscv, amd64 and arm64 are created more or
# less the same way. UEFI + ACPI implementations
- for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
+# for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
+ for a in amd64:amd64 arm64:aarch64; do
m=${a%%:*}
ma=${a##*:}
ma_combo="${m}"
@@ -445,15 +487,16 @@ make_freebsd_images()
cat > ${dir2}/etc/fstab <<EOF
/dev/ufs/root / ufs rw 1 1
EOF
- makefs -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
+ ${MAKEFS} -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
-o volume_label=EFISYS -s100m ${esp} ${src}
- makefs -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
- mkimg -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
+ ${MAKEFS} -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
+ ${MKIMG} -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
# rm -f ${esp} ${ufs} # Don't need to keep this around
done
set -x
+if false; then
# BIOS i386
a=i386:i386
m=${a%%:*}
@@ -469,10 +512,10 @@ EOF
cat > ${dir2}/etc/fstab <<EOF
/dev/ufs/root / ufs rw 1 1
EOF
- makefs -t ffs -B little -s 200m \
+ ${MAKEFS} -t ffs -B little -s 200m \
-o label=root,version=2,bsize=32768,fsize=4096,density=16384 \
${ufs} ${dir} ${dir2}
- mkimg -s gpt -b ${dir2}/boot/pmbr \
+ ${MKIMG} -s gpt -b ${dir2}/boot/pmbr \
-p freebsd-boot:=${dir2}/boot/gptboot \
-p freebsd-ufs:=${ufs} \
-o ${img}
@@ -493,13 +536,14 @@ EOF
cat > ${dir2}/etc/fstab <<EOF
/dev/ufs/root / ufs rw 1 1
EOF
- makefs -t ffs -B big -s 200m \
+ ${MAKEFS} -t ffs -B big -s 200m \
-o label=root,version=2,bsize=32768,fsize=4096,density=16384 \
${ufs} ${dir} ${dir2}
- mkimg -a 1 -s apm \
+ ${MKIMG} -a 1 -s apm \
-p freebsd-boot:=${dir2}/boot/boot1.hfs \
-p freebsd-ufs:=${ufs} \
-o ${img}
+fi
set +x
}
@@ -521,7 +565,7 @@ make_freebsd_scripts()
if [ ${bios_code} -ot /usr/local/share/qemu/edk2-x86_64-code.fd ]; then
cp /usr/local/share/qemu/edk2-x86_64-code.fd ${bios_code}
# vars file works on both 32 and 64 bit x86
- cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
+# cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
fi
;;
aarch64)
@@ -568,6 +612,7 @@ EOF
esac
done
+if false; then
set -x
a=powerpc:powerpc
m=${a%%:*}
@@ -603,6 +648,7 @@ ${qemu_bin}/qemu-system-i386 -m 1g \\
-monitor telnet::4444,server,nowait \\
-serial stdio \$*
EOF
+fi
}
# The smallest FAT32 filesystem is 33292 KB
diff --git a/tools/boot/install-boot.sh b/tools/boot/install-boot.sh
index 332756582137..217bf0ff1457 100755
--- a/tools/boot/install-boot.sh
+++ b/tools/boot/install-boot.sh
@@ -42,11 +42,10 @@ get_uefi_bootname() {
}
make_esp_file() {
- local file sizekb loader device stagedir fatbits efibootname
+ local file sizekb device stagedir fatbits efibootname
file=$1
sizekb=$2
- loader=$3
if [ "$sizekb" -ge "$fat32min" ]; then
fatbits=32
@@ -58,8 +57,25 @@ make_esp_file() {
stagedir=$(mktemp -d /tmp/stand-test.XXXXXX)
mkdir -p "${stagedir}/EFI/BOOT"
- efibootname=$(get_uefi_bootname)
- cp "${loader}" "${stagedir}/EFI/BOOT/${efibootname}.efi"
+
+ # Allow multiple files to be copied.
+ # We do this in pairs, e.g:
+ # make_esp_file ... loader1.efi bootx64 loader2.efi bootia32
+ #
+ # If the second argument is left out,
+ # determine it automatically.
+ shift; shift # Skip $file and $sizekb
+ while [ ! -z $1 ]; do
+ if [ ! -z $2 ]; then
+ efibootname=$2
+ else
+ efibootname=$(get_uefi_bootname)
+ fi
+ cp "$1" "${stagedir}/EFI/BOOT/${efibootname}.efi"
+
+ shift; shift || : # Ignore failure to shift
+ done
+
makefs -t msdos \
-o fat_type=${fatbits} \
-o sectors_per_cluster=1 \
@@ -70,13 +86,20 @@ make_esp_file() {
}
make_esp_device() {
- local dev file mntpt fstype efibootname kbfree loadersize efibootfile
+ local dev file dst mntpt fstype efibootname kbfree loadersize efibootfile
local isboot1 existingbootentryloaderfile bootorder bootentry
# ESP device node
dev=$1
file=$2
+ # Allow caller to override the default
+ if [ ! -z $3 ]; then
+ efibootname=$3
+ else
+ efibootname=$(get_uefi_bootname)
+ fi
+ dst=$(basename ${file%.efi})
mntpt=$(mktemp -d /tmp/stand-test.XXXXXX)
# See if we're using an existing (formatted) ESP
@@ -93,7 +116,6 @@ make_esp_device() {
echo "Mounted ESP ${dev} on ${mntpt}"
- efibootname=$(get_uefi_bootname)
kbfree=$(df -k "${mntpt}" | tail -1 | cut -w -f 4)
loadersize=$(stat -f %z "${file}")
loadersize=$((loadersize / 1024))
@@ -114,7 +136,7 @@ make_esp_device() {
fi
fi
- if [ ! -f "${mntpt}/EFI/freebsd/loader.efi" ] && [ "$kbfree" -lt "$loadersize" ]; then
+ if [ ! -f "${mntpt}/EFI/freebsd/${dst}.efi" ] && [ "$kbfree" -lt "$loadersize" ]; then
umount "${mntpt}"
rmdir "${mntpt}"
echo "Failed to update the EFI System Partition ${dev}"
@@ -126,24 +148,26 @@ make_esp_device() {
mkdir -p "${mntpt}/EFI/freebsd"
# Keep a copy of the existing loader.efi in case there's a problem with the new one
- if [ -f "${mntpt}/EFI/freebsd/loader.efi" ] && [ "$kbfree" -gt "$((loadersize * 2))" ]; then
- cp "${mntpt}/EFI/freebsd/loader.efi" "${mntpt}/EFI/freebsd/loader-old.efi"
+ if [ -f "${mntpt}/EFI/freebsd/${dst}.efi" ] && [ "$kbfree" -gt "$((loadersize * 2))" ]; then
+ cp "${mntpt}/EFI/freebsd/${dst}.efi" "${mntpt}/EFI/freebsd/${dst}-old.efi"
fi
echo "Copying loader to /EFI/freebsd on ESP"
- cp "${file}" "${mntpt}/EFI/freebsd/loader.efi"
+ cp "${file}" "${mntpt}/EFI/freebsd/${dst}.efi"
- if [ -n "${updatesystem}" ]; then
- existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}//EFI/freebsd/loader.efi")
+ # efibootmgr won't work on systems with ia32 UEFI firmware
+ # since we only use it to boot the 64-bit kernel
+ if [ -n "${updatesystem}" ] && [ ${efibootname} != "bootia32" ]; then
+ existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}//EFI/freebsd/${dst}.efi")
if [ -z "$existingbootentryloaderfile" ]; then
# Try again without the double forward-slash in the path
- existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}/EFI/freebsd/loader.efi")
+ existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}/EFI/freebsd/${dst}.efi")
fi
if [ -z "$existingbootentryloaderfile" ]; then
echo "Creating UEFI boot entry for FreeBSD"
- efibootmgr --create --label FreeBSD --loader "${mntpt}/EFI/freebsd/loader.efi" > /dev/null
+ efibootmgr --create --label FreeBSD --loader "${mntpt}/EFI/freebsd/${dst}.efi" > /dev/null
if [ $? -ne 0 ]; then
die "Failed to create new boot entry"
fi
diff --git a/tools/boot/lua-lint.sh b/tools/boot/lua-lint.sh
index d771be090c6e..60d7c567dab4 100755
--- a/tools/boot/lua-lint.sh
+++ b/tools/boot/lua-lint.sh
@@ -17,4 +17,4 @@ cd $(make -V SRCTOP)/stand
${LUACHECK} . --globals loader --globals lfs --globals io.getchar \
--globals io.ischar --globals printc --globals cli_execute \
--globals cli_execute_unparsed --globals try_include \
- --globals pager --std lua53
+ --globals pager --globals gfx --globals hash --std lua53
diff --git a/tools/boot/smbios/Makefile b/tools/boot/smbios/Makefile
index 042b3aaee274..42a17aa54b5a 100644
--- a/tools/boot/smbios/Makefile
+++ b/tools/boot/smbios/Makefile
@@ -1,4 +1,3 @@
-
PROG= smbios
MAN=
.PATH: ${SRCTOP}/stand/libsa
diff --git a/tools/boot/universe.sh b/tools/boot/universe.sh
index 3e033ce26ae2..e97858ff2bcb 100755
--- a/tools/boot/universe.sh
+++ b/tools/boot/universe.sh
@@ -3,7 +3,7 @@
#
# Full list of all arches we don't build.
#
-# powerpc/powerpcspe arm/armv6
+# powerpc/powerpcspe
#
# This script is expected to be run in stand (though you could run it anywhere
# in the tree). It does a full clean build. For stand you can do all the archs in