Related
Guide for debian on the Tattoo
this will NOT delete your android system
if it damage your android i am not responsible to that ... but actually it cant harm your loved phone
you must get the terminal emulator and androidvnc
first you should download the image file from here http://rapidshare.com/files/161776007/debian-armel-750.img.bz2then download the installer package from the attached zip file
this is only for the fyodor ROM or a rom with ext2 modules
extract the image and the package to anywhere or your desktop
copy the installer package to /sdcard/kit and the image to there too
then type
Code:
cd /sdcard/kit
su
sh firstrun.sh
now your debian is installed
to launch it you just write:
Code:
su
debian
to exit the shell type
Code:
exit
now you can make a desktop (icewm confirmed WORKING) with this:
http://www.androidfanatic.com/community-forums.html?func=view&catid=9&id=1620#1620
then you can help me make debian run at / from here ...
cant get the unionfs module into systemhttp://www.saurik.com/id/10
I'm interested, please write a guide.
Holy, it's very interesting
Post a guide please
I have been waiting for this for ages. I will love you long time if you share with us how.
What is debian?
Let me know please.
It is a linux distro. http://www.debian.org/
Thanks man.
Waiting.....
me 2 waiting...
okay i make the guide maybe tomorrow i but it will be in this week
Waiting.
Lets develop debian on Tattoo...
I am loving this..
Re: Debian on the tattoo
ohh..
I don't have mega skill, but maybe we all developers can made it.
-------------------------------------
Sent from my HTC Tattoo
rly looking forward
Great idea!
I have been using Debian for AVR and MIPS for ages, maybe I can help in some way.
I guess/hope the radio interface are open so that Debian application can use, as soon as we made a good Window Manager UI and can get rid of the google's dam binding business ;-)
Re: Debian on the tattoo
I can help with graphics.
-------------------------------------
Sent from my HTC Tattoo
Holyachmed said:
Guide for debian on the Tattoo
this will NOT delete your android system
if it damage your android i am not responsible to that ... but actually it cant harm your loved phone
you must get the terminal emulator and androidvnc
first you should download the image file from here http://rapidshare.com/files/161776007/debian-armel-750.img.bz2then download the installer package from the attached zip file
this is only for the fyodor ROM or a rom with ext2 modules
extract the image and the package to anywhere or your desktop
copy the installer package to /sdcard/kit and the image to there too
then type
Code:
cd /sdcard/kit
su
sh firstrun.sh
now your debian is installed
to launch it you just write:
Code:
su
debian
to exit the shell type
Code:
exit
now you can make a desktop (icewm confirmed WORKING) with this:
http://www.androidfanatic.com/community-forums.html?func=view&catid=9&id=1620#1620
then you can help me make debian run at / from here ...
cant get the unionfs module into systemhttp://www.saurik.com/id/10
Click to expand...
Click to collapse
we can have the list of the things that are missing? so that we can work on it one by one..
Cheers!!
I cannot install it.
I get this error:
modprobe: chdir</system/modules>: No such file or directory
mkdir: cannot create directory '/data/local/bin' : file exists
Any help?
dancer_69 said:
I cannot install it.
I get this error:
modprobe: chdir</system/modules>: No such file or directory
mkdir: cannot create directory '/data/local/bin' : file exists
Any help?
Click to expand...
Click to collapse
try to:
adb shell
su (if u aren't root)
mkdir /system/modules
chmod 775 /system/modules
rm -rf /data/local/bin ( check the content of folder before delete..)
Cannot create /system/modules file exists, so I just chmod it.
I remove folder bin and the scipt run, but very fast print "on" and "#"(root symbol)
After that I tried to run the debian command and I get these errors:
mknod: /dev/loop2:file exists
mount: mounting /sdcard/kit/debian.img on /data/local/mnt failed: No such file or directory (but mnt folder exists)
mount: No such file or directory
mount: No such file or directory
mount: No such file or directory
rm failed for -f, No such file or directory
link failed File exists
EDIT:
After fresh installation of fyodor rom 5.31 version, happens again the above error.
Only this time I didn't get any messages when the firstrun.sh script ran.
Another reason why I shouldn't sell my HTC Tattoo...
Nice guide!
want to edit your boot.img?
included files in zip: mkbootimg (i compiled this file from android source), unpack-bootimg.pl, repack-bootimg.pl
i edited the repack script to compile the nexus s img correctly.
Code:
--base 0x30000000 --pagesize 4096
first dump original boot.img:
Code:
cat /dev/mtd/mtd2 > /sdcard/boot.img
then drag/drop to your linux box to edit file.
use unpack script:
Code:
./unpack-bootimg.pl boot.img
you will end up with 2 compressed files and 1 folder.
finished editing and want to repack boot.img, for example:
Code:
./repack-bootimg.pl <kernel> <ramdisk-directory> <outfile>
most info and scripts pulled from here: http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack,_Edit,_and_Re-Pack_Boot_Images, thanks to the original author.
test your new boot.img:
Code:
fastboot boot boot.img
Two things:
1. if you have any bad blocks in your boot partition, this method will fail to extract the boot.img (you need to skip bad blocks, but cat will just get an error)
2. you can replace just the kernel (leaving the ramdisk and parameters intact) using:
Code:
% fastboot flash zimage zImage
The bootloader will read-modify-write the boot partition, replacing the kernel only.
how would you skip bad blocks? i never thought of a phone as having bad blocks.
k0mpresd said:
i never thought of a phone as having bad blocks.
Click to expand...
Click to collapse
All flash devices can have bad blocks. But it usually isn't something the end user would notice, unless there are so many and something is wrong that you're losing drive space.
edit: more info here if your curious http://en.wikipedia.org/wiki/Flash_memory
hmm, very strange thing happening to me. I've only gotten my boot.img to compile and boot successfully once with this method, but now I can't seem to get it to compile? I keep getting errors of the file name or file type. I'm using the correct usage.. If I compile manually with mkbootimg on the cmd line it'll compile but it won't boot. Just bootloops at the Google splash..
Jroid try my Matr1x kernel and see what happens
Sent from my Nexus S using XDA App
The problem seems to be compiling the boot with the perl scripts, not the kernel itself.
Try manually:
Once unpacked do the boot.img-ramdisk.cpio.gz with the following command (moved to the ramdisk folder):
Code:
#sudo find . | cpio -o -H newc | gzip > ../<your boot name>.img-ramdisk.cpio.gz
Then cd ../
And repack:
Code:
#./mkbootimg --kernel <your boot name>.img-kernel.gz --ramdisk <your boot name>.img-ramdisk.cpio.gz --base 0x30000000 --pagesize 4096 -o boot.img
you can replace just the kernel (leaving the ramdisk and parameters intact) using:
Code:
% fastboot flash zimage zImage
The bootloader will read-modify-write the boot partition, replacing the kernel only.
Click to expand...
Click to collapse
It won't work on the Nexus S.
python08 said:
It won't work on the Nexus S.
Click to expand...
Click to collapse
exactly, i'd love to be able to do this for some testing but it doesn't allow me.
EDIT: yes it does. Swetland is right
Chamb' said:
Try manually:
Once unpacked do the boot.img-ramdisk.cpio.gz with the following command (moved to the ramdisk folder):
Code:
#sudo find . | cpio -o -H newc | gzip > ../<your boot name>.img-ramdisk.cpio.gz
Then cd ../
And repack:
Code:
#./mkbootimg --kernel <your boot name>.img-kernel.gz --ramdisk <your boot name>.img-ramdisk.cpio.gz --base 0x30000000 --pagesize 4096 -o boot.img
Click to expand...
Click to collapse
I've tied compiling a boot both manually (with cmdline) and with the perl scripts and have used a simple kernel.gz and ramdisk.cpio.gz for my file names.. doesn't really matter what I name it as long as it has the correct file format in this .gz and .cpio.gz right? the manual compile goes fine with base 0x30000000 and pagesize 4096
however, it does not boot and will bootloop at the Google splash
Used boot.img extracted from (what ROM ?) cat /dev/mtd/mtd2 ?
Is the phone start with this boot.img (unchanged) if you flash it by typing "fastboot flash..." ?
After that, just try to unpack and repack the boot.img without changes on ramdisk or kernel, if it works that means your changes suck (^^).
These commands (or perl scripts) work perfectly for me.
Lol I will try doing that. The boot.img I used is from stock 2.3.4, edited the ramdisk (specifically init.rc & init.herring.rc)
Like I said, first time I used the perl scripts I edited my ramdisk, threw in a netarchy kernel, it compiled fine and booted. Now if I use the perl script to repack with an aosp kernel, it gives me an error about file name and/or extension being wrong. Or complains it can't find mkbootimg when its there and executable. I'll re run it again and post errors
Sent from my Nexus S
he guys where is the boot image located? not the animation, the google logo at the start of the booting!
Sent from my Nexus S using XDA Premium App
ok so when I used the repack-bootimg.pl script, it kept giving me this error:
Code:
boot.img-kernel.gz Not a directory at ./repack-bootimg.pl line 13.
So I ran mkbootimg manually, without a cmdline comment as stated above. It compiled
and booted beautifully all stock with no init.rc or init.herring.rc edits.
however when I compile a boot.img coupled with a stock kernel and a modified ramdisk, I get a non-booting boot.img. One came out at 2.9 mb and the other at 5.6 mb neither boots using the same cmd that compiled the working boot. Must be my edits.. I literally only changed about 1 line in init.rc and another line in init.herring.rc that causing it not to boot.
By the way, I got some info on a stock boot.img using the unpackbootimg binary (not the perl script) and here's what it outputs:
Code:
#BOARD_KERNEL_CMDLINE console=ttyFIQ0 no_console_suspend
BOARD_KERNEL_BASE 30000000
BOARD_PAGE_SIZE 00001000
I enter that pagesize and it says it's not a valid value when I compile boot.img's
Borky_16 said:
he guys where is the boot image located? not the animation, the google logo at the start of the booting!
Sent from my Nexus S using XDA Premium App
Click to expand...
Click to collapse
part of the kernel
to change-https://github.com/morfic/Samsung-logo
ogdobber said:
part of the kernel
to change-https://github.com/morfic/Samsung-logo
Click to expand...
Click to collapse
yeah i know thanks for the link a helping source though!
Sent from my Nexus S using XDA Premium App
Sorry for the Control C Control V of it, but I just found this topic now..
I`m facing this problem when I try to unpack boot.img..
I have done it 2 days ago but dunno why, now I can`t..
Follows what is happening..
Code:
[email protected]:~/NS-bootwork$ ./unpack-bootimg.pl boot.img
Found a secondary file after the ramdisk image.
According to the spec (mkbootimg.h) this file can exist,
but this script is not designed to deal with this scenario.
The Kernel is built, as a zImage and the WLAN as a bmc3429.ko..
Just repeating, I have built this Kernel 2 days ago in the same way, without any problems, but now I`m struggling on the message after inputting ./unpack-bootimg.pl boot.img..
Dunno what else to try, I re-downloaded the unpack-bootimg.pl from 2 different sources, and still the same error..
Any ideas?
Many thanks..
P.S.: Ubuntu 11.04 x64..
EDIT
Well, I already solve it!
That is what I did..
As unpack-bootimg.pl was not working (don`t know why) I used split_bootimg.pl script, splitting the boot.img and created new ramdisk img..
Code:
./split_bootimg.pl boot.img
mkdir ramdisk
cd ramdisk
gzip -dc ../boot.img-ramdisk.gz | cpio -i
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
Then after just compiled the Kernel with
Code:
./mkbootimg --kernel zImage --ramdisk newramdisk.cpio.gz --base 0x30000000 --pagesize 4096 --cmdline _console_suspend=1 console=bull's -o newtestboot.img'no
Witches includes " --cmdline _console_suspend=1 console=bull's" to not break BT functionality, in the case of Nexus S..
I found the tools here work well: http://glandium.org/blog/?p=2214
...if you then use the code originally posted above:
Code:
sudo find . | cpio -o -H newc | gzip > ../<your boot name>.img-ramdisk.cpio.gz
./mkbootimg --kernel <your boot name>.img-kernel.gz --ramdisk <your boot name>.img-ramdisk.cpio.gz --base 0x30000000 --pagesize 4096 -o boot.img
Hi,
There seems to me to be the general idea that swapping kernels is just flashing a different boot.img, however, what seems to never be mentioned is that each boot.img has a unique ram disk or included set of files/folder structure. This ram disk was designed to work with a specific version of android and within that, a specific build of that version. The init.rc file could be totally different, there could be a different init compiled in, ro.secure could be 0 in default.prop, and so on.
When looking through some of the scripts out there, it is always flash boot.img, not extract the ramdisk and rebuilt boot.img first. This introduces a tad bit of randomness to the whole kernel swapping scenario.
This is an pseudo example of what I would do, if I had to swap kernels manually on the phone. I have attached the referenced phone compatible binaries. (I would normally do it from within linux on a PC)
With CWM running on your phone, start adb.
$ adb shell
# ~ cd /tmp
# /tmp dump_image /dev/block/mmcblk0p11 boot.img
# /tmp unpack boot.img
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk
# /tmp cp /sdcard/mynewkernel-zImage .
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk mynewkernel-zImage
# /tmp cat /proc/cmdline >cmdline.txt
# /tmp cat ./cmdline.txt
[email protected] [email protected] vmalloc=320M video=tegrafb console=null usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=mbr:1100:100:800,kpanic:2500:400:800 security=tomoyo mot_prod=1 androidboot.serialno=TA2xxxxxxx
# /tmp busybox vi cmdline.txt
# /tmp cat ./cmdline.txt
[email protected] [email protected] [email protected] vmalloc=320M video=tegrafb console=null usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=mbr:1100:100:800,kpanic:2500:400:800 security=tomoyo mot_prod=1 androidboot.serialno=TA2xxxxxxx
# /tmp mkbootimg --cmdline cmdline.txt --kernel mynewkernel-zImage --ramdisk boot.img-ramdisk.gz -o boot.img
# /tmp flash_image /dev/block/mmcblk0p11 boot.img
the bits in green if you wanted to fix the missing [email protected] in your cmdline if applicable.
Replace the general sequence in your CWM install scripts when all you want is to swap the kernel, not potentially change the boot sequence/flags as well.
Cheers!
hi
thanks for tutorial
but regarding this command :
Code:
/tmp cp /sdcard/mynewkernel-zImage
what is mynewkernel-zImage ?
Hazem62 said:
hi
thanks for tutorial
but regarding this command :
Code:
/tmp cp /sdcard/mynewkernel-zImage
what is mynewkernel-zImage ?
Click to expand...
Click to collapse
That would be whatever kernel image you wanted to replace your existing kernel with. As the ones around are in zip files with prepackaged boot.img files you would have to unzip and extract to get just the kernel part. Also, you would need any dependent libs copied over to /system/lib/[modules].
This is nothing really new, just not being done with the Atrix thus far.
Cheers!
How do I get boot.img-ramdisk from this step
NFHimself said:
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk
Click to expand...
Click to collapse
into boot.img-ramdisk.gz for mkbootimg? do I use the regular gzip?
NFHimself said:
# /tmp mkbootimg --cmdline cmdline.txt --kernel mynewkernel-zImage --ramdisk boot.img-ramdisk.gz -o boot.img
Click to expand...
Click to collapse
If I wanted to edit and change the partition table, could I use the same method to pull and edit the partition file since it also exists in the same directory as cmdline?
toyota86 said:
do I use the regular gzip?
Click to expand...
Click to collapse
Yes.
(deleted)
NFHimself said:
Hi,
There seems to me to be the general idea that swapping kernels is just flashing a different boot.img, however, what seems to never be mentioned is that each boot.img has a unique ram disk or included set of files/folder structure. This ram disk was designed to work with a specific version of android and within that, a specific build of that version. The init.rc file could be totally different, there could be a different init compiled in, ro.secure could be 0 in default.prop, and so on.
When looking through some of the scripts out there, it is always flash boot.img, not extract the ramdisk and rebuilt boot.img first. This introduces a tad bit of randomness to the whole kernel swapping scenario.
This is an pseudo example of what I would do, if I had to swap kernels manually on the phone. I have attached the referenced phone compatible binaries. (I would normally do it from within linux on a PC)
With CWM running on your phone, start adb.
$ adb shell
# ~ cd /tmp
# /tmp dump_image /dev/block/mmcblk0p11 boot.img
# /tmp unpack boot.img
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk
# /tmp cp /sdcard/mynewkernel-zImage .
# /tmp ls
boot.img boot.img-zImage boot.img-ramdisk mynewkernel-zImage
# /tmp cat /proc/cmdline >cmdline.txt
# /tmp cat ./cmdline.txt
[email protected] [email protected] vmalloc=320M video=tegrafb console=null usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=mbr:1100:100:800,kpanic:2500:400:800 security=tomoyo mot_prod=1 androidboot.serialno=TA2xxxxxxx
# /tmp busybox vi cmdline.txt
# /tmp cat ./cmdline.txt
[email protected] [email protected] [email protected] vmalloc=320M video=tegrafb console=null usbcore.old_scheme_first=1 tegraboot=sdmmc tegrapart=mbr:1100:100:800,kpanic:2500:400:800 security=tomoyo mot_prod=1 androidboot.serialno=TA2xxxxxxx
# /tmp mkbootimg --cmdline cmdline.txt --kernel mynewkernel-zImage --ramdisk boot.img-ramdisk.gz -o boot.img
# /tmp flash_image /dev/block/mmcblk0p11 boot.img
the bits in green if you wanted to fix the missing [email protected] in your cmdline if applicable.
Replace the general sequence in your CWM install scripts when all you want is to swap the kernel, not potentially change the boot sequence/flags as well.
Cheers!
Click to expand...
Click to collapse
can any1 tell me how to extract boot.img-zimage for adding more drivers
Ni5hant said:
can any1 tell me how to extract boot.img-zimage for adding more drivers
Click to expand...
Click to collapse
Basically, you can't.
New drivers are either built into the kernel when it is compiled. Or built as kernel modules using the same kernel source and same compiler as the main kernel. In both cases, you need to know all about compiling a kernel.
runekock said:
Basically, you can't.
New drivers are either built into the kernel when it is compiled. Or built as kernel modules using the same kernel source and same compiler as the main kernel. In both cases, you need to know all about compiling a kernel.
Click to expand...
Click to collapse
anyway ..i have an ARM kali 2.0 on my galaxy j7.. and i want to connect my TP-Link Tw722n wifi adapter to it....
"Dmesg | grep usb" shows the usb...bt i cant anything else with it..........any help would be appreciated
Ni5hant said:
anyway ..i have an ARM kali 2.0 on my galaxy j7.. and i want to connect my TP-Link Tw722n wifi adapter to it....
"Dmesg | grep usb" shows the usb...bt i cant anything else with it..........any help would be appreciated
Click to expand...
Click to collapse
If you are running Kali Linux on a Galaxy J7, then you are in entirely the wrong thread. This is about Android on Motorola Atrix. Try asking in a Kali Linux thread. Though I suspect the answer will be more or less the same -- that you need to learn how to compile a kernel to do anything.
runekock said:
If you are running Kali Linux on a Galaxy J7, then you are in entirely the wrong thread. This is about Android on Motorola Atrix. Try asking in a Kali Linux thread. Though I suspect the answer will be more or less the same -- that you need to learn how to compile a kernel to do anything.
Click to expand...
Click to collapse
Thnx for the answer buddy i have downloaded my kernel source and goind to recompile it...just looking for the right toolchain to download...anyways thnx for the replies
Ni5hant said:
Thnx for the answer buddy i have downloaded my kernel source and goind to recompile it...just looking for the right toolchain to download...anyways thnx for the replies
Click to expand...
Click to collapse
BTW, this may not only be a question of drivers. The userspace networking code also needs to setup the new network port.
runekock said:
BTW, this may not only be a question of drivers. The userspace networking code also needs to setup the new network port.
Click to expand...
Click to collapse
Nopp..i have to just enable aethros driver support with cfg80211 module..and after flash dat kernel next time i can use my usb wifi adapter...although at this kernel i cant use my inbuilt wifi adapter...anyways i have. Build my kernel have to just compile it...if it will be a success i will upload it...
There are a lot of people out there wondering how to build kernels. It sounds confusing and hard, but once you get the hang of it, it is actually quite easy. I got the jist of it in just a few practices. Now I give all of my information to you, in the simplest, most comprehensible and most noob friendly way I can. In this guide, I will be building the kernel for my phone, the Samsung Galaxy Victory 4G LTE. So make your adjustments where necessary.
What You Will Need:
A linux OS. I now use Ubuntu 14.04 Manjaro, and Manjaro or Arch are preferred. (Ubuntu is easiest)
Patience
(Optional) A boot.img for your device
Required files
Required Files:
Open terminal and paste the following (I assume you already have java and perl and all that jazz):
In Ubuntu/ Debian:
Code:
sudo apt-get install abootimg git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
For Arch/Manjaro, do
Code:
sudo pacman -S gcc git gnupg flex bison gperf sdl wxgtk squashfs-tools curl ncurses zlib schedtool perl-switch zip unzip libxslt python2-virtualenv bc
for 32 and 64 bit systems. For only 64 bit, add the following:
Code:
sudo pacman -S gcc-multilib lib32-zlib lib32-ncurses lib32-readline
Also, abootimg can be installed using
Code:
yaourt -S abootimg-git
For other distros, you may have to modify the command to get the required files, such as using yum
Also, make sure you have setup git and it is ready to go.
Setting Up Folders:
You are going to need a folder to build you kernel in. For this tutorial, I will use my setup: /home/nick/android/kernel/SPH-L300/Kernel. Kernel is the source directory that is made from the source zip and SPH-L300 I will also use a lot, which contains Kernel.
Downloading The Source:
Download the zip from http://opensource.samsung.com/ or from InsanelyCool's stock kernel source. Then I put it in the SPH-L300 folder. Afterwards, unzip it. You should have 2 files, Kernel.tar.gz and Platform.tar.gz. We are going to focus on Kernel.tar.gz, so unzip it. This will make the Kernel folder.
Now, in your terminal, cd to somewhere to keep your toolchains. I keep mine in ~/android/kernel.
Now type
Code:
git clone git://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains
for the toolchains I used. They should be put in the folder toolchains.
Modifying The Kernel:
Now is the time to modify the kernel. You can apply patches and change governors and frequencies etc here.
Applying a Patch:
The kernel version is 3.0.31. You can upgrade it using patches. Patches can be found here. You have to apply one patch at a time, which is why scripts come in handy when patching multiple times. I am going to show you how to upgrade to 3.0.33, since you can do that without error.
First, download patch-3.0.31-32.bz2 (or .gz) and download patch-3.0.32-33.bz2 (or .gz).
Extract both and move the extracted files into the Kernel source folder.
Cd to this folder in your terminal and type
Code:
patch -p1 < patch-3.0.31-32
. If you get something about
Code:
...assume -R? [n]
just press enter then press y then enter again.
Do the same steps for applying the other patch, just mod the command to work.
Building The Kernel:
Setting Up Environment:
In the Kernel source directory, open the file Makefile and press ctrl-f. Then enter CROSS_COMPILE, and look for CROSS_COMPILE = /xxxxx, where xxxxx is a directory. Change that directory to the toolchain of your choice. **Not all toolchains work!** For me, it would look like: CROSS_COMPILE = /home/nick/android/kernel/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi- for Linaro 4.6.2. Save the file and exit.
Make sure your terminal is in the Kernel source directory.
Kernel Name:
If you want to change the kernel name, in terminal type
Code:
KBUILD_BUILD_VERSION="ROM NAME"
then
Code:
export KBUILD_BUILD_VERSION
.
Compiling It:
Next, type
Code:
export ARCH=arm
into terminal.
Almost there. The next step is to type
Code:
make gogh_defconfig
into terminal.
If you added options such as governors, do
Code:
make menuconfig
to activate them.
Otherwise, type
Code:
make -jx
where x is the number of processes per core. I use
-j2 for a dual core cpu. This takes about 20-30 mins for me. A quad-core Intel cpu takes 4 mins if you use -j5. For Intel, it is the # of cores + 1.
Actually Putting The Kernel Together:
Now that it has built, assuming you have had no errors and the terminal finishes with
Code:
Kernel: arch/arm/boot/zImage is ready
you are ready to assemble the kernel. Cd to outside your Kernel source to the folder that contains it. For me that would be SPH-L300. You are going to need a working boot.img for this phone to speed up this process by a lot. Whether its stock, mine, or Insanelycool's, just paste it into the folder.
In terminal, type
Code:
abootimg -x boot.img
Then
Code:
mkdir initrd && cd initrd && zcat ../initrd.img | cpio -i
And finally
Code:
find . | cpio -o -H newc | gzip > ../initrd.img
This splits the boot.img, and puts the ramdisk in the initrd folder.
Now, navigate to (kernel source)/arch/arm/boot and copy the zImage to where you were before (the SPH-L300 folder for me). When you paste, override the pre-existing zImage.
If you would like to change the splash screen before the bootanimation, swap out initlogo.rle in the initrd folder with the image of you choice. It must be a rle image and must be named initlogo to work. I won't tell you how to convert png's to rle's cuz I am sure you know how to Google.
Now, we actually but the boot.img together. In terminal, type
Code:
cd ../ && abootimg --create boot.img -k zImage -r initrd.img && abootimg --create boot.img -f bootimg.cfg -k zImage -r initrd.img
and make sure you are in the initrd folder. If you get the error updated is too big for Boot Image, use this command:
Code:
cd ../ && abootimg --create boot.img -k zImage -r initrd.img && abootimg --create boot.img -f bootimg.cfg -k zImage -c "bootsize=xxxxxx" -r initrd.img
and replace the x's with the size the kernel wants to be. This will give you a new boot.img in the containing folder (SPH-L300 for me). Now just zip it up and tell the updater-script where to flash it and voila!, you just made you own kernel.
Feel free to ask any questions below.
I WOULD LIKE TO THANK ONE PERSON IN SPECIFIC, AND THAT IS INSANELYCOOL FOR TEACHING ME MOST OF THE STEPS HERE.
please help me a aint got a clue using ubuntu 15.10 withe kernel 4.3
Nick_73 said:
There are a lot of people out there wondering how to build kernels. It sounds confusing and hard, but once you get the hang of it, it is actually quite easy. I got the jist of it in just a few practices. Now I give all of my information to you, in the simplest, most comprehensible and most noob friendly way I can. In this guide, I will be building the kernel for my phone, the Samsung Galaxy Victory 4G LTE. So make your adjustments where necessary.
What You Will Need:
A linux OS. I now use Ubuntu 14.04 Manjaro, and Manjaro or Arch are preferred. (Ubuntu is easiest)
Patience
(Optional) A boot.img for your device
Required files
Required Files:
Open terminal and paste the following (I assume you already have java and perl and all that jazz):
In Ubuntu/ Debian:
Code:
sudo apt-get install abootimg git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
For Arch/Manjaro, do
Code:
sudo pacman -S gcc git gnupg flex bison gperf sdl wxgtk squashfs-tools curl ncurses zlib schedtool perl-switch zip unzip libxslt python2-virtualenv bc
for 32 and 64 bit systems. For only 64 bit, add the following:
Code:
sudo pacman -S gcc-multilib lib32-zlib lib32-ncurses lib32-readline
Also, abootimg can be installed using
Code:
yaourt -S abootimg-git
For other distros, you may have to modify the command to get the required files, such as using yum
Also, make sure you have setup git and it is ready to go.
Setting Up Folders:
You are going to need a folder to build you kernel in. For this tutorial, I will use my setup: /home/nick/android/kernel/SPH-L300/Kernel. Kernel is the source directory that is made from the source zip and SPH-L300 I will also use a lot, which contains Kernel.
Downloading The Source:
Download the zip from http://opensource.samsung.com/ or from InsanelyCool's stock kernel source. Then I put it in the SPH-L300 folder. Afterwards, unzip it. You should have 2 files, Kernel.tar.gz and Platform.tar.gz. We are going to focus on Kernel.tar.gz, so unzip it. This will make the Kernel folder.
Now, in your terminal, cd to somewhere to keep your toolchains. I keep mine in ~/android/kernel.
Now type
Code:
git clone git://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains
for the toolchains I used. They should be put in the folder toolchains.
Modifying The Kernel:
Now is the time to modify the kernel. You can apply patches and change governors and frequencies etc here.
Applying a Patch:
The kernel version is 3.0.31. You can upgrade it using patches. Patches can be found here. You have to apply one patch at a time, which is why scripts come in handy when patching multiple times. I am going to show you how to upgrade to 3.0.33, since you can do that without error.
First, download patch-3.0.31-32.bz2 (or .gz) and download patch-3.0.32-33.bz2 (or .gz).
Extract both and move the extracted files into the Kernel source folder.
Cd to this folder in your terminal and type
Code:
patch -p1 < patch-3.0.31-32
. If you get something about
Code:
...assume -R? [n]
just press enter then press y then enter again.
Do the same steps for applying the other patch, just mod the command to work.
Building The Kernel:
Setting Up Environment:
In the Kernel source directory, open the file Makefile and press ctrl-f. Then enter CROSS_COMPILE, and look for CROSS_COMPILE = /xxxxx, where xxxxx is a directory. Change that directory to the toolchain of your choice. **Not all toolchains work!** For me, it would look like: CROSS_COMPILE = /home/nick/android/kernel/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi- for Linaro 4.6.2. Save the file and exit.
Make sure your terminal is in the Kernel source directory.
Kernel Name:
If you want to change the kernel name, in terminal type
Code:
KBUILD_BUILD_VERSION="ROM NAME"
then
Code:
export KBUILD_BUILD_VERSION
.
Compiling It:
Next, type
Code:
export ARCH=arm
into terminal.
Almost there. The next step is to type
Code:
make gogh_defconfig
into terminal.
If you added options such as governors, do
Code:
make menuconfig
to activate them.
Otherwise, type
Code:
make -jx
where x is the number of processes per core. I use
-j2 for a dual core cpu. This takes about 20-30 mins for me. A quad-core Intel cpu takes 4 mins if you use -j5. For Intel, it is the # of cores + 1.
Actually Putting The Kernel Together:
Now that it has built, assuming you have had no errors and the terminal finishes with
Code:
Kernel: arch/arm/boot/zImage is ready
you are ready to assemble the kernel. Cd to outside your Kernel source to the folder that contains it. For me that would be SPH-L300. You are going to need a working boot.img for this phone to speed up this process by a lot. Whether its stock, mine, or Insanelycool's, just paste it into the folder.
In terminal, type
Code:
abootimg -x boot.img
Then
Code:
mkdir initrd && cd initrd && zcat ../initrd.img | cpio -i
And finally
Code:
find . | cpio -o -H newc | gzip > ../initrd.img
This splits the boot.img, and puts the ramdisk in the initrd folder.
Now, navigate to (kernel source)/arch/arm/boot and copy the zImage to where you were before (the SPH-L300 folder for me). When you paste, override the pre-existing zImage.
If you would like to change the splash screen before the bootanimation, swap out initlogo.rle in the initrd folder with the image of you choice. It must be a rle image and must be named initlogo to work. I won't tell you how to convert png's to rle's cuz I am sure you know how to Google.
Now, we actually but the boot.img together. In terminal, type
Code:
cd ../ && abootimg --create boot.img -k zImage -r initrd.img && abootimg --create boot.img -f bootimg.cfg -k zImage -r initrd.img
and make sure you are in the initrd folder. If you get the error updated is too big for Boot Image, use this command:
Code:
cd ../ && abootimg --create boot.img -k zImage -r initrd.img && abootimg --create boot.img -f bootimg.cfg -k zImage -c "bootsize=xxxxxx" -r initrd.img
and replace the x's with the size the kernel wants to be. This will give you a new boot.img in the containing folder (SPH-L300 for me). Now just zip it up and tell the updater-script where to flash it and voila!, you just made you own kernel.
Feel free to ask any questions below.
I WOULD LIKE TO THANK ONE PERSON IN SPECIFIC, AND THAT IS INSANELYCOOL FOR TEACHING ME MOST OF THE STEPS HERE.
Click to expand...
Click to collapse
Actually where is the zImage located in output/arch/arm/boot/ or in source/arch/arm/boot/ both the files are different for me
Sent from my SM-G530H using Tapatalk
pradeepreddychimmula said:
Actually where is the zImage located in output/arch/arm/boot/ or in source/arch/arm/boot/ both the files are different for me
Sent from my SM-G530H using Tapatalk
Click to expand...
Click to collapse
The one you made may be a diff size depending on the compression and mods you've done
Sent from my A0001 using Tapatalk
Nick_73 said:
The one you made may be a diff size depending on the compression and mods you've done
Sent from my A0001 using Tapatalk
Click to expand...
Click to collapse
I mean which is the compiled one
Sent from my SM-G530H using Tapatalk
pradeepreddychimmula said:
I mean which is the compiled one
Sent from my SM-G530H using Tapatalk
Click to expand...
Click to collapse
The one u compiled should be the output
Sent from my A0001 using Tapatalk
Nick_73 said:
There are a lot of people out there wondering how to build kernels. It sounds confusing and hard, but once you get the hang of it, it is actually quite easy. I got the jist of it in just a few practices. Now I give all of my information to you, in the simplest, most comprehensible and most noob friendly way I can. In this guide, I will be building the kernel for my phone, the Samsung Galaxy Victory 4G LTE. So make your adjustments where necessary.
What You Will Need:
A linux OS. I now use Ubuntu 14.04 Manjaro, and Manjaro or Arch are preferred. (Ubuntu is easiest)
Patience
(Optional) A boot.img for your device
Required files
Required Files:
Open terminal and paste the following (I assume you already have java and perl and all that jazz):
In Ubuntu/ Debian:
Code:
sudo apt-get install abootimg git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
For Arch/Manjaro, do
Code:
sudo pacman -S gcc git gnupg flex bison gperf sdl wxgtk squashfs-tools curl ncurses zlib schedtool perl-switch zip unzip libxslt python2-virtualenv bc
for 32 and 64 bit systems. For only 64 bit, add the following:
Code:
sudo pacman -S gcc-multilib lib32-zlib lib32-ncurses lib32-readline
Also, abootimg can be installed using
Code:
yaourt -S abootimg-git
For other distros, you may have to modify the command to get the required files, such as using yum
Also, make sure you have setup git and it is ready to go.
Setting Up Folders:
You are going to need a folder to build you kernel in. For this tutorial, I will use my setup: /home/nick/android/kernel/SPH-L300/Kernel. Kernel is the source directory that is made from the source zip and SPH-L300 I will also use a lot, which contains Kernel.
Downloading The Source:
Download the zip from http://opensource.samsung.com/ or from InsanelyCool's stock kernel source. Then I put it in the SPH-L300 folder. Afterwards, unzip it. You should have 2 files, Kernel.tar.gz and Platform.tar.gz. We are going to focus on Kernel.tar.gz, so unzip it. This will make the Kernel folder.
Now, in your terminal, cd to somewhere to keep your toolchains. I keep mine in ~/android/kernel.
Now type
Code:
git clone git://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains
for the toolchains I used. They should be put in the folder toolchains.
Modifying The Kernel:
Now is the time to modify the kernel. You can apply patches and change governors and frequencies etc here.
Applying a Patch:
The kernel version is 3.0.31. You can upgrade it using patches. Patches can be found here. You have to apply one patch at a time, which is why scripts come in handy when patching multiple times. I am going to show you how to upgrade to 3.0.33, since you can do that without error.
First, download patch-3.0.31-32.bz2 (or .gz) and download patch-3.0.32-33.bz2 (or .gz).
Extract both and move the extracted files into the Kernel source folder.
Cd to this folder in your terminal and type
Code:
patch -p1 < patch-3.0.31-32
. If you get something about
Code:
...assume -R? [n]
just press enter then press y then enter again.
Do the same steps for applying the other patch, just mod the command to work.
Building The Kernel:
Setting Up Environment:
In the Kernel source directory, open the file Makefile and press ctrl-f. Then enter CROSS_COMPILE, and look for CROSS_COMPILE = /xxxxx, where xxxxx is a directory. Change that directory to the toolchain of your choice. **Not all toolchains work!** For me, it would look like: CROSS_COMPILE = /home/nick/android/kernel/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi- for Linaro 4.6.2. Save the file and exit.
Make sure your terminal is in the Kernel source directory.
Kernel Name:
If you want to change the kernel name, in terminal type
Code:
KBUILD_BUILD_VERSION="ROM NAME"
then
Code:
export KBUILD_BUILD_VERSION
.
Compiling It:
Next, type
Code:
export ARCH=arm
into terminal.
Almost there. The next step is to type
Code:
make gogh_defconfig
into terminal.
If you added options such as governors, do
Code:
make menuconfig
to activate them.
Otherwise, type
Code:
make -jx
where x is the number of processes per core. I use
-j2 for a dual core cpu. This takes about 20-30 mins for me. A quad-core Intel cpu takes 4 mins if you use -j5. For Intel, it is the # of cores + 1.
Actually Putting The Kernel Together:
Now that it has built, assuming you have had no errors and the terminal finishes with
Code:
Kernel: arch/arm/boot/zImage is ready
you are ready to assemble the kernel. Cd to outside your Kernel source to the folder that contains it. For me that would be SPH-L300. You are going to need a working boot.img for this phone to speed up this process by a lot. Whether its stock, mine, or Insanelycool's, just paste it into the folder.
In terminal, type
Code:
abootimg -x boot.img
Then
Code:
mkdir initrd && cd initrd && zcat ../initrd.img | cpio -i
And finally
Code:
find . | cpio -o -H newc | gzip > ../initrd.img
This splits the boot.img, and puts the ramdisk in the initrd folder.
Now, navigate to (kernel source)/arch/arm/boot and copy the zImage to where you were before (the SPH-L300 folder for me). When you paste, override the pre-existing zImage.
If you would like to change the splash screen before the bootanimation, swap out initlogo.rle in the initrd folder with the image of you choice. It must be a rle image and must be named initlogo to work. I won't tell you how to convert png's to rle's cuz I am sure you know how to Google.
Now, we actually but the boot.img together. In terminal, type
Code:
cd ../ && abootimg --create boot.img -k zImage -r initrd.img && abootimg --create boot.img -f bootimg.cfg -k zImage -r initrd.img
and make sure you are in the initrd folder. If you get the error updated is too big for Boot Image, use this command:
Code:
cd ../ && abootimg --create boot.img -k zImage -r initrd.img && abootimg --create boot.img -f bootimg.cfg -k zImage -c "bootsize=xxxxxx" -r initrd.img
and replace the x's with the size the kernel wants to be. This will give you a new boot.img in the containing folder (SPH-L300 for me). Now just zip it up and tell the updater-script where to flash it and voila!, you just made you own kernel.
Feel free to ask any questions below.
I WOULD LIKE TO THANK ONE PERSON IN SPECIFIC, AND THAT IS INSANELYCOOL FOR TEACHING ME MOST OF THE STEPS HERE.
Click to expand...
Click to collapse
How to covert zImage- to boot.img
Sent from my SM-G530H using Tapatalk
pradeepreddychimmula said:
How to covert zImage- to boot.img
Sent from my SM-G530H using Tapatalk
Click to expand...
Click to collapse
It tells u in the instructions how to put the zImage into the boot.img
Sent from my 1+ One using Tapatalk
Fantastic guide. Much appreciated!!! Thank you.
Now if i need to compile a custom kernel, i know where to look at.
Nick_73 said:
(I assume you already have java and perl and all that jazz)
Click to expand...
Click to collapse
it's not noob friendly. how do i know about other stuff that required for compiling?
Thank's for this tutorial. I have a Unbuntu box with 4Gig RAM and I'm interested in trying this out. Would that be sufficient for compiling android or should I upgrade my machine first?
Hello,
I'm compiling this kernel https://github.com/MiCode/Xiaomi_Kernel_OpenSource/tree/ido-l-oss
But the kernel stop booting as it doesn't found a sound card.
Running ls /dev/snd return only timer while it will have some pcm and other device in stock kernel.
Can somebody point me where to look at?
Thanks
Sent from my Redmi 3 using XDA Labs
can I have one?
can I have a copy of the Victory's rom o.o it sounds AWESOME
Soory but I am newbie building kernels for every device is same thanks in advance
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.