Skip to content

Instantly share code, notes, and snippets.

@jiachengx
Last active November 11, 2018 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiachengx/c55729e26e289e4125b4e83a81cf4a80 to your computer and use it in GitHub Desktop.
Save jiachengx/c55729e26e289e4125b4e83a81cf4a80 to your computer and use it in GitHub Desktop.
ESP flash tool
#!/bin/bash
# Aurhor: JC
if [ -z $1 ] || [ -z $2 ]; then
printf "Usage:\n\t $0 sID port e.g $0 S5 0\n"
exit 0
fi
sid=$1
port=$2
ver="1.00.18.101"
t_macaddr="t_macaddr" # Record each MAC address and label
espfile="/opt/micropython/bin/esp8266-20180511-v1.9.4.bin"
# Modify the WiFi.cfg
printf "$0 ver. ${ver}\n"
# Get the Flash info and then parse the mac address
mac=$(esptool.py --port /dev/ttyUSB${port} flash_id | awk -F 'MAC:' '{print $2}' | tr -d " " | tr -d "\r\n" | tr '[:lower:]' '[:upper:]')
printf "MAC address: ${mac}\n"
printf "${sid}: ${mac}\n" | tee -a ${t_macaddr}
# Erase the ESP01s
esptool.py --port /dev/ttyUSB${port} erase_flash
# Download the firmware
esptool.py --port /dev/ttyUSB${port} --baud 460800 write_flash --flash_size detect 0 ${espfile}
@jiachengx
Copy link
Author

Update the espflash 2nd version. Add label variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment