Upload creates crazy GPIO-values + constant reboots (builds fine)

Multiple sources say this can happen when you try to access pin “-1”, which in some libraries means “pin undefined”, but they still try to use it.

For example, with the LovyanGFX library

and you also set a pin to -1 here

Not saying that that’s the culprit, but “something” in either your code or a library seems to try to use either pin -1 or another invalid pin number in pinMode.

The good message is that the ESP32S3 has a built in USB-JTAG controller. So, if your development board’s USB port is directly connected to the ESP32S3, then you can actually start up the debugger in the VSCode Debug sidebar and press “Play” for the PIO Debug configuration. The default debug_tool for the board should already be esp-builtin.

https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/api-guides/jtag-debugging/configure-builtin-jtag.html

There’s also a guide here:

https://community.platformio.org/t/how-to-use-jtag-built-in-debugger-of-the-esp32-s3-in-platformio/36042

What this will allow you to do is set a breakpoint in the __pinMode which throws that error message

by e.g. saying

debug_init_break = break esp32-hal-gpio.c:102

so that after the debugger starts, it keeps running until it hits that breakpoint in that line, which is where the error message is printed. The call stack in the debugger sidebar will then show you how execution has reached that location, immediately identifying the calling function and library, from which you can identify what’s wrong.