Boot Loop on ESP32-S3

michalk
Posts: 20
Joined: Wed Mar 24, 2021 7:09 pm

Boot Loop on ESP32-S3

Postby michalk » Tue Sep 13, 2022 1:24 pm

In troubleshooting a USB problem, I've somehow stumbled into a condition that I don't know how to recover from.
I'm using an ESP32-S3-DevKitC bare, nothing connected but a USB cable to UART connector. VSCode, PlatformIO, Arduino framework.

After flashing, I get the following infinite loop on the USB console:

```
ELF file SHA256: 0000000000000000
Rebooting...
�ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x18 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40376b40
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3808,len:0x43c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2a3c
SHA-256 comparison failed:
Calculated: dcde8d8a4817d9bf5d5d69a7247667264e4e10ac7493514868b61f5aa6146539
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x403c98d8
assert failed: do_core_init startup.c:298 (flash_ret == ESP_OK)
Backtrace:0x40376f36:0x3fceb1800x40379ce9:0x3fceb1a0 0x4037f2a5:0x3fceb1c0 0x42009292:0x3fceb2f0 0x403768a1:0x3fceb320 0x403cd6ef:0x3fceb350 0x403cd9ae:0x3fceb380 0x403c992d:0xD
```
My platformio.ini:
```
[env]
framework = arduino
platform = espressif32
build_unflags = -Os
build_flags =
-DDEBUG_MODE
-Wswitch
-O3
-mlongcalls
debug_init_break = tbreak setup
lib_extra_dirs =
~/git/libraries/

[env:esp32-s3]
platform = https://github.com/platformio/platform-espressif32.git
board = esp32-s3-devkitc-1
debug_init_break = tbreak setup
debug_tool = custom
debug_server =
/home/michalk/git/openocd-esp32/src/openocd
-s
/home/michalk/git/openocd-esp32/tcl/
-f
/home/michalk/git/openocd-esp32/tcl/board/esp32s3-builtin.cfg
build_flags =
${env.build_flags}
```

My source code:
```
#include "Arduino.h"
#define SerialUART Serial
#define SerialCDC USBSerial

void setup() {
SerialUART.begin(115200);
SerialUART.println("SerialUART: Hello World!");
}
void loop() {
SerialUART.print("SerialUART ");
SerialUART.println(millis());
delay(500);
}
```

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: Boot Loop on ESP32-S3

Postby chegewara » Tue Sep 13, 2022 1:54 pm

Its module with OPI flash enabled, it wont work with PIO yet.
https://github.com/platformio/platform- ... issues/837

michalk
Posts: 20
Joined: Wed Mar 24, 2021 7:09 pm

Re: Boot Loop on ESP32-S3

Postby michalk » Tue Sep 13, 2022 2:26 pm

Thanks for the reply.
I have two boards, D3N32R8V One is working, the other not.
I'm planning on searching for a way to read the eFuse, to see if that's the issue.
I'm also suspicious of my partitions. I'm fairly new to ESP32, and I don't know if I even need partitions unless I'm doing NVRAM. So, I'm also going to search on that issue.

I'm finding documentation on the partitions, but nothing yet indicating that I need partitions or filesystems.

michalk
Posts: 20
Joined: Wed Mar 24, 2021 7:09 pm

Re: Boot Loop on ESP32-S3

Postby michalk » Tue Sep 13, 2022 3:01 pm

This is interesting.
The stock esp32-s3-devkitc-1.json doesn't work, whereas it used to.
Following your posts, I used this file:
https://github.com/platformio/platform- ... cd.json#L5
I flashed, and the program ran correctly as expected.
I then started picking out parts that are different, merging the working one into the stock one.

If I flash with the stock, I get the bootloop.
If I then flash with the merged, I get the bootloop.

If I flash with the camlcd version, it works.
Then, if I flash with merged it still works.

Here is my merged version:

Code: Select all

{
  "build": {
    "arduino":{
      "ldscript": "esp32s3_out.ld",
      "partitions": "default_8MB.csv",
      "memory_type": "opi_opi"
    },
    "boot": "opi",
    "core": "esp32",
    "extra_flags": [
      "-DARDUINO_ESP32S3_DEV",
      "-DARDUINO_USB_MODE=1",
      "-DARDUINO_RUNNING_CORE=1",
      "-DARDUINO_EVENT_RUNNING_CORE=1"
    ],
    "f_cpu": "240000000L",
    "f_flash": "80000000L",
    "flash_mode": "dout",
    "hwids": [
      [
        "0x303A",
        "0x1001"
      ]
    ],
    "mcu": "esp32s3",
    "variant": "esp32s3"
  },
  "connectivity": [
    "wifi"
  ],
  "debug": {
    "default_tool": "esp-builtin",
    "onboard_tools": [
      "esp-builtin"
    ],
    "openocd_target": "esp32s3.cfg"
  },
  "frameworks": [
    "arduino",
    "espidf"
  ],
  "name": "Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM)",
  "upload": {
    "flash_size": "8MB",
    "maximum_ram_size": 327680,
    "maximum_size": 8388608,
    "require_upload_port": true,
    "speed": 460800
  },
  "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html",
  "vendor": "Espressif"
}

michalk
Posts: 20
Joined: Wed Mar 24, 2021 7:09 pm

Re: Boot Loop on ESP32-S3

Postby michalk » Tue Sep 13, 2022 3:07 pm


chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: Boot Loop on ESP32-S3

Postby chegewara » Tue Sep 13, 2022 3:13 pm

Its good you managed to solve the problem, even if its not reliable.
I spent few hours to make it work and failed, but it is not something i have to use in any project, so im not wasting time on it.
If you find a good solution, please share with us.

Here you can find more about efuse and option to read:
https://docs.espressif.com/projects/esp ... spefuse-py
and this one is for flash mode:
FLASH_TYPE (BLOCK0) Selects SPI flash type = 4 data lines R/W (0b0)
where 0b1 means OPI

https://docs.espressif.com/projects/esp ... r-handling
python3 ./espefuse.py -p /dev/<serial_device> --do-not-confirm burn_efuse FLASH_TYPE 1

michalk
Posts: 20
Joined: Wed Mar 24, 2021 7:09 pm

Re: Boot Loop on ESP32-S3

Postby michalk » Tue Sep 13, 2022 5:27 pm

Changing the ldscript from esp32s3_out.ld to esp32_out.ld seems to be a fix, but not the fix. It's like there is residual information from load to load.

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: Boot Loop on ESP32-S3

Postby chegewara » Tue Sep 13, 2022 9:15 pm

After few more hours of digging finally i can flash and run ESP32S3-N32R8 with flash mode OPI in platformio.
Here is temporary solution, before platformio maintainers fix it:
https://github.com/platformio/platform- ... 1245958447

Who is online

Users browsing this forum: Majestic-12 [Bot] and 160 guests