Fiio X5iii Custom Kernel and Scripts | 2016MHz CPU | 20% RAM increase | Undervolting | New DAC drivers | and much more
May 3, 2019 at 5:51 PM Thread Starter Post #1 of 575

jkbuha

100+ Head-Fier
Joined
Jan 2, 2014
Posts
284
Likes
401
Dear Head-Fi community

Following on from the posts on the dedicated X5iii thread, this is a thread that will solely contain any and all software modifications to the @FiiO X5iii. The custom kernel contains the largest amount of new code, extra features and performance improvements for the X5, and really pushes the limits of the hardware to its fullest potential. The benchmarks alone are outstanding - using Geekbench and Antutu the performance is more than 400% that of the vanilla 1.2.4 firmware, and it will similarly feel more intuitive and responsive, as can be attested by the numerous users to date.

As of Version 3.x, audio tuning is also taken one step further. A new custom AK4490 driver has been implemented, and a significant portion of redundant and/or unnecessary code has been removed from the sound drivers. Therefore, if not better, the sound should at least feel ‘cleaner’ when compared with previous or vanilla versions. We still have a long way to go to enhancing the audio on these DACs, but this driver is a start.

Installation instructions are outlined further below; ie flash via TWRP, but first-time users can also find a more detailed set of instructions in the zip file.

There are three versions - the 2GHz version for faster CPUs, the 1.7GHz for most players, and the 1.4GHz version for anyone experiencing random lockups or reboots.

Important - this version *should* also be compatible with Fidelizer 1.2.4. I’ve spoken with the developer and he’s taken the (wise) decision not to de-odex the files in system partition on the basis of sound changes, so there should be ample space to install. Nonetheless, please test and report back.

Unique Features
- Custom AK4490 DAC driver (faster, better oversampling)
- Support for DSD256
- Increased clock speed from 1416MHz to 2016MHz
- Increased GPU speed from 133MHz to 600MHz
- Increased DDR speed from 200MHz to 800MHz
- Better voltage regulation using all possible pwm and clocks on the board
- Increased available RAM by 20%
- LZ4 compression for better, faster swap and virtual memory usage
- ZRAM usage for additional system memory
- Fsync_disable for much faster system processing
- UKSM for faster Kernel operations
- Adaptive-LMK for better memory management
- Undervolting for lower heat dissipation and battery consumption
- New Faster CPU Governors: interactiveX, PegasusQ,
- New Faster I/O Schedulers: zen, bfq, sio, vr, maple
- New Faster Westwood TCP/IP congestion handler for faster wifi and internet access
- CPUBoost algorithm for faster on-demand processing
- CPU SMP feature for powering down unused cores on screen off
- RQ Affinity for faster I/O scheduling
- Linaro gcc toolkit for faster, leaner code
- RK3188 neon vfp3 code optimisation for faster fixed-point and floating DSP operation
- Full init.d support for script runtime loading
- Frandom genrator (23x faster than standard random function)

Download the latest version:

https://bit.ly/FiiOX5iiiV331

Thanks and Rants

Massive thanks to prispewnic from 4PDA for his incredible scripting experience, product features, suggestions and testing, and the great community of beta testers on Head-Fi and 4PDA.

Thanks also to @FiiO for releasing the GPL source code. If it weren’t for you we wouldn’t have this modded kernel.

Next Steps

As of Version 3.x, the amount of outstanding (tangible) functionality is now limited, and in developing this version it’s become apparent that there is a lot of Android/OS based limitations. Thus I’d like to next focus on building a proper bespoke X5iii custom firmware that best enhances the audio and performance functionality at an OS level as well. I don’t have a depth of knowledge on this, so am now reaching my own (limited) understanding of kernel and Android development, thus I’ll also be creating a specific topic on xda-developers and reddit to reach out for more specific help on the technical aspect; but this topic will still remain active and focused on the audio part.

As always, any queries, comments etc - please shout.

Changelog
=========

Version 3.31
Fix: Reverted Page writeback tweaks (caused random reboots)
Fix: Minor AROMA fixes

