Can't get S2 Mini to Flash

Hi All, I’ve got a few s2 mini’s that I thought I’d give a try. But I cant seem to get them to flash. The web Flasher does not work, it fails claiming it needs to be in boot mode etc, but when I do this (hold reset and boot and then continue to hold boot after I let go of reset) it still does not work. I can tell it’s in the correct model as the com port changes from COM3 (normal) to COM4.

SO I then down downloaded the ESP flasher, but this also does not work it just seems to do nothing for ever… I’ve downloaded the correct image for S2, placing in slot 1, then proceeded to sync… and it seems to take for ever and does nothing.

Had anyone got an S2 to flash and if so how?

Use esptool from Espressif.
You will need to upload:

  • bootloader
  • partition table
  • WLED binary

All of those require correct configuration for your particular ESP32-S2 development board.

EDIT: If you are inexperienced you may be better off using regular ESP32.

@blazoncek can I get a few more details like the link to
bootloader and partition table (binary?) and what addresses to flash them to?

I mean what ones are you refering to?

I did already try the v4 bootloader from a previous release but I have read that s2 comes with a spi bootloader and it’s not needed.

I know how to use esptool and flash using it so I just need a bit more details of how you succeed in order to duplicate it.

I have tasmota running on the S2 in question and it can control the led strip but I would rather run wled.

Play with PIO and different environments or even platforms. And use it to flash your ESP. It will also flash correct bootloader and partition map.
For me platform espressif@5.3.0 works.

For posterity I’ll provide my working PIO environment for Lolin ESP32-S2 D1 mini with 2MB PSRAM and 4MB flash. You can start with that and modify board parameters and change other build flags as required. If your board does not have PSRAM you can omit those build flags but they should not hurt.

[env:lolin_s2_mini_custom]
platform = espressif32@5.3.0
platform_packages = 
board = lolin_s2_mini
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
board_build.flash_mode = qio
board_build.f_flash = 80000000L
monitor_filters = esp32_exception_decoder
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32s2.build_flags} -D WLED_RELEASE_NAME=ESP32-S2-Lolin
  -DBOARD_HAS_PSRAM
  -DARDUINO_USB_CDC_ON_BOOT=1
  -DARDUINO_USB_MSC_ON_BOOT=0
  -DLOLIN_WIFI_FIX
  -D WLED_USE_PSRAM
  -D WLED_WATCHDOG_TIMEOUT=0
  -D CONFIG_ASYNC_TCP_USE_WDT=0
  -D DATA_PINS=16,39 # or 37
  -D PIXEL_COUNTS=30,30
  -D ABL_MILLIAMPS_DEFAULT=3000
  -D BTNPIN=18  # GPIO0 is onboard button
  -D RLYPIN=35  # Q2 on Dig-Uno
  -D IRPIN=-1
  -D HW_PIN_SCL=35
  -D HW_PIN_SDA=33
  -D HW_PIN_CLOCKSPI=7
  -D HW_PIN_DATASPI=11
  -D HW_PIN_MISOSPI=9
;  -D STATUSLED=15
  -D WLED_ENABLE_SIMPLE_UI
  -D WLED_DISABLE_ALEXA
  -D WLED_DISABLE_HUESYNC
  -D WLED_DISABLE_LOXONE
  -D WLED_DISABLE_ESPNOW
  -D USERMOD_DALLASTEMPERATURE
  -D TEMPERATURE_PIN=7  # for Dig-Uno
  -D USERMOD_PIRSWITCH
  -D PIR_SENSOR_PIN=33   # Q2 on Dig-Uno (3 for A0, 35 for Q1)
  -D PIR_SENSOR_OFF_SEC=60
  -D USERMOD_MULTI_RELAY  # 35, ...
  -D MULTI_RELAY_MAX_RELAYS=2
  -D USERMOD_AUDIOREACTIVE
  -D UM_AUDIOREACTIVE_USE_NEW_FFT
  -D AUDIOPIN=-1  # analog pin
  -D DMTYPE=1     # 0-analog/disabled, 1-I2S generic, 2-ES7243, 3-SPH0645, 4-I2S+mclk, 5-I2S PDM
  -D I2S_SDPIN=3  # A0 on Dig-Uno (35 for Q1, 33 for Q2)
  -D I2S_WSPIN=9  # Q3 on Dig-Uno
  -D I2S_CKPIN=11 # Q4 on Dig-Uno
