[英]Using persistent storage in linux kernel
我正在尝试使用 linux 内核中可用的持久存储(Pstore),但不知何故我没有在内核崩溃的情况下获取日志。 我在内核配置文件中制作了以下内核模块作为内置:
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_RAM=y
现在 a/c 到文档pstore我应该在 /sys/fs/pstore/...(或 /dev/pstore/...)中获取下次重新启动时的日志,但在那里找不到日志。 我是不是错过了什么……?
除了内核配置选项:
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_PMSG=y
CONFIG_PSTORE_RAM=y
我不得不保留一部分内存来保存日志。 我通过这样的设备树做到了这一点:
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>;
};
另外,检查是否存在以下内核补丁(内核需要它才能解析上面给出的选项): https : //android-review.googlesource.com/#/c/kernel/common/+/ 195160/
另一种方式是通过内核cmdline开启,例如:
ramoops.mem_address=0x30000000 ramoops.mem_size=0x100000 memmap=0x100000$0x30000000
检查以下配置选项是否已启用
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
**CONFIG_PSTORE_FTRACE=y**
CONFIG_PSTORE_RAM=y
但为什么 /dev/pstore 文件?,它不需要,
要检查 console-ramoops 是否工作,请执行 echo Trigger a kernel panic using command
echo c > /proc/sysrq-trigger
然后手动重启设备。 系统启动后,运行命令“/sys/fs/pstore/console-ramoops”,检查console_ramoops是否有任何记录。
您必须按照@shadowfire 的描述声明平台数据。 但是所有内核都不能将设备树用于ramoops。
通用的方法是在你的硬件的源文件中(例如 mx6ul : arch/arm/mach-imx/mach-imx6ul.c )在函数 xxx_init_machine 中添加以下代码:
#include <linux/pstore_ram.h>
[...]
static struct ramoops_platform_data ramoops_data = {
.mem_size = <...>,
.mem_address = <...>,
.mem_type = <...>,
.record_size = <...>,
.dump_oops = <...>,
.ecc = <...>,
};
static struct platform_device ramoops_dev = {
.name = "ramoops",
.dev = {
.platform_data = &ramoops_data,
},
};
[... inside xxx_init_machine ...]
int ret;
ret = platform_device_register(&ramoops_dev);
if (ret) {
printk(KERN_ERR "unable to register platform device\n");
return ret;
}
文档中提供的更多信息: ramoops
您是否有 dmesg 中的日志可以确认 ramoops 已成功启用?
# dmesg | grep -i "pstore\|ramoops"
console [pstore-1] enabled
pstore: Registered ramoops as persistent store backend
ramoops: attached 0x20000@0x80000000, ecc: 0/0
此外,您必须挂载 pstore 目录,这就是为什么该目录在您的 rootfs 上为空的原因:
mount -t pstore -o kmsg_bytes=8000 - /sys/fs/pstore
挂载的默认大小为 10 KB,因为您没有设置 kmsg_bytes 选项。 您可以使用 /etc/fstab 自动挂载它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.