gen_mxs_sdcard_img.sh 920 B

1234567891011121314151617181920212223242526272829303132333435363738
  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> <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 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="$UBOOT" of="$OUTPUT" seek="$UBOOTOFFSET" conv=notrunc
  30. dd bs=512 if="$BOOTFS" of="$OUTPUT" seek="$BOOTOFFSET" conv=notrunc
  31. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc