[Q] init Questions - Flipout and Charm General

I see there are several init.*.rc files in the root directory(/), like
init.goldfish.rc
init.mapphone_cdma.rc
init.mapphone_umts.rc
init.mapphone30_umts.rc
init.rc
And I was wondering, which of them were called/executed by the init process and the order they were called.
Another question is, if I run 2nd-init, how will the scripts be executed.
Thanks in advance.

Related

permanently change $PATH

I'm trying to change $PATH to have /system/xbin/ before /system/bin/.
I could do this manually but I'm lazy, so I'm looking for a way to have it like that on boot. But no matter whether I change it in init.rc, fota.rc, recovery.rc, they're all back in the old order after a reboot.
Anyone know which file I have to change to make my path changes stick?
XlAfbk said:
I'm trying to change $PATH to have /system/xbin/ before /system/bin/.
I could do this manually but I'm lazy, so I'm looking for a way to have it like that on boot. But no matter whether I change it in init.rc, fota.rc, recovery.rc, they're all back in the old order after a reboot.
Anyone know which file I have to change to make my path changes stick?
Click to expand...
Click to collapse
The init.rc file is a part of the initramfs which is included in the kernel image (zImage). You need to change the init.rc and recompile the kernel with the updated initramfs to make the changes stick.
There is also a way to unpack and repack an existing kernel image, but IMHO recompiling the kernel is much simpler.
hm, compiling kernels isn't really my thing.
is there another way to insert commands into boot process or change path on startup?
XlAfbk said:
hm, compiling kernels isn't really my thing.
is there another way to insert commands into boot process or change path on startup?
Click to expand...
Click to collapse
I think if you have a kernel with init.d support, you can just drop a script in the init.d directory and it will get automatically executed.
I think all the custom kernels (at least ones based on Voodoo) have init.d support -- never actually tried this so I am not totally sure about this.
I'm using the hacked voodoo kernel for gingerbread, created a /init.d/test.rc with "export PATH ... " but it didn't work. Is it supposed to be a .rc script? supposed to work in gingerbread kernel?
edit: after a closer looks it seems that the script is not only not run but /init.d is completly and without a trace gone after rebooting

[HACK] Run scripts at boot-time on stock rooted 3.2 without reflashing (nfs modules)

Hi,
When you want to perform some scripts at boot-time, there is two possibilities :
- modify init.rc, but it requires to reflashing the rootfs image (modification in / does not hold after a reboot),
- using an android app like script manager, which will load your scripts at java/dalvik platform boot-time.
I've managed to find a way based on activating tf-daemon, which is a script called by the asus/ventana initrc, but disabled at boot-time. Basically, we're re-enabling this daemon by setting the property tf.enable to yes, and then creating a script called tf-daemon and put it in /system/bin. Since this script is called by init.ventana.rc as root, you can put whatever you want inside this script.
I don't know what is the original purpose of this daemon, but probably it's used by the asus team for internal and debugging purpose.
Be aware that in the next firmware update, this possibility could disappear.Let's hope the asus team does not read this post. Or at least they could allow power users to call custom scripts at boot-time.
As a case study, you will find as attachment a script for loading nfs modules at boot-time.
PS: damn, can't upload. Here is a temporary link : http://dl.free.fr/hwTZ0YBq2
Untar the archive, then su, and sh install.sh
At reboot, you should have nfs modules loaded.
Good find:
I gave this a try just to load a couple of my own modules that work with the kernel I'm using. Works fine -- Thanks, -
Another method is to make a script and just call it in the init.rc. After a firmware update you only have to add the "exec myscript.sh" line to init.rc. I personally prefer this method because it allows me to control when the script is executed, whereas the tf-daemon method is always executed at the same point(AFAIK). Good research though, always nice to know all the boot calls.
Modifying the init.rc was my first shot, but the problem is that init.rc lies in ramdisk. So when trying to modify, the modification does not hold
after reboot. So a real modification involves to reflash rootfs with nvflash, too much hassle for me. The method I'm providing is for lazy ones. ;-)
nice find, but the link is dead, could you please provide a new link for the script?
also, how do I load nfs module for there is none under /lib/modules, compile the kernel myself?

Auto mount or symlink at boot

