How to set zram swappiness for budget Android device - Android General

Today I'm gonna write on how to set zram swappiness for budget Android device which have zram built in it. This method does not requires rooting but involves boot.img editing and requires flashing.
What you need is:
1. Boot.img file extracted from the ROM file package or just dumped from your rooted device.
2. ADB tools installed.
3. Bootimg.exe tool (Download from the attachment here)
4. Notepad++
5. Patience
Here's how to do it:
1. Create one empty folder and place both boot.img and bootimg.exe tool in one place and then, Ctrl+right click to open CMD/PowerShell in the folder. If you're using PowerShell, run the command cmd after launching.
2. Run the command bootimg.exe --unpack-bootimg boot.img to extract the boot.img file.
3. Go to initrd folder and open up init.rc or init.[device-chipset-name].rc with Notepad++ and find the code snippet that are usually like this below (Press Ctrl+F and key-in the keyword swap or swappiness for quick search):
on property:ro.config.zram.support=true
setprop sys.vm.swappiness 80
write /proc/sys/vm/page-cluster 0
start zram
4. After finding the code snippet inside the init.rc or equivalent file, edit the setprop sys.vm.swappiness line and edit the default value to 100 which stands for aggressive swap mode. Then save the file.
5. Next, you have to repack the boot.img file back by running the command bootimg.exe --repack-bootimg and the file boot-new.img created.
6. Flash your device with boot-new.img via fastboot with command fastboot flash boot boot-new.img and boot the device.

Related

[How to] Make a script to auto-flash nandroid backups

The idea is pretty simple really. All you will need is the notepad application on Windows. When applying it, make sure to put all contents of your backup into the folder that also contains fastboot.
Open that up and copy and paste this into notepad, filling in correct information where appropriate.
(my first line would be desktop\phone\g1\fastboot)
cd C:\ -location of your fastboot folder-
fastboot flash system system.img
fastboot flash userdata data.img
fastboot flash boot boot.img
fastboot reboot
exit
Now hit file>save and in the save window where it selects the file type, select "all files". Now, name the script anything you like, but make sure it ends with a .bat . For example "script.bat". Once you are done, hit save, and the script is ready!
To use, have your files in the fastboot folder, your G1 booted into fastboot mode, and double click on the script.
that's great, i just created a similar one for linux today, i was switching between the 1.5 build and JF a few times because of a few things and was comparing and so i wrote the same script

How to make a ROM

