Migrated to ESP-IDF, now CPU won't start

hesthewanderer
Posts: 2
Joined: Sun Sep 20, 2020 8:27 pm

Migrated to ESP-IDF, now CPU won't start

Postby hesthewanderer » Sun Sep 20, 2020 8:40 pm

Hello, I am attempting to move a project from ESP32-Arduino to ESP-IDF with Arduino as a component.

Everything compiles fine, but after flashing it seems like the CPU never starts (no cpu_start in the logs), which triggers wdt timeout. This happens if I set CONFIG_ARDUINO_AUTOSTART=y and have a setup() / loop() and also if I don't set autostart and just have an app_main() that calls initArduino() first.

Is there a missing menuconfig setting that would cause this? I'm using a custom board with an ESP32-WROVER 16MB chip, have had no problems with this board running the same code compiled under ESP32-Arduino.

Log:

Code: Select all

rst:0xc (SW_CPU_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:0x3fff0018,len:4
load:0x3fff001c,len:8896
ho 0 tail 12 room 4
load:0x40078000,len:14824
ho 0 tail 12 room 4
load:0x40080400,len:5152
entry 0x400806f0
D (78) bootloader_flash: mmu set block paddr=0x00000000 (was 0xffffffff)
I (85) boot: Chip Revision: 3
I (93) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (48) boot: ESP-IDF 3.40001.200521 2nd stage bootloader
I (48) boot: compile time 16:27:13
I (48) boot: Enabling RNG early entropy source...
D (50) qio_mode: Probing for QIO mode enable...
D (55) qio_mode: Raw SPI flash chip id 0xc84018
D (59) qio_mode: Manufacturer ID 0xc8 chip ID 0x4018
I (64) qio_mode: Enabling default flash chip QIO
D (68) qio_mode: Initial flash chip status 0x2
D (72) qio_mode: QIO mode already enabled in flash
D (77) qio_mode: Enabling QIO mode...
D (80) boot: magic e9
D (82) boot: segments 04
D (84) boot: spi_mode 02
D (86) boot: spi_speed 00
D (89) boot: spi_size 04
I (91) boot: SPI Speed      : 40MHz
I (94) boot: SPI Mode       : QIO
I (97) boot: SPI Flash Size : 16MB
D (100) bootloader_flash: mmu set paddr=00010000 count=1 size=c00 src_addr=10000 src_addr_aligned=10000
D (110) boot: mapped partition table 0x10000 at 0x3f400000
D (115) flash_parts: partition table verified, 7 entries
I (120) boot: Partition Table:
I (123) boot: ## Label            Usage          Type ST Offset   Length
D (129) boot: load partition table entry 0x3f400000
D (134) boot: type=1 subtype=2
I (136) boot:  0 nvs              WiFi data        01 02 00011000 00004000
D (143) boot: load partition table entry 0x3f400020
D (148) boot: type=1 subtype=0
I (150) boot:  1 otadata          OTA data         01 00 00015000 00002000
D (157) boot: load partition table entry 0x3f400040
D (162) boot: type=1 subtype=1
I (164) boot:  2 phy_init         RF data          01 01 00017000 00001000
D (171) boot: load partition table entry 0x3f400060
D (176) boot: type=0 subtype=0
I (178) boot:  3 factory          factory app      00 00 00020000 00200000
D (185) boot: load partition table entry 0x3f400080
D (190) boot: type=0 subtype=10
I (192) boot:  4 ota_0            OTA app          00 10 00220000 00200000
D (199) boot: load partition table entry 0x3f4000a0
D (204) boot: type=0 subtype=11
I (206) boot:  5 ota_1            OTA app          00 11 00420000 00200000
I (213) boot: End of partition table
D (216) boot: OTA data offset 0x15000
D (220) bootloader_flash: mmu set paddr=00010000 count=1 size=2000 src_addr=15000 src_addr_aligned=10000
D (229) boot: otadata[0]: sequence values 0x65747369
D (234) boot: otadata[1]: sequence values 0x00000000
E (238) boot: ota data partition invalid, falling back to factory
D (244) boot: Trying partition index -1 offs 0x20000 size 0x200000
D (250) esp_image: reading image header @ 0x20000
D (254) bootloader_flash: mmu set block paddr=0x00020000 (was 0xffffffff)
D (261) esp_image: image header: 0xe9 0x06 0x00 0x04 40081bc8
I (266) boot_comm: chip revision: 3, min. application chip revision: 0
V (273) esp_image: loading segment header 0 at offset 0x20018
V (278) esp_image: segment data length 0x2762c data starts 0x20020
V (284) esp_image: segment 0 map_segment 1 segment_data_offs 0x20020 load_addr 0x3f400020
I (292) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x2762c (161324) map
D (300) esp_image: free data page_count 0x00000032
D (304) bootloader_flash: mmu set paddr=00020000 count=3 size=2762c src_addr=20020 src_addr_aligned=20000
V (375) esp_image: loading segment header 1 at offset 0x4764c
D (375) bootloader_flash: mmu set block paddr=0x00040000 (was 0xffffffff)
V (375) esp_image: segment data length 0x4010 data starts 0x47654
V (381) esp_image: segment 1 map_segment 0 segment_data_offs 0x47654 load_addr 0x3ffbdb60
I (389) esp_image: segment 1: paddr=0x00047654 vaddr=0x3ffbdb60 size=0x04010 ( 16400) load
D (397) esp_image: free data page_count 0x00000032
D (402) bootloader_flash: mmu set paddr=00040000 count=1 size=4010 src_addr=47654 src_addr_aligned=40000
V (418) esp_image: loading segment header 2 at offset 0x4b664
D (418) bootloader_flash: mmu set block paddr=0x00040000 (was 0xffffffff)
V (423) esp_image: segment data length 0x400 data starts 0x4b66c
V (428) esp_image: segment 2 map_segment 0 segment_data_offs 0x4b66c load_addr 0x40080000
I (436) esp_image: segment 2: paddr=0x0004b66c vaddr=0x40080000 size=0x00400 (  1024) load
D (444) esp_image: free data page_count 0x00000032
D (449) bootloader_flash: mmu set paddr=00040000 count=1 size=400 src_addr=4b66c src_addr_aligned=40000
V (458) esp_image: loading segment header 3 at offset 0x4ba6c
D (463) bootloader_flash: mmu set block paddr=0x00040000 (was 0xffffffff)
V (470) esp_image: segment data length 0x459c data starts 0x4ba74
V (476) esp_image: segment 3 map_segment 0 segment_data_offs 0x4ba74 load_addr 0x40080400
I (484) esp_image: segment 3: paddr=0x0004ba74 vaddr=0x40080400 size=0x0459c ( 17820) load
D (492) esp_image: free data page_count 0x00000032
D (496) bootloader_flash: mmu set paddr=00040000 count=2 size=459c src_addr=4ba74 src_addr_aligned=40000
V (513) esp_image: loading segment header 4 at offset 0x50010
D (513) bootloader_flash: mmu set block paddr=0x00050000 (was 0xffffffff)
V (517) esp_image: segment data length 0xad238 data starts 0x50018
V (523) esp_image: segment 4 map_segment 1 segment_data_offs 0x50018 load_addr 0x400d0018
I (531) esp_image: segment 4: paddr=0x00050018 vaddr=0x400d0018 size=0xad238 (709176) map
D (539) esp_image: free data page_count 0x00000032
D (544) bootloader_flash: mmu set paddr=00050000 count=11 size=ad238 src_addr=50018 src_addr_aligned=50000
V (820) esp_image: loading segment header 5 at offset 0xfd250
D (820) bootloader_flash: mmu set block paddr=0x000f0000 (was 0xffffffff)
V (821) esp_image: segment data length 0xe73c data starts 0xfd258
V (826) esp_image: segment 5 map_segment 0 segment_data_offs 0xfd258 load_addr 0x4008499c
I (834) esp_image: segment 5: paddr=0x000fd258 vaddr=0x4008499c size=0x0e73c ( 59196) load
D (842) esp_image: free data page_count 0x00000032
D (847) bootloader_flash: mmu set paddr=000f0000 count=2 size=e73c src_addr=fd258 src_addr_aligned=f0000
V (882) esp_image: image start 0x00020000 end of last section 0x0010b994
D (882) bootloader_flash: mmu set block paddr=0x00100000 (was 0xffffffff)
D (884) esp_image: Calculated hash: c4412b63c924d6e9b0f7b506fe4d241580cbc50ec7346317fb687489ba5b2c22
D (892) bootloader_flash: mmu set paddr=00100000 count=1 size=20 src_addr=10b9a0 src_addr_aligned=100000
D (902) bootloader_flash: mmu set paddr=00100000 count=1 size=20 src_addr=10b9a0 src_addr_aligned=100000
I (923) boot: Loaded app from partition at offset 0x20000
I (923) boot: Disabling RNG early entropy source...
D (924) boot: Mapping segment 0 as DROM
D (926) boot: Mapping segment 4 as IROM
D (930) boot: calling set_cache_and_start_app
D (934) boot: configure drom and irom and start
V (938) boot: d mmu set paddr=00020000 vaddr=3f400000 size=161324 n=3
V (944) boot: rc=0
V (946) boot: rc=0
V (948) boot: i mmu set paddr=00050000 vaddr=400d0000 size=709176 n=11
V (954) boot: rc=0
V (956) boot: rc=0
D (958) boot: start: 0x40081bc8
Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0)
Core 0 register dump:
PC      : 0x4008b33c  PS      : 0x00060334  A0      : 0x8008b094  A1      : 0x3ffe3af0  
A2      : 0x3ffbf248  A3      : 0x00000000  A4      : 0x00ffffff  A5      : 0xff000000  
A6      : 0xf7ffffff  A7      : 0xfffffffd  A8      : 0x00040002  A9      : 0x3ffc31a8  
A10     : 0xdfffffff  A11     : 0x00000000  A12     : 0xbfffffff  A13     : 0x00000001  
A14     : 0x000000fe  A15     : 0x3ffb63f4  SAR     : 0x0000001f  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x4009029a  LEND    : 0x400902a5  LCOUNT  : 0x00000000  

