[Q] Best way to chmod the /dev file? - Android Software Development

I need to chmod one of the devices under /dev so it can be accessed by java app.
One way is that I have to root the phone, and run chmod from java every time after boot.
Another way is, I can put it into the init.rc file. But I will need to unpack the boot image, and repack it, then flash it back to the phone. Is there a tool I can use to easily do this job? And is there a better way?

Related

Android img files

Okay I know this is a very noob question, how do I open android .img files And I have run a number of different search queries and still haven't found the answer.
jimmydafish said:
Okay I know this is a very noob question, how do I open android .img files And I have run a number of different search queries and still haven't found the answer.
Click to expand...
Click to collapse
what do you want to do with the img? dump it or just flash it?
if you got some kind of linux distro installed, just go (in terminal) to the dir where the image file is located, and type "file filename.img" if it returns something like ext2 filesystem, simply do:
mount -o loop filename.img /mnt
and the file will be mounted on /mnt, so you can access it using cd /mnt
if it returns something like VMS Alpha executable, you will have to download unyaffs, and if you want to repackage it later on, mkfs.yaffs2,
to get the file's content, just run unyaffs filename.img, and you will have the file content right in the folder with the img file...
if you don't have a linux distro installed, you can simply get virtualbox, and download the latest ubuntu iso file... mount the file in virtualbox and install ubuntu (it's quite easy)...
oh and incase you need them some basic commands:
Code:
ls - lists current folder content
cd folder - allows you to switch to a specific folder, like if you type ls, and you get the folder android listed just type cd android... if you want to go back to your home folder, type ~/...
sudo command - allows you to run specific commands as superuser (root... you can also just switch to user root by typing sudo su, so you won't need sudo every single time)
rm file / rm -R folder/file - allows you to remove files and with the parameter -R also folders ;)
hope this helped
emulator
What if i want to use the .imgs in the emulator/AVD? Any tips?
Thanks.
tdh_andy said:
What if i want to use the .imgs in the emulator/AVD? Any tips?
Thanks.
Click to expand...
Click to collapse
use mkfs.yaffs2.

[Q] How to Create boot.img file

I couldn't find a thread on this. If there is one and I just missed it, please direct me that way and I apologize for the duplicate.
I hacked the .config file (kernel), compiled it, tested it in fastboot's boot mode (from the bootloader) and then flashed it to the phone with the instructions on this site:
credentiality2.blogspot.com/2010/08/nexus-one-htc-passion-compile-and-flash.html
It works and is wonderful, but I would love to find a way to create a boot.img file with the kernel I've hacked. Do any of you have any insight or know where I can look for more info.?
Do any of you know how to create the boot.img-ramdisk.gz file? I know how to put that with my hacked boot.img-kernel file and create a boot.img file that way.
Any help is much appreciated.
Fixed!
I figured out the problem was I couldn't the boot.img file from my Android 2.2 phone because the read-write permissions did not allow me to do the adb pull command. Now, I've pulled that boot.img file and can unpack and repack it with my hacked kernel using the directions on the website I originally referenced.
I used this command to change the permissions so I could pull the boot.img file:
#mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Hi,
I have rooted my HTC Dream successfully. I have flashed in CyanogenMod ROM.
Now I have downloaded Android Kernel and rebuilt it. Now I have the zImage which is the kernel image. Now how do I use this new image? I guess must modify the boot.img to use this new kernel image.
Any idea how can I do this? I tried using "fastboot flash:raw boot <kernel directory> <ramdisk directory>"
For <ramdisk directory> I point to the one in the android-sdk. But after flashing it stuck in the "G1 T Mobile" screen and doesn't proceed. Not sure how to resolve.
Thanks In Advance,
Perumal
I downloaded the boot.img file, split it into boot.img-kernel and boot.img-ramdisk.gz. Then, renamed my newly-compiled kernel's "zImage" file as "boot.img-kernel" and zipped them back up into boot.img. Then, I flashed it to the phone with fastboot. All of the directions are on this website:
credentiality2.blogspot.com/2010/08/nexus-one-htc-passion-compile-and-flash.html
It was written for HTC Passion / Nexus One, so you may want to pull your existing boot.img file first in case it doesn't work on the HTC Dream and you need to go back to where you started. I found this tutorial helpful for that.
credentiality2.blogspot.com/2010/08/extract-bootimg-from-android-phone.html
You probably need to change your permissions to push and pull the boot.img file. I would do that on my computer (with it tethered to the phone), using the following commands in a terminal window:
$ adb shell
$ su
# mount -o remount,rw /dev

[Q] no /sbin/am

