Friday, May 31, 2019

root access - How to capture kernel panic logs when ROM failed to flash?


Background: Stuck in boot-loop when unpack and pack system.img?


Short Description: I am trying to modify the system partition of my Samsung S10 5G system-as-root treble device. I have successfully rooted it with patching the AP file and flashed it on the device. It works fine but if I will just unpack and then pack the system.img.ext4.lz4(or vendor.img.ext4.lz4) and put it in the AP file, then the flashing succeeds but the device stuck in a boot loop. So, I am interested to see the logs that cause the boot loop.


Try 1: I have read about pstore and using adb I have noted the following things:



  1. Run find . | grep pstore and the result is as following:



./sys/fs/pstore
./sys/module/pstore
./sys/module/pstore/uevent
./sys/module/pstore/parameters
./sys/module/pstore/parameters/update_ms
./sys/module/pstore/parameters/backend


  1. Check the kernel config by pulling the file from /proc/config.gz and it has all the flag available that are listed in Reading kernel logs article.



$ cat config | grep PSTORE
CONFIG_PSTORE=y
CONFIG_PSTORE_ZLIB_COMPRESS=y
# CONFIG_PSTORE_LZO_COMPRESS is not set
# CONFIG_PSTORE_LZ4_COMPRESS is not set
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_PMSG=y
CONFIG_PSTORE_PMSG_SSPLOG=y
CONFIG_PSTORE_RAM=y


With the above information, I should be able to read logs from /sys/fs/pstore/ after following the following steps:



  1. Flash the ROM that makes the kernel panic. Followed all steps to root the system-as-root device until the step to boot in recovery mode after factory data reset. Because the device didn't boot properly and stuck in a boot loop.

  2. Open the download mode and flashed the working ROM with following the root instructions.

  3. After setup the device, I have installed MagiskManager and let it do its work.

  4. Then, I have opened the adb shell with su user. I have tried to check logs but there were no logs:


1|beyondxq:/ # ls -l /sys/fs/pstore/
total 0


Try 2: Read this article and tried to do the same step as above but with mounting /dev/pstore as following:


// Just flashed rooted ROM
// Install MagiskManager and allow it to do required setup
// Run adb shell:
D:\SamsungS105G\VZW-G977UVRU2ASH7-20190827135903>adb shell
beyondxq:/ $ su
beyondxq:/ # ls -l /dev/pstore
ls: /dev/pstore: No such file or directory
1|beyondxq:/ # ls -l /sys/fs/pstore/

total 0
beyondxq:/ # mkdir /dev/pstore
beyondxq:/ # mount -t pstore - /dev/pstore
beyondxq:/ # ls -l /dev/pstore
total 0
beyondxq:/ #

// switching off
// Opening Download mode
// Flashing Panic ROM

// Reboot into recovery
// Done Wipe data/factory reset and then Reboot system now
// Pressed Recovery ket combination till Splash Screen
// Instead of starting setup, the device rebooted, display Splash, black screen, and then again device rebooted...[3 times]

// Open download mode
// Flashing rooted ROM
// Reboot into recovery
// Done Wipe data/factory reset and then Reboot system now
// Pressed Recovery key combination till Splash Screen

// Device opened with root enable
// Install MagiskManager and allow it to do required setup
// Run adb shell:
D:\SamsungS105G\VZW-G977UVRU2ASH7-20190827135903>adb shell
beyondxq:/ $ su
beyondxq:/ # ls -l /dev/pstore
ls: /dev/pstore: No such file or directory
1|beyondxq:/ # ls -l /sys/fs/pstore/
total 0
beyondxq:/ # mkdir /dev/pstore

beyondxq:/ # mount -t pstore - /dev/pstore
beyondxq:/ # ls -l /dev/pstore
total 0
beyondxq:/ # ls -l /sys/fs/pstore/
total 0

The above is the 6th try. While scrolling the command prompt above, I have noticed that in the very first try I have following logs:


1|beyondxq:/ # mkdir /dev/pstore
beyondxq:/ # ls /dev/pstore/
beyondxq:/ # mount -t pstore - /dev/pstore

beyondxq:/ # ls /dev/pstore/
beyondxq:/ #

-- Probably switch off or reboot

D:\SamsungS105G\VZW-G977UVRU2ASH7-20190827135903>adb shell
beyondxq:/ $ su
beyondxq:/ # ls /dev/pstore
ls: /dev/pstore: No such file or directory
1|beyondxq:/ # mount -t pstore - /dev/pstore

mount: '-'->'/dev/pstore': No such file or directory
1|beyondxq:/ # mkdir /dev/pstore
beyondxq:/ # mount -t pstore - /dev/pstore
beyondxq:/ # ls -l /dev/pstore/
total 0
-r--r----- 1 system log 262004 2018-01-11 09:32 console-ramoops-0
beyondxq:/ # exit
beyondxq:/ $ exit

So, I did a mistake :( and missed to read the console-ramoops-0 file. But the problem is I am not able to get it back.



Is it like:



  • if you don't remove the console-ramoops-0 file when its generated first then no more logs will be written by kernel?

  • Or the memory is full?


Please suggest what I did wrong in my later tries?


Update: Tried to crash manually using the instructions given here but no logs recorded.


Update 2: Grep the pstore using find . | grep '\.rc' | xargs cat | grep pstore -n -i and get following result:


314:    # pstore/ramoops previous console log
315: mount pstore pstore /sys/fs/pstore nodev noexec nosuid

316: chown system log /sys/fs/pstore/console-ramoops
317: chmod 0440 /sys/fs/pstore/console-ramoops
318: chown system log /sys/fs/pstore/console-ramoops-0
319: chmod 0440 /sys/fs/pstore/console-ramoops-0
320: chown system log /sys/fs/pstore/pmsg-ramoops-0
321: chmod 0440 /sys/fs/pstore/pmsg-ramoops-0
13623: # pstore/ramoops previous console log
13624: mount pstore pstore /sys/fs/pstore nodev noexec nosuid
13625: chown system log /sys/fs/pstore/console-ramoops
13626: chmod 0440 /sys/fs/pstore/console-ramoops

13627: chown system log /sys/fs/pstore/console-ramoops-0
13628: chmod 0440 /sys/fs/pstore/console-ramoops-0
13629: chown system log /sys/fs/pstore/pmsg-ramoops-0
13630: chmod 0440 /sys/fs/pstore/pmsg-ramoops-0
27725: # pstore/ramoops previous console log
27726: mount pstore pstore /sys/fs/pstore nodev noexec nosuid
27727: chown system log /sys/fs/pstore/console-ramoops
27728: chmod 0440 /sys/fs/pstore/console-ramoops
27729: chown system log /sys/fs/pstore/console-ramoops-0
27730: chmod 0440 /sys/fs/pstore/console-ramoops-0

27731: chown system log /sys/fs/pstore/pmsg-ramoops-0
27732: chmod 0440 /sys/fs/pstore/pmsg-ramoops-0

Update 3 The configuration of ramoops is as following:


./sys/module/ramoops/parameters/console_size            262144
./sys/module/ramoops/parameters/dump_oops 1
./sys/module/ramoops/parameters/ecc 0
./sys/module/ramoops/parameters/ftrace_size 262144
./sys/module/ramoops/parameters/mem_address 3241148416
./sys/module/ramoops/parameters/mem_size 1048576

./sys/module/ramoops/parameters/mem_type 0
./sys/module/ramoops/parameters/pmsg_size 262144
./sys/module/ramoops/parameters/record_size 262144


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...