ESP32-S2 loop enter failed

Hello,
I’m facing a problem when I use the ESP32-S2, Arduino framework in PlatformIO. The same procedure works fine with an ESP32.

Code:

#include <Arduino.h>
void setup() {
Serial.begin(115200);
}

void loop() {
Serial.println(“Hello”);
delay(200);
}

ini

[env:adafruit_metro_esp32s2]
platform = espressif32
board = adafruit_metro_esp32s2
framework = arduino
monitor_speed = 115200

After build and upload, I reset the ESP32-S2 and see the boot sequence, but no string as defined in the loop

Boot sequence:

ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x1 (POWERON),boot:0x9 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x17c0
load:0x4004c000,len:0xfd4
load:0x40050000,len:0x2fa0
entry 0x4004c340
␛[0;32mI (21) boot: ESP-IDF v4.3.1-480-g233dc30fb1 2nd stage bootloader␛[0m
␛[0;32mI (21) boot: compile time 10:09:11␛[0m
␛[0;32mI (21) boot: chip revision: 0␛[0m
␛[0;32mI (25) qio_mode: Enabling default flash chip QIO␛[0m
␛[0;32mI (30) boot.esp32s2: SPI Speed      : 80MHz␛[0m      
␛[0;32mI (35) boot.esp32s2: SPI Mode       : QIO␛[0m        
␛[0;32mI (40) boot.esp32s2: SPI Flash Size : 4MB␛[0m        
␛[0;32mI (45) boot: Enabling RNG early entropy source...␛[0m
␛[0;32mI (50) boot: Partition Table:␛[0m
␛[0;32mI (54) boot: ## Label            Usage          Type ST Offset   Length␛[0m
␛[0;32mI (61) boot:  0 nvs              WiFi data        01 02 00009000 00005000␛[0m
␛[0;32mI (68) boot:  1 otadata          OTA data         01 00 0000e000 00002000␛[0m
␛[0;32mI (76) boot:  2 ota_0            OTA app          00 10 00010000 00160000␛[0m
␛[0;32mI (83) boot:  3 ota_1            OTA app          00 11 00170000 00160000␛[0m
␛[0;32mI (91) boot:  4 uf2              factory app      00 00 002d0000 00040000␛[0m
␛[0;32mI (98) boot:  5 ffat             Unknown data     01 81 00310000 000f0000␛[0m    
␛[0;32mI (106) boot: End of partition table␛[0m
␛[0;32mI (110) boot: Detect double reset using RC on GPIO 38 to enter UF2 bootloader␛[0m
␛[0;32mI (118) esp_image: segment 0: paddr=002d0020 vaddr=3f000020 size=02f78h ( 12152) map␛[0m
␛[0;32mI (129) esp_image: segment 1: paddr=002d2fa0 vaddr=3ffbca30 size=01bd0h (  7120) load␛[0m
␛[0;32mI (136) esp_image: segment 2: paddr=002d4b78 vaddr=40022000 size=0aa2ch ( 43564) load␛[0m
␛[0;32mI (153) esp_image: segment 3: paddr=002df5ac vaddr=50000000 size=00010h (    16) load␛[0m
␛[0;32mI (153) esp_image: segment 4: paddr=002df5c4 vaddr=00000000 size=00a54h (  2644) ␛[0m    
␛[0;32mI (160) esp_image: segment 5: paddr=002e0020 vaddr=40080020 size=10abch ( 68284) map␛[0m
␛[0;32mI (185) boot: Loaded app from partition at offset 0x2d0000␛[0m
␛[0;32mI (185) boot: Disabling RNG early entropy source...␛[0m
␛[0;32mI (197) c���␆�f�~␀�␘����Սѥ���cache       : size 8KB, 4Ways, cache line size 32Byte␛[0m
␛[0;32mI (198) cpu_start: Pro cpu up.␛[0m
␛[0;32mI (211) cpu_start: Pro cpu start user code␛[0m
␛[0;32mI (211) cpu_start: cpu freq: 160000000␛[0m
␛[0;32mI (211) cpu_start: Application information:␛[0m
␛[0;32mI (216) cpu_start: Project name:     tinyuf2␛[0m
␛[0;32mI (221) cpu_start: App version:      0.6.2␛[0m
␛[0;32mI (225) cpu_start: Compile time:     Dec  8 2021 10:09:05␛[0m
␛[0;32mI (231) cpu_start: ELF file SHA256:  bcef9f58e8eb2367...␛[0m
␛[0;32mI (237) cpu_start: ESP-IDF:          v4.3.1-480-g233dc30fb1␛[0m
␛[0;32mI (244) heap_init: Initializing. RAM available for dynamic allocation:␛[0m
␛[0;32mI (251) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM␛[0m
␛[0;32mI (257) heap_init: At 3FFD1B88 len 0002A478 (169 KiB): DRAM␛[0m
␛[0;32mI (263) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM␛[0m
␛[0;32mI (270) spi_flash: detected chip: generic␛[0m
␛[0;32mI (274) spi_flash: flash io: qio␛[0m
␛[0;32mI (278) cpu_start: Starting scheduler on PRO CPU.␛[0m

Any help would be appreciated

Under which settings does the above sketch work in the Arduino IDE?

I compared it with ESP32, which works fine in PlatformIO Arduino framework. I don’t use Arduino IDE

The same code produce the expected serial output:

rst:0x1 (POWERON_RESET),boot:0x12 (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:0x3fff0030,len:1184
load:0x40078000,len:12784
load:0x40080400,len:3032
entry 0x400805e4
Hello
Hello
Hello
Hello
Hello
Hello

Ini has been modified to:

[env:adafruit_metro_esp32s2]
platform = espressif32
;board = adafruit_metro_esp32s2
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200

Very strange… repeated the same code with the ESP32-S2 (board = adafruit_metro_esp32s2 in ini) and receive now the following output:

load:0x40050000,len:0x2fa0
entry 0x4004c340
␛[0;32mI (24) boot: ESP-IDF v4.3.1-480-g233dc30fb1 2nd stage bootloader␛[0m
␛[0;32mI (24) boot: compile time 10:09:11␛[0m
␛[0;32mI (24) boot: chip revision: 0␛[0m
␛[0;31mE (28) boot_comm: mismatch chip ID, expected 2, found 0␛[0m
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x3 (RTC_SW_SYS_RST),boot:0x9 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40051636
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x17c0
load:0x4004c000,len:0xfd4
load:0x40050000,len:0x2fa0
entry 0x4004c340
␛[0;32mI (24) boot: ESP-IDF v4.3.1-480-g233dc30fb1 2nd stage bootloader␛[0m
␛[0;32mI (24) boot: compile time 10:09:11␛[0m
␛[0;32mI (24) boot: chip revision: 0␛[0m
␛[0;31mE (28) boot_comm: mismatch chip ID, expected 2, found 0␛[0m
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x3 (RTC_SW_SYS_RST),boot:0x9 (SPI_FAST_FLASH_BOOT)

But that’s expected, flashig an ESP32 firmwre on an ESP32S2 is just not compatible.

Which exact development board do you have?

the board type has been changed to the ESP32S2 in ini… or is that not enough?

It is a custom board with an ESP32-S2-WROVER

Do you read the serial output via a USB-to-serial chip on the board (like a CH340) or does that come from the ESP32-S2’s USB port itself?

Remember when you are using this, the board definition says

so Serial output will go to the USB-serial device created on the ESP32S2’s USB port.

If that does not apply to you and you want it out via hardware UART, use board = esp32-s2-saola-1 instead, that one doesn’t have it…

ok, I changed the ini, but the problem is still the same…

[env:adafruit_metro_esp32s2]
platform = espressif32
board = esp32-s2-saola-1
framework = arduino
monitor_speed = 115200

the same problem with a new created project:

[env:esp32-s2-saola-1]
platform = espressif32
board = esp32-s2-saola-1
framework = arduino
monitor_speed = 115200

But what’s the answer to this question

I use a CP210X USB2UART device connected to the ESP32-S2 RXD0/TXD0

In addition the same behaviour is with esp-prog with usage of the UART interface (not the Jtag)

Then per https://cdn-reichelt.de/documents/datenblatt/A200/ESP32-S2-WROVER_ESP32-S2-WROVER-I_DATASHEET_EN.pdf page 11 those pins should be TX = IO43 and RX=IO44.

image

which means wthat when you select board = esp32-s2-saola-1 which gives you

which maps to this variant and UART pins

it should be correct for pins at least.

Can you change the code to blink an LED instead of trying to send something via UART?

Use

on an arbitrary free IO and see if the voltage changes at that pin at all.

If it does, it does enter loop() and when you have board = esp32-s2-saola-1 selected but still see no output it could because of a hardware fault (TX/RX swapped or whatever)

1 Like

it seems that there was a problem with the prototype board. I have connected another one and the code works fine with the serial output for the ESP32-S2.

Many thanks for your support @maxgerhardt

1 Like