To enable it, take the below step (test on MSM8916)
enable below config in kernel config:
```
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_RAM=y
CONFIG_PSTORE_FTRACE=y
CONFIG_PSTORE_PMSG=y
CONFIG_DEBUG_FS=y
CONFIG_FUNCTION_TRACER=y
```
and disable below config:
# CONFIG_STRICT_MEMORY_RWX
-----code changes ------
LINUX/android/kernel/fs/pstore/ram.c
```
-static ulong ramoops_console_size = MIN_MEM_SIZE;
+static ulong ramoops_console_size = 256*1024UL;
- static ulong mem_address;
+ static ulong mem_address=0x9ff00000;
module_param(mem_address, ulong, 0400);
MODULE_PARM_DESC(mem_address, "start of reserved RAM used to store oops/panic logs");
- static ulong mem_size;
+ static ulong mem_size=0x100000;
```
kernel/arch/arm/boot/dts/qcom/msm8916-memory.dtsi
```
peripheral_mem: pheripheral_region@0 {
linux,reserve-contiguous-region;
linux,reserve-region;
linux,remove-completely;
reg = <0x0 0x8b600000 0x0 0x0600000>;
label = "peripheral_mem";
};
+ pstore_reserve_mem: pstore_reserve_mem_region@0 {
+ linux,reserve-contiguous-region;
+ linux,reserve-region;
+ linux,remove-completely;
+ reg = <0x0 0x9ff00000 0x0 0x00100000>;
+ label = "pstore_reserve_mem";
+ };
```
-----test command ------
enable record ftrace
```
# mount -t debugfs debugfs /sys/kernel/debug/
# echo 1 > /sys/kernel/debug/pstore/record_ftrace
disable download mode:
# echo 0 > /sys/module/msm_poweroff/parameters/download_mode
# echo c > /proc/sysrq-trigger
```
[...device restart]
```
# ls /sys/fs/pstore/
console-ramoops
dmesg-ramoops-0
dmesg-ramoops-1
ftrace-ramoops
# cat /sys/fs/pstore/ftrace-ramoops
0 c08bf830 c08bfbf0 do_page_fault.part.8 <- do_page_fault+0x3c/0xa8
0 c001b770 c08bfb48 fixup_exception <- do_page_fault.part.8+0x32c/0x398
0 c0045bb0 c001b780 search_exception_tables <- fixup_exception+0x20/0x38
0 c008914c c0045bd8 search_module_extables <- search_exception_tables+0x38/0x44
0 c08bff5c c008915c add_preempt_count <- search_module_extables+0x24/0xc0
0 c08bfe78 c00891cc sub_preempt_count <- search_module_extables+0x94/0xc0
0 c08b2e28 c08bfb64 __do_kernel_fault.part.7 <- do_page_fault.part.8+0x348/0x398
```
--------------------------------------------------------
workaround for 8916/39/94 64 bit version:
ram_core.c (kernel\fs\pstore)
```
+static void *memcpy_pstore(void *dest, const void *src, size_t count)
+{
+ char *tmp = dest;
+ const char *s = src;
+
+ while (count--)
+ *tmp++ = *s++;
+ return dest;
+}
static void notrace persistent_ram_update(struct persistent_ram_zone *prz,
const void *s, unsigned int start, unsigned int count)
{
struct persistent_ram_buffer *buffer = prz->buffer;
- memcpy(buffer->data + start, s, count);
+ memcpy_pstore(buffer->data + start, s, count);
persistent_ram_update_ecc(prz, start, count);
}
```
# 立即重新启动计算机
echo b > /proc/sysrq-trigger
# 立即关闭计算机
echo o > /proc/sysrq-trigger
# 导出内存分配的信息 (可以用/var/log/message 查看)
echo m > /proc/sysrq-trigger
# 导出当前CPU寄存器信息和标志位的信息
echo p > /proc/sysrq-trigger
# 导出线程状态信息
echo t > /proc/sysrq-trigger
# 故意让系统崩溃
echo c > /proc/sysrq-trigger
# 立即重新挂载所有的文件系统
echo s > /proc/sysrq-trigger
# 立即重新挂载所有的文件系统为只读
echo u > /proc/sysrq-trigger
备注: 上面的patch重点是找到一个地址,作为resvered 0x1000000开始地址
// user 版本有问题
pstore 有没有build check .config
如果不能保存pstore,需要check 是否是warm reboot 还是cold reboot
echo 1 /sys/module/msm_poweroff/parameters/download_mode
bool need_warm_reset = true;
in_panic=1---> 会进入download mode, 如果设定成0 , 则download ->reboot,
网友评论