@@ -22,6 +22,7 @@ PKG_LICENSE:=GPL-2.0
# Extend depends from version.mk
PKG_CONFIG_DEPENDS += \
CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE \
+ CONFIG_HAS_DT_OVERLAY_SUPPORT \
CONFIG_NAND_SUPPORT \
CONFIG_LEGACY_SDCARD_SUPPORT \
CONFIG_CLEAN_IPKG \
@@ -189,6 +190,11 @@ else
mkdir -p $(1)/var
$(LN) /tmp/run $(1)/var/run
endif
+
+ifneq ($(CONFIG_HAS_DT_OVERLAY_SUPPORT),y)
+ rm $(1)/lib/preinit/90_apply_dt_overlays
+endif
+
$(LN) /tmp/resolv.conf /tmp/TZ /tmp/localtime $(1)/etc/
chmod 0600 $(1)/etc/shadow
@@ -15,6 +15,7 @@ boot_hook_init preinit_main
boot_hook_init failsafe
boot_hook_init initramfs
boot_hook_init preinit_mount_root
+boot_hook_init preinit_late
for pi_source_file in /lib/preinit/*; do
. $pi_source_file
@@ -27,3 +28,4 @@ pi_jffs2_mount_success=false
pi_failsafe_net_message=false
boot_run_hook preinit_main
+boot_run_hook preinit_late
new file mode 100644
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+do_apply_dt_overlays() {
+ grep -q configfs /proc/filesystems || return 0
+ mount configfs -t configfs /sys/kernel/config
+ local overlays_dir="/sys/kernel/config/device-tree/overlays"
+ [ -d "$overlays_dir" ] || return 0
+ local dto dtoname
+ for dto in /lib/firmware/device-tree/overlays/*.dto ; do
+ [ -r "$dto" ] || continue
+ dtoname="$(basename "$dtbo" .dtbo)"
+ [ -e "$overlays_dir/$dtoname" ] && continue
+ echo " - applying device-tree overlay '$dtoname' - "
+ mkdir "$overlays_dir/$dtoname"
+ echo "$dto" > "$overlays_dir/$dtoname/path"
+ done
+}
+
+boot_hook_add preinit_late do_apply_dt_overlays
Add new boot hooklist 'preinit_late' 'preinit_main' returns once initramfs is detected and skips all later hooks, hence it cannot be used e.g. for loading device tree overlays which should work independently of running in initramfs of not, but needs to happen after rootfs is mounted in the "regular" squashfs+overlayfs case. Hence introduce new hooklist 'preinit_late' which is run after 'preinit_main' has completed. Introduce preinit_late hook to mount configfs and apply device tree overlays from /lib/firmware/device-tree/overlays/*.dtbo on targets which got the 'dt-overlay' feature set. Device tree overlay blobs placed into that folder will be loaded early on boot before AutoProbing kernel modules. Signed-off-by: Daniel Golle <daniel@makrotopia.org> --- package/base-files/Makefile | 6 ++++++ package/base-files/files/etc/preinit | 2 ++ .../files/lib/preinit/90_apply_dt_overlays | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 package/base-files/files/lib/preinit/90_apply_dt_overlays