my-mkimage 973 B

1234567891011121314151617181920212223242526272829303132
  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. OLDSIZE=$(stat -c%s $1)
  12. NEWSIZE=$(((OLDSIZE / 65536 + 1) * 65536 - 64))
  13. dd if=$1 of=vmlinuz.tmp bs=$NEWSIZE conv=sync >/dev/null 2>&1
  14. shift
  15. appends=$(($# - 1))
  16. echo
  17. while [ $appends -gt 0 ]; do
  18. dd if=$1 of=temp bs=64k conv=sync >/dev/null 2>&1
  19. printf "### '%s' starts at 0x%x\n" "`basename $1`" "$((NEWSIZE+64))"
  20. cat temp >>vmlinuz.tmp
  21. shift
  22. appends=$((appends-1))
  23. NEWSIZE=$(stat -c%s vmlinuz.tmp)
  24. done
  25. echo
  26. ../../../../staging_dir/host/bin/mkimage -A mips -O linux -T kernel \
  27. -C none -a 0x80400000 -e 0x80400000 -n "ADM8668 Linux Kernel(2.4.31)" \
  28. -d vmlinuz.tmp $1
  29. rm temp vmlinuz.tmp