Skip to content

Commit

Permalink
Improve img create script for amd64, add EFI support, improve MBR boot
Browse files Browse the repository at this point in the history
Inspire from OpenBSD distrib/{amd64,arm64}/iso/Makefile
  • Loading branch information
sonertari committed Feb 25, 2024
1 parent 541a430 commit 6c9b860
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ The following are steps you can follow to build UTMFW yourself. Some of these st
+ Extract src.tar.gz and and sys.tar.gz under /usr/src/
+ Apply the patches under openbsd/utmfw
+ Update the sources with the stable branch changes if any
+ Follow the instructions in release(8), this step takes about 6 hours on a relatively fast amd64 computer and about 55 hours on a Raspberry Pi 4
+ Follow the instructions in release(8), this step takes about 6 hours on a relatively fast amd64 computer and longer than 60 hours on a Raspberry Pi 4
+ Build the kernel and reboot
+ Build the base system
+ Make the release, use the dest and rel folders created above:
Expand All @@ -315,6 +315,7 @@ The following are steps you can follow to build UTMFW yourself. Some of these st
+ Copy the xbaseXY.tgz install set from installXY.img to docs/expat/arm64/xbaseXY.tgz
+ Copy the xfontXY.tgz install set from installXY.iso to docs/fonts/amd64/xfontXY.tgz
+ Copy the xfontXY.tgz install set from installXY.img to docs/fonts/arm64/xfontXY.tgz
+ Copy the files under the BOOT partition of installXY.img for the amd64 arch to ~/OpenBSD/X.Y/amd64/BOOT/
+ Copy the files under the BOOT partition of installXY.img for the arm64 arch to ~/OpenBSD/X.Y/arm64/BOOT/
+ Download and copy [the Broadcom wifi drivers](https://github.com/pftf/RPi4/tree/master/firmware/brcm) for Raspberry Pi 4 to ~/OpenBSD/X.Y/arm64/firmware/

Expand Down
46 changes: 23 additions & 23 deletions meta/createimg
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ cd $ROOT_PATH/$CD_PATH
if [ "$ARCH" = arm64 ]; then
MSDOSSTART=32768
MSDOSSIZE=16384
FFSSTART=$(($MSDOSSTART + $MSDOSSIZE))
fi
if [ "$ARCH" = amd64 ]; then
FFSSTART=0
MSDOSSTART=0
MSDOSSIZE=960
fi
FFSSTART=$(($MSDOSSTART + $MSDOSSIZE))

# Size of cd/{arm64,amd64}, trim trailing white spaces by adding 0
CD_SIZE=$(($(du -L -s . | cut -d . -f 1) + 0))
Expand All @@ -72,9 +73,7 @@ cd $ROOT_PATH
rm $IMG_FILE

doas umount ./img_ffs
if [ "$ARCH" = arm64 ]; then
doas umount ./img_msdos
fi
doas umount ./img_msdos
doas vnconfig -u vnd0

# 1 sector = 512 bytes
Expand All @@ -85,42 +84,43 @@ dd if=/dev/zero of=$IMG_FILE bs=512 count=$IMG_SIZE
doas vnconfig vnd0 $IMG_FILE

if [ "$ARCH" = arm64 ]; then
echo "reinit\ne 0\nC\nn\n$MSDOSSTART\n$MSDOSSIZE\nf 0\ne 3\nA6\nn\n$FFSSTART\n*\nw\nq\n" | doas fdisk -e vnd0 >/dev/null
#echo "reinit\ne 0\nC\nn\n$MSDOSSTART\n$MSDOSSIZE\nf 0\ne 3\nA6\nn\n$FFSSTART\n*\nw\nq\n" | doas fdisk -e vnd0 >/dev/null
doas fdisk -yi -b "${MSDOSSIZE}@${MSDOSSTART}:c" vnd0
fi
if [ "$ARCH" = amd64 ]; then
echo "y\n" | doas fdisk -i vnd0 >/dev/null
doas fdisk -yi -l $FS_SIZE -b $MSDOSSIZE -f /usr/mdec/mbr vnd0
fi
doas fdisk vnd0

echo "a a\n\n\n\nw\nq\n" | doas disklabel -E vnd0 >/dev/null
echo '/ *' | doas disklabel -wAT- vnd0
doas disklabel vnd0

doas newfs -O 1 -m 0 -o space -i $FS_SIZE -c $CD_SIZE /dev/rvnd0a
doas newfs -O 1 -m 0 -o space -i 524288 -c $CD_SIZE /dev/rvnd0a

if [ "$ARCH" = arm64 ]; then
doas newfs_msdos -L boot -c 1 -F 16 /dev/rvnd0i
doas newfs -t msdos -L boot -c 1 -F 16 /dev/rvnd0i
fi
if [ "$ARCH" = amd64 ]; then
doas newfs -t msdos /dev/rvnd0i
fi

mkdir ./img_ffs
doas mount /dev/vnd0a ./img_ffs

if [ "$ARCH" = arm64 ]; then
mkdir ./img_msdos
doas mount -o-l /dev/vnd0i ./img_msdos
fi

doas cp -R -L -v $ROOT_PATH/$CD_PATH/* ./img_ffs/

if [ "$ARCH" = arm64 ]; then
doas cp -R -v openbsd/$INSTALL_SETS_PATH/BOOT/* ./img_msdos
echo "$VOL_ID\n$SYS_ID\n$APP_ID\n$PUBLISH_ID\n$PREP_ID" > ./img_msdos/README.txt
fi
mkdir ./img_msdos
doas mount -o-l /dev/vnd0i ./img_msdos

doas cp -R -v openbsd/$INSTALL_SETS_PATH/BOOT/* ./img_msdos

if [ "$ARCH" = amd64 ]; then
doas installboot -r ./img_ffs vnd0 /usr/mdec/biosboot /usr/mdec/boot
doas objcopy -S -R .comment /usr/mdec/boot ./img_ffs/boot
doas installboot -v -r ./img_ffs vnd0 /usr/mdec/biosboot ./img_ffs/boot
fi

echo "$VOL_ID\n$SYS_ID\n$APP_ID\n$PUBLISH_ID\n$PREP_ID" > ./img_msdos/README.txt

doas umount ./img_ffs
if [ "$ARCH" = arm64 ]; then
doas umount ./img_msdos
fi
doas umount ./img_msdos
doas vnconfig -u vnd0

0 comments on commit 6c9b860

Please sign in to comment.