esp32 won't boot

aj_larkin
Posts: 4
Joined: Sun Jan 24, 2021 3:48 pm

esp32 won't boot

Postby aj_larkin » Sun Jan 24, 2021 6:43 pm

Esp32 endlessly reboots after flashing. Anyone have advice?

Monitor output:

Code: Select all

...
Writing at 0x00074000... (96 %)
Writing at 0x00078000... (100 %)
Wrote 693056 bytes (439172 compressed) at 0x00010000 in 9.8 seconds (effective 563.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
[100%] Built target app-flash
Done
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x33 (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:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
0x40080400: _init at ??:?

entry 0x400806ac
I (251) cpu_start: Pro cpu up.
I (251) cpu_start: Starting app cpu, entry point is 0x40081214
0x40081214: call_start_cpu1 at /home/neddie/esp/esp-idf/components/esp_system/port/cpu_start.c:126

I (0) cpu_start: App cpu up.
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (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:1
...
From here it endlessly reboots. It gets to "I (0) cpu_start: App cpu up." then reboots after a short pause.

The first line in app_main is:

Code: Select all

	esp_log_write(ESP_LOG_INFO, "AcMeter", "AcMeter app_main start");
If I remove sections of my code then the app boots and works normally, and this line shows up in monitor.
When it boot-loops it is clearly not getting to my code at all. So it is something in the configuration.

The menuconfig settings are all default except for FreeRTOS --> enable static allocation API

The problem happens on two different devices, a WROOM32 ESP32-D0WDQ6 (revision 1) from aliexpress and a pico-kit from Digikey.

Output of esptool.py image_info is:

Code: Select all

esptool.py v3.0
Image version: 1
Entry point: 400812fc
6 segments

Segment 1: len 0x181d8 load 0x3f400020 file_offs 0x00000018 [DROM]
Segment 2: len 0x042e4 load 0x3ffb0000 file_offs 0x000181f8 [BYTE_ACCESSIBLE, DRAM]
Segment 3: len 0x00404 load 0x40080000 file_offs 0x0001c4e4 [IRAM]
Segment 4: len 0x03720 load 0x40080404 file_offs 0x0001c8f0 [IRAM]
Segment 5: len 0x779d0 load 0x400d0020 file_offs 0x00020018 [IROM]
Segment 6: len 0x11a84 load 0x40083b24 file_offs 0x000979f0 [IRAM]
Checksum: 7a (valid)
Validation Hash: 27da376a55cc308ed19d9f6880230c778a073396d579c3c36ae009b12a6b1571 (valid)

ESP_Sprite
Posts: 9052
Joined: Thu Nov 26, 2015 4:08 am

Re: esp32 won't boot

Postby ESP_Sprite » Mon Jan 25, 2021 1:43 am

What does your code do? Any chance it reconfigures some GPIO that should be connected to flash?

aj_larkin
Posts: 4
Joined: Sun Jan 24, 2021 3:48 pm

Re: esp32 won't boot

Postby aj_larkin » Mon Jan 25, 2021 1:56 am

My code uses HSPI to read an external ADC, but it never gets there.

After looking through cpu_start.c, I suspect that both cpus are setting s_cpu_up to true.

The app cpu sets s_cpu_inited[1] = true, and then sits in a loop waiting for s_cpu_inited[0] == true.

But call_start_cpu0 never gets to the point where it sets this.

To try to figure out where call_start_cpu0 was hanging, I added an ESP_EARLY_LOGI right after the line "rtcio_hal_unhold_all();". It all magically started working -- app cpu finished loading and ran my code.

I'm using ESP-IDF v4.3-dev-1901-g178b122c1-dirty.

aj_larkin
Posts: 4
Joined: Sun Jan 24, 2021 3:48 pm

Re: esp32 won't boot

Postby aj_larkin » Mon Jan 25, 2021 7:47 pm

This is still happening on a variety of different boards. By adding logging to cpu_start.c I've narrowed it down: the call to bootloader_flash_clock_config in call_start_cpu0 seems to be causing a problem.

Code: Select all

ESP_EARLY_LOGI(TAG, "test 1.");

#if CONFIG_IDF_TARGET_ESP32
#if !CONFIG_SPIRAM_BOOT_INIT
    // If psram is uninitialized, we need to improve some flash configuration.
ESP_EARLY_LOGI(TAG, "test 2.");
    bootloader_flash_clock_config(&fhdr);
ESP_EARLY_LOGI(TAG, "test 3.");
    bootloader_flash_gpio_config(&fhdr);
    bootloader_flash_dummy_config(&fhdr);
    bootloader_flash_cs_timing_config();
#endif //!CONFIG_SPIRAM_BOOT_INIT
#endif //CONFIG_IDF_TARGET_ESP32
gives output

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
0x40080400: _init at ??:?

entry 0x400806ac
I (255) cpu_start: Pro cpu up.
I (255) cpu_start: Starting app cpu, entry point is 0x400811f8
0x400811f8: call_start_cpu1 at /home/neddie/esp/esp-idf/components/esp_system/port/cpu_start.c:126

I (0) cpu_start: App cpu up.
I (269) cpu_start: test 1.
I (269) cpu_start: test 2.
I (269������ѕ�Ѐ̸ml��(ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
0x40080400: _init at ??:?

entry 0x400806ac
I (255) cpu_start: Pro cpu up.
I (255) cpu_start: Starting app cpu, entry point is 0x400811f8
0x400811f8: call_start_cpu1 at /home/neddie/esp/esp-idf/components/esp_system/port/cpu_start.c:126

I (0) cpu_start: App cpu up.
I (269) cpu_start: test 1.
I (269) cpu_start: test 2.
I (269������ѕ�Ѐ̸ml��(
This board has no external psram.

On another board that does, I enabled "Component config --> esp32 specific --> support for external spi-connected ram" and the problem went away.

aj_larkin
Posts: 4
Joined: Sun Jan 24, 2021 3:48 pm

Re: esp32 won't boot

Postby aj_larkin » Wed Feb 03, 2021 3:00 pm

Switched back to idf v4.2 and the problem appears to be fixed

Who is online

Users browsing this forum: No registered users and 198 guests