Flash script for esptool on Linux

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
felixm
Normal 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 1533 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!!

costo
Normal user
Posts: 490
Joined: 21 Nov 2015, 15:03

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
Normal 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
Normal user
Posts: 3
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
Normal user
Posts: 3
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: 40
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'

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests