gen_sdcard_vfat_ext4.sh 886 B

12345678910111213141516171819202122232425262728293031323334353637
  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 6 ] || {
  10. echo "SYNTAX: $0 <file> <u-boot.sb image> <bootfs image> <rootfs image> <bootfs size> <rootfs size>"
  11. exit 1
  12. }
  13. OUTPUT="$1"
  14. UBOOT="$2"
  15. BOOTFS="$3"
  16. ROOTFS="$4"
  17. BOOTFSSIZE="$5"
  18. ROOTFSSIZE="$6"
  19. head=4
  20. sect=63
  21. # Set the u-boot storage to 2M
  22. set `ptgen -o $OUTPUT -h $head -s $sect -l 1024 -t 53 -p 2M -t c -p ${BOOTFSSIZE}M -t 83 -p ${ROOTFSSIZE}M`
  23. UBOOTOFFSET="$(($1 / 512))"
  24. UBOOTSIZE="$(($2 / 512))"
  25. BOOTOFFSET="$(($3 / 512))"
  26. BOOTSIZE="$(($4 / 512))"
  27. ROOTFSOFFSET="$(($5 / 512))"
  28. ROOTFSSIZE="$(($6 / 512))"
  29. dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
  30. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc
  31. sdimage -d "$OUTPUT" -f "$UBOOT"