Skip to content

Instantly share code, notes, and snippets.

@MonksterFX
Created April 3, 2021 07:41
Show Gist options
  • Save MonksterFX/169c2b321813c692f6180a3fc03aa3c9 to your computer and use it in GitHub Desktop.
Save MonksterFX/169c2b321813c692f6180a3fc03aa3c9 to your computer and use it in GitHub Desktop.
Micropython Install Firmware Script For ESP32 & ESP8266

Requirements

  • mac/linux terminal zsh
  • zenity installed
  • conda env microptyhon (with all necessary scripts epstools etc.)
  • folder with firmware im bin format
#!/bin/zsh
# change conda env
CONDA_BASE=$(conda info --base)
source $CONDA_BASE/etc/profile.d/conda.sh
conda activate micropython
# collect usb ports
AVAILABLE_PORTS=$(find /dev/cu.usb*)
# select port - convert available ports to array
PORT=$(zenity --list --title="Choose controller to reset and install micropython" --column="controller" \
${(@f)AVAILABLE_PORTS})
if [[ $PORT = *[!\ ]* ]]; then
echo "Selected port for installation" $PORT
else
echo "No port selected aborting... Bye!"
exit
fi
# erase board bootloader
esptool.py --port $PORT erase_flash
# select firmware
AVAILABLE_FIRMWARE=$(find ../firmware/*)
FIRMWARE=$(zenity --list --title="Choose firmware" --column="firmware" \
${(@f)AVAILABLE_FIRMWARE})
if [[ $FIRMWARE = *[!\ ]* ]]; then
echo "Selected firmware for installation" $FIRMWARE
else
echo "No firmware selected aborting... Bye!"
exit
fi
# install ESP32 Only!
esptool.py --port $PORT --baud 115200 write_flash -z 0x1000 $FIRMWARE
# info
zenity --info
echo "Bye!"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment