| 1 | #!/bin/sh |
| 2 | # my-mkimage |
| 3 | # This will pad given files to 64k boundaries to make a single u-boot image. |
| 4 | # we have to be fancy because u-boot mkimage is going to add 64 byte header, ... |
| 5 | # and i only know basic arithmetic.. ;) |
| 6 | # |
| 7 | # Copyright (C) 2010 Scott Nicholas <neutronscott@scottn.us> |
| 8 | [ $# -lt 2 ] && { |
| 9 | echo usage: $0 loader.bin [rootfs.squashfs [fs_mark [...]]] output.bin |
| 10 | } |
| 11 | |
| 12 | OLDSIZE=$(stat -c%s $1) |
| 13 | NEWSIZE=$(((OLDSIZE / 65536 + 1) * 65536 - 64)) |
| 14 | |
| 15 | dd if=$1 of=vmlinuz.tmp bs=$NEWSIZE conv=sync >/dev/null 2>&1 |
| 16 | shift |
| 17 | appends=$(($# - 1)) |
| 18 | echo |
| 19 | while [ $appends -gt 0 ]; do |
| 20 | dd if=$1 of=temp bs=64k conv=sync >/dev/null 2>&1 |
| 21 | printf "### '%s' starts at 0x%x\n" "`basename $1`" "$((NEWSIZE+64))" |
| 22 | cat temp >>vmlinuz.tmp |
| 23 | shift |
| 24 | appends=$((appends-1)) |
| 25 | NEWSIZE=$(stat -c%s vmlinuz.tmp) |
| 26 | done |
| 27 | echo |
| 28 | ../../../../staging_dir/host/bin/mkimage -A mips -O linux -T kernel \ |
| 29 | -C none -a 0x80400000 -e 0x80400000 -n "ADM8668 Linux Kernel(2.4.31)" \ |
| 30 | -d vmlinuz.tmp $1 |
| 31 | |
| 32 | rm temp vmlinuz.tmp |
| 33 | |