Pointer to array failing during linking on an ESP32?

Hi,

Can anyone tell me why this code is failing?
I need a pointer to the wavebuffer to use in an ISR that outputs to the DAC on an ESP32.

volatile uint8_t waveBuffer[200000]; //buffer to hold wave file
volatile uint8_t *waveBufferPointer;

void setup() {
Serial.begin(115200); // Not needed for sound, just to demo printing to the serial
// Monitor whilst the sound plays, ensure your serial monitor
// speed is set to this speed also.

//initialize the pointer to the wave file buffer
waveBufferPointer = &waveBuffer[0];

}

Thanks for any help on this!
Mike

Console output attached.

console-output.txt (55.7 KB)

It's not about pointer. Your array is just too big to fit in RAM

c:/users/user1/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: DRAM segment data does not fit.

c:/users/user1/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: region `dram0_0_seg' overflowed by 88560 bytes

Thank you very much for the prompt reply!

The thing that is confusing me is, if I comment out the pointer assignment as below, the compile/link proceeds without error.

//initialize the pointer to the wave file buffer
//waveBufferPointer = &waveBuffer[0];

Sketch uses 234352 bytes (17%) of program storage space. Maximum is 1310720 bytes.
Global variables use 13136 bytes (4%) of dynamic memory, leaving 314544 bytes for local variables. Maximum is 327680 bytes.

I'm not familiar with the ESP32. Could you try to decrease array size significantly? Let say to 100 bytes.

Hi Alesam,

I am able to increase the array size to 100K without error which is workable for my application.

Thank you again for your help!

Mike

MrMikeK:
The thing that is confusing me is, if I comment out the pointer assignment as below, the compile/link proceeds without error.

//initialize the pointer to the wave file buffer
//waveBufferPointer = &waveBuffer[0];

The compiler sees that waveBuffer is not used for anything and throws it away.