Search code examples
testingembeddedheap-memorystack-memoryconsistency

How to check the Heap and Stack RAM consistency on an embedded system


I'm working on a project using a LEON2 Processor (Sparc V8). The processor uses 8Mbytes of RAM that need to be consistency checked during the Self-Test of my Boot. My issue is that my Boot obviously uses a small part of the RAM for its Heap/BSS/Stack which I cannot modify without crashing my application. My RAM test is very simple, write a certain value to all the RAM address then read them back to be sure the RAM chip can be addressed.

This method can be used for most of the RAM available but how could I safely check for the consistency of the remaining RAM?


Solution

  • as I am programming a safety-relevant device, I have to do a full RAM test during operation time. I split the test in two tests:

    1. Addressing test

    you write unique values to the addresses reached by each addressing line and after all values are written, the values are read back and compared to the expected values. This test detects short-circuits (or stuck@low/high) of addressing lines (meaning you want to write 0x55 on address 0xFF40, but due to a short-circuit the value is stored at 0xFF80, you cannot detect this by test 2:

    1. Pattern Test:

    You save e.g. the first 4 bytes of RAM in CPU's registers and afterwards you first clear the cells, write 0x55, verify, write 0xAA, verify and restore saved content (you can use other patterns of course) and so on. The reason you have to use the registers is that by using a variable, this variable would be destroyed by that test. You can even test your stack with this test. In our project, we test 4 cells at a time and we have to run this test until whole RAM is tested.

    I hope that helped a bit.