Flash script for esptool on Linux

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
felixm
New user
Posts: 4
Joined: 09 Oct 2016, 17:05

Flash script for esptool on Linux

#1 Post by felixm » 09 Oct 2016, 17:16

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
Attachments
ESPEasy_Flashutils.zip
Flash scripts and esptool for Windows and Linux
(32.03 KiB) Downloaded 2074 times

NietGiftig
Normal user
Posts: 103
Joined: 16 Sep 2015, 20:32

Re: Flash script for esptool on Linux

#2 Post by NietGiftig » 10 Oct 2016, 08:23

Linux user since 2 months here

Thanks!!

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Flash script for esptool on Linux

#3 Post by costo » 11 Oct 2016, 00:38

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 ?

felixm
New user
Posts: 4
Joined: 09 Oct 2016, 17:05

Re: Flash script for esptool on Linux

#4 Post by felixm » 19 Nov 2016, 13:21

Hei guys,

at first sorry for the late answer, so much to do, so little time. :roll:

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

thonshic
New user
Posts: 4
Joined: 25 Feb 2017, 11:00

Re: Flash script for esptool on Linux

#5 Post by thonshic » 25 Feb 2017, 11:41

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

thonshic
New user
Posts: 4
Joined: 25 Feb 2017, 11:00

Re: Flash script for esptool on Linux

#6 Post by thonshic » 25 Feb 2017, 11:43

Is there any place/repo for a pull request?

NietGiftig
Normal user
Posts: 103
Joined: 16 Sep 2015, 20:32

Re: Flash script for esptool on Linux

#7 Post by NietGiftig » 25 Feb 2017, 14:07

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

obod0002c
Normal user
Posts: 119
Joined: 10 Aug 2019, 20:31

Re: Flash script for esptool on Linux

#8 Post by obod0002c » 17 Jun 2020, 18:01

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'

thonshic
New user
Posts: 4
Joined: 25 Feb 2017, 11:00

Re: Flash script for esptool on Linux

#9 Post by thonshic » 22 Jul 2020, 20:57

Thanks for the bug report @obod0002c, I edited it in the wiki, hopefully it works now (untested)...

michaudjp
New user
Posts: 2
Joined: 08 Dec 2020, 16:42

Re: Flash script for esptool on Linux

#10 Post by michaudjp » 08 Dec 2020, 16:46

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

michaudjp
New user
Posts: 2
Joined: 08 Dec 2020, 16:42

Re: Flash script for esptool on Linux

#11 Post by michaudjp » 08 Dec 2020, 17:25

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 87 guests