kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

jm_maclaren
Posts: 13
Joined: Sun Nov 25, 2012 1:09 pm

kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

Postby jm_maclaren » Sun Dec 30, 2012 9:39 am

I have tried the following unsuccessfully
1. grabbed to kernel config from /proc/config.gz from a running alpha 0.3 build
2. used the tool chain from git clone git://github.com/DooMLoRD/android_prebu ... chains.git toolchains as referenced here viewtopic.php?f=66&t=835
3. grabbed the kernel source from the alpha 0.2 root file system
4. adjusted the .config to point to the initramfs.cpio in the alpha 0.3 or 0.2 root file system (they are the same) CONFIG_INITRAMFS_SOURCE="../../../root/initramfs.cpio"
5. did a make; make modules
6. in the arch/arm/boot directory ~/rkcrc -k Image image.flash. I got the rkcrc from split tools from here viewtopic.php?f=66&t=835.
7. copy the image .flash to my p and flash into the recovery partition

when I reboot the I see nothing on the screen and then it reboots into android. :x

I have been able to build modules successfully with this toolchain - I compiled the driver for the internal wireless just fine.

I note that is I do a "head" on the linux kernel that the file starts ANDROID! whereas the kernel created by rkcrc -k starts KRNL. Is this what is wrong or is it something else? Where can I find an appropriate rkcrc to make a recovery kernel if thats the issue. I tried modifying the rkcrc from here http://gitorious.org/rockchip-android/t ... er/rkcrc.c to add that longer header but no luck.


Thanks
James


