Today I was trying to download custom firmware to a sonoff basic. For those who don't know what that is: It's an ESP8266 with a flash chip, power supply, and a relay that you can use to switch a 230 V load. Really simple, and since it's based on an ESP, also very hackable. There's even some holes for a header with 3V3, RX, TX and GND that yells at you to plug in your own code. So I wanted to do just that.
Basically, flashing is as simple as for any other generic ESP board, especially with arduino which uses esptool under the hood. Many tutorials describe the basic workflow:
- unplug the device from mains, if it was connected before
- really do that previous step!
- wait until everything has discharged and is safe to touch
- wait some more
- solder in a 4- or 5-pin header (the fifth pin is not necessary)
- connect a USB to serial converter
- supply the chip with an external 3V3 power supply (capable of supplying 300 mA or so)
- use esptool to flash your own firmware.
I won't repeat the numerous pictures here, just google for "sonoff basic flash" or something similar.
However, I ran into a problem: After esptool reported that it had flashed the new firmware successfully, my ESP just wouldn't run. I finally found this issue on github:
It boils down to this: when flashing, you have to do so in DOUT mode. You can select this in the arduino tools menu or on the command line for esptool.