2017-10-24 06:15:02 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-04-27 17:25:07 +08:00
|
|
|
FULLIMAGE="armsrc/obj/fullimage.elf"
|
|
|
|
BOOTIMAGE="bootrom/obj/bootrom.elf"
|
|
|
|
|
|
|
|
cd $(dirname "$0")
|
|
|
|
|
2018-08-17 00:31:12 +08:00
|
|
|
function wait4proxmark_Linux {
|
2019-03-09 18:10:22 +08:00
|
|
|
echo >&2 "Waiting for Proxmark to appear..."
|
2019-03-14 19:30:32 +08:00
|
|
|
while [ ! -c /dev/ttyACM? -a ! -c /dev/pm3-? ]; do
|
2019-03-09 18:10:22 +08:00
|
|
|
sleep .1
|
|
|
|
done
|
|
|
|
local PM3=`ls -1 /dev/pm3-? /dev/ttyACM? 2>/dev/null | head -1`
|
|
|
|
echo >&2 -e "Found proxmark on ${PM3}\n"
|
|
|
|
echo $PM3
|
2017-10-24 06:15:02 +08:00
|
|
|
}
|
|
|
|
|
2018-08-16 22:22:54 +08:00
|
|
|
function wait4proxmark_macOS {
|
2019-03-09 18:10:22 +08:00
|
|
|
echo >&2 "Waiting for Proxmark to appear..."
|
|
|
|
while true; do
|
|
|
|
PM3=$(ls /dev/pm3-* /dev/cu.usbmodem* 2>/dev/null | head -1)
|
|
|
|
if [[ $PM3 != "" ]]; then
|
|
|
|
#echo >&2 -e "Found proxmark on $(ls /dev/pm3-* /dev/cu.usbmodem* 2>/dev/null | head -1)\n"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep .1
|
|
|
|
done
|
|
|
|
echo $PM3
|
2018-08-16 22:22:54 +08:00
|
|
|
}
|
|
|
|
|
2019-07-03 20:16:16 +08:00
|
|
|
function wait4proxmark_Windows {
|
|
|
|
echo >&2 "Waiting for Proxmark to appear..."
|
|
|
|
while true; do
|
|
|
|
device=$(wmic path Win32_SerialPort get DeviceID,PNPDeviceID 2>/dev/null | awk 'NR==2')
|
|
|
|
if [[ $device =~ VID_9AC4\&PID_4B8F ]]; then
|
|
|
|
PM3=${device/ */}
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep .1
|
|
|
|
done
|
|
|
|
echo $PM3
|
|
|
|
}
|
|
|
|
|
2019-04-27 17:25:07 +08:00
|
|
|
SCRIPT=$(basename -- "$0")
|
2018-08-16 22:22:54 +08:00
|
|
|
|
2019-04-27 17:25:07 +08:00
|
|
|
if [ "$SCRIPT" = "proxmark3.sh" ]; then
|
|
|
|
CMD=client/proxmark3
|
|
|
|
elif [ "$SCRIPT" = "flash-all.sh" ]; then
|
|
|
|
CMD=client/flasher
|
|
|
|
ARG1="-b $BOOTIMAGE"
|
|
|
|
ARG2="$FULLIMAGE"
|
|
|
|
elif [ "$SCRIPT" = "flash-fullimage.sh" ]; then
|
|
|
|
CMD=client/flasher
|
|
|
|
ARG2="$FULLIMAGE"
|
|
|
|
elif [ "$SCRIPT" = "flash-bootrom.sh" ]; then
|
|
|
|
CMD=client/flasher
|
|
|
|
ARG1="-b $BOOTIMAGE"
|
|
|
|
else
|
|
|
|
echo "Script ran under unknown name, abort: $SCRIPT"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
HOSTOS=$(uname | awk '{print toupper($0)}')
|
|
|
|
if [ "$HOSTOS" = "LINUX" ]; then
|
|
|
|
PORT=$(wait4proxmark_Linux)
|
|
|
|
elif [ "$HOSTOS" = "DARWIN" ]; then
|
|
|
|
PORT=$(wait4proxmark_macOS)
|
2019-07-03 20:16:16 +08:00
|
|
|
elif [[ "$HOSTOS" =~ MINGW(32|64)_NT* ]]; then
|
|
|
|
PORT=$(wait4proxmark_Windows)
|
2019-04-27 17:25:07 +08:00
|
|
|
else
|
|
|
|
echo "Host OS not recognized, abort: $HOSTOS"
|
|
|
|
exit 1
|
2018-08-16 22:22:54 +08:00
|
|
|
fi
|
2019-04-27 17:25:07 +08:00
|
|
|
if [ "$PORT" = "" ]; then
|
|
|
|
echo "No port, abort"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-03 17:25:05 +08:00
|
|
|
#echo Running "$CMD" "$PORT" $ARG1 $ARG2 "$@"
|
2019-04-27 17:25:07 +08:00
|
|
|
"$CMD" "$PORT" $ARG1 $ARG2 "$@"
|
|
|
|
exit $?
|