New: XDA launches forum for app developers. Discuss coding, tools, marketing, and more.
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
CallMeAria
Old
(Last edited by CallMeAria; 20th November 2011 at 05:21 PM.)
#1  
CallMeAria's Avatar
Senior Member - OP
Thanks Meter 263
Posts: 1,421
Join Date: Aug 2010
Location: Murrieta, CA

 
DONATE TO ME
Default [HOW-TO] Modify boot.img for LG Thrill/O3D

Im sure a good bit of you have already figured out that there is ZERO documentation on building a boot.img for our phones. Unfortunately it is not a generic process and every device is different. So basically this is a how-to on unpacking/repacking a boot.img for flashing to the device. This will allow you to make ramdisk modifications and create a boot.img from a kernel you compiled.

Directions

First youre going to need a few things. First and foremost, I have NO IDEA HOW TO DO THIS ON WINDOWS, so dont ask. If someone does then shoot me the directions and Ill put it up here and give you full credit.

You will need a Linux distribution such as Ubuntu (you can use a live CD or run it in a Virtual Machine as well, but again, dont ask me how to run it in Virtual Machine, Ive never done it).

-You will need to download the included boot-tools.zip which includes three things: unpack-bootimg.pl, mkbootimg, and a META-INF directory for flashing the boot.img in cwm recovery.

-You will also need the stock boot.img (or a custom one if you can find one at this point :P )

-Extract the boot-tools.zip to youre home folder. Make sure both files inside can be Executed as a program by checking 'Properties>Permissions'.

-Paste your boot.img in that folder as well.

