Skip to content

Commit

Permalink
software/scripts: Split firmware flash and micropython update
Browse files Browse the repository at this point in the history
Add a 2nd script to update the micropython code separately from
reflashing the firmware image
  • Loading branch information
thaytan committed Jan 15, 2018
1 parent f37b899 commit 32ea6f3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 39 deletions.
51 changes: 51 additions & 0 deletions software/scripts/copy_micropython_scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh

if [ -z "$AMPY_PORT" ]; then
echo This script updates all MicroPython code to the
echo Lolibot.
echo
echo Please provide the AMPY_PORT environment variable
echo containing the device name of the lolin32.
echo e.g. AMPY_PORT=/dev/ttyUSB0 "$0"
exit 1
fi

echo '### Remove boot.py ###'
ampy rm boot.py >/dev/null 2>&1 # TODO: Fix this command failing

echo '### Make directories ###'
for d in configuration lib lib/aiko lib/umqtt; do
if ampy ls $d 2>&1 | grep RuntimeErr > /dev/null; then
ampy mkdir $d
fi
done

echo '### Copy configuration/*.py ###'
ampy put configuration/led.py configuration/led.py
ampy put configuration/lolibot.py configuration/lolibot.py
ampy put configuration/mqtt.py configuration/mqtt.py
ampy put configuration/services.py configuration/services.py
ampy put configuration/wifi.py configuration/wifi.py

echo '### Copy lib/aiko/*.py ###'
ampy put lib/aiko/led.py lib/aiko/led.py
ampy put lib/aiko/mqtt.py lib/aiko/mqtt.py
ampy put lib/aiko/services.py lib/aiko/services.py
ampy put lib/aiko/wifi.py lib/aiko/wifi.py

echo '### Copy lolibot.py ###'
ampy put lib/lolibot.py lib/lolibot.py

echo '### Copy mpu9250.py ###'
ampy put lib/mpu9250.py lib/mpu9250.py

echo '### Copy lib/umqtt ###'
ampy put lib/umqtt/simple.py lib/umqtt/simple.py
ampy put lib/umqtt/robust.py lib/umqtt/robust.py

echo '### Copy boot.py ###'
ampy put boot.py

echo '### Complete ###'

# miniterm.py $AMPY_PORT 115200
51 changes: 12 additions & 39 deletions software/scripts/flash_lolibot.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,19 @@
#!/bin/sh

if [ -z "$AMPY_PORT" ]; then
echo This script re-flashes the firmware and copies
echo all MicroPython scripts to the board.
echo
echo Please provide the AMPY_PORT environment variable
echo containing the device name of the lolin32.
echo e.g. AMPY_PORT=/dev/ttyUSB0 "$0"
exit 1
fi

D="`dirname $0`"

echo '### Erase flash ###'
esptool.py --chip esp32 --port $AMPY_PORT erase_flash

echo '### Flash microPython ###'
esptool.py --chip esp32 --port $AMPY_PORT write_flash -z 0x1000 firmware/esp32-20171122-v1.9.2-443-g236297f4.bin

echo '### Remove boot.py ###'
ampy rm boot.py >/dev/null 2>&1 # TODO: Fix this command failing

echo '### Make directories ###'
ampy mkdir configuration
ampy mkdir lib
ampy mkdir lib/aiko
ampy mkdir lib/umqtt

echo '### Copy configuration/*.py ###'
ampy put configuration/led.py configuration/led.py
ampy put configuration/lolibot.py configuration/lolibot.py
ampy put configuration/mqtt.py configuration/mqtt.py
ampy put configuration/services.py configuration/services.py
ampy put configuration/wifi.py configuration/wifi.py

echo '### Copy lib/aiko/*.py ###'
ampy put lib/aiko/led.py lib/aiko/led.py
ampy put lib/aiko/mqtt.py lib/aiko/mqtt.py
ampy put lib/aiko/services.py lib/aiko/services.py
ampy put lib/aiko/wifi.py lib/aiko/wifi.py

echo '### Copy lolibot.py ###'
ampy put lib/lolibot.py lib/lolibot.py

echo '### Copy mpu9250.py ###'
ampy put lib/mpu9250.py lib/mpu9250.py

echo '### Copy lib/umqtt ###'
ampy put lib/umqtt/simple.py lib/umqtt/simple.py
ampy put lib/umqtt/robust.py lib/umqtt/robust.py

echo '### Copy boot.py ###'
ampy put boot.py

echo '### Complete ###'

# miniterm.py $AMPY_PORT 115200

0 comments on commit 32ea6f3

Please sign in to comment.