Flashing issues with Sonoff nspanel. Please, help

I tried to flash Sonoff NSPanel using esphomeflasher first and esptool.py second.

Both reported that flashing was OK. But after successfull flash with esphomeflasher NSPanel booted Sonoff firmware, not esphome.

Then I used esptool.py (4.7). And ended up with no firmware loaded at all.

I followed these steps:

Step 1: created nspanel-sonoff-config.yaml:

substitutions:
  # Settings - Editable values
  device_name: "nspanel-sonoff"
  friendly_name: "Sonoff NSPanel"
  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password
  nextion_update_url: "http://raspberry:8123/local/nspanel_eu.tft"  # Optional
  # Add-on configuration (if needed)
  # heater_relay: "1"  # Possible values: "1" or "2"

# Core and optional configurations
packages:
  remote_package:
    url: https://github.com/Blackymas/NSPanel_HA_Blueprint
    ref: main
    refresh: 300s
    files:
      - nspanel_esphome.yaml # Basic package
      # Optional advanced and add-on configurations
      # - esphome/nspanel_esphome_advanced.yaml
      # - esphome/nspanel_esphome_addon_ble_tracker.yaml
      # - esphome/nspanel_esphome_addon_bluetooth_proxy.yaml
      # - esphome/nspanel_esphome_addon_climate_cool.yaml
      - esphome/nspanel_esphome_addon_climate_heat.yaml
      # - esphome/nspanel_esphome_addon_climate_dual.yaml
      # - esphome/nspanel_esphome_addon_cover.yaml
 
esp32:
  framework:
    type: esp-idf

Step 2: compiled esphome firmware using esphome compile nspanel-sonoff-config.yaml No errors:

Building .pioenvs/nspanel-sonoff/firmware.bin
Creating esp32 image...
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs/nspanel-sonoff/firmware.bin"], [".pioenvs/nspanel-sonoff/firmware.elf"])
Wrote 0x13bbc0 bytes to file /home/vit/work/smarthome/esphome/.esphome/build/nspanel-sonoff/.pioenvs/nspanel-sonoff/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/nspanel-sonoff/firmware.bin"], [".pioenvs/nspanel-sonoff/firmware.elf"])

Step 3: Flash:

esptool.py --port /dev/ttyUSB0 write_flash -z 0x1000 ./.esphome/build/nspanel-sonoff/.pioenvs/nspanel-sonoff/firmware.bin

Question 1: did I use correct file?

Flash finished successfully:

esptool.py v4.7.0
Serial port /dev/ttyUSB0
Connecting.......
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d4:8a:fc:97:ec:28
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x0012cfff...
Compressed 1227712 bytes to 788428...
Wrote 1227712 bytes (788428 compressed) at 0x00001000 in 69.5 seconds (effective 141.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Step 5: Device does not boot.

If I connect with picocom to the serial port using picocom -b 115200 /dev/ttyUSB0 then I see messages:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3f400020,len:198844
ets Jul 29 2019 12:21:46

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3f400020,len:198844
ets Jul 29 2019 12:21:46

Ans they are constantly repeating. LCD is off.

Could you help me and point me to the right direction?

Thanks in advance!

P.S. I flashed using esphomeflasher Sonoff M5 switch and everything works with it. But NSPanel seems to be different.

Did esphome not flash it?

esphomeflasher flashed. Also successfully. But then Sonoff firmware booted. I tried several times with the same result.

That’s why I switched to the more low-level tool.

I did not try web-based solution as it does not work for my environment. I can’t flash firmware from browser.

Is that the correct address for esphome thought it was 0x0. It’s been a while since I used command line and only once to recover a device. Web flasher makes life so much easier or at least in Windows.

Andy

Thanks for all the comments.

I resolved the issue this evening by creating firmware in the web version of esphome (running in docker), downloading OTA file and flashing it with esphomeflasher.

Important note for other newbies in NSPanel. Do not make judgement about successful or unsuccessful flashing by the UI being displayed. Sonoff UI continues to load even after successful flashing of esphome! UI changes only after TFT file (used by display) is updated. This step is described in the NSPanel_HA_Blueprint manual.