gen_sdcard_ext4_ext4.sh 800 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (C) 2015 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 -x
  9. [ $# -eq 4 ] || {
  10. echo "SYNTAX: $0 <file> <u-boot.sb image> <rootfs image> <rootfs size>"
  11. exit 1
  12. }
  13. OUTPUT="$1"
  14. UBOOT="$2"
  15. ROOTFS="$3"
  16. ROOTFSSIZE="$4"
  17. head=4
  18. sect=63
  19. # set the Boot stream partition size to 1M
  20. set `ptgen -o $OUTPUT -h $head -s $sect -l 1024 -t 53 -p 1M -t 83 -p ${ROOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M`
  21. ROOTFS1OFFSET="$(($3 / 512))"
  22. ROOTFS1SIZE="$(($4 / 512))"
  23. ROOTFS2OFFSET="$(($5 / 512))"
  24. ROOTFS2SIZE="$(($6 / 512))"
  25. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFS1OFFSET" conv=notrunc
  26. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFS2OFFSET" conv=notrunc
  27. sdimage -d "$OUTPUT" -f "$UBOOT"