1 Ramoops oops/panic logger 2 ========================= 3 4 Sergiu Iordache <sergiu@chromium.org> 5 6 Updated: 10 Feb 2021 7 8 Introduction 9 ------------ 10 11 Ramoops is an oops/panic logger that writes it 12 crashes. It works by logging oopses and panics 13 needs a system with persistent RAM so that the 14 survive after a restart. 15 16 Ramoops concepts 17 ---------------- 18 19 Ramoops uses a predefined memory area to store 20 and type of the memory area are set using thre 21 22 * ``mem_address`` for the start 23 * ``mem_size`` for the size. The memory size 24 power of two. 25 * ``mem_type`` to specify if the memory type 26 * ``mem_name`` to specify a memory region de 27 line parameter. 28 29 Typically the default value of ``mem_type=0`` 30 mapping to pgprot_writecombine. Setting ``mem_ 31 ``pgprot_noncached``, which only works on some 32 depends on atomic operations. At least on ARM, 33 memory to be mapped strongly ordered, and atom 34 memory are implementation defined, and won't w 35 Setting ``mem_type=2`` attempts to treat the m 36 which enables full cache on it. This can impro 37 38 The memory area is divided into ``record_size` 39 power of two) and each kmesg dump writes a ``r 40 information. 41 42 Limiting which kinds of kmsg dumps are stored 43 the ``max_reason`` value, as defined in includ 44 ``enum kmsg_dump_reason``. For example, to sto 45 ``max_reason`` should be set to 2 (KMSG_DUMP_O 46 ``max_reason`` should be set to 1 (KMSG_DUMP_P 47 (KMSG_DUMP_UNDEF), means the reason filtering 48 ``printk.always_kmsg_dump`` boot param: if uns 49 otherwise KMSG_DUMP_MAX. 50 51 The module uses a counter to record multiple d 52 on restart (i.e. new dumps after the restart w 53 54 Ramoops also supports software ECC protection 55 This might be useful when a hardware reset was 56 to life (i.e. a watchdog triggered). In such c 57 corrupt, but usually it is restorable. 58 59 Setting the parameters 60 ---------------------- 61 62 Setting the ramoops parameters can be done in 63 64 A. Use the module parameters (which have the 65 as before). For quick debugging, you can also 66 boot and then use the reserved memory for ram 67 machine with > 128 MB of memory, the followin 68 the kernel to use only the first 128 MB of me 69 ramoops region at 128 MB boundary:: 70 71 mem=128M ramoops.mem_address=0x8000000 72 73 B. Use Device Tree bindings, as described in 74 ``Documentation/devicetree/bindings/reserved- 75 For example:: 76 77 reserved-memory { 78 #address-cells = <2>; 79 #size-cells = <2>; 80 ranges; 81 82 ramoops@8f000000 { 83 compatible = "ramoops" 84 reg = <0 0x8f000000 0 85 record-size = <0x4000> 86 console-size = <0x4000 87 }; 88 }; 89 90 C. Use a platform device and set the platform 91 be set through that platform data. An example 92 93 .. code-block:: c 94 95 #include <linux/pstore_ram.h> 96 [...] 97 98 static struct ramoops_platform_data ramoops_ 99 .mem_size = <...>, 100 .mem_address = <...>, 101 .mem_type = <...>, 102 .record_size = <...>, 103 .max_reason = <...>, 104 .ecc = <...>, 105 }; 106 107 static struct platform_device ramoops_dev = 108 .name = "ramoops", 109 .dev = { 110 .platform_data = &ramoops_data 111 }, 112 }; 113 114 [... inside a function ...] 115 int ret; 116 117 ret = platform_device_register(&ramoops_dev) 118 if (ret) { 119 printk(KERN_ERR "unable to register pl 120 return ret; 121 } 122 123 D. Using a region of memory reserved via ``re 124 parameter. The address and size will be de 125 parameter. Note, that ``reserve_mem`` may 126 in the same location, and cannot be relied 127 to be done, and it may not work on every m 128 Consider this a "best effort" approach. Th 129 takes a size, alignment and name as argume 130 to map the memory to a label that can be r 131 132 reserve_mem=2M:4096:oops ramoops.mem_ 133 134 You can specify either RAM memory or periphera 135 specifying RAM, be sure to reserve the memory 136 very early in the architecture code, e.g.:: 137 138 #include <linux/memblock.h> 139 140 memblock_reserve(ramoops_data.mem_addr 141 142 Dump format 143 ----------- 144 145 The data dump begins with a header, currently 146 timestamp and a new line. The dump then contin 147 148 Reading the data 149 ---------------- 150 151 The dump data can be read from the pstore file 152 files is ``dmesg-ramoops-N``, where N is the r 153 a stored record from RAM, simply unlink the re 154 155 Persistent function tracing 156 --------------------------- 157 158 Persistent function tracing might be useful fo 159 related hangs. The functions call chain log is 160 file. Here is an example of usage:: 161 162 # mount -t debugfs debugfs /sys/kernel/debug/ 163 # echo 1 > /sys/kernel/debug/pstore/record_ft 164 # reboot -f 165 [...] 166 # mount -t pstore pstore /mnt/ 167 # tail /mnt/ftrace-ramoops 168 0 ffffffff8101ea64 ffffffff8101bcda native_ 169 0 ffffffff8101ea44 ffffffff8101bcf6 native_ 170 0 ffffffff81020084 ffffffff8101a4b5 hpet_di 171 0 ffffffff81005f94 ffffffff8101a4bb iommu_s 172 0 ffffffff8101a6a1 ffffffff8101a437 native_ 173 0 ffffffff811f9876 ffffffff8101a73a acpi_re 174 0 ffffffff8101a514 ffffffff8101a772 mach_re 175 0 ffffffff811d9c54 ffffffff8101a7a0 __const 176 0 ffffffff811d9c34 ffffffff811d9c80 __delay 177 0 ffffffff811d9d14 ffffffff811d9c3f delay_t
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.