Skip to content
Snippets Groups Projects
Commit a2b67812 authored by Tobias Kahlki's avatar Tobias Kahlki
Browse files

fng-install: Updated post-install scripts

The environmental variable based passing of devicetrees and overlays has
been replaced entirely by a file-based mechanism.
The documentation, comments, and format of the post-install scripts
have been extended and reworked.
parent 83f74a24
No related branches found
No related tags found
1 merge request!395fng-install: Clarify interface between fng-install and postinstall steps
...@@ -25,29 +25,28 @@ mount_bootpartition BOOTFILES_DIR ...@@ -25,29 +25,28 @@ mount_bootpartition BOOTFILES_DIR
#======================================================== #========================================================
# ENV Variable DEVICETREE is set from the fng-install script # Read the default devicetree file from the boot partition
# when it was called with --DTB parameter if [ -r "$BOOTFILES_DIR"/devicetree ]
#
if [ -z "$DEVICETREE" ]
then then
# Read the default devicetree file from the boot partition DEVICETREE_FILE="$( head -n 1 "$BOOTFILES_DIR"/devicetree )"
if [ -r "$BOOTFILES_DIR"/devicetree ] else
then # If no default devicetree is set, detect a valid
DEVICETREE_FILE="$( head -n 1 "$BOOTFILES_DIR"/devicetree )" # devicetree based on the platform
else get_platform PLATFORM
get_platform PLATFORM
for dtb in "$BOOTFILES_DIR/"*"$PLATFORM.dtb" ; do for dtb in "$BOOTFILES_DIR/"*"$PLATFORM.dtb" ; do
DEVICETREE_FILE="$(basename "$dtb")" DEVICETREE_FILE="$(basename "$dtb")"
done done
if [ -z "$DEVICETREE_FILE" ]; then if [ -z "$DEVICETREE_FILE" ]; then
echo "No devicetree found for: $PLATFORM" echo "No devicetree found for: $PLATFORM"
exit 1 exit 1
fi
fi fi
else
DEVICETREE_FILE="$DEVICETREE" mount -o remount,async "$BOOTFILES_DIR"
# Mark the selected devicetree as default
echo "$DEVICETREE_FILE" > "$BOOTFILES_DIR/devicetree"
fi fi
if [ ! -e "$BOOTFILES_DIR/$DEVICETREE_FILE" ] if [ ! -e "$BOOTFILES_DIR/$DEVICETREE_FILE" ]
...@@ -56,14 +55,6 @@ then ...@@ -56,14 +55,6 @@ then
exit 1 exit 1
fi fi
mount -o remount,async "$BOOTFILES_DIR"
# Mark the selected devicetree as default
#
# Note: Since we are on a fat partition,
# we use a textfile instead of a link.
echo "$DEVICETREE_FILE" > "$BOOTFILES_DIR/devicetree"
exit 0 exit 0
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
...@@ -7,18 +7,14 @@ ...@@ -7,18 +7,14 @@
# BOOTPARTITION='$TARGET_PARTITION_BOOT' \ # BOOTPARTITION='$TARGET_PARTITION_BOOT' \
# #
# The script can also be called standalone, or by the fnginstall-postinstallation # The script can also be called standalone, or by the fnginstall-postinstallation
# script in the target OS, to update configurations # script in the target OS, to update configurations.
# #
# This helper script to select the used base kernel and base devicetree # This helper script loads/detects the active/valid kernel, loads the active
# and combine those together to linux image # devicetree, and appends the devicetree overlays to the active devicetree
# In dunfell we currently use the feature to load the devicetree directly # if applicable.
# after the kernel in the memory by concat both files
# #
# Kernel and devicetree files are detect automatically # Note: For i.MX6 devices, the kernel and devicetree (including the overlays)
# but may be specified on the commandline # are combined into a single file (named linuximage) that is loaded altogether.
# After the selection, the result is written to two textfiles
# 'kernel' and 'devicetree'.
# When these are found, these values override the autodetection
# #
# The files to work on, are selected by a list of known boot partitions # The files to work on, are selected by a list of known boot partitions
# from which the first one is selected. # from which the first one is selected.
...@@ -44,37 +40,31 @@ mount_bootpartition BOOTFILES_DIR ...@@ -44,37 +40,31 @@ mount_bootpartition BOOTFILES_DIR
# Detect active kernel # Detect active kernel
#======================================================== #========================================================
# Allows to specify a specific kernel as environment variable # Read the active kernel from the boot partition
# Not used currently if [ -r "$BOOTFILES_DIR"/kernel ]
if [ -z "$KERNEL" ]
then then
# Read default kernel file from boot partitione KERNEL_FILE="$( head -n 1 "$BOOTFILES_DIR"/kernel )"
if [ -r "$BOOTFILES_DIR"/kernel ] else
then # If no kernel is marked as active, detect a valid kernel
KERNEL_FILE="$( head -n 1 "$BOOTFILES_DIR"/kernel )" # inside the boot partition and mark it as active
else KERNEL_FILE="$( find "$BOOTFILES_DIR" -maxdepth 1 -name "*Image*" \
-exec basename {} \; | head -n 1 )"
# Mark the currently installed kernel as selected:
# (we are on fat, so we use a textfile instead of links):
KERNEL_FILE="$( find "$BOOTFILES_DIR" -maxdepth 1 -name "*Image*" \
-exec basename {} \; | head -n 1 )"
if [ -z "$KERNEL_FILE" ]
then
echo "Failed to determine the kernel file to use."
exit 1
fi
sed -i "$BOOTFILES_DIR/boot.cfg" -e "s|kernel=.*|kernel=$KERNEL_FILE|" if [ -z "$KERNEL_FILE" ]
then
echo "Failed to determine a valid kernel to be used."
exit 1
fi fi
else
KERNEL_FILE="$KERNEL" # Store the active kernel for later usage
echo "$KERNEL_FILE" > "$BOOTFILES_DIR/kernel"
# Set the active kernel in the boot configuration
sed -i "$BOOTFILES_DIR/boot.cfg" -e "s|kernel=.*|kernel=$KERNEL_FILE|"
fi fi
mount -o remount,async "$BOOTFILES_DIR" mount -o remount,async "$BOOTFILES_DIR"
# Store default kernel file for later usage
echo "$KERNEL_FILE" > "$BOOTFILES_DIR/kernel"
#======================================================== #========================================================
# Load active devicetree from file and apply overlays # Load active devicetree from file and apply overlays
#======================================================== #========================================================
...@@ -84,8 +74,7 @@ DEVICETREE_APPEND_FILE=$DEVICETREE_FILE ...@@ -84,8 +74,7 @@ DEVICETREE_APPEND_FILE=$DEVICETREE_FILE
# Load the active overlays from the overlays.txt # Load the active overlays from the overlays.txt
if [ -e "$BOOTFILES_DIR/overlays.txt" ]; then if [ -e "$BOOTFILES_DIR/overlays.txt" ]; then
DEVICETREE_OVERLAYS_FILE="$( head -n 1 "$BOOTFILES_DIR"/overlays.txt | awk -F '=' '{print $2}' )" DEVICETREE_OVERLAYS="$( head -n 1 "$BOOTFILES_DIR"/overlays.txt | awk -F '=' '{print $2}' )"
DEVICETREE_OVERLAYS="$DEVICETREE_OVERLAYS_FILE $DEVICETREE_OVERLAYS"
fi fi
# Change into the boot directory and combine the devicetree # Change into the boot directory and combine the devicetree
......
...@@ -6,11 +6,9 @@ ...@@ -6,11 +6,9 @@
# script. # script.
# #
# The script gathers the devicetree overlays from various sources and locations # The script gathers the devicetree overlays from various sources and locations
# and places them in /boot/overlays. Overlays that have been provided via the # and places them in /boot/overlays.
# script's arguments are additionally added to the overlays.txt to
# mark them active.
# The overlays that are not provided via the arguments are either activated # The overlays that are not provided via the arguments are either activated
# by another post-install script (e.g. the prepare-rtc script) or via the # by another post-install scripts (e.g. the prepare-rtc script) or via the
# shared configuration. # shared configuration.
# shellcheck source=../../../recipes-guf/sharedconf/sharedconf/gf-functions.sh # shellcheck source=../../../recipes-guf/sharedconf/sharedconf/gf-functions.sh
......
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