Modify the Init.rc

7,287 views
Skip to first unread message

chainz roid

unread,
Sep 28, 2012, 3:33:13 AM9/28/12
to android-...@googlegroups.com
Hello
        I'm using iberry-BT07i with ANDROID ICS. i need to modify the init.rc. with following lines.

                 mount usbfs none /proc/bus/usb -o devmode=0666
 
                 service vcsFPService /system/bin/ScanService
                         oneshot
                         disable
                 on property:persist.service.sensor.enable=1
                         start ScanService
                 on property:persist.service.sensor.enable=0
                        stop ScanService
I have tired the following ways but i can't succeed any of this.

1. Pull the init.rc from the tablet and edit then Push into the device. Then i reboot the tablet the old init.rc only there my modified init.rc is not their.
    ( while rebooting inti.rc taken from recovery.img not from boot.img)  

2. I've installed the nano editor in my tablet and then i tried to edit init.rc. i can open and edit the init.rc but i couldn't save the edited document.

3. My final try was extract the boot image from my device by cat /dev/block/nandc > /mnt/sdcard/boot.img. from this image i had unpacked the ramdisk and i had edited the init.rc,  Then packed again with the name of rooted.img.
    When i try to flash the new rooted.img i couldn't flash the image into my device, i tried with below mentioned ways
 
                 $ adb push ./mynewimage.img /sdcard
                 
                 # cat /dev/zero >> /dev/block/nandc
                     write: No space left on device
                 # flash_image boot /sdcard/rooted.img
                     error scanning partitions: No such file or directory 

I dono the reason for this error, anyone can help me ?

               And also i tried the fastboot method, its also no use. when i try to find my device by executing  " $ fastboot devices " not showing my device but when it try to execute 
 "$ adb devices " its showing my device. 
               And also when i try to boot my device into fastboot mode by pressing VOL UP + POWER key its entering into normal mode not into normal mode.

Hence i have tried all possible way to modify init.rc but i couldn't modify the init.rc.
Is any one handled this or have idea regarding this kindly share with me..
Mainly i need solution for mount the USB and Add my services into OS is there any otherway to accomplish it.?

Thanks in advance..











hagenp

unread,
Sep 28, 2012, 3:57:58 AM9/28/12
to android-...@googlegroups.com
On Friday, 28 September 2012 09:33:14 UTC+2, chainz roid wrote:
                 # cat /dev/zero >> /dev/block/nandc
                     write: No space left on device

Congratulations, you have wiped the complete NAND, including the partition table, with this command.
No wonder you get an error afterwards.

This web site has helpful hints about how to analyze problems and get helpful responses from forums (like this):
http://www.catb.org/esr/faqs/smart-questions.html

chainz roid

unread,
Sep 28, 2012, 4:14:15 AM9/28/12
to android-...@googlegroups.com
Oh.!!!
Thanks for your reply.!

But i re flashed my tablet with new image given by vendor, and i have tried without  " # cat /dev/zero >> /dev/block/nandc" but its showing same error.

So, There is any way to create the partition table or any other solution.?
If you have idea kindly share here..!!

Thanks 

hagenp

unread,
Sep 28, 2012, 5:15:14 AM9/28/12
to android-...@googlegroups.com
On Friday, 28 September 2012 10:14:16 UTC+2, chainz roid wrote:
So, There is any way to create the partition table or any other solution.?

Hm... maybe you are just trying the wrong thing.
"flash_image boot xxx" tries to flash the file "xxx" into the partition named "boot".
It scans the partition table. But maybe you really don't have one.

If your /dev/block/nandc contains _only_ the boot image (and no partitioning at all),
you can just use "cat" to write your new image into it.
Check your boot.img copy if there is a partition table present in the first sector.

Also your saved "boot.img" should contain the complete NAND content, including any parition table (if any).
So you could always "cat" that back, reboot, look at dmesg output to see which partitions are in the /dev/block/nand and then only overwrite the correct partition for that.

Good luck!

celavek