Version 3.3
New: Enabled ARM ARCH_POWER feature
New: Disabled Gentle_Fair_Sleepers (much faster)
New: Enabled cache wakeup preemption
New: Forced memory overcommit for better performance
New: Ignore all ICMP echo requests
New: Enable TCP low latency
New: Removed noatime and nodiratime to improve ext4 and sys filesystem performance (much faster)
New: Added asynchronous filesystem calls (much faster)
New: Enable TCP reuse read mostly algorithm
New: Enable TCP sysctl recycle algorithm
New: Disable TCP slow start after idle
Enhanced: Optimised SLUB memory allocator
Enhanced: Reduced Mini Memory Map to from 32k to 0
Enhanced: Reduced Max Block Dev size from 128 to 32
Enhanced: Increased Max Queue length from 128 to 1024
Enhanced: Tuned kernel fair scheduler workload parameters
Enhanced: Increased memory threshold compaction from 500 to 800
Enhanced: Reduced dirty write back interval
Enhanced: Increased sysctl read interval for reduced latency
Enhanced: Optimise TCP sack/fack/dsack read requests
Enhanced: Optimise TCP memory pressure
Enhanced: Optimise TCP proto packet length algorithm

Version 3.2
New : Added RCU Synchronization Mechanism (much faster)
New : Optimised RCU Settings
New : Added s2idle S0 state (better battery lifetime)
Enhanced: Voltage optimisation for 2016MHz kernel
Enhanced: Updated hosts file - 135385 exceptions for no spamware, faster browsing
Fix: Minor Bugfixes
AROMA: Added "Restore" section
AROMA: Added "Support the Project" section
AROMA: Reworked logic and scripts

Version 3.11

Miscellaneous bugfixes

Version 3.1

Single installer for all kernel versions
New optimised voltages for 1416, 1704 and 2016 kernels (more stable and better performance)
Customisable removal of unwanted system applications
Customisable removal of system equalizer
Customising different audio_flinger libraries (different sound profiles to suit taste)
Enable/Disable Boot-up animation
Enable/Disable custom application on bootup

Version 3.02

New: 1704MHz release for players that can work at higher frequencies than 1416MHz (install this version if you previously had reboots at 2016MHz)
Enhanced: Increased stability without performance decrease
Enhanced: CPU down-volting for performance kernel version (2016MHz)
Fix: Removed additional CPU frequencies for 1416MHz kernel version (increased stability)

Version 3.01

New: 1752MHz intermediary version
Enhanced: More step frequencies from 504 to 2016MHz
Enhanced: Better handling of frequencies at high CPU loads
Enhanced: Powersave governor enabled by default

Version 3.0

New: Upstreamed relevant portions of kernel source code to Linux 3.10.49
New: AdFree hosts file - 67825 exceptions for no spamware, faster browsing
New: Support for DSD256
New: CPU Boost algorithm to increase frequency on screen touch
New: RQ Affinity for faster I/O scheduling
New: CPU SMP feature for faster processing
New: PegasusQ CPU governor
New: Improved interactiveX governor with increased performance and more power saving on idle (2 core shutdown)
New: Custom AK4490 driver with up to 768kHz oversampling
New: Custom plugin module for AK4490 to add more audio filters in future
New: CPU Maximum overclocking to 2016MHz! (Super significant performance improvement)
New: Current CPU frequency 1896MHz (Significant performance improvement and good stability)
New: GPU overclocking to 500MHz (More fluid screen responsiveness)
New: DDR overclocking to 720MHz (Ultra-fast memory and software processing)
New: Reduced Graphics requirements from 225MB down to 80MB (20% more available RAM)
New: Adaptive Low Memory Killer (A-LMK) algorithm
New: A-LMK optimised scripting (thanks again to prispewnic)
New: Compaction algorithm for low memory killer
New: FiiO RK3188/RK3188T efuse algorithm handling
New: VM Pressure algorithm implementation
Enhanced: zram and zcache now compressed with LZ4
Enhanced: better voltage regulation code
Enhanced: support for apll, cpll and gpll clocks on RK30 board
Enhanced: better GPIO code specific to FiiO player
Enhanced: removed unnecessary encryption
Enhanced: lowered minimum screen brightness for better battery lifetime

Version 2.8
Performance Build

New: Disabled CRC checking in all kernel code (significant performance improvement)
New: Optimised compilation parameters (-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer)
New: Fine-tuned kernel optimisation for RK3188 (-mtune=cortex-a9)
New: Optimised ARM RWSEM algorithm

Version 2.7

