Since last time I had kernel source code repository and initramfs used in stock kernel and I thought that the way to boot will be easy. Unfortunatelly there are several facts I needed to accept and tasks I needed to do. This will give you idea what have I done in the meantime:
- to be able to flash or boot kernel I needed to unlock bootloader -
Sony is respectable that it offers way to unlock your bootloader
(with loosing or reducing warranty though)
- if you want to be able to re-lock your bootloader, you need to backup your TA partition, before unlocking (you'll need root for that)
-
unlocking doesn't work well before latest Sony update (you'll loose some functionality when unlocking on 4.1)
-
updating to lastest Sony firmware will remove your root access
- the only way I found is slightly crazy, but works.
-
updating to lastest Sony firmware will remove your root access
At the end of this saga, I was running Sony's Android 4.3 with root access and I could start playing with fastboot's boot command. After plethora of unsuccessful attempts I get to know that it is crippled in Sony's bootloader and won't work - that was dead end for me. Flashing kernel using fastboot protocol worked but my experimental kernel didn't boot. Furthermore experimenting with kernel builds and flashing each of them would kill my flash memory very soon.
I left Sony's stock firmware and installed Cyanogenmod 10.2 which
works quite nice. I was able to build identical kernel by myself and could play further. I
tried to enable kexec()
support in kernel but as you probably expect,
it didn't started the kernel correctly so this was also dead end for now.
People from FreeXperia community gave a lot of useful information about almost everything (i.e. proper location of boot kernel and meaning of other partition) and told me also about Little Kernel bootloader. Lilstevie even made port to Xperia Tablet Z already.
I need to have device initialized during boot before loading kernel and that is the job for Sony's bootloader. In LK bootloader scenario Sony's bootloader loads Little Kernel instead of Linux Kernel so Little Kernel doesn't have to care about HW initialization and can only load and run kernel. FreeXperia community used this method to have two separated images with kernels and initial ramdisk instead of one kernel+initrd which can behave both as normal boot or recovery. In this setup you don't have to worry about flashing wrong kernel anymore as it will be fixable even without computer access.
LK was already prepared so I could only grab binaries and flash it, with some minor differences - I used actual version of TeamWin recovery project, and Cyangenmod's boot.img. It worked nicely but only after applying this kernel patch I could use `adb reboot recovery' to get to recovery. Besides Little Kernel usefulness it has also one nice feature - it supports fastboot protocol as well and it's boot command implementation even works!
I spent some time on building my own LK binary (which seems to be very
sensitive to toolchain used) to be able to hack it as well. There is
currently missing screen support or led support for Xperia Tablet
Z sp it is hard to say when you enter or leave LK. I indicate that Little
Kernel is up and ready by polling using `watch -n 0 fastboot devices
'.
After entering LK you have ~5 seconds to press VolDown button to
listen for fastboot interface.
And before end one less serious note. When I have seen logo.rle file in initrd image, I couldn't resist to play with that a bit. When you think Sony logo during boot is not nice anymore or when do you want to make it a bit more personal. You'll need installed ImageMagick, to565 (i.e. this), from565 (could be found here and ability to repack initrd image. To convert logo to some more sane format use:
$ ./from565 -rle < /Devel/xperia/logo.rle > logo.raw $ convert -depth 8 -size 1920x1080 rgb:logo.raw logo.pngTo convert sane format to the one used in initrd:
$ convert -depth 8 logo.png rgb:logo.raw $ ./to565 -rle < logo.raw > logo.rleDon't forget that initrd image is gzipped cpio archive of exact format:
$ cd initrd-unpacked $ cp new-logo.rle logo.rle $ find | cpio -o -H newc | gzip -9 > ../new-initrd.imgIt seems that you can easily meet initrd size limit so don't use too complicated pictures.
That's all for today. After my second blog entry on this topic I can finally boot my own kernel (which currently panics) and have some initial terribly broken framebuffer console to even see the panic! Now I can focus on kernel itself.