Jump to content
  • 0

Digilent WiFire PIC32MZ running out of RAM before 512 KB are allocated


souvlaki

Question

I have a Digilent WiFire PIC32MZ Rev D microcontroller board. It is supposed to have 512 KB of RAM. When running the attached test program, I run out of memory (it crashes) when trying to allocate more than 1964 bytes.

Other members on my team with the same code, and same board, report that they crash when allocating more than 1988 bytes.

We are compiling and flashing through the Arduino IDE.

UPDATE [4.28.21]:

Further testing shows this is only the case when using `new` or `malloc`, but not with static allocation. See working `shield_static.ino`.

shield.ino

shield_static.ino

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hi @souvlaki,

I apologize for the delay.

My understanding (I'm likely not entirely correct) is that the default heap size set by the linker script (0x800 or about 2048 bytes is what I'm seeing) is the limiting factor here. You can increase the available heap by putting something like this (as explained in this old chipKIT forum thread) at the top of your program:

#define CHANGE_HEAP_SIZE(size) __asm__ volatile ("\t.globl _min_heap_size\n\t.equ _min_heap_size, " #size "\n")

CHANGE_HEAP_SIZE(0x5000);

extern __attribute__((section("linker_defined"))) char _heap;
extern __attribute__((section("linker_defined"))) char _min_heap_size;

I was able to use the above code with an arbitrarily chosen heap size of 0x1650 and was then able to get the new function (as per your shield.ino sketch) to succeed with an uint8_t array size up to 5676. What I don't understand at the moment is why the static/predefined allocation works without issue; the Arduino IDE compiler is certainly not reporting a drastic usage difference in the program storage space and dynamic memory used.

I'm sorry I couldn't be of much more help.

Thanks
JColvin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...