New: Redesigned Busybox installer
New: Redesigned Permissive SE Linux installer
New: Kernel version now displayed in settings
Fix: Corrections to anyone who was not seeing the msg "Kernel optimisation Ready" prompt

Version 2.6

New: UKSM instead of KSM (much faster)
New: ZRAM (more RAM)
New: fsync_disable (much, much faster)
New: ROW I/O scheduler for SD cards (much faster)
New: LZ4 Compression instead of LZO (faster, more compression)
New: zsmalloc implementation instead of xsmalloc
New: zcache enabling (faster)
New: ARM RSEM implementation (faster)
New: frandom generator instead of random (much, much faster)
New: MSG pop-up notification daemon
Fix: Lowered voltage for some FiiO players with lower-grade VCOs
Fix: Corrected git file dependencies
Fix: Disabled system animation by default

Version 2.5

New: Increased max clock speed to 1752MHz (faster)
New: BFQ I/O scheduler (faster)
New: Westwood TCP/IP congestion protocol (much faster)
New: InteractiveX governor (much, much, much faster)
Fix: Stability checks to voltage
Fix: iX handling changes

Version 2.4

New: Maple I/O Scheduler (faster)
New: init.d full support (much, much faster)
New: init.d scripts (thanks prispewnic @ 4PDA)

Version 2.3

New: Zen I/O scheduler (much faster)

Version 2.2

Fix: Changes to scheduler priorities during screen off (faster)

Version 2.1

New: Additional GPU and DDR overclocking (much, much faster)

Version 1.4

New: Update to Linaro gcc 4.9.4 (significantly much faster)

Version 1.3

New: SIO I/O scheduler (faster)
New: VR I/O scheduler (faster)
New: CPU clock to 1704MHz (much, much faster)

Version 1.2

New: Additional voltage optimisation and DDR overclocking

Version 1.1

New: GPIO optimisation and documentation
New: CPU clock to 1518MHz (faster)

Version 1.0

Initial system release and branch-off from FiiO GPL code


Installation instructions:

1) Windows and/or first time users

If you already have TWRP or a previous version of my kernel, go to step 2.

a) If you don't yet have TWRP and/or any previous version of my kernel yet, download the Windows-based loader here and unzip to a folder

https://www.androidfilehost.com/?fid=1395089523397899882
(note: you need to have the FiiO USB Windows drivers correctly installed)

b) Run the AndroidTool.exe program and connect the FiiO via USB.

c) Put the player in bootloader mode (just as if you were going to upgrade the player the traditional FiiO way with the Windows based loader), by pressing power+pause+back.

d) If all goes well you should see the green light with 'Found One Loader Device'. Make sure 'boot' and 'recovery_twrp' are selected and press Run. Once done, click the 'Advanced Function' tab and click Reset Device. You should have the new kernel and TWRP installed!

2) TWRP users

a) Download the latest version of the kernel (with new optimisation scripts) above and push to sdcard

b) Reboot to TWRP recovery

c) Install -> FiiO-X5iii-jkbuha-V2.6-TWRP.zip

d) Wipe kernel and dalvik cache

e) Reboot

f) IMPORTANT: leave running for new scripts to do their magic (you will be prompted to reboot)

g) Reboot

h) Enjoy :)


As always, any queries, comments etc - please shout.
 
Last edited:
May 3, 2019 at 5:52 PM Post #2 of 575
Scripting

This post will be for custom run-time scripts or installable via TWRP.
All credits go to prispewnic of 4PDA.

1) Disable System EQ

This script removes any system-level sound equalisation and restores the sound to a more 'balanced' and 'neutral' envelope, without the soundfx and musicfx libraries.

Installation:

1. Move the archive [FiiO-X5III-DisableEQ-v1.1.zip] to the internal SD card
2. Flash the package with TWRP (Pre-wipes do not need it)
3. After the installation is completed, restart the player

Install via TWRP:
https://www.androidfilehost.com/?fid=1395089523397958862

2) Disable Stock Apps

This script disables a part of system applications and removes uncessary system files to free up RAM of your device and thus have more memory.

Installation:

1. Move the archive [FiiO-X5III-DisableStockApps-v1.0.zip] to the internal SD card
2. Flash the package with TWRP (Pre-wipes do not need it)
3. After the installation is completed, restart the player in the system