unread,
Sep 28, 2012, 5:23:23 AM9/28/12
to android-...@googlegroups.com

The init.rc file is usually contained in the init ramdisk so you need to have access to that file,
that is uInitrd.  Below is the complete procedure on how to "properly" update your init.rc file:

# the 'initrd' is used as the base of the root, '/', mount point
# you could modify for example the init.rc or ueventd.rc with your own custom
# settings(or any other !important! system file for that matter)

# create a temporary folder for your work
mkdir /tmp/initrd
cd /tmp/initrd

# mount the first partition of your Android SD card
# that is the 'boot' partition; ! your device identification might be different
# so be careful !; use 'dmesg | tail' to find out how the SD card was identified
# when plugged in

sudo mount /dev/sdc1 /mnt

# the ramdisk is a compressed CPIO file with a u-boot header and it's named
# 'uInitrd'
dd bs=1 skip=64 if=/mnt/uInitrd of=initrd.gz
gunzip initrd.gz

# at this point running the command "file initrd" should show:
# initrd: ASCII cpio archive (SVR4 with no CRC)
file initrd

# copy the contents
mkdir fs
cd fs
cpio -id < ../initrd

# you should see now the 'init.rc' file; you can edit it
...

# now from the contents of the 'fs' dir create the base for a new ramdisk
find ./ | cpio -H newc -o > ../newinitrd
cd ..

# zip it and generate the image
gzip newinitrd
mkimage -A arm -O linux -C gzip -T ramdisk -n "My Android Ramdisk Image" -d newinitrd.gz uInitrd_new

# copy the new image on the 'boot' partition as 'uInitrd';
# ! make sure you have a backup of the old ramdisk if anything should go boncus !
cp uInitrd_new /mount/point/of/your/SDcard/boot/partition/uInitrd

# that's it!

celavek

unread,
Sep 28, 2012, 5:28:31 AM9/28/12
to android-...@googlegroups.com

Just to clarify a bit. The SD card does not mean the sdcard partition on an Android device
which would relate to a physical SD card if the device allows for one.
I run my whole test system from a physical SD card(on a Pandaboard) so the
"SD card" in the above guideline means actually your "Android system image".
 

chainz roid

unread,
Sep 28, 2012, 6:43:50 AM9/28/12
to android-...@googlegroups.com

Thanks Mr.celavak, thanks for spending your time for me 

Actually i'm working with iberry tablet which have ANDROID ICS and NAND flash. My job is edit the init.rc which is inside the tablet.

My partitions are
# ls /dev/block
nanda, nandb, nandc(boot), nandd(system), nande(data), nandf(misc), nandi, nandj
These are my partitions. 
( In my tablet there is no cat /proc/mtd & /dev/mtd/mt1)

Already i had extracted my ramdisk by " cat /dev/block/nandc > /sdcard/oldboot.img "


But i cant re flash into my device.

I hope your idea will work well for me, So please can you highlights commands have to execute. Because its confusing because of many # symbol at your last reply

Thanks in advance..!!



chainz roid

unread,
Sep 28, 2012, 7:16:39 AM9/28/12
to android-...@googlegroups.com
"dmesg | tail " is not working its showing tail not found error.

And #mount showing 

rootfs / rootfs rw 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
/dev/block/nandd /system ext4 rw,nodev,noatime,user_xattr,barrier=0,data=ordered
 0 0
/dev/block/nande /data ext4 rw,nosuid,nodev,noatime,user_xattr,barrier=0,journal
_checksum,data=ordered,noauto_da_alloc 0 0
/dev/block/nandh /cache ext4 rw,nosuid,nodev,noatime,user_xattr,barrier=0,journa
l_checksum,data=ordered,noauto_da_alloc 0 0
/dev/block/vold/93:64 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,relatime,u
id=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset
=ascii,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/93:64 /mnt/secure/asec vfat rw,dirsync,nosuid,nodev,noexec,relat
ime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,ioch
arset=ascii,shortname=mixed,utf8,errors=remount-ro 0 0
tmpfs /mnt/sdcard/.android_secure tmpfs ro,relatime,size=0k,mode=000 0 0