OK some progress, I believe I need to build an image using the kernel I just made. I looks like I need mkbootfs (I'm trying to compile that now). The recovery image from alpha 03 has a ram disk and kernel so I guess I just swap out the kernel and rebuild with the same ramdisk.
Last edited by jm_maclaren on Mon Dec 31, 2012 4:12 pm, edited 2 times in total.

jm_maclaren
Posts: 13
Joined: Sun Nov 25, 2012 1:09 pm

Re: kernel compilation woes - advice needed

Postby jm_maclaren » Mon Dec 31, 2012 11:09 am

getting somewhat closer. I edited mkbootimg to allow for a page size of 0x4000, now I can split the linux image using split_bootimg.pl and then rebuild the image using

Code: Select all

mkbootimg --kernel  recovery-ok.img-kernel --ramdisk recovery-ok.img-ramdisk.gz --pagesize 16384 --base 0 --board "" --cmdline "" --kernel_offset 0x60408000 --ramdisk_offset 0x62000000 --tags_offset 0x60088000 --second_offset 0x60f00000 -o new


The image is almost binary equivalent to the original. except for the line at 0x240 which I believe is a sha signature. It gets generated by mkbootimg. Trying to boot from recovery with that flashed seems to put the stick into bootloader mode (at least its recoverable) but I would like help on this last piece. Does anyone know how to successfully create that recovery image and why are the offsets so large? They seem to be the same numbers as in the finless recovery file too.

jm_maclaren
Posts: 13
Joined: Sun Nov 25, 2012 1:09 pm

Re: kernel compilation woes - advice needed (SOLVED)

Postby jm_maclaren » Mon Dec 31, 2012 11:58 am

oldmkbootimg.c
solved it finally. I needed to use a different mkbootimg and one compiled with -lcrypto not the libaries provided by the android sdk. I have been able to pull apart the recovery image, rebuild it and then after flashing boot back into linux. Now to try my own kernel....
You do not have the required permissions to view the files attached to this post.
Last edited by jm_maclaren on Mon Dec 31, 2012 4:09 pm, edited 1 time in total.

ss808
Posts: 6
Joined: Sun Dec 02, 2012 8:41 pm

Re: kernel compilation woes - advice needed (SOLVED)

Postby ss808 » Mon Dec 31, 2012 3:07 pm

That is fantastic to hear that you cracked it, I too am facing the same issues - the MK808 boots into android instead of the Linux kernel, when commanded to boot from the recovery partition.

My original guess was that the rkcrc generated kernel image was meant for the kernel partition and not for the recovery partition. I too obtained the rkcrc tools from viewtopic.php?f=66&t=835

Could you please let me know the steps to convert the arch/arm/boot/Image into a MK808 compatible recovery.img?

thanks
Iyer

jm_maclaren
Posts: 13
Joined: Sun Nov 25, 2012 1:09 pm

Re: kernel compilation woes - advice needed (SOLVED)

Postby jm_maclaren » Mon Dec 31, 2012 4:07 pm

Here is how to do it. Build your kernel using the instructions here
http://www.armtvtech.com/armtvtechforum/viewtopic.php?f=66&t=835

Note I have found that you need to ensure that your .config initramfs configuration has no compression set otherwise I could not get the kernel to boot.

Code: Select all

CONFIG_INITRAMFS_SOURCE="../../../root/initramfs.cpio"
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
CONFIG_RD_GZIP=y
# CONFIG_RD_BZIP2 is not set
CONFIG_RD_LZMA=y
# CONFIG_RD_XZ is not set
# CONFIG_RD_LZO is not set
CONFIG_INITRAMFS_COMPRESSION_NONE=y
# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set
# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set


As a good first test grab the config file from the running alpha 0.3 kernel. Note the initramfs.cpio path in the config is wrong so edit that and make sure there is no compression set (see above code fragment). It is in root so for me it is ../../../root/initramfs.cpio . There is no diference between alpha-0.2 and alpha-0.3 initramfs.cpio files.
Then grab my modified mkbootimg from here
http://www.armtvtech.com/armtvtechforum/viewtopic.php?f=66&t=1132
compile it

Code: Select all

gcc oldmkbootimg.c -o oldmkbootimg -l crypto

copy oldmkbootimg to /usr/local/bin

use the split_bootimg.pl to get the ramdisk file referred to below
copy the zImage into a working directory and run it as

Code: Select all

oldmkbootimg --kernel zImage --ramdisk recovery-ok.img-ramdisk.gz --pagesize 16384 --base 0 --board "" --cmdline "" --kernel_offset 0x60408000 --ramdisk_offset 0x62000000 --tags_offset 0x60088000 --second_offset 0x60f00000 -o my_recovery.img

move my_recovery.img to your pc and call it recovery.img in the finless folder with all the images
then start the flashing tool uncheck ALL but recovery and hit flash rom

BIG FAT CAVEAT
I had problems with finless 1.6 - I can reboot to linux using the reboot tool to recovery BUT every reboot went back to linux and I had to use the pin trick to get back to bootloader and reflash. This does not seem to happen with finless 1.5a I have no idea why.
Last edited by jm_maclaren on Thu Jan 03, 2013 11:04 am, edited 1 time in total.

ss808
Posts: 6
Joined: Sun Dec 02, 2012 8:41 pm

Re: kernel compilation woes - advice needed (SOLVED)

Postby ss808 » Mon Dec 31, 2012 4:26 pm

jm_maclaren wrote:Here is how to do it. Build your kernel using the instructions here

use the split_bootimg.pl to get the ramdisk file referred to below
copy the zImage into a working directory and run it as



Thanks, James for the detailed instructions. What is the input to the split_bootimg.pl? Is it a previously working recovery.img posted earlier by AndrewDB, or the Finless recovery.img? :?

I can't wait to try out the instructions out as soon as I get to the MK808 device. Thanks!

Iyer

jm_maclaren
Posts: 13
Joined: Sun Nov 25, 2012 1:09 pm

Re: kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

Postby jm_maclaren » Mon Dec 31, 2012 5:10 pm

Its the ramdisk from the linux kernel for 0.3. It's just a blank file size 0x100000 gzipped as far as I can tell. Just run split on that image.

ss808
Posts: 6
Joined: Sun Dec 02, 2012 8:41 pm

Re: kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

Postby ss808 » Tue Jan 01, 2013 3:53 pm

I've done all the steps listed out -- when I reboot to recovery, I only see two penguins - and no scrolling dmesg messages. I'm using the initramfs.cpio from the 0.2 kernel.

I've used the split_bootimg.pl to split AndrewDB's recovery.img and then rebuilt this recovery.img with your oldmkbootimg and I can confirm that this rebuilt recovery.img boots all the way to the prompt

Is there any step that I'm missing -- possibly in the initramfs composition?

jm_maclaren
Posts: 13
Joined: Sun Nov 25, 2012 1:09 pm

Re: kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

Postby jm_maclaren » Tue Jan 01, 2013 6:27 pm

To be clear
1. can you boot to linux if you flash the alpha-0.3 kernel from http://www.slatedroid.com/topic/41654-p ... imito-mx1/
2. If yes, can you split that image and then rebuild using my patched tools AND run a diff to see of the binary files are the same?


If 1 and 2 are ok then I am assuming your new kernel didn't build right. What I found is that if I took the config from a running alpha-0.3 and then adjusted the path for the initramfs.cpio wen ahead and compiled that the kernel was identical to the one I had split off the alpha-0.3. That would be something to test.

If the image you rebuilt in 2 is not the same as the original do a hexdump of each to a file and do a diff. The header is described in the split utility. From location 0x240 the next 10 bytes are the sha1 sum. That was what gave me problems with the original code. The first couple of lines after the first 8 bytes are sizes and offsets

ss808
Posts: 6
Joined: Sun Dec 02, 2012 8:41 pm

Re: kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

Postby ss808 » Wed Jan 02, 2013 3:37 am

jm_maclaren wrote:To be clear
1. can you boot to linux if you flash the alpha-0.3 kernel from http://www.slatedroid.com/topic/41654-p ... imito-mx1/
2. If yes, can you split that image and then rebuild using my patched tools AND run a diff to see of the binary files are the same?


Absolutely, I can boot to linux with the alpha-0.3 kernel from the slatedroid pre-alpha-03 thread. The diff, when run on the split image files and your patch tool shows no differences.

jm_maclaren wrote:If 1 and 2 are ok then I am assuming your new kernel didn't build right. What I found is that if I took the config from a running alpha-0.3 and then adjusted the path for the initramfs.cpio wen ahead and compiled that the kernel was identical to the one I had split off the alpha-0.3. That would be something to test.


I used the same config from the running alpha-0.3, with path adjusted for the initramfs.cpio

I built the kernel with both the Linaro and the arm-eabi toolchain, as recommended in viewtopic.php?f=66&t=835. Did you use a different toolchain? Also, did you run rkcrc on the zImage?

jm_maclaren wrote:If the image you rebuilt in 2 is not the same as the original do a hexdump of each to a file and do a diff. The header is described in the split utility. From location 0x240 the next 10 bytes are the sha1 sum. That was what gave me problems with the original code. The first couple of lines after the first 8 bytes are sizes and offsets


The rebuilt image is not same as the original. It shows differences in the 9th, 10th, 11th, 17th,18th, 19th , 61st, 62nd, 257th bytes on wards in a number of locations.

It could be due to a different toolchain, though I've tried compiling executables using the toolchains listed on viewtopic.php?f=66&t=835 which work well, when run on the MK808.

ss808
Posts: 6
Joined: Sun Dec 02, 2012 8:41 pm

Re: kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

Postby ss808 » Thu Jan 03, 2013 4:14 am

Thanks much for your help, James. The CONFIG_INITRAMFS_COMPRESSION_NONE was set to y per your suggestions and CONFIG_DECOMPRESS_LZMA, CONFIG_RD_LZMA were unset in the .config file. The kernel now boots all the way to the prompt. :D

jps
Posts: 36
Joined: Wed Mar 13, 2013 3:27 pm

Re: kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

Postby jps » Wed Mar 13, 2013 6:01 pm

A lot of thanks!!! I have the exactly same problem that u. Now i am getting my linux kernel customing for Minix neo X5!!!!!! HOOOOOOOOOOOOOOOOOOOOOOOOOOOAAAH!!!

woodpecker
Posts: 2
Joined: Thu Mar 28, 2013 10:39 am

Re: kernel compilation woes - SOLVED & WITH INSTRUCTIONS)

Postby woodpecker » Thu Mar 28, 2013 5:33 pm

Hi folks,

I am stuck trying to get a new compiled kernel working on my MK808, if I flash the current working recovery.img back it fires back up ok but my kernel does nothing.

I've compiled the kernel using the info here:-

viewtopic.php?f=66&t=835

My .config file has this for initramfs:-

CONFIG_INITRAMFS_SOURCE=""

Do I need to change this? If so how do I find what it should be?

When I get to this step:-

"use the split_bootimg.pl to get the ramdisk file referred to below
copy the zImage into a working directory and run it as"

I am doing:-

./split_bootimg.pl zImage

But I get an error - Android Magic not found in Image. Giving up.

Please help..


Return to “Development”

Who is online

Users browsing this forum: No registered users and 3 guests