linux记录关机前上一次系统log,打印本次开机原因

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,这是标准流程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值