2 # Copyright (C) 2006-2012 OpenWrt.org
4 if [ $# -ne 5 ] && [ $# -ne 6 ]; then
5 echo "SYNTAX: $0 <file> <kernel size> <kernel directory> <rootfs size> <rootfs image> [<align>]"
21 # create partition table
22 set $
(ptgen
-o "$OUTPUT" -h $head -s $sect ${GUID:+-g} -p "${KERNELSIZE}m" -p "${ROOTFSSIZE}m" ${ALIGN:+-l $ALIGN} ${SIGNATURE:+-S 0x$SIGNATURE} ${GUID:+-G $GUID})
24 KERNELOFFSET
="$(($1 / 512))"
26 ROOTFSOFFSET
="$(($3 / 512))"
27 ROOTFSSIZE
="$(($4 / 512))"
29 [ -n "$PADDING" ] && dd if=/dev
/zero of
="$OUTPUT" bs
=512 seek
="$ROOTFSOFFSET" conv
=notrunc count
="$ROOTFSSIZE"
30 dd if="$ROOTFSIMAGE" of
="$OUTPUT" bs
=512 seek
="$ROOTFSOFFSET" conv
=notrunc
32 if [ -n "$GUID" ]; then
33 [ -n "$PADDING" ] && dd if=/dev
/zero of
="$OUTPUT" bs
=512 seek
="$((ROOTFSOFFSET + ROOTFSSIZE))" conv
=notrunc count
="$sect"
34 mkfs.fat
-n kernel
-C "$OUTPUT.kernel" -S 512 "$((KERNELSIZE / 1024))"
35 mcopy
-s -i "$OUTPUT.kernel" "$KERNELDIR"/* ::/
37 make_ext4fs
-J -L kernel
-l "$KERNELSIZE" "$OUTPUT.kernel" "$KERNELDIR"
39 dd if="$OUTPUT.kernel" of
="$OUTPUT" bs
=512 seek
="$KERNELOFFSET" conv
=notrunc
40 rm -f "$OUTPUT.kernel"