pstore.rst 2.8 KB

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