Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
Chenglu
Old
(Last edited by Chenglu; 15th August 2012 at 05:45 PM.) Reason: update for cygwin
#1  
Chenglu's Avatar
Senior Member - OP
Thanks Meter 441
Posts: 211
Join Date: Oct 2010
Talking [HOW TO]Unpack/Repack initramfs in zImage (update for cygwin)

The latest version:
https://github.com/xiaolu/galaxys2_kernel_repack

update for cygwin

Attached Thumbnails
Click image for larger version

Name:	2011-10-09-01-50-02.jpg
Views:	4293
Size:	26.0 KB
ID:	743723   Click image for larger version

Name:	2011-10-09-01-51-37.jpg
Views:	3787
Size:	18.1 KB
ID:	743724  
Attached Files
File Type: zip initramfs-xwki8-cwm5.0.2.6.zip - [Click for QR Code] (2.82 MB, 948 views)
The Following 15 Users Say Thank You to Chenglu For This Useful Post: [ Click to Expand ]
 
Chenglu
Old
#2  
Chenglu's Avatar
Senior Member - OP
Thanks Meter 441
Posts: 211
Join Date: Oct 2010
I hate GFW
The Following 3 Users Say Thank You to Chenglu For This Useful Post: [ Click to Expand ]
 
rock_shen
Old
#3  
Junior Member
Thanks Meter 5
Posts: 17
Join Date: Aug 2008
Location: Taipei
I got a problem after repacked the new zImage.

The original size of zImage is 8MB, but the new zImage is 5MB...
 
netchip
Old
#4  
Account currently disabled
Thanks Meter 635
Posts: 1,090
Join Date: Sep 2011
Quote:
Originally Posted by Chenglu View Post
Unpack:
Code:
./k-unpack zImagexwki8 initramfs-ki8
[I] Extracting gzip'd kernel image from file: zImagexwki8 (start = 16621) 
[I] CPIO compression type detected = none | offset = 163840 
[I] Extracting non-compressed CPIO image from kernel image (offset = 163840) 
[I] Expanding CPIO archive: initramfs.cpio to initramfs-ki8.
Create newinitramfs.cpio:
Code:
./gen_initramfs.sh -o newinitramfs-ki8.cpio -u 0 -g 0 ./initramfs-ki8
or
Code:
cd initramfs-ki8
find . | cpio -o -H newc > ../newinitramfs-ki8.cpio
Edit k-repack Modified to your cross-compiler:
Code:
COMPILER=/home/xiaolu/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi
COMPILER_LIB=/home/xiaolu/CodeSourcery/Sourcery_G++_Lite/lib/gcc/arm-none-eabi/4.5.2
Rebuild kernel:
Code:
./k-repack zImagexwki8 newinitramfs-ki8.cpio
[I] ---------------------------kernel repacker for i9100---------------------------
 
[I] Extracting gzip'd kernel from zImagexwki8 (start = 16621) 
[I] Non-compressed CPIO image from kernel image (offset = 163840) 
[I] CPIO image MAX size:3044984 
[I] head count:3208824 
[I] Making head.img ( from 0 ~ 163840 ) 
[I] Making a tail.img ( from 3208824 ~ 13773971 ) 
[I] Current ramdsize using cat : 3045376 with required size : 3044984 
[I] Current ramdsize using gzip -fc : 1888879 with required size : 3044984 
[I] gzip -fc accepted! 
[I] Merging [head+ramdisk] + padding + tail 
[I] Now we are rebuilding the zImage 
[I] Image ---> piggy.gzip 
[I] piggy.gzip ---> piggy.gzip.o 
[I] Compiling head.o 
[I] Compiling misc.o 
[I] Compiling decompress.o 
[I] Compiling lib1funcs.o 
[I] Create vmlinux.lds 
[I] head.o + misc.o + piggy.gzip.o + decompress.o + lib1funcs.o---> vmlinux 
[I] vmlinux ---> zImage 
[I] Re-compiled to new_zImage 
[I] Cleaning up... 
[I] finished...
Resources form GT-I9100_OpenSource_Update2(https://opensource.samsung.com )

initramfs-xwki8-cwm5.0.2.6.zip is modified initramfs for xwki8 stock kernel.

You are my hero
Thanks for making it
 
Chenglu
Old
(Last edited by Chenglu; 8th October 2011 at 08:50 PM.)
#5  
Chenglu's Avatar
Senior Member - OP
Thanks Meter 441
Posts: 211
Join Date: Oct 2010
Quote:
Originally Posted by rock_shen View Post
I got a problem after repacked the new zImage.

The original size of zImage is 8MB, but the new zImage is 5MB...
No problem,CPIO image is gzipped
 
Chenglu
Old
#6  
Chenglu's Avatar
Senior Member - OP
Thanks Meter 441
Posts: 211
Join Date: Oct 2010
Quote:
Originally Posted by rock_shen View Post
I got a problem after repacked the new zImage.

The original size of zImage is 8MB, but the new zImage is 5MB...
use command Filled to 8387840 bytes
Code:
dd if=new_zImage of=zImage bs=8387840 conv=sync
 
netchip
Old
#7  
Account currently disabled
Thanks Meter 635
Posts: 1,090
Join Date: Sep 2011
I have writed a script for easy repacking/unpacking/padding

Code:
#!/bin/sh

REUNPACK=$1

if [ $REUNPACK == repack ]; then
cd initramfs_root
find . | cpio -o -H newc > ../initramfs.cpio 
cd ..
./k-repack zImage initramfs.cpio
fi;

if [ $REUNPACK == unpack ]; then
./k-unpack zImage 
fi;

if [ $REUNPACK == cpio ]; then
cd initramfs_root
find . | cpio -o -H newc > ../initramfs.cpio 
fi;

if [ $REUNPACK == padding ]; then
rm -rf zImage
dd if=new_zImage of=zImage bs=8387840 conv=sync
fi;

if [ $REUNPACK == clean ]; then
rm -rf zImage initramfs_root initramfs.cpio new_zImage
echo "Done!"
fi;
 
Chenglu
Old
#8  
Chenglu's Avatar
Senior Member - OP
Thanks Meter 441
Posts: 211
Join Date: Oct 2010
Quote:
Originally Posted by netchip View Post
I have writed a script for easy repacking/unpacking/padding

Code:
#!/bin/sh

REUNPACK=$1

if [ $REUNPACK == repack ]; then
cd initramfs_root
find . | cpio -o -H newc > ../initramfs.cpio 
cd ..
./k-repack zImage initramfs.cpio
fi;

if [ $REUNPACK == unpack ]; then
./k-unpack zImage 
fi;

if [ $REUNPACK == cpio ]; then
cd initramfs_root
find . | cpio -o -H newc > ../initramfs.cpio 
fi;

if [ $REUNPACK == padding ]; then
rm -rf zImage
dd if=new_zImage of=zImage bs=8387840 conv=sync
fi;

if [ $REUNPACK == clean ]; then
rm -rf zImage initramfs_root initramfs.cpio new_zImage
echo "Done!"
fi;
good work
 
guaiwujia
Old
#9  
Senior Member
Thanks Meter 5
Posts: 135
Join Date: Nov 2006
Location: SHANGHAI
Quote:
Originally Posted by Chenglu View Post
I hate GFW
haha
me too
 
Chenglu
Old
#10  
Chenglu's Avatar
Senior Member - OP
Thanks Meter 441
Posts: 211
Join Date: Oct 2010
Quote:
Originally Posted by guaiwujia View Post
haha
me too
hiahia

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...