Hello, is it possible to do that ?
Regards
Sure, you have a few options.
The best way (hardest):
-requires root and knowledge of the boot.img and ramdisk partitions of Android
-create the symlink or mountpoint by adding the necessary lines the /init.rc file.
Next best way (not hard if you have init.d support):
-requires root
-requires init.d support
-simply write a script to create your symlink/mountpoint, name it appropriately, and place it in the /system/etc/init.d directory.
-with init.d support, this will automatically run the script at boot and set the parameters you've outlined in said script.
The "other" method (avoid this if possible since it relies on loading an app on boot):
-requires root
-download Script Manager from the play store
-write a script to create your mountpoint or symlink
-configure Script Manager to execute the script on boot.
Hello
I found /init.rc, also found init.00.rc and init.01.rc, but i guess we are talking about the first one (init.rc)
I wasn't able to edit it with a text editor on my tf101, do i need something i don't have to edit it ? Or notepadd++ will be enough ?
In case i fail completly with this, is tasker able apply the line for me too ?
Thanks you for your time.
Regards
Magissia said:
Hello
I found /init.rc, also found init.00.rc and init.01.rc, but i guess we are talking about the first one (init.rc)
I wasn't able to edit it with a text editor on my tf101, do i need something i don't have to edit it ? Or notepadd++ will be enough ?
In case i fail completly with this, is tasker able apply the line for me too ?
Thanks you for your time.
Regards
Click to expand...
Click to collapse
The /init.rc can't be directly modified that way. Everything in the root filesystem "/", as well as the kernel zImage, are loaded at boot from the boot.img image. Therefore, any changes you make will just be reverted when you reboot because it reloads the original from the boot.img image. In order to modify /init.rc, you must pull your boot.img and then extract the files from it. Now you can add the necessary lines to it. After that, you re-combine everything back into the boot.img, and push it back to your device.
If all that sounds unfamiliar to you, you will have some reading to do. Most of this will need to be done on a linux machine too.
What ROM are you running? If you have init.d support, that would be the most straightforward way to accomplish your goals.
I'm running asus' rom .24 on a tf101
I don't know if it support init.d, didn't found this file on my device.
Regards
You can also use an app from here, XDA, called directory bind. It all depends what you're looking to do with those symlinks.
Sent from my Sprint Evo View 4G (PG41200) using Xparent Purple Tapatalk 2
Hello, i plan to move game data to sdcard and symlink it to the old internal place.
Also plan to symlink some folders to the movie folder
Regards
Then directory bind app is designed for just your need. All these solutions require rooting your device.
Sent from my HTCEVOV4G using Xparent Purple Tapatalk 2
I will look at this, thanks.
Directory bind run during boot or after boot ?(little delay before things get re symlinked ?)
Regards

[Q] ROM porting

