What is the Due's memory architecture?

Hello. I'm working on a large project (~28,000 lines of code) and I'm experiencing mysterious bugs. I'm wondering if I'm running out of memory.

I found this article
https://docs.arduino.cc/learn/programming/memory-guide/
but the list of boards doesn't include the Due. So is the Due Harvard, Von Neumann, or a hybrid?

if my memory serves me well, the Arduino Due’s CPU uses a modified Harvard architecture with separate instruction and data buses (so Harvard) but a unified address space (both code and data share the same logical addressing), making it appear Von Neumann-like from a programmer’s perspective.

So yes, you could call that "hybrid".

1 Like

Hi @tallkite. The documentation provided by Arduino is focused on the Arduino-specific aspects of the board, including the board hardware as a whole, the "Arduino language" framework, and the Arduino development tools.

When it comes to things which are not Arduino-specific, the datasheet and other information provided by the manufacturer of the Due board's ATSAM3X8E microcontroller will serve as a more comprehensive reference:

https://www.microchip.com/en-us/product/atsam3x8e

I give this advice only in regards to performing autonomous research. As you see here, Arduino Forum can serve as an excellent resource whenever you want to solicit direct support or discussion on any subject matter related to Arduino.

1 Like

Thanks for the replies!

1 Like

I'll assume that you're looking for info on whether the stack and heap are permitted to grow into each other (stack starting at the top of ram and growing down, heap starting at the end of bss and growing up), similar to the way things are done on the AVR.
Especially since many ARM systems seem to specify a maximum stack size.

That's a good question.
It seems a bit tough to answer by looking at the source code, since the repository is "polluted" with a bunch of "standard init code for an ARM processor" and similar :frowning:

I'll do some runtime or object code checks. Soon.

1 Like

Here’s a little sketch that prints out the stack and heap addresses at the time of setup.

If the stack address is “near” the end of RAM and the heap is near the start of RAM, we can assume that the architecture permits growth (probably.)

For example, on an Uno R4 Minima (sorry, my Due is buries somewhere), I get:

/Users/BillW/Documents/Arduino/-test-/test_heapandstack/test_heapandstack.ino

Frame pointer (on the stack) currently: 0x20007ED0
Malloced data (on the heap) currently: 0x20000A48

Which looks pretty reasonable: RAM starts are 0x20000000 and is 32k long (ending at 0x20007FFF)

void setup() {
  Serial.begin(115200);
  while (!Serial) ;
  delay(10000);
  Serial.println(__FILE__);
  Serial.println();
  void* stack = __builtin_frame_address(0);
  void * heap = malloc(100);
#ifdef ARDUINO_ARCH_SAM
  // unfortunately, these linker symbols seem to vary from board to board.
  extern int _srelocate, _erelocate, _sbss, _ebss, _end, _sstack, _estack;

  Serial.print("_srelocate = 0x");
  Serial.println((uint32_t)&_srelocate, HEX);
  Serial.print("_erelocate = 0x");
  Serial.println((uint32_t)&_erelocate, HEX);
  Serial.print("_sbss = 0x");
  Serial.println((uint32_t)&_sbss, HEX);
  Serial.print("_ebss = 0x");
  Serial.println((uint32_t)&_ebss, HEX);
  Serial.print("_end = 0x");
  Serial.println((uint32_t)&_end, HEX);
    Serial.print("_sstack= 0x");
  Serial.println((uint32_t)&_sstack, HEX);
    Serial.print("_estack = 0x");
  Serial.println((uint32_t)&_estack, HEX);
#endif

  Serial.print("Frame pointer (on the stack) currently: 0x");
  Serial.println((uint32_t)stack, HEX);
  Serial.print("Malloced data (on the heap) currently: 0x");
  Serial.println((uint32_t)heap, HEX);
}

void loop() {
}