see also

do debug the boot process the pstore driver is used to create a persitant storage area that survives boot.

The principle idea is:

  • boot the boot image that you want to debug and write the boot log to pstore
  • generate a kernel panic
  • boot a recovery boot image that also has pstore enabled to analyze the log

In the TWRP recovery image for the chiron pstore is enabled and pstore is automatically mounted to /sys/fs/pstore/


The following options have to be enabled in the kernel config (in both boot images)


Mounting pstore

To read the info in pstore it has to be mounted (in the boot image that is used to analyze the pstore) with something like

mount -t pstore pstore /sys/fs/pstore

In the TWRP recovery image for the chiron pstore is automatically mounted to /sys/fs/pstore/

Writing to pstore

When CONFIG_PSTORE_PMSG is enabled it defines a device /dev/pmsg0 to which one can write messages

echo "Hello Guhl" > /dev/pmsg0

After the kernel panic and reboot the result should be in /sys/fs/pstore/pmsg-ramoops-X

Kernel panic

For what ever reason the standard way to generate a kernel panic

echo c > /proc/sysrq-trigger

did not work for me so I created a kernel module that I can insmod to generate a panic.

I am using the attached kernel module to create a kernel panic (modprobe the module)

See also

The files are placed in a directory "panic" in the kernel directory and enabled in kernel config with


In addition the following line has to be added to the Makefile in the kernel directory.

obj-y += panic/

and the following line has to be added to the to the Kconfig in the root of the kernel directory

source "kernel/panic/Kconfig"

Kernel panic in boot image

To use the kernel panic in the boot image it has to be added to the initramfs.


Changes in hybris/hybris-boot/

  • define a variable for the panic module (next to BB_STATIC)
    PM_STATIC := $(PRODUCT_OUT)/vendor/lib/modules/panic.ko
  • copy the PM_STATIC to the /bin directory (next to "@cp $(BB_STATIC) $(BOOT_INTERMEDIATE)/initramfs/bin/")
    @cp $(PM_STATIC) $(BOOT_INTERMEDIATE)/initramfs/bin/

Usage in init

See also

To write to pstore and cause a kernel panic add something like

    # first test of pstore / panic
    cat /init.log > /dev/pmsg0
    /bin/busybox insmod /bin/panic.ko

to hybris/hybris-boot/init-script where ever you want to see the init.log or output additional information.

Then build the boot image using make hybrs-boot in HABUILD and boot it using fastboot boot. After the kernel panic and the reboot boot to recovery or LOS and check the files in /sys/fs/pstore

/sys/fs/pstore/console-ramoops-0 and /sys/fs/pstore/dmesg-ramoops-0 should contain

<0>[    3.596679] Kernel panic - not syncing: Guhl caused a kernel panic!

/sys/fs/pstore/pmsg-ramoops-0 should contain the init.log of mer and look something like

+ exec
+ echo Running Mer Boat Loader
Running Mer Boat Loader
+ DATA_PARTITION=/dev/sda17
+ DEFAULT_OS=sailfishos
+ export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
+ ANDROID_USB=/sys/class/android_usb/android0
+ GADGET_DIR=/config/usb_gadget
+ [ /init = /init-debug ]
+ [ no = no ]
+ /bin/busybox --install -s
+ date
Sat Nov 28 00:15:15 UTC 1970
+ do_mount_devprocsys
+ echo ########################## mounting devprocsys
########################## mounting devprocsys
+ mkdir /dev
mkdir: can't create directory '/dev': File exists
+ mount -t devtmpfs devtmpfs /dev
+ mkdir /dev/pts
+ mount -t devpts devpts /dev/pts
+ mkdir /proc
+ mkdir /sys
+ mount -t sysfs sysfs /sys
+ mount -t proc proc /proc
+ mkdir /config
+ mount -t configfs none /config
+ do_hotplug_scan
+ echo /sbin/mdev
+ mdev -s
+ sleep 2
+ cat /init.log
Last modified 2 years ago Last modified on 09/07/18 08:50:52

Attachments (3)

Download all attachments as: .zip