Why does my sketch not fit?

I'm having trouble to upload a sketch with a circular buffer. The intended size is 160,000 bytes but it will only upload when I reduce the size to 100,000 bytes.
The sketch with the reduced size will work, but I want at least 10 second of playing time in the buffer.

#define C_BUF_SIZE 100000   // 160.000 to large; is not uploading

I use the default partition scheme as defined in default.csv like this:

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x140000,
app1,     app,  ota_1,   0x150000,0x140000,
spiffs,   data, spiffs,  0x290000,0x170000,

And the compiler output is:

Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 5491.1 kbit/s)...
Hash of data verified.
Compressed 17392 bytes to 11186...
Wrote 17392 bytes (11186 compressed) at 0x00001000 in 0.1 seconds (effective 992.5 kbit/s)...
Hash of data verified.
Compressed 695680 bytes to 389570...
Wrote 695680 bytes (389570 compressed) at 0x00010000 in 6.0 seconds (effective 932.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 1823.0 kbit/s)...
Hash of data verified.

If I interpret this right then there is a:
total memory use: 47 + 11,186 + 389,570 + 128 = 400,931 bytes, which is well within the maximum of 0x140000 = 1.310.720 bytes.

So, why is this sketch not uploading?

Where is an error message?

How much RAM the processor HAS is not important. How much is available TO YOU is very important. The WiFi and other features consume quite a bit of the available RAM.

Compile a minimal sketch, like Blink, and see how much RAM is used, and how much is left. That will answer your question for you.

@RayLivingston
When the compiler reports for example:

Compressed 695680 bytes to 389570...[color=#222222][/color]
Wrote 695680 bytes (389570 compressed) at 0x00010000 in 6.0 seconds (effective 932.8 kbit/s)...[color=#222222][/color]
Hash of data verified.[color=#222222][/color]

Are you telling that the actual sketch size is very much than reported?

That is the output from the upload. You need to look at the output from the compile/link, which will tell you exactly how much RAM is used, and how much is free.

The best information I've found on this subject is: Where goes the (ESP32-) Memory? - Programming Questions - Arduino Forum

My workaround on the issue at hand is this:
Define and initialize a rather small buffer as global var:

cbuf circBuffer(1000);

Then in setup use the resize function that comes with the buffer library:

  circBuffer.resize(C_BUF_SIZE);

C_BUF_SIZE here is what I want it to be: 160.000 bytes.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.