gen_axs10x_sdcard_img.sh 728 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (C) 2016 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 5 ] || {
  10. echo "SYNTAX: $0 <file> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
  11. exit 1
  12. }
  13. OUTPUT="$1"
  14. BOOTFS="$2"
  15. ROOTFS="$3"
  16. BOOTFSSIZE="$4"
  17. ROOTFSSIZE="$5"
  18. head=4
  19. sect=63
  20. set `ptgen -o $OUTPUT -h $head -s $sect -l 1024 -t c -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M`
  21. BOOTOFFSET="$(($1 / 512))"
  22. BOOTSIZE="$(($2 / 512))"
  23. ROOTFSOFFSET="$(($3 / 512))"
  24. ROOTFSSIZE="$(($4 / 512))"
  25. dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
  26. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc