Skip to content
Snippets Groups Projects
Commit f497d0ae authored by Clemens Terasa's avatar Clemens Terasa
Browse files

fng-install: Add overlay via gfxml2to

Using the new approach of the `guf-prepare-kernel.sh` we can now
manipulate the kernel device tree during installation time.

This makes it possible to overlay the base kernel device tree with device
specific device tree overlay blobs. As a result we can configure the
kernel in a device specific way on installation using a chroot
approach.

One approach to create the device specific overlay is to create it from
the established Garz & Fricke XML files. This is done by the new tool
`gfxml2dtbo`. The tool is not finished and polished yet however it
might be of use already and the usage in the install script will enable
us to faster develop the tool further.

To be able to get the XML file that is normally residing in
`/etc/shared` we need to mount it first.
parent 691f8978
No related branches found
No related tags found
1 merge request!7fng-install: Add overlay via gfxml2to
...@@ -657,10 +657,13 @@ mounttarget() ...@@ -657,10 +657,13 @@ mounttarget()
mount -o bind /tmp $TARGETROOT/var/tmp mount -o bind /tmp $TARGETROOT/var/tmp
mkdir -p $TARGETROOT/var/tmp mkdir -p $TARGETROOT/var/tmp
mkdir -p $TARGETROOT/etc/shared
mount -t proc proc ${TARGETROOT}/proc/ mount -t proc proc ${TARGETROOT}/proc/
mount -t sysfs sys ${TARGETROOT}/sys/ mount -t sysfs sys ${TARGETROOT}/sys/
mount -o bind /dev ${TARGETROOT}/dev/ mount -o bind /dev ${TARGETROOT}/dev/
mount -o ro,bind /etc/shared ${TARGETROOT}/etc/shared
} }
#=========================================================== #===========================================================
...@@ -670,6 +673,7 @@ mounttarget() ...@@ -670,6 +673,7 @@ mounttarget()
unmounttarget() unmounttarget()
{ {
set +o pipefail set +o pipefail
umount $TARGETROOT/etc/shared || true
umount $TARGETROOT/var/tmp || true umount $TARGETROOT/var/tmp || true
umount $TARGETROOT/tmp || true umount $TARGETROOT/tmp || true
umount $ABSTARGETTMP || true umount $ABSTARGETTMP || true
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
KERNEL_FILE=$1 KERNEL_FILE=$1
DEVICETREE_FILE=$2 DEVICETREE_FILE=$2
shift 2
DEVICETREE_OVERLAYS=$*
# Make sure we have access to the bootpartition # Make sure we have access to the bootpartition
BOOTPARTITION=/dev/mmcblk0p2 BOOTPARTITION=/dev/mmcblk0p2
...@@ -15,21 +17,6 @@ MOUNTPOINT=/boot ...@@ -15,21 +17,6 @@ MOUNTPOINT=/boot
#======================================================== #========================================================
# helper functions # helper functions
#======================================================== #========================================================
string_contains()
{
case "$1" in
*$2*) return 0
esac
return 1
}
string_ends_with()
{
case "$1" in
*$2) return 0
esac
return 1
}
get_platform() get_platform()
{ {
# Determine platform in order to choose devicetree # Determine platform in order to choose devicetree
...@@ -108,17 +95,14 @@ fi ...@@ -108,17 +95,14 @@ fi
if [ -z "$DEVICETREE_FILE" ] if [ -z "$DEVICETREE_FILE" ]
then then
# Read default devicetree file from boot partitione # Read default devicetree file from boot partition
if [ -r "$MOUNTPOINT"/devicetree ] if [ -r "$MOUNTPOINT"/devicetree ]
then then
DEVICETREE_FILE="$( head -n 1 "$MOUNTPOINT"/devicetree )" DEVICETREE_FILE="$( head -n 1 "$MOUNTPOINT"/devicetree )"
else else
PLATFORM="$( get_platform )" PLATFORM="$( get_platform )"
for dtb in "$MOUNTPOINT/"*.dtb ; do for dtb in "$MOUNTPOINT/"*"$PLATFORM.dtb" ; do
if string_ends_with "$dtb" "$PLATFORM.dtb" DEVICETREE_FILE="$(basename "$dtb")"
then
DEVICETREE_FILE="$(basename "$dtb")"
fi
done done
if [ -z "$DEVICETREE_FILE" ]; then if [ -z "$DEVICETREE_FILE" ]; then
...@@ -138,14 +122,31 @@ fi ...@@ -138,14 +122,31 @@ fi
# Mark the currently selected devicetree as the one # Mark the currently selected devicetree as the one
# (we are on fat, so we use a textfile instead of links): # (we are on fat, so we use a textfile instead of links):
echo "${DEVICETREE_FILE}" > "${MOUNTPOINT}/devicetree" echo "${DEVICETREE_FILE}" > "${MOUNTPOINT}/devicetree"
DEVICETREE_APPEND_FILE=$DEVICETREE_FILE
# Store default kernel file for later usage # Store default kernel file for later usage
echo "$KERNEL_FILE" > "$MOUNTPOINT"/kernel echo "$KERNEL_FILE" > "$MOUNTPOINT"/kernel
if [ -x "/usr/bin/gfxml2dto" ]
then
# Create overlay form G&F XML
if gfxml2dto -o "$MOUNTPOINT"/gfxml-overlay.dtbo
then
DEVICETREE_OVERLAYS="$MOUNTPOINT/gfxml-overlay.dtbo $DEVICETREE_OVERLAYS"
fi
fi
if [ -n "$DEVICETREE_OVERLAYS" ] && [ -x "/usr/bin/fdtoverlay" ]
then
# shellcheck disable=SC2086
if fdtoverlay -i "$MOUNTPOINT/$DEVICETREE_FILE" -o "${MOUNTPOINT}/devicetree.dtb" $DEVICETREE_OVERLAYS
then
echo $DEVICETREE_OVERLAYS > ${MOUNTPOINT}/overlays
DEVICETREE_APPEND_FILE="${MOUNTPOINT}/devicetree.dtb"
fi
fi
# Combine both to one file called linuximage # Combine both to one file called linuximage
cat "$MOUNTPOINT/$KERNEL_FILE" "$MOUNTPOINT/$DEVICETREE_FILE" > "$MOUNTPOINT"/linuximage cat "$MOUNTPOINT/$KERNEL_FILE" "$DEVICETREE_APPEND_FILE" > "$MOUNTPOINT"/linuximage
# Store the selected kernel
echo "$KERNEL_FILE" > "$MOUNTPOINT"/kernel
echo "$DEVICETREE_FILE" > "$MOUNTPOINT"/devicetree
sync sync
if $MOUNTED if $MOUNTED
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment