56 lines
1.1 KiB
Plaintext
56 lines
1.1 KiB
Plaintext
|
#!/usr/bin/env bash
|
||
|
|
||
|
DEVICES=$(mpremote connect list | grep MicroPython | cut -d " " -f 1)
|
||
|
|
||
|
if [ -z $DEVICES ] ; then
|
||
|
echo "No MicroPython devices found in FS mode"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
DEVICE=${DEVICES[0]}
|
||
|
|
||
|
echo "Copying firmware files to ${DEVICE}"
|
||
|
|
||
|
function create_directory {
|
||
|
echo -n "> creating directory $1"
|
||
|
|
||
|
RESULT=$(mpremote connect ${DEVICE} mkdir $1)
|
||
|
ERROR=$?
|
||
|
|
||
|
|
||
|
if [ $ERROR -eq 0 ] ; then
|
||
|
echo " .. done!"
|
||
|
else
|
||
|
if [[ "$RESULT" == *"EEXIST"* ]] ; then
|
||
|
echo " .. already exists, skipping."
|
||
|
else
|
||
|
echo " .. failed!"
|
||
|
echo "! it looks like this device is already in use - is Thonny running?"
|
||
|
exit 1
|
||
|
fi
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
function copy {
|
||
|
for file in $1
|
||
|
do
|
||
|
echo -n "> copying file $file"
|
||
|
mpremote connect ${DEVICE} cp $file $2 > /dev/null
|
||
|
if [ $? -eq 0 ] ; then
|
||
|
echo " .. done!"
|
||
|
else
|
||
|
echo " .. failed!"
|
||
|
fi
|
||
|
done
|
||
|
}
|
||
|
|
||
|
|
||
|
create_directory networking
|
||
|
create_directory sensors
|
||
|
create_directory www
|
||
|
|
||
|
copy "main.py" :
|
||
|
copy "networking/*.py" :networking/
|
||
|
copy "sensors/*.py" :sensors/
|
||
|
copy "www/*" :www/
|