README.memory-test 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. The most frequent cause of problems when porting U-Boot to new
  2. hardware, or when using a sloppy port on some board, is memory errors.
  3. In most cases these are not caused by failing hardware, but by
  4. incorrect initialization of the memory controller. So it appears to
  5. be a good idea to always test if the memory is working correctly,
  6. before looking for any other potential causes of any problems.
  7. U-Boot implements 3 different approaches to perform memory tests:
  8. 1. The get_ram_size() function (see "common/memsize.c").
  9. This function is supposed to be used in each and every U-Boot port
  10. determine the presence and actual size of each of the potential
  11. memory banks on this piece of hardware. The code is supposed to be
  12. very fast, so running it for each reboot does not hurt. It is a
  13. little known and generally underrated fact that this code will also
  14. catch 99% of hardware related (i. e. reliably reproducible) memory
  15. errors. It is strongly recommended to always use this function, in
  16. each and every port of U-Boot.
  17. 2. The "mtest" command.
  18. This is probably the best known memory test utility in U-Boot.
  19. Unfortunately, it is also the most problematic, and the most
  20. useless one.
  21. There are a number of serious problems with this command:
  22. - It is terribly slow. Running "mtest" on the whole system RAM
  23. takes a _long_ time before there is any significance in the fact
  24. that no errors have been found so far.
  25. - It is difficult to configure, and to use. And any errors here
  26. will reliably crash or hang your system. "mtest" is dumb and has
  27. no knowledge about memory ranges that may be in use for other
  28. purposes, like exception code, U-Boot code and data, stack,
  29. malloc arena, video buffer, log buffer, etc. If you let it, it
  30. will happily "test" all such areas, which of course will cause
  31. some problems.
  32. - It is not easy to configure and use, and a large number of
  33. systems are seriously misconfigured. The original idea was to
  34. test basically the whole system RAM, with only exempting the
  35. areas used by U-Boot itself - on most systems these are the areas
  36. used for the exception vectors (usually at the very lower end of
  37. system memory) and for U-Boot (code, data, etc. - see above;
  38. these are usually at the very upper end of system memory). But
  39. experience has shown that a very large number of ports use
  40. pretty much bogus settings of CONFIG_SYS_MEMTEST_START and
  41. CONFIG_SYS_MEMTEST_END; this results in useless tests (because
  42. the ranges is too small and/or badly located) or in critical
  43. failures (system crashes).
  44. Because of these issues, the "mtest" command is considered depre-
  45. cated. It should not be enabled in most normal ports of U-Boot,
  46. especially not in production. If you really need a memory test,
  47. then see 1. and 3. above resp. below.
  48. 3. The most thorough memory test facility is available as part of the
  49. POST (Power-On Self Test) sub-system, see "post/drivers/memory.c".
  50. If you really need to perform memory tests (for example, because
  51. it is mandatory part of your requirement specification), then
  52. enable this test which is generic and should work on all archi-
  53. tectures.
  54. WARNING:
  55. It should pointed out that _all_ these memory tests have one
  56. fundamental, unfixable design flaw: they are based on the assumption
  57. that memory errors can be found by writing to and reading from memory.
  58. Unfortunately, this is only true for the relatively harmless, usually
  59. static errors like shorts between data or address lines, unconnected
  60. pins, etc. All the really nasty errors which will first turn your
  61. hair gray, only to make you tear it out later, are dynamical errors,
  62. which usually happen not with simple read or write cycles on the bus,
  63. but when performing back-to-back data transfers in burst mode. Such
  64. accesses usually happen only for certain DMA operations, or for heavy
  65. cache use (instruction fetching, cache flushing). So far I am not
  66. aware of any freely available code that implements a generic, and
  67. efficient, memory test like that. The best known test case to stress
  68. a system like that is to boot Linux with root file system mounted over
  69. NFS, and then build some larger software package natively (say,
  70. compile a Linux kernel on the system) - this will cause enough context
  71. switches, network traffic (and thus DMA transfers from the network
  72. controller), varying RAM use, etc. to trigger any weak spots in this
  73. area.
  74. Note: An attempt was made once to implement such a test to catch
  75. memory problems on a specific board. The code is pretty much board
  76. specific (for example, it includes setting specific GPIO signals to
  77. provide triggers for an attached logic analyzer), but you can get an
  78. idea how it works: see "examples/standalone/test_burst*".
  79. Note 2: Ironically enough, the "test_burst" did not catch any RAM
  80. errors, not a single one ever. The problems this code was supposed
  81. to catch did not happen when accessing the RAM, but when reading from
  82. NOR flash.