Unable to upload to SONOFF with Arduino 1.8.4 on Linux

I have 4 new SONOFF's.
I've had them about a year but just got round to opening them up and flashing custom firmware.
Each sonoff module also has the 433.92MHz radio for a hand held remote.
Other than that they are just the basic module.

I'm having problems loading any sketch onto these modules.
I have soldered headers onto the 3v3, RX,TX and GND for each of the modules, so I can be certain that I have as good a connection to the FTDI USB programer as I can get.

I'm using 3.3v not 5v.

I have 3 different FTDI's and have tried each one with most of the modules; no luck.

I have also tried using the serial chip on the Arduino Uno as a programer by connecting Reset to ground on the Arduino and then connecting the 3V3, GND, TX and RX pins to the SONOFF. This didn't work either.

I make sure to ground GPIO0 before connecting 3V3 each time, so that the ESP8266 goes into programing mode.

I've tried switching TX and RX round. Didn't work.

I can always see the FTDI (or Arduino Uno) programmer port in the Adruino IDE under
menu -> Tools -> Port

Settings I am using are "Generic ESP8266" and others as shown in image attachment.

I can't even get the sketch to begin uploading.

Sketch compiles just fine.

Error I see every time, regardless of which SONOFF module I try to program, or settings selected is

Sketch uses 248967 bytes (25%) of program storage space. Maximum is 958448 bytes.
Global variables use 35620 bytes (43%) of dynamic memory, leaving 46300 bytes for local variables. Maximum is 81920 bytes.
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

Done loads of googling and nothing obvious.

Ideas?

ps I'm able to upload the sketch I'm using onto a stand alone ESP8266-01 with no trouble at all.

Voltage and current measurements.

Don't know if I'm going down the wrong path here but I though I'd check that I'm delivering enough voltage and current and it's not overly being soaked up by the relay and the 433MHz receiver.

While one of my 3 FTDI's is plugged into laptop and the SONOFF is connected to the 3v3 power pin, the SONOFF LED blinks green brightly every 2 seconds.

The measured voltage across the FTDI 3v3 and GND pins is 3.41 volts.
The current draw through the same pins is 38 mA.

It seems as if nothing I do will let me program these sonoffs.

May be they added a jumper to stop custom firmware upload somewhere?

Because I cannot even get any of the the orange dots that show the .bin file upload to the sonoff esp8266. I tried blinky again. No luck. Still no orange dots.

Any ideas?

Jasz:
It seems as if nothing I do will let me program these sonoffs.

May be they added a jumper to stop custom firmware upload somewhere?

Because I cannot even get any of the the orange dots that show the .bin file upload to the sonoff esp8266. I tried blinky again. No luck. Still no orange dots.

Any ideas?

Select Flash Mode: DOUT instead of DIO.

Thanks Lenny,

I think I tried that already somewhere along the line, having read about it somewhere.

Just tried (DOUT instead of DIO ) again, with TX and RX in regular position then switched.
Don't remember the output from before, but here is what I get.

Here is result with TX & RX as they should be.

Sketch uses 248,623 bytes (25%) of program storage space. Maximum is 958,448 bytes.
Global variables use 35,588 bytes (43%) of dynamic memory, leaving 46,332 bytes for local variables. Maximum is 81,920 bytes.
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
error: failed sending 0xC0
error: failed sending 8 bytes
error: failed sending 36 bytes
error: failed sending 0xC0
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

As far as my experience goes with Sonoffs it's one of these four things.

  1. Make sure to provide enough power. Some usb-to-serial adapters cannot provide enough power to make a succesfull flash.
  2. Make sure that the connection is TX - RX and RX - TX.
  3. Make sure to pull GPIO0 to Ground BEFORE booting.
  4. The new Sonoffs require DOUT to be selected as Flash Mode.

How are you pulling GPIO0 to Ground? As you can see on this page you need to manually short R21 to pull GPIO0 to Ground. This only applies to the RF-version.

Hey Lenny,

That did it, thanks. I got it to upload sketches. That was a proper gotcha!

It seems INTEAD have more than one version of the Sonoff PCB, and that the newer ones, one of which one is shown in the below linked page, do not set GPIO0 to GND when the button is pushed.
Instead I have to hold a jumper across the two locations shown by the red connecting line, on the 3rd image down on the linked page https://tech.scargill.net/more-sonoff
I selected DOUT also.

Thanks again

Jasz:
Hey Lenny,

That did it, thanks. I got it to upload sketches. That was a proper gotcha!

It seems INTEAD have more than one version of the Sonoff PCB, and that the newer ones, one of which one is shown in the below linked page, do not set GPIO0 to GND when the button is pushed.
Instead I have to hold a jumper across the two locations shown by the red connecting line, on the 3rd image down on the linked page https://tech.scargill.net/more-sonoff
I selected DOUT also.

Thanks again

Glad to hear you got it working.

I have to correct you though for if someone else reads this thread.

that the newer ones, one of which one is shown in the below linked page, do not set GPIO0 to GND when the button is pushed.

This is incorrect. It's unrelated to newer models. The not pulling GPIO0 to GND when the button is pushed ONLY applies to the RF-version of the Sonoff.