Boot the kernel directly from ext4 (drop the FAT partition, image repack and CRC sidecar) #1

Open
opened 2026-08-22 14:54:24 +00:00 by kit · 0 comments
Owner

Today booting Linux takes five steps: build kernel → repack into an Android boot image with a baked-in cmdline → compute CRC32 → write image + .crc sidecar to the SD FAT partition → sdboot loads it, verifies the CRC and boots. That whole apparatus exists only because a raw image on FAT has no integrity check.

U-Boot can already do better — our build has:

CONFIG_CMD_EXT4=y
CONFIG_CMD_EXT4_WRITE=y
CONFIG_CMD_EXT2=y
CONFIG_EFI_PARTITION=y
CONFIG_SCSI=y  CONFIG_CMD_SCSI=y
CONFIG_GZIP=y  CONFIG_CMD_UNZIP=y  CONFIG_CMD_BOOTI=y  CONFIG_FIT=y

So we can load the kernel straight out of the rootfs:

ext4load mmc 0:2 ${kernel_addr_r} /boot/Image.gz     # SD
unzip ${kernel_addr_r} ${loadaddr}
ext4load mmc 0:2 ${fdt_addr_r} /boot/dtbs/qcom/sm8150-samsung-gts6l.dtb
booti ${loadaddr} - ${fdt_addr_r}

…and the same with ext4load scsi 0:N once we install to UFS (see the internal-install issue).

Why this is worth doing

  • Completes the packaging story. linux-gts6l installs /boot/Image.gz and /boot/dtbs/... — exactly what U-Boot would load. Kernel updates become pacman -U, with no repack, no CRC, no manual deploy.
  • Gets the cmdline out of the image. It moves to bootargs in the U-Boot env, which is persistent on UFS and editable from Linux via gts6l-env. Today switching golden↔debug means rebuilding the boot image — the trap that nearly gave us a single-core tablet (maxcpus=1 is build-617.sh's default).
  • Deletes the FAT partition and CRC sidecar entirely.

Steps

  1. Verify U-Boot can actually read our rootfs first: ext4ls mmc 0:2 /boot from the console. Non-destructive, and worth knowing before rewriting sdboot — TWRP's e2fsck already choked on our fs (FEATURE_C12/orphan_file), so U-Boot's ext4 driver may have gaps with newer features.
  2. Add an ext4boot env target alongside sdboot; keep sdboot as fallback until it's proven.
  3. Consider a FIT image instead of raw Image.gz+dtb — hashes are built into the format, so bootm verifies for us and the CRC sidecar concept dies properly rather than being replaced by nothing.

Risk

The rootfs becomes the boot path, so filesystem damage costs booting. Mitigated by the existing fbauto fastboot fallback and by TWRP being untouched on its own partition.

Today booting Linux takes five steps: build kernel → repack into an Android boot image with a baked-in cmdline → compute CRC32 → write image + `.crc` sidecar to the SD FAT partition → `sdboot` loads it, verifies the CRC and boots. That whole apparatus exists only because a raw image on FAT has no integrity check. U-Boot can already do better — our build has: ``` CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_EXT2=y CONFIG_EFI_PARTITION=y CONFIG_SCSI=y CONFIG_CMD_SCSI=y CONFIG_GZIP=y CONFIG_CMD_UNZIP=y CONFIG_CMD_BOOTI=y CONFIG_FIT=y ``` So we can load the kernel straight out of the rootfs: ``` ext4load mmc 0:2 ${kernel_addr_r} /boot/Image.gz # SD unzip ${kernel_addr_r} ${loadaddr} ext4load mmc 0:2 ${fdt_addr_r} /boot/dtbs/qcom/sm8150-samsung-gts6l.dtb booti ${loadaddr} - ${fdt_addr_r} ``` …and the same with `ext4load scsi 0:N` once we install to UFS (see the internal-install issue). ## Why this is worth doing - **Completes the packaging story.** `linux-gts6l` installs `/boot/Image.gz` and `/boot/dtbs/...` — exactly what U-Boot would load. Kernel updates become `pacman -U`, with no repack, no CRC, no manual deploy. - **Gets the cmdline out of the image.** It moves to `bootargs` in the U-Boot env, which is persistent on UFS and editable from Linux via `gts6l-env`. Today switching golden↔debug means rebuilding the boot image — the trap that nearly gave us a single-core tablet (`maxcpus=1` is build-617.sh's default). - **Deletes the FAT partition and CRC sidecar** entirely. ## Steps 1. **Verify U-Boot can actually read our rootfs first**: `ext4ls mmc 0:2 /boot` from the console. Non-destructive, and worth knowing before rewriting `sdboot` — TWRP's `e2fsck` already choked on our fs (`FEATURE_C12`/`orphan_file`), so U-Boot's ext4 driver may have gaps with newer features. 2. Add an `ext4boot` env target alongside `sdboot`; keep `sdboot` as fallback until it's proven. 3. Consider a **FIT image** instead of raw Image.gz+dtb — hashes are built into the format, so `bootm` verifies for us and the CRC sidecar concept dies properly rather than being replaced by nothing. ## Risk The rootfs becomes the boot path, so filesystem damage costs booting. Mitigated by the existing `fbauto` fastboot fallback and by TWRP being untouched on its own partition.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kit/u-boot-gts6l#1
No description provided.