ESP32-S3 + AXS15231 display flickers only in PlatformIO (works fine in Arduino IDE)

I have a project that uses ESP32-S3-Touch-LCD-3.5B from Waveshare with a display driver AXS15231.
The project compiles and runs perfectly in Arduino IDE (no flicker), but when I build the exact same code in PlatformIO, the display flickers heavily.

I made sure that:

  • ESP32 Arduino core version is the same: 3.2.1
  • GFX Library version is the same: 1.6.1 (moononournation/GFX Library for Arduino)
  • Board definition: esp32-s3-devkitc1-n16r8

Still, only the PlatformIO build shows flickering.

PlatformIO Configuration:

Here is my current platformio.ini:

[env:esp32-s3-devkitc1-n16r8]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21-2/platform-espressif32.zip
board = esp32-s3-devkitc1-n16r8
framework = arduino
monitor_speed = 115200
board_build.arduino.memory_type = qio_opi
board_build.partitions = app3M_fat9M_16MB.csv
lib_deps =
    moononournation/GFX Library for Arduino@^1.6.1

build_flags =
  -DF_CPU=240000000L
  -DARDUINO_ESP32S3_DEV
  -DARDUINO_ARCH_ESP32
  -DARDUINO_HOST_OS=\"windows\"
  -DARDUINO_FQBN=\"esp32:esp32:esp32s3:UploadSpeed=921600,USBMode=hwcdc,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,CPUFreq=240,FlashMode=qio,FlashSize=16M,PartitionScheme=app3M_fat9M_16MB,DebugLevel=debug,PSRAM=opi,LoopCore=1,EventsCore=1,EraseFlash=none,JTAGAdapter=default,ZigbeeMode=default\"
  -DARDUINO_RUNNING_CORE=1
  -DARDUINO_EVENT_RUNNING_CORE=1
  -DBOARD_HAS_PSRAM
  -DARDUINO_USB_MODE=1
  -DARDUINO_USB_CDC_ON_BOOT=1
  -DARDUINO_USB_MSC_ON_BOOT=0
  -DARDUINO_USB_DFU_ON_BOOT=0
  -DCORE_DEBUG_LEVEL=4

What I already tried:

  • Matched all build flags with Arduino IDE
  • Tried both board_build.arduino.memory_type = qio_opi and qio_qspi
  • Disabled PSRAM heap override with -DARDUINO_DISABLE_PSRAM_HEAP

Nothing solved the flickering.

Why does the display flicker only when compiled with PlatformIO?

remove this. It is wrong with Platformio / pioarduino
Probaby this slows done causing the flickering

  -DCORE_DEBUG_LEVEL=4

There are no settings needed at all! The board does set all correctly esp32-s3-devkitc1-n16r8

I added these after seeing it flickers hoping that it would solve the problem. The result is the same if I remove these lines.