/contrib/angstrom/omap3-mkcard.sh

https://github.com/mkarrman/openembedded · Shell · 79 lines · 47 code · 21 blank · 11 comment · 8 complexity · 23b69f5b90f790ddde8ea18ecb822e53 MD5 · raw file

  1. #! /bin/sh
  2. # mkcard.sh v0.5
  3. # (c) Copyright 2009 Graeme Gregory <dp@xora.org.uk>
  4. # Licensed under terms of GPLv2
  5. #
  6. # Parts of the procudure base on the work of Denys Dmytriyenko
  7. # http://wiki.omap.com/index.php/MMC_Boot_Format
  8. export LC_ALL=C
  9. if [ $# -ne 1 ]; then
  10. echo "Usage: $0 <drive>"
  11. exit 1;
  12. fi
  13. DRIVE=$1
  14. dd if=/dev/zero of=$DRIVE bs=1024 count=1024
  15. SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
  16. echo DISK SIZE - $SIZE bytes
  17. CYLINDERS=`echo $SIZE/255/63/512 | bc`
  18. echo CYLINDERS - $CYLINDERS
  19. {
  20. echo ,9,0x0C,*
  21. echo ,,,-
  22. } | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
  23. sleep 1
  24. if [ -x `which kpartx` ]; then
  25. kpartx -a ${DRIVE}
  26. fi
  27. # handle various device names.
  28. # note something like fdisk -l /dev/loop0 | egrep -E '^/dev' | cut -d' ' -f1
  29. # won't work due to https://bugzilla.redhat.com/show_bug.cgi?id=649572
  30. PARTITION1=${DRIVE}1
  31. if [ ! -b ${PARTITION1} ]; then
  32. PARTITION1=${DRIVE}p1
  33. fi
  34. DRIVE_NAME=`basename $DRIVE`
  35. DEV_DIR=`dirname $DRIVE`
  36. if [ ! -b ${PARTITION1} ]; then
  37. PARTITION1=$DEV_DIR/mapper/${DRIVE_NAME}p1
  38. fi
  39. PARTITION2=${DRIVE}2
  40. if [ ! -b ${PARTITION2} ]; then
  41. PARTITION2=${DRIVE}p2
  42. fi
  43. if [ ! -b ${PARTITION2} ]; then
  44. PARTITION2=$DEV_DIR/mapper/${DRIVE_NAME}p2
  45. fi
  46. # now make partitions.
  47. if [ -b ${PARTITION1} ]; then
  48. umount ${PARTITION1}
  49. mkfs.vfat -F 32 -n "boot" ${PARTITION1}
  50. else
  51. echo "Cant find boot partition in /dev"
  52. fi
  53. if [ -b ${PARITION2} ]; then
  54. umount ${PARTITION2}
  55. mke2fs -j -L "Angstrom" ${PARTITION2}
  56. else
  57. echo "Cant find rootfs partition in /dev"
  58. fi