boot partition is not there, its hidden or missed.
"# flash_image boot /mnt/rooted.img" shows the following error
error scanning partitions: No such file or directory

How can be overcome this problem..

hagenp

unread,
Sep 28, 2012, 8:35:11 AM9/28/12
to android-...@googlegroups.com
On Friday, 28 September 2012 12:43:50 UTC+2, chainz roid wrote:
# ls /dev/block
nanda, nandb, nandc(boot), nandd(system), nande(data), nandf(misc), nandi, nandj
These are my partitions.

Ah... that "ls" output is the key:
My mistake  was that I assumed /dev/block/nandc would be a block device containing multiple partitions.
"flash_image boot sdcard/rooted.img" also expects this. ("cat /dev/zero >blockdevice" is a really bad idea for initializing a multi-partition block device, because you then really wipe the partitioning scheme _and_ all content.)

But your NAND already exposes the partitions individually
 - and the "boot" partition _is_ "/dev/block/nandc".

Then all you need to do is
 # cat sdcard/rooted.img >/dev/block/nandc

celavek

unread,
Sep 28, 2012, 10:38:31 AM9/28/12
to android-...@googlegroups.com

 The "hash #" symbol means comment, so those lines contain just guidelines.

I think I misinterpreted  a bit your question. So you already have access to the
init.rc file and already modified it it's just writing the image back which fails.
Then I think the suggestion in the last comment from @hagenp should solve the issue for you.

chainz roid

unread,
Sep 28, 2012, 11:26:02 AM9/28/12
to android-...@googlegroups.com
Thanks for your replies.

I tried Mr.Hagenp idea 
 
# cat sdcard/rooted.img > /dev/block/nandc 

Rebooted the device its failed to boot, so i flash the image with vendor provided image.

Then i have extract the ramdisk from device and i named that berry.img. again i have tried 

# cat sdcard/berry.img > /dev/block/nandc 

Rebooted the device now its booting fine so no problem with flashing the image.

I guess the problem is repack the " kernel image + Ramdisk ". Here i mentioned how i did that.

1--> unpacked the image and got two files they were nandc.img-kernel.gz and nandc.img-ramdisk.cpio.gz 

2--> unpacked the ramdisk and edited the init.rc 

3--> Then i had repack the ramdisk by the following command

     $ find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz

4--> Then i have repack the kernel-image and ramdisk by the follwoing command

     mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel your-kernel-file --ramdisk newramdisk.cpio.gz -o rooted.img 
Finally i got rooted.img

The problem is if i tried 
# cat sdcard/berry.img > /dev/block/nandc device boot again successfully
( berry.img is got from device and didn't unpacked and edited )

# cat sdcard/rooted.img > /dev/block/nandc device not booting again its died.

Where i did the mistake any idea.?

if any mistakes in init.rc like typo or any error means device will boot again or not.?

Thanks in advance.!  

chainz roid

unread,
Oct 1, 2012, 2:23:07 AM10/1/12
to android-...@googlegroups.com
Thanks for your help. i had completed this.. i'm thankful for you both.!!

My mistake was i had repack the image with default kernel base address ( 0x20000000 ), but my kernel base address is ( 0x40000000). So i packed my image with the base address and flashed the image its working now.
Sadly my service not working now. but the same service working when i port in my beaglebone. i gave full permission for my service still its not working.  

chainz roid

unread,
Jan 23, 2013, 12:51:59 AM1/23/13
to android-...@googlegroups.com
Hi Rajip
             What kind of device you are using ? Can you let me clear about it.
             Checkout this link http://droidcore.blogspot.in/ to get clear idea..

On Monday, January 21, 2013 9:12:50 AM UTC+5:30, Rajib Nath wrote:
I kind of followed the same approach to change the init.rc file. 
My device does not get powered on when I did reboot. 
How do I get back to factory settings ? 
Reply all
Reply to author
Forward
0 new messages