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

fng-install:prepare-kernel: Added i.MX8 support

The default prepare-kernel script didn't support the i.MX8.
Tweaked the script, to support the custom requirements of the i.MX8.
The i.MX6 specific parts for the generation of the overlays (from the
shared XML) and the gf_platform detection has been moved to new scripts.

BCS 746-000877
parent 5f97c8e6
No related branches found
No related tags found
1 merge request!391Add RTC detection for TANARO
#!/bin/sh
# shellcheck source=../../../recipes-guf/sharedconf/sharedconf/gf-functions.sh
if ! . /usr/sbin/gf-functions.sh; then
echo "Unable to include gf-functions"
fi
# shellcheck source=./gf-prepare-common.sh
if ! . /usr/sbin/gf-prepare-common.sh; then
echo "Unable to include gf-prepare-common"
fi
#========================================================
parse_args "$@"
mount_bootpartition BOOTFILES_DIR
#========================================================
if [ -z "$DEVICETREE_FILE" ]
then
# Read default devicetree file from boot partition
if [ -r "$BOOTFILES_DIR"/devicetree ]
then
DEVICETREE_FILE="$( head -n 1 "$BOOTFILES_DIR"/devicetree )"
else
get_platform PLATFORM
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
fi
fi
if [ ! -e "$BOOTFILES_DIR/$DEVICETREE_FILE" ]
then
echo "Default devicetree specified ($DEVICETREE_FILE) not found."
echo "Please select one as parameter."
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
......@@ -51,7 +51,7 @@ parse_args()
--*)
unkown_parameter "$1"
;;
*) # only positional parameters left
*) # Only positional parameters left
break
;;
esac
......@@ -59,11 +59,12 @@ parse_args()
done
KERNEL_FILE=$1
# TODO imx8 uses DEVICETREE environment varaible to set this
DEVICETREE_FILE=$2
if [ $# -gt 2 ];then
shift 2
fi
DEVICETREE_OVERLAYS=$*
}
......@@ -84,84 +85,64 @@ then
# 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 "uImage*" \
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
fi
fi
if [ ! -e "$BOOTFILES_DIR/$KERNEL_FILE" ]
then
echo "Default kernel specified ($KERNEL_FILE) not found."
echo "Please select one as parameter."
exit 1
fi
if [ -z "$DEVICETREE_FILE" ]
then
# Read default devicetree file from boot partition
if [ -r "$BOOTFILES_DIR"/devicetree ]
then
DEVICETREE_FILE="$( head -n 1 "$BOOTFILES_DIR"/devicetree )"
else
get_platform PLATFORM
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
sed -i "$BOOTFILES_DIR/boot.cfg" -e "s|kernel=.*|kernel=$KERNEL_FILE|"
fi
fi
if [ ! -e "$BOOTFILES_DIR/$DEVICETREE_FILE" ]
then
echo "Default devicetree specified ($DEVICETREE_FILE) not found."
echo "Please select one as parameter."
exit 1
fi
mount -o remount,async "$BOOTFILES_DIR"
# Mark the currently selected devicetree as the one
# (we are on fat, so we use a textfile instead of links):
echo "${DEVICETREE_FILE}" > "${BOOTFILES_DIR}/devicetree"
DEVICETREE_APPEND_FILE=$DEVICETREE_FILE # Store default kernel file for later usage
echo "$KERNEL_FILE" > "$BOOTFILES_DIR"/kernel
# Store default kernel file for later usage
echo "$KERNEL_FILE" > "$BOOTFILES_DIR/kernel"
if [ -x "/usr/bin/gfxml2dto" ]
then
# Create overlay form G&F XML
if gfxml2dto -o "$BOOTFILES_DIR"/gfxml-overlay.dtbo
then
DEVICETREE_OVERLAYS="$BOOTFILES_DIR/gfxml-overlay.dtbo $DEVICETREE_OVERLAYS"
else
echo "Failed to when executing gfxml2dto, device configuration will not be used."
fi
#========================================================
# Load active devicetree from file and apply overlays
#========================================================
DEVICETREE_FILE="$( head -n 1 "$BOOTFILES_DIR/devicetree" )"
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"
fi
# Change into the boot directory and combine the devicetree
# with the overlays.
#
# NOTE: The overlays in the overlays.txt contain relative paths.
# Since we don't want to extend every overlay path, we change
# temporarily into the boot directory, create the overlay and
# switch back to where we came from.
if [ -n "$DEVICETREE_OVERLAYS" ] && [ -x "/usr/bin/fdtoverlay" ]
then
# shellcheck disable=SC2086
if fdtoverlay -i "$BOOTFILES_DIR/$DEVICETREE_FILE" -o "${BOOTFILES_DIR}/devicetree.dtb" $DEVICETREE_OVERLAYS
then
echo $DEVICETREE_OVERLAYS > ${BOOTFILES_DIR}/overlays
DEVICETREE_APPEND_FILE="devicetree.dtb"
else
echo "Error executing fdtoverlay."
exit 1
PWD=$( pwd )
if cd "$BOOTFILES_DIR"; then
# shellcheck disable=SC2086
if fdtoverlay -i "$DEVICETREE_FILE" -o "devicetree.dtb" $DEVICETREE_OVERLAYS
then
DEVICETREE_APPEND_FILE="devicetree.dtb"
sed -i boot.cfg -e "s|devicetree=.*|devicetree=devicetree.dtb|"
else
echo "Error executing fdtoverlay."
exit 1
fi
fi
cd "$PWD" || exit 1
fi
# Combine both to one file called linuximage
cat "$BOOTFILES_DIR/$KERNEL_FILE" "${BOOTFILES_DIR}/$DEVICETREE_APPEND_FILE" > "$BOOTFILES_DIR"/linuximage
cat "$BOOTFILES_DIR/$KERNEL_FILE" "$BOOTFILES_DIR/$DEVICETREE_APPEND_FILE" > "$BOOTFILES_DIR"/linuximage
# We are done, cleanup
umount_bootpartition
......
#!/bin/sh
# shellcheck source=../../../recipes-guf/sharedconf/sharedconf/gf-functions.sh
if ! . /usr/sbin/gf-functions.sh; then
echo "Unable to include gf-functions"
fi
# shellcheck source=./gf-prepare-common.sh
if ! . /usr/sbin/gf-prepare-common.sh; then
echo "Unable to include gf-prepare-common"
fi
GFXML_OVERLAY_NAME="gfxml-overlay.dtbo"
# Get the directory containing the bootfiles
mount_bootpartition BOOTFILES_DIR
# Change into boot directory
cd "$BOOTFILES_DIR" || exit 1
# Create overlays directory if it doesn't exist
mkdir -p overlays
# Create overlay form SECO Northern Europe XML
if [ -x "/usr/bin/gfxml2dto" ]; then
if gfxml2dto -o "overlays/$GFXML_OVERLAY_NAME"
then
append_overlay "${GFXML_OVERLAY_NAME}"
else
echo "Error: Failed to execute gfxml2dto. The device configuration will not be used."
fi
fi
exit 0
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
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