;  -D WLED_DEBUG
  -UWLED_USE_MY_CONFIG
lib_deps = ${esp32s2.lib_deps}
  https://github.com/blazoncek/OneWire.git
  https://github.com/kosme/arduinoFFT#develop @ 1.9.2+sha.419d7b0 ;; used for USERMOD_AUDIOREACTIVE - using "known working" hash
1 Like

Thx, That’s exactly the board I have so I’ll try it and report back. Interestingly tasmota will flash and work with their generic s2 build. One wonders how.

I saw here that this person succeeded following your advice

Now I wonder how the S2 asset in the latest release is built and why it won’t work. Maybe better to not build it if it has issues as it makes folks think it is functional. I mentioned elsewhere I had another non lolin s2 dev board and it didn’t work after flashing that asset so doesn’t seem like this is a lolin d1 mini specific issue.

Ok @blazoncek your env worked! THX!

I simply clone the repo and made an override file with it.

Here are the two issues I ran across.

  1. PIO/vscode would not recognize the build task in the override file so I had to move it to the platformio.ini
[platformio]
default_envs = lolin_s2_mini_custom
  1. This board has issues getting into program mode and staying there. PIO wants to hard reset the board before upload (like the esphome based web installer) and that takes it out of programming mode. So for upload the trick is to hold the reset and gpio 0 buttons until it gets to waiting for new upload port then release the buttons then it will find the port and upload. I have no idea how to disable that reset or otherwise get this to work “normally”
Looking for upload port...
Auto-detected: /dev/ttyS0
Forcing reset using 1200bps open/close on port /dev/ttyS0
Waiting for the new upload port...
Uploading .pio/build/lolin_s2_mini_custom/firmware.bin
esptool.py v4.4
Serial port /dev/ttyACM0
Connecting...
Chip is ESP32-S2FNR2 (revision v0.0)
Features: WiFi, Embedded Flash 4MB, Embedded PSRAM 2MB, ADC and temperature sensor calibration in BLK2 of efuse V2
Crystal is 40MHz
MAC: 84:fc:e6:c5:ad:4a
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00004fff...

now the question is can I/we make a generic S2 build that will work for any S2 like the tasmota32s2.factory.bin file does?

If you have a bunch of these devices then by all means invest your time and figure out a way. We’d appreciate it.

This is not a pio specific flash issue. It’s the same with for example the tasmota web installer (based on esphome web installer).

I can flash this board with esptool but I MUST set NO before reset. And I must get it into programming mode by holding gpio 0 down at power up for 5 secs.

I think pio and the esphome webinstaller both do this because they assume the board can be automatically put into program mode and this is why there is the issue.

It’s hard enough just to get the thing into programming mode to start. I think that’s a design issue I can’t fix. Other lolin mini boards can be put into programming mode “automatically” but not this one.

I have a handful of them luckily not hundreds as there appears no fix.

Looks like indeed getting into programming mode was a board design flaw.

Hello,
I now have this problem with my own circuit boards and hope you can help me.

I can flash TASmota without any problems and it works.

However, as soon as I flash WLED, whether via PlatformIO or via Bin File, I get:

Rx][18:05:37.651] E (337) esp_core_dump_flash: No core dump partition found!
[Rx][18:05:37.651] E (337) esp_core_dump_flash: No core dump partition found!
[Rx][18:05:37.651] E (340) psram: PSRAM ID read error: 0x00030000
[Rx][18:05:37.651] ./components/esp_littlefs/src/littlefs/lfs.c:1229:error: Corrupted dir pair at {0x0, 0x1}
[Rx][18:05:37.651] E (350) esp_littlefs: mount failed, (-84)
[Rx][18:05:37.651] E (353) esp_littlefs: Failed to initialize LittleFS
[Rx][18:06:06.320] ESP ROM:esp32s2-rc4-20191025
[Rx][18:06:06.320] Build:Oct 25 2019

If you are just flashing a prebuilt binary that is not what I did here. I cloned the wled github repo and had PIO build and then flash the build using the environment settings mentioned above.

@blazoncek. Is this environment build now included in 0.14.4 assets so I no longer have build my own binary? a quick look seems no.

0.15 has a working Wemos S2 Mini environment.

@blazoncek

Not sure what has changed but now I am having trouble getting board flashed with this custom env (I did pull latest main branch so maybe that caused the issue?). I did get it flashed once but it would not go into AP mode so probably binary was no good (don’t have enough PIO to debug this, What if anything can I do from serial terminal?)

So…I checked out the 15 b4 you said it would “fix” things but it won’t compile

Compiling .pio/build/lolin_s2_mini/lib00e/IRremoteESP8266/ir_Haier.cpp.o
wled00/wled_server.cpp:3:10: fatal error: html_ui.h: No such file or directory

*****************************************************************
* Looking for html_ui.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:html_ui.h"
* Web  > https://registry.platformio.org/search?q=header:html_ui.h
*
*****************************************************************

 #include "html_ui.h"
          ^~~~~~~~~~~
compilation terminated.
*** [.pio/build/lolin_s2_mini/src/wled_server.cpp.o] Error 1

Do you have an s2 mini you can try to confirm it is working?

I can’t use the web installer because of programming mode issue but can I download the binary and use esptool. If so what are the details of the esptool command line for flashing the binary from github releases?

Well, nevermind. I got one mini flashed and working. Don’t know why the other two won’t work. They work with tasmota. It worked with the last commit of that dev branch of arduinoFFT

I found the esptool settings so I will try with 15 b4 release asset again. I see though that the release assets for 15b4 don’t include the s2 d1-mini. AFAIK that generic s2 bin won’t work.

https://kno.wled.ge/basics/install-binary/#flashing-method-2-esptool

For the boards for which the AP would not come up I had to use esptool and erase the flash first. I also set the board upload speed.

Here is the custom environment currently working for me.

[env:lolin_s2_mini_custom]
platform = espressif32@5.3.0
platform_packages = 
board = lolin_s2_mini
board_upload.before_reset = usb_reset
upload_speed = 115200
board_upload.after_reset = no_reset
board_build.partitions = tools/WLED_ESP32_4MB_1MB_FS.csv
board_build.flash_mode = qio
board_build.f_flash = 80000000L
monitor_filters = esp32_exception_decoder
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32s2.build_flags} -D WLED_RELEASE_NAME=ESP32-S2-Lolin
  -DBOARD_HAS_PSRAM
  -DARDUINO_USB_CDC_ON_BOOT=1
  -DARDUINO_USB_MSC_ON_BOOT=0
  -DLOLIN_WIFI_FIX
  -D WLED_USE_PSRAM
  -D WLED_WATCHDOG_TIMEOUT=0
  -D CONFIG_ASYNC_TCP_USE_WDT=0
  -D DATA_PINS=16,39 # or 37
  -D PIXEL_COUNTS=30,30
  -D ABL_MILLIAMPS_DEFAULT=3000
  -D BTNPIN=18  # GPIO0 is onboard button
  -D RLYPIN=35  # Q2 on Dig-Uno
  -D IRPIN=-1
  -D HW_PIN_SCL=35
  -D HW_PIN_SDA=33
  -D HW_PIN_CLOCKSPI=7
  -D HW_PIN_DATASPI=11
  -D HW_PIN_MISOSPI=9
