[Galaxy Note II Android Development] mat9v:
First - the guide for EXT4 to F2FS migration

OK, here is a simple guide to doing it SAFELY (if not simply)

1. To get full benefits of F2FS every partition except external sdcard should be formatted.

2. Copy ALL your personal data from INTERNAL sdcard to either your external one or to your pc

3. Make space on your EXTERNAL sdcard for full backup of system and data of your current running system

4. That should be about 4GB in most cases, recovery will inform you how much space is required for backup when you attempt to start it, the best chance to have no problems would be to have about 8GB free on external sdcard

5. Download new recovery and kernel from OP of this thread.

------- here starts somewhat destructive part ---------------

IMPORTANT - all new recoveries based on v6.0.+ have a curious problem, the first time you try to access external sdcard it bouces you to the main menu of recovery, following access attempts are without problem, unless you reboot recovery, then the problem occurs again. I suspect it's due to mounting external sdcard for use on the first attempt

6. Boot into recovery.

- flash your new recovery

- reboot recovery (option to do that is found in Power Options>Reboot Recovery)

- once back in recovery flash new kernel

- reboot recovery again

- go to Backup and Restore > Custom Backup and Restore > Custom Backup Job

- there select : boot, recovery, system, data and cache and tap Start Custom Backup Job

- select (Important): Backup to /storage/sdcard1

The backup will take time, for me it took 18 minutes to complete (4GB) and it may look like it has frozen, especially when creating MD5 - be patient

- once completed go back to main menu

- enter Mounts and Storage

- format /system and from submenu select f2fs

- format /data, /sdcard and secondrom (it will destroy your secondary rom as it is placed in /sdcard so BACKUP it before) and select f2fs from submenu

