Related
First I would like to thank boog for all his help to get me to this point, but I'm stuck with an error.
I've been dipping my foot into the kernel unpacking and repacking waters. I'm currently using the attached two scripts boog sent me for unpacking and repacking as well as these toolchains, but this is what my output looks like after unpacking and then attempting to repack the stock I897UCKI2 kernel:
Code:
##### My name is ./repacker.sh #####
##### The source kernel is /media/C70D-E87A/Captivate/Kernels/I897UCKI2/zImage #####
##### The destination zImage file is /media/C70D-E87A/Captivate/Kernels/I897UCKI2/repacked/zImage #####
##### The directory of the initramfs has been selected #####
##### The initramfs is /media/C70D-E87A/Captivate/Kernels/I897UCKI2/initramfs_root (will be gzipped) #####
5970 blocks
##### 01. Extracting kernel from /media/C70D-E87A/Captivate/Kernels/I897UCKI2/zImage (start = 16541) to ./out/Image
321+1 records in
321+1 records out
5310899 bytes (5.3 MB) copied, 0.540424 s, 9.8 MB/s
gzip: stdin: decompression OK, trailing garbage ignored
##### 02. The size of the new initramfs is = 1851649 / original = 3056568
##### 03. The size of the Image is 13428224
##### 04. Making a head.img ( from 0 ~ 143360 )
1+0 records in
1+0 records out
143360 bytes (143 kB) copied, 0.000480648 s, 298 MB/s
##### 05. Making a tail.img ( from 3199928 ~ 13428224 )
3+1 records in
3+1 records out
10228296 bytes (10 MB) copied, 0.0784701 s, 130 MB/s
##### 06. Merging head + initramfs
##### 07. Checking the size of [head+initramfs]
##### 08. Merging [head+initramfs] + padding + tail
1+0 records in
1+0 records out
1204919 bytes (1.2 MB) copied, 0.0129411 s, 93.1 MB/s
#==========================================
##### Now we are rebuilding the zImage #####
#==========================================
##### 09. Image ---> piggy.gz
##### 10. piggy.gz ---> piggy.o
##### 13. head.o + misc.o + piggy.o ---> vmlinux
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-ld: arch/arm/boot/compressed/vmlinux: Unknown mandatory EABI object attribute 44
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-ld: failed to merge target specific data of file arch/arm/boot/compressed/piggy.o
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-ld: arch/arm/boot/compressed/misc.o: Unknown mandatory EABI object attribute 44
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-ld: failed to merge target specific data of file arch/arm/boot/compressed/misc.o
##### 14. vmlinux ---> zImage
/opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-objcopy: 'arch/arm/boot/compressed/vmlinux': No such file
##### 15. Getting finished!!
cp: cannot stat `arch/arm/boot/zImage': No such file or directory
rm: cannot remove `arch/arm/boot/compressed/vmlinux': No such file or directory
rm: cannot remove `arch/arm/boot/zImage': No such file or directory
#==========================================
##### DONE!! #####
#==========================================
I ran the script like follows:
./repacker.sh -s /media/C70D-E87A/Captivate/Kernels/I897UCKI2/zImage -d /media/C70D-E87A/Captivate/Kernels/I897UCKI2/repacked/zImage -r /media/C70D-E87A/Captivate/Kernels/I897UCKI2/initramfs_root/ -c gzip
I've attempted to run the repack script normally and with sudo with the same output. Now I'm wanting to pick anyone's brain who will let me in why I'm having this issue.
I was able to compile a new zImage using these toolchains but I would be stuck in a kernel bootloop.
If you need or would like more info just let me know and I'll provide what I can.
Just thought I'd provide a little update and some more OS/hardware information.
I'm working off a laptop with a 1.6Ghz Intel Celeron M 380 and 1G of RAM running Kubuntu 11.04.
I read somewhere that some people have had issues with getting the repacking to work on 11.04 so I'm thinking about downgrading back to 10.04 or whatever is the LTS version is.
I did move the kernel to ~/Kernels/I897UCKI2/ to see if it being on the FATwhatever Flash drive was causing the issue or not with no luck.
Glad to see you put your knowledge to work Patience and u'll get it done, although it would be nice if someone would give u a hand on this. I would gladly do so if I only had the knowledge
gl
fuloplori said:
Glad to see you put your knowledge to work Patience and u'll get it done, although it would be nice if someone would give u a hand on this. I would gladly do so if I only had the knowledge
gl
Click to expand...
Click to collapse
This mostly came from boog's knowledge that he shared with me. I'm still trying out a few things, but so far I'm still stuck. Just burnt me a Ubuntu 11.04 disk that I'm going to try to boot Live from and see if I can't do it from there on my main/gaming PC.
If that doesn't work I'm going to use boog's kernel as a the base for the script mtcarey used to modify boog's kernel with and just replace the initramfs from it with the one I put together. The scripts wouldn't unpack any other kernel but boog's and require more then what the other unpack scripts unpack to repack. Doesn't look like it uses the toolchains though (seeing as I didn't have them installed at the time I used it to unpack boog's kernel).
U'd prolly came across this already, but thought I'd share what I've bumped into http://forum.xda-developers.com/showthread.php?p=15318639
While I didn't see that, I'm pretty sure those are the same (or almost the same) scripts I'm using. Thanks for the tutorial though.
I would like to unpack a kernel so I can change the boot animation of it and then repack it.
Is that hard to do?
whipps said:
I would like to unpack a kernel so I can change the boot animation of it and then repack it.
Is that hard to do?
Click to expand...
Click to collapse
boot animation is not in the kernel....
Pirateghost said:
boot animation is not in the kernel....
Click to expand...
Click to collapse
Sorry. I mean the black screen with the Samsung SGH-i897.
kernel is DarkCore
whipps said:
Sorry. I mean the black screen with the Samsung SGH-i897.
kernel is DarkCore
Click to expand...
Click to collapse
That requires the kernel source. Cannot be changed in the initramfs which is all that is unpacked.
Sent from my SAMSUNG-SGH-I897 using XDA App
Go to ficeto's git hub for the source.
It should still be there,
we use a custom kernel splash for darkcore in mosaic.
studacris said:
Go to ficeto's git hub for the source.
It should still be there,
we use a custom kernel splash for darkcore in mosaic.
Click to expand...
Click to collapse
Thanks for the info.
This is where I went, https://github.com/ficeto, but I'm not sure what I'm looking for.
whipps said:
Thanks for the info.
This is where I went, https://github.com/ficeto, but I'm not sure what I'm looking for.
Click to expand...
Click to collapse
I believe the bottom two from the following url are the ones you want I believe.
https://github.com/DarkyROM/
Kyuta Syuko said:
I believe the bottom two from the following url are the ones you want I believe.
https://github.com/DarkyROM/
Click to expand...
Click to collapse
That looks like what I need, but I hate to say I'm not that advanced to try unpacking a kernel on my phone just to change the boot image.
I guess I will just deal with it.
I've seen you haven't been able to unpack the boot images so I investigated a bit on this "weird format" Moto used. This is what I could figure out by looking at the image and the bootstub code Motorola released:
Code:
0x00000000 kernel CMDLINE, filled with zeroes where unused
0x00000400 bzImage size
0x00000404 initrd size
0x00000408 SPI UART suppression
0x0000040B SPI type (0: SPI0, 1: SPI1)
0x00001000 future stack for bootstub (?)
0x00002000 actual bzImage start
On the boot image I grabbed from the root post, using the awesome "hexdump" tool we can see at 0x400
Code:
60 a8 46 00 90 6c 1a 00
Which means (remember x86 is Little Endian) bzImage size 0x0046A860 (~4.5MB) and initrd size of 0x001A6C90 (~1.65MB)
So let's go to the practical side:
0x00002000 + 0x0046A860 = 4638816
Code:
$ dd if=razr_i_boot.img of=ramdisk.cpio skip=4638816 bs=1
$ zcat ramdisk.cpio|cpio -i
gzip: ramdisk.cpio: decompression OK, trailing garbage ignored
8927 blocks
$ ls
android.fstab dev init.moto.usb.rc init.sc1.rc init.wifi.rc ramdisk.cpio system ueventd.smi.rc
charger init init.moto.usb.sh init.sdcard1.rc init.xmm.rc res ueventd.goldfish.rc xbin
data init.goldfish.rc init.nfs.rc init.sdcard2.rc lib sbin ueventd.rc
default.prop init.moto.rc init.rc init.sdcard.rc proc sys ueventd.sc1.rc
Code:
$ dd if=razr_i_boot.img of=bzImage skip=8192 count=4630624 bs=1
$ file bzImage
bzImage: Linux kernel x86 boot executable bzImage, version 3.0.8-g229e199 ([email protected]) #1 SMP PREEMPT Sat Sep, RO-rootFS, root_dev 0x806, swap_dev 0x4, Normal VGA
Ta-da! Unpacked. It wasn't that hard really
Now, is there interest on a tool to repack/unpack these images? I don't own the phone (and probably won't, no $$ ) but if there's enough interest I can make one, it should be relatively easy.
EDIT: Okay, so I wrote a pair of tools to unpack existing images and package new images, you can get them at
https://github.com/turl/razr-i-boot-tools
Just run "make" to build the tools, the usage is really simple
Code:
$ ./pack
Usage: ./pack <valid image> <bzImage> <ramdisk> <output>
From left to right, an already existing boot image (to copy bootstub from, it could be built from source on the future), the kernel, the gzipped cpio ramdisk and the output filename
Code:
$ ./unpack
Usage: ./unpack <image to unpack> <bzImage out> <ramdisk out>
From left to right, the image you want to unpack, and the destination files for bzImage and ramdisk. You can then unpack the ramdisk with something like
Code:
$ mkdir ramdisk-unpack
$ cd ramdisk-unpack
$ zcat ../ramdisk.cpio.gz|cpio -i
And then repack it with something like
Code:
$ find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
turl1 said:
Ta-da! Unpacked. It wasn't that hard really
Now, is there interest on a tool to repack/unpack these images? I don't own the phone (and probably won't, no $$ ) but if there's enough interest I can make one, it should be relatively easy.
Click to expand...
Click to collapse
Making it look so simple
I really appreciate you taking the time to look at this, especially since you don't even have the device. I definitely have interest in a tool if at all possible. I'd donate and encourage others to as well
I agree with everything he said. Awesome job
Okay, so I wrote a tool to package images, check the edit on the first post and let me know how it works. I'll make another one to unpack current images when I get some more time
turl1 said:
Okay, so I wrote a tool to package images, check the edit on the first post and let me know how it works. I'll make another one to unpack current images when I get some more time
Click to expand...
Click to collapse
Been working all day yesterday to get up and running on Linux again, time to redouble my efforts and try a new distro so I can get packin'!
EDIT:Got everything set up besides ramdisk I believe. First attempt is progress, instead of error booting into fastboot it sticks on the boot logo, then reboots and loops that. I'm pretty sure its because I did ramdisk wrong but we'll see if anyone else can get it further.
File includes ramdisk folder, boot.img, and my compiled bzImage. http://d-h.st/Cyn
mattlgroff said:
Been working all day yesterday to get up and running on Linux again, time to redouble my efforts and try a new distro so I can get packin'!
EDIT:Got everything set up besides ramdisk I believe. First attempt is progress, instead of error booting into fastboot it sticks on the boot logo, then reboots and loops that. I'm pretty sure its because I did ramdisk wrong but we'll see if anyone else can get it further.
File includes ramdisk folder, boot.img, and my compiled bzImage. http://d-h.st/Cyn
Click to expand...
Click to collapse
What did you use to repackage the ramdisk? Something like this should work
Code:
$ cd ramdisk
$ find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
Then use the generated 'newramdisk.cpio.gz' when calling pack; something like
Code:
$ ./pack boot.img bzImage newramdisk.cpio.gz newboot.img
turl1 said:
What did you use to repackage the ramdisk? Something like this should work
Code:
$ cd ramdisk
$ find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
Then use the generated 'newramdisk.cpio.gz' when calling pack; something like
Code:
$ ./pack boot.img bzImage newramdisk.cpio.gz newboot.img
Click to expand...
Click to collapse
Getting a 4.6 MB boot.img with this, trying to boot now.
mattlgroff said:
Getting a 4.6 MB boot.img with this, trying to boot now.
Click to expand...
Click to collapse
Yes, a smaller boot.img is to be expected, the dumped one you guys got has garbage on its tail
turl1 said:
Yes, a smaller boot.img is to be expected, the dumped one you guys got has garbage on its tail
Click to expand...
Click to collapse
Same bootloop issue, looping the bootlogo and phone reboots
Well, it turns out I fail when programming on the late AM
https://github.com/turl/razr-i-boot-tools/commit/34f618b5cb2d6fb4b4c7d8affb194113a0b11270
Update/reclone your tools repo, rebuild it and try again. Rebuild your ramdisk image too, just in case the tool corrupted it.
turl1 said:
Well, it turns out I fail when programming on the late AM
https://github.com/turl/razr-i-boot-tools/commit/34f618b5cb2d6fb4b4c7d8affb194113a0b11270
Update/reclone your tools repo, rebuild it and try again. Rebuild your ramdisk image too, just in case the tool corrupted it.
Click to expand...
Click to collapse
Updated tools, rebuilt tools, rebuilt ramdisk....
6.5 MB newboot.img now.
Boot animation....
Booted!
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Where's your donation link?
mattlgroff said:
Updated tools, rebuilt tools, rebuilt ramdisk....
6.5 MB newboot.img now.
Boot animation....
Booted!
[image]
Where's your donation link?
Click to expand...
Click to collapse
Awesome! I just wrote the unpack tool by the way, same repo. Check the first post for more info and let me know if you have any issues with it.
I also completed the "donate to me" box on the XDA profile for those looking for it
turl1 said:
Awesome! I just wrote the unpack tool by the way, same repo. Check the first post for more info and let me know if you have any issues with it.
I also completed the "donate to me" box on the XDA profile for those looking for it
Click to expand...
Click to collapse
OMG, I sure won't make use of it but I know how important it is to build Custom Recovery and Custom Roms sooo I'll make a donate soon as I can.
Make boot.img
Hi,
I can't manage to make the boot.img with my compiled kernel for Razr I. Anyone can make the boot.img for me please :victory:
Thank you
"Direct booting from floppy is no longer supported...Please use a boot loader program instead...Remove disk and press any key to reboot..."
WTF?!
open your bzImage with a hex editor, the first lines
Hai mattlgroff, I have switch from your homemade 40002 to 31006 with RST & then OTA auto update to 40002 & then do root & CWM but now the kernel version is older (Sept 2012), so can i copy the recovery.signed in 31006 & change the file name to recovery.img & put into the CWM folder & ADB/Fastboot.
Can i have this better matt-desktop #1 too.Thks.
Daniel 9999 said:
Hai mattlgroff, I have switch from your homemade 40002 to 31006 with RST & then OTA auto update to 40002 & then do root & CWM but now the kernel version is older (Sept 2012), so can i copy the recovery.signed in 31006 & change the file name to recovery.img & put into the CWM folder & ADB/Fastboot.
Can i have this better matt-desktop #1 too.Thks.
Click to expand...
Click to collapse
Its not better, worse actually because things are broken.
Sent from my MB886 using Tapatalk 2
mattlgroff said:
Its not better, worse actually because things are broken.
Sent from my MB886 using Tapatalk 2
Click to expand...
Click to collapse
However,thanks Mattlgroff, For you & all info.,I take your 40002 boot.img & Fastboot flash boot boot.img after RSDlite 31006 & got back the newest Nov,2 kernel. It really run very smooth & fast ( I overwrite your ADB file to a newer ADB from android-sdk folder as dont know why ADB devices cant read/see).Cheers.
mat have you got this to complied because iv only got cgywin or could you build my boot.img to unlink data/media
http://batakang.com/ftp/incoming/boot.img
Having some troubles with this Jellybean boot.img. Anyone want to take a stab at it?
environment: ubuntu 10.04 LTS 64bit
get some package
sudo apt-get install gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc
install git
first install some packages that git depends on:
sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
get the new git source code from http://code.google.com/p/git-core/downloads/list.
download git-1.8.0.tar.gz
tar -xvf git-1.8.0.tar.gz
cd git-1.8.0
./configure
make
sudo make install
this will install git to /usr/local/bin/
get the kernel source code:
mkdir -p ~/android/kernel
cd ~/android/kernel
git clone https://android.googlesource.com/kernel/msm
check which version of kernel to checkout
mkdir ~/work/android/nexus4-kernel
cd ~/work/android/nexus4-kernel
git clone https://android.googlesource.com/device/lge/mako-kernel
cd mako-kernel
git log kernel
get the commit rev, which is e039dcb (nov 25, 2012), this number seems to correspond to the latest commit revision in https://android.googlesource.com/kernel/msm/android-msm-mako-3.4-jb-mr1
check out the kernel
cd ~/android/kernel/kernel_msm
git checkout <commit version>
note: commit version is e039dcb, which is the result of the git log kernel command in the previous step
install google toolchain
mkdir ~/android/toolchain
cd ~/android/toolchain
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6
add “export PATH=$PATH:~/android/toolchain/arm-linux-androideabi-4.6/bin” to ~/.profile and run source ~/.profile
setup environment variables and build
cd ~/android/kernel/kernel_msm
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-linux-androideabi-
make mako_defconfig
make -j4
done
if you wanna thank me. go to google play and try out my app Wishlist :laugh:
https://play.google.com/store/apps/details?id=com.wish.wishlist
So with this I can make my own kernel for the Nexus 4? Hmm... will be nice to make one and get people to test it out for me lol.
I can edit the CPU, GPU, UV settings, etc? Is this only on Ubuntu or can it be done on Windows?
the kernel source is from google, but you can modify it as you wish. this is only for ubuntu. other linux environment will also work. but not windows.
You could change "make -j4" by "make -j$(grep -c ^processor /proc/cpuinfo)" ...
matt73300 said:
You could change "make -j4" by "make -j$(grep -c ^processor /proc/cpuinfo)" ...
Click to expand...
Click to collapse
that's handy to use.
But should the general rule of N in make -jN be twice the number of cpu core? for example, on my computer, I have two cores, so I use -j4.
yduck said:
that's handy to use.
But should the general rule of N in make -jN be twice the number of cpu core? for example, on my computer, I have two cores, so I use -j4.
Click to expand...
Click to collapse
Not really nice for lambda users. I think it's better when it written as I said (no need to know how many cores you have), or j# (and say replace # by 2xnumber_of_cores).
I have 8 cores on my computer, so I use j16 and it's much faster than j4, some people should know it
for some reason, the kernel I built cannot be booted.
when I did:
fastboot boot zImage
the phone stuck at the google logo.
any idea? I have seen other people in the forum built the kernel and booted it. there must be something wrong with the way I compiled the kernel, or the config is incorrect, or do I need to sign the kernel?
yduck said:
for some reason, the kernel I built cannot be booted.
when I did:
fastboot boot zImage
the phone stuck at the google logo.
any idea? I have seen other people in the forum built the kernel and booted it. there must be something wrong with the way I compiled the kernel, or the config is incorrect, or do I need to sign the kernel?
Click to expand...
Click to collapse
Is the zImage file the one found in "arch/arm/boot/zImage"? If so, then you can't use this directly in fastboot. You need to create a boot.img file.
Edit 2: You could possibly try this: " fastboot flash:raw boot <kernel> <ramdisk> ". I personally have not done, this. I created the boot.img file and flashed it.
Edit 3: Note that Edit 2 does perform a flash instead of boot, so be very wary of this. I recommend you create a boot.img file and use "fastboot boot boot.img" for testing --- it's safer that way.
dsana123 said:
Is the zImage file the one found in "arch/arm/boot/zImage"? If so, then you can't use this directly in fastboot. You need to create a boot.img file.
Edit 2: You could possibly try this: " fastboot flash:raw boot <kernel> <ramdisk> ". I personally have not done, this. I created the boot.img file and flashed it.
Edit 3: Note that Edit 2 does perform a flash instead of boot, so be very wary of this. I recommend you create a boot.img file and use "fastboot boot boot.img" for testing --- it's safer that way.
Click to expand...
Click to collapse
great suggestion. I just figured this out yesterday. as you said, fastboot boot does not work with just the zImage. it needs a boot.img.
so I created a newboot.img by packing my zImage and the ramdisk extracted from google's stock boot.img, and the newboot.img boots!
the command "fastboot flash:raw <kernel> <ramdisk>" seems simple to use. does it have an equivalent "fastboot boot: raw <kernel> <ramdisk"? so I don't need to worry about breaking my phone.
yduck said:
the command "fastboot flash:raw <kernel> <ramdisk>" seems simple to use. does it have an equivalent "fastboot boot: raw <kernel> <ramdisk"? so I don't need to worry about breaking my phone.
Click to expand...
Click to collapse
The fasboot.c source file at
https://android.googlesource.com/pl...8d27c72a03d56c1a36068a57f/fastboot/fastboot.c
indicates that there is no equivalent, although if you want to start modifying the fastboot.c code, it is probably easy enough to do so. Below is the relevant flash:raw code in fastboot.c:
} else if(!strcmp(*argv, "flash:raw")) {
char *pname = argv[1];
char *kname = argv[2];
char *rname = 0;
require(3);
if(argc > 3) {
rname = argv[3];
skip(4);
} else {
skip(3);
}
data = load_bootable_image(page_size, kname, rname, &sz, cmdline);
if (data == 0) die("cannot load bootable image");
fb_queue_flash(pname, data, sz);
Click to expand...
Click to collapse
From your post it sounds like you're using mkbootimg to create the boot image so you have what you need anyway (as long as you call mkbootimg with all the parameters corresponding to the boot header info from the boot image you extracted --- base offset, kernel offset, ramdisk offset, page offset, kernel command line , etc).
I've just added this guide to the Nexus 4 Complete Index
Sent from my GT-I9100 using xda premium
KidCarter93 said:
I've just added this guide to the Nexus 4 Complete Index
Sent from my GT-I9100 using xda premium
Click to expand...
Click to collapse
awesome! my post got into the index. I am so excited.:cyclops:
Thanks- although cdesai already made one
cdesai's thread here
yduck said:
great suggestion. I just figured this out yesterday. as you said, fastboot boot does not work with just the zImage. it needs a boot.img.
so I created a newboot.img by packing my zImage and the ramdisk extracted from google's stock boot.img, and the newboot.img boots!
the command "fastboot flash:raw <kernel> <ramdisk>" seems simple to use. does it have an equivalent "fastboot boot: raw <kernel> <ramdisk"? so I don't need to worry about breaking my phone.
Click to expand...
Click to collapse
I wonder if this is the correct way of making boot.img. I heard kernel image and ramdisk are related, if you modify and recompile the kernel and pack it with an old ramdisk, it may not boot. Is it true? what's the standard way of making boot.img? Is there a method to make our own ramdisk, instead of extracting it from google's stock boot.img?
yduck said:
setup environment variables and build
cd ~/android/kernel/kernel_msm
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-linux-androideabi-
make mako_defconfig
make -j4
Click to expand...
Click to collapse
Based in part on this documentation, I have created a HOWTO on building the system.img and boot.img files (for fastboot) with a single "make" call. Checkout: http://nosemaj.org/howto-build-android-nexus-4 .
Hi, I have two strange problems when trying to compile the mako kernel source. My setup:
Ubuntu 10.04, 64-bit (succesfully compiled a GB kernel for another device with this setup, using Google gcc 4.4.3 and Linaro gcc 4.6.2)
Kernel source from https://android.googlesource.com/kernel/msm, HEAD @ 7ce11cd - this is the android-msm-mako-3.4-jb-mr1.1 branch, wich should be identical to the kernel shipped with 4.2.2
Google gcc 4.6.x from https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6, also jb-mr1.1-release
No changes to the source, yet
There are two problems when compiling. First, there is this error
Code:
error: the frame size of XXXX bytes is larger than 1024 bytes
which is caused by 'CONFIG_FRAME_WARN=1024'. This value is not set in mako_defconfig, but seems to be the default for gcc 4.6 and is written to the .config when running make mako_defconfig. I am able to bypass this by setting 'CONFIG_FRAME_WARN=2048', but question is: Why do I need to? The stock kernel on my device running 4.2.2 has been compiled with 'CONFIG_FRAME_WARN=1024'.
The second problem are warnings of the type
Code:
warning: unwinding may not work because EXIDX input section XX of arch/arm/.../YYY.o is not in EXIDX output section
These can be suppressed by setting '# CONFIG_ARM_UNWIND is not set' and adding 'CONFIG_FRAME_POINTER=y'. But again, the stock kernel is compiled with 'CONFIG_ARM_UNWIND=y' and obviously, the Google guys didn't have this problem. What's wrong with my setup?
add “export PATH=$PATH:~/android/toolchain/arm-linux-androideabi-4.6/bin” to ~/.profile and run source ~/.profile
I can't figure out why but I keep getting a no command 'add' found
Sent From My Paranoid Nexus
atomilluminati said:
add “export PATH=$PATH:~/android/toolchain/arm-linux-androideabi-4.6/bin” to ~/.profile and run source ~/.profile
I can't figure out why but I keep getting a no command 'add' found
Sent From My Paranoid Nexus
Click to expand...
Click to collapse
Thanks for the response. The path to the compiler is defined in my kernel build script. Do I have to change it in my .profile, too?
XDA_Bam said:
Thanks for the response. The path to the compiler is defined in my kernel build script. Do I have to change it in my .profile, too?
Click to expand...
Click to collapse
Actually this was supposed to be a question...my bad... I keep getting to that line in the OP's instructions and can't get past it
Sent From My Paranoid Nexus
atomilluminati said:
Actually this was supposed to be a question...my bad... I keep getting to that line in the OP's instructions and can't get past it
Sent From My Paranoid Nexus
Click to expand...
Click to collapse
Hehe Okay, the answer is that you have to open the ~/.profile and manually add in a text editor the line given in the OP. The file should be in your profile folder (/home/your_user_name/). After this, save, close and run
Code:
source ~/.profile
in the terminal. That should do it, as far as I understood.
Hi All,
I am working on MotoX kernel(3.4.42) , after compilation of kernel source code i am able to generate zImage. I have written zImage to original boot.img using following command
$ abootimg -u boot.img -k zImage
with this boot.img(with custom zImage) I flashed using following command
$fastboot flash boot boot.img
After booting my MotoX phone , my touch screen is not responding. I observed touch screen I2c driver is not initilized because device tree image(dt.img) is not loading by zImage during booting .
Can any one please help how to create dt.img with compiled dtb files and flash in to device???????
Thanks
Ram
516
Any one any help???????
ram1443 said:
Any one any help???????
Click to expand...
Click to collapse
im really surprised you expected most people to know the answer to your question. anyways you can rip t he prebuilt dtb from you stock boot.img using these tools right here : https://github.com/xiaolu/mkbootimg_tools and then use them to repack your zimage. abootimg isnt useful in its current form it seems.
if you wish to compile the dts files into dtb ones youll need to run a script on them, here is teh guide that taught me how to http://www.wiki.xilinx.com/Build+Device+Tree+Blob
shabbypenguin said:
im really surprised you expected most people to know the answer to your question. anyways you can rip t he prebuilt dtb from you stock boot.img using these tools right here : https://github.com/xiaolu/mkbootimg_tools and then use them to repack your zimage. abootimg isnt useful in its current form it seems.
if you wish to compile the dts files into dtb ones youll need to run a script on them, here is teh guide that taught me how to http://www.wiki.xilinx.com/Build+Device+Tree+Blob
Click to expand...
Click to collapse
Hi shabbypenguin,
Thanks for your help,
Now i am able to boot with my custom zImage and default dt.img afeter following above links. but i am unable to generate custom dt.img from my compiled dtb files.
To generate dt.img i am doing below steps:
COMMAND:
-------------
$ ./dtbTool -s 2048 -o ./dt.img -p ../../source/kernel_kitkat/out/target/product/generic/obj/kernel/scripts/dtc/ ../../source/kernel_kitkat/out/target/product/generic/obj/kernel/arch/arm/boot/
OUTPUT :
-----------
Input directory: '../../source/kernel_kitkat/out/target/product/generic/obj/kernel/arch/arm/boot/'
Output file: 'dt.img'
Found file: msm8960ab-ultra-maxx-p1.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
Found file: msm8960ab-ultram-p3.dtb ... skip, failed to scan for 'qcom,msm-id = <' tag
=> Found 0 unique DTB(s)
Can you please guide me how to generate dt.img from compiled dtb files??
Thanks
Ram
Hi all,
I am trying to get an insecure kernel for Nexus 6, marshmallow 6.0, and I stuck at a bootloop.
The AOSP tag android-6.0.0_r1 builds without any errors. Then I flash the produced insecure boot image on a nexus 6, which had the latest 6.0 factory images.
Has anyone managed to do this procedure?
Btw, I am compiling the AOSP sources, and not the kernel sources.
In AOSP, I think, the kernel/zImage is precompiled, and the aosp build system bundles it into a boot image.
So, if someone has managed to build a working insecure boot.img from any marshmallow branch please let me know.
Or has done the same thing from kernels sources, also let me know.
EDIT:
How to compile an insecure kernel:
0. This will use the precompiled kernel found in aosp sources.
So we are not actually compiling. But this title might help some folks googling the topic.
2. modify device/<maker>/<codename>/fstab.<codename>/, and remove verify tag from system
3. make -jN bootimage
Alternatively, you can follow the procedure by ziddey, and removing the verify tag from fstab.shamu, allows the kernel to be booted!
NOTE: insecure kernel is not permissive.
How to compile a permissive kernel:
0. Now we will actually compile the kernel.
1. Download the kernel sources, and checkout the branch you want. Do these modifications.
Finally compile the kernel. (There are many tutorials for kernel compilation online)
2. copy the kernel (arch/arm/boot/zImage-dtb) to your aosp_dir/device/<maker>/<codename>-kernel/
3. Disable verification (as w/ insecure kernel)
4. make -j8 bootimage
How to compile an insecure and permissive kernel:
Not sure about this. I 'd play with configurations in aosp_dir/device/<maker>/<codename>,
or maybe try an eng build. If anyone knows just post it!
I have tried these with the kernel branch "android-msm-shamu-3.10-marshmallow-mr1",
and the aosp tag "android-6.0.1_r21".
I have also tried to unpack and repack the boot.img using unpackbootimg and mkbootimg from https://github.com/osm0sis/mkbootimg.
I have extracted ramdisk, edited the default prob, repacked ramdisk, and packed using:
Code:
mkbootimg --kernel su_boot.img-zImage --ramdisk su_boot.img-ramdisk.gz --cmdline 'console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=shamu msm_rtb.filter=0x37 ehci-hcd.park=3 utags.blkdev=/dev/block/platform/msm_sdcc.1/by-name/utags utags.backup=/dev/block/platform/msm_sdcc.1/by-name/utagsBackup coherent_pool=8M' --base 00000000 --pagesize 2048 --kernel_offset 00008000 --ramdisk_offset 02000000 --tags_offset 01e00000 --board "" -o ins_su_boot.img
Have I missed anything?
*EDIT* also tried w/ 'abootimg'. Still no luck.
Screwing around with random files found on the internet is not going to solve your problem. Use the program from *AOSP*. And make sure your parameters match (I'm not going to verify them for you). Bootloops are always cute, what did you change? Typically running make bootimg should make you a good bootimg from AOSP sources.
Well, turns out that in this case, that assumption is not correct.
The first issue is that the verity keys are not present in a custom built boot.img. At least not ones without also involving an entire system build (not that they would match the system partition that you already have).
So to solve that, edit the fstab file in the shamu device tree to remove the verify parameter from the system partition. Once that is done, it should no longer randomly reboot.
UNFORTUNATELY, that may not be enough to make the whole thing work properly still, since there appears to be some other differences between the AOSP userdebug's boot.img and the google user build. You will be able to adb in, but the android subsystem won't run.
These utilities I have used were the ones that have been successfully used to pack/unpack boot images by others. I have also done this successfully in the past, for another device running earlier versions.
Yeap. That's the problem. A kernel build from AOSP sources does not work out of the box with the rest of the system, if it is a production build. This used to work for Lollipop, but I guess they tighten security up.
Building zImage from kernel sources is still not a solution for me, as I can't properly pack/unpack a Marshmallow boot.img
The problem might be something very stupid, OS specific, and I don't want to waste any more time on this.
For now I will live with SuperSu and adbd insecure.
Maybe at some point I might try to remove the verification to see whether the rest of the stuff play nicely.
Thanks for your time!
[edit]
Answer is root. http://forum.xda-developers.com/showpost.php?p=64110288&postcount=1283
[/edit]
I spent a while tonight trying to figure this out as well. Simply dumping boot.img and recreating it works fine. But something goes wrong when unpacking/repacking the ramdisk. Stripping bootsize from bootimg.cfg so abootimg recalculates it doesn't help.
1. I did find that mkboot "works": https://github.com/ModdingMyMind/mkbootimg_tools
Simply run `mkboot boot.img boot` to dump to dir boot. Make changes to ramdisk, and then run `mkboot boot newboot.img` to create a new image. However, for whatever reason, this causes at least one issue for me. The sbin dir, despite being 755 in the ramdisk is 750 again in Android. Not sure what's going on here since I can redump newboot.img and confirm that sbin is 755.
2. I looked at seSuperuser/super-bootimg and found https://github.com/seSuperuser/super-bootimg/blob/master/scripts/bootimg.sh
The relevant part is in doneBootImgEdit(). Looking at the comments, Husson found that appending the changes to the inflated ramdisk cpio and then deflating it works. I just tested this and indeed it does work.
Husson only appends new/changed files; as a test, I tried appending the entire new ramdisk onto the old one, and sure enough, it bugs out again. Will have to investigate why this happening later, but for now, this is good enough.
As well, abootimg also comes with the tools abootimg-pack-initrd and aboot-unpack-initrd, which takes care of gzip/cpio. Of course, since the packing part doesn't work, we can't use it.
So, here's an example. Say you want to change fstab.shamu (to remove /system verification and/or /data forced encryption):
Code:
# extract boot.img
abootimg -x boot.img
# unpack the extracted initrd.img to ramdisk dir
abootimg-unpack-initrd
cd ramdisk
# make your changes to ramdisk/fstab.shamu here....
echo fstab.shamu | cpio -o -H newc > ../initrd2
cd ..
# inflate initrd.img
cp initrd.img initrd.gz
gunzip initrd.gz
# append and create new initrd.img
cat initrd initrd2 |gzip -9 -c > newinitrd.img
# strip bootsize from bootimg.cfg
sed 1d bootimg.cfg > newbootimg.cfg
# create new boot.img
abootimg --create newboot.img -f newbootimg.cfg -k zImage -r newinitrd.img
newboot.img should be a working boot image. If modifying multiple files, it may be easiest to create a different dir with those files and use find . |cpio -o -H newc > ../initrd2
Hope this helps. And if anyone can explain why this is necessary / how to recreate initrd from scratch, I can continue being lazy.
Thanks @phhusson
[edit]
Damn. I tried applying a different init file and it ate ****.
[/edit]
ziddey said:
I spent a while tonight trying to figure this out as well. Simply dumping boot.img and recreating it works fine. But something goes wrong when unpacking/repacking the ramdisk. Stripping bootsize from bootimg.cfg so abootimg recalculates it doesn't help.
1. I did find that mkboot "works": https://github.com/ModdingMyMind/mkbootimg_tools
Simply run `mkboot boot.img boot` to dump to dir boot. Make changes to ramdisk, and then run `mkboot boot newboot.img` to create a new image. However, for whatever reason, this causes at least one issue for me. The sbin dir, despite being 755 in the ramdisk is 750 again in Android. Not sure what's going on here since I can redump newboot.img and confirm that sbin is 755.
2. I looked at seSuperuser/super-bootimg and found https://github.com/seSuperuser/super-bootimg/blob/master/scripts/bootimg.sh
The relevant part is in doneBootImgEdit(). Looking at the comments, Husson found that appending the changes to the inflated ramdisk cpio and then deflating it works. I just tested this and indeed it does work.
Husson only appends new/changed files; as a test, I tried appending the entire new ramdisk onto the old one, and sure enough, it bugs out again. Will have to investigate why this happening later, but for now, this is good enough.
As well, abootimg also comes with the tools abootimg-pack-initrd and aboot-unpack-initrd, which takes care of gzip/cpio. Of course, since the packing part doesn't work, we can't use it.
So, here's an example. Say you want to change fstab.shamu (to remove /system verification and/or /data forced encryption):
Code:
# extract boot.img
abootimg -x boot.img
# unpack the extracted initrd.img to ramdisk dir
abootimg-unpack-initrd
cd ramdisk
# make your changes to ramdisk/fstab.shamu here....
echo fstab.shamu | cpio -o -H newc > ../initrd2
cd ..
# inflate initrd.img
cp initrd.img initrd.gz
gunzip initrd.gz
# append and create new initrd.img
cat initrd initrd2 |gzip -9 -c > newinitrd.img
# strip bootsize from bootimg.cfg
sed 1d bootimg.cfg > newbootimg.cfg
# create new boot.img
abootimg --create newboot.img -f newbootimg.cfg -k zImage -r newinitrd.img
newboot.img should be a working boot image. If modifying multiple files, it may be easiest to create a different dir with those files and use find . |cpio -o -H newc > ../initrd2
Hope this helps. And if anyone can explain why this is necessary / how to recreate initrd from scratch, I can continue being lazy.
Thanks @phhusson
[edit]
Damn. I tried applying a different init file and it ate ****.
[/edit]
Click to expand...
Click to collapse
My guess, and the reason why I tried appending without further thinking, is that the new initramfs files contains SELinux labels, which standard GNU/Linux cpio tool doesn't support.
One would have to investigate the changes in mkbootfs done recently.
Also, I guess mkboot is using Android's mkbootfs, which forces the permissions by itself I think.
Though the fact that extracting back give the result you expected is weird.
In super-bootimg I chose to change init.rc to chmod /sbin
Wow. http://forum.xda-developers.com/showpost.php?p=64110288&postcount=1283
Just tested and sure enough, everything is working.
Thanks @shoey63
Hopefully a final update:
The difference is in ownership. Unpacking (cpio -i) as a regular user will not preserve the ownership. However, repacking (cpio -o) does.
To repack, add -R 0.0 to cpio (i.e. --owner root.root).
e.g.
Code:
find . |cpio -o -H newc -R 0.0 | gzip -9 > ../newinitrd.img
I just tested and this works just fine without being root.
ziddey said:
Hopefully a final update:
The difference is in ownership. Unpacking (cpio -i) as a regular user will not preserve the ownership. However, repacking (cpio -o) does.
To repack, add -R 0.0 to cpio (i.e. --owner root.root).
e.g.
Code:
find . |cpio -o -H newc -R 0.0 | gzip -9 > ../newinitrd.img
I just tested and this works just fine without being root.
Click to expand...
Click to collapse
Erf that's weird, I'm pretty sure I always ran the script as root...
Anyway, thanks for the info! I'll probably update my scripts with it
I just wanted to post that using root to extract the cpio file fixed the boot failure for me on my Nexus 9 with 6.0.1. You also need to use root to find the files and create the cpio file because some files are only accessible by root of course. I guess that should have been obvious (usually needed for /dev nodes) as @phhusson said, but this time I didn't do that until reading here.
To unpack the boot.img file I used: https://github.com/osm0sis/mkbootimg.git
To pack the boot.img file I used: https://android.googlesource.com/platform/system/core/+/master/mkbootimg
I'm not sure you need the official google packer, but I just happened to use when it worked.
EDIT: I needed to update boot.img and I tried it using the osm0sis packer and it worked.
Hey guys. Thanks for the replies!
I needed a permissive kernel this time, and I have played around with the sources and your recommendations and got it working. :good:
The post by ziddey might be the easiest way to make any kernel bootable, by disabling the verification from fstab.
(and uses just one packing/unpacking tool)
You can do the same thing from sources, again by modifying the fstab on aosp.
You can build an insecure kernel by using the pre-built kernel (is aosp),
or compile and then pack a permissive one.
This procedure wasn't working for me back then when I tried it (hence this thread). I am not sure if it was my fault or the initial marshmallow release had differences from the sources. More info on the first post.