Writes a bootable BeagleY-AI SD card image without root, loop devices, mtools or e2fsprogs.
shards build --release
SOURCE_DATE_EPOCH=$(date +%s) bin/cleave-image -o sd.img \
--boot boot/ --root bq2-rootfs-0.4.0-arm64.tar.gz [--root overlay.tar]
Layout
| Part | Start | Type | Contents |
|---|---|---|---|
| MBR | 0 | Disk signature from the inputs; CHS for 255 heads/63 sectors | |
| 1 | 1 MiB | 0x0e FAT16 "BOOT", active | tiboot3.bin, tispl.bin, u-boot.img, Image, dtb/, extlinux/extlinux.conf |
| 2 | after boot | 0x83 ext2 "root" | The --root archives, with ownership, modes, links and devices |
The kernel goes on the FAT partition, as Armbian does for this board. U-Boot's
bootflow scan (BeagleY-AI's bootcmd) only searches bootable partitions when any partition
is marked bootable, and the K3 ROM wants the FAT partition marked. So partition 1 must hold
extlinux/extlinux.conf. The running system should mount partition 1 at /boot.
Pieces
src/cleave/tar_reader.cr: streaming ustar/pax/GNU tar reader.src/cleave/ext2.cr: ext2 rev 1 writer (4 KiB blocks, 256-byte inodes, sparse superblocks).src/cleave/fat16.cr: FAT16 writer with VFAT long names.src/cleave/sd_image.cr: MBR and assembly.
Checked
With the BQ2 0.4.0 arm64 seed (43,620 entries, 2 GB) and Armbian's BeagleY-AI boot files:
- Partition 1 passes
fsck.fat -n(dosfstools 4.2). pyfatfs reads the files back, andtiboot3.binis byte-identical. - Partition 2 passes
e2fsck -fn(e2fsprogs 1.47.1). debugfs shows the content matches the tarball. - Reproducible: two runs with the same
SOURCE_DATE_EPOCHgive the same SHA-256. - Speed: about 14 s on 8 cores.
Not yet tried on hardware.
Secrets
Don't put Wi-Fi passwords or logins into --root archives that are committed or published.
First-boot settings will come from a file on the boot partition, written from an uncommitted
local copy. local/ is in this repository's ignore list for such files.