File editbootinstall_arm64.sh of Package openSUSE-MicroOS

#!/bin/bash
set -euxo pipefail

diskname=$1
devname="$2"
loopname="${devname%*p?}"
loopdev=${loopname#/dev/mapper/*}

echo "Installing Bootloader"

# Make sure first partition starts after bootloader!
# https://docs.kontron-electronics.de/sw/ked/docs/docs/howto/mx8mm/installing-a-standard-distribution/
# disk_start_sector="8192" is 4M

for target in imx8mm_evk imx8mn_evk; do
	fn="usr/lib/u-boot/flash-${target}.bin"
	[ -e "$fn" ] || continue
	echo "Installing flash.bin for $target"
	# fallback for A/B bootloader updates is at second offset
	for offset in 33 2081; do
		if ! dd if="$fn" of="$diskname" bs=1024 seek="$offset" conv=notrunc; then
		    echo "Failed to install $fn"
		    exit 1
		fi
	done
	# create some partitions to cover the area
	sgdisk -a 2 --new=4:66:4161   -c 4:flash1 -t 4:a000 "$diskname"
	sgdisk -a 2 --new=5:4162:8191 -c 5:flash2 -t 5:a001 "$diskname"
	break
done
openSUSE Build Service is sponsored by