Since We have such a fantastic tutorial on how to build your own CM9, I thought I'd add one for building a kernel.
Edit: updated kernel sources for jellybean
First off:
You NEED Linux. DO NOT TRY THIS ON WINDOWS, IT WON'T WORK.
Sources: https://github.com/freexperia/semc-kernel-msm7x30-ics
https://github.com/DarkforestGroup/sony-kernel-msm7x30-ics
https://github.com/DooMLoRD/Xperia-2011-Kernel-2.6.32.9
http://forum.xda-developers.com/showthread.php?t=1556971
http://forum.xda-developers.com/showthread.php?t=1477845
http://developer.sonymobile.com/wp/2011/05/06/how-to-build-a-linux-kernel/
DooMLoRD, KeiranFTW & Atarii.
Prepping:
1) Grab the toolchain I have here (Android NDK R5b), it's the only one I've been able to use that doesn't throw errors when compiling: http://db.tt/hE3TmJJi Doom has provided a better toolchain https://github.com/DooMLoRD/android_prebuilt_toolchains[/QUOTE] you can get it using
Code:
git clone https://github.com/DooMLoRD/android_prebuilt_toolchains.git -b master
(thanks Doom!!)
Building a kernel from fxp sources
1) Terminal for any commands, file explorer for finding stuff & gedit for changes.
2) open up terminal, mkdir (no spaces)
3) cd
4) git clone https://github.com/CyanogenMod/semc-kernel-msm-7x30 -b jellybean (no spaces)
5) cd /semc-kernel-msm-7x30-ics (if you didn't rename it)
6) (If this is after the first time, and lets say a week has past do this step, otherwise ignore) git pull (automatically updates any files)
7) First important step: Find the defconfig that fxp uses. They are located in arch/arm/config. fxp_zeus_defconfig is the name of theirs
8) copy fxp_zeus_defconfig & rename to _zeus_defconfig (for example, mine will be pax_zeus_defconfig)
9) open up your defconfig & put it into another workspace, we'll mess with it later
10) Hop onto DooMLoRD's github, his we'll use for references.
11) Adding governors: https://github.com/DooMLoRD/Xperia-...mmit/bec19001ded34077d7776639834a1229b69e5f87
A1) Well, as I look into this, fxp has a ton of governors not used... (located in /drivers/cpufreq/
A2) Check the Kconfig file to see that they're all in there (they must just not be in the defconfig file)
A3) Edit the deconfig file you created in lines 467-474 removing "#" from any you want to add (and add in any you might've added by adding the line CONFIG_CPU_FREQ_GOV_=y
A4) If you want to add more governors, check out the Commits from DooMLoRD's build to add in when needed (anytime you see a "+" that means line added, "-" means line deleted)
12) Adding IO Schedulers: https://github.com/DooMLoRD/Xperia-...mmit/0ae625f7561c559d4933284f489733bf5eb66e96
B1) Navigate to /block folder
B2) Once again, FXP has a ton of IO Schedulers added, but not used in Play kernel:
B3) Open up Kconfig.ioshced to make sure they're in there (and add any you want)
B4) Edit the defconfig file you created (lines 121-137) & fix it to your liking (same as above)
B5) If you want to add more, see Doom's commits to add 'em
13) Turning off ALS
C1) Navigate to /arch/arm/mach-msm
C2) Open up board-semc_zeus.c
C3) Search for .als_connected (it on line 1349)
C4) Change the variable from 1 to 0
14) Overclocking
D1) open up arch/arm/mach-msm/acpuclock-7x30.c
D2) Lines 96 - 144 contain the PLL2 table, which is used to set clock speeds, note FXP can go all the way up to 2ghz, they just stop it short.
15) Building the Kernel
E1) Save your defconfig file, you'll need it now.
E2) naviage to folder (in terminal)
E3) Type in "ARCH=arm CROSS_COMPILE= ../ramdisk.img
F17) cd ../
17) Putting the ramdisk & kernel together
G1) By now (hopefully) the kernel is done compiling. (time for terminal, you should still be in folder you were above)
G2) cp ~//arch/arm/boot/zImage ./
G3) mkbootimg --base 0x00200000 --kernel zImage --ramdisk ramdisk.img -o .img
18) Flashing it for testing.
H1) Keep your copy of FXP's kernel around, just in case any issues happen
H2) fastboot boot .img
H3) If it boots & works, SUCCESS!! you modified your own custom kernel!
H4) If it doesn't boot (at all, just a vibrate & blank screen for 10-20 seconds) there's a problem with the ramdisk, sometimes it's bad, sometimes is needs filler, overall, it's just a pain in the butt to figure out.
H5) If it boots & bootloops the splash screen, well, that's an issue with the ramdisk again, that possibly, your ramdisk does not match you rom. Recovery, reflash rom & try again.
Courtesy of Atarii reminding me
19) Adding your wifi modules (they get built when you build the kernel) into the ramdisk
I1) Let's pretend that you haven't gotten through step F16, we're gonna add the wifi modules in.
I2) The wifi modules are located in /drivers/net/wireless/
I3) Copy bcm4329.ko to ~/ramdisk/working/modules/
I4) Add in the following lines to init.semc.rc
Code:
#load bcm4329 module
insmod /modules/bcm4329.ko
I5) Now your modules will autoload on boot!
Pax
hi my guys
i've a silly question! coz im a Noob
lemme explain what is my mean:
custom kernels supports init.d and we can create own tweaks and save these files into init.d directory,
for example this one :
vm.dirty_ratio=20;
i found dirty_ratio in /proc/sys/vm/dirty_ratio.
but when i open this file with text viewer , i see another value for this parameter!
like this : 35
and other parameters that we can write in initd tweak files!
every time i change values , when i open original file in /proc/sys/vm/ i see constant values! ( for example 35 for dirty_ratio )
i think ROM or some apps control this parameter!
it means if we change this parameters for customization , we cant see any changes!
emmm , jelly sandwich - maxio made - custom rom control this parameters??????
or you have same problems with all ROMS???????
or this is a common situation??????
sorry for poor english!
My Device : Xperia Ray
ROM : Jelly Sandwich 8.5
Kernel : Advanced Stock.587
Unlocked , Rooted!
Maybe the init.d script not properly created..init.d script must have execution lines in the script and # symbol.
Sent from my gorgeous ST18i
yamin8000 said:
hi my guys
i've a silly question! coz im a Noob
lemme explain what is my mean:
custom kernels supports init.d and we can create own tweaks and save these files into init.d directory,
for example this one :
vm.dirty_ratio=20;
i found dirty_ratio in /proc/sys/vm/dirty_ratio.
but when i open this file with text viewer , i see another value for this parameter!
like this : 35
and other parameters that we can write in initd tweak files!
every time i change values , when i open original file in /proc/sys/vm/ i see constant values! ( for example 35 for dirty_ratio )
i think ROM or some apps control this parameter!
it means if we change this parameters for customization , we cant see any changes!
emmm , jelly sandwich - maxio made - custom rom control this parameters??????
or you have same problems with all ROMS???????
or this is a common situation??????
sorry for poor english!
My Device : Xperia Ray
ROM : Jelly Sandwich 8.5
Kernel : Advanced Stock.587
Unlocked , Rooted!
Click to expand...
Click to collapse
You can check your init.d scripts with script manager (or something similar) before you jam them into the init.d folder. This way you can test them with out having to reboot your device. There is a pretty good tut for init.d from irridaki here: http://forum.xda-developers.com/showthread.php?t=1422061 It is mostly for getting init.d to work on stock roms...but it should work on custom roms as long as there is init.d support....
to change a value in /proc you have to use:
Code:
echo [I]value[/I] > /proc/[I]path/to/file[/I]
so in your case it's
Code:
echo 20 > /proc/sys/vm/dirty_ratio
Haaop said:
to change a value in /proc you have to use:
Code:
echo [I]value[/I] > /proc/[I]path/to/file[/I]
so in your case it's
Code:
echo 20 > /proc/sys/vm/dirty_ratio
Click to expand...
Click to collapse
thnx man
yes, i saw this pattern for setting values to parameters
ill check it plus will tell u the feedback
Can someone explain how init.d support is implemented in CyanogenMod? Link to the relevant github source file/files would be the best.
Is is supported for all devices automatically or a special section (something like busybox run-parts) needs to be added to init.rc file in android_device_<VENDOR>_<NAME> repository?
If anyone interested I think I found the answer to my question:
In a device specific init.rc (e.g. https://github.com/CyanogenMod/android_device_sony_montblanc-common/blob/ics/config/init.rc) there is usually a call to sysinit:
Code:
exec /system/bin/sysinit
and sysinit is a script that runs run-parts: https://github.com/CyanogenMod/android_vendor_cm/blob/ics/prebuilt/common/bin/sysinit
THIS IS A SCRIPT TO HAVE SWAP AND NOT A ROM!
I tested the swap on "CM10.x" by volk204 but there isn't a reason it shouldn't work on other rom versions.
version 1.0 13/11/2013 18:29 GMT+2
I experienced some lag with my wave due to its low ram memory. So after testing a few things i found myself more comfortable with setting up swapfile on sd card(NAND memory); after few minutes this terminal becomes really smooth. (It strangely is faster than setting it up on the phone memory, atleast for me)
The idea is mine, but checking around i found that many other script were made. I got the sleep line to boot part idea from "Defiant07 @ XDA" (http://forum.xda-developers.com/showthread.php?t=2359182). Everything else (as simple it is it's all mine)
Swap is the *nix term for virtual memory, that maybe many are familiar with on windows.
You set up a partition/file and use that as virtual memory. It will be much slower than real ram, but it will be much faster than reloading everything from disk everytime.
Code:
#!/system/bin/sh
# This script was authored by Defiant07 @ XDA. If you use/redistribute it, eve$
# Thanks to zeppelinrox most of all, but also many thanks to dk_zero-cool & gu5$
# Much thanks to pikachu01 @ XDA for permission to use the sysctl tweaks from T$
# Read Karl Marx!
# Nearly entirely modified by skyglow
swapfile="/storage/sdcard0/swapfile"
#swapsize in KB
swapsize=524288
swappiness=90
vfs_cache_pressure=100
dirty_background_ratio=5
dirty_ratio=20
dirty_writeback_centisecs=500
dirty_expire_centisecs=200
while [ ! "`ps | grep -m 1 [a]ndroid`" ]; do sleep 10; done
if [ ! -f "$swapfile" ]; then
dd if=/dev/zero of=$swapfile bs=1024 count=$swapsize
mkswap $swapfile
fi
# sleep 30
# mkswap $swapfile
swapon $swapfile
busybox sysctl -e -w vm.swappiness=$swappiness
busybox sysctl -e -w vm.vfs_cache_pressure=$vfs_cache_pressure
busybox sysctl -e -w vm.dirty_background_ratio=$dirty_background_ratio
busybox sysctl -e -w vm.dirty_ratio=$dirty_ratio
busybox sysctl -e -w vm.dirty_writeback_centisecs=$dirty_writeback_centisecs
busybox sysctl -e -w vm.dirty_expire_centisecs=$dirty_expire_centisecs
exit 0
Requirements
Superuser rights on terminal to change permission and copy this file
Configuration
1) set up "swapfile" field to where you want your swap
2) set up "swapsize" field to an appropriate value in KB! ( i think you should try values over 307200 => 300MB to have performance improvements)
(SD or NAND version)
SD version
size=512 MB
position=sdcard root
NAND version
size=300MB
position=bada application partition
How to install
1) Download the right zip from this page
2) Extract the file from the zip
3) Upload the file in some way on the phone
4) Become superuser
5) move it to "/system/etc/init.d"
6) this file should keep hits name "99myswap"
7) change permissions of "99myswap" to 755
8) change its rights to "root:shell"
9) done, next reboot your swap will be set up automatically
P.S.
How to check if swap is activated:
Open terminal
cat /proc/swaps
Swap filename should be displayed with the right size
[ADDED DEBUG SCRIPT]
Possible problems
1) System hangs on cyanogen loading screen ( rotating circle)
INVESTIGATING
2) Battery charge lasts less.
Any kind of virtual memory use more electrical power to perform write/read on disk (SD). This is a side effect of swap.
3) File format
*NIX file format is LF and not CR-LF (for reference why this happens http://en.wikipedia.org/wiki/Newline#Representations)
You can't edit the file with windows notepad, but use something else such as notepad++ and save it in LF coding.
4) System is slower
Possible causes are:
a) you have applications on the same filesystem where you placed the swap
b) your memory (such as SD card) is too slow. Swap will work, it will just go much slower. Try it with a better sd. I tested it with a class 4 and class 10 sdcard and they both speed up. I don't have any possibility at the moment to test a class 2. (reference http://en.wikipedia.org/wiki/Secure_Digital#Speeds)
5) How to change permissions (thanks Eltjo for copy paste from your answer)
Open terminal
Type: su
Type: cd /system/etc/init.d
Type: chmod 0755 99myswap
Type: chown root:shell 99myswap
6) zRam
On my mobile it's faster if i disable zRam from Settings > Performance > Memory Management > zRam .
Anyway i think outcome may change. Try both solutions.
could be possible to use free nand memory as swap instead of sd card?
cfernr said:
could be possible to use free nand memory as swap instead of sd card?
Click to expand...
Click to collapse
I added the NAND version that installs itself in the bada partition. If you installed the sd version remember to remove the swapfile.
darklight2k2 said:
I added the NAND version that installs itself in the bada partition. If you installed the sd version remember to remove the swapfile.
Click to expand...
Click to collapse
lets try both, thank you very much
no problem.
DEBUG REQUEST
Who had the loading screen on cyanogen circle may tell me which sd card class have?
The following procedure do not install the script, it just will work till reboot.
may them try to upload the script in a generic directory such as /storage/sdcard0 and execute it with
su
cd /storage/sdcard0
sh ./99myswap
I'd like the output of that command and the resulting /proc/swaps
then use the phone, (play/call/charge/reboot)
next boot start the script again please and tell me the resulting /proc/swaps again
Thank you for the help
seems work on my phone.
installed swapfile on nand and ram increased 30mb, but low improvement in real performance.
need to change zram options, but cant find this on my phone, maybe due to language discrepancy. can you explain better?
thank you a lot
I also cannot find zram a options under B.U.X V3.1 (4.3.1 CM10.2) by Tigrouzen
If you don't have the menu for zRam it's disabled by default. To see it you should enable all developer settings.
Settings > About phone > Build number (tap 7 times)
Some more tweaks will unlock.
saltcushy said:
I also cannot find zram a options under B.U.X V3.1 (4.3.1 CM10.2) by Tigrouzen
Click to expand...
Click to collapse
Unfortunally i didn't test that rom yet but i think the procedure above will work.
darklight2k2 said:
If you don't have the menu for zRam it's disabled by default. To see it you should enable all developer settings.
Settings > About phone > Build number (tap 7 times)
Some more tweaks will unlock.
Unfortunally i didn't test that rom yet but i think the procedure above will work.
Click to expand...
Click to collapse
tested and I have to say this is necessary if you want to enjoy a few extra mb in this phone.
I recommend nand swap because everybody have 300-400 unused mb in bada apps partition.
disabling zRAM seems also recommendable.
I hope everybody take care of this script for future ROM releases
*** I will decrease swappiness to 70 or 60, I think it is enough.
darklight2k2 said:
no problem.
DEBUG REQUEST
Who had the loading screen on cyanogen circle may tell me which sd card class have?
The following procedure do not install the script, it just will work till reboot.
may them try to upload the script in a generic directory such as /storage/sdcard0 and execute it with
su
cd /storage/sdcard0
sh ./99myswap
I'd like the output of that command and the resulting /proc/swaps
Thank you for the help
Click to expand...
Click to collapse
i've a samsung class 10 32gb.
i've not run the script with sh command, just copied it to /system/etc/init.d (aplied chmod and chown) and reboot the phone. after that it hangs on CM circle on first boot and have to re-install the rom. wipe data/factory reset didn't help.
best regards
JonasVFC said:
i've a samsung class 10 32gb.
i've not run the script with sh command, just copied it to /system/etc/init.d (aplied chmod and chown) and reboot the phone. after that it hangs on CM circle on first boot and have to re-install the rom. wipe data/factory reset didn't help.
best regards
Click to expand...
Click to collapse
To try to solve it i need to know what happens when executed with the sh command
darklight2k2 said:
To try to solve it i need to know what happens when executed with the sh command
Click to expand...
Click to collapse
after installing the rom again it can boot the first time but hangs on the second like everybody else
running with sh it runs ok
JonasVFC said:
after installing the rom again it can boot the first time but hangs on the second like everybody else
running with sh it runs ok
Click to expand...
Click to collapse
that's why i said not install in the problem request
problem is with chown, just run the chmod 755. didn't run chown command last time and it booted second and third time
edit: nevermind, it hanged again
darklight2k2 said:
that's why i said not install in the problem request
Click to expand...
Click to collapse
i did it with 2 different ways....with a fresh install between and both hang
JonasVFC said:
i did it with 2 different ways....with a fresh install between and both hang
Click to expand...
Click to collapse
You're just posting and posting what happens but not what i asked you to do to five me information.
darklight2k2 said:
You're just posting and posting what happens but not what i asked you to do to five me information.
Click to expand...
Click to collapse
i did what you asked, read again, i ran it with sh: it runs fine!! creates the swapfile and outputs some parameters that are in the script like swapiness and others....
JonasVFC said:
i did what you asked, read again, i ran it with sh: it runs fine!! creates the swapfile and outputs some parameters that are in the script like swapiness and others....
Click to expand...
Click to collapse
Hi, @JonasVFC.
I understand you've been running the Swap version of Android v2.1 Volk204. How do you get it?.
Yo, if I install the file in the directory 99myswap indicating the first page, but I get that the system does not start, stays on constantly CM logo.
A greeting.
chapito said:
Hi, @JonasVFC.
I understand you've been running the Swap version of Android v2.1 Volk204. How do you get it?.
Yo, if I install the file in the directory 99myswap indicating the first page, but I get that the system does not start, stays on constantly CM logo.
A greeting.
Click to expand...
Click to collapse
May you guys try the following attached file please?
when it hangs may you post the logfile created in the phone directory ( you can get it from bada)
Hey Guys.
Don't know were to post this so I did it here...
I'm not an scripting/Unix pro and struggeling a bit with my folloing script:
Code:
FOLDER="/data/system/"
DAT1=$(date --date="$(date +%Y-%m-15) -1 month" +%Y%m)
FILE1="packages.xml-RW-"
FILE2="*.bak"
DELETE="$FOLDER$FILE1$DAT1$FILE2"
echo $DELETE
OUTPUT: /data/system/packages.xml-RW-201609*.bak (but only with UBUNTU)
File format is packages.xml-RW-201610161339144.bak - Bold is just an unusefull number for me....
Goal is to delete (I use for now echo for testing) specific file which having an specific format. I want to delete all files from last month!
So for this month all files containing "packages.xml-RW-201609*.bak"
Obove script is working under UBUNTU but Android has problems with "-1 month".
DATE command (of Android 6.0.1) is not accepting this...
Maybe one of you have a glue?
Thanks for help.
fluffi444 said:
Hey Guys.
Don't know were to post this so I did it here...
I'm not an scripting/Unix pro and struggeling a bit with my folloing script:
OUTPUT: /data/system/packages.xml-RW-201609*.bak (but only with UBUNTU)
File format is packages.xml-RW-201610161339144.bak - Bold is just an unusefull number for me....
Goal is to delete (I use for now echo for testing) specific file which having an specific format. I want to delete all files from last month!
So for this month all files containing "packages.xml-RW-201609*.bak"
Obove script is working under UBUNTU but Android has problems with "-1 month".
DATE command (of Android 6.0.1) is not accepting this...
Maybe one of you have a glue?
Thanks for help.
Click to expand...
Click to collapse
Instead of using a script have you taken a look at Tasker? It can do pretty much everything and scheduling the deletion of files with specific extensions is definitely something it can do. Let me know if you have any additional questions!
Thanks for your suggestion. I know Tasker. But I do not use it anymore. I want to keep the system as clean as possible... Don't like apps running in background all the time...
So only script is the way for me...
Question is still active ?
As it happens quite often I did it for myself But with an a bit different approach because of limited DATE functions of Android.
This set premonth correctly and also year switching to the year before if we are in JAN is working....
Code:
#!/system/bin/sh
FOLDER="/data/system/"
FILE1="packages.xml-RW-"
FILE2="*.bak"
YEAR=`date +%Y`
MONTH=`date +%m`
set -A MTH '12' '01' '02' '03' '04' '05' '06' '07' '08' '09' '10' '11' '12'
PREMONTH=${MTH[$((MONTH - 1))]}
if [ "$PREMONTH" == 12 ]; then
NEWYEAR=`expr $YEAR - 1`
else
NEWYEAR=$YEAR
fi
rm -rf $FOLDER$FILE1$NEWYEAR$PREMONTH$FILE2
#