Linux 记录上次log使用的方法:
基于pstore和 ramoops实现在非易失性内存中保存panic日志
kernel 配置
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_PMSG=y
CONFIG_PSTORE_RAM=y
dts配置崩溃打印地址
ramoops_mem: ramoops_mem {
reg = <0x0 0x110000 0x0 0xf0000>;
reg-names = “ramoops_mem”;
};
ramoops {
compatible = “ramoops”;
record-size = <0x0 0x20000>;
console-size = <0x0 0x80000>;
ftrace-size = <0x0 0x00000>;
pmsg-size = <0x0 0x50000>;
memory-region = <&ramoops_mem>;
};
开机mount pstore
pstore/ramoops previous console log
mount pstore pstore /sys/fs/pstore
chown system log /sys/fs/pstore/console-ramoops
chmod 0440 /sys/fs/pstore/console-ramoops
chown system log /sys/fs/pstore/pmsg-ramoops-0
chmod 0440 /sys/fs/pstore/pmsg-ramoops-0
测试
echo c > /proc/sysrq-trigger
开机方式获取,通常在uboot里面都有接口
通过uboot里的enum fbt_reboot_type board_fbt_get_reboot_type(void)函数来获取
关机方式:
关机方式走的是SYSCALL_DEFINE4,这是标准流程