ELF file SHA256: 42fab2ce459b230d

Backtrace: 0x4008b339:0x3ffe3af0 0x4008b091:0x3ffe3b10 0x40089ba6:0x3ffe3b30 0x40085970:0x3ffe3b60 0x40085a24:0x3ffe3b90 0x40118951:0x3ffe3bc0 0x40081aaa:0x3ffe3c00 0x40081cee:0x3ffe3c50 0x40079437:0x3ffe3c70 |<-CORRUPTED
  #0  0x4008b339:0x3ffe3af0 in get_spi_dev at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/soc/src/hal/spi_flash_hal_iram.c:24
      (inlined by) spi_flash_hal_poll_cmd_done at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/soc/src/hal/spi_flash_hal_iram.c:29
  #1  0x4008b091:0x3ffe3b10 in spi_flash_hal_common_command at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/soc/src/hal/spi_flash_hal_iram.c:92
  #2  0x40089ba6:0x3ffe3b30 in memspi_host_read_id_hs at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/spi_flash/memspi_host_driver.c:50
  #3  0x40085970:0x3ffe3b60 in esp_flash_read_chip_id at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/spi_flash/esp_flash_api.c:175
  #4  0x40085a24:0x3ffe3b90 in esp_flash_init at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/spi_flash/esp_flash_api.c:123 (discriminator 2)
  #5  0x40118951:0x3ffe3bc0 in esp_flash_init_default_chip at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/spi_flash/esp_flash_spi_init.c:192
  #6  0x40081aaa:0x3ffe3c00 in start_cpu0_default at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/esp32/cpu_start.c:399
  #7  0x40081cee:0x3ffe3c50 in call_start_cpu0 at /Users/nick/.platformio/packages/framework-espidf@3.40001.200521/components/esp32/cpu_start.c:259
  #8  0x40079437:0x3ffe3c70 in ?? ??:0

dmaxben
Posts: 79
Joined: Thu Nov 16, 2017 6:04 pm

Re: Migrated to ESP-IDF, now CPU won't start

Postby dmaxben » Mon Sep 21, 2020 2:41 pm

Might be an incompatible bootloader. There are some arduino bootloaders that are incompatible with ESP-IDF.

hesthewanderer
Posts: 2
Joined: Sun Sep 20, 2020 8:27 pm

Re: Migrated to ESP-IDF, now CPU won't start

Postby hesthewanderer » Mon Sep 21, 2020 3:05 pm

I'm actually using an IDF bootloader. Weirdly, it seems completely disabling bluetooth in menuconfig fixes the issue and the CPU starts. Any idea why that might happen?

With bluetooth disabled my CPU starts, code starts to run, and then one of my tasks causes a core panic (illegal instruction) when parsing UDP wifi packets. I think due to some changes in the underlying WiFiUDP library between IDF v3.3 (which Arduino is currently on) and v4.0, which is what I am now using.

Who is online

Users browsing this forum: No registered users and 39 guests