⚠️ Users of the custom FiiO-X5III-jkbuha kernel will be loaded into the "first boot" state after the flashing this script.
⚠️ After the end of the process of optimizing system applications, you will receive a notification "PLEASE REBOOT DEVICE", similar to the first boot, after installing the custom kernel.

Comment :

List of disabled system applications :

BasicDreams (Standard Screensavers)
Browser (Internet browser)
CaptivePortalLogin (Connecting to private Wi-Fi networks. Does not affect Wi-Fi operation)
DeskClock (Clock application. Not applicable to system clock)
Email (Email Client)
Exchange2 (Part of email client)
Galaxy4 (Screensaver)
GoogleJapanese (Japanese keyboard, for system keyboard)
HoloSpiralWallpaper (Screensaver)
LiveWallpapers (Live Wallpaper)
LiveWallpapersPicker (Part of live wallpaper)
NoiseField (Live Wallpaper)
PacProcessor (Proxy Handler)
PhaseBeam (Live Wallpaper)
PinyinIME (Chinese layout, for system keyboard)
RKUpdateService (Update RK chips. Not relevant.)
VisualizationWallpapers (Live Wallpaper)
WAPPushManager (Responsible for the work of WAP)

The script does not affect critical system applications, Google components and Google Play Market.

To return the necessary applications:

1. Go to the directory: /system/app/X-Backup/(backup date)/
2. Copy the necessary applications back to the /system/app/ folder (you do not need to set the owner’s rights)
3. Restart the device.

Install via TWRP:
https://www.androidfilehost.com/?fid=1395089523397958861
 

Attachments

  • FiiO-X5III-DisableEQ-v1.1.zip
    321.3 KB · Views: 0
Last edited:
May 3, 2019 at 5:53 PM Post #3 of 575
This post intentionally left blank (for now :) )
 
May 4, 2019 at 8:28 AM Post #5 of 575
Two new scripts added to second post:

1) Disable System EQ
2) Disable Stock Apps

Credits all go to prispewnic from 4PDA
 
May 4, 2019 at 4:49 PM Post #7 of 575
Is it possible to make a less aggressive LKM version?

Yes, and I'd strongly suggest you modify your own settings to suit your own specific configuration.

There are two main ways:

1) Modify the boot-scripts.
Edit /etc/init.d/60main and change the following lines:
Code:
echo '2048,4096,6144,12288,16384,24576' > /sys/module/lowmemorykiller/parameters/minfree
echo '1' > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk

A *lower* value will apply less aggressive settings. Eg: the settings above are for 8/16/24/48/64/96MB (very aggressive according to Android, but for just 1GB of RAM, very well optimised). Decrease x2 or x4 to suit. You can also disable ALMK, but I wouldn't advise it. It works very well for low memory targets.

2) Download Kernel Aduitor and change them via the app, but they will need to be applied every time the player is rebooted.
 
Last edited:
May 4, 2019 at 5:12 PM Post #8 of 575
Yes, and I'd strongly suggest you modify your own settings to suit your own specific configuration.

There are two main ways:

1) Modify the boot-scripts.
Edit /etc/init.d/60main and change the following lines:
Code:
echo '2048,4096,6144,12288,16384,24576' > /sys/module/lowmemorykiller/parameters/minfree
echo '1' > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk

A *lower* value will apply less aggressive settings. Eg: the settings above are for 8/16/24/48/64/96MB (very aggressive according to Android, but for just 1GB of RAM, very well optimised). Decrease x2 or x4 to suit. You can also disable ALMK, but I wouldn't advise it. It works very well for low memory targets.

2) Download Kernel Aduitor and change them via the app, but they will need to be applied every time the player is rebooted.

thanks
 
May 4, 2019 at 5:52 PM Post #9 of 575
Scripting

List of disabled system applications :

BasicDreams (Standard Screensavers)
Browser (Internet browser)
CaptivePortalLogin (Connecting to private Wi-Fi networks. Does not affect Wi-Fi operation)
DeskClock (Clock application. Not applicable to system clock)
Email (Email Client)
Exchange2 (Part of email client)
Galaxy4 (Screensaver)
GoogleJapanese (Japanese keyboard, for system keyboard)
HoloSpiralWallpaper (Screensaver)
LiveWallpapers (Live Wallpaper)
LiveWallpapersPicker (Part of live wallpaper)
NoiseField (Live Wallpaper)
PacProcessor (Proxy Handler)
PhaseBeam (Live Wallpaper)
PinyinIME (Chinese layout, for system keyboard)
RKUpdateService (Update RK chips. Not relevant.)
VisualizationWallpapers (Live Wallpaper)
WAPPushManager (Responsible for the work of WAP)

