PlatformIO Community

ESP32 HTTPS Request example panics

Hello! I’ve recently switched from Arduino IDE to PlatformIO so I can use the ESP-IDF framework. I wanted to try Espressif’s HTTPS Request Example, so I cloned it and tried to match its environment. Here is the folder structure I ended up with:

.
│   .gitignore
│   CMakeLists.txt
│   platformio.ini
│   sdkconfig.esp32doit-devkit-v1
│   sdkconfig.esp32doit-devkit-v1.old
│
├───.pio
│   └───build
│           project.checksum
│
├───.vscode
│       c_cpp_properties.json
│       extensions.json
│       launch.json
│
├───components
│   └───protocol_examples_common
│       │   addr_from_stdin.c
│       │   CMakeLists.txt
│       │   component.mk
│       │   connect.c
│       │   Kconfig.projbuild
│       │   stdin_out.c
│       │
│       └───include
│               addr_from_stdin.h
│               protocol_examples_common.h
│
├───include
│       README
│
├───lib
│       README
│
├───src
│       CMakeLists.txt
│       component.mk
│       Kconfig.projbuild
│       local_server_cert.pem
│       local_server_key.pem
│       main.c
│       server_root_cert.pem
│
└───test
        README

I was able to build and upload, and from looking at the monitor, the ESP32 was able to connect to my WiFi and was able to get an established connection. However, as soon as there is a connection, Core 0 panic’ed with error (InstrFetchProhibited). Here is the relevant serial monitor output:

