| 40 | |
| 41 | '''Using a shell script to copy a .bin file to the SD card:'''[[BR]] |
| 42 | The following script automatically looks for the file descriptor of the SD card and copies the .bin file to the chosen slot. To execute the script: |
| 43 | 1. copy the script to a text file |
| 44 | 1. save it under the name copytosd.sh |
| 45 | 1. make it executable (chmod +x copytosd.sh) |
| 46 | 1. run it as root: sudo ./copytosd.sh. |
| 47 | {{{ |
| 48 | #!/bin/sh |
| 49 | # Author: Matthias Schulz <mschulz@seemoo.tu-darmstadt.de> |
| 50 | # The author is not responsible for the consequences of use of this script |
| 51 | |
| 52 | # Check if at least two arguments are passed |
| 53 | if [ $# -lt 2 ] |
| 54 | then |
| 55 | echo "Usage : ./copytosd.sh filename slot [description]" |
| 56 | exit |
| 57 | fi |
| 58 | |
| 59 | if [ $# -eq 3 ] |
| 60 | then |
| 61 | find "/Volumes/WARP SD" -name "`printf \"Slot %s - *\" \"$2\"`" -delete |
| 62 | FILE="/Volumes/WARP SD/`printf \"Slot %s - %s\" \"$2\" \"$3\"`" |
| 63 | echo "" > $FILE |
| 64 | fi |
| 65 | |
| 66 | DISK=/dev/`diskutil list | grep "WARP SD" | cut -c 69-73` |
| 67 | |
| 68 | diskutil unmountDisk $DISK |
| 69 | |
| 70 | case "$2" in |
| 71 | 0) dd bs=512 seek=131072 if=$1 of=$DISK |
| 72 | ;; |
| 73 | 1) dd bs=512 seek=163840 if=$1 of=$DISK |
| 74 | ;; |
| 75 | 2) dd bs=512 seek=196608 if=$1 of=$DISK |
| 76 | ;; |
| 77 | 3) dd bs=512 seek=229376 if=$1 of=$DISK |
| 78 | ;; |
| 79 | 4) dd bs=512 seek=262144 if=$1 of=$DISK |
| 80 | ;; |
| 81 | 5) dd bs=512 seek=294912 if=$1 of=$DISK |
| 82 | ;; |
| 83 | 6) dd bs=512 seek=327680 if=$1 of=$DISK |
| 84 | ;; |
| 85 | 7) dd bs=512 seek=360448 if=$1 of=$DISK |
| 86 | ;; |
| 87 | *) echo "Error: use a slot number between 0 and 7" |
| 88 | exit |
| 89 | ;; |
| 90 | esac |
| 91 | |
| 92 | diskutil unmountDisk $DISK |
| 93 | }}} |