How to set it up so kernel panic will reboot to fastboot

Hey,

I’m writing some device drivers and sometimes panic the kernel, to save some time (sometimes I work remotely and can’t physically hold vol- and pwr buttons), how can I get it to reboot directly to fastboot? When I say fastboot, I mean when LK allows me to push a new boot img to the device. Thanks.

Example log output from a kernel panic.
[ 24.585801] Rebooting in 5 seconds…
[ 29.588433] Going down for restart now
[ 29.591921] Causing a watchdog bite!
[ 29.595700] Wdo
Format: Log Type - Time(microsec) - Message - Optional Info
Log Type: B - Since Boot(Power On Reset), D - Delta, S - Statistic
S - QC_IMAGE_VERSION_STRING=BOOT.BF.3.0-00261
S - IMAGE_VARIANT_STRING=HAAAANAAA
S - OEM_IMAGE_VERSION_STRING=C-BPATTH
S - Boot Config, 0x000002e1
S - Core 0 Frequency, 0 MHz
B - 1545 - PBL, Start
B - 3490 - bootable_media_detect_entry, Start
B - 152082 - bootable_media_detect_success, Start
B - 152086 - elf_loader_entry, Start
B - 155051 - auth_hash_seg_entry, Start
B - 155261 - auth_hash_seg_exit, Start
B - 170702 - elf_segs_hash_verify_entry, Start
B - 229929 - PBL, End
B - 236436 - SBL1, Start
B - 299357 - pm_device_init, Start
D - 14762 - pm_device_init, Delta
B - 314699 - boot_flash_init, Start
D - 30 - boot_flash_init, Delta
B - 318725 - boot_config_data_table_init, Start
D - 30896 - boot_config_data_table_init, Delta - (0 Bytes)
B - 354196 - CDT version:3,Platform ID:24,Major ID:1,Minor ID:0,Subtype:0
B - 360388 - sbl1_ddr_set_params, Start
B - 364109 - cpr_init, Start
D - 0 - cpr_init, Delta
B - 369721 - Pre_DDR_clock_init, Start
D - 183 - Pre_DDR_clock_init, Delta
D - 0 - sbl1_ddr_set_params, Delta
B - 382226 - pm_driver_init, Start
D - 6832 - pm_driver_init, Delta
B - 397750 - clock_init, Start
D - 30 - clock_init, Delta

for kernel development, i would recommend that you don’t flash the boot.img in the first place. So you erase once the boot partition with

fastboot erase boot

then on reboot/reset LK will automatically fallback into fastboot, since there is no boot image.

You can boot your own image with

fastboot boot <boot.img>

It will load the boot.img into memory and boot it, without flashing it into eMMC.

To answer the actual question, i don’t think it’s possible without rebuilding/customizing LK.

I’m fine with customizing/rebuilding LK but since I’m new to it, I don’t have the immediate experience on what to modify first.

Although your suggestion to erase the boot and run it from memory is a good idea. I will try it tomorrow but I’m wondering if I may still see the issue since it looks like the bootloader doesn’t dump back to fastboot or boot normally… Still, worth a shot tomorrow. Thanks!

Hey,

So for kernel panics, the fix by ndec works! It drops me right back to LK and I can start a new session.

Now, it doesn’t solve my original problem where the board halts and doesn’t go into LK to start fastboot. I hit it again with the last couple of lines from the kernel serial output:

[ 438.720360] stmvl6180_power_up_i2c: Enter [ 438.721355] binder: 17204: binder_alloc_buf, no vma [ 438.722122] binder: 17204: binder_alloc_buf, no vma [ 438.724977] binder: 17204: binder_alloc_buf, no vma

Format: Log Type - Time(microsec) - Message - Optional Info
Log Type: B - Since Boot(Power On Reset), D - Delta, S - Statistic
S - QC_IMAGE_VERSION_STRING=BOOT.BF.3.0-00261
S - IMAGE_VARIANT_STRING=HAAAANAAA
S - OEM_IMAGE_VERSION_STRING=C-BPATTH
S - Boot Config, 0x000002e1
S - Core 0 Frequency, 0 MHz
B - 1545 - PBL, Start
B - 3490 - bootable_media_detect_entry, Start
B - 162681 - bootable_media_detect_success, Start
B - 162686 - elf_loader_entry, Start
B - 165788 - auth_hash_seg_entry, Start
B - 165998 - auth_hash_seg_exit, Start
B - 181488 - elf_segs_hash_verify_entry, Start
B - 240691 - PBL, End
B - 247202 - SBL1, Start
B - 310124 - pm_device_init, Start
D - 14762 - pm_device_init, Delta
B - 325465 - boot_flash_init, Start
D - 30 - boot_flash_init, Delta
B - 329461 - boot_config_data_table_init, Start
D - 31689 - boot_config_data_table_init, Delta - (0 Bytes)
B - 365725 - CDT version:3,Platform ID:24,Major ID:1,Minor ID:0,Subtype:0
B - 371947 - sbl1_ddr_set_params, Start
B - 375638 - cpr_init, Start
D - 30 - cpr_init, Delta
B - 381189 - Pre_DDR_clock_init, Start
D - 183 - Pre_DDR_clock_init, Delta
D - 0 - sbl1_ddr_set_params, Delta
B - 393755 - pm_driver_init, Start
D - 6832 - pm_driver_init, Delta
B - 409249 - clock_init, Start
D - 30 - clock_init, Delta

There’s no kernel panic and LK doesn’t start into fastboot. Instead, the device just locks up and does nothing until I power cycle it (then it goes right back to LK fastboot). I’m assuming this is the Qualcomm Watchdog but I can’t find any documentation about how to configure the watchdog.

Do you have any solution when the device hangs up ?

If I’m developing remotely on boards like this I tend to have an empty boot partition and a software controlled relay on the power supply.