gistfile1.txt
· 1.6 KiB · Text
Raw
#!/bin/sh
# Some devices (xiaomi-surya) ship with a touchscreen that has no persistent
# firmware storage. That is unfortunate and means we need to provide firmware
# from the initramfs for FDE to work.
# This is only the case for the novatek touchscreens. Their firmware resides
# in /vendor/firmware. Let's copy it over.
# The file names are novatek_ts_huaxing_fw.bin and novatek_ts_tianma_fw.bin,
# for both panels respectively.
for input in /sys/class/input/input*/uevent
do
if grep -q "NT36XXX" "$input"
then
echo "nt36xxx is loaded, mounting firmware for it!"
mkdir /firmware-mnt
for part in /sys/block/sd*/sd*
do
DEVNAME="$(grep DEVNAME "$part"/uevent | sed 's/DEVNAME=//g')"
PARTNAME="$(grep PARTNAME "$part"/uevent | sed 's/PARTNAME=//g')"
# Could be vendor_a or vendor_b
if [[ "$PARTNAME" == "vendor"* ]]
then
mount -o ro,nodev,noexec,nosuid \
"/dev/$DEVNAME" /firmware-mnt
break
# Super partition with vendor on a subpartition, system if retrofit
elif [[ "$PARTNAME" == "super" ]] || [[ "$PARTNAME" == "system" ]]
then
if ! make-dynpart-mappings "/dev/$DEVNAME"; then continue; fi;
for dynpart in /dev/mapper/*
do
if [[ "$dynpart" == *"vendor"* ]]
then
mount -o ro,nodev,noexec,nosuid \
"$dynpart" /firmware-mnt
break
fi
done
fi
done
if [ -d /firmware-mnt/firmware ]
then
for firmware_file in /firmware-mnt/firmware/novatek_ts_*_fw.bin
do
echo "Found novatek firmware file at $firmware_file"
cp $firmware_file /lib/firmware/
done
umount /firmware-mnt
fi
fi
done
| 1 | #!/bin/sh |
| 2 | |
| 3 | # Some devices (xiaomi-surya) ship with a touchscreen that has no persistent |
| 4 | # firmware storage. That is unfortunate and means we need to provide firmware |
| 5 | # from the initramfs for FDE to work. |
| 6 | # This is only the case for the novatek touchscreens. Their firmware resides |
| 7 | # in /vendor/firmware. Let's copy it over. |
| 8 | # The file names are novatek_ts_huaxing_fw.bin and novatek_ts_tianma_fw.bin, |
| 9 | # for both panels respectively. |
| 10 | |
| 11 | for input in /sys/class/input/input*/uevent |
| 12 | do |
| 13 | if grep -q "NT36XXX" "$input" |
| 14 | then |
| 15 | echo "nt36xxx is loaded, mounting firmware for it!" |
| 16 | |
| 17 | mkdir /firmware-mnt |
| 18 | |
| 19 | for part in /sys/block/sd*/sd* |
| 20 | do |
| 21 | DEVNAME="$(grep DEVNAME "$part"/uevent | sed 's/DEVNAME=//g')" |
| 22 | PARTNAME="$(grep PARTNAME "$part"/uevent | sed 's/PARTNAME=//g')" |
| 23 | |
| 24 | # Could be vendor_a or vendor_b |
| 25 | if [[ "$PARTNAME" == "vendor"* ]] |
| 26 | then |
| 27 | mount -o ro,nodev,noexec,nosuid \ |
| 28 | "/dev/$DEVNAME" /firmware-mnt |
| 29 | break |
| 30 | # Super partition with vendor on a subpartition, system if retrofit |
| 31 | elif [[ "$PARTNAME" == "super" ]] || [[ "$PARTNAME" == "system" ]] |
| 32 | then |
| 33 | if ! make-dynpart-mappings "/dev/$DEVNAME"; then continue; fi; |
| 34 | |
| 35 | for dynpart in /dev/mapper/* |
| 36 | do |
| 37 | if [[ "$dynpart" == *"vendor"* ]] |
| 38 | then |
| 39 | mount -o ro,nodev,noexec,nosuid \ |
| 40 | "$dynpart" /firmware-mnt |
| 41 | break |
| 42 | fi |
| 43 | done |
| 44 | fi |
| 45 | done |
| 46 | |
| 47 | if [ -d /firmware-mnt/firmware ] |
| 48 | then |
| 49 | for firmware_file in /firmware-mnt/firmware/novatek_ts_*_fw.bin |
| 50 | do |
| 51 | echo "Found novatek firmware file at $firmware_file" |
| 52 | |
| 53 | cp $firmware_file /lib/firmware/ |
| 54 | done |
| 55 | |
| 56 | umount /firmware-mnt |
| 57 | fi |
| 58 | fi |
| 59 | done |
| 60 |