7012d7b97579d6747d1f0f49aa8c1269f6ffcca4
[openwrt.git] / target / linux / adm8668 / image / my-mkimage
1 #!/bin/sh
2 # my-mkimage
3 # This will just pad the kernel partition to 64k boundary, then add rootfs.
4 # but we have to be fancy because u-boot mkimage is going to add 64 byte header.
5 #
6 # Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>
7
8 PATH_LOADER=$1
9 PATH_ROOTFS=$2
10 OUTPUT=$3
11
12 # todo - check arguments...? nah...
13 if [ -x $OUTPUT ]; then
14   echo usage: $0 loader.bin root.squashfs output.bin
15   exit
16 fi
17
18 OLDSIZE=$(stat -c%s $PATH_LOADER)
19 NEWSIZE=$(((OLDSIZE / 65536 + 1) * 65536 - 64))
20
21 dd if=$PATH_LOADER of=vmlinuz.tmp bs=$NEWSIZE conv=sync
22 cat $PATH_ROOTFS >>vmlinuz.tmp
23 ../../../../staging_dir/host/bin/mkimage -A mips -O linux -T kernel -C none -a 0x400000 -e 0x400000 -n "ADM8668 Linux Kernel(2.4.31)" -d vmlinuz.tmp $OUTPUT
24 rm vmlinuz.tmp
25
26 printf '\n\nOk done, now your squashfs starts on an erase boundary of %x :)\n\n' $((NEWSIZE+64))