Android knowledge point 450 -- Reason Analysis of Android restart

Keywords: Mobile Android shell Java

Reprinted Original: https://blog.csdn.net/chi_wy/article/details/42472279

Return to knowledge list: Android knowledge points list

1, Restart reason classification

1. Upper layer causes restart

  • system_server killed
  • watchdog restart
  • Critical thread blocking

2. Restart caused by kernel

  • Null pointer
  • Illegal address

3.kernel watchdog causes restart, and the reason is uncertain

  • Memory reason
  • nand drive

 

log view steps and keywords

1. After restart kernel.log Or misc/cmdline.log

At the top of the log, there will be a long section, such as:

initrd=0x85500000,0x204229 apv="td860-user 4.1.2 MocorDroid4.1.2 eng..20131107.215135 test-keys" mem=512M loglevel=1 console=ttyS1,115200n8 init=/init mtdparts=sprd-nand:256k(spl),512k(2ndbl),256k(params),512k(vmjaluna),10m(modem),3840k(fixnv),3840k(backupfixnv),5120k(dsp),3840k(runtimenv),10m(boot),10m(recovery),250m(system),180m(userdata),20m(cache),256k(misc),1m(boot_logo),1m(fastboot_logo),3840k(productinfo),512k(kpanic) androidboot.mode=panic lcd_id=ID9816 lcd_base=8ff27000 CHR_STATE=0 ram=512M no_console_suspend boot_ram_log=0x8fe00000,0x80000 tdfixnv=0x89060000,0x40000 tdruntimenv=0x890a0000,0x60000 wfixnv=0x90440000,0x40000 wruntimenv=0x90480000,0x60000 productinfo=0x80490000,0x4000 androidboot.serialno=12345678912345 adc_cal=216338536,185339408 fgu_cal=186388584,159845904,7534 fgu_init=2805,7742 

search androidboot.mode If not, it defaults to normal mode and starts normally. In the above example, it is panic, which is the restart caused by an error in the kernel. This value is from ana_ REG_ GLB_ POR_ RST_ The value obtained in the monitor bit will be set to 0 after each acquisition:

rst_mode = ANA_REG_GET(ANA_REG_GLB_POR_RST_MONITOR);
rst_mode &= 0x7FFF;
ANA_REG_SET(ANA_REG_GLB_POR_RST_MONITOR, 0); //clear flag 

This value is filled in before restart, such as HWRST_STATUS_PANIC,HWRST_STATUS_ALARM, etc.


2. Last after restart_ kmsg log

This file records the kernel log before restart. Search the panic to determine whether the problem occurs at the upper or lower level. If there is information about the panic, it is generally caused by the kernel. If there is a Restarting system, it is caused by the upper level. Here is logcat.


Case 1: restart caused by upper null pointer

0[   83.522143] Restarting system with command 'special-systemserver-died'.
0[   83.900657] SPRD_WDT watchdog_feeder, margin=20, feed_period=3, sys_cnt = 86225
0[   84.026350] sprd_set_reboot_mode:cmd=special-systemserver-died 

At this time, there is a problem with the upper system server that causes the restart. Check the restart mode androidboot.mode=special , which is the restart caused by the system server hanging up. It seems that the special mode is caused by the upper layer.

reboot: Restarting system with command 'special-systemserver-died'.

The command here can have "shell", "recovery", "conservation". For example, recovery may be the user's factory settings, while recovery is RecueParty.java It's working.

Case 2:

[other] when the phone is in standby mode, press Power key for a long time to POP up POP box, do nothing, and press Power for a long time, the phone will restart automatically.
[preset conditions] none
[operation steps] long press the Power key when the phone is in standby mode -- POP up the POP box and do nothing -- continue to long press the Power key
[actual result] the phone will restart automatically
[expected result] should be normal
[recurrence probability] Must
[note] no such phenomenon compared with other mobile phones.

Analysis: last_ SPRD found in kmsg_ set_ reboot_ mode:cmd=panic , which indicates that the restart is caused by the kernel. In the log of the attachment, there are also!!! trigger_watch_powerkey !!!! do emergency_restart, indicating that it is most likely to call restart actively, and search and find in the code

static void trigger_watch_powerkey(void *private)
{
  unsigned long flags;
  local_irq_save(flags);
#ifdef CONFIG_MAGIC_SYSRQ
  handle_sysrq('m');
  handle_sysrq('w');
#endif
  pr_warn("!!!! trigger_watch_powerkey !!!! do emergency_restart\n");
  emergency_restart();
  pr_err("%s should never reach here!\n", __func__);
} 

This function will be called when the power key is pressed for more than 6 seconds to restart the mobile phone. The added function of consulting Spreadtrum is to debug the fixed screen problem, which can be removed in mass production.

Solution: comment out the input in the code_ report_ key_ For the call of hook function, the input-hook.o library is not compiled in Makefile.

Case 3:

[wireless hotspot] pull down the status bar, click the wireless hotspot, and the phone will restart automatically
[preset conditions] none
[operation steps] pull down the status bar - click the wireless hotspot multiple times
[actual result] automatic restart of mobile phone
[expected result] the wireless hotspot is turned on and off normally
[recurrence probability] often

Analysis: last_ The Kernel panic - not syncing: Fatal exception is found in kmsg. It indicates that the restart is caused by the kernel, and the stack information printed out should be WIFI problem. Check last_ The kernel log in the log may be soft_ap open failed.

01-01 08:06:06.522 <4>[  296.682000] thr_wait_for_2nd_eth_dev: sap_eth_sema timeout 

Solution: increase the number of open attempts to 3, and reduce the probability of open failure.

Posted by 4554551n on Thu, 18 Jun 2020 21:01:58 -0700