I am using kinetis MK60FX512VMD15 controller having 128 KB SRAM and MQX RTOS version 4.2.
I would like to implement RAM self test mechanism as follows:
Write some test pattern (e.g. walking 1, walkin 0 etc) to RAM locations, read back the value from RAM locations and verify that the read value matches the written pattern. This way I would like to test the entire physical SRAM periodically.
I am thinking to create one Task using MQX provided API "_task_create()" that will take care of writing the test pattern to RAM locations, reading it back and verifying it.
This way the Task will try to access the physical RAM from its start location and will keep testing it until the RAM's end location.
My questions are:
1. Can a Task access entire physical RAM so that I can start writing the test pattern from RAM start location and go until RAM end location ?
i.e. assuming the RTOS will allow this Task to access entire RAM without crashing/terminating the Task, even if this Task tries to write to a RAM address that may be mapped to another Task.
2. How can I access complete physical RAM locations from above Task to perform above test at run time when my other tasks in system are also running ?
i.e. if I try to write the test pattern to a certain RAM location and if that location is mapped/assigned by RTOS to another Task, won't it corrupt the data that was used by other Task?
Kindly let me know if this would be a correct approach or if you would like to suggest some different approach.
Thanks & Regards,
Maybe it is not possible to do a self test for the entire physical RAM while MQX RTOS is running. Because RTOS key components and structures , task stacks,... are also in the RAM space. The RAM test (write and read back) will corrupt the data.
One possible way maybe do a RAM test before the MQX RTOS running.
MQX needs RAM for the stacks, heap, and other data fields so it would be impossible to test all of the RAM if you are wanting to test the same RAM MQX is using. The only way to do this is to have use a different area of RAM like external SDRAM. If you are wanting to do this test at boot up you could minimize the area to avoid by writing bare metal code that ran before MQX starts, but even then some RAM is required.
I hope that helps,
Thanks for your reply.
I found below defines in ".icf" file:
define symbol __ICFEDIT_region_RAM_start__ = 0x1fff0000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2000FFF0;
I used "0x1fff0000" as start address for my test code, kept incrementing it until address "0x2000FFF0" is reached, and ran below pseudo test code on all the RAM addresses/locations starting from address "0x1fff0000" up-to "0x2000FFF0".
Please refer below pseudo code that i tried:
//take "backup" of original data present at test RAM location so that we can restore the test RAM location with it later.
//write test pattern to RAM location.
//Read RAM data and compare with test pattern written.
//If read value of RAM data matches the test pattern; SUCCESS.
//If read value of RAM data does not match the test pattern; FAILURE.
//Restore the test RAM location data that was taken as "backup" previously.
Repeat above pseudo code for next RAM location.
This way I was able to access the entire SRAM (From 0x1fff0000 to 0x2000FFF0) and could run my test successfully.
I verified that my test pattern was actually getting written in RAM addresses by monitoring the RAM contents in IAR IDE.
I have created one low priority Task using "_task_create()" MQX API and I am running above test code from this Task periodically. MQX RTOS is running and other application specific high priority Tasks are also running.
I did not see any data corruption happening. I am disabling interrupts (_int_disable() ), stopping task preemption (_task_stop_preemption() ) and restoring original RAM contents as soon as test pattern is verified, so looks like the possibility of data corruption is eliminated, correct?
Do you see any problem with this approach?
Kindly let me know your thoughts on this.
With Best Regards,