Flash Tasmota to Sonoff using Raspberry Pi

From KlavoWiki
Revision as of 11:14, 9 November 2019 by David (talk | contribs) (→‎settings)
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

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

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 

settings

change the settings as you require.

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

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.