Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kernel/configs/vamos.config
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,10 @@ CONFIG_TOUCHSCREEN_S6SY761=y
CONFIG_EXPERT=y
CONFIG_GPIO_SYSFS=y

# EROFS
CONFIG_EROFS_FS=y
CONFIG_EROFS_FS_ZIP=y
CONFIG_EROFS_FS_ZIP_LZ4=y

# Misc
CONFIG_LOCALVERSION_AUTO=n
16 changes: 15 additions & 1 deletion tools/build/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,24 @@ RUN apk add --no-cache \
git \
libcap \
linux-headers \
lz4-dev \
openssl \
openssl-dev \
perl \
python3
python3 \
util-linux-dev \
xz-dev

# Build erofs-utils from source (not packaged in Alpine)
RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git /tmp/erofs-utils \
&& cd /tmp/erofs-utils \
&& git checkout v1.8.5 \
&& apk add --no-cache autoconf automake libtool \
&& autoreconf -fi \
&& ./configure --enable-lz4 --enable-lzma --disable-fuse \
&& make -j$(nproc) \
&& make install \
&& rm -rf /tmp/erofs-utils

# Cross-compiler for x86_64 hosts building aarch64 kernel
# gcc-aarch64-none-elf is bare-metal but works for kernel (freestanding code)
Expand Down
23 changes: 23 additions & 0 deletions tools/build/build_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ MOUNT_CONTAINER_ID="$MOUNT_CONTAINER_ID" ROOTFS_DIR="$ROOTFS_DIR" \
ROOTFS_IMAGE="$ROOTFS_IMAGE" OUTPUT_DIR="$OUTPUT_DIR" \
"$DIR/vamos" profile

# Build EROFS image (before unmount, while rootfs is still mounted)
EROFS_IMAGE="$BUILD_DIR/system.erofs.img"
OUT_EROFS_IMAGE="$OUTPUT_DIR/system.erofs.img"
echo "Building EROFS image (LZ4HC, 64K clusters)"
exec_as_root mkfs.erofs \
-zlz4hc,12 \
-C65536 \
-T0 \
--all-root \
"$EROFS_IMAGE" "$ROOTFS_DIR"

# Unmount image
echo "Unmount filesystem"
exec_as_root umount -l "$ROOTFS_DIR"
Expand All @@ -137,6 +148,9 @@ exec_as_root umount -l "$ROOTFS_DIR"
echo "Sparsifying system image"
exec_as_user img2simg "$ROOTFS_IMAGE" "$OUT_IMAGE"

# Copy EROFS image to output
cp "$EROFS_IMAGE" "$OUT_EROFS_IMAGE"

# Patch sparse image size into profile JSON
SPARSE_SIZE=$(stat -c%s "$OUT_IMAGE" 2>/dev/null || stat -f%z "$OUT_IMAGE")
if command -v jq &>/dev/null; then
Expand All @@ -145,4 +159,13 @@ if command -v jq &>/dev/null; then
mv "$OUTPUT_DIR/rootfs-profile.json.tmp" "$OUTPUT_DIR/rootfs-profile.json"
fi

# Size comparison
EXT4_SPARSE_SIZE=$(stat -c%s "$OUT_IMAGE" 2>/dev/null || stat -f%z "$OUT_IMAGE")
EROFS_SIZE=$(stat -c%s "$OUT_EROFS_IMAGE" 2>/dev/null || stat -f%z "$OUT_EROFS_IMAGE")
echo ""
echo "=== Image size comparison ==="
echo "ext4 (sparse): $(numfmt --to=iec-i --suffix=B "$EXT4_SPARSE_SIZE") ($EXT4_SPARSE_SIZE bytes)"
echo "EROFS (LZ4HC): $(numfmt --to=iec-i --suffix=B "$EROFS_SIZE") ($EROFS_SIZE bytes)"
echo ""

echo "Done!"
Loading