[KERNEL] Semaphore ICS 1.3.0

Search This thread

traian4u2005

Senior Member
Oct 27, 2008
69
21
After more than 4 days searching for a solution to make deep idle (TOP=OFF) to work, I found this:

http://xdaforums.com/showpost.php?p=22592878&postcount=10470

WIFI ON ,Screen OFF => I get TOP=ON Values
WIFI OFF ,Screen OFF => I get TOP=OFF Values (if you get this tipes of values your deep idle is working)

I am talking just about wifi because after flashing the attached .zip file bluetooth is not working if you want to start it is gonna stuck and next boot is goona work. I don't use bluetooth and i don't care about it
Phone is gonna enter on deep idle and give TOP=OFF after a fresh restart without any usb connected , if you connect an usb you have to restart phone to get TOP=ON or TOP=OFF Values. It is working with [KERNEL] Semaphore ICS 0.9.1 (0.9.5b) and with devils kernel
 

Attachments

  • Screenshot_2012-03-12-18-29-21.jpg
    Screenshot_2012-03-12-18-29-21.jpg
    18.8 KB · Views: 612
  • screen_off_Bluetooth_disable_deepidle_top_OFF_ALLICSROMS.zip
    149.4 KB · Views: 92

ngenhit

Senior Member
Sep 26, 2010
74
41
New version 0.9.5beta
- Deep Idle (Ezekeel's approach) *
fix sound glitches when TOP=OFF
added option to enable/disable statistics (disabled by default)
added dflags accesible through sysfs to debug deep idle checks **
some optimization for less CPU overhead
scripts to enable/disable Deep Idle and Deep Idle statistics
- fix: Smartassv2 use LiveOC frequencies
- Option to lock min frequency to 100MHz when gpu inactive
- enable_logger: change script to always copy current version modules
- fix conservative script

* To get TOP=OFF you need to power down BT when screen off. Use rfkill scripts or mod frameworks. I use this command in a terminal emulator:
Code:
echo 1 > /sys/devices/platform/bt_rfkill/rfkill/rfkill0/soft
You need to reboot to get back BT

** This is for development purposes. to enable debug use this command:
Code:
echo 1 > /sys/devices/virtual/misc/deepidle/ddebug_enabled

Then reading this
Code:
cat /sys/devices/virtual/misc/deepidle/dflags
you get the value of various checks that performed before phone entering deep idle:

/*
* dflags bits:
* 0 S5PV210_PD_LCD, 1 S5PV210_PD_CAM, 2 S5PV210_PD_TV, 3 S5PV210_PD_MFC
* 4 S5PV210_PD_G3D, 5 SND_S5P_RP, 6 S5P_CLKGATE_IP0, 7 S5P_CLKGATE_IP1
* 8 S5P_CLKGATE_IP3, 9 loop_sdmmc_check, 10 check_usbotg_op
* 11 check_rtcint, 12 check_idmapos
*/

I use the script below in a terminal emulator to get the dflags value every 1 second and check what prevents the phone entering deep idle:

Code:
#!/system/xbin/busybox sh

while true; do
        cat /sys/devices/virtual/misc/deepidle/dflags

        sleep 1
done
This made my day!. Full day boring and when i logged into xda. I'm seing this with much needed BT off code wich i wasnt able to find anywhere else. I'm BACK to semaphore!!. :). two days on devil for testing DIDLE and no use except for some ms savings. Lemme try Semaphore now :).

Thanks. :)

---------- Post added at 10:14 PM ---------- Previous post was at 10:10 PM ----------

After more than 4 days searching for a solution to make deep idle (TOP=OFF) to work, I found this:

http://xdaforums.com/showpost.php?p=22592878&postcount=10470

WIFI ON ,Screen OFF => I get TOP=ON Values
WIFI OFF ,Screen OFF => I get TOP=OFF Values (if you get this tipes of values your deep idle is working)

I am talking just about wifi because after flashing the attached .zip file bluetooth is not working if you want to start it is gonna stuck and next boot is goona work. I don't use bluetooth and i don't care about it
Phone is gonna enter on deep idle and give TOP=OFF after a fresh restart without any usb connected , if you connect an usb you have to restart phone to get TOP=ON or TOP=OFF Values. It is working with [KERNEL] Semaphore ICS 0.9.1 (0.9.5b) and with devils kernel
@Stratosk,

DIDLE in ICS needs these kind of things.

can you put a menu option in Semaphore app to kill the BT process + USB process ( leftovers of connection ) etc to get DIDLE?.