- format /cache - you will not have an option to select f2fs (it's not even strictly necessary to format as all /cache data are placed in /data partition and since /data is formatted to f2fs......)

- go back to main recovery menu

- tap Backup and Restore

- tap Restore from /storage/sdcard1

- select freshly made backup (the date is obvious)

- wait for some time being good patient person you are

- go back to main recovery menu

- tap reboot primary system now

7. You should have a fully working system now, it's time to restore your personal data from step 2 to internal sdcard

Process finished.

Second - guide to modifying various cool and useful settings in the kernel (under construction).

Devil 2 kernel let's us play with a lot of exciting futures, the most interesting being increased battery charging, ScoobyDoo sound engine and advanced color correction and enhancement. Here I will try to guide you in how to configure those settings so you can get the most out of your hardware.

1. Battery charging.

Modifying these values CAN be dangerous to your hardware, both phone, charger and PC (if you are charging from USB port) but should not pose any problems if there are no hidden problems with charging equipment. Samsung installed in our phones an intelligent charging controller that constantly monitors charging current looking for spikes and other problems. Unfortunately it is very sensitive. As the charger ages and cable is constantly bent, connectors plugged and unplugged, they physically loose quality of connection, creating instabilities in charging current. The controller reacts to that by first lowering current requested from charger until it passes quality checks, but checks are so strict that often we end up with charging of 8-10 hours instead of 2.5 as it should be. The charger is able to supply 2A of constant current, but our battery (3100mAh) will not be charged that fast unless we turn our phone off because when it is running it still uses some power, right? This brings us to the configuration of charging circuitry - we have 3 separately defined charging sources - AC charger, USB charger and specialized charging USB port, each has defined total input power and max amount of current for charging battery.

In my scripts I have configured the following values:

The first pair is used to define parameters for charging from AC charger, total input power and the part for charging battery, both are increased from default but should make no problem for standard Samsung charger (as a side note, default config does not even use full 2A current, but only 1.8A)

echo "2100" > /sys/devices/platform/samsung-battery/dcp_ac_input_curr

echo "2000" > /sys/devices/platform/samsung-battery/dcp_ac_chrg_curr

Second pair defines charging from USB port - now this one is more risky because the USB 2.0 standard defines max current available as only 500mA while in fact almost all newer mainboards easily provide much more power (my own works with 2A without problem - or maybe it did not suffer cataclysmic burnout yet). If you have a new PC you should be safe, if not - the correct settings is 500/500 in both entries.

echo "1300" > /sys/devices/platform/samsung-battery/sdp_input_curr

echo "1200" > /sys/devices/platform/samsung-battery/sdp_chrg_curr

The last pair defines specialized charging port - I have no such port to test so I did not increase the values a lot, those should be perfectly safe.

echo "1350" > /sys/devices/platform/samsung-battery/cdp_input_curr

echo "1250" > /sys/devices/platform/samsung-battery/cdp_chrg_curr

This value is important if you ever use non-standard battery. Samsung 3100mAh battery has the maximum charging limit of 4.35V and as you see I have lowered that limit to 4.3V - while it will decrease battery max capacity by about 100mAh it will increase how many times the battery can be safely charged before it degrades. If anyone is very interested in how process works please read HERE

echo "4300000" > /sys/devices/platform/samsung-battery/batt_chrg_soft_volt

Last two entries are very important to charging speed. The first disables 100mA charging current margin that always lowers max charging speed by 100mA from max defined by detected current quality. The second completely disables mechanism responsible for detecting quality of charging current. This is a dangerous process that MAY cause your charger and phone to spontaneously combust if your battery and/or charger is faulty. Haven't heard of it ever happening but there is always the first time :) Consider also that other phones do not have that circuitry.

echo "1" > /sys/devices/platform/samsung-battery/ignore_stable_margin

echo "1" > /sys/devices/platform/samsung-battery/ignore_unstable_power

2. ScoobyDoo sound system is used to configure quality of sound output from our phone. There is a lot of things that can be done, including sound processing and 3D audio postprocessing but I personally like to hear sound as close to the recorded source so the only thing I did in my script is disable all sound processing and slightly increase amplifier boost value because my headphones are quite demanding.

echo "1" > /sys/devices/virtual/misc/scoobydoo_sound/fll_tuning

echo "1" > /sys/devices/virtual/misc/scoobydoo_sound/dac_osr128

echo "1" > /sys/devices/virtual/misc/scoobydoo_sound/adc_osr128

echo "1" > /sys/devices/virtual/misc/scoobydoo_sound/dac_direct

echo "1" > /sys/devices/virtual/misc/scoobydoo_sound_control/enable

echo "57" > /sys/devices/virtual/misc/scoobydoo_sound/headphone_amplifier_level

"dac_osr128" and "adc_osr128" improves sound quality by applying 128X oversampling - improves clarity

"dac_direct" forces the bypass of analog channel conversion

"fll_tuning" tunes audio chip clock, reduces distortion by playing with power supplied to headphones

"enable" well, enables control of audio chip by this engine

"headphone_amplifier_level" changes max volume for headphones, max value here being 63 but it can produce distortions so better to use something lower

Here are 3 settings for modifying Speaker configuration to increase or decrease total loudness (personally don't use that but maybe someone may need it)

echo "0" > /sys/devices/virtual/misc/scoobydoo_sound/speaker_tuning

echo "44" > /sys/devices/virtual/misc/scoobydoo_sound/speaker_tuning_level

echo "0" > /sys/devices/virtual/misc/scoobydoo_sound/speaker_offset

The first one enables Speaker control, change to "1" to enable.

Second increases speaker volume, default being 44 with max value of 63, change to your liking

Third does similar thing but changes "base" speaker volume value, default being 0, why it exist and in what way it differs from speaker_tuning I don't know :)

There is a few other settings here:

Stereo expansion - creates 3D sound from stereo source

Speaker amplification - does the same as Headphone amplification only for phone speaker - I would not touch that even wit 10 feet pole, the built in speaker just don't have the quality to reproduce anything louder :)

Equalizer - 5 band one to tune the sound for various headphones? Never used that one, don't like equalizers :)

Substitute "1" with "0" in those entries to disable my modifications.

3. Samsung loves to market "crisp and lifelike colors", yeah right. They may look good but have no base in reality :) More than a year ago someone (don't remember who, search in Perseus kernel thread) did test our display with hardware tester to tune the color gamut to as close as possible reproduce natural colors. The effect we can see when the factory color settings are enabled without Samsung "improvements" :) There is a lot that can be done within this engine but I have done only the minimum to correct color to it's base form.

echo "1" > /sys/class/misc/mdnie/hook_intercept

echo "1" > /sys/class/misc/mdnie/sequence_intercept

echo "1" > /sys/class/misc/mdnie/hook_control/s_MCM

Above that, you can enable Dogital Noise Reduction for both Video and Desktop image, force HDR, modify Gamma for each color or combined, enable Dithering and Edge Enhancement, play with color temperature, enable Adaptive Brightness and much more. I have not found any documentation on what exactly can be done, not even correct values that can be passed to various settings. If anyone have such a document available I welcome any links :)

Substitute "1" with "0" in those entries to disable my modifications.

4. In Devil kernel touch buttons backlight can be controlled by rom or the kernel. In my script I have completely disabled backlight for the buttons. After all there are only two of them and their placement is kind of in the center :) , at night they are very bright and annoying.

echo "1" > /sys/class/sec/sec_touchkey/touch_led_handling

Enable touch led handling by kernel.

echo "1" > /sys/class/sec/sec_touchkey/touch_led_on_screen_touch

Not really needed but turns on leds when you touch the screen.

echo "1" > /sys/class/sec/sec_touchkey/force_disable

This one disables the leds completely.

You can also modify sensitivity of touchkey, how long the leds are alight after touching screen or touchkey, you can change led brightness.

Substitute "1" with "0" in those entries to disable my modifications.

5. Latest version of Devil kernel implement F2FS file system. Created by Samsung (Jaegeuk Kim) in 2012 and designed specifically for flash based drives. F2FS belongs to a class of file systems named Long-structured File system, it's main design principles can be described in following: "A log-structured file system writes all modifications to disk sequentially in a log-like structure, thereby speeding up both file writing and crash recovery. The log is the only structure on disk; it contains indexing information so that files can be read back from the log efficiently. In order to maintain large free areas on disk for fast writing, the log is devided into segments and use a segment cleaner to compress the live information from heavily fragmented segments". Main advantages lie in increased write performance (which is an Achilles heel of flash solutions) in random write category (but not only that). It is an answer to logging problems in ext4 and earlier file systems. Has internal garbage collector and both "on demand" and "background" cleaning service. Test performed by Anandtech show almost 100% increase in random write performance with small increase in write and read performance compared to ext4 filesystem (phones used were Motorola Moto X vs Galaxy S4). In all a highly suggested solution for us :)