openwrtv3/target/linux/zynq/image/gen_zynq_sdcard_img.sh
Luis Araneda 412763c812 zynq: add sdcard image support
Implement the generation of sdcard images with ext4 or
squashfs + f2fs overlay, but only enable the latter
automatically

Additionally, add mkf2fs and e2fsprogs to default packages
to manipulate ext4 and f2fs filesystems

Finally, disable the automatic generation of initramfs
and rootfs.tar.gz images, as they are no longer required
(they can still be selected in menuconfig)

Signed-off-by: Luis Araneda <luaraneda@gmail.com>
2018-09-10 08:55:39 +02:00

26 lines
578 B
Bash
Executable file

#!/usr/bin/env bash
set -ex
[ $# -eq 5 ] || {
echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
exit 1
}
OUTPUT="$1"
BOOTFS="$2"
ROOTFS="$3"
BOOTFSSIZE="$4"
ROOTFSSIZE="$5"
head=4
sect=63
set $(ptgen -o $OUTPUT -h $head -s $sect -l 1024 -t c -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M)
BOOTOFFSET="$(($1 / 512))"
BOOTSIZE="$(($2 / 512))"
ROOTFSOFFSET="$(($3 / 512))"
ROOTFSSIZE="$(($4 / 512))"
dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc