2021-12-18 20:56:45 +00:00
|
|
|
#!/bin/bash +ex
|
|
|
|
|
|
|
|
dd if=/dev/zero of=build/rpi.img bs=1M count=4096
|
|
|
|
# Copy the first 8k from the original rpi.img, which seems to have
|
2021-12-20 02:17:33 +00:00
|
|
|
# non-zeroed content. Without this, the Pi doesn't seem to boot.
|
|
|
|
# It could be that there is the binary boot blob for the GPU
|
|
|
|
# in that section?
|
|
|
|
dd if=rpi.img of=build/rpi.img bs=8192 count=1 conv=notrunc
|
2021-12-18 20:56:45 +00:00
|
|
|
sudo losetup -Pf build/rpi.img
|
|
|
|
# Partition:
|
|
|
|
# start: 8192, size 256M typ W95 FAT32
|
|
|
|
DEVICE=$(losetup -j build/rpi.img | cut -d ':' -f 1)
|
2021-12-20 02:17:33 +00:00
|
|
|
parted --script "${DEVICE}" \
|
|
|
|
rm 2 \
|
|
|
|
mkpart primary ext4 272629760B 4022337536B
|
2021-12-18 20:56:45 +00:00
|
|
|
mkfs.vfat "${DEVICE}p1"
|
|
|
|
mkfs.ext4 "${DEVICE}p2"
|
|
|
|
TMP=$(mktemp -d)
|
|
|
|
mount "${DEVICE}p1" "$TMP"
|
|
|
|
tar -C "$TMP" -xf build/all.tar --strip=1 boot/
|
|
|
|
umount "$TMP"
|
|
|
|
mount "${DEVICE}p2" "$TMP"
|
|
|
|
tar -C "$TMP" -xf build/all.tar --exclude='boot/*'
|
|
|
|
umount "$TMP"
|
|
|
|
losetup -D "${DEVICE}"
|
|
|
|
rm -rf "$TMP"
|