Just in case you havent thought about it. :)
 

pwlj

Senior Member
Dec 14, 2010
103
13
I have problem with 0.9.5b, deep sleep (not deep idle) doesn't work for me, it doesn't go on deep sleep even when phone doesn't do nothing and the screen is off, it's working at 100 MHz all the time when screen is off. I used cleaning script, clean init.d, and clean nstools in cwm before flashing this kernel.

Wysłane z mojego GT-I9000 za pomocą Tapatalk

Same here! Deep sleep ain't working.


On the other hand DIDLE top=off is working fine with BT OFF script.
But sometimes (i guess when more apps are running in backgroung (browser, and regular crap, but just much) it stops working, and isn't going to DIDLE.
OR MAYBE I'M TRIPPIN'.


cheers!
 

Lakerdas

Senior Member
Aug 25, 2010
78
19
Ierapetra
After more than 4 days searching for a solution to make deep idle (TOP=OFF) to work, I found this:

http://xdaforums.com/showpost.php?p=22592878&postcount=10470

WIFI ON ,Screen OFF => I get TOP=ON Values
WIFI OFF ,Screen OFF => I get TOP=OFF Values (if you get this tipes of values your deep idle is working)

I am talking just about wifi because after flashing the attached .zip file bluetooth is not working if you want to start it is gonna stuck and next boot is goona work. I don't use bluetooth and i don't care about it
Phone is gonna enter on deep idle and give TOP=OFF after a fresh restart without any usb connected , if you connect an usb you have to restart phone to get TOP=ON or TOP=OFF Values. It is working with [KERNEL] Semaphore ICS 0.9.1 (0.9.5b) and with devils kernel

I can confirm that the above mentioned script allowed me to use wi-fi while bluetooth is disabled and getting top=off.
 

Bonvaz

Senior Member
Jul 30, 2011
1,001
128
I m on semaphore 0.9.5 from some hours,works great for me!!!really it only breaks me the save battery mode in aokp

Sent from my GT-I9000 using XDA
 

Bonvaz

Senior Member
Jul 30, 2011
1,001
128
After more than 4 days searching for a solution to make deep idle (TOP=OFF) to work, I found this:

http://xdaforums.com/showpost.php?p=22592878&postcount=10470

WIFI ON ,Screen OFF => I get TOP=ON Values
WIFI OFF ,Screen OFF => I get TOP=OFF Values (if you get this tipes of values your deep idle is working)

I am talking just about wifi because after flashing the attached .zip file bluetooth is not working if you want to start it is gonna stuck and next boot is goona work. I don't use bluetooth and i don't care about it
Phone is gonna enter on deep idle and give TOP=OFF after a fresh restart without any usb connected , if you connect an usb you have to restart phone to get TOP=ON or TOP=OFF Values. It is working with [KERNEL] Semaphore ICS 0.9.1 (0.9.5b) and with devils kernel
Sorry,so bluetooth stop TO work only when is active with wifi?when wifi is on and bluetooth off something happen?


Sent from my GT-I9000 using XDA
 

traian4u2005

Senior Member
Oct 27, 2008
69
21
Sorry,so bluetooth stop TO work only when is active with wifi?when wifi is on and bluetooth off something happen?


Sent from my GT-I9000 using XDA

After a lot of testing i can see that after a fresh reboot you can use bluetooth and wifi as you want , but when you turn screen off and phone goes to deep idle after starting the screen again , bluetooth is not gonna work , just after a reboot , (wifi works no matter what) .
Another problem is with music player , if deep idle is activated , when screen goes off and deep idle is activated the player is gonna switch the music or switch off , or is gonna start acting crazy . But if you want to play music disable deep idle and enable after that.
Just two problems until now .
 

purpleraintoxicity

Senior Member
Feb 7, 2011
3,749
832
Jerusalem
After a lot of testing i can see that after a fresh reboot you can use bluetooth and wifi as you want , but when you turn screen off and phone goes to deep idle after starting the screen again , bluetooth is not gonna work , just after a reboot , (wifi works no matter what) .
Another problem is with music player , if deep idle is activated , when screen goes off and deep idle is activated the player is gonna switch the music or switch off , or is gonna start acting crazy . But if you want to play music disable deep idle and enable after that.
Just two problems until now .

If you can't use didle with music you lost the whole point of didke

Sent from my GT-I9000 using Tapatalk
 

cink40

Senior Member
Nov 25, 2010
1,854
577
Samsung Galaxy S23 Plus
On 0.9.5b, NStools not installed, so I suppose deep idle is not active: Playing music with Google music, when screen goes off, music start to stutter. Exact same settings on 0.9.1 and music plays fine...

sent from the Outer Space
 

stratosk

Recognized Developer
Mar 3, 2011
6,224
31,853
Thessaloniki
www.semaphore.gr
Deep Idle Guide and FAQ

This was really unexpected. Unfortunately I can't answer all these questions and comments. So I tried to write a guide and a FAQ for deep idle. Feel free for suggestions and corrections. Source: Samsung's SPV210 RISC Microprocessor User's Manual. Hope it clarifies some things.


Deep Idle Guide and FAQ

When the phone has no actions to perform, because you leave it alone or for example contacts are not synchronizing or gmail application is not fetching a new mail e.t.c., then the best thing that the phone has to do is to go to... sleep (suspend). In this state the phone consumes very little power.

There are also 5 other power schemes that the processor s5pv210 can use to reduce power consumption: Normal, Idle, Deep Idle, Stop and Deep Stop. We are interested in the first three states Normal, Idle and Deep Idle.

In Normal state the CPU is running, that is, some software is running.
In Idle state the CPU core is idle, that is, the CPU core clock is disabled but the remaining parts of s5pv210 are running.
In Deep Idle state the CPU core power is supplied but is powered off by the internal power switch. The remaining parts of processor may become power gated except the Audio power domain for low power MP3 playback.
Samsung in gingerbread kernels used only the Idle scheme. Deep Idle was implemented in the kernel but it was disabled by default. All known GB custom kernels have enabled Deep Idle state.

With stock kernels only Normal, Idle and Sleep states are used. Examples of these states use:

Normal state: User uses browser, or reading emails, watching video etc
Idle state: User listen to music and screen is off, no other software is running.
Sleep state: No user activity, screen is off, no activity of background services and processes.

Kernel checks many times per second different factors and decides which power state to use.
Deep Idle can be used as a better alternative of Idle state and the major benefit is when user listen to music. Then IF and only if all other conditions (factors) are satisfied the kernel decides to go to Deep Idle. That is, as we mentioned, CPU powered off, TOP powered off and L2 cache is powered off. Only Audio is on and that's why we have a major benefit. Another option of Deep Idle is the TOP=ON which means that the TOP module is still powered. This is used when bluetooth is enabled (powered).

Regarding power consumption, Sleep is always the desired state. Below the states ordered by the power they consumes (Normal consumes more power):

Normal -> Idle -> Deep Idle (TOP=ON) -> Deep Idle (TOP=OFF) -> Sleep


FAQ

How to enable Deep Idle?
a) Simply check the Deep Idle option in Semaphore Script Manager or b) use this command on a terminal emulator or adb shell:
echo 1 > /sys/devices/virtual/misc/deepidle/enabled

How to enable Deep Idle Statistics?
a) Simply check the Deep Idle Statistics option in Semaphore Script Manager or b) use this command on a terminal emulator or adb shell:
echo 1 > /sys/devices/virtual/misc/deepidle/stats_enabled

Why statistics are not enabled by default?
Simply for saving CPU cycles. Kernel checks for entering Deep Idle (or Idle) many thousand times per minute. So, disabling statistics we have less overhead in CPU. What is the difference? Not to much, but better little than nothing.

What is TOP?
S5PV210 internal modules are grouped into 11 power domains based on their functions. One of these domain is the TOP and it includes these modules: Clock Management Unit (CMU), GPIO(OFF), Bus components, VIC, TZIC, Internal memory (IROM and IRAM), NAND controller, OneNAND controller, CF controller, SRAM controller, Peripheral DMA, Memory DMA, CoreSight, JTAG, Modem interface, Security sub-system, TSI, HSMMC, USB HOST, USB OTG, DRAM controller, CHIPID, IEM_IEC, Security key, SPDIF, PCM, SPI, KEYIF, TSADC, I2C, I2S channel 1 and 2, AC97, PCM, System timer, Watchdog timer, UART.
So, Deep Idle with TOP=OFF power gates all the above modules.

How to check if Deep Idle works?
Enable Deep Idle and Deep Idle statistics then run music player and select your favorite music (it must be your favorite song in order to deep idle work properly). Switch the screen off and wait few seconds (or wait until your favorite song is finished). Check with this command in a terminal emulator or adb shell deep idle statistics:
cat /sys/devices/virtual/misc/deepidle/idle_stats

Alternatively you may just open the idle_stats file in the above directory using a root explorer like application.

I only get TOP=ON statistics
Bluetooth or GPS or Vibrator is running

How to power down Bluetooth?
Use this command:
echo 1 > /sys/devices/platform/bt_rfkill/rfkill/rfkill0/soft
Unfortunately I didn't manage to find a way to enable it again. I tried an rfkil script but it doesn't work for me. If you find a way, please let me know.

I only get Idle statistics (neither TOP=ON nor TOP=OFF)
Something is preventing kernel to enter in deep idle state. This maybe normal. For example:
LCD controller is enabled
USB is connected
TV encoder is working
G3D (GPU) is active
MFC (multi format codec) is active
SDMMC controller is active
etc.

How can I find what is preventing deep idle?
That's why I implemented dflags in deep idle. Kernel check many factors to decide if it can enter deep idle. All these check are encoded in dflags. dflags is an integer number. If you read this number and decode it in binary you will get the results of the last check. Each check is a bit set in binary format. For example:
dflag = 3 binary = 11. This means that LCD controller and camera are active. (Please note that I disabled camera check for preventing kernel entering deep idle). The flags in dflags (most of the are self explanatory):
0 S5PV210_PD_LCD
1 S5PV210_PD_CAM
2 S5PV210_PD_TV
3 S5PV210_PD_MFC
4 S5PV210_PD_G3D
5 SND_S5P_RP
6 S5P_CLKGATE_IP0
7 S5P_CLKGATE_IP1
8 S5P_CLKGATE_IP3
9 loop_sdmmc_check
10 check_usbotg_op
11 check_rtcint
12 check_idmapos

You may enable debugging with
echo 1 > /sys/devices/virtual/misc/deepidle/ddebug_enabled

The you may use this script to get the value of dflags every second.

Code:
#!/system/xbin/busybox sh

while true; do
        cat /sys/devices/virtual/misc/deepidle/dflags

        sleep 1
done

Leave it to run and try to enter your phone in deep idle. The switch on the screen and read the last values and convert the to binary. Values 0 or 1 lead to deep idle. Other values lead to Idle.
 
Last edited:

HiKsFiles

Senior Member
Aug 7, 2010
537
158
Québec city
awesome!!

You should consider using the second post of this thread (the one reserved for future use ;) ) to show this last piece of information ... quite usefull it is!
 

stratosk

Recognized Developer
Mar 3, 2011
6,224
31,853
Thessaloniki
www.semaphore.gr
Seemed to be working for a while actually. Got into deep idle, Top=OFF for a little while. But then unable to reproduce it again. Playing around a bit to see if i can get it back...

After testing through emulator the commands stratosk suggested, this is what i got apparently preventing deep idle. If anyone can deconstruct it. (Running 4.2 ICSSGS, SmartassV2, no OC/UV)

I see some 0s. This is deep idle IF (bluetooth and gps and vibrator) is off
 

DH-

Senior Member
Jun 14, 2009
91
3
awesome!!

You should consider using the second post of this thread (the one reserved for future use ;) ) to show this last piece of information ... quite usefull it is!

I would also nominate this guide for front page. :D


Also: is the battery use difference between TOP=ON and TOP=OFF really huge or not? I do use bluetooth sometimes so I'd rather have it working, unless it really benefits my battery hugely.
 

stratosk

Recognized Developer
Mar 3, 2011
6,224
31,853
Thessaloniki
www.semaphore.gr
Following my earlier message I did the following:
Rebooted to achieve wi-fi and bluetooth functionality again. Ran the same command through terminal emulator. Top=off was activated. But when I tried to open wi-fi my phone rebooted.
I'm attaching last_kmsg. I hope it will be usefull to you.

With a quick look I can't understand what's going on. Does this happen every time?
 

stratosk

Recognized Developer
Mar 3, 2011
6,224
31,853
Thessaloniki
www.semaphore.gr
I would also nominate this guide for front page. :D


Also: is the battery use difference between TOP=ON and TOP=OFF really huge or not? I do use bluetooth sometimes so I'd rather have it working, unless it really benefits my battery hugely.

Yes, I believe there is a big difference. Please note that in GB kernel only TOP=OFF is implemented...

Anyway, I will keep searching a way to make them work all together (of course I can't promise I will manage to do it)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 597
    This is a kernel based on the pawitp's one and it works for Android 4.0.x ICS ROMs.


    Features

    - LiveOC
    - Custom Voltage
    - Voodoo Sound
    - BLN
    - 373.5MB - 398.7MB available RAM
    - Compiled with Linaro 4.7.2
    - O3 optimization
    - Semaphore Script Manager 0.75
    - Auto brightness driver
    - Touch Wake
    - Vibration intensity
    - Deep Idle
    - USB host driver
    - Governor ondemand (default)
    - ondemand: sampling_down_factor tunable by momentum, smooth_ui
    - Governor conservative (module, smooth_ui)
    - Governor smartassV2 (module, smooth_ui)
    - Noop I/O scheduler (default)
    - Deadline I/O Scheduler (module)
    - Simple I/O Scheduler (module)
    - CFQ I/O Scheduler (module)
    - Netfilter (iptables) as modules
    - CIFS as module
    - TUN as module
    - Logcat disabled (as module only)
    - Standard network packet scheduler
    - Kernel log buffer size 4KB (from 128KB)
    - Reduced debug info
    - TinyRCU
    - Fast Charge support
    - WiFi PM_MAX when suspend
    - CWM 6.0.1.0
    - /system/etc/init.d directory creation if not exist

    In order to load various modules of the kernel and enable or disable features use HM.Carbide's Semaphore Script Manager application. It automatically copies and runs the respective scripts from /res/scripts to /system/etc/init.d directory. The scripts:

    - S05enable_oc_0800 (disable overclocking - caps max freq to 800Mhz)
    - S05enable_oc_1000_default (disable overclocking)
    - S05enable_oc_1100 (enable overclocking - max freq 1100MHz)
    - S05enable_oc_1140 (enable overclocking - max freq 1140MHz)
    - S05enable_oc_1200 (enable overclocking - max freq 1200MHz)
    - S10enable_gov_conservative (load and enable conservative governor module)
    - S10enable_gov_ondemand_default (enable ondemand governor)
    - S10enable_gov_smartassV2 (load and enable conservative smartassV2 module)
    - S15enable_sched_deadline (load and enable the deadline I/O scheduler module)
    - S15enable_sched_noop_default (enable noop scheduler)
    - S15enable_sched_sio (enable and load SIO scheduler module)
    - S20enable_netfilter (load netfilter modules for firewall or WiFi, USB tethering)
    - S30enable_logger (enable logging)
    - S35enable_tun (load tun module)
    - S40enable_cifs (load cifs module)

    Custom Voltage may be configured with Voltage control or similar applications.

    For more information check the semaphore kernel website: www.semaphore.gr

    For questions or issues about Semaphore Script Manager please visit HM.Carbide thread

    Thanks to Superuser, you may download a wonderful custom bootanimation for CM9 from http://www.semaphore.gr/downloads/boot-animations


    Thanks to

    pawitp for his kernel.
    zacharias.maladroit for his useful information about CM's initramfs
    HM.Carbide for his Semaphore Script Manager application.
    Ezekeel for LiveOC, Custom Voltage
    sztupy for USB host driver
    koush for CWM
    xcaliburinhand for his work about dock support
    mialwe for his vibrator intensity and other fixes
    ShadowInkDesigns for Android logo
    trailblazerz11 for his help with Linaro and other changes
    DerTeufel1980 for various hints

    All people who support this kernel by testing, reporting issues, donating or simply using it.


    Change log

    1.3.0 (30/07/2012)
    - added CFQ scheduler as module
    - in call volume settings (thanks to DerTeufel for his hint)
    - fix charging display for car dock (thanks to pawitp)
    - CWM 6.0.1.0 (thanks to koush) *
    - CWM: added AROMA Filemanager (thanks to amarullz)
    - compiled with Linaro 4.7.2 201207

    Normal versions (for CM9 or ROMs without hugemem configuration)
    1.3.0
    - 373.5MB - 385.7MB

    For Slim ROM or patched ROMs with hugemem configuration
    1.3.0s
    - 386.5MB - 398.7MB

    * Nandroid backups with CWM 6 are not compatible with previous versions.



    1.2.6 (07/07/2012)
    - USB mass storage disable write speed cache support (thanks kasper_h, DerTeufel1980 for the hint)
    - CWM: Allow key to repeat on hold (thanks to FaultException, koush). Works for volume up, down and touch key menu (as down)
    - CWM: fix selection bar color when battery < 21%
    - CWM: upstream sync (thanks to koush) *
    - initramfs sync some changes with CM9 (adb works in root by default in recovery)
    - compiled with linaro 4.7.1 201206

    Normal versions (for CM9 or ROMs without hugemem configuration)
    1.2.6
    - 373.5MB - 385.7MB

    For Slim ROM or patched ROMs with hugemem configuration
    1.2.6s
    - 386.5MB - 398.7MB

    * Please note that due to changes in nandroid backup/restore, previous versions of Semaphore can't restore backups from version >= 1.2.6. To be on the safe side, please renew your backups.


    1.2.5 (19/06/2012)
    - rebased to 3.0.17 (thanks to trailblazerz11 and eugene373 for their github)
    - compiled with Linaro 4.7.1 toolchain (thanks to trailblazerz11 for his help)
    - O3 optimization flag
    - upstream sync (fixes for cdma in-call volume and mic gain included, thanks to pawitp, efpophis)
    - WiFi PM_MAX when suspended
    - fixed 800MHz underclocking
    - changed boot splash screen

    Normal versions (for CM9 or ROMs without hugemem configuration)
    1.2.5
    - 373.5MB - 385.7MB

    For Slim ROM or patched ROMs with hugemem configuration
    1.2.5s
    - 386.5MB - 398.7MB


    1.2.2 (01/06/2012)
    - Bootloop detection (if no normal boot is detected the phone will be forced to recovery in next boot) *
    - bugfix: enabling Wi-Fi hotspot twice (copy the new netfilter script in order this to work by disabling and then enabling again netfilter in Semaphore app)
    - creation of /system/lib/modules if does not exist
    - removed LMK scripts
    - fix some typos in scripts description (thanks to cdmackay, HiKsFiles)

    * It doesn't mean that this will necessarily resolve the known bootloop issue, but it may help on bootloops because of bad OC/UV etc.



    Full changelog: http://www.semaphore.gr/changelog/ics-version
    Deep Idle Guide and FAQ


    Sources

    The Linux Kernel
    Samsung Kernel sources
    Semaphore kernel sources


    Please use it at your own risk!

    The attachment zip files are for flashing from CWM recovery.
    The attachment tar files are for flashing through Heimdall/ODIN.

    Attachment files md5sum:

    4a963c5183993b256c5a0d52f88bc2c7 Semaphore_ICS_1.2.6.zip
    408178563587859c31a4c5a90b394166 Semaphore_ICS_1.2.6s.zip
    3a0ca16342f811dfd9666ce3633a20b6 Semaphore_ICS_1.2.6.tar
    c53114e74530e68c3b5cddb424343e8b Semaphore_ICS_1.2.6s.tar
    753748fba3b590babcbfb76857bf609d Semaphore_ICS_1.3.0.zip
    a6f0d7c9d2254d9a178248d48cf3de45 Semaphore_ICS_1.3.0s.zip
    1e71744541d74fdd60d6b43c2dc767c7 Semaphore_ICS_1.3.0.tar
    09e1e9806dc84c9c2e2341e38ebd51b0 Semaphore_ICS_1.3.0s.tar


    Alternative download from http://www.semaphore.gr/downloads/gt-i9000-ics

    1.2.5e Euro 2012 - Spain Special Edition
    100
    Deep Idle Guide and FAQ

    This was really unexpected. Unfortunately I can't answer all these questions and comments. So I tried to write a guide and a FAQ for deep idle. Feel free for suggestions and corrections. Source: Samsung's SPV210 RISC Microprocessor User's Manual. Hope it clarifies some things.


    Deep Idle Guide and FAQ

    When the phone has no actions to perform, because you leave it alone or for example contacts are not synchronizing or gmail application is not fetching a new mail e.t.c., then the best thing that the phone has to do is to go to... sleep (suspend). In this state the phone consumes very little power.

    There are also 5 other power schemes that the processor s5pv210 can use to reduce power consumption: Normal, Idle, Deep Idle, Stop and Deep Stop. We are interested in the first three states Normal, Idle and Deep Idle.

    In Normal state the CPU is running, that is, some software is running.
    In Idle state the CPU core is idle, that is, the CPU core clock is disabled but the remaining parts of s5pv210 are running.
    In Deep Idle state the CPU core power is supplied but is powered off by the internal power switch. The remaining parts of processor may become power gated except the Audio power domain for low power MP3 playback.
    Samsung in gingerbread kernels used only the Idle scheme. Deep Idle was implemented in the kernel but it was disabled by default. All known GB custom kernels have enabled Deep Idle state.

    With stock kernels only Normal, Idle and Sleep states are used. Examples of these states use:

    Normal state: User uses browser, or reading emails, watching video etc
    Idle state: User listen to music and screen is off, no other software is running.
    Sleep state: No user activity, screen is off, no activity of background services and processes.

    Kernel checks many times per second different factors and decides which power state to use.
    Deep Idle can be used as a better alternative of Idle state and the major benefit is when user listen to music. Then IF and only if all other conditions (factors) are satisfied the kernel decides to go to Deep Idle. That is, as we mentioned, CPU powered off, TOP powered off and L2 cache is powered off. Only Audio is on and that's why we have a major benefit. Another option of Deep Idle is the TOP=ON which means that the TOP module is still powered. This is used when bluetooth is enabled (powered).

    Regarding power consumption, Sleep is always the desired state. Below the states ordered by the power they consumes (Normal consumes more power):

    Normal -> Idle -> Deep Idle (TOP=ON) -> Deep Idle (TOP=OFF) -> Sleep


    FAQ

    How to enable Deep Idle?
    a) Simply check the Deep Idle option in Semaphore Script Manager or b) use this command on a terminal emulator or adb shell:
    echo 1 > /sys/devices/virtual/misc/deepidle/enabled

    How to enable Deep Idle Statistics?
    a) Simply check the Deep Idle Statistics option in Semaphore Script Manager or b) use this command on a terminal emulator or adb shell:
    echo 1 > /sys/devices/virtual/misc/deepidle/stats_enabled

    Why statistics are not enabled by default?
    Simply for saving CPU cycles. Kernel checks for entering Deep Idle (or Idle) many thousand times per minute. So, disabling statistics we have less overhead in CPU. What is the difference? Not to much, but better little than nothing.

    What is TOP?
    S5PV210 internal modules are grouped into 11 power domains based on their functions. One of these domain is the TOP and it includes these modules: Clock Management Unit (CMU), GPIO(OFF), Bus components, VIC, TZIC, Internal memory (IROM and IRAM), NAND controller, OneNAND controller, CF controller, SRAM controller, Peripheral DMA, Memory DMA, CoreSight, JTAG, Modem interface, Security sub-system, TSI, HSMMC, USB HOST, USB OTG, DRAM controller, CHIPID, IEM_IEC, Security key, SPDIF, PCM, SPI, KEYIF, TSADC, I2C, I2S channel 1 and 2, AC97, PCM, System timer, Watchdog timer, UART.
    So, Deep Idle with TOP=OFF power gates all the above modules.

    How to check if Deep Idle works?
    Enable Deep Idle and Deep Idle statistics then run music player and select your favorite music (it must be your favorite song in order to deep idle work properly). Switch the screen off and wait few seconds (or wait until your favorite song is finished). Check with this command in a terminal emulator or adb shell deep idle statistics:
    cat /sys/devices/virtual/misc/deepidle/idle_stats

    Alternatively you may just open the idle_stats file in the above directory using a root explorer like application.

    I only get TOP=ON statistics
    Bluetooth or GPS or Vibrator is running

    How to power down Bluetooth?
    Use this command:
    echo 1 > /sys/devices/platform/bt_rfkill/rfkill/rfkill0/soft
    Unfortunately I didn't manage to find a way to enable it again. I tried an rfkil script but it doesn't work for me. If you find a way, please let me know.

    I only get Idle statistics (neither TOP=ON nor TOP=OFF)
    Something is preventing kernel to enter in deep idle state. This maybe normal. For example:
    LCD controller is enabled
    USB is connected
    TV encoder is working
    G3D (GPU) is active
    MFC (multi format codec) is active
    SDMMC controller is active
    etc.

    How can I find what is preventing deep idle?
    That's why I implemented dflags in deep idle. Kernel check many factors to decide if it can enter deep idle. All these check are encoded in dflags. dflags is an integer number. If you read this number and decode it in binary you will get the results of the last check. Each check is a bit set in binary format. For example:
    dflag = 3 binary = 11. This means that LCD controller and camera are active. (Please note that I disabled camera check for preventing kernel entering deep idle). The flags in dflags (most of the are self explanatory):
    0 S5PV210_PD_LCD
    1 S5PV210_PD_CAM
    2 S5PV210_PD_TV
    3 S5PV210_PD_MFC
    4 S5PV210_PD_G3D
    5 SND_S5P_RP
    6 S5P_CLKGATE_IP0
    7 S5P_CLKGATE_IP1
    8 S5P_CLKGATE_IP3
    9 loop_sdmmc_check
    10 check_usbotg_op
    11 check_rtcint
    12 check_idmapos

    You may enable debugging with
    echo 1 > /sys/devices/virtual/misc/deepidle/ddebug_enabled

    The you may use this script to get the value of dflags every second.

    Code:
    #!/system/xbin/busybox sh
    
    while true; do
            cat /sys/devices/virtual/misc/deepidle/dflags
    
            sleep 1
    done

    Leave it to run and try to enter your phone in deep idle. The switch on the screen and read the last values and convert the to binary. Values 0 or 1 lead to deep idle. Other values lead to Idle.
    92
    How to build Semaphore kernel

    Prerequisites
    Basic knowledge of Linux is required to be able to build the kernel. We will also need a modern Linux box (preferably).

    Basic Setup
    First, we need to setup a directory in which we will clone the kernel and initramfs repositories. In this guide, we will setup them in /tmp but you can do it in any directory you want.

    In a terminal we run:

    Code:
    mkdir /tmp/semaphore
    cd /tmp/semaphore

    Then we clone the basic kernel repository:
    Code:
    git clone https://github.com/stratosk/samsung-kernel-aries

    Finally we clone the initramfs repository:
    Code:
    git clone https://github.com/stratosk/ics-ramdisk

    OK, first step done. We got the code. Now we have to do some preparation and compile it.

    Configuration
    I prefer to use a mini ugly script to compile the kernel and pack it. It's located in the root of the kernel tree (/tmp/semaphore/samsung-kernel-aries/sbuild.sh)

    We open this file with an editor of our choice (I prefer vi) and edit:
    1) The two lines with the 'make' command, changing the CROSS_COMPILE= option. We need to set the path from the cross compiler toolchain. I use the one that it's included in CM9 repository.
    2) The line starting with the 'find' command, changing the kernel source directory and destination directory of the modules location. This is into the initramfs directory. In our example it's /tmp/semaphore/ics-ramdisk/ics_combo/files/modules

    The Semaphore's kernel configuration is located in the file config_sema in the root kernel directory. So, we need to copy this file as .config:

    Code:
    cp config_sema .config

    Then we run this command to start the Linux kernel configuration utility (again change the CROSS_COMPILE according to your toolchain directory):
    Code:
    make CROSS_COMPILE=/kernels/semaphore_cap/android/android/system/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- ARCH=arm menuconfig

    We go to 'General Setup' section and we change the 'Initramfs source files' option to /tmp/semaphore/ics-ramdisk/ics_combo/
    We also need to change the next 2 options User ID and Group ID to whatever uid and gid we are logged in in the Linux box. In my case is 500,500. We exit and save the configuration.

    Compiling
    Now we are ready to build the kernel!

    We just run:
    Code:
    ./sbuild.sh

    We wait few minutes (time depends on the machine) and hopefully the compilation will end.

    The script will produce 2 files.
    1) /tmp/semaphore/samsung-kernel-aries/arch/arm/boot/zImage
    2) /tmp/semaphore/ics-ramdisk/cwm/Semaphore_ICS_1.2.0s.zip

    These are the 2 known files that we can flash via Heimdal or CWM respectively.
    68
    Please accept my apologies

    I'm sorry for your issues.

    And I have no more desire to build new versions. At least for now.

    @all

    Please accept my apologies about this comment.

    I guess I was very tired trying to prepare the new version, and hearing about these problems and almost no comments about the new stuff make me decide to stop this project.

    But, during the day and after reading all these beatiful comments from all of you, I realized that Semaphore is part of my life. It sounds a little bit exceeding saying this but it's true.
    For almost a year this project and most of all the communication with all of you is an important part of my life.

    And it would be unfair for all of you and for me to kill Semaphore.

    @Znida
    I'm sorry. My commect was general and I didn't mean to blame you for anything.

    @mialwe
    Thanks about your comment my friend. It's good to hear that from a person like you.

    @bennybaz
    Thanks so much trying to help. Beers it's not the issue. As I said I work on Semaphore for year and the $600 is not the reason I still working for this.
    Of course it's a huge help for me and many thanks to everybody who donate to me.

    @greasyguy
    Thanks mate, really appreciated.


    @all
    Thanks again for your nice comments. You gave me the motivation to start working again. THANK YOU!
    67
    Thank you all of you! Your help and your support is awesome!