ramoops.txt 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Ramoops oops/panic logger
  2. =========================
  3. Sergiu Iordache <sergiu@chromium.org>
  4. Updated: 17 November 2011
  5. 0. Introduction
  6. Ramoops is an oops/panic logger that writes its logs to RAM before the system
  7. crashes. It works by logging oopses and panics in a circular buffer. Ramoops
  8. needs a system with persistent RAM so that the content of that area can
  9. survive after a restart.
  10. 1. Ramoops concepts
  11. Ramoops uses a predefined memory area to store the dump. The start and size of
  12. the memory area are set using two variables:
  13. * "mem_address" for the start
  14. * "mem_size" for the size. The memory size will be rounded down to a
  15. power of two.
  16. The memory area is divided into "record_size" chunks (also rounded down to
  17. power of two) and each oops/panic writes a "record_size" chunk of
  18. information.
  19. Dumping both oopses and panics can be done by setting 1 in the "dump_oops"
  20. variable while setting 0 in that variable dumps only the panics.
  21. The module uses a counter to record multiple dumps but the counter gets reset
  22. on restart (i.e. new dumps after the restart will overwrite old ones).
  23. Ramoops also supports software ECC protection of persistent memory regions.
  24. This might be useful when a hardware reset was used to bring the machine back
  25. to life (i.e. a watchdog triggered). In such cases, RAM may be somewhat
  26. corrupt, but usually it is restorable.
  27. 2. Setting the parameters
  28. Setting the ramoops parameters can be done in 2 different manners:
  29. 1. Use the module parameters (which have the names of the variables described
  30. as before).
  31. 2. Use a platform device and set the platform data. The parameters can then
  32. be set through that platform data. An example of doing that is:
  33. #include <linux/pstore_ram.h>
  34. [...]
  35. static struct ramoops_platform_data ramoops_data = {
  36. .mem_size = <...>,
  37. .mem_address = <...>,
  38. .record_size = <...>,
  39. .dump_oops = <...>,
  40. .ecc = <...>,
  41. };
  42. static struct platform_device ramoops_dev = {
  43. .name = "ramoops",
  44. .dev = {
  45. .platform_data = &ramoops_data,
  46. },
  47. };
  48. [... inside a function ...]
  49. int ret;
  50. ret = platform_device_register(&ramoops_dev);
  51. if (ret) {
  52. printk(KERN_ERR "unable to register platform device\n");
  53. return ret;
  54. }
  55. 3. Dump format
  56. The data dump begins with a header, currently defined as "====" followed by a
  57. timestamp and a new line. The dump then continues with the actual data.
  58. 4. Reading the data
  59. The dump data can be read from the pstore filesystem. The format for these
  60. files is "dmesg-ramoops-N", where N is the record number in memory. To delete
  61. a stored record from RAM, simply unlink the respective pstore file.