;  -D STATUSLED=15
  -D WLED_ENABLE_SIMPLE_UI
  -D WLED_DISABLE_ALEXA
  -D WLED_DISABLE_HUESYNC
  -D WLED_DISABLE_LOXONE
  -D WLED_DISABLE_ESPNOW
  -D USERMOD_DALLASTEMPERATURE
  -D TEMPERATURE_PIN=7  # for Dig-Uno
  -D USERMOD_PIRSWITCH
  -D PIR_SENSOR_PIN=33   # Q2 on Dig-Uno (3 for A0, 35 for Q1)
  -D PIR_SENSOR_OFF_SEC=60
  -D USERMOD_MULTI_RELAY  # 35, ...
  -D MULTI_RELAY_MAX_RELAYS=2
  -D USERMOD_AUDIOREACTIVE
  -D UM_AUDIOREACTIVE_USE_NEW_FFT
  -D AUDIOPIN=-1  # analog pin
  -D DMTYPE=1     # 0-analog/disabled, 1-I2S generic, 2-ES7243, 3-SPH0645, 4-I2S+mclk, 5-I2S PDM
  -D I2S_SDPIN=3  # A0 on Dig-Uno (35 for Q1, 33 for Q2)
  -D I2S_WSPIN=9  # Q3 on Dig-Uno
  -D I2S_CKPIN=11 # Q4 on Dig-Uno
;  -D WLED_DEBUG
  -UWLED_USE_MY_CONFIG
lib_deps = ${esp32s2.lib_deps}
  https://github.com/blazoncek/OneWire.git
  https://github.com/kosme/arduinoFFT#7059599c5923ca8a70fbcd44d97c5f051537f9b4
  ; #develop @ 1.9.2+sha.419d7b0 ;; used for USERMOD_AUDIOREACTIVE - using "known working" hash

FYI That’s my dev environment that has been made obsolete since.
Use platform 6.3.x and you can remove some build flags.

@blazoncek ok, so I checked out 15 b4 and built it (just lolin s2 mini as it is in repo) and it works! yea

…But I can’t use the github release asset binary because

  1. I can’t use the web installer (see above about not getting into program mode)
  2. I tried to use esptool which works for a tasmota factory bin but I think the bootloader procedure and the addresses for flashing WLED are not ok for s2. Install WLED Binary - WLED Project. So how is platformio using esptool correctly as obviously it is?
  1. hold “program” button during boot
  2. the instructions are partially ok, but you also need partition map and app0 binary.

Check: [WEB Installer] Lolin S3 mini loads but does't boot wled · Issue #22 · Aircoookie/WLED-WebInstaller · GitHub

I also posted some info on Discord. Check pinned messages.

Per

  1. Have you @blazoncek ever successfully used the web installer with this board? No matter when and how long i press the program button it has never worked for me and that could be said for both the tasmota and esphome web installers which are basically the same code. You never get by this warning. ESP Web Tools See post above (march 11 and link).
    image

  2. I scrolled through pinned messages from you in Hardware and Issues at discord and didn’t see any info about s2 flashing. So from the github issue I read this.

ESP32 and its variants S2, S3 and C3 use bootloader, partition map and firmware files to successfully flash a device. Additionally, you need boot_app0.bin at 0xe000.

so to summarize what I can divine according to the posts

  • bootloader at 0x1000 which boot loader? is it specific for s2, download link?
  • partition map at x?000, download link?
  • firmware at 0x8000 I assume that this is the ESP32-S2 release .bin
  • boot_app0.bin at 0xe000 , download link?

nothing flashed at 0x000?

I’d like to be able to flash using the precompiled binary (I can write a bash script for esptool to make it easy save for having to “fiddle” with the program button at the right time). Still if it’s not possible I’m ok with using pio at this point.

Also, what I haven’t tried is the OTA upgrade once it’s flashed. If that just replaces the firmware then it might work fine since the other pieces are already there.