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