-Open up a Terminal and:
Code:
cd ~/boot-tools
-Type:
Code:
./unpack-bootimg.pl boot.img
-This will create:
boot-img.ramdisk (this is the extracted ramdisk where you can make changes to your ramdisk)
boot-img.ramdisk.cpio.gz (this is the compressed ramdisk. You dont need to touch this.
boot.img-kernel.gz (this is the actual kernel)

-Rename "boot.img-kernel.gz" to "zImage" (OR, if you compiled your own just delete "boot.img-kernel.gz" and paste your compiled zImage here.

-Now you can make any changes you want inside boot-img.ramdisk.

-Now to repack the ramdisk so it can be packaged with the kernel you need to change directories in Terminal again:
Code:
cd ~/boot-tools/boot-img.ramdisk
-Now in the Terminal type:
Code:
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
(This part may require some package dependencies which you may need to install (gzip)

-This will produce a new package called "newramdisk.cpio.gz" This is the ramdisk you will package into the boot.img.

-So now finally we are going to bundle it all up into a boot.img

-So again we are going to change directories in the Terminal:
Code:
cd ~/boot-tools
-Now this next part needs to be exact or it will not work. In Terminal type:
Code:
mkbootimg --kernel zImage --ramdisk newramdisk.cpio.gz --cmdline "root=/dev/ram0 rw mem=128M console=ttyS2,115200n8 initrd=0x81600000,20M ramdisk_size=20480" --board omap4spd --base 0x756e0000 --ramdiskaddr 0x81600000 -o newboot.img
-This is very fast and it produces a new file called "newboot.img"

-You can now either delete or rename the original file called "boot.img"

-Now rename "newboot.img" to "boot.img"

-Now take "boot.img" and "Meta-INF" and zip those up together, naming the .zip whatever you want.

-Now you have a flashable boot.img update.zip you can put on your SD Card and flash from CWM recovery.

I suggest unpacking and then repacking a stock kernel without modification and then flashing it just to make sure it works before you make any changes.

Barring typo's, this process does work. Ive built a boot.img with it and the boot.img has been verified by other xda-ers to fully boot up and work. If I messed something up just let me know so I can fix it! Feedback is always welcome!

DOWNLOADS
boot-tools.zip
___________________________________
HTC Aria --CM7-- Donated
Samsung Captivate --CM7-- Retired
LG Thrill 4G --ThrillSeeker 2.2 -- Sold
Samsung Galaxy SII --CM10.1-- Sold
Samsung Galaxy SII Skyrocket --CM10.1--Sold (P.O.S)
Samsung Galaxy S4 --Stock Modified --CURRENT
The Following 4 Users Say Thank You to CallMeAria For This Useful Post: [ Click to Expand ]
 
CallMeAria
Old
#2  
CallMeAria's Avatar
Senior Member - OP
Thanks Meter 263
Posts: 1,421
Join Date: Aug 2010
Location: Murrieta, CA

 
DONATE TO ME
A breakdown of the boot.img bundling code:
Code:
mkbootimg --kernel zImage --ramdisk newramdisk.cpio.gz --cmdline "root=/dev/ram0 rw mem=128M console=ttyS2,115200n8 initrd=0x81600000,20M ramdisk_size=20480" --board omap4spd --base 0x756e0000 --ramdiskaddr 0x81600000 -o newboot.img
mkbootimg: This is just the command to use mkbootimg that packages the boot.img
--kernel zImage:This defines the file you want mkbootimg to use as your kernel.
--ramdisk newramdisk.cpio.gz: This defines the package you want to use as your ramdisk.
--cmdline "root=/dev/ram0 rw mem=128M console=ttyS2,115200n8 initrd=0x81600000,20M ramdisk_size=20480": This part is specific to our device and is taken from the kernel source. This is the part that was such a mystery :P
--board: This defines what board were installing our kernel too. This may or may not be needed. But I didnt test without this.
--base 0x756e0000: This defines the kernel base address. This is also device specific.
--ramdiskaddr 0x81600000: This defines the ramdisk base address. This is also device specific.
-o newboot.img: This tells mkbootimg what to name the output file, which in this case is "newboot.img" You can change this to whatever you want.
___________________________________
HTC Aria --CM7-- Donated
Samsung Captivate --CM7-- Retired
LG Thrill 4G --ThrillSeeker 2.2 -- Sold
Samsung Galaxy SII --CM10.1-- Sold
Samsung Galaxy SII Skyrocket --CM10.1--Sold (P.O.S)
Samsung Galaxy S4 --Stock Modified --CURRENT
The Following 2 Users Say Thank You to CallMeAria For This Useful Post: [ Click to Expand ]
 
tekahuna
Old
#3  
Senior Member
Thanks Meter 51
Posts: 119
Join Date: Jul 2010
Location: Oakland

 
DONATE TO ME
Thanks, good write up. I have a question. I'm on mac. I have mkbootimg from ICS sources, but I have no --ramdiskaddr option. Are you using a special mkbootimg?
Aloha,
FreeWELL/tekahuna
Android and Open Source Freelanthropist
OPPtimizer - Overclocking for OMAP Devices, Creator/Lead Developer
> Moto Droid 3, Bionic & RAZR > LG Thrill & O3D > Kindle Fire > Nook Tablet > Samsung i9100g, and more...

Android Wifi Tether - Wireless Tether for Root Users, Committer/Infrastructure Mode Specialist
> Moto Droid X, Droid 2/3, Milestone/2/3, Bionic & RAZR > LG Thrill & O3D, Galaxy Nexus and more...

Bring the forum to me: @tekahuna
 
rdannar
Old
(Last edited by rdannar; 20th November 2011 at 07:51 PM.)
#4  
rdannar's Avatar
Senior Member
Thanks Meter 988
Posts: 1,444
Join Date: Sep 2009

 
DONATE TO ME
You can install run it through cygwin on windows and i think on a mac too. Thats what i use for my kitchen and tools...

Or you cab just make a 10 gig partition and run dual boot ubuntu... i do that too but actually use 20 gigs... it is much easier than virtual. I use cygwin the most unless its a heavy duty project.

Sent from my LG-P925 using XDA App
 
bzlmnop
Old
#5  
bzlmnop's Avatar
Member
Thanks Meter 2
Posts: 36
Join Date: Dec 2008
Default Dont know what im doing wrong...

getting

"mkbootimg not found"

dont know what i did wrong...

its in the folder...

any ideas?
 
rdannar
Old
#6  
rdannar's Avatar
Senior Member
Thanks Meter 988
Posts: 1,444
Join Date: Sep 2009

 
DONATE TO ME
Cannot repack in cygwin. You must use virtual or real ubuntu install.




Sent from my LG-P925 using XDA App
 
bedwa
Old
(Last edited by bedwa; 21st November 2011 at 04:33 PM.)
#7  
bedwa's Avatar
Recognized Developer
Thanks Meter 622
Posts: 1,038
Join Date: Oct 2008
Location: Springfield IL
Thank you eternally sir! This shall come in handy.

oh, and I'm going to be doing this on my HP 210 netbook with Linux on it. It's what I've compiled every kernel over in the Infuse forums and even Linuxbozo's CM7 Kang for myself before I moved to the Thrill.
Former Devices: HTC Wizard-WM 6.5, OG iPhone, iPhone 3GS, 15+ android devices, including N1, Galaxy Nexus, Galaxy Tab 7.7 and many more.
Current Device: Moto xt910 w/ xt912 screen / S-off HTC One S

SIM Unlock: $16
Broken SIM locked XT910: $75
Working XT912: $200
Knowledge to dissasemble two phones and make one: Priceless.

Current Project(s)
Resources: Tab 7.7 Kernel/Initramfs
Kernels: Thrillz---Thrillz-GB---Infusion-GB---Infusion (Froyo)
No Odin? Flash a I897/I997 Kernel, Modem or both "zip packages!"
Red Nexus S LWP
LG Optimus Z Launcher

My Git.
My Twitter
Fuel my insanity fund, or click Thanks.
 
Gerrett
Old
#8  
Senior Member
Thanks Meter 2042
Posts: 1,167
Join Date: Mar 2011
Anyone try to complie the kernel with cm7 source? Didn't get the Tiap_drv.ko (wifi driver)

Sent from my Optimus 3D using Tapatalk
 
bzlmnop
Old
(Last edited by bzlmnop; 21st November 2011 at 09:01 PM.)
#9  
bzlmnop's Avatar
Member
Thanks Meter 2
Posts: 36
Join Date: Dec 2008
Default anyone?

im running ubuntu linux...
i tried adding ./mkbootimg... (says cannot execute binary file)
i tried adding sudo ./mkbootimg... (says syntax error)
i tried sudo mkbootimg... (says command not found)
i tried a space between . and /... (says no such file or directory)
i tried adding the full file path.
i have no idea what to do...
help please.
 
CallMeAria
Old
#10  
CallMeAria's Avatar
Senior Member - OP
Thanks Meter 263
Posts: 1,421
Join Date: Aug 2010
Location: Murrieta, CA

 
DONATE TO ME
Quote:
Originally Posted by bzlmnop View Post
im running ubuntu linux...
i tried adding ./mkbootimg... (says cannot execute binary file)
i tried adding sudo ./mkbootimg... (says syntax error)
i tried sudo mkbootimg... (says command not found)
i tried a space between . and /... (says no such file or directory)
i tried adding the full file path.
i have no idea what to do...
help please.
Did you give mkbootimg executable permissions?

Also you might try
Code:
sudo cp path_to_/mkbootimg /usr/bin
Sent from my LG-P925 using Tapatalk
___________________________________
HTC Aria --CM7-- Donated
Samsung Captivate --CM7-- Retired
LG Thrill 4G --ThrillSeeker 2.2 -- Sold
Samsung Galaxy SII --CM10.1-- Sold
Samsung Galaxy SII Skyrocket --CM10.1--Sold (P.O.S)
Samsung Galaxy S4 --Stock Modified --CURRENT