extlinux-conf-builder.sh: allow a custom FDT to be specified

Some bootloaders might not properly detect the model.
If the specific model is known by configuration, provide a way to
explicitly point to a specific dtb in the extlinux.conf.
This commit is contained in:
Florian Klink 2020-06-20 20:33:18 +02:00
parent afa627730e
commit bd8137aef1
1 changed files with 14 additions and 3 deletions

View File

@ -6,7 +6,7 @@ export PATH=/empty
for i in @path@; do PATH=$PATH:$i/bin; done for i in @path@; do PATH=$PATH:$i/bin; done
usage() { usage() {
echo "usage: $0 -t <timeout> -c <path-to-default-configuration> [-d <boot-dir>] [-g <num-generations>]" >&2 echo "usage: $0 -t <timeout> -c <path-to-default-configuration> [-d <boot-dir>] [-g <num-generations>] [-n <dtbName>]" >&2
exit 1 exit 1
} }
@ -15,7 +15,7 @@ default= # Default configuration
target=/boot # Target directory target=/boot # Target directory
numGenerations=0 # Number of other generations to include in the menu numGenerations=0 # Number of other generations to include in the menu
while getopts "t:c:d:g:" opt; do while getopts "t:c:d:g:n:" opt; do
case "$opt" in case "$opt" in
t) # U-Boot interprets '0' as infinite and negative as instant boot t) # U-Boot interprets '0' as infinite and negative as instant boot
if [ "$OPTARG" -lt 0 ]; then if [ "$OPTARG" -lt 0 ]; then
@ -29,6 +29,7 @@ while getopts "t:c:d:g:" opt; do
c) default="$OPTARG" ;; c) default="$OPTARG" ;;
d) target="$OPTARG" ;; d) target="$OPTARG" ;;
g) numGenerations="$OPTARG" ;; g) numGenerations="$OPTARG" ;;
n) dtbName="$OPTARG" ;;
\?) usage ;; \?) usage ;;
esac esac
done done
@ -96,8 +97,18 @@ addEntry() {
echo " LINUX ../nixos/$(basename $kernel)" echo " LINUX ../nixos/$(basename $kernel)"
echo " INITRD ../nixos/$(basename $initrd)" echo " INITRD ../nixos/$(basename $initrd)"
if [ -d "$dtbDir" ]; then if [ -d "$dtbDir" ]; then
# if a dtbName was specified explicitly, use that, else use FDTDIR
if [ -n "$dtbName" ]; then
echo " FDT ../nixos/$(basename $dtbs)/${dtbName}"
else
echo " FDTDIR ../nixos/$(basename $dtbs)" echo " FDTDIR ../nixos/$(basename $dtbs)"
fi fi
else
if [ -n "$dtbName" ]; then
echo "Explicitly requested dtbName $dtbName, but there's no FDTDIR - bailing out." >&2
exit 1
fi
fi
echo " APPEND systemConfig=$path init=$path/init $extraParams" echo " APPEND systemConfig=$path init=$path/init $extraParams"
} }