Flash Tasmota to Sonoff using Raspberry Pi: Difference between revisions

From KlavoWiki
Jump to navigationJump to search
(Created page with "I'm using a Raspberry Pi to slash the firmware. I find this simplier that using a USB TTY device plus I also have a number of Raspberry Pi's lying around. = Prerquisite = =...")
 
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
I'm using a Raspberry Pi to slash the firmware.  I find this simplier that using a USB TTY device plus I also have a number of Raspberry Pi's lying around.
I'm using a Raspberry Pi to flash the firmware.  I find this simplier that using a USB TTY device plus I also have a number of Raspberry Pi's laying around.


= Prerquisite =
= Prerquisite =
Line 11: Line 11:
== Change Config Files ==
== Change Config Files ==


Serial device --> /dev/ttyAMA0


=== cmdline.txt ===
=== cmdline.txt ===
Line 27: Line 26:


= Flashing =
= Flashing =
<span style="color:red; background:yellow">Warning: Do not have this device connected to mains power while flashing.</span>  Power is obtained by the Raspberry Pi. You need to hold the button down while powering on.  After each command you will need to reboot the device and hold the button down to enter flash mode.


== Display Existing ==
== Display Existing ==
Line 33: Line 33:
== Backup ==
== Backup ==
<pre> esptool.py --port /dev/serial0 read_flash 0x00000 0x400000 sonoff-image4M-stock.bin </pre>
<pre> esptool.py --port /dev/serial0 read_flash 0x00000 0x400000 sonoff-image4M-stock.bin </pre>
or
<pre> esptool.py --port /dev/serial0 read_flash 0x00000 0x100000 sonoff-image1M-stock.bin </pre>


== Erase ==
== Erase ==
Line 38: Line 40:


== Flash ==
== Flash ==
Here I'm downloading the sonoff.bin file from thehackbox but writing the file as sonoff-6.7.1.bin.  At time of download the version has probably changed, so write the file as per the correct version number so you know which version of the file you have.
Here I'm downloading the sonoff.bin file from thehackbox but writing the file as sonoff-7.2.0.bin.  At time of download the version has probably changed, so write the file as per the correct version number so you know which version of the file you have.


<pre>
<pre>wget http://thehackbox.org/tasmota/release/sonoff.bin -O /home/pi/Downloads/sonoff-7.2.0.bin</pre>
wget http://thehackbox.org/tasmota/release/sonoff.bin -O /home/pi/Downloads/sonoff-6.7.1.bin </pre>
<pre>esptool.py --port /dev/serial0 write_flash -fm dout 0x0 /home/pi/Downloads/sonoff-7.2.0.bin</pre>
esptool.py --port /dev/serial0 write_flash -fm dout 0x0 /home/pi/Downloads/tosmato-sonoff-6.7.1.bin
 
</pre>
= Configure =




= Configure =
== miniterm ==
Once the firmware has been upload you will need to connect to the Sonoff device via a custom SSID that the device is now advertising.  The default IP is 192.168.4.1
Miniterm is a terminal app to allow connection to the Sonoff over serial so we don't need to connect to the device over Wi-Fi for initial configuration.


Log onto the device using the Raspberry Pi.  Connect to the WEB console and then issue the following commands to configure your device.  Just configure the Wi-Fi settings for now to connect to your network.  Once changed you can then do the rest of the configuration from any other computer on the same network.
<pre>miniterm /dev/serial0 115200 -e</pre>


Log onto the web interface of the sonoff device.  Frro Main Menu, Console.
== settings ==
Change the settings as you require.
<pre>
<pre>
backlog ssid1 myssid; password1 mypassword
backlog ipaddress1 10.13.13.238; ipaddress2 10.13.13.254; ipaddress3 255.255.255.0; ipaddress4 8.8.8.8
backlog ipaddress1 10.13.13.238; ipaddress2 10.13.13.254; ipaddress3 255.255.255.0; ipaddress4 8.8.8.8
backlog ntpserver au.pool.ntp.org; timezone +10; Latitude -27.475646; Longitude 153.030499
backlog ntpserver1 1.au.pool.ntp.org; ntpserver2 2.au.pool.ntp.org; ntpserver3 3.au.pool.ntp.org; timezone +10; Latitude -27.475646; Longitude 153.030499
backlog PowerOnState 1; teleperiod 20; PowerRetain 1
backlog PowerOnState 1; teleperiod 20; PowerRetain 1
backlog MqttUser username; MqttPassword passw0rd; Topic laundry; FriendlyName laundry; MqttHost 10.13.13.253
backlog MqttUser username; MqttPassword passw0rd; Topic laundry; DeviceName laundry; MqttHost 10.13.13.253; GroupTopic2 CanUpgrade
</pre>
 