␛[0;32mI (44) boot.esp32: SPI Mode       : DIO␛[0m
␛[0;32mI (48) boot.esp32: SPI Flash Size : 4MB␛[0m
␛[0;32mI (53) boot: Enabling RNG early entropy source...␛[0m
␛[0;32mI (58) boot: Partition Table:␛[0m
␛[0;32mI (62) boot: ## Label            Usage          Type ST Offset   Length␛[0m
␛[0;32mI (69) boot:  0 nvs              WiFi data        01 02 00009000 00006000␛[0m
␛[0;32mI (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000␛[0m
␛[0;32mI (84) boot:  2 factory          factory app      00 00 00010000 00100000␛[0m
␛[0;32mI (91) boot: End of partition table␛[0m
␛[0;32mI (95) boot_comm: chip revision: 3, min. application chip revision: 0␛[0m
␛[0;32mI (103) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=281cch (164300) map␛[0m
␛[0;32mI (171) esp_image: segment 1: paddr=000381f4 vaddr=3ffb0000 size=03848h ( 14408) load␛[0m
␛[0;32mI (177) esp_image: segment 2: paddr=0003ba44 vaddr=40080000 size=045d4h ( 17876) load␛[0m
␛[0;32mI (184) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=86198h (549272) map␛[0m
␛[0;32mI (384) esp_image: segment 4: paddr=000c61c0 vaddr=400845d4 size=0fd60h ( 64864) load␛[0m
␛[0;32mI (410) esp_image: segment 5: paddr=000d5f28 vaddr=50000000 size=00010h (    16) load␛[0m
␛[0;32mI (421) boot: Loaded app from partition at offset 0x10000␛[0m
␛[0;32mI (421) boot: Disabling RNG early entropy source...␛[0m
␛[0;32mI (433) cpu_start: Pro cpu up.␛[0m
␛[0;32mI (433) cpu_start: Starting app cpu, entry point is 0x400811ac␛[0m
␛[0;32mI (0) cpu_start: App cpu up.␛[0m
␛[0;32mI (447) cpu_start: Pro cpu start user code␛[0m
␛[0;32mI (447) cpu_start: cpu freq: 160000000␛[0m
␛[0;32mI (447) cpu_start: Application information:␛[0m
␛[0;32mI (452) cpu_start: Project name:     esp_https_request␛[0m
␛[0;32mI (458) cpu_start: App version:      1␛[0m
␛[0;32mI (462) cpu_start: Compile time:     Nov 16 2022 08:56:54␛[0m
␛[0;32mI (468) cpu_start: ELF file SHA256:  e70c38a16a8dbf5f...␛[0m
␛[0;32mI (474) cpu_start: ESP-IDF:          4.4.1␛[0m
␛[0;32mI (479) heap_init: Initializing. RAM available for dynamic allocation:␛[0m
␛[0;32mI (486) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM␛[0m
␛[0;32mI (492) heap_init: At 3FFB7760 len 000288A0 (162 KiB): DRAM␛[0m
␛[0;32mI (498) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM␛[0m
␛[0;32mI (505) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM␛[0m
␛[0;32mI (511) heap_init: At 40094334 len 0000BCCC (47 KiB): IRAM␛[0m
␛[0;32mI (519) spi_flash: detected chip: generic␛[0m
␛[0;32mI (522) spi_flash: flash io: dio␛[0m
␛[0;32mI (527) cpu_start: Starting scheduler on PRO CPU.␛[0m
␛[0;32mI (0) cpu_start: Starting scheduler on APP CPU.␛[0m
I (603) wifi:wifi driver task: 3ffbffec, prio:23, stack:6656, core=0
␛[0;32mI (603) system_api: Base MAC address is not set␛[0m
␛[0;32mI (603) system_api: read default base MAC address from EFUSE␛[0m
I (623) wifi:wifi firmware version: 63017e0
I (623) wifi:wifi certification version: v7.0
I (623) wifi:config NVS flash: enabled
I (623) wifi:config nano formating: disabled
I (623) wifi:Init data frame dynamic rx buffer num: 32
I (633) wifi:Init management frame dynamic rx buffer num: 32
I (633) wifi:Init management short buffer num: 32
I (643) wifi:Init dynamic tx buffer num: 32
I (643) wifi:Init static rx buffer size: 1600
I (653) wifi:Init static rx buffer num: 10
I (653) wifi:Init dynamic rx buffer num: 32
␛[0;32mI (653) wifi_init: rx ba win: 6␛[0m
␛[0;32mI (663) wifi_init: tcpip mbox: 32␛[0m
␛[0;32mI (663) wifi_init: udp mbox: 6␛[0m
␛[0;32mI (673) wifi_init: tcp mbox: 6␛[0m
␛[0;32mI (673) wifi_init: tcp tx win: 5744␛[0m
␛[0;32mI (673) wifi_init: tcp rx win: 5744␛[0m
␛[0;32mI (683) wifi_init: tcp mss: 1440␛[0m
␛[0;32mI (683) wifi_init: WiFi IRAM OP enabled␛[0m
␛[0;32mI (693) wifi_init: WiFi RX IRAM OP enabled␛[0m
␛[0;32mI (693) example_connect: Connecting to my_ssid...␛[0m
␛[0;32mI (703) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07␛[0m
I (803) wifi:mode : sta (94:e6:86:38:09:6c)
I (813) wifi:enable tsf
␛[0;32mI (813) example_connect: Waiting for IP(s)␛[0m
I (3223) wifi:new:<6,0>, old:<1,0>, ap:<255,255>, sta:<6,0>, prof:1
I (3963) wifi:state: init -> auth (b0)
I (3973) wifi:state: auth -> assoc (0)
I (3983) wifi:state: assoc -> run (10)
I (4073) wifi:connected with my_ssid, aid = 1, channel 6, BW20, bssid = 36:a5:67:36:13:f4
I (4073) wifi:security: WPA2-PSK, phy: bgn, rssi: -56
I (4073) wifi:pm start, type: 1

W (4083) wifi:<ba-add>idx:0 (ifx:0, 36:a5:67:36:13:f4), tid:0, ssn:0, winSize:64
I (4153) wifi:AP's beacon interval = 102400 us, DTIM period = 2
␛[0;32mI (5093) esp_netif_handlers: example_connect: sta ip: 192.168.156.173, mask: 255.255.255.0, gw: 192.168.156.99␛[0m
␛[0;32mI (5093) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.156.173␛[0m
␛[0;32mI (5593) example_connect: Got IPv6 event: Interface "example_connect: sta" address: fe80:0000:0000:0000:96e6:86ff:fe38:096c, type: ESP_IP6_ADDR_IS_LINK_LOCAL␛[0m
␛[0;32mI (5593) example_connect: Connected to example_connect: sta␛[0m
␛[0;32mI (5603) example_connect: - IPv4 address: 192.168.156.173␛[0m
␛[0;32mI (5603) example_connect: - IPv6 address: fe80:0000:0000:0000:96e6:86ff:fe38:096c, type: ESP_IP6_ADDR_IS_LINK_LOCAL␛[0m
␛[0;32mI (5613) example: Start https_request example␛[0m
␛[0;32mI (5623) example: https_request using crt bundle␛[0m
␛[0;32mI (6973) esp-x509-crt-bundle: Certificate validated␛[0m
␛[0;32mI (8873) example: Connection established...␛[0m
Guru Meditation Error: Core  0 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x878b74fc  PS      : 0x00060f30  A0      : 0x800d2346  A1      : 0x3ffc7930  
A2      : 0x878b74fc  A3      : 0x3f400518  A4      : 0x3ffb9520  A5      : 0x00000000
A6      : 0x3f400518  A7      : 0x00000000  A8      : 0x800d21b3  A9      : 0x3ffc7920  
A10     : 0x3ffb9520  A11     : 0x3f400518  A12     : 0x0000006a  A13     : 0x0000ff00
A14     : 0x00ff0000  A15     : 0xff000000  SAR     : 0x00000004  EXCCAUSE: 0x00000014  
EXCVADDR: 0x878b74fc  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffe5


Backtrace:0x478b74f9:0x3ffc79300x400d2343:0x3ffc7b60 0x400d2433:0x3ffc7c30 0x4008b545:0x3ffc7c50 




ELF file SHA256: e70c38a16a8dbf5f

Rebooting...
ets Jul 29 2019 12:21:46

I launched the monitor again with the stack backtrace decoder and it resulted with this:

Guru Meditation Error: Core  0 panic'ed (InstrFetchProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x00000000  PS      : 0x00060530  A0      : 0x800d2346  A1      : 0x3ffc7950
A2      : 0x00000000  A3      : 0x3f400518  A4      : 0x3ffb9520  A5      : 0x00000000
A6      : 0x3f400518  A7      : 0x00000000  A8      : 0x800d21b3  A9      : 0x3ffc7940  
A10     : 0x3ffb9520  A11     : 0x3f400518  A12     : 0x0000006a  A13     : 0x0000ff00
A14     : 0x00ff0000  A15     : 0xff000000  SAR     : 0x00000004  EXCCAUSE: 0x00000014  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffe5


Backtrace:0xfffffffd:0x3ffc79500x400d2343:0x3ffc7b80 0x400d2433:0x3ffc7c50 0x4008b545:0x3ffc7c70 

  #0  0xfffffffd:0x3ffc7950 in ?? ??:0
  #1  0x400d2343:0x3ffc7b80 in https_get_request_using_crt_bundle at src/main.c:161
  #2  0x400d2433:0x3ffc7c50 in https_request_task at src/main.c:244
  #3  0x4008b545:0x3ffc7c70 in vPortTaskWrapper at C:\Users\kivla\.platformio\packages\framework-espidf\components\freertos\port\xtensa/port.c:131 

I would assume this is due to an error in copy-pasting from the example. The code of main.c is identical to the one in the example, but my CMakeList.txt was modified to match with PlatformIO’s environment.

If anyone knows what I did wrong, please point it out. Thank you very much!