Memory Dump

I'd like to do a complete memory dump of the Due processor. No big reason at all, I'd just like to see if it's possible and I can make it work.

So I wrote this very simple script:

unsigned long count = 0;

void setup() {
  Serial.begin(250000);
  delay(5);
}

void loop() {
  // put your main code here, to run repeatedly:
  while(1)
  {
    Serial.print(0x00000000U + count, HEX);
    Serial.print(": ");
    Serial.print((*(RwReg*)(0x00000000U + count)),BIN);
    Serial.print("\n");
    count++;
  }
}

As you can see, all it does is start at register adress 0 and increment in 4-byte-steps while printing the 32 bit it reads at that adress.

I didn't leave it running all the way but it seems to work... except for a weird problem right at the start. Look at this:

ˆZˆJ¨JæKˆJ%¨J%ˆJˆJˆJÐ%ˆJˆJ%‚Š‚‚‚‚‚‚‚‚R510000000100010011001
59: 10011001000000000000100000001000
5A: 1000100110010000000000001000
5B: 1000000010001001100100000000
5C: 10000000100010011001
5D: 10101101000000000000100000001000
5E: 1101011010000000000001000
5F: 1000000000011010110100000000
60: 10000000000110101101
61: 10011001000000000000100000000001
62: 10001001100100000000000010ð0: 100000000010001000000000000000
1: 1011001001000000000100010000000
2: 110010110010010000000001000
3: 1000000001100101100100100000
4: 10000000011001011001
5: 10011001000000000000100000000110
6: 1000100110010000000000001000
7: 1000000010001001100100000000
8: 10000000100010011001
9: 10011001000000000000100000001000

Haha :smiley: Do you have any idea what this is?

It's cr@p in the serial buffer. The code is outputting to your serial port which isn't dealing with the data, then when you start the serial monitor it picks up what's in the buffer and displays it.

To stop it this is what I did.

  1. upload the code
  2. start serial monitor
  3. hold reset
  4. either change baud rate or close/reopen serial monitor (to get a clean window)
  5. release the reset button

I also changed your code slightly

void setup() {
  Serial.begin(250000);
  delay (5);
}

void loop() {
  unsigned long count = 0;
  while(1)
  {
    Serial.print(count, HEX);
    Serial.print(": ");
    Serial.println((*(RwReg*)(count)),BIN);
    count += 4;
  }
}

This version waits for you to hit the send button on the serial monitor, but it doesn't stop when you close it so I still end up with a buffer full....

void setup() {
  Serial.begin(250000);
  delay (5);
  while (Serial.available() == 0);
}

void loop() {
  unsigned long count = 0;
  while(1)
  {
    Serial.print(count, HEX);
    Serial.print(": ");
    Serial.println((*(RwReg*)(count)),BIN);
    count += 4;
  }
}