ESP32 does not boot on Espressif32 3.3.2

Hello everyone, I am having some trouble updating one of my projects with an ESP-WROOM-32 module (bare, soldered on a custom PCB).
Is has always worked just fine both via Serial and OTA. Now I got a new notebook, tried to flash OTA, but then lost contact.
Upon investigation via serial, I found out that the output stops at

[...]
load:[hex value],len:[number]
entry [hex value]

then after some time resets and stops again at this point.

By comparison to my old notebook, I found out that that still hat espressif32 2.1.0, so I forced that version in the platformio.ini and was able to successfully flash again.

After entry, at least in 2.1.0 Booting is supposed to be output in the next line, which does not happen with 3.3.2.

My current platformio.ini is

[platformio]
default_envs = firebeetle32

[env:firebeetle32]
platform = espressif32@2.1.0
board = firebeetle32
framework = arduino
build_flags = -DMQTT_MAX_PACKET_SIZE=196

[upload port stuff]
[libs]

Does anyone have any idea why the recent version does not work? I actually WAS able to flash another dev module with someone else’s code earlier … Did anything change hardware wise, regarding the boot GPIO configuration?

When you re-flash this standard wifiscan example with the latest platform, what is the exact output?

Okay, turns out the wifiscan example works, so no hardware issue:

rst:0x1 (POWERON_RESET),boot:0x17 (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:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
Setup done
scan start
scan done
9 networks found
[local networks]

I also noticed that the “Booting” output came from my own script when it works, so the lack of it does actually not mean that it does not boot … I added delays to the start of my setup function

void setup() {
delay(1000);

Serial.begin(115200);
Serial.println(“Booting”);

delay(1000);

to no avail. The output is still

rst:0x1 (POWERON_RESET),boot:0x17 (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:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x17 (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:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8

...

If anything in my code causes the hold explicitly, it seems to be in the globals, I guess …
The code is here.

If the WiFi scan examples works fine with the latest platform and outputs something, but your firmware that uses the exact same platform does not, the fault must be in the code, that’s the correct conclusion.

Sadly it’s hard for me to test your code when it does hardware initialization stuff like initializating an SPI LCD. Since I have none that would surely fail and lead to wrong resuls.

A tip that I can definitively give is the following: Remove all inner code from setup() and loop() and rewrite them to just do

void setup() {
   Serial.begin(115200);
   Serial.println("Boot");
}

void loop() { Serial.prinln("Looping..."); delay(1000); }

while keeping all other code the same.

If that does not display anything on the serial monitor, that means that it hangs up before even reaching setup(). That is possible since when you have a globally constructed C++ object (and you have a billion) their constructor functions get executed before the main function of the firmware starts.

On the other hand, if the above code example works, then something happens inside the setup() or loop() routines that make the firmware hang up.

What is the result when you try the above?

Actually, it turned out, the issue is reproducible with a standard dev board without any periphery. Up until espressiv32 3.0.0, this displays all the initial output, connects to the wifi and prints the IP. Starting from 3.1.0, I get above-mentioned issue.

This makes testing a lot easier, because I don’t have to kneel in the utility room and put the flash jumper back and forth :slight_smile:

I will now proceed to test your suggestions.

Okay, that was fast.
The culprit was SPIClass SPI1(HSPI);

This minimal example breaks it.

#include <Arduino.h>

#include <SPI.h>

SPIClass SPI1(HSPI);

void setup() {
  Serial.begin(115200);
  Serial.println("Boot");
  // put your setup code here, to run once:
}

void loop() {
  Serial.println("Looping");
  delay(1000);
  // put your main code here, to run repeatedly:
}

… and I didn’t even use hardware SPI, I just tried it for the display and apparently went back to software for some reason …

Thanks for the input!

1 Like

Hmm weird that instantiating that object breaks it. The SPI library code does the same with VSPI as the default SPI object.

How else is one supposed to use the HSPI? The post Using VSPI with ESP32 - #2 by pylon - Programming Questions - Arduino Forum says the same…