Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using persistent storage in linux kernel

I am trying to use persistent store(Pstore) available in linux kernel but somehow I am not getting the logs in case of kernel panics. I made the following kernel modules in kernel config file as built in:

CONFIG_PSTORE=y 
CONFIG_PSTORE_CONSOLE=y 
CONFIG_PSTORE_RAM=y

Now a/c to documentation pstore I should get the logs on next reboot in /sys/fs/pstore/... (or /dev/pstore/...) but couldn't find the logs there. Am I missing something...?

like image 259
user2910111 Avatar asked Mar 17 '23 00:03

user2910111


2 Answers

Besides the kernel config options:

CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_PMSG=y
CONFIG_PSTORE_RAM=y

I had to reserve a part of memory in which the logs will be saved. I did this through the device tree like this:

reserved-memory {
    #address-cells = <2>;
    #size-cells = <2>;
    ranges;

    pstore: pstore@FF00000 {
        no-map;
        reg = <0x0 0xFF00000 0x0 0x00100000>;  /* pstore/ramoops buffer
            starts at memory address 0xFF00000 and is of size 0x00100000 */
    };
};

ramoops {
    compatible = "ramoops";
    memory-region = <&pstore>;
    record-size     = <0x0 0x00020000>;
    console-size    = <0x0 0x00020000>;
    pmsg-size       = <0x0 0x00020000>;
};

Also, check if the following kernel patch is present (which is needed for the kernel to be able to parse the options given above): https://android-review.googlesource.com/#/c/kernel/common/+/195160/

Another way is to turn it on through the kernel cmdline, for example:

ramoops.mem_address=0x30000000 ramoops.mem_size=0x100000 memmap=0x100000$0x30000000
like image 189
shadowfire Avatar answered Mar 19 '23 14:03

shadowfire


check if below config options are enabled

CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
**CONFIG_PSTORE_FTRACE=y**
CONFIG_PSTORE_RAM=y

But why /dev/pstore file?, it's not needed,

To check if console-ramoops working, do echo Trigger a kernel panic using command

echo c > /proc/sysrq-trigger

then reboot device manually. after system boots up, run command "/sys/fs/pstore/console-ramoops", check if console_ramoops has got anything logged.

like image 41
Sundeep471 Avatar answered Mar 19 '23 12:03

Sundeep471