Flashing the eWeLink PCIe Computer Remote (SANT-SUD01)

I’m trying to flash the eWeLink PCIe Computer Remote (SANT-SUD01) as detailed here.

My Pi running Home Assistant OS & ESPHome has insufficient memory to successfully compile so I have to compile and run on a WSL Ubuntu machine. However it is successfully identified & Backed Up the chip and stock firmware and am using the USB to UART Module (Micro/Mini/Type-A or Type-C) | The Pi Hut module to connect to it.

When flashing it usually fails at 50% - is there an undocumented stage that’s required first or should this be working?

Also tried directly from python on Windows and get the same error.

C:\Users\Kev\Downloads>C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts\esptool.exe --port COM10 --before default_reset --after hard_reset --chip esp8266 write_flash -z --flash_size detect 0x0 mclaren-pc-power-control.bin


esptool.py v4.6.2
Serial port COM10
Connecting...
Chip is ESP8285N08
Features: WiFi, Embedded Flash
Crystal is 26MHz
MAC: 48:55:19:4c:39:54
Stub is already running. No upload is necessary.
Configuring flash size...
Auto-detected Flash size: 1MB
Flash will be erased from 0x00000000 to 0x0006cfff...
Compressed 444272 bytes to 314232...
Writing at 0x00005d92... (10 %)Traceback (most recent call last):
  File "C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\esptool\__init__.py", line 1073, in _main
    main()
  File "C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\esptool\__init__.py", line 868, in main
    operation_func(esp, args)
  File "C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\esptool\cmds.py", line 595, in write_flash
    esp.flash_defl_block(block, seq, timeout=timeout)
  File "C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\esptool\loader.py", line 131, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\esptool\loader.py", line 1037, in flash_defl_block
    self.check_command(
  File "C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\esptool\loader.py", line 436, in check_command
    val, data = self.command(op, data, chk, timeout=timeout)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\esptool\loader.py", line 405, in command
    p = self.read()
        ^^^^^^^^^^^
  File "C:\Users\Kev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\esptool\loader.py", line 338, in read
    return next(self._slip_reader)
           ^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

A fatal error occurred: The chip stopped responding.

esptool.py --before no_reset --port /dev/ttyACM0 chip_id

esptool.py v4.6.2
Serial port /dev/ttyACM0
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: 48:55:19:4c:39:54
Stub is already running. No upload is necessary.
Chip ID: 0x004c3954
Hard resetting via RTS pin...

esptool.py --before no_reset --port /dev/ttyACM0 flash_id

esptool.py v4.6.2
Serial port /dev/ttyACM0
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: 48:55:19:4c:39:54
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 3214
Detected flash size: 1MB
Hard resetting via RTS pin...

esptool.py --port /dev/ttyACM0 read_flash 0x000000 0x100000 flash_backup.bin

esptool.py v4.6.2
Serial port /dev/ttyACM0
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: 48:55:19:4c:39:54
Stub is already running. No upload is necessary.
1048576 (100 %)
1048576 (100 %)
Read 1048576 bytes at 0x00000000 in 93.2 seconds (90.0 kbit/s)...
Hard resetting via RTS pin...

Yaml:- mclaren-pc-power-control.yaml

substitutions:
  friendly_name: "McLaren PC Power Control"
  friendly_name_short: "McLaren Control"

  hostname: "mclaren-pc-power-control"

esphome:
  name: ${hostname}

  # Shows up in UI
  comment: "Remote power button for ${friendly_name_short}."

wifi:
  ssid: "MYSSID
  password: "MyPASS"


esp8266:
  # Specifically a 'ESP8285N08' with 1MB built in flash
  # See: https://docs.platformio.org/en/stable/boards/espressif8266/esp8285.html
  board: esp8285

logger:
  level: INFO

script:
  - id: regular_press
    mode: single
    then:
      - output.turn_on: out_relay
      - delay: .5s
      - output.turn_off: out_relay

status_led:
  pin:
    number: GPIO13
    inverted: True

sensor:
  - platform: pulse_meter
    id: power_status_pulses
    pin: GPIO0
    timeout: 5s

switch:
  - name: "${friendly_name_short} Power"
    id: sw_pc_power
    platform: template
    lambda: |-
      if (id(power_status_pulses).state > 60.0f) {
        return true;
      } else {
        return false;
      }

#Replace the lambda function above with the one below if you have inverted the relay output
#    lambda: |-
#      if (id(power_status_pulses).state > 60.0f) {
#        return false;
#      } else {
#        return true;
#      }

    # Mimic the user pressing the button
    turn_on_action:
      - script.execute: regular_press
    turn_off_action:
      - script.execute: regular_press

output:
  - platform: gpio
    id: out_relay
    #Inverts relay operation, this avoids force shutdown behavior on some motherboards. Uncomment here and replace the above lambda if you are having this problem.
    #inverted: True
    pin: GPIO12

# Enable Home Assistant API
api:
  encryption:
    key: "MYENCRYPTION"

ota:
  password: "MYPASSWORD"

Run
esphome run mclaren-pc-power-control.yaml

Then Errors with

(number): 1
esptool.py v4.6.2
Serial port /dev/ttyACM0
Connecting....
Chip is ESP8285N08
Features: WiFi, Embedded Flash
Crystal is 26MHz
MAC: 48:55:19:4c:39:54
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 1MB
Flash will be erased from 0x00000000 to 0x0006dfff...
Compressed 448496 bytes to 316371...
Writing at 0x00013f7f... (20 %)ERROR Running command failed:
ERROR Please try running esptool.py --before default_reset --after hard_reset --baud 460800 --port /dev/ttyACM0 --chip esp8266 write_flash -z --flash_size detect 0x0 /mnt/c/Users/Kev/Downloads/.esphome/build/mclaren-pc-power-control/.pioenvs/mclaren-pc-power-control/firmware.bin locally.
INFO Upload with baud rate 460800 failed. Trying again with baud rate 115200.
esptool.py v4.6.2
Serial port /dev/ttyACM0
Connecting......................................
ERROR Running command failed: Failed to connect to ESP8266: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
ERROR Please try running esptool.py --before default_reset --after hard_reset --baud 115200 --port /dev/ttyACM0 --chip esp8266 write_flash -z --flash_size detect 0x0 /mnt/c/Users/Kev/Downloads/.esphome/build/mclaren-pc-power-control/.pioenvs/mclaren-pc-power-control/firmware.bin locally.

Reconnecting and running the command manually produces the following:-

sudo chmod 777 /dev/ttyACM0 ;esptool.py --before default_reset --after hard_reset --port /dev/ttyACM0 --chip esp8266 write_flash -z --flash_size detect 0x0 /mnt/c/Users/Kev/Downloads/.esphome/build/mclaren-pc-power-control/.pioenvs/mclaren-pc-power-control/firmware.bin
esptool.py v4.6.2
Serial port /dev/ttyACM0
Connecting....
Chip is ESP8285N08
Features: WiFi, Embedded Flash
Crystal is 26MHz
MAC: 48:55:19:4c:39:54
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Flash will be erased from 0x00000000 to 0x0006dfff...
Compressed 448496 bytes to 316371...
Writing at 0x0002693c... (35 %)Traceback (most recent call last):
  File "/home/kev/.local/lib/python3.10/site-packages/esptool/__init__.py", line 1073, in _main
    main()
  File "/home/kev/.local/lib/python3.10/site-packages/esptool/__init__.py", line 868, in main
    operation_func(esp, args)
  File "/home/kev/.local/lib/python3.10/site-packages/esptool/cmds.py", line 595, in write_flash
    esp.flash_defl_block(block, seq, timeout=timeout)
  File "/home/kev/.local/lib/python3.10/site-packages/esptool/loader.py", line 131, in inner
    return func(*args, **kwargs)
  File "/home/kev/.local/lib/python3.10/site-packages/esptool/loader.py", line 1037, in flash_defl_block
    self.check_command(
  File "/home/kev/.local/lib/python3.10/site-packages/esptool/loader.py", line 436, in check_command
    val, data = self.command(op, data, chk, timeout=timeout)
  File "/home/kev/.local/lib/python3.10/site-packages/esptool/loader.py", line 405, in command
    p = self.read()
  File "/home/kev/.local/lib/python3.10/site-packages/esptool/loader.py", line 338, in read
    return next(self._slip_reader)
StopIteration

A fatal error occurred: The chip stopped responding.

Highest I’ve gotten is 50%

IMHO try to limit baud rate to 115200 during flashing.
Use -b 115200 or --baud 115200 as described here, as well as suggested in attached output.

Drat

Tried again this morning (putting the pin header from the bottom this morning), first without the baud change and errored with

Wrote 444272 bytes (314232 compressed) at 0x00000000 in 30.3 seconds (effective 117.5 kbit/s)...
File  md5: 3caa876c6b6da93a4d8e7031c747f750
Flash md5: 659c8d50dcf4f6324dee8d137d144f59
MD5 of 0xFF is e44a52f704ae58b93ebfc0d3293ae871

A fatal error occurred: MD5 of file does not match data in flash!

115200 gets

Wrote 444272 bytes (314232 compressed) at 0x00000000 in 30.3 seconds (effective 117.5 kbit/s)...
File  md5: 3caa876c6b6da93a4d8e7031c747f750
Flash md5: 659c8d50dcf4f6324dee8d137d144f59
MD5 of 0xFF is e44a52f704ae58b93ebfc0d3293ae871

A fatal error occurred: MD5 of file does not match data in flash!

and 28000 gets

Wrote 444272 bytes (314232 compressed) at 0x00000000 in 126.5 seconds (effective 28.1 kbit/s)...
File  md5: 3caa876c6b6da93a4d8e7031c747f750
Flash md5: 67d1b04c410514571bfdde0a46c19ff3
MD5 of 0xFF is e44a52f704ae58b93ebfc0d3293ae871

A fatal error occurred: MD5 of file does not match data in flash!

So looking like a dirty connection and just using a PIN header won’t work (my soldering skills are horrifically bad :frowning: )