mirror of https://github.com/arendst/Tasmota.git
Updated Flash Sonoff using Raspberry Pi (markdown)
parent
2d02cca7bc
commit
35d01d1b19
|
@ -1,55 +1,52 @@
|
|||
If you have no USB-to-TTL serial converter available, but a Raspberry Pi, you can use this for flashing your Sonoff switch.
|
||||
If you don't have a USB-to-TTL serial adapter available, but you have a Raspberry Pi, you can use this procedure for flashing your device.
|
||||
|
||||
All is basically described here, but it is a little outdated:
|
||||
https://www.sigmdel.ca/michel/ha/sonoff/flashing_sonoff_en.html
|
||||
[Tutorial](https://www.sigmdel.ca/michel/ha/sonoff/flashing_sonoff_en.html) (a little outdated)
|
||||
|
||||
So, I will summarize the process and needed adoptions based on the above blog, please refer there for a more detailed explanation ;)
|
||||
Summarizing the process and needed connections based on the above blog, please refer there for a more detailed explanation :wink:
|
||||
|
||||
# Preparation of the Raspberry:
|
||||
1. Install esptool (pip needed)
|
||||
# Preparation of the Raspberry Pi
|
||||
1. Install esptool (pip needed)
|
||||
`sudo pip install esptool`
|
||||
|
||||
`sudo pip install esptool`
|
||||
2. Prepare serial connection.
|
||||
_Note: Use the correct serial connection as per your version of the Raspberry Pi._
|
||||
|
||||
2. Prepare serial connection.
|
||||
| Device | Serial Connection |
|
||||
| ------------- |---------------|
|
||||
| RaspberryPi 1/2/3 (BT disabled or miniuart) | /dev/ttyAMA0 |
|
||||
| RaspberryPi 3 | /dev/ttyS0 |
|
||||
|
||||
_Note: Use the correct serial connection as per your version of the Raspberry Pi._
|
||||
`sudo systemctl stop serial-getty@ttyS0.service`
|
||||
|
||||
| Device | Serial Connection |
|
||||
| ------------- |---------------|
|
||||
| RaspberryPi 1/2/3 (BT disabled or miniuart) | /dev/ttyAMA0 |
|
||||
| RaspberryPi 3 | /dev/ttyS0 |
|
||||
`sudo systemctl disable serial-getty@ttyS0.service`
|
||||
|
||||
`sudo systemctl stop serial-getty@ttyS0.service`
|
||||
`sudo cp /boot/cmdline.txt /boot/cmdline.bak` (This backups the file ;))
|
||||
|
||||
`sudo systemctl disable serial-getty@ttyS0.service`
|
||||
`sudo nano /boot/cmdline.txt`
|
||||
-> delete "console=serial0,115200" option
|
||||
|
||||
`sudo cp /boot/cmdline.txt /boot/cmdline.bak` (This backups the file ;))
|
||||
3. I don’t know if this is necessary, but I did it as it was mentioned here:
|
||||
https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/
|
||||
|
||||
`sudo nano /boot/cmdline.txt`
|
||||
-> delete "console=serial0,115200" option
|
||||
`sudo nano /boot/config.txt`
|
||||
|
||||
3. I don’t know if this is necessary, but I did it as it was mentioned here: https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/
|
||||
-> add the line (at the bottom):
|
||||
`enable_uart=1`
|
||||
|
||||
`sudo nano /boot/config.txt`
|
||||
Please note following overlays setting port to `/dev/ttyAMA0`
|
||||
|
||||
-> add the line (at the bottom):
|
||||
`enable_uart=1`
|
||||
|
||||
Please note following overlays setting port to `/dev/ttyAMA0`
|
||||
|
||||
* `pi3-miniuart-bt`
|
||||
* `pi3-disable-bt`
|
||||
* `pi3-miniuart-bt`
|
||||
* `pi3-disable-bt`
|
||||
|
||||
4. Reboot your Pi
|
||||
|
||||
|
||||
# Wire RaspberryPi:
|
||||
# Connections
|
||||
Connect GND, RX->TX and TX->RX as shown below.
|
||||
|
||||
**If you power the Sonoff with the 3.3v power from the RPi it will cause it to reboot when connecting.** You can still enter flash mode if you power up the RPi with the 3.3v connected and pressing the button on Sonoff simultaneously. It's recommended to use either an external power supply for this or use the 5V GPIO and a 3.3V Voltage Regulator.
|
||||
**If you power the device with the 3.3V power from the RPi it will cause it to reboot when connecting.** You can still enter flash mode if you power up the RPi with the 3.3v connected and pressing the connecting GPIO0 to ground (e.g., pressing the button on the Sonoff Basic) simultaneously. It's recommended to use either an external power supply for this or use the 5V GPIO and a 3.3V Voltage Regulator.
|
||||
([issue #4807](https://github.com/arendst/Sonoff-Tasmota/issues/4807))
|
||||
|
||||
**Do not connect 3,3V yet!**
|
||||
**Do not connect 3.3V yet!**
|
||||
|
||||
https://www.sigmdel.ca/michel/ha/sonoff/flashing_sonoff_en.html
|
||||
![Wiring](https://www.sigmdel.ca/michel/ha/sonoff/img/sonoff-rpi.jpg)
|
||||
|
@ -61,99 +58,94 @@ This is how it looks in real-life 😆
|
|||
|
||||
# Flashing the firmware
|
||||
1. Erase flash memory:
|
||||
Connect 3,3V while button pressed for about 10 seconds to enter flash-mode. Then release and run:
|
||||
Connect 3.3V while button pressed for about 10 seconds to enter flash-mode. Then release and run:
|
||||
|
||||
```bash
|
||||
# if using Raspberry Pi 1/2 use
|
||||
# esptool.py --port /dev/ttyAMA0 erase_flash
|
||||
```bash
|
||||
# if using Raspberry Pi 1/2 use
|
||||
# esptool.py --port /dev/ttyAMA0 erase_flash
|
||||
|
||||
# if using Raspberry Pi 3 use
|
||||
esptool.py --port /dev/ttyS0 erase_flash
|
||||
```
|
||||
You should see output like this:
|
||||
# if using Raspberry Pi 3 use
|
||||
esptool.py --port /dev/ttyS0 erase_flash
|
||||
```
|
||||
You should see output like this:
|
||||
|
||||
```bash
|
||||
➜ ~ esptool.py --port /dev/ttyAMA0 erase_flash
|
||||
esptool.py v2.5.1
|
||||
Serial port /dev/ttyAMA0
|
||||
Connecting....
|
||||
Detecting chip type... ESP8266
|
||||
Chip is ESP8285
|
||||
Features: WiFi, Embedded Flash
|
||||
MAC: dc:4f:22:ab:5e:dc
|
||||
Uploading stub...
|
||||
Running stub...
|
||||
Stub running...
|
||||
Erasing flash (this may take a while)...
|
||||
Chip erase completed successfully in 3.3s
|
||||
Hard resetting via RTS pin...
|
||||
➜ ~
|
||||
```
|
||||
```bash
|
||||
➜ ~ esptool.py --port /dev/ttyAMA0 erase_flash
|
||||
esptool.py v2.5.1
|
||||
Serial port /dev/ttyAMA0
|
||||
Connecting....
|
||||
Detecting chip type... ESP8266
|
||||
Chip is ESP8285
|
||||
Features: WiFi, Embedded Flash
|
||||
MAC: dc:4f:22:ab:5e:dc
|
||||
Uploading stub...
|
||||
Running stub...
|
||||
Stub running...
|
||||
Erasing flash (this may take a while)...
|
||||
Chip erase completed successfully in 3.3s
|
||||
Hard resetting via RTS pin...
|
||||
➜ ~
|
||||
```
|
||||
|
||||
2. Flash .bin, which you can download from the [release-section](https://github.com/arendst/Sonoff-Tasmota/releases):
|
||||
|
||||
Again connect 3,3V while pressing button for 10 seconds. Then release and run:
|
||||
Again connect 3.3V while pressing button for 10 seconds. Then release and run:
|
||||
|
||||
```bash
|
||||
# if using Raspberry Pi 1/2 use
|
||||
# esptool.py --port /dev/ttyAMA0 write_flash -fm dout 0x0 /path/to/downloaded/sonoff.bin
|
||||
```bash
|
||||
# if using Raspberry Pi 1/2 use
|
||||
# esptool.py --port /dev/ttyAMA0 write_flash -fm dout 0x0 /path/to/downloaded/sonoff.bin
|
||||
|
||||
# if using Raspberry Pi 3 use
|
||||
esptool.py --port /dev/ttyS0 write_flash -fm dout 0x0 /path/to/downloaded/sonoff.bin
|
||||
```
|
||||
# if using Raspberry Pi 3 use
|
||||
esptool.py --port /dev/ttyS0 write_flash -fm dout 0x0 /path/to/downloaded/sonoff.bin
|
||||
```
|
||||
|
||||
You should see output like this:
|
||||
You should see output like this:
|
||||
|
||||
```bash
|
||||
➜ ~ esptool.py --port /dev/ttyAMA0 write_flash -fm dout 0x0 sonoff.bin
|
||||
esptool.py v2.5.1
|
||||
Serial port /dev/ttyAMA0
|
||||
Connecting.....
|
||||
Detecting chip type... ESP8266
|
||||
Chip is ESP8285
|
||||
Features: WiFi, Embedded Flash
|
||||
MAC: dc:4f:22:ab:5e:dc
|
||||
Uploading stub...
|
||||
Running stub...
|
||||
Stub running...
|
||||
Configuring flash size...
|
||||
Auto-detected Flash size: 1MB
|
||||
Compressed 456000 bytes to 312426...
|
||||
Wrote 456000 bytes (312426 compressed) at 0x00000000 in 29.2 seconds (effective 124.8 kbit/s)...
|
||||
Hash of data verified.
|
||||
```bash
|
||||
➜ ~ esptool.py --port /dev/ttyAMA0 write_flash -fm dout 0x0 sonoff.bin
|
||||
esptool.py v2.5.1
|
||||
Serial port /dev/ttyAMA0
|
||||
Connecting.....
|
||||
Detecting chip type... ESP8266
|
||||
Chip is ESP8285
|
||||
Features: WiFi, Embedded Flash
|
||||
MAC: dc:4f:22:ab:5e:dc
|
||||
Uploading stub...
|
||||
Running stub...
|
||||
Stub running...
|
||||
Configuring flash size...
|
||||
Auto-detected Flash size: 1MB
|
||||
Compressed 456000 bytes to 312426...
|
||||
Wrote 456000 bytes (312426 compressed) at 0x00000000 in 29.2 seconds (effective 124.8 kbit/s)...
|
||||
Hash of data verified.
|
||||
|
||||
Leaving...
|
||||
Hard resetting via RTS pin...
|
||||
➜ ~
|
||||
```
|
||||
Leaving...
|
||||
Hard resetting via RTS pin...
|
||||
➜ ~
|
||||
```
|
||||
|
||||
7. Setup Wifi:
|
||||
Connect with an external device to the wifi and configure over the browser.
|
||||
3. Setup Wi-Fi:
|
||||
- Connect with an external device to the `sonoff-xxxx` Wi-Fi AP and configure over the browser.
|
||||
|
||||
Alternativ: Reboot your sonoff after flashing(toggle power wire) and connect to serial console via miniterm:
|
||||
- Alternative: Reboot your device after flashing (toggle power wire) and connect to the serial console via miniterm:
|
||||
|
||||
```bash
|
||||
# if using Raspberry Pi 1/2 use
|
||||
# miniterm.py /dev/ttyAMA0 115200 -e
|
||||
```bash
|
||||
# if using Raspberry Pi 1/2 use
|
||||
# miniterm.py /dev/ttyAMA0 115200 -e
|
||||
|
||||
# if using Raspberry Pi 3 use
|
||||
miniterm.py /dev/ttyS0 115200 -e
|
||||
```
|
||||
# if using Raspberry Pi 3 use
|
||||
miniterm.py /dev/ttyS0 115200 -e
|
||||
```
|
||||
|
||||
You will see some output, after pressing enter.
|
||||
You will see some output, after pressing enter.
|
||||
|
||||
Now just type in, your SSID, press enter and then type the password…
|
||||
Now just type in, your SSID, press enter and then type the password…
|
||||
|
||||
`ssid yourSSID`
|
||||
`Backlog ssid yourSSID; password yourPassword`
|
||||
|
||||
wait until sonoff stops outputting messages (~3 seconds) and type
|
||||
|
||||
`password yourPassword`
|
||||
# That’s it :smiley:
|
||||
|
||||
# That’s it :)
|
||||
|
||||
Feel free to edit, if I forgot something or changes are necessary in the future!
|
||||
|
||||
Sources:
|
||||
https://github.com/arendst/Sonoff-Tasmota/wiki/Esptool (flashing commands)
|
||||
https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/
|
||||
Sources:
|
||||
[Flashing commands](https://github.com/arendst/Sonoff-Tasmota/wiki/Esptool)
|
||||
https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/
|
||||
|
|
Loading…
Reference in New Issue