Hey XDA
This might be a dumb question, but i dont know where else to ask
I would like to try and make my own ROM for my magic, but i have no idea about where to start, so i was wondering if someone knew of a guide, or some other form of "getting startet" thingy?
And what about apps, how do you make them?
Does it require a Linux machine, or can it be done in windows?
Per
I'm interested in this as well , guys nobody wants to share with us your knowledge??
I too would like to know.
bump
I would like to know also. A quick guide or write-up would be supper nice.
Not to burst anyone's bubble but I seriously doubt a quick write-up would explain the steps on to creating your own ROM or how to write apps. If you really want to learn, I would suggest you take some programing classes at your local community college.
cptandroid said:
Not to burst anyone's bubble but I seriously doubt a quick write-up would explain the steps on to creating your own ROM or how to write apps. If you really want to learn, I would suggest you take some programing classes at your local community college.
Click to expand...
Click to collapse
A quick write up doesn't explain it, but equally going to college isn't applicable to rom cooking either.
All the information you need is on the Internet, have a look in this link where the basics are explained, and use google to fill in the blanks ...
http://www.johandekoning.nl/index.php/2009/06/07/building-android-15-build-environment/
The documentation in ASOP recommends Ubuntu for your dev machine (http://source.android.com/download) so familiarity with Linux is essential, also knowing how to use git will save you some time.
Also use the resources in the Dream section in this site. It's been around much longer than the Magic and most dev topics are already covered in a lot more detail than in Sapphire rom development. Above all I think you need a lot of time on your hands and understanding wifes/girlfriends etc as a lot of reading is necessary!
You basically need a Linux distro to be able to do the most modding. Here are the port tools:
http://www.4shared.com/file/122118622/fd190fe1/PortTools.html
Here's a nice quide that you can use as reference:
1. Download the original Nandroid backup of the Rogers-Wiped from Skittleguy (http://forum.xda-developers.com/showpost.php?p=4029461&postcount=4).
2. Unzip Rogers-Wiped.zip and move boot.img to a directory called "Org".
3. Download nk02ion_r4_LITE-signed.zip and upzip it to a directory called "nk02".
4. Move boot.img out of the nk02ion_r4_LITE-signed directory into a directory called "temp".
5. Open your Terminal window and navigate to your "temp" directory.
6. Unpack the boot image inside the "temp" directory :
Execute : $unpack-H.pl boot.img
This should give you 2 new files : boot.img-kernel and boot-img-ramdisk.gz
7. Remove boot.img and boot.img-kernel from the "temp" directory by doing :
Execute : $rm boot.img
Execute : $rm boot.img-kernel
You should now have only one file called boot.img-ramdisk.gz in your temp directory.
8. Navigate to the "org" directory.
9. Unpack the boot image inside the "org" folder :
Execute : $unpack-H.pl boot.img
This should give you 2 new files : boot.img-kernel and boot-img-ramdisk.gz
10. Move the boot.img-kernel file from the "org" directory to the "temp" directory.
Execute : $mv boot.img-kernel ../temp/
11. Remove the "org" directory
12. Navigate to the "temp" direcory
You should now have 2 files inside the "temp" directory, boot.img-kernel and boot.img-ramdisk.gz
13. Create a directory called boot.img-ramdisk inside the "temp" directory :
Execute : $mkdir boot.img-ramdisk
14. Move inside the newly created boot.img-ramdisk directory :
Execute : $cd boot.img-ramdisk
14. Unzip the boot.img-ramdisk.gz file :
Execute : $gunzip -c ../boot.img-ramdisk.gz | cpio -i
15. Check that the ramdisk is unpacked :
Execute : $ls -l
You should now see a bunch of files
16. Remove the boot.img-ramdisk.gz file inside the boot.img-ramdisk directory :
Execute : $rm boot.img-ramdisk.gz
17. Navigate to the temp folder and also delete the boot.img-ramdisk.gz file :
Execute : $rm boot.img-ramdisk.gz
You should now have 1 file called boot.img-kernel and 1 directory called boot.img-ramdisk inside the "temp" folder
18. Repack the kernel and ramdisk to a boot.img file :
Execute : $repack-H.pl boot.img-kernel boot.img-ramdisk boot.img
You should now have a new boot.img inside the "temp" directory.
19. Move the boot.img file to the nk02 directory :
Execute : $mv boot.img ../nk02/
20. Remove the "temp" folder.
21. Navigate to the nk02 folder and check that you have 1 boot.img file and 2 directories (META-INF and system)
22. Zip the boot.img and the 2 directories into an nk02.zip file
Execute : $zip -r nk02.zip *
23. Sign the nk02.zip file :
Execute : $java -jar signapk.jar testkey.x509.pem testkey.pk8 nk02.zip update.zip
24. Push update.zip to your SDcard :
Execute : adb push update.zip /sdcard/update.zip
25. Boot the device in fastboot mode.
27. $fastboot boot recovery-RAv1.0H.img
28. Select "Wipe data/factory reset"
29. Select "Apply sdcard:update.zip"
30. Select "Reboot system now"
31. Enjoy nk02ion_r4_LITE on your HTC branded Magic.
Click to expand...
Click to collapse
The above guide shows you how to modify the boot.img and how to sign the updates. That's a good start...
ok this is a dumb question i imagine but how to i sign a zip file? i have already made my rom but it wont work because it says its not signed
thejesster said:
ok this is a dumb question i imagine but how to i sign a zip file? i have already made my rom but it wont work because it says its not signed
Click to expand...
Click to collapse
Here is the thread where signing is explained.
I am no expert, but I managed to use this to modify other ROM's (Adding wallpaper, ringtones and removing apps etc.)
Signing made easy thread

(How to) unpack/repack boot.img using terminal apk

This is a tutorial I've decided to put together as I'm learning to compile kernels. It will cover unpacking and repacking a boot.img and/or recovery.img, and also touch on unpacking the ramdisk after we have unpacked the boot.img This tutorial will only focus on executing this on a android device using the terminal emulator app but of course you could use these tools on a PC in a adb shell.
This would not be possible without the hard work of xda member @Modding.MyMind. I am not responsible for anything you do to your device by using these tools.
What you will need
1. Android device
2. Have root
3. Have busybox installed (1.23.1 is recommended)
4. Terminal Emulator app
5. Root Explorer app
6. Your devices boot.img and/or recovery.img
7. mkbootimg_tools-master.zip (download below)
https://www.dropbox.com/s/fiat0zrf2f533uq/mkbootimg_tools-master.zip?dl=0
DIRECTIONS
1. Let's pull the boot.img we are going to work with using dd. Open your terminal and type su > press enter. Type dd if=/dev/block/platform/msm_sdcc.1/by-name/boot of=/sdcard/boot.img > press enter and now you should see a file on your sdcard called boot.img
2. Place the zip file on the root of your internal sdcard and extract it. You will see a folder called mkbootimg_tools-master and inside that folder you will see 2 folders. One called ARM and one called README.md Now we are going to copy the ARM folder to data/local/tmp and paste it inside of the tmp folder.
3. Now we need to go the ARM folder that you just copied inside tmp and set the permissions to 0777 (rwxrwxrwx) and also set the same permissions for each file inside the ARM folder.
4. Now go inside the ARM folder and copy the bash file to system/xbin and set the permission to chmod 0755 (rwxr-xr-x)
5. Ok now copy the boot.img file that we pulled onto your sdcard inside the ARM folder and leave the permissions for that file 0666 (rw-rw-rw-)
6. Open up your terminal emulator app and type su > press enter
7. Now we are going to change directories to the ARM folder which we want to be in by typing cd data/local/tmp/ARM > press enter
########################################
Now to unpack your boot.img
1. Type ./mkboot boot.img bootfolder > press enter and you will see the magic happen. It will automatically create a folder called bootfolder which is your project folder and you can name it whatever you like but I like to call it bootfolder and if I was unpacking a recovery.img I would call it recoveryfolder
2. So now you have your unpacked boot.img.
3. Now go to your terminal and type cd bootfolder > and press enter. We are going into your bootfolder now because that is where your ramdisk.gz is located and we are now going to decompress your ramdisk by typing gunzip -dc ramdisk.gz | cpio -i > and press enter and it will decompress your ramdisk for you.
4. So now you have unpacked a boot.img and also learned how to decompress your ramdisk.
########################################
How to decompress a ramdisk in lzma format
1. ./mkboot recovery.img workfolder
2. cd workfolder/ramdisk
3. Now type lzma -dc ../ramdisk.lzma | cpio -i; strings *.ko
4. Now you will have your lzma compressed ramdisk inside your workfolder
#######################################
Now we are going to repack your boot.img
1. In your terminal type cd .. > and press enter so you will move back 1 directory into your ARM folder.
2. Now to repack you are going to type ./mkboot bootfolder boot.img > and press enter and that will repack your boot.img for you
*wherever you saw me type a > don't ever type that as I was just showing that you are done the command or syntax and your are ready to press enter
Source code https://github.com/ModdingMyMind/mkbootimg_tools/commit/6c44267b4a8a43504c870678c68df6a31b8e2f18
Screenshot - https://www.dropbox.com/s/se171tzgnf6wp0q/Screenshot_2015-03-12-02-49-50.png?dl=0
Screenshot - https://www.dropbox.com/s/5bzt8p6l2ltosl6/Screenshot_2015-03-12-02-50-04.png?dl=0
Thanks to @leonardoafa for being a great help & friend
How different is it for a recovery image file please?
Is the same, just put your recovery.img in the ARM folder and you might want to call your project folder something different than bootfolder (ex; recoveryfolder) so you don't get confused or forget
Oh yes, however ramdisk folder is empty when you use only a recovery image. Less content of course.
image45 said:
Oh yes, however ramdisk folder is empty when you use only a recovery image. Less content of course.
Click to expand...
Click to collapse
When i use twrp everything is working perfect. Your ramdisk is probably in a lzma format I'm guessing
As you can see im inside of my ramdisk folder, which is inside my recoveryfolder
https://www.dropbox.com/sc/ffyy2ndrkl57hn4/AACV__FpJuScCvIvErx2WFffa
@image45 i added how to decompress a ramdisk in lzma format to the op
Nice guide :good:
Yes very detailed, thank you.
@skulldreamz
Hi my friend, do you still want to learn about scripts.
Please go to telegram app.
Thanks
@image45 can you sendme your image that uses a lzma compressed ramdisk. The project supports lzma so there should be no need to decompress it manually however, if the project is not doing what it should already be doing then I need to debug the script, find the culprit, make my fix, and push the changes to my github. Would be greatly appreciated. Thanks.
app
Hy,
I use this app for long time to open boot.img and extract ramdisk.
The app asked then if you want open the ramdisk also.
Only click on your boot.img and in 4 sec its open.
Second function is to pack a boot.img.
Very simple to use, also for beginners.
konsolen said:
Hy,
I use this app for long time to open boot.img and extract ramdisk.
The app asked then if you want open the ramdisk also.
Only click on your boot.img and in 4 sec its open.
Second function is to pack a boot.img.
Very simple to use, also for beginners.
Click to expand...
Click to collapse
It only decompresses gzip ramdisks. Doesn't support other types unless you modify the ramdisk.sh script used inside the apk. It also doesn't support images with dt binaries which is more common nowadays. I use to use this a long time ago but to say it simple, it is outdated and lacks support.
However, if it works then I say use it. Especially if the person isn't comfortable with command lines.
Very helpful thx
Thanks
Sent from my SAMSUNG-SGH-I747 using Tapatalk
I see this is an older thread but tried it on my Nexus 6p. When I repacked boot it was significantly smaller in size. It also has the warning of non standard address. Anything I should do or be aware of?
Fe Mike said:
I see this is an older thread but tried it on my Nexus 6p. When I repacked boot it was significantly smaller in size. It also has the warning of non standard address. Anything I should do or be aware of?
Click to expand...
Click to collapse
Try using mkboot....
https://github.com/xiaolu/mkbootimg_tools
The Sickness said:
Try using mkboot....
https://github.com/xiaolu/mkbootimg_tools
Click to expand...
Click to collapse
Thank you, bare with me as Im fairly new to this. Just to be clear, when i go to link there is the ARM folder that has all the same stuff in it or the single mkboot file thats 9.46mb in size? Not sure how to download just the mkboot file. When i click it, it just opens up the code. Do i copy and paste the code?
Fe Mike said:
Thank you, bare with me as Im fairly new to this. Just to be clear, when i go to link there is the ARM folder that has all the same stuff in it or the single mkboot file thats 9.46mb in size? Not sure how to download just the mkboot file. When i click it, it just opens up the code. Do i copy and paste the code?
Click to expand...
Click to collapse
You have to clone the source using "git clone" in your terminal. Which means you need to be on Linux
The Sickness said:
You have to clone the source using "git clone" in your terminal. Which means you need to be on Linux
Click to expand...
Click to collapse
Ok, I was able to clone using cygwin. But i was reading in the forums that the size of extracted boot from phone will not be the same as it being repacked. So I used original files from this post and and just extracted, unpacked, and repacked. Then just flashed img thru twrp and everthing went well. Thank you for your response.
SHM said:
It only decompresses gzip ramdisks. Doesn't support other types unless you modify the ramdisk.sh script used inside the apk. It also doesn't support images with dt binaries which is more common nowadays. I use to use this a long time ago but to say it simple, it is outdated and lacks support.
However, if it works then I say use it. Especially if the person isn't comfortable with command lines.
Click to expand...
Click to collapse
Why haven't you made something like this, he's just using someone else's tools, please MMM, you're the man

How to unpack and repack boot.img full guide by Jai Sharma

How to unpack and repack boot.img
For Windows user
1. Download CarlivImageKitchen from here http://forum.xda-developers.com/attachment.php?attachmentid=3798926&d=1467275078
all credit goes to bluefirebird http://forum.xda-developers.com/member.php?u=5186178
2. extract it using 7zip or similar program
3.. Put your boot.img in boot-resources folder
4. Double click carlive batch file
now select B and Enter
Now choose your boot.img and enter
5. To unpack it type 1 and Enter
that's it. now you can find extract boot.img in boot folder. type enter for continue and keep this window open if you want to repack it again after
making change in boot folder
edit your files in boot folder and for repacking it again keep reading
Repacking
type 2 for repacking
now you can find you new boot.img in output folder
For Linux user
i am using ubuntu as my linux machine
1. Download Boot.img Tool from here https://github.com/jsharma44/bootimg-tools
2. cd bootimgtools
Type following in terminal
./unpackbootimg -i "boot.img path"
For example
./unpackbootimg -i /home/user/Desktop/boot.img
find your files in bootimgtools
I hope you like it. Please visit my website http://azodik.com/ for more interesting guide
Thank You
Extracting boot.img from your device
Extracting boot.img from your device
What we need
1. A rooted phone
2. Enable Usb Debugging in Developer Mode
3. ADB command knowldge
connect your phone via usb cable ensure that usb debugging is enabled
open terminal and type adb devices
if it is showing your device’s serial no than we are ready to go
C. type
adb shell
su
ls -l /dev/block/platform/mtk-msdc.0/11230000.msdc0/by-name
please note this command may vary by device to device. What we are doing here we want to know partition scheme of your device.
note down block name of /boot partition
example it will be like boot -> /dev/block/mmcblk0p7
d. type this
dd if=/dev/block/mmcblk0p7 of=/sdcard/boot.img
now boot.img succesfully transfered to your SD card Copy it to your Desktop
How To Extract System Folder From Android device
1. Connect your phone to computer with USB debugging enabled
2. Type following command to check
adb devices
if it is showing your device's serial no then go to step 3. If not then make sure drivers are installed for your device.
3. To pull system folder use following command
adb pull system
it will pull system folder to your current adb directory. If you want to pull it to some specific directory use following command
adb pull system "output directory"
Example
1. adb pull /system C:/Users/user_name/Desktop/ (For Windows)
2.adb pull /system /home/user/Desktop (for linux)
Your link to Windows zip is no longer there. Getting a 410 error
ianmb said:
Your link to Windows zip is no longer there. Getting a 410 error
Click to expand...
Click to collapse
link updated..Please check now. Thanks for pointing out it
jai44 said:
How to unpack and repack boot.img
For Windows user
1. Download CarlivImageKitchen from here http://forum.xda-developers.com/attachment.php?attachmentid=3798926&d=1467275078
all credit goes to bluefirebird http://forum.xda-developers.com/member.php?u=5186178
2. extract it using 7zip or similar program
3.. Put your boot.img in boot-resources folder
4. Double click carlive batch file
now select B and Enter
Now choose your boot.img and enter
5. To unpack it type 1 and Enter
that's it. now you can find extract boot.img in boot folder. type enter for continue and keep this window open if you want to repack it again after
making change in boot folder
edit your files in boot folder and for repacking it again keep reading
Repacking
type 2 for repacking
now you can find you new boot.img in output folder
For Linux user
i am using ubuntu as my linux machine
1. Download Boot.img Tool from here https://github.com/jsharma44/bootimg-tools
2. cd bootimgtools
Type following in terminal
./unpackbootimg -i "boot.img path"
For example
./unpackbootimg -i /home/user/Desktop/boot.img
find your files in bootimgtools
I hope you like it. Please visit my website http://azodik.com/ for more interesting guide
Thank You
Click to expand...
Click to collapse
Your link no longer exists. I want to download the software to Windows. I would love for you to update the link. Thank you!

Power on the phone when charging

I bought a Lenovo Yoga tablet with android 6.0.1 and I want to use it only for PC hardware sensors. I want to power it up when my pc starts. I found some methods to do this but I can`t find these files on "/system/bin/" playlpm, ipod, lpm etc.; fastboot oem off-mode-charge 0 is not working. Anyone has a working solution please?
edit: found a rom that had kpoc_charger and ipod file inside /system/bin/ . They had in common charging word and some others. I copied all my files from /system/bin/ to PC and opened all of them with notepad++. I search those words on my files and I haven`t found any. So there is no file in bin folder that have any relation with charger or battery animation file on Lenovo YT3-850F android 6.0.1. WTF GOOGLE ?
edit: after some research and I don`t remember how many google pages and searches I found that you can achieve this function using:
1. Enter Fastboot Mode (adb reboot bootloader)
2. Enter Command: fastboot oem off-mode charge 0
3. Enter Command: fastboot reboot
if that is not working for you maybe this one will work:
1. search in /system/bin/ for playlpm, ipod, lpm, kpoc_charger or any other file that have inside some reference to battery animation.
2. edit that file, delete all content inside and add
#!/system/bin/sh
/system/bin/reboot
if that is not working you can try this:
1. Unpack boot.img and edit init.rc.
2. Add following to the end of file:
#Check if chargermode and start autoreboot service.
on property:ro.bootmode=charger
start autoreboot
#autoreboott service which command reboot
service autoreboot /su/bin/su /system/bin/reboot -c reboot now
user root
oneshot
3. re-pack boot.img
None of that worked for me but I had an idea. Why not just create that damn file inside /bin ???
1. unpack boot.img
2. edit > ramdisk > init.target.rc (your file may have a different name then mine but search every file for "on charger" word using notepad++ and when you see that below that line are some "start" services you found it)
3. add start kpoc_charger below "on charger" line *** "kpoc_charger" can have any name be free to name it ***
4. add after:
service kpoc_charger /system/bin/kpoc_charger
class charge
5. create kpoc_charger file on root/system/bin/ with 755 permissions using any root file managers
6. edit file and add:
#!/system/bin/sh
/system/bin/reboot
Have fun and enjoy this.
Did you have to remove dm-verity to get this to work?

Categories

Resources