mediatek: add script to trigger scrubbing of FIP-in-UBI
authorDaniel Golle <daniel@makrotopia.org>
Sun, 11 Aug 2024 22:45:46 +0000 (23:45 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 12 Aug 2024 10:31:37 +0000 (11:31 +0100)
Read the 'fip' static volume in order to trigger scrubbing in case of
detecting flipped bits while reading.
We have to do this in Linux because we never read or touch the 'fip'
volume and the UBISPL implementation in ARM TrustedFirmware-A does NOT
handle scrubbing itself.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/mediatek/base-files/lib/preinit/07_trigger_fip_scrubbing [new file with mode: 0644]

diff --git a/target/linux/mediatek/base-files/lib/preinit/07_trigger_fip_scrubbing b/target/linux/mediatek/base-files/lib/preinit/07_trigger_fip_scrubbing
new file mode 100644 (file)
index 0000000..74458e0
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+trigger_fip_scrubbing() {
+       local vol voltype volname
+       for vol in /sys/class/ubi/ubi*_*; do
+               [ -e "$vol" ] || continue
+               voltype="$(cat "$vol"/type)"
+               volname="$(cat "$vol"/name)"
+               if [ "$voltype" = "static" ] && [ "$volname" = "fip" ]; then
+                       cat "/dev/${vol##*/}" > /dev/null
+                       break
+               fi
+       done
+}
+
+boot_hook_add preinit_main trigger_fip_scrubbing