Skip to content

Commit 2b1e94c

Browse files
committed
kernel/install.d: store DT files uncompressed for U-Boot
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.
1 parent e00d417 commit 2b1e94c

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

debian-rk3576-img.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ actions:
110110
mkdir -p "$IMAGEMNTDIR/var/log/journal"
111111
chattr +C "$IMAGEMNTDIR/var/log/journal"
112112
113+
# U-Boot can't read inline-zstd .dtbo overlays, so the DT drop-in dir must be
114+
# compression=none for later drop-ins to inherit it. Set before @Minimal_stock so
115+
# every profile snapshot carries it via COW.
116+
- action: run
117+
description: Ship /etc/kernel/dtbo uncompressed for U-Boot overlay reads
118+
chroot: false
119+
command: |
120+
set -eu
121+
mkdir -p "$IMAGEMNTDIR/etc/kernel/dtbo"
122+
btrfs property set "$IMAGEMNTDIR/etc/kernel/dtbo" compression none
123+
113124
- action: overlay
114125
description: Copy Linux kernel packages into the target
115126
source: {{ $kerneldir }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: LGPL-2.1-or-later
3+
#
4+
# Store the device-tree files U-Boot reads UNCOMPRESSED. U-Boot's btrfs driver cannot
5+
# decompress *inline* zstd extents (regular extents are fine), so small zstd-compressed
6+
# .dtbo overlays fail to load ("zstd_decompress: failed to decompress: 70"). btrfs stores
7+
# small files inline, so overlays are exactly the affected case.
8+
#
9+
# Fix: set the DT dirs to compression=none (new files inherit it) and rewrite the small,
10+
# inline-prone files (the flipper base .dtb + every .dtbo) so their existing extents are
11+
# uncompressed too. Runs on every kernel-install add (build-time apt install AND any later
12+
# install), so new kernels are covered. Idempotent; no-op off btrfs. Ordered before
13+
# 90-loaderentry.install (which then references these files in devicetree-overlay=).
14+
set -e
15+
16+
[ "$KERNEL_INSTALL_LAYOUT" = bls ] || exit 0
17+
[ "$1" = add ] || exit 0
18+
KERNEL_VERSION="$2"
19+
command -v btrfs >/dev/null 2>&1 || exit 0
20+
21+
# rewrite a file so its data lands uncompressed (inherits the dir's compression=none);
22+
# --reflink=never forces a real copy, not an extent-sharing reflink. Best-effort.
23+
uncompress() {
24+
[ -f "$1" ] || return 0
25+
if cp --reflink=never -p "$1" "$1.tmp" && mv -f "$1.tmp" "$1"; then return 0; fi
26+
rm -f "$1.tmp" 2>/dev/null || :
27+
echo "85-flipper-dtb-uncompress: could not rewrite $1 uncompressed" >&2
28+
}
29+
30+
# kernel-shipped DTBs/overlays (build-kernel-bsp installs them here, board-prefixed)
31+
D="/usr/lib/linux-image-$KERNEL_VERSION/rockchip"
32+
if [ -d "$D" ]; then
33+
btrfs property set "$D" compression none 2>/dev/null || exit 0 # not btrfs -> nothing to do
34+
for f in "$D"/rk3576-flipper-one*.dtb "$D"/*.dtbo; do
35+
uncompress "$f"
36+
done
37+
fi
38+
39+
# user overlay drop-in dir (version-independent): create it uncompressed so a later
40+
# `cp x.dtbo /etc/kernel/dtbo/` inherits compression=none, AND rewrite anything already
41+
# there in case it was dropped in while the dir was still compressible.
42+
install -d -m 755 /etc/kernel/dtbo
43+
btrfs property set /etc/kernel/dtbo compression none 2>/dev/null || :
44+
for f in /etc/kernel/dtbo/*.dtbo; do
45+
uncompress "$f"
46+
done
47+
48+
exit 0

0 commit comments

Comments
 (0)