Flash Tasmota to Sonoff using Raspberry Pi

From KlavoWiki
Jump to navigationJump to search

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

Install PIP

apt install python3-pip
sudo pip3 install esptool

Change Config Files

Serial device --> /dev/ttyAMA0

cmdline.txt

 vi /boot/cmdline.txt 

delete

 "console=serial0,115200" 

config.txt

 vi /boot/config.txt 

add

 "enable_uart=1" 


Flashing

Display Existing

 esptool.py --port /dev/serial0 flash_id 

Backup

 esptool.py --port /dev/serial0 read_flash 0x00000 0x400000 sonoff-image4M-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-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.

wget http://thehackbox.org/tasmota/release/sonoff.bin -O /home/pi/Downloads/sonoff-6.7.1.bin 

esptool.py --port /dev/serial0 write_flash -fm dout 0x0 /home/pi/Downloads/tosmato-sonoff-6.7.1.bin


Configure

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

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.

Log onto the web interface of the sonoff device. Frro Main Menu, Console.

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 PowerOnState 1; teleperiod 20; PowerRetain 1
backlog MqttUser username; MqttPassword passw0rd; Topic laundry; FriendlyName laundry; MqttHost 10.13.13.253
module 43
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.


mincom

Minicom 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.


 minicom -b 115200 -o -D /dev/serial0 
 backlog ssid1 myssid; password1 mypassword