summaryrefslogtreecommitdiffstats
path: root/target/linux/adm8668/image/my-mkimage
blob: 7012d7b97579d6747d1f0f49aa8c1269f6ffcca4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
# my-mkimage
# This will just pad the kernel partition to 64k boundary, then add rootfs.
# but we have to be fancy because u-boot mkimage is going to add 64 byte header.
#
# Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us>

PATH_LOADER=$1
PATH_ROOTFS=$2
OUTPUT=$3

# todo - check arguments...? nah...
if [ -x $OUTPUT ]; then
  echo usage: $0 loader.bin root.squashfs output.bin
  exit
fi

OLDSIZE=$(stat -c%s $PATH_LOADER)
NEWSIZE=$(((OLDSIZE / 65536 + 1) * 65536 - 64))

dd if=$PATH_LOADER of=vmlinuz.tmp bs=$NEWSIZE conv=sync
cat $PATH_ROOTFS >>vmlinuz.tmp
../../../../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
rm vmlinuz.tmp

printf '\n\nOk done, now your squashfs starts on an erase boundary of %x :)\n\n' $((NEWSIZE+64))