The script does not affect critical system applications, Google components and Google Play Market.
Any way for a user (simple method) to only disable some of these? I don't want to lose browser or email capabilities, but everything else can go.
 
May 4, 2019 at 6:12 PM Post #10 of 575
Yes that's a good point. Probably the best way to go about this would be to have a menu/option based launcher in TWRP that would allow you to select which ones to remove. We had also discussed using a similar mechanism for selecting the max CPU frequency at install time as well.

Will be working on this shortly.
 
May 13, 2019 at 1:22 PM Post #11 of 575
Dear Head-Fi community

After weeks of testing, prispewnic and I are pleased to announce Version 3.1 of the X5iii modded kernel. This release has been completely prepared by prispewnic, is fully menu- and wizard-based and takes the customisation of the player to the next level.

Changelog

Version 3.1
  • Single installer for all kernel versions
  • New optimised voltages for 1416, 1704 and 2016 kernels (more stable and better performance)
  • Customisable removal of unwanted system applications
  • Customisable removal of system equalizer
  • Customising different audio_flinger libraries (different sound profiles to suit taste)
  • Enable/Disable Boot-up animation
  • Enable/Disable custom application on bootup
Download

http://bit.ly/FiiOiiiv31

Installation

1. Move the archive [FiiO-X5iii-jkbuha-V3.1-TWRP-MULTI.zip] to the root of the player’s memory (To the internal SD card)
2. Flash the package with TWRP (Pre-wipes do not need to)
3. Follow all stages of the installer
4. After the installation is completed, restart the player in the system
5. Next, the scripts will perform the initial optimization of the system, after which the notification "KERNEL 3.1: PLEASE REBOOT DEVICE" will be displayed.

If you do not restart the system yourself, it will restart automatically in 20 minutes. With every future boot, after each system is turned on, you will receive a notification 'KERNEL 3.1: ALL OPTIMIZATIONS DONE!'. It takes 15-20 seconds to complete all scripts (on average).

Additional Installer Information

If you select the Default installation option in the installer, the kernel will be installed with the following parameters:
  • Kernel type (1416 MHz)
  • No disabling of system applications
  • No disabling of system equalizers;
  • No replacing audio_flinger;
  • No disabling the startup animation
  • Blank autostart template
  • No custom application on start
Disable system equalizers

* If you select the option "Do not disable / Restore", the files will be restored if they were disabled by the installer of the custom kernel 3.1 or by the script FiiO-X5III-DisableEQ-v1.1

Disable system loading animation

** If you select the option "Do not turn off / Restore", the files will be restored in the event that they were not deleted by the user forcibly. Otherwise, instead of FiiO boot animation, you will see Android animation.

App Autostart

*** If you select the option “Leave unchanged”, a blank template will be added to the 60Main script located in the /system/etc/init.d/ directory to automatically launch any application. Same as found in kernel version 3.0.2.

Thanks and Rants

This release was almost entirely prispewnic's work; his incredible knowledge on audio files and AROMA installers have resulted in this great easy-to-use installer. Thanks also to the extensive testers on this release; we truly are pushing the limits of this FiiO X5 player.

Enjoy :)
 
May 13, 2019 at 7:14 PM Post #14 of 575
I may have just bricked my device. Won't reboot past "Welcome". Simply shuts down. When I reboot to TWRS, attempt various remedies and then hit "reboot system", TWRS tells me "No Operating System Found, are you sure you wish to reboot?"......

I've worked on this for an hour and am dead in the water. Any suggestions?

Powderphinger
 
May 13, 2019 at 7:35 PM Post #15 of 575
I may have just bricked my device. Won't reboot past "Welcome". Simply shuts down. When I reboot to TWRS, attempt various remedies and then hit "reboot system", TWRS tells me "No Operating System Found, are you sure you wish to reboot?"......

I've worked on this for an hour and am dead in the water. Any suggestions?

Powderphinger

have you tried to flash back firmware 1.2.1 via the official firmware upgrade tool?
 

Users who are viewing this thread

Back
Top