Have a gander at this page that was recommended by people in the Tasmoto chat Getting Started - Tasmota
I was having many issues flashing mine. I would suggest testing the device first with esptool: Releases · espressif/esptool · GitHub
Check flash (Useful to get the flash size for the second command 1M etc):
Nix
esptool --port /dev/ttyUSB1 flash_id
or Windows
esptool --port COM4 flash_id
Should spit out something like this:
esptool.py v2.8
Serial port /dev/ttyUSB1
Connecting....
Detecting chip type... ESP8266
Chip is ESP8285
Features: WiFi, Embedded Flash
Crystal is 26MHz
MAC: xx:xx:xx:xx:xx:xx
Enabling default SPI flash mode...
Manufacturer: 5e
Device: 3214
Detected flash size: 1MB
Hard resetting via RTS pin...
A fail will look like this:
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____
A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header
Once you get a success you can then dump the firmware with:
sudo chmod +x esptool
./esptool --port /dev/ttyUSB0--baud 921600 read_flash 0x00000 0x100000 ifan04lfwbackup001-1.bin
Which should then look something like this:
esptool.py v3.3.2
Serial port /dev/ttyUSB0
Connecting...
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP8266
Chip is ESP8285N08
Features: WiFi, Embedded Flash
Crystal is 26MHz
MAC: xx:xx:xx:xx:xx:xx
Stub is already running. No upload is necessary.
Changing baud rate to 921600
Changed.
1048576 (100 %)
1048576 (100 %)
Read 1048576 bytes at 0x0 in 16.7 seconds (501.9 kbit/s)...
Hard resetting via RTS pin...
If that is not working with your USB to TTL just remove the --baud line so it will default back to 115200.
You should dump the firmware twice and compare just for a sanity check. (If you ever care about returning the worst beeping firmware on earth)
md5sum ifan04lfwbackup001-1.bin
cb5b29008c9459e4014ffdaa12537c94 ifan04lfwbackup001-1.bin
md5sum ifan04lfwbackup001-2.bin
cb5b29008c9459e4014ffdaa12537c94 ifan04lfwbackup001-2.bin
I was having multiple issues. First issue was I was using an FT232RL (not fake) but had no voltage regulator on the board. I think this board consumes a lot of mW with the two radio IC etc.
I ended up wiring it to VAC (Not recommended for safety reasons in the documentation above) then just using TX to TX, RX to RX (Thanks above) and Ground only. Which started dumping the firmware but then would die at 40%.
You can also test if your getting any console data with Putty or Minicom as the device will dump a version line to the serial console when you hold the button down while powered and not synced to the eWeLink app yet (“DIY mode” gets activated with an ad-hoc AP. Check out sonoff.tech/diy-developer for more information about the process. The blurb about the other device seems to work with this one when you hold the sync button down on the 433 remote as well I think).
Serial Console:
FWFAN-XXXXXXXXMCU-IFAN04-XXXXXXXXX v1.1.0
I then bought the recommended USB adapter with the CH340G and an external LDO regulator from that Tasmoto article above from AliExpress for a few dollars (Don’t just grab any CH340G from Ali as some of the boards are garbage with no external LDO. I haven’t got it yet but I remembered I had a second device an ESP-Prog so I hooked that up and at first it had an error:
A fatal error occurred: ESP8266 ROM does not support function read_flash.
This was caused from Debian’s old apt esptool version 2.8. After grabbing the one from the github repo above 3+ it worked fine.
I remembered in the past I also had issues with the laptop dock (USB C) when it’s charging the laptop. I can’t get programmers to flash the ESP for some reason. (USB2TTL plugged into the side of the laptop not the dock) Maybe it’s noisy or something. Soon as I unplug the laptop from power it flashes fine.
So there’s some more food for thought. Try a different computer / programmer / get solid power to it / make sure everything shares the same ground plane.
I just bought my iFan04 a week ago. They are on firmware 3.5 from Sonoff (latest) and still read the flash fine. So your unit age should be ok as well (I had this same concern). People in the Tasmoto chat said there is pretty much nothing Sonoff could do with the firmware to prevent flashing an esp82xx.
Also your question about holding the button down. Your 5 seconds should be fine but maybe you are also activating the “DIY mode” if not power cycling properly. Check if there is a WiFi itead SSID near you. I hold the button down, then flick the power bar on, then count to 2 or 3, then let go, then test with esptool flash id command. (This is of course with no 3v3 connected from the TTL Adapter / ie VAC power)
Otherwise if I had a decent external LDO without VAC attached. I would go: Hold button down, plug in USB, do the count, let go, test the flash.
Note the quality control on Sonoff gear may not be the best… The transformer leads on the back of my board were not removed and touching each other (I’m glad I never plugged it in before taking it apart).
I also had to remove half a mm off both sides with the sanding dremel tool to fit it in the fan bracket mount housing.