Can you make sense of this memory sizes listed for TTGO (LILYGO) T-Beam board?

I’ve built and run a simple memory size listing code on a T-Beam board:

  Serial << "Chip: " << ESP.getChipModel() << ", " << ESP.getCpuFreqMHz() << "MHZ, " << ESP.getChipCores() << " cores\n";
  Serial << "Heap: " << ESP.getFreeHeap() << "/" << ESP.getHeapSize() << ", " << ESP.getMaxAllocHeap() << " max block\n";
  Serial << "PSRAM: " << ESP.getFreePsram() << "/" << ESP.getPsramSize() << ", " << ESP.getMaxAllocPsram() << " max block\n";
  Serial << "Flash: " << ESP.getFlashChipSize() << "\n";
  Serial << "Free sketch space: " << ESP.getFreeSketchSpace(); 

Building the image shows:

RAM:   [          ]   1.7% (used 22236 bytes from 1310720 bytes)
Flash: [==        ]  19.1% (used 249993 bytes from 1310720 bytes)

and running it shows:

Chip: ESP32-D0WDQ6-V3, 240MHZ, 2 cores
Heap: 344440/369848, 114676 max block
PSRAM: 4192123/4192123, 4128756 max block
Flash: 4194304
Free sketch space: 1310720

I have several problems interpreting these numbers:

  1. ESP32-D0WDQ6-V3 has only 540KB of on-chip SRAM for data and instructions, according to the data sheet. 1310720 bytes is inconsistent with that.
  2. Free sketch space: 1310720 shows that no memory was used, contrary to the linker output of used 22236 bytes from 1310720 bytes.
  3. The board is listed with 8MB PSRAM, not 4192123 bytes shown.

Can someone shed more light on these numbers?

What’s the platformio.ini?

I used the new project wizard generated one with some additions:

[env:ttgo-t-beam]
platform = espressif32
board = ttgo-t-beam
framework = arduino
monitor_speed = 115200
monitor_rts = 0
monitor_dtr = 0
build_unflags = -std=gnu++11
build_flags = -std=gnu++2a
lib_deps = 
	mikalhart/Streaming@^1.0.0

PlatformIO just has the wrong value here for maximum RAM.

Since it’s a regular ESP32 chip, it does should have the same

like esp32dev. And yes that’s not 540KB of “RAM”, but that’s because we’re couning DRAM here not IRAM (plus no PSRAM included in calculation).

That number if just wrong. I think it detects the end of the sketch by a magic linker script symbol. Either PlatformIO is not defining it to the right value here of the Arduino-ESP32 core has a bug (in e.g. the linker script).

Does it show the same free sketch size in the Arduino IDE?

Empty sketch with Arduino IDE 2.1.0 shows:

Sketch uses 228333 bytes (17%) of program storage space. Maximum is 1310720 bytes.
Global variables use 21976 bytes (6%) of dynamic memory, leaving 305704 bytes for local variables. Maximum is 327680 bytes.

But is this output good too and matches it?

Arduino IDE 2.1.0 output of the initially posted sketch:

Chip: ESP32-D0WDQ6-V3, 240MHZ, 2 cores
Heap: 344020/369428, 114676 max block
PSRAM: 4192123/4192123, 4128756 max block
Flash: 4194304
Free sketch space: 1310720

It is the same as with PlatformIO.