我们有个产品有质量问题,是SPI Flash出问题,启动不了变砖头了,返修较麻烦,且影响产品的信誉和市场。
有一个怀疑内存数据出错,导致回写flash时校验不正确,会触发flash上的文件系统擦除索引数据,破环了文件系统。
所以需要找一个测试工具,进行压力测试,来验证一下内存。验证SRAM的稳定性、读写速度以及无错误操作。
这个主要是在出问题但已修复的板子上,看下SRAM物料、布线等方面是否有问题。
我们这个产品,运行的是实时操作系统,所以需要找一个裸机上运行的内存压力测试工具。在Github上搜了一下,找到了一个:
https://github.com/nfd/ci20-os-port-memtester-4.3.0
https://github.com/jnavila/memtester
对起进行了一定的修改,来适配我们的系统。
在编译中,因为没有libc的rand函数,所以网上搜了一个代替:
https://android.googlesource.com/kernel/lk/+/master/lib/libc/rand.c
这个是Android的bootloader,Little Kernel里的一个rand函数。
需要注意的是,使用上面的工具,只是测试了栈空间的一部分数据,整个覆盖的内存空间是有限的。
关于测试
---------------
以下测试来自原始版本,只是为了提高速度而进行了更新,并根据程序的新框架进行了重写。 这些测试主要是捕捉由于坏位永久停留在高位或低位而导致的内存错误:
随机值
XOR 比较
SUB 比较
MUL 比较
DIV 比较
OR 比较
AND 比较
以下测试由我实现,在捕捉不稳定的比特(可能是也可能不是真实值)方面做得稍好一些:
Sequential Increment
Block Sequential
Solid Bits
其余测试也是由我实现的,目的是捕捉那些依赖于同一 word32 或前一个和后一个 word32 中周围位当前值的坏位。
Bit Flip
Checkerboard
Walking Ones
Walking Zeroes
Bit Spread
还有一个测试(卡住地址)会首先运行。 它能确定程序试图访问的程序尝试访问的内存位置是否正确寻址。 如果该测试报告错误,几乎可以肯定是内存子系统中的某个地方出了问题。内存子系统中的某个地方出现了问题。 如果该测试失败,其他测试的结果就不能被认为是准确的。如果该测试失败,其他测试结果就不能被认为是准确的:
Stuck Address
使用信息汇总在 README 文件和 man 页面中。
About the Tests
---------------
The following tests are from the original version, updated simply for speed
and rewritten to fit the new framework of the program. These tests will
mainly catch memory errors due to bad bits which are permanently stuck high
or low:
Random value
XOR comparison
SUB comparison
MUL comparison
DIV comparison
OR comparison
AND comparison
The following tests were implemented by me, and will do a slightly better job
of catching flaky bits, which may or may not hold a true value:
Sequential Increment
Block Sequential
Solid Bits
The remaining tests were also implemented by me, and are designed to catch
bad bits which are dependent on the current values of surrounding bits in either
the same word32, or in the preceding and succeeding word32s.
Bit Flip
Checkerboard
Walking Ones
Walking Zeroes
Bit Spread
There is also a test (Stuck Address) which is run first. It determines if the
memory locations the program attempts to access are addressed properly or not.
If this test reports errors, there is almost certainly a problem somewhere in
the memory subsystem. Results from the rest of the tests cannot be considered
accurate if this test fails:
Stuck Address
Usage information is summarized in the file README, and in the man page.