Skip to content

Per-profile user DT overlay drop-ins (/etc/kernel/dtbo) + add-dtbo#113

Open
Yury-MonZon wants to merge 3 commits into
devfrom
load-dtbo-files
Open

Per-profile user DT overlay drop-ins (/etc/kernel/dtbo) + add-dtbo#113
Yury-MonZon wants to merge 3 commits into
devfrom
load-dtbo-files

Conversation

@Yury-MonZon

Copy link
Copy Markdown
Contributor

What

Lets a user drop device-tree overlays into a per-profile directory and have them applied to that
profile's boot, without rebuilding the image or a full kernel-install. Three parts:

  1. Per-profile user overlays (flipper-bls.sh): every *.dtbo in a profile's
    /etc/kernel/dtbo/ is merged into that profile's BLS devicetree-overlay line, subvol-prefixed
    (/@<subvol>/etc/kernel/dtbo/...), alongside the kernel-shipped profile overlays. Un-versioned,
    so drop-ins survive kernel updates.

  2. Uncompressed DT files (85-flipper-dtb-uncompress.install): U-Boot's btrfs driver can't read
    inline zstd extents (zstd_decompress: failed to decompress: 70), and small files like .dtbo
    get inlined. On every kernel-install add this sets the DT dirs (/usr/lib/linux-image-<ver>/rockchip
    and /etc/kernel/dtbo) to compression=none and rewrites the base .dtb + every .dtbo
    uncompressed. This also un-breaks the pre-existing kernel-shipped overlays (e.g. hdmi-cec).

  3. add-dtbo CLI: apply/manage a profile's drop-in overlays in-place (rewrites only the booted
    profile's devicetree-overlay line via sed, no re-staging/initrd rebuild):

    • add-dtbo FILE.dtbo ... copy in + apply (multiple at once)
    • add-dtbo --rm NAME ... remove named overlay(s) + apply
    • add-dtbo --clear remove all (deletes the files, durable across kernel updates)
    • add-dtbo --apply re-sync the entry to the dir
    • add-dtbo --list, add-dtbo --help; --all-kernels scopes to every installed kernel
      Bare invocation prints usage; unknown options are rejected.

Why the uncompress step

The root subvol is compress=zstd, so a freshly written .dtbo is compressed and U-Boot fails to
load it. compression=none on the containing dir (inherited by new files; existing extents rewritten)
is the same approach already used for /boot.

On-device validation (flipper1, @minimal)

  • Adding one/multiple overlays updates only the booted profile + running-kernel entry, subvol-prefixed
    and uncompressed; U-Boot boot log shows it retrieving/applying /@Minimal/etc/kernel/dtbo/<x>.dtbo,
    and /proc/device-tree/<node> confirms it took effect after reboot.
  • --rm drops just the named overlay; --clear empties the dir and the line.
  • Non-root apt/tooling paths and -h behave correctly.

Apply every *.dtbo a user drops in a profile's /etc/kernel/dtbo/ to that
profile's BLS entries. emit_entry merges them (subvol-prefixed, after the
profile-declared overlays) into the devicetree-overlay line; flipper_write_entry
scans the target root so clones pick up their own. Silent when the dir is empty.
@Yury-MonZon
Yury-MonZon requested a review from a team July 9, 2026 17:05
U-Boot's btrfs driver can't decompress inline zstd extents, so small
zstd-compressed .dtbo overlays fail to load (zstd_decompress error 70).
On every kernel-install add, set the kernel rockchip/ DT dir and
/etc/kernel/dtbo to compression=none and rewrite the flipper base .dtb
+ overlays uncompressed (property alone only affects future writes).
Covers build-time and future/runtime kernel installs; clones inherit
via COW.

Also create /etc/kernel/dtbo compression=none in the image build,
before @Minimal_stock is snapshotted, so every profile root carries
the property via COW even ahead of the kernel-install hook.
flipper-bls.sh: dt_overlay_line (+profile-only) shared by emit_entry and the new
flipper_rewrite_overlay; add-dtbo (--list/--clear/--all-kernels, or copy FILE.dtbo)
rewrites only the booted profile+kernel entry's devicetree-overlay line, no kernel-install.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant