I'm trying to diagnose a random reboot on LineageOS 14. last_kmsg
is not in /proc
, nor it is in /sys/fs/pstore/console-ramoops
.
EDIT:
~# mount | grep PSTORE
~# mkdir /mnt/pstore && mount pstore -t pstore /mnt/pstore && ls /mnt/pstore
mount: 'pstore'->'/mnt/pstore': No such device
Answer
Back in 2012, /proc/last_kmsg
(1) used to be a dump of kernel console messages, exported after reboots by Android's ram_console
functionality (CONFIG_ANDROID_RAM_CONSOLE), which used persistent_ram
(CONFIG_ANDROID_PERSISTENT_RAM) to handle a block of RAM that wasn't erased across reboots (2).
persistent_ram
was based on Linux upstream RAMOOPS code which logged panic and oops messages to RAM. RAMOOPS was deprecated in favor of PSTORE (3) (memory handling) and PSTORE_RAM (4) (logging panics/oops to pstore/dmesg-ramoops
). Later PSTORE_CONSOLE support was added (5, 6) to log not only the panics/oops, but all kernel console messages to pstore/console-ramoops-N
which can be read later by mounting pstore
(7). So the Android specific RAM_CONSOLE (8, 9) and PERSISTENT_RAM (10) were utterly removed.
Now pstore
also offers logging userspace messages (PSTORE_PMSG) (11) and other features (12). Plus it supports multiple backends for persistent storage if supported by hardware, though SoC's on Android devices only support RAM storage (ramoops
driver, AFAIK).
So it's not possible to enable last_kmsg
on an upstream kernel, instead pstore
offers a more versatile functionality.
mount: 'pstore'->'/mnt/pstore': No such device
It shows that your kernel isn't built with pstore
support. All you need to do is use a kernel built with CONFIG_PSTORE_CONSOLE
and optionally CONFIG_PSTORE_RAM
(though buggy). Android's init
by-default mounts pstore
at /sys/fs/pstore
(13) from where dmesg-ramoops
(on panics/oops only) and console-ramoops
can be read.
You can search forums for a custom ROM shipped with such kernel. Or if you have kernel source, you can build yourself on a Linux machine.
NOTE: Some new devices, like Samsung, still expose /proc/last_kmsg
interface; I'm not sure whether they use original implementation or pstore
at back end.
FURTHER READING: Reading kernel logs
No comments:
Post a Comment