gen_sunxi_sdcard_img.sh 810 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (C) 2013 OpenWrt.org
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. set -ex
  9. [ $# -eq 6 ] || {
  10. echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size> <u-boot image>"
  11. exit 1
  12. }
  13. OUTPUT="$1"
  14. BOOTFS="$2"
  15. ROOTFS="$3"
  16. BOOTFSSIZE="$4"
  17. ROOTFSSIZE="$5"
  18. UBOOT="$6"
  19. head=4
  20. sect=63
  21. set `ptgen -o $OUTPUT -h $head -s $sect -l 1024 -t c -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M`
  22. BOOTOFFSET="$(($1 / 512))"
  23. BOOTSIZE="$(($2 / 512))"
  24. ROOTFSOFFSET="$(($3 / 512))"
  25. ROOTFSSIZE="$(($4 / 512))"
  26. dd bs=1024 if="$UBOOT" of="$OUTPUT" seek=8 conv=notrunc
  27. dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
  28. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc