Announcements

ILLEGAL CONTENT I'd like to just reaffirm MoDaCo's position regarding piracy and illegal content in the light of some recent questions / postings. Posts will be censored by myself or my moderation team if the contain or link to: Illegal / pirated / cracked software or sites that host such softwareNintendo emulators / ROMs or sites hosting them (in light of Nintendo's legal stance)CUSTOM ROMS You may discuss and post links to custom device ROMs on MoDaCo, provided the following rules are adhered to: ROMs must not contain any illegal 3rd party software (this includes trial versions included without permission)ROMs must give full credit to the original authorISSUES If you have any issues with this policy, please contact PaulOBrien directly via PM.

Please note that selling items on the forum directly is not allowed by the forum rules. There is a forum for eBay auctions whereby you can list the items on eBay and link to them there. This is the ONLY forum for this type of activity. You may also advertise links to the eBay forum in your signature. Please note that selling directly in contravention of these rules will result in a warning / suspension / ban.

Kernel Experiment - 4.0 updated 2012.05.28

199 posts in this topic

For those who are adventurous and are willing to try new things to improve your phone, I have produced some binary kernels if you don't want to do the compilation yourselves. Please note these are not for beginners and would require some knowledge and skills to properly set it up. More importantly, although unlikely, it may brick your phone and render it completely wasted. It comes with absolutely no guarantee and no warranty whatsoever. I am not responsible for any damages done. For those who is willing to take the risk, proceed below.

Brief changelog

Not all builds contain all features - see build info for details.

4.0: ae49c12

Lack of time for thorough testing - but hope you enjoy this build.

AHB166 builds have a higher default cpu scaling min frequency to eliminate screen flicker completely - see special instruction below if you need to lower it.

Tuned the default conservative scaling governor so that it will raise and drop frequency much quicker in response to system load changes - a smoother screen refresh is expected but at the expense of more power.

Kexec a.k.a. Never See WinMo Again (Almost). See special instruction below for details.

Fix camera module unloading crash.

Bonus: Not strictly kernel related (though used by Kexec) - a bionic (libc.so) fix that prevents background executed commands from stalling. This fixes apps such as Titanium Backup and AdAway that use su in the background. See special instruction for Kexec.

Download and build info

Modules included within the same package as zImage - IMPORTANT: modules files and zImages from different bundles CANNOT be mixed.

Rearranged memory layout giving either 13/16/32MB more free RAM memory at the expense of 3D (if you don't do any 3D app, 32MB is good for you while 13/16MB versions are safe as far as AB is concerned.)

Some builds are AHB overclocked from 133Mhz to 166Mhz while CPU underclocked from 800Mhz to 666Mhz - this combination (666/166) gives the best memory bandwidth ~25% more than the default (800/133) combo, with the side benefit of better IO and 2D/3D. Since the max voltage applied is even lower than for the original 800Mhz kernel, the risk should be minimal. Some benchmark figures here.

Added Z-RAM - which supersedes compcache/ramzswap, together with Snappy, an extremely fast compression algorithm that gives more RAM by compressing part of the memory and use it as a swap space (~2.6x compression ratio.) I have benchmarked it and it's even faster than swap partition in terms of read/write while still maintaining good interactivity and performance. Benchmark results here - all in MB/s.

24bpp framebuffer (truecolor display) driver - the color gradient banding in the original kernel using 16bpp is very bad - like the dialer grey / blue FB logo page. Using this 24bpp framebuffer will make the display slightly slower but the screen is prettier than ever (even better than WinMo's 16bpp.) See some bad 16bpp sample here.

Full kernel preemption enabled for even better responsiveness, and at the same time HZ reduced to 200 in an attempt to save power.

Backup your original stuff and files that will be replaced in later steps

Download and unpack the corresponding zImage to the same directory where you would start haret.exe.

Cleanup the existing /modules/ directory in your root filesystem, either by deleting all files inside or by renaming the old name and creating a new one.

Download and unpack the corresponding kernel modules (kmod) and unpack the files to the /modules/ directory in your root filesystem.

Observe any build specifc info in their respective post.

[*]Follow the below special instructions if applicable to your build.

[*]Start your OS, and profit.

Special Instructions for Kexec (4.0 or above)

[*]Kexec is a linux kernel mechanism that allows you to load and execute another kernel while the original one is still running. In other words, you can reboot your current linux session without having to go back to the Samsung bootloader or the WinMo layer altogether. It saves time, ease kernel development work, and can also trick others into believing your phone has a built-in or NAND-flashed Android -- only if you never shut it down and do a full restart.

[*]To enable Kexec, follow these steps:

[*]Backup to offline storage every file that you are going to change or replace in the following steps.

[*]Insert the following line into your /init.rc: "setprop haret.kernel /sdcard/zImage" - adapt it accordingly if you zImage is located elsewhere. EDIT: The new line must be placed BEFORE the "class_start default" line.

[*]Download and extract kexec from here, framework.jar and libc.so from here

[*]Drop kexec it to /system/xbin of your phone.

[*]On a terminal, adb, or from an appropriate app, do a "chown 0:1000 /system/xbin/kexec"

[*]In the same session do a further command: "chmod 4554 /system/xbin/kexec"

[*]Drop and replace libc.so in /system/lib - WARNING: copy the file and overwrite the original in one go (do not delete or rename the original first) or otherwise your android might crash immediately and won't boot anymore.

[*]Clear dalvik cache - perhaps you might get lucky that it might be auto cleared during reboot due to dependency checking, so you might want to try rebooting first.

[*]Get yourself a cup of coffee - it will take some time to re-generate the caches - even longer than your first boot after new installation!

[*]Optional: add "panic=5" in your list of startup.txt cmdline parameters so that it recover from boot time kernel faults automatically. Reboot afterwards to activate it. EDIT: Copied from below to a more prominent place here.

[*]From now on, when you choose reboot (REMEMBER to unplug from USB first), it will recycle your phone immediately to the "Android on Omnia II Loading" screen after some shutting down business. If it fails somehow, you still get normal reboot. And if you choose Recovery reboot, you will force normal reboot, probably because you are missing WinMo :-)

[*]For those who don't want to mess with system files like libc.so or framework.jar (but you really should - see why below) or just want to test it first, adapt and run the following script as root instead: EDIT: The quotation marks are extremely tricky to differentiate and to type - you may want to download a script here instead.

[*]Bugs to be hunted down: kexec'ing a new kernel while USB is connected is a definite no-no. It triggers some hidden kernel bugs that won't normally show up, and would cause the kernel to panic at the initial stage of hardware initialization. I recommend adding "

panic=5" in your startup.txt cmdline parameter so that it will recover and reboot automatically. Also avoid kexec'ing a new kernel that has different cpu / ahb frequencies - though it will boot, the max freq might be capped somehow and I am still looking into it.

[*]The

framework.jar incorporates my previous fix for calling waiting, together with necessary code that calls the kexec binary when shutting down. The libc.so contains a fix that externally called programs, especially called from inside Android apps, would not get stuck in the middle and not starting. This also solves the problem of apps such as Titanium Backup being stalled in the middle of a long running backup job. No-frills. But then, if you don't use Kexec, you can skip all these files together, the kernel itself runs fine without them (of course with the obvious exception of the corresponding modules.)

[*]Troubleshooting Kexec Installation - if it reboot to WinMo:

[*]You can verify by manually running a reboot script above. If it does not work and just spits out error messages, then recheck steps 1 - 6.
[*]If it does work via manual script but not in Android UI, check steps 9 - 11.
[*]If the Android UI displays rebooting but is stuck there forever without actual reboot, check steps 7 - 8.
[*]If the manual script / Android UI is rebooting, but abruptly sends you back to the Samsung bootloader (and then inevitably WinMo)

after a very brief display of the grey Android on Omnia II splash screen, disconnect your USB cable before performing the reboot ops.

[*]A small development note to self and those interested, the kexec binary is compiled straight from

[*]In normal non-AHB 166MHz builds the lowest frequency offered is 66MHz but is almost never - the active minimum freq is 133MHz - and with very good reasons to: the lowest frequency is too low that there's screen flicker or banding or whatever you wish to call it, and audio with static sounds.

[*]The 4.0 AHB166 builds have tweaked memory QoS settings together with cpu governor settings, so it most cases it won't have the above problems even running in 83.25MHz and under normal load. However, to give users the best experience, I've decided to make 166.5 the default just like what the original kernel did.

[*]But if you want the absolute minimum to save battery juice, you can do either:

[*]Method 1: use apps like SetCPU or Method 2: add the following line to /loadmod after all the insmod statements:

[*]Tune the parameters such as SIZE and fudgeswap as wish - default is somewhat extreme but does demonstrate how your aging phone can do multitasking - it can bring you an extra 100MB of memory using around 30-40MB of real one.

[*]You may also tune the other mm parameters - my set of stress testing params are as follows:

[*]Try it by running it either via an ADB shell, terminal, or scripting app such as SL4A - it should disable the original swap partition and added itself to the swap space. Note the difference in swap total when running the free command.

[*]If it's successful, you can hook the script up as a shortcut on your home screen via SL4A, or you can also do a init.rc service like this to make it start automatically when your OS boots:

[*]

service zram /bin/bash /zr
user root
# disabled
oneshot

Edited 1 Jun 2012 by ipaq3870

5

Share this post

Link to post

Share on other sites

Some have problem getting phone service in its first boot - try 2.0 builds to see if it works. It never occurred to me - so if the new ones still do not work, post a dmesg output. For instructions, follow this.EDIT: no longer happen since 2.0.

Boot animation showing white squares - the animated images of the current boot animation set is too big. When freeing the last bit of memory, some 3D memory was sacrificed, and thus the white squares. The workaround is to use a smaller version of boot animation. Some good ones can be found here. Just remember not to download the MDPI version for which the logo would appear smaller in your screen.

3D apps might show white squares or white background depending on which memory versions you are using. Choose a smaller memory version if that's the case.

Static sound during music play / screen flickering in low frequency. This is mostly caused by full kernel preemption. Workaround by setting a higher minimum frequency for your frequency scaling governor. For a detailed discussion and howto see this.EDIT: no longer happen since 4.0.

It was not too possible to multitask while keeping too many apps residing in memory. With this kernel, you can do serious multitasking. That said, when you have too many apps in memory, it will sometimes trigger Android bugs that cause it to be restarted (not the phone itself). If you find your phone not responding, wait for 1 minute as it is probably reloading itself before pressing the kill key combo or pulling out the battery.

Plugging in the USB while booting up may cause the system to hang at the logo splash screen (before the boot animation). I believe I have fixed some USB boot up bugs, but one related to the voltage regulator still evades me.

When using a CPU underclocked version, the vibrator is less powerful.EDIT: vibrator hotfix for 4.0 is here.

Development Issues

kexec is in the kernel, but it boots only 50% of the times or less, probably only on 800Mhz/133Mhz non-OC'ed kernels. I attach the kexec executable in case someone might want to have a look at it. EDIT: almost 100% working since 4.0.

Tips

For normal use, I'd suggest this lowmemkiller value, which would kill tasks more often but help to prevent the condition that too many in memory apps that could trigger Android bugs and reload the whole OS. This way, you don't have to restart your phone every day.

Also, if you are using LauncherPro, the 3D drawers is actually much smoother than the 2D one: Settings->Launcher Settings->Advanced Settings: Use 3D drawer

This is perhaps the most important one: don't use task killers - it's at best wasting time if not slowing it even further. Killed process can restart automatically after few seconds. Use Autostarts instead: you can stop anything from starting in the first place. Stop those which starts when the phone during boot, after boot, change in network connection status, change in background data setting, power plug in/disconnected, media inserted/new picture, app installed/removed, so on and so forth. Of course you keep what you need - don't just close your eyes and disable everything. My phone is completely usable immediately after it displays the home screen. I used to wait for two minutes or three before it could even start making a phone call.

Not strictly for my kernel - but this piece might be useful to someone who want to understand and troubleshoot wifi issues.

I have written a log multiplexer script that enable anyone to collect debug logs very easily, and it can be downloaded here.

Troubleshooting

[*]Set up and use the app kill key when an app appears to have hanged: Seetings->Applications->Development->Stop app via long-press.

[*]If the phone still seems hanged, wait for 30 seconds to 1 minute to see if Android is reloading itself. If it's the case, then you'd probably hit an Android bug. A logcat would supposedly help.

[*]If it doesn't reload automatically even after waiting, use the kill key combo to restart phone: press the power button a few times, and then press VolDown+Back+Menu (was Hold+VolUp+Camera before 3.0). It will hard restart your phone. After restart, get /proc/last_kmsg which is the kernel message log of the crashed session to see what went wrong.

[*]For sleep related kernel problems, you may need to add "no_console_suspend" to startup cmdline for a more complete kernel log.

[*]If it doesn't work, pull out the battery is the last resort, and it's still worth trying to see if you can get a last_kmsg.

[*]Autoreboot the phone in case of kernel panic is also a good idea for a fast recovery. Add something like this in your init.rc below, and/or add a panic=5 to your kernel startup command line.

[*]

write /proc/sys/kernel/panic_on_oops 1
write /proc/sys/kernel/panic 5

[*]Hardware watchdog is enabled in the kernel - you can use this to auto-restart a hanged phone cause by kernel failures (but not sleep related problems after the phone went to SLEEP mode.) Add the following snippet to init.rc and unpack the attached file in /system/xbin/ and chmod +x /system/xbin/watchdog_test

EDIT: the line "oneshot" should be removed to auto-restart the watchdog if case of it being killed.

[*]

service watchdog /system/xbin/watchdog_test
user root

[*]

EDIT: and this line too before the insmod /modules/vibrator.ko

[*]

insmod /modules/s3c2410_wdt.ko

Source

[*]As always, located at github.com/ipaq3870.

[*]Source is always sooner and fresher than binary build.

[*]Credits go to the original developers as well as those mentioned in the commitlog.

Share this post

Link to post

Share on other sites

I reverted back to the original wifi driver with a very slight change - so I believe it should perform as good as the original one. For no phone service, it never really occurred to me - so it's really difficult for me to debug it without anyone sending a dmesg output. Anyway, I did made some timing changes in the new build, so it is a good idea for you to test if it works for you.

Have you updated the kernel modules as well? The zImage and the modules go in pair - you need to use the new modules with the new kernel.

should we comment /insmod dpram.ko/ in init.rc in order to boot successfully?

Ahhh... no. What you should comment out is param.ko, NOT dpram.ko. dpram is the onedram driver for your OS to communicate with the phone modem via IPC. Commenting the wrong one will give you no phone service.

which shouid download？why are there so many downloads link？which one is？

You need to download 2 files from the first post (containing 4 links in the 2.0 section). The first one you'll need is the kernel modules, the second is the kernel zImage for which you have a choice from the remaining 3 links. Click each of the links in the first post to see what kernel configuration you want, and download only one of them.

0

Share this post

Link to post

Share on other sites

Ahhh... no. What you should comment out is param.ko, NOT dpram.ko. dpram is the onedram driver for your OS to communicate with the phone modem via IPC. Commenting the wrong one will give you no phone service.

Share this post

Link to post

Share on other sites

hey ipaq, about the (zram) script, can i put it in (sh file) and put it an (system/etc/init.d) folder???

I read some of you got some mods to put in that init.d directory, but I am quite sure the default installation has no such facilities to run init.d scripts. If you really need to do it, you'll need another version of busybox that supports the run-parts applet. Still you have to modify your init.rc to add the run-parts snippet. And IIRC, the stuff inside the init.d directory from the default installation can wreck havoc to your installation. So be careful when you plan touch that.

EDIT: Indeed there's run-part that comes with the default installation - but you still have to mod the init.rc scripts.

with "dirtypack"got signal and no

wifii error!!

Great. That means I have to read a good git book on how to do diff properly, and then make a 2.1 build <_<

Share this post

Link to post

Share on other sites

I didn't noticied speed difference with ZRAM. When you are using a lot of applications (Ebuddy, Opera Mini, SoundCloud, etc) it get slow just as regular swap. Took a while to switch between applications. Also, i'm using GO Launcher because of all widgets (it's all free) which make it even slower. But i checked with CPUTunner and it's running with 667mhz and isn't slower than 800mhz, which is good, at least i didn't noticied it.

Also, have someone noticied the "24bpp framebuffer (truecolor display) driver"? I can't see the difference, maybe isn't working here, as i said above i've that interference problem.