Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/sh
  2. if [ "$#" -ne 1 ] ; then
  3. echo "Usage: $0 /dev/disk" >&2
  4. exit 1
  5. fi
  6. # Unmount mounted partitions
  7. for fs in `grep $1 /proc/mounts|cut -d ' ' -f 1` ; do
  8. echo Unmounting $fs
  9. sudo umount $fs
  10. done
  11. echo Overwriting old partition table
  12. sudo dd if=/dev/zero of=$1 bs=1024 count=1024
  13. if [ -e output/images/u-boot.sd ] ; then
  14. echo Recreating new partition table
  15. sed 's/#.*//' << EOF | tr -d " \t" | sudo fdisk $1
  16. n # new partition
  17. p # primary partition
  18. 1 # number 1
  19. # default start
  20. +16M # 16MB
  21. t # New Type field
  22. 53 # OnTrack DM6 Aux3
  23. n # new partition
  24. p # primary partition
  25. 2 # number 2
  26. # default start
  27. # default size
  28. w # write changes
  29. EOF
  30. echo Writing U-Boot bootstream
  31. sudo dd if=output/images/u-boot.sd of="$1"1
  32. elif [ -d output/images/rpi-firmware ] ; then
  33. SIZE=`sudo fdisk -l $1 | grep Disk | grep bytes | awk '{print $5}'`
  34. echo Disk size: $SIZE bytes
  35. CYLINDERS=`echo $SIZE/255/63/512 | bc`
  36. echo Cylinders: $CYLINDERS
  37. sed 's/#.*//' << EOF | tr -d " \t" | sudo sfdisk -D -H 255 -S 63 -C $CYLINDERS $1
  38. ,9,0x0C,* # From http://downloads.angstrom-distribution.org/demo/beaglebone/mkcard.txt
  39. ,,,- # Found in http://elinux.org/RPi_Advanced_Setup#Advanced_SD_card_setup
  40. EOF
  41. echo Creaeting boot filesystem
  42. sudo mkfs.vfat -F 32 -n boot "$1"1
  43. echo Mounting boot filesystem
  44. sudo mkdir -p /media/boot
  45. sudo mount "$1"1 /media/boot
  46. echo Copying bootloader files
  47. sudo cp output/images/rpi-firmware/* /media/boot/
  48. if ls output/images/*.dtb > /dev/null 2>&1; then
  49. echo Copying device tree binaries
  50. sudo cp output/images/*.dtb /media/boot/
  51. fi
  52. if [ -x output/host/usr/bin/mkknlimg ] ; then
  53. echo Preparing and copying Kernel Image
  54. sudo output/host/usr/bin/mkknlimg output/images/zImage /media/boot/zImage
  55. else
  56. echo mkknlimg not found, only copying kernel image
  57. sudo cp output/images/zImage /media/boot/zImage
  58. fi
  59. echo Synchronising changes to disk
  60. sudo sync
  61. echo Unmounting boot filesystem
  62. sudo umount /media/boot
  63. sudo rm -rf /media/boot
  64. else
  65. echo Could not find a suitable bootstream!
  66. fi
  67. if [ -e output/images/rootfs.tar ] ; then
  68. echo Creating root filesystem
  69. sudo mkfs.ext4 "$1"2 -L rootfs
  70. echo Mounting root filesystem
  71. sudo mkdir -p /media/rootfs
  72. sudo mount "$1"2 /media/rootfs
  73. echo Copying root filesystem
  74. sudo tar xfp output/images/rootfs.tar -C /media/rootfs
  75. echo Synchronising changes to disk
  76. sudo sync
  77. echo Unmounting root filesystem
  78. sudo umount /media/rootfs
  79. sudo rm -rf /media/rootfs
  80. elif [ -e output/images/rootfs.ext2 ] ; then
  81. echo Writing ext2 root filesystem
  82. sudo dd if=output/images/rootfs.ext2 of="$1"2 bs=512
  83. echo Synchronising changes to disk
  84. sudo sync
  85. else
  86. echo Could not find a suitable root filesystem!
  87. fi
  88. eject $1