There's a couple of ways to do this:
cat /proc/last_kmsg > /sdcard/last_kernel_message_log.txt
dmesg > /sdcard/kernel_boot_log.txt
- plug in the usb cable with the smart-phone switched off. Then issue the command
adb logcat
from your Windows cmd or Linux terminal, it will hang waiting for the device to come on-line, now power up the smart-phone. The logcat should start scrolling off then.
Since you expressed interest in figuring out how far one's phone gets in the boot stages before it crashes, those methods should help. The thing is you need to be pretty quick to grab the kernel's log (the first two methods shown above).
What I would do is this, on my Arch Linux box, two terminal windows, one for the adb logcat
, the other, to grab the log the minute logcat starts scrolling off!
Edit:
BE aware, there are differences with using adb
and fastboot
!
fastboot
works differently, it is only used for flashing images into specified partitions, and is more tied in with the boot-loader process, i.e, it can understand the boot-loader mechanism. It also requires that:
- under Windows, 'Administrator' privilege to execute it
- under Linux, 'root' privilege
The reason it requires it is because it bypasses certain input/output of the hardware, and thus, does not "talk" in adb
protocol, rather, it is to "talk" directly to the boot-loader. Something that cannot be done as a normal user. Here is the help for the usage of fastboot
.
$ sudo fastboot
usage: fastboot [ <option> ] <command>
commands:
update <filename> reflash device from update.zip
flashall flash boot + recovery + system
flash <partition> [ <filename> ] write a file to a flash partition
erase <partition> erase a flash partition
getvar <variable> display a bootloader variable
boot <kernel> [ <ramdisk> ] download and boot kernel
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
devices list all connected devices
continue continue with autoboot
reboot reboot device normally
reboot-bootloader reboot device into bootloader
help show this help message
options:
-w erase userdata and cache
-s <serial number> specify device serial number
-p <product> specify product name
-c <cmdline> override kernel commandline
-i <vendor id> specify a custom USB vendor id
-b <base_addr> specify a custom kernel base address
-n <page size> specify the nand page size. default: 2048
A well known-usage of fastboot
is for flashing for example, to flash a recovery image: sudo fastboot flash recovery recovery.img
, another is to directly flash a raw image, sudo fastboot flash system system.img
. For more of for the case of kernel development, using this fastboot boot new_kernel
, this temporarily downloads a new kernel and boot using that without touching the boot-loader's own boot.
There is also a limitation on the size of a raw image that requires to be flashed, when I say raw image, I am referring to a file that has a .img
extension, the image must not exceed 128Mb. (I found out this when developing ics4blade, after the build completed, the system.img was 162Mb, and I tried to flash it but fastboot refused! To circumvent the limitation, had to create a CWM flashable zip file to do that and get around it!)
Practice caution and ensure the partition is correct and double-check and double-check again, if necessary, walk away from the computer, take a break, come back again, and double-check again, this is where it can go horribly wrong, flash the wrong file into the wrong partition... well shrugs