-
-
Save daniel-thompson/89cf62189282e2fd2dbf9b163da142ee to your computer and use it in GitHub Desktop.
Quick 'n dirty DT integration for Debian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# /etc/grub.d/11_devicetree | |
# | |
# Scan the devicetree file available in /boot and construct menu entries | |
# for them. | |
# | |
# This script has a fewer smart features compared to normal grub scripts. | |
# In particular it must be configured differently for boot-in-root and | |
# separate boot (a.k.a. encrypted rootfs) scenarios. | |
# | |
# We are relying on the Debian theme code to look up the /boot partition so | |
# that we can load a devicetree from them. We could do something like the | |
# following but I'm too busy right now to lookup how Debian's grub scripts | |
# find that UUID! | |
# | |
# insmod part_gpt | |
# insmod ext2 | |
# search --no-floppy --fs-uuid --set=root c741fdf7-37fa-4269-a1bc-246ef13d8871 | |
# | |
# This configuration is correct for encrypted rootfs (and Thinkpad X13s) | |
grub_boot=/ | |
linux_boot=/boot/ | |
dtb=sc8280xp-lenovo-thinkpad-x13s.dtb | |
# Select a default dtb. This file is strictly manually managed and, if absent, | |
# then we'll simply assume DtbLoader is still doing it's (pointless) thing! | |
if [ -e "${linux_boot}${dtb}" ] | |
then | |
echo devicetree ${grub_boot}${dtb} | |
fi | |
# Update the set of DTs in /boot | |
for d in /usr/lib/linux-image-*/qcom/${dtb} | |
do | |
tag=$(echo ${d} | cut -d/ -f4 | cut -c12-) | |
if [ ! -e ${linux_boot}${dtb}${tag} ] | |
then | |
cp ${d} ${linux_boot}${dtb}${tag} | |
fi | |
done | |
# Generate menu items to allow replacing the DTB with specific versions | |
if [ ! -z $(ls ${linux_boot}${dtb}-* | wc -l) ] | |
then | |
echo "submenu 'Devicetree recovery options for Debian/GNU/Linux' {" | |
for d in $(ls -r ${linux_boot}${dtb}-*) | |
do | |
d="$(basename ${d})" | |
echo " menuentry 'Replace DT with $d' {" | |
echo " devicetree ${grub_boot}${d}" | |
echo " }" | |
done | |
echo "}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment