gen_socfpga_sdcard_img.sh 886 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 5 ] || {
  10. echo "SYNTAX: $0 <file> <rootfs image> <rootfs size> <u-boot image> <cfg image>"
  11. exit 1
  12. }
  13. OUTPUT="$1"
  14. ROOTFS="$2"
  15. ROOTFSSIZE="$3"
  16. UBOOT="$4"
  17. CFGFS="$5"
  18. head=4
  19. sect=63
  20. set `ptgen -o $OUTPUT -h $head -s $sect -l 1024 \
  21. -t a2 -p 1M \
  22. -t 83 -p ${ROOTFSSIZE}M \
  23. -t 83 -p 1M`
  24. UBOOTOFFSET="$(($1 / 512))"
  25. UBOOTSIZE="$(($2 / 512))"
  26. ROOTFSOFFSET="$(($3 / 512))"
  27. ROOTFSSIZE="$(($4 / 512))"
  28. CFGFSOFFSET="$(($5 / 512))"
  29. CFGFSSIZE="$(($6 / 512))"
  30. dd bs=512 if="$UBOOT" of="$OUTPUT" seek="$UBOOTOFFSET" conv=notrunc
  31. dd bs=512 if="$ROOTFS" of="$OUTPUT" seek="$ROOTFSOFFSET" conv=notrunc
  32. mkdosfs "$CFGFS" -C 1024
  33. dd bs=512 if="$CFGFS" of="$OUTPUT" seek="$CFGFSOFFSET" conv=notrunc