Page 1 of 1
Flash script for esptool on Linux
Posted: 09 Oct 2016, 17:16
by felixm
Hi guys,
first of all i was very impressed of EspEasy as i started to use it days ago. I had some WemoS D1 mini ordered months ago for smart home applications and now it was so easy to get them to fhem.
During flashing the first chips i tried the "Stable" R120 Download which has a flashscript for windows users in the zipfile. As i'm a strict Linux-user i just ported the windows batch to Linus shell and wanted to share it here. If this and the binary for espttol could've been added to the download this could make it way easier for linux systems. (There is a confusing different kind of "esptool" available with complete different syntax).
Cheers from germany
Felix
Re: Flash script for esptool on Linux
Posted: 10 Oct 2016, 08:23
by NietGiftig
Linux user since 2 months here
Thanks!!
Re: Flash script for esptool on Linux
Posted: 11 Oct 2016, 00:38
by costo
felixm wrote:
........
As i'm a strict Linux-user i just ported the windows batch to Linus shell and wanted to share it here. If this and the binary for espttol could've been added to the download this could make it way easier for linux systems. (There is a confusing different kind of "esptool" available with complete different syntax).
........
Thank you for this tool, I like the idea of being able to flash ESPEasy from within my linux environment.
It must be my ignorance but sadly I cannot make this tool/command do what it is supposed to do.
Is it possible that you provide a sort of helpfile, explaining how to use this tool ?
Re: Flash script for esptool on Linux
Posted: 19 Nov 2016, 13:21
by felixm
Hei guys,
at first sorry for the late answer, so much to do, so little time.
Basicly i tried to make the use similar to the windows tool.
Obviously it's to simple
: Just start the script without any params, everything will be asked at runtime.
The script asks for: Serial Port (Default: "/dev/ttyUSB0"), Flash Size (Depending on BoardVersion, for me on Wemos D1 mini 4096K) and Build number (Default 120 because its the latest stable).
The file is expected in the current directory. If it's there it will be flashed.
Felix
Re: Flash script for esptool on Linux
Posted: 25 Feb 2017, 11:41
by thonshic
Saw your script too late, so wrote my own one.
This one looks for
* esptool
* firmware images
and presents a list of found ones, so it should also work for other releases.
Code: Select all
#!/bin/bash
selectst=""
for i in ESPEasy*bin
do
selectst="$i $i off $selectst"
done
# check for esptool
esptoolbin=$(which esptool)
if [ ! -x "$esptoolbin" ] ; then
if [ -x "./esptool" ] ; then
esptoolbin="./esptool"
else
eardu=$(find $HOME/.arduino15/packages/esp8266/tools/esptool/* -name esptool|sort|tail -1)
if [ -x "$eardu" ] ; then
echo "found esptool: $eardu"
esptoolbin="$eardu"
fi
fi
fi
if [ ! -x "$esptoolbin" ] ; then
echo "esptool not found, you can link it here or put in \$PATH"
exit 2
else
echo "using esptool $esptoolbin"
fi
read -e -p "serial device, (USB2serial devices: $(ls /dev/ttyUSB*)):" -i "/dev/ttyUSB0" serdev
if [ ! -r "$serdev" ] ; then
echo "device '$serdev' does not exist"
exit 2
fi
if [ -n "$(which dialog)" ] ; then
cmd=(dialog --radiolist "Select firmware" 22 76 16)
choice=$("${cmd[@]}" ${selectst} 2>&1 >/dev/tty)
else
# bash only, do it with an array
fa=(ESPEasy_*.bin)
cnt=0
nfa=${#fa[*]}
while [ $cnt -lt $nfa ]
do
echo $cnt ${fa[$cnt]}
((cnt++))
done
read -p "choose number of firmware file to flash [0-$((nfa-1))]: " nsel
choice=${fa[$nsel]}
if [ ! -f "$choice" ] ; then
echo "cannot find file \"$choice\", exiting"
exit 2
fi
fi
echo "----"
read -p "flash $choice? [Y/n]" yn
if [ "$yn" != "n" ] ; then
"$esptoolbin" -vv -cd nodemcu -cb 115200 -cp "$serdev" -ca 0x00000 -cf "$choice"
fi
Re: Flash script for esptool on Linux
Posted: 25 Feb 2017, 11:43
by thonshic
Is there any place/repo for a pull request?
Re: Flash script for esptool on Linux
Posted: 25 Feb 2017, 14:07
by NietGiftig
thonshic wrote:Is there any place/repo for a pull request?
Best to place it in the wiki
A good place would be here:
http://www.letscontrolit.com/wiki/index ... are_Upload
Re: Flash script for esptool on Linux
Posted: 17 Jun 2020, 18:01
by obod0002c
nothing of any importance but maybe helpful for beginners who are struggling with other problems.
the binaries must have been renamed, so none of the bin-files will be selected, by none of the two really helpful scripts described here:
https://www.letscontrolit.com/wiki/inde ... ript_linux
Super simple reason: '_' missing ... not in the zip-archive's name but the binaries stored within the zip's.
Scripts are looking for filenames like 'ESPEasy', name of the bin's: 'ESP_Easy'
Re: Flash script for esptool on Linux
Posted: 22 Jul 2020, 20:57
by thonshic
Thanks for the bug report @obod0002c, I edited it in the wiki, hopefully it works now (untested)...
Re: Flash script for esptool on Linux
Posted: 08 Dec 2020, 16:46
by michaudjp
Did esptool had major changes since you wrote the script? I have following error:
Code: Select all
...
esptool: error: argument --chip/-c: invalid choice: 'p' (choose from 'auto', 'esp8266', 'esp32')
I'm using February 2020 esptool.py 2.8
https://manpages.debian.org/testing/esp ... .1.en.html
Re: Flash script for esptool on Linux
Posted: 08 Dec 2020, 17:25
by michaudjp
Fixed it quickly:
Code: Select all
fi
echo "----"
read -p "flash $choice? [Y/n]" yn
if [ "$yn" != "n" ] ; then
"$esptoolbin" -b 115200 -p "$serdev" write_flash 0x00000 "$choice"
Best would be to integrate esptool actions (write_flash, erase_flash...) in a choice list first if someone has some time.