Now change your device to the correct type.  Note if you have the Pow device, changing to Pow will disable the serial logger so any further commands will need to be done from the WEB GUI.
<pre>
module 43
module 43
</pre>
</pre>
You can view the console command but can not enter any moving forward.  Also notice the baud rate change.
<pre> miniterm /dev/serial0 4800 -e</pre>
When updating the MQTT details and the module type the device will reboot, so make sure you wait for reboot to complete.


{|
{|
Line 100: Line 114:


....and many more.
....and many more.
= Termite =
<pre>
apt install gtk-doc-tools intltool gobject-introspection libglib2.0-dev libtool gtk+-3.0 gnutls-bin pango-graphite
git clone --recursive https://github.com/thestinger/vte-ng /usr/src/vte-ng
cd /usr/src/vte-ng
bash autogen.sh
sudo apt install vte-2.91
sudo git clone --recursive https://github.com/thestinger/termite.git /usr/src/
cd /usr/src/termite
make




[[Category : Sonoff]] [[ Category : Tasmota]]
[[Category : Sonoff]] [[ Category : Tasmota]]

Latest revision as of 12:27, 13 February 2022

I'm using a Raspberry Pi to flash the firmware. I find this simplier that using a USB TTY device plus I also have a number of Raspberry Pi's laying around.

Prerquisite

Install PIP

apt install python3-pip
sudo pip3 install esptool

Change Config Files

cmdline.txt

 vi /boot/cmdline.txt 

delete

 "console=serial0,115200" 

config.txt

 vi /boot/config.txt 

add

 "enable_uart=1" 


Flashing

Warning: Do not have this device connected to mains power while flashing. Power is obtained by the Raspberry Pi. You need to hold the button down while powering on. After each command you will need to reboot the device and hold the button down to enter flash mode.

Display Existing

 esptool.py --port /dev/serial0 flash_id 

Backup

 esptool.py --port /dev/serial0 read_flash 0x00000 0x400000 sonoff-image4M-stock.bin 

or

 esptool.py --port /dev/serial0 read_flash 0x00000 0x100000 sonoff-image1M-stock.bin 

Erase

 esptool.py --port /dev/serial0 erase_flash 

Flash

Here I'm downloading the sonoff.bin file from thehackbox but writing the file as sonoff-7.2.0.bin. At time of download the version has probably changed, so write the file as per the correct version number so you know which version of the file you have.

wget http://thehackbox.org/tasmota/release/sonoff.bin -O /home/pi/Downloads/sonoff-7.2.0.bin
esptool.py --port /dev/serial0 write_flash -fm dout 0x0 /home/pi/Downloads/sonoff-7.2.0.bin

Configure

miniterm

Miniterm is a terminal app to allow connection to the Sonoff over serial so we don't need to connect to the device over Wi-Fi for initial configuration.

miniterm /dev/serial0 115200 -e

settings

Change the settings as you require.

backlog ssid1 myssid; password1 mypassword 
backlog ipaddress1 10.13.13.238; ipaddress2 10.13.13.254; ipaddress3 255.255.255.0; ipaddress4 8.8.8.8
backlog ntpserver1 1.au.pool.ntp.org; ntpserver2 2.au.pool.ntp.org; ntpserver3 3.au.pool.ntp.org; timezone +10; Latitude -27.475646; Longitude 153.030499
backlog PowerOnState 1; teleperiod 20; PowerRetain 1
backlog MqttUser username; MqttPassword passw0rd; Topic laundry; DeviceName laundry; MqttHost 10.13.13.253; GroupTopic2 CanUpgrade

Now change your device to the correct type. Note if you have the Pow device, changing to Pow will disable the serial logger so any further commands will need to be done from the WEB GUI.

module 43


You can view the console command but can not enter any moving forward. Also notice the baud rate change.

 miniterm /dev/serial0 4800 -e

When updating the MQTT details and the module type the device will reboot, so make sure you wait for reboot to complete.

Field Description
ipaddress1 IP address
ipaddress2 gateway
ipaddress3 IP mask
ipaddress4 DNS

Modules

Number Descrption
0 Generic
1 Basic
4 TH
5 Dual
43 Pow R2

....and many more.