pstore.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. PStore command
  3. ==============
  4. Design
  5. ------
  6. Linux PStore and Ramoops modules (Linux config options PSTORE and PSTORE_RAM)
  7. allow to use memory to pass data from the dying breath of a crashing kernel to
  8. its successor. This command allows to read those records from U-Boot command
  9. line.
  10. Ramoops is an oops/panic logger that writes its logs to RAM before the system
  11. crashes. It works by logging oopses and panics in a circular buffer. Ramoops
  12. needs a system with persistent RAM so that the content of that area can survive
  13. after a restart.
  14. Ramoops uses a predefined memory area to store the dump.
  15. Ramoops parameters can be passed as kernel parameters or through Device Tree,
  16. i.e.::
  17. ramoops.mem_address=0x30000000 ramoops.mem_size=0x100000 ramoops.record_size=0x2000 ramoops.console_size=0x2000 memmap=0x100000$0x30000000
  18. The same values should be set in U-Boot to be able to retrieve the records.
  19. This values can be set at build time in U-Boot configuration file, or at runtime.
  20. U-Boot automatically patches the Device Tree to pass the Ramoops parameters to
  21. the kernel.
  22. The PStore configuration parameters are:
  23. ======================= ==========
  24. Name Default
  25. ======================= ==========
  26. CMD_PSTORE_MEM_ADDR
  27. CMD_PSTORE_MEM_SIZE 0x10000
  28. CMD_PSTORE_RECORD_SIZE 0x1000
  29. CMD_PSTORE_CONSOLE_SIZE 0x1000
  30. CMD_PSTORE_FTRACE_SIZE 0x1000
  31. CMD_PSTORE_PMSG_SIZE 0x1000
  32. CMD_PSTORE_ECC_SIZE 0
  33. ======================= ==========
  34. Records sizes should be a power of 2.
  35. The memory size and the record/console size must be non-zero.
  36. Multiple 'dump' records can be stored in the memory reserved for PStore.
  37. The memory size has to be larger than the sum of the record sizes, i.e.::
  38. MEM_SIZE >= RECORD_SIZE * n + CONSOLE_SIZE + FTRACE_SIZE + PMSG_SIZE
  39. Usage
  40. -----
  41. Generate kernel crash
  42. ~~~~~~~~~~~~~~~~~~~~~
  43. For test purpose, you can generate a kernel crash by setting reboot timeout to
  44. 10 seconds and trigger a panic
  45. .. code-block:: console
  46. $ sudo sh -c "echo 1 > /proc/sys/kernel/sysrq"
  47. $ sudo sh -c "echo 10 > /proc/sys/kernel/panic"
  48. $ sudo sh -c "echo c > /proc/sysrq-trigger"
  49. Retrieve logs in U-Boot
  50. ~~~~~~~~~~~~~~~~~~~~~~~
  51. First of all, unless PStore parameters as been set during U-Boot configuration
  52. and match kernel ramoops parameters, it needs to be set using 'pstore set', e.g.::
  53. => pstore set 0x30000000 0x100000 0x2000 0x2000
  54. Then all available dumps can be displayed
  55. using::
  56. => pstore display
  57. Or saved to an existing directory in an Ext2 or Ext4 partition, e.g. on root
  58. directory of 1st partition of the 2nd MMC::
  59. => pstore save mmc 1:1 /