diff --git a/recipes-bsp/fng-install/prepare-image/gf-prepare-dt.sh b/recipes-bsp/fng-install/prepare-image/gf-prepare-dt.sh index f076993c01227cd42b73a35520cb17815ff773a4..dc78b6642f79a627421c1e74379707c29d607f2a 100644 --- a/recipes-bsp/fng-install/prepare-image/gf-prepare-dt.sh +++ b/recipes-bsp/fng-install/prepare-image/gf-prepare-dt.sh @@ -25,29 +25,28 @@ mount_bootpartition BOOTFILES_DIR #======================================================== -# ENV Variable DEVICETREE is set from the fng-install script -# when it was called with --DTB parameter -# -if [ -z "$DEVICETREE" ] +# Read the default devicetree file from the boot partition +if [ -r "$BOOTFILES_DIR"/devicetree ] then - # Read the default devicetree file from the boot partition - if [ -r "$BOOTFILES_DIR"/devicetree ] - then - DEVICETREE_FILE="$( head -n 1 "$BOOTFILES_DIR"/devicetree )" - else - get_platform PLATFORM + DEVICETREE_FILE="$( head -n 1 "$BOOTFILES_DIR"/devicetree )" +else + # If no default devicetree is set, detect a valid + # devicetree based on the platform + get_platform PLATFORM - for dtb in "$BOOTFILES_DIR/"*"$PLATFORM.dtb" ; do - DEVICETREE_FILE="$(basename "$dtb")" - done + for dtb in "$BOOTFILES_DIR/"*"$PLATFORM.dtb" ; do + DEVICETREE_FILE="$(basename "$dtb")" + done - if [ -z "$DEVICETREE_FILE" ]; then - echo "No devicetree found for: $PLATFORM" - exit 1 - fi + if [ -z "$DEVICETREE_FILE" ]; then + echo "No devicetree found for: $PLATFORM" + exit 1 fi -else - DEVICETREE_FILE="$DEVICETREE" + + mount -o remount,async "$BOOTFILES_DIR" + + # Mark the selected devicetree as default + echo "$DEVICETREE_FILE" > "$BOOTFILES_DIR/devicetree" fi if [ ! -e "$BOOTFILES_DIR/$DEVICETREE_FILE" ] @@ -56,14 +55,6 @@ then exit 1 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 # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/recipes-bsp/fng-install/prepare-image/gf-prepare-kernel.sh b/recipes-bsp/fng-install/prepare-image/gf-prepare-kernel.sh index 8547897a46329ecce507c6d55aadd9fb4cea3564..d2002d8cc33c2e731e86829682e1ea716eac9039 100644 --- a/recipes-bsp/fng-install/prepare-image/gf-prepare-kernel.sh +++ b/recipes-bsp/fng-install/prepare-image/gf-prepare-kernel.sh @@ -7,18 +7,14 @@ # BOOTPARTITION='$TARGET_PARTITION_BOOT' \ # # 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 -# and combine those together to linux image -# In dunfell we currently use the feature to load the devicetree directly -# after the kernel in the memory by concat both files +# This helper script loads/detects the active/valid kernel, loads the active +# devicetree, and appends the devicetree overlays to the active devicetree +# if applicable. # -# Kernel and devicetree files are detect automatically -# but may be specified on the commandline -# After the selection, the result is written to two textfiles -# 'kernel' and 'devicetree'. -# When these are found, these values override the autodetection +# Note: For i.MX6 devices, the kernel and devicetree (including the overlays) +# are combined into a single file (named linuximage) that is loaded altogether. # # The files to work on, are selected by a list of known boot partitions # from which the first one is selected. @@ -44,37 +40,31 @@ mount_bootpartition BOOTFILES_DIR # Detect active kernel #======================================================== -# Allows to specify a specific kernel as environment variable -# Not used currently -if [ -z "$KERNEL" ] +# Read the active kernel from the boot partition +if [ -r "$BOOTFILES_DIR"/kernel ] then - # Read default kernel file from boot partitione - if [ -r "$BOOTFILES_DIR"/kernel ] - then - KERNEL_FILE="$( head -n 1 "$BOOTFILES_DIR"/kernel )" - else - - # 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 + KERNEL_FILE="$( head -n 1 "$BOOTFILES_DIR"/kernel )" +else + # If no kernel is marked as active, detect a valid kernel + # inside the boot partition and mark it as active + KERNEL_FILE="$( find "$BOOTFILES_DIR" -maxdepth 1 -name "*Image*" \ + -exec basename {} \; | head -n 1 )" - 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 -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 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 #======================================================== @@ -84,8 +74,7 @@ DEVICETREE_APPEND_FILE=$DEVICETREE_FILE # Load the active overlays from the overlays.txt if [ -e "$BOOTFILES_DIR/overlays.txt" ]; then - DEVICETREE_OVERLAYS_FILE="$( head -n 1 "$BOOTFILES_DIR"/overlays.txt | awk -F '=' '{print $2}' )" - DEVICETREE_OVERLAYS="$DEVICETREE_OVERLAYS_FILE $DEVICETREE_OVERLAYS" + DEVICETREE_OVERLAYS="$( head -n 1 "$BOOTFILES_DIR"/overlays.txt | awk -F '=' '{print $2}' )" fi # Change into the boot directory and combine the devicetree diff --git a/recipes-bsp/fng-install/prepare-image/gf-prepare-overlays.sh b/recipes-bsp/fng-install/prepare-image/gf-prepare-overlays.sh index 025d89b870977c789bf392e4e1454478e65263f7..a3431035c9aef3d80d267c40e959292c6fdcda52 100644 --- a/recipes-bsp/fng-install/prepare-image/gf-prepare-overlays.sh +++ b/recipes-bsp/fng-install/prepare-image/gf-prepare-overlays.sh @@ -6,11 +6,9 @@ # script. # # The script gathers the devicetree overlays from various sources and locations -# and places them in /boot/overlays. Overlays that have been provided via the -# script's arguments are additionally added to the overlays.txt to -# mark them active. +# and places them in /boot/overlays. # 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. # shellcheck source=../../../recipes-guf/sharedconf/sharedconf/gf-functions.sh