Edit: bootloop, partitions are not mounting.
nagato.fm said:
I'm trying to port an X5PRO rom to regular X5 and facing an issue of unworking wi-fi and USB mass-storage. All data I have: it's all right with IMEI, wi-fi and bluetoth MAC's are missing, serial number is missing, wi-fi toggle in settings is inactive (I mean it can't be turned on and if I try to turn it on directly from wi-fi settings it says "an error occured" and goes inactive again), when I'm connecting my phone to computer and trying to turn on storage I get message of dismounting SD card and the storage stays turned off.
I've already tried to change the kernel (this ROM is running 3.0.8 PRO kernel and I've used Dzo's v5.0u17 kernel) and it haven't fixed my problems. Changing of /system/libs/hw/ to the Aurora's resulted in non-bootable rom.
Have you any ideas of how to solve it? Or is there any threads about x5pro to non-pro porting I could miss? (I've tried to google anything about problems with my port and about porting from U8800PRO and found... nothing)
Click to expand...
Click to collapse
I have no ideal to give you because i'm not a DEV, but in the whole 4rum, you can easy find out the solution to help you.
http://forum.xda-developers.com/showthread.php?t=1941239
Those so called tutorials are pretty much useless, they will help you get the base on, but no more.
So, since U8800+ has a different Wi-Fi, you should first replace /system/lib/libhardware_legacy.so, /system/bin/wpa_supplicant with the dzo ones. Then copy over the /system/lib/modules directory, it contains Wi-Fi modules needed.
If it does not work out, try to modify the init.huawei.rc or init.rc and replace service wpa_supplicant and related configs with dzo ones. Note that you will have to modify boot.img, because it contains the init files. So use a boot.img unpacker, modify it, then repack it again.
Try to get me the logs too .
Blefish said:
Those so called tutorials are pretty much useless, they will help you get the base on, but no more.
So, since U8800+ has a different Wi-Fi, you should first replace /system/lib/libhardware_legacy.so, /system/bin/wpa_supplicant with the dzo ones. Then copy over the /system/lib/modules directory, it contains Wi-Fi modules needed.
If it does not work out, try to modify the init.huawei.rc or init.rc and replace service wpa_supplicant and related configs with dzo ones. Note that you will have to modify boot.img, because it contains the init files. So use a boot.img unpacker, modify it, then repack it again.
Try to get me the logs too .
Click to expand...
Click to collapse
The problem is that I've changed the kernel using abootimg package in Ubuntu because none of the scripts for unpacking/repacking boot.img found on this forum worked for me, also I couldn't unpack ramdisk so I think I can't modify init.rc at this moment. I'll try to get some logs and do all that you've mentioned.
Also there is another problem: no mobile network at all. When I turn on the phone the indicator goes gray and nothing seems working (can't phone someone and etc.). When trying to change mobile operator via settings I get a VERY strange menu asking me for PIN code (I actually don't have one - I've disabled it years ago).
Also I need to ask for some tutorials or knowledge bases about how android works and how core parts of android work (I mean EVERYTHING I can get) because I actually don't know ANYTHING about android and there's no noob-friendly tutorials or FAQ's over the internet. I've checked xda-university and it didn't helped either.
Anyway thanks for your help, Blefish!
After following your instructions system hangs on boot. When first flashed it started to "updating android:setting applications..." and then it rebooted. Then it said "updating... 1 of 1" and another reboot. Seems like framework-res isn't starting because it hangs on bootanimation and hardware buttons lights are constantly flashing. Installing SDK now, will try to get some logs.
Try to do it step-by-step so first replace one thing, reboot, then try another. That will help us understand what makes the phone hang.
For modifying kernel or init.rc I attatched boot.img unpacker-repacker with README, check it out. I am not sure if you need a Linux box for it, but I use that tool and it works well.
MIUI-XJ (my ROM) is a ported u800pro ROM. But it is a gingerbread ROM.
First of all,you need change all init files in /system. You can found this files in system/etc (example;init.qcom.wifi.sh).And I think the mass stroage problem causing by init.qcom.usb.rc (It can found in boot.img) but I'm not sure.
You should change gralloc files for a better GPU performance. It can found in systen/lib/hw. I think You don't need change other hw files.
u8800 needs system/bin/netd - system/lib/modules/*(anything in this folder) - system/bin/wpa_supplicant - system/lib/liboem_rapi.so - system/lib/libreference-ril.so - system/lib/libhardware_legacy.so - system/etc/init.qcom.wifi.sh - system/etc/firmware/wlan/*(anything in this folder) for turn on WiFi
and also u8800 needs system/etc/init.qcom.bt.sh - system/bin/hci_qcomm_init - system/bin/qmuxd (I'm not sure about this file) - system/bin/sdptool - system/bin/hciattach for turn on BT
And also,you need change init.rc and init.huawei.rc files in boot.img for turn on WiFi and BT.
forumber2 said:
MIUI-XJ (my ROM) is a ported u800pro ROM. But it is a gingerbread ROM.
First of all,you need change all init files in /system. You can found this files in system/etc (example;init.qcom.wifi.sh).And I think the mass stroage problem causing by init.qcom.usb.rc (It can found in boot.img) but I'm not sure.
You should change gralloc files for a better GPU performance. It can found in systen/lib/hw. I think You don't need change other hw files.
u8800 needs system/bin/netd - system/lib/modules/*(anything in this folder) - system/bin/wpa_supplicant - system/lib/liboem_rapi.so - system/lib/libreference-ril.so - system/lib/libhardware_legacy.so - system/etc/init.qcom.wifi.sh - system/etc/firmware/wlan/*(anything in this folder) for turn on WiFi
and also u8800 needs system/etc/init.qcom.bt.sh - system/bin/hci_qcomm_init - system/bin/qmuxd (I'm not sure about this file) - system/bin/sdptool - system/bin/hciattach for turn on BT
And also,you need change init.rc and init.huawei.rc files in boot.img for turn on WiFi and BT.
Click to expand...
Click to collapse
Thanks a lot! Will try it all now!
Okey, now it's a bootloop on splash screen.
Edit: a bootloop was caused by some error in boot.img repack. Will try to repack it again now.
How to enable ADB when booting? On Aurora I could get kernel messages via ADB using adb shell cat /proc/kmsg. And now I really miss this feature.
Okey, great news! Wi-fi turned on, but the phone will fastreboot if I turn it off (framework crash I think) and wont turn on again until a full reboot. Also it isn't really working: no networks found.
No changes at all except Aurora kernel + setprop persist.sys.wifimac mac_param in terminal. After that wi-fi turned on, but even with that prop I have no wi-fi mac.
From that I understand all my problems are from some RIL or hardware libs that don't load or load with mistakes. So I need to know what exactly it can be and what libs are for what. Also I think it can be because of unedited init.rc's in ramdisk so I need to know what to edit in them. I've tried to look through them but I don't understand anything in it.
nagato.fm said:
Okey, great news! Wi-fi turned on, but the phone will fastreboot if I turn it off (framework crash I think) and wont turn on again until a full reboot. Also it isn't really working: no networks found.
No changes at all except Aurora kernel + setprop persist.sys.wifimac mac_param in terminal. After that wi-fi turned on, but even with that prop I have no wi-fi mac.
From that I understand all my problems are from some RIL or hardware libs that don't load or load with mistakes. So I need to know what exactly it can be and what libs are for what. Also I think it can be because of unedited init.rc's in ramdisk so I need to know what to edit in them. I've tried to look through them but I don't understand anything in it.
Click to expand...
Click to collapse
Which ROM are you fixing? Isn't CM10?
Nope, it's some desire z jb rom.
Code:
[email protected]:~# adb shell dmesg
- exec '/system/bin/sh' failed: No such file or directory (2) -
That's what I'm getting now. Already tried to fix this issue with some methods from google, no results. Even tried to adb-push bash from 4pda to system/bin and make symlinks, no results. Phone is in bootloop. Any ideas?
P.S.: sh is actually in both xbin and bin, so the problem is somewhere in the boot.img, right?
Have tried all kind of sorcery, still bootloops and exec '/system/bin/sh' failed: No such file or directory (2). Don't know why this is happening. Either /system mounts on boot in some wrong poing or init.rc is completely messed up. But I've checked everything connected to mounting partitions in all init files (except binaries) and gained nothing. I really need some explanation of what are these files for and what they do and what they MUST do.
If someone can give me answers or advices, please, do it now. Because all my ideas are over and I simply don't know now what to do.
EDIT: with aurora boot.img (no changes at all) results are the same except the message in terminal is now "/system/bin/sh: no such tool"
The system/bin/sh error is caused by not mounting /system properly. Check the init.rc files, it could also be in init.emmc.rc if it's a CM rom.
Find out where the on emmc-fs trigger is; if you can't find it, add it into one of the init.rc files.
Code:
on emmc-fs
# mount mmc partitions
wait /dev/block/mmcblk0p12
mount ext4 /dev/block/mmcblk0p12 /system rw barrier=1
wait /dev/block/mmcblk0p13
exec /system/bin/e2fsck -p /dev/block/mmcblk0p13
mount ext4 /dev/block/mmcblk0p13 /data nosuid nodev barrier=1 noauto_da_alloc
mount ext4 /dev/block/mmcblk0p6 /cache nosuid nodev barrier=1
Not sure that I am following this thread properly. I am just starting out with android devel in Fedora. Have you recompiled the WLAN module?
eyeconic said:
Not sure that I am following this thread properly. I am just starting out with android devel in Fedora. Have you recompiled the WLAN module?
Click to expand...
Click to collapse
Nope, I have no proper skills for that, sorry.
I still need some information
Mostly completely rewrote init. files and still no results.
According to this: (http://forum.xda-developers.com/showpost.php?p=30458679&postcount=1)
The Android Boot Process
Bootloader – In HD2’s case, Magldr or cLK – loads the kernel based on how you have configured the phone.
Kernel – The kernel (zImage) is loaded into RAM along with an initial ramdisk (initrd.gz), which initializes various devices (IO, memory, GPU, etc.), interrupts, and mounts the root file system (/). After this, the first user-space process called init is started.
Init – this is a binary file that is contained within the initrd.gz. The init binary processes init.rc and init..rc , along with other .rc files that are called by these two .rc files. Some of the key functions (from this thread’s perspective) in the order of their initialization/ execution are:
The init process follows the instructions in the init.rc and init.xyz.rc files and creates empty directories including /data. It then mounts the storage devices (partitions in the internal NAND (MTD)) to these empty directories. The NAND partition for system is mounted to /system, followed by the partitions specified for data, cache, etc. The directories for dalvik-cache (/data/dalvik-cache) are also created by the init process after mounting the specified device to /data.
The init process then starts various services including adb, service manager, Volume Daemon (vold) for media like SD Card (FAT partition). Most importantly, the zygote service which initiates the Dalivk-Cache is loaded in this sequence.
As we all know, Android is based on Linux. The boot sequence described above is common for all Linux machines – until the zygote stage. Core Android file like core, framework, services, IME, policy, etc. are executed from the Dalvik-Cache and hence Initialization of the Dalvik Cache is pretty much where Android comes into the picture
The sysinit/ run-parts part, which runs scripts from the /system/etc/init.d later the Zygote stage. No matter how this is done, Android has already started loading by the time the boot process comes to executing scripts in /system/etc/init.d
Click to expand...
Click to collapse
Click to expand...
Click to collapse
the error is in mounting nand partitions, but how can it past to starting adb when it fails on mounting system partitions? I don't understand this.

Tried to modify .jar files to fix the NST screensaver rotation. Need help.

Hey all,
I tried to use mergesmali to modify my own android.policy.jar and services.jar using mergesmali and apktool to apply the patches that @Renate NST so gracefully provided to fix this minor issue.
In short, it was way too techie of an endeavor for me. I tried for about 5 hours, but the instructions were too tech savvy for me to understand. I was wondering if someone could patch my files for me and upload them so I can download them?
I'm running 1.2.1 rooted with NookManager.
Please forgive me Renate if I have done something by inappropriate uploading your files. Thank you to anyone willing to help.
I have attached my own android.policy.jar and services.jar to be patched. I have also provided (hopefully) all of the necessary files to patch the two .jar files.
You should be able to do this all yourself.
Did you read "readme.txt" that is packed inside nook121patch.zip?
Could you "apktool d" correctly?
apktool has changed over time, you need to:
Code:
apktool d foo.jar -o whatever
This will create the directory "whatever" and put everything in there.
Without this option, it will generate its own subdirectory named "foo".
Could you apply the patches correctly?
You can apply either a single patch or multiple patches with one line.
The "readme.txt" may have confused you because it was trying to make clear that you get to decide on each patch.
Make sure that everything went through correctly before swapping the new services.jar on your Nook!
Unzip nook121patch.zip into a directory called Nook121Patch.
Code:
apktool d services.jar -o Services
mergesmali \Services\smali Nook121Patch\LockScreen.smali
apktool b services.jar -o Services
Renate NST said:
You should be able to do this all yourself.
Did you read "readme.txt" that is packed inside nook121patch.zip?
Could you "apktool d" correctly?
apktool has changed over time, you need to:
Code:
apktool d foo.jar -o whatever
This will create the directory "whatever" and put everything in there.
Without this option, it will generate its own subdirectory named "foo".
Could you apply the patches correctly?
You can apply either a single patch or multiple patches with one line.
The "readme.txt" may have confused you because it was trying to make clear that you get to decide on each patch.
Make sure that everything went through correctly before swapping the new services.jar on your Nook!
Unzip nook121patch.zip into a directory called Nook121Patch.
Code:
apktool d services.jar -o Services
mergesmali \Services\smali Nook121Patch\LockScreen.smali
apktool b services.jar -o Services
Click to expand...
Click to collapse
Thank you so much. I thought my post died with no response. I will try this when I get some free time. Thank you again.

Categories

Resources