Hi.
My problem is on a SGSII, but I suppose it could be on any phone.
All last rom I flashed had problems with adb : after flashing, I am unable to use some adb command. For example :
Code:
$ adb uninstall <mypackage>
/sbin/sh: pm: not found
the pm script exists in /system/bin, but is not useable "as is" because it lacks of "#!/system/bin/sh" on the first line.
What I have to do is
Code:
mount -o remount,rw - /
echo '#!/system/bin/sh' >/sbin/am
cat /system/bin/am >>/sbin/am
chmod 0777 /sbin/am
echo '#!/system/bin/sh' >/sbin/pm
cat /system/bin/pm >>/sbin/pm
chmod 0777 /sbin/pm
mount -o remount,ro - /
And then it works again.
But my problem is that on each reboot I have to do this again.
So my questions are :
- do you know why those rom (I'm actually using Lite'ning) does not have those scripts ?
- how can I make those change permanent ? how /system is build ? for example, there is a "build.prop" file in it but it is nowhere else on my phone ...
Thanks a lot for your help !
Mike
The problem is twofold. First, a proper shell script should have the first line as a path to the command interpreter ("#!/system/bin/sh"), but for some reason, am and pm scripts don't have this. The second part of the problem is that the default shell as shipped in the AOSP code base ignores that line and happily executes these broken shell scripts. Depending on just how your rooted ROM was cooked, you may have any of a number of shell interpreters; bash, busybox sh, and the original sh being the most common. Bash is more tolerant of broken scripts, but the busybox interpreter won't execute these.
I don't know why your editing doesn't keep between boots though. It seems it should based on what's posted above. I don't have any knowledge of the internals of the SGSII so you probably need to ask that question in a forum dedicated to that device.
Tanks for your reply.
OK, it don't work anymore because default shell has been changed.
2 questions remains :
- why those scrips are not any more in /sbin
- why they don't stay when I reboot.
If anybody knows ...
I'll try to ask on the rom maker thread ...
Mike
I must have missed that. /sbin is part of the ramdisk. It is stored in the boot image and gets expanded to RAM at every boot, so any changes in /sbin will be destroyed on next boot.
all I have to do then is find where this ramdisk and update it ? ...
I'll try and let you know
Thanks again !
mbaroukh said:
all I have to do then is find where this ramdisk and update it ? ...
I'll try and let you know
Thanks again !
Click to expand...
Click to collapse
The ramdisk is a cpio archive gzipped to save space, then concatenated with a kernel into a single file. A short header on the whole thing tells where to split the two, and the kernel command lines and some other housekeeping tasks. Together that all makes up the boot.img partition (at least this is how it is on most androids I've played with). When the bootloader launches, it loads the header that tells where the kernel is in the file. It then loads the kernel into RAM. It then passes control to the kernel. The kernel knows how to gunzip the cpio archive and how to create a ramdisk partition of the required size. It then un-archives it into the newly created ramdisk, then passes control to `init' to do the rest of the boot process.
You can't just modify the ramdisk on the device. You have to extract the whole boot.img from flash, then separate its two parts (ramdisk and kernel) then gunzip and un-archive the cpio filesystem somewhere (preferably a *nix system that understands unix permissions, simlinks, etc), then modify whatever it is you want, then archive the contents again to a cpio archive, gzip it up, then recombine it with the kernel and the appropriate header for the whole thing, then re-flash it to the NAND partition on your device where the boot.img normally resides.
Thanks !
This is my next week-end task to try all this.
I'll let you know if I succeed or not.

[HELP] [Battery capacity] Cannot save/push/copy file to root of device

hello guys. battery of my zf5 is dead. i have dissambled it and get the controller, and i have conected another battery (bigger one, 6000mah) to controller.
now device work, but it using only 2100 mah from battery, because this value is setted in framework-res.apk, and in the charge-full file from /sys/class/power_supply/battery.
now, i have modified value in the framework-res.apk, recompiled it and pushed to device (no problem with this).
now, i have pulled charge-full file from /sys/class/power_supply/battery folder, modified it, but i cannot copy/replace it back to device.
i have root, i have rw permisions to root of device.
i have chmod 777 -R /sys/class/power_supply/battery folder, chmod +x -R /sys/class/power_supply/battery folder. i have try to change owner of /sys/class/power_supply/battery/charge-full file. but no luck, allways i get Failed: operation not permited.
tryed copy/replace from adb shell, from twrp file manager, from twrp terminal. no luck
can please anyone help me?
thx!!

Make ROOT Permanet / System Read and Write to all Android ROMS for Tenderloin

Extracting ramdisk image to change fstab.tenderloin to make system read and write allowing permanent root access using any ROM ever created for the HP Touchpad.
I am using Ubuntu 18.04.1 LTS 64-bit (All the software is open source and free, you can get the packages necessary for your distro)
Create a folder in /home (root) name it hpboot ( on the PC ) all work is done on the PC.
Open the custom ROM zip file and extract boot.img to the created directory hpboot
Open Terminal in the hpboot directory, all the commands needs to be enter there.
Text beginning with –>># are for information only. Do not paste into the Linux terminal window.
–>># The following will extract images from boot.img file located in the hpboot direcory.
–>># Copy and paste each individual line in the Terminal window one by one and wait until each command finish processing.
dumpimage -i boot.img kernel.uImage
dumpimage -i boot.img -p 1 ram
dd if=ram of=ramdisk.img.gz bs=64 skip=1
gunzip ramdisk.img.gz
mkdir ramdisk; cd ramdisk
cpio -i < ../ramdisk.img
–>>#The ramdisk files are uncompress in the hpboot/ramdisk directory
–>>#Open file fstab.tenderloin using (text editor) change mnt_flags of/system ext4 from ro to rw
–>>#Look like this when change from (ro ) read only to ( rw ) read and write.
–>>#<src> <mnt_point> <type> <mnt_flags and options>
–>>#/dev/store/cm-system /system ext4 rw,errors=panic
–>># Save and close the fstab.tenderloin file
–>># The next 3 steps will repack the files into the ramdisk and merge Kernel to create the finish boot image.
find . | cpio --create --format=’newc’ | gzip > ../ramdiskRW.img
cd ~/hpboot
mkimage -A arm -O linux -T ramdisk -C none -a 0x00000000 -n “TENDERLOIN RW SYSTEM RAMDISK” -d ./ramdiskRW.img ./ramdisk.uImage
mkimage -A arm -T multi -C none -n “Tenderloin RW System” -d kernel.uImage:ramdisk.uImage uImage.Android_RW
–>>#Boot the touchpad into TWRP, connect to PC, copy uImage.Android_RW to the external Micro SDCard.
–>>#Select MOUNT and touch Boot, go back, touch Advanced, File Manager, touch external_sd, select uImage.Android_RW, touch Copy File, touch boot, touch select Current Folder.
–>>#You should have free space on your boot for both images. At the boot screen you will have the option of Android (with no permanet ROOT access) and Android_RW (RW System), you need to install SuperSu. You can use any of the two options or delete uImage.Android and then rename uImage.Android_RW to uImage.Android for one boot option.
You do not need to re flash the ROM, you can add this boot file and use it with your current installed working ROM.
The process works for all boot.img created for the HP Touchpad. If you have a ROM and would like to have system read and write access then you can do this.
Hopefully a Linux Guru will create a script for this, which will automate the process to 3 seconds!
I like tinkering with my TP but I am running @Windows 7 on a 32 bit.. any suggestions?
Android is base on Linux OS.
Install vmware player and run ubuntu as a virtual machine, both are free.
--SNIP--
Hopefully a Linux Guru will create a script for this, which will automate the process to 3 seconds!
Click to expand...
Click to collapse
Here's a shell script that automates the process (rename the extension from .txt to .sh). Put the script and boot image file in any directory and type
Code:
./rwcreate.sh
If it doesn't execute, it probably needs its permissions changed.. Right click the file you created, select 'properties'. In the properties window, select "Permissions" and check "allow executing as ..." or type
Code:
chmod +x rwcreate.sh
in a terminal window
Thanks for your help and dedicating your time to make it easier for others.
I made suggestion to the script on correcting an error, on DU forum.
Now is just a click to get it done, but if we were in a perfect computer world, it could be even easier as to connect the HP Touchpad to PC using USB.
Then run the script and everything is complete!
Using adb pull command to get (boot.uImage) from hp boot directory, to PC.
Changes are done as per script.
adb push command new boot.uImage to hp boot directory, all done!
But making it easier, will make it more complicated and having to install more software and confusing!
HP_TOUCHPAD said:
Thanks for your help and dedicating your time to make it easier for others.
I made suggestion to the script on correcting an error, on DU forum.
Now is just a click to get it done, but if we were in a perfect computer world, it could be even easier as to connect the HP Touchpad to PC using USB.
Then run the script and everything is complete!
Using adb pull command to get (boot.uImage) from hp boot directory, to PC.
Changes are done as per script.
adb push command new boot.uImage to hp boot directory, all done!
But making it easier, will make it more complicated and having to install more software and confusing!
Click to expand...
Click to collapse
Done. Thanks.
shumash said:
Done. Thanks.
Click to expand...
Click to collapse
The script on this forum is correct, but in the DU the file was wrong, corrected now.
Thanks for the fix and help!

Categories

Resources