ESP32 resets when a sprintf formatted time sramp is called

Been going in circles on this one all day but have now identified that the same “sprintf” time stamp I use on an ESP8266 resets the ESP32 as soon as it’s called. Tried two different boards same result. Even simplified the sketch and used the sketch builder but its always the same use “sprintf” and it resets the ESP32 take it out and it runs fine?

I should point out its the full date and time string with some special characters. Just don’t understand why it would work fine on one device and not the other. It’s something about the threading as it point to processor 1 in the error.

char time_buf[24]; // size big enough for string sprintf(time_buf,"%02u/%02u/%02u \xe2\x81\x91 %02u:%02u:%02u",day(),month(),year(),hour(),minute(),second());

If anyone has any ideas as to how to solve that would be great

What exception message do you get when this happens?
Have you tried decoding the exception message using the exception decoder?

The two board types use different ESP core code. Have you checked that your ESP32 core is up to date (2.0.1) in Boards Manager?

Pete.

Latest board driver version it shows me is 1.0.6

image

and this is the error it shows

How do I debug this error??

I suspect that you have the wrong URL in your preferences, because the latest version of the ESP32 core is 2.0.1

Pete.

1 Like

You may well be right @PeteKnight I’ll let you know if this is the fix.

Big download

Have no idea how to get a json link from a git repo but found it on this espressif page Installing — Arduino-ESP32 2.0.0 documentation

Once again thanx for the help.

So, its still the same and crashes when it calls the sprintf but if I change to a string its fine.

V2 doesn’t like to serial monitor being open either when you upload as it errors now didn’t before.

Strange, very strange

Try again tomorrow

So do you now see a crash report that can be pasted into the Exception Decoder?

Pete.

does it crash if you remove the unicode characters?

That’s a new one on me. Dr Google said to enable “PSRAM” which I tried and the result was

E (178) psram: PSRAM ID read error: 0xffffffff

As I understand 0xFFFFFFFF is the last address of 32bits??

@Juraj You’ve nailed it with nothing i n between the date and time it doesn’t crash.
Weirdly though if I put some standard ASCII like “||” to seperate it will crash once then work fine

It’s a mystery but thanks for your sharp eye on this.

Cheerrs
macca

It depends on the type of ESP32 you’re using . Some have PSRAM, some don’t.

Pete.

@PeteKnight

Yes I installed the java “Exception Decoder” but there is no “Stack” that I can see in the dump that happens between reboot

[2672] Connecting to blynk.cloud:80
[3696] Ready (ping: 608ms).
[4221] Time sync: OK
TIME STAMP: 04/12/2021  ⁑  07:56:22 


Stack smashing protect failure!


abort() was called at PC 0x400ddd68 on core 1


Backtrace:0x400831ed:0x3ffb26b00x4008c7b1:0x3ffb26d0 0x40091771:0x3ffb26f0 0x400ddd68:0x3ffb2770 0x400d33ea:0x3ffb2790 0x400d503d:0x3ffb27e0 0x400d34b3:0x3ffb2800 0x400d61f1:0x3ffb2820 




ELF file SHA256: 0000000000000000

Rebooting...
ets Jun  8 2016 00:22:57

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:1
load:0x3fff0030,len:1420
ho 0 tail 12 room 4
load:0x40078000,len:13540
load:0x40080400,len:3604
entry 0x400805f0
E (178) psram: PSRAM ID read error: 0xffffffff
[32] Connecting to MillFlat_El_Rancho
[2664] Connected to WiFi
[2664] IP: 192.168.1.81
[2665] 

Interesting that you can have ASCII special characters as separators on an ESP8266 but not an ESP32
My dev boards are marked “ESP32 DEVKITV1”

Thanks for all your support
At least we know now
Cheers
macca

@PeteKnight and @Juraj Just in case you are interested I have just done an experiment with the same ESP32 and using sprintf with unicode separators with an NTP Time sketch.

While it’s well above my pay-grade this result suggests one of the Blynk libraries is the problem as the NTP sketch runs fine as does the Blynk ESP8266 version.

Seems I need to retarct this statement, I’ve managed to crash the ESP32 with complex sprintf statement (one int 2 x strings) in a non-Blynk sketch. Simplified things to “Serial.printf” and it all worked. So it seems its a bug/limitation in the ESP32 firmware.