Video Tutorial on How to Compile Android and Modify Kernels

video

For those interested, I have just posted a video tutorial series on XDA for building Android Oreo, Nougat, Marshmallow, and Lollipop on 5 different phones, the emulator, and 5 different ROMs. Also included are custom kernel editing, adding apps, changing source code, backgrounds, and more. Here’s what I posted:

From XDA: https://forum.xda-developers.com/android/general/guide-how-to-build-custom-roms-kernel-t3814251

===========================================================================

Praise God! Finally a video tutorial of how to build Android and modify kernels!

I have created a video tutorial and guide for how to compile Android, from Lollipop through Marshmallow, Nougat, and Oreo. The video series covers several different phones, the emulator, kernel and rom editing, app source code editing, and much more!

Who is this video series for?
Well, this video tutorial is a step by step guide built primarily for the beginner. This is written for those who already know how to flash TWRP, CWM, or the like, and who have installed a custom rom before. This is designed to help those who are ready to move up from flashing and installing other peoples custom rom to actually start making their own custom roms. I recommend that a beginner watch the entire series in numerical/alphabetical order (the videos are marked).

That said, I believe that an intermediate developer may find a useful trick here and there, and they should just skip ahead to videos of interest. Perhaps kernel development, or something along those lines.

An advanced rom/kernel developer will probably far exceed my feeble abilities, and will not likely find much useful information here. Perhaps if you are an advanced developer, you would consider continuing the tutorial or making an advanced video series! (See further posts for recommendations on contributing videos.)

Why did you put this together?
Well, after building roms for several different devices, I started receiving requests from users who wanted to start building their own roms, but didn’t know how. I didn’t have enough time to answer everyones questions, so I wrote a few guides, pointed others to guides that were available, but there are some things that you just need to see to understand. Hence, the video tutorial. I just hope that someone finds it useful.

This course was written in order! While Lollipop and Marshmallow are old by today’s standards, there is still good learning value in building them, and there are topics covered there that really make them worth watching.

What’s in the videos?
During the series, we will be building for the emulator, as well as 5 different phones of various brands, and 5 different roms. I hope that this will give the viewer a good idea of how to build for their own specific phone as they see the differences and similarities across the phones and custom roms.

[CODE]
+ Ubuntu installation
+ Java installations
+ Using Git, GitHub, GitKraken, and the command line
+ Fastboot and ADB
+ Heimdall/Odin
+ QFIL, QPST, SALT, and other tools
+ AOSP, SlimRoms, PACrom, AOKP, AOSCP
+ Lollipop, Marshmallow, Nougat, Oreo
+ Errors
+ Overclocking CPU/GPU
+ Adding Governors and I/O Schedulers
+ Sound modifications
+ Changing app colors, text, and icons
+ Adding prebuilt apps
+ Adding source code
+ Converting device from one rom to another
+ AND MORE!
[/CODE]

**** This is an UNOFFICIAL TUTORIAL. Use at your own risk! ****
Download links:
Ogg Vorbis Video GitLab:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide[/url]
Clicking on a video in GitLab will allow you to watch it online.

Ogg Vorbis Video Downloads:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide/-/archive/master/course_android_developer_guide-master.zip[/url]
This download is rather large due to the multiple videos.

MP4 Video GitLab:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide_mp4[/url]
Clicking on a video in GitLab will allow you to watch it online.

MP4 Video Downloads:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide_mp4/-/archive/master/course_android_developer_guide_mp4-master.zip[/url]
This download is rather large due to the multiple videos.

I also have several written guides available on XDA, here are a few:

Building ROMs for the Galaxy Note Edge: [url]https://forum.xda-developers.com/note-edge/general/guide-build-aosp-roms-kernels-note-edge-t3488840[/url]
Building ROMs for the Galaxy S4: [url]https://forum.xda-developers.com/galaxy-s4-tmobile/general/guide-step-step-instructions-building-t3402637[/url]

===========================================================================

Be sure to check out the videos or the XDA thread! I hope that these will help some of the aspiring Android developers out there!

Linux – keep it simple.

Advertisements

Overclocked the Verizon Galaxy S5

Actually, I’m not the first one to do this. It’s been done dozens of times before, and quite frankly, to higher levels. So, why do I make my own kernel overclocked? Well, I do think there is one difference in my kernel overclocking than the others. I don’t increase the voltage while adding faster processing power.

Typically, in my kernels I try to focus on battery over performance. However, I like getting the most bang for the buck, too. So, in my kernel, I increased the frequency by 3%, but did not increase the voltage any. This allows the maximum benefit for the same amount of voltage, which equals an increase in performance, without an extra drain on the battery.

Okay, at least not a noticeable drain on the battery. Ohms law is still true, so the Resistance will drop slightly as the frequency went up, because of slightly higher heat, microscopically decreasing the resistance and changing the formula. However, when you increase the voltage, the Power formula changes dramatically.

For example, some fictitious numbers for conceptualization:

Power = Current x Voltage Let’s say, (P) 12 = (I) 2 x (E) 6.

If we increase the Voltage, the change is drastic: (P) 14 = (I) 2 x (E) 7.

If we don’t increase the voltage, the change is microscopic, only because the change in frequency will ultimately increase the heat (very slightly). In ohm’s law, that is I=E/R, so our formula looks like this: Power = Voltage/Resistance x Voltage, or (P) 12 = ([E] 6 / [R] 3) x (E) 6. So if the heat rises microscopically, then the semiconductor resistance lowers microscopically*, then the power will only change microscopically. So, our new fictitious formula looks like this: (P) 12.04 = ([E] 6 / [R] 2.99) x (E) 6.

Either way, you can check out the commit here:

https://github.com/alaskalinuxuser/android_kernel_samsung_klte/commit/dd3e95708f0f4166486fc4341691826ea303d993

Linux – keep it simple.

*Normally, in wire, heat increases cause the resistance to increase. However:

“In a semi-conductor, there is an energy gap between the (filled) valence and the (empty) conduction band. At zero temperature, no charges are in the conduction band and the resistance should be infinite as the system behaves basically like an insulator. If you turn on the temperature, some electrons will start to occupy the conduction band and thus contribute to conduction, lowering the [resistance].”  https://physics.stackexchange.com/users/661/lagerbaer

 

CPU and GPU voltage control are back!

CPU and GPU voltage control are back! To God be the glory!

Since moving to Android Nougat, I have not been able to make GPU and CPU voltage control work for the Samsung Galaxy S4, but that changed today. You can see the commit here:

https://github.com/alaskalinuxuser/android_kernel_samsung_jf/commit/9544cab218a4348563067588b8b607d6e9d7ab11

Finally the end user has the ability to control the CPU and GPU voltage with apps like Kernel Adiutor and my GPU Voltage Control App.

You can find my GPU voltage control app here:

https://forum.xda-developers.com/galaxy-s4-tmobile/themes-apps/app-gpu-voltage-control-app-aklu-kernels-t3506985

Remember, changing your CPU or GPU voltages is dangerous. Don’t make drastic changes, and be careful!

Linux – keep it simple.

Samsung Galaxy S5 kernels

Below are some kernels for the Samsung Galaxy S5. You can find the source code here:

https://github.com/alaskalinuxuser

Praise God! The AKLU kernel has arrived on the Galaxy S5 in the flavor of NOUGAT!

Here is the latest download for AOKP Nougat, it may work on CM, PAC, or RR:

http://www.mediafire.com/file/iwwcjaw6ab96rv3/AKLU-KLTE-AOKP-N-20170530.zip

Change log:

+ Added KTOONSEZ Voltage control!
– Can be controlled from Kernel Adiutor or other apps. WARNING! THIS IS DANGEROUS!

20170524
+ Overclocked CPU from 2457 MHz to 2533 MHz
– A 3% gain without increasing voltage!

20170518
+ Added Governors:
– SmartMax
– Wheatley
– LionHeart
– Already had: Powersave, Interactive, Conservative, Ondemand, Userspace.

Enjoy!

Linux – keep it simple.

Fixing a WiFi hotspot issue

While working on the JFLTETMO (Samsung Galaxy S4) I ran into an error with the WiFi hotspot, but only after flashing my custom kernel. So, I grabbed my USB cable, and pulled a logcat over ADB, while trying to use the WiFi hotspot feature.

Here’s what the logs read:

[CODE]

01-26 10:42:10.483 578 723 D AudioService: Stream muted, skip playback
01-26 10:42:10.488 264 624 D SoftapController: Softap fwReload – Ok
01-26 10:42:11.622 578 712 D wifi : set interface wlan0 flags (UP)
01-26 10:42:11.622 578 712 I WifiHAL : Initializing wifi
01-26 10:42:11.622 578 712 I WifiHAL : Creating socket
01-26 10:42:11.631 578 712 I WifiHAL : Initialized Wifi HAL Successfully; vendor cmd = 103
01-26 10:42:11.631 578 712 D wifi : Did set static halHandle = 0x9c9380e0
01-26 10:42:11.631 578 712 D wifi : halHandle = 0x9c9380e0, mVM = 0xb42f8000, mCls = 0x201fb2
01-26 10:42:11.631 578 712 D wifi : array field set
01-26 10:42:11.645 578 712 E wifi : failed to get channel list : -95
01-26 10:42:11.645 578 712 D wifi : set country code: US
01-26 10:42:11.651 578 10453 I WifiNative-HAL: Waiting for HAL events mWifiHalHandle=-1668054816
01-26 10:42:11.651 578 10453 D wifi : waitForHalEvents called, vm = 0xb42f8000, obj = 0x201fb2, env = 0x9cc0ecd0
01-26 10:42:11.654 264 624 D SoftapController: SoftAP started successfully
01-26 10:42:11.751 10455 10455 E hostapd : Configuration file: /data/misc/wifi/hostapd.conf
01-26 10:42:11.765 10455 10455 I hostapd : rfkill: Cannot open RFKILL control device
01-26 10:42:11.785 10455 10455 E hostapd : Using interface wlan0 with hwaddr d0:22:be:45:9e:d0 and ssid “AndroidAPun”
01-26 10:42:11.854 264 624 D SoftapController: /data/misc/wifi/sockets already exists
01-26 10:42:11.855 264 10471 D SoftapController: SoftapController::threadStart…
01-26 10:42:11.855 264 10471 D SoftapController: /data/misc/wifi/sockets already exists
01-26 10:42:11.856 578 712 D SoftApManager: Soft AP is started
01-26 10:42:11.871 10455 10455 I hostapd : wlan0: interface state UNINITIALIZED->ENABLED
01-26 10:42:11.871 10455 10455 I hostapd : wlan0: AP-ENABLED
01-26 10:42:11.871 578 712 E wifi : wifi_get_supported_feature_set returned error = 0xffffffa1
01-26 10:42:11.872 578 609 E BatteryStatsService: no controller energy info supplied
01-26 10:42:11.898 264 624 D CommandListener: Setting iface cfg
01-26 10:42:11.900 264 624 D CommandListener: Trying to bring up wlan0
01-26 10:42:11.909 264 624 D TetherController: tetherInterface(wlan0)
01-26 10:42:12.052 264 624 D TetherController: Setting IP forward enable = 1
01-26 10:42:12.058 264 624 D TetherController: Starting tethering services
01-26 10:42:12.060 264 624 D TetherController: Sending update msg to dnsmasq [update_ifaces|wlan0]
01-26 10:42:12.060 264 624 D TetherController: Tethering services running
01-26 10:42:12.064 578 578 D Tethering: got Sim changed to state LOADED, mSimAbsentSeen=false
01-26 10:42:12.064 578 628 D ConnectivityService: requestNetwork for uid/pid:1000/578 NetworkRequest [ TRACK_DEFAULT id=9, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
01-26 10:42:12.067 578 735 D Ethernet: got request NetworkRequest [ TRACK_DEFAULT id=9, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 50
01-26 10:42:12.068 578 712 D WIFI : got request NetworkRequest [ TRACK_DEFAULT id=9, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 50
01-26 10:42:12.068 578 712 D WIFI_UT : got request NetworkRequest [ TRACK_DEFAULT id=9, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 50
01-26 10:42:12.069 923 923 D PhoneSwitcherNetworkRequstListener: got request NetworkRequest [ TRACK_DEFAULT id=9, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ] with score 50
01-26 10:42:12.072 578 707 W ConnectivityExtension: ConnectivityExt jar file not present
01-26 10:42:12.103 578 628 W ConnectivityExtension: ConnectivityExt jar file not present
01-26 10:42:12.104 578 628 I Tethering: Finding IPv4 upstream interface on: {InterfaceName: rmnet_usb0 LinkAddresses: [10.44.167.240/30,] Routes: [0.0.0.0/0 -> 10.44.167.241 rmnet_usb0,] DnsAddresses: [172.20.64.179,172.20.64.180,] Domains: null MTU: 1410 TcpBufferSizes: 2097152,4194304,8388608,262144,524288,1048576}
01-26 10:42:12.104 578 628 I Tethering: Found interface rmnet_usb0
01-26 10:42:12.105 264 624 D TetherController: setDnsForwarders(0xf0064 0 = ‘172.20.64.179’)
01-26 10:42:12.106 264 624 D TetherController: setDnsForwarders(0xf0064 1 = ‘172.20.64.180’)
01-26 10:42:12.106 264 624 D TetherController: Sending update msg to dnsmasq [update_dns|0xf0064|172.20.64.179|172.20.64.180]
01-26 10:42:12.110 264 624 V NatController: enableNat(intIface=, extIface=)
01-26 10:42:12.125 10499 10499 I dnsmasq : started, version 2.51 cachesize 150
01-26 10:42:12.125 10499 10499 I dnsmasq : compile time options: IPv6 GNU-getopt no-DBus no-I18N DHCP no-scripts no-TFTP
01-26 10:42:12.125 10499 10499 W dnsmasq : warning: no upstream servers configured
01-26 10:42:12.125 10499 10499 I dnsmasq : DHCP, IP range 192.168.49.2 — 192.168.49.254, lease time 1h
01-26 10:42:12.126 10499 10499 I dnsmasq : DHCP, IP range 192.168.48.2 — 192.168.48.254, lease time 1h
01-26 10:42:12.126 10499 10499 I dnsmasq : DHCP, IP range 192.168.47.2 — 192.168.47.254, lease time 1h
01-26 10:42:12.127 10499 10499 I dnsmasq : DHCP, IP range 192.168.46.2 — 192.168.46.254, lease time 1h
01-26 10:42:12.127 10499 10499 I dnsmasq : DHCP, IP range 192.168.45.2 — 192.168.45.254, lease time 1h
01-26 10:42:12.127 10499 10499 I dnsmasq : DHCP, IP range 192.168.44.2 — 192.168.44.254, lease time 1h
01-26 10:42:12.127 10499 10499 I dnsmasq : DHCP, IP range 192.168.43.2 — 192.168.43.254, lease time 1h
01-26 10:42:12.127 10499 10499 I dnsmasq : DHCP, IP range 192.168.42.2 — 192.168.42.254, lease time 1h
01-26 10:42:12.127 10499 10499 I dnsmasq : read /etc/hosts – 2 addresses
01-26 10:42:12.128 10499 10499 I dnsmasq : Closing wildcard listener family=2
01-26 10:42:12.128 10499 10499 I dnsmasq : Closing wildcard listener family=10
01-26 10:42:12.129 10499 10499 I dnsmasq : using nameserver 172.20.64.180#53
01-26 10:42:12.129 10499 10499 I dnsmasq : using nameserver 172.20.64.179#53
01-26 10:42:12.146 264 624 V NatController: runCmd(/system/bin/iptables -w -t nat -A natctrl_nat_POSTROUTING -o rmnet_usb0 -j MASQUERADE) res=0
01-26 10:42:12.168 264 624 V NatController: runCmd(/system/bin/ip6tables -w -A natctrl_FORWARD -g natctrl_tether_counters) res=0
01-26 10:42:12.190 264 624 V NatController: runCmd(/system/bin/iptables -w -A natctrl_FORWARD -i rmnet_usb0 -o wlan0 -m state –state ESTABLISHED,RELATED -g natctrl_tether_counters) res=0
01-26 10:42:12.221 264 624 V NatController: runCmd(/system/bin/iptables -w -A natctrl_FORWARD -i wlan0 -o rmnet_usb0 -m state –state INVALID -j DROP) res=0
01-26 10:42:12.245 264 624 V NatController: runCmd(/system/bin/iptables -w -A natctrl_FORWARD -i wlan0 -o rmnet_usb0 -g natctrl_tether_counters) res=0
01-26 10:42:12.285 264 624 V NatController: runCmd(/system/bin/ip6tables -w -t raw -A natctrl_raw_PREROUTING -i wlan0 -m rpfilter –invert ! -s fe80::/64 -j DROP) res=1
01-26 10:42:12.337 264 624 V NatController: runCmd(/system/bin/iptables -w -D natctrl_FORWARD -i wlan0 -o rmnet_usb0 -g natctrl_tether_counters) res=0
01-26 10:42:12.373 264 624 V NatController: runCmd(/system/bin/iptables -w -D natctrl_FORWARD -i wlan0 -o rmnet_usb0 -m state –state INVALID -j DROP) res=0
01-26 10:42:12.405 264 624 V NatController: runCmd(/system/bin/iptables -w -D natctrl_FORWARD -i rmnet_usb0 -o wlan0 -m state –state ESTABLISHED,RELATED -g natctrl_tether_counters) res=0
01-26 10:42:12.405 264 624 E NatController: Error setting forward rules
01-26 10:42:12.435 264 624 V NatController: runCmd(/system/bin/iptables -w -F natctrl_FORWARD) res=0
01-26 10:42:12.464 264 624 V NatController: runCmd(/system/bin/ip6tables -w -F natctrl_FORWARD) res=0
01-26 10:42:12.494 2699 2715 E MP-Decision: Error(-22) changing core 3 status to offline
01-26 10:42:12.494 2699 2715 E MP-Decision: Error(-22) changing core 2 status to offline
01-26 10:42:12.494 2699 2715 E MP-Decision: Error(-22) changing core 1 status to offline
01-26 10:42:12.541 264 624 V NatController: runCmd(/system/bin/iptables -w -A natctrl_FORWARD -j DROP) res=0
01-26 10:42:12.577 264 624 V NatController: runCmd(/system/bin/iptables -w -t nat -F natctrl_nat_POSTROUTING) res=0
01-26 10:42:12.614 264 624 V NatController: runCmd(/system/bin/ip6tables -w -t raw -F natctrl_raw_PREROUTING) res=0
01-26 10:42:12.616 578 628 E NetdConnector: NDC Command {82 nat enable wlan0 rmnet_usb0 1 192.168.43.0/24} took too long (507ms)
01-26 10:42:12.618 578 628 E TetherInterfaceSM: Exception enabling Nat: java.lang.IllegalStateException: command ’82 nat enable wlan0 rmnet_usb0 1 192.168.43.0/24′ failed with ‘400 82 Nat operation failed (No such device)’
01-26 10:42:12.620 264 625 D TetherController: Sending update msg to dnsmasq [update_ifaces|wlan0]
01-26 10:42:12.623 264 624 D TetherController: untetherInterface(wlan0)
01-26 10:42:12.695 264 624 D CommandListener: Setting iface cfg
01-26 10:42:12.699 264 624 D CommandListener: Trying to bring down wlan0
01-26 10:42:12.948 10455 10455 I hostapd : wlan0: INTERFACE-DISABLED
01-26 10:42:12.966 264 624 D TetherController: setDnsForwarders(0xf0064 0 = ‘172.20.64.179’)
01-26 10:42:12.966 264 624 D TetherController: setDnsForwarders(0xf0064 1 = ‘172.20.64.180’)
01-26 10:42:12.966 264 624 D TetherController: Sending update msg to dnsmasq [update_dns|0xf0064|172.20.64.179|172.20.64.180]
01-26 10:42:12.968 10499 10499 I dnsmasq : using nameserver 172.20.64.180#53
01-26 10:42:12.968 10499 10499 I dnsmasq : using nameserver 172.20.64.179#53
01-26 10:42:12.984 264 624 D TetherController: Stopping tethering services
01-26 10:42:12.984 10499 10499 I dnsmasq : exiting on receipt of SIGTERM
01-26 10:42:12.986 264 624 D TetherController: Tethering services stopped
01-26 10:42:12.997 264 624 D TetherController: Setting IP forward enable = 0
01-26 10:42:13.002 578 716 D ConnectivityService: releasing NetworkRequest [ TRACK_DEFAULT id=9, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN] ]
01-26 10:42:13.101 578 707 W ConnectivityExtension: ConnectivityExt jar file not present
01-26 10:42:13.504 2699 2715 E MP-Decision: Error(-22) changing core 3 status to offline
01-26 10:42:13.505 2699 2715 E MP-Decision: Error(-22) changing core 2 status to offline
01-26 10:42:13.505 2699 2715 E MP-Decision: Error(-22) changing core 1 status to offline
01-26 10:42:13.875 264 10471 D SoftapController: Get event from hostapd (INTERFACE-DISABLED )
01-26 10:42:13.877 578 627 D NetworkManagement: onEvent: 618 90 IfaceMessage active INTERFACE-DISABLED
01-26 10:42:13.877 578 627 E NetdConnector: Error handling ‘618 90 IfaceMessage active INTERFACE-DISABLED ‘: java.lang.ArrayIndexOutOfBoundsException: length=5; index=5

[/CODE]

There is a lot in there, but one of the highlights is that it did start the interface, set it up, and then couldn’t forward anything on it:

01-26 10:42:12.405 264 624 E NatController: Error setting forward rules

So, I ran back through my configurations, and compared them to the original CM configs, and found two things that I should enable. You can check out the commit here:

https://github.com/alaskalinuxuser/android_kernel_samsung_jf/commit/fe3fae847fe12c48515513654ac1dba2e088a0e2

Essentially, I enabled Reverse Path Filtering, you can read about it here. Basically, it filters out what should be ignored or included as a packet to/from your network. I can’t believe that I missed that. Seems pretty integral to packet forwarding, routing, and other “path” tools for packets. By God’s grace, enabling it fixed the problem and made the WiFi hotspot work again!

Linux – keep it simple.

Wframe-larger-than error!

It’s been a while since I’ve seen this happen, and although I’ve mentioned it before, it just goes to show that it is an ongoing issue. Let’s take a look at the output of the compiler:

[CODE]
/home/alaskalinuxuser/compile/build_cm14/kernel/samsung/tblte/drivers/input/touchscreen/wacom/wacom_i2c_flash.c: In function ‘wacom_i2c_flash’:
/home/alaskalinuxuser/compile/build_cm14/kernel/samsung/tblte/drivers/input/touchscreen/wacom/wacom_i2c_flash.c:622:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]
error, forbidden warning: wacom_i2c_flash.c:622
make[5]: *** [drivers/input/touchscreen/wacom/wacom_i2c_flash.o] Error 1
make[4]: *** [drivers/input/touchscreen/wacom] Error 2
make[3]: *** [drivers/input/touchscreen] Error 2
make[2]: *** [drivers/input] Error 2
make[1]: *** [drivers] Error 2
make[1]: *** Waiting for unfinished jobs….
[/CODE]

The key part being here:

warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]
error, forbidden warning: wacom_i2c_flash.c:622

Typically, a warning is not going to stop your build process, but in some cases, the warning is so severe that it is flagged by predetermined settings that this type of warning would be an error. Errors, of course, stop the build.

In the case of frames being too large, I have usually found that (if it built sucessfully for someone else) the toolchain you are using is not sufficient for the task. So I headed over to UBERTC to download a newer toolchain.

https://bitbucket.org/UBERTC/

And, after downloading it, extracting it, and placing it in the build_cm14/prebuilts/gcc/linux-x86/arm folder, I then edited my device/samsung/tblte-common/BoardConfigCommon.mk file, like so:

[CODE]
KERNEL_TOOLCHAIN := /home/alaskalinuxuser/compile/build_cm14/prebuilts/gcc/linux-x86/arm/UBERTC-5.3/bin
KERNEL_TOOLCHAIN_PREFIX := arm-eabi-
[/CODE]

And away we go, there turned out to be some other errors as well, but this did solve the “too large” problem, as the new toolset built it in a way that was within tolerance.

Linux – keep it simple.

Adding a hotplug alternative or option to a kernel

Today was a pretty fun day. By God’s grace, I was able to add intelli_plug, a hotplug alternative made by Faux123, to my JFLTE kernel! Adding a hotplug was a lot easier than I thought it would be, and only required one trimming of the code by Faux123 to make it work on my kernel.

Some of you may wonder, well, what IS a hotplug? A hotplug is a controller that chooses how many of your cpu cores are going to be used at once. I know that sounds a lot like a governor, but a governor governs at what frequency the core(s) are used, and a hotplugger allows you to turn off cores that do not need to be utilized right now. This saves you battery life, and also helps to keep your phone or computer cool.

So, here’s what I did to make it work.

First, I added the intelli_plug.c file, which I found here:
https://github.com/antaril/AGK-OMNI/commit/635fd311f456ca5ae4690180556014b1ffd3ef79
I would recommend that you use mine however, as I had to ammend 2 lines to make it work with the JFLTE kernel.

Then, I added the appropriate lines to kconfig:

[CODE]
config INTELLI_PLUG
bool “Enable intelli-plug cpu hotplug driver”
default y
help
Generic Intelli-plug cpu hotplug driver for ARM SOCs WJH 20161222
[/CODE]
and Makefile:

[CODE]
obj-$(CONFIG_INTELLI_PLUG) += intelli_plug.o
[/CODE]
in the arch/arm/mach-msm folder.

Then I recompiled it. Note that I set the default option to “y”, so I didn’t need to add intelli_plug to my arch/arm/config/files, it simply is added by default to any kernel I build with that tree. On first run, there was an error on this line:

unsigned int avg_nr_run = avg_nr_running();

and This line:

if (avg_nr_run <= (nr_threshold << (FSHIFT – nr_fshift)))

but avg_nr_running() did not exist elsewhere in the kernel, so I commented these out with the double forward slash “//”. Normally, I would think it needs that, but in this case it still works okay. Upon rebuilding, it whent smoothly, and seems to work great!

Linux – keep it simple.

How to add an I/O Scheduler to your kernel

How to add an I/O Scheduler to your kernel:

Praise God, another succesful addition to the TBLTE kernel was that of adding the FIOPS I/O scheduler to the kernel. What is an I/O scheduler? Well it is the part of the kernel that handles, or schedules, input and output. Particularly, this has to do with writing and reading to and from media, like your hard drive, flash drive, etc.

So, how do we do that? How do we add I/O schedulers to our kernel?

Well, for the TBLTE kernel, I will show you what I did, and you can add to your kernel similarly.

Go to the block folder in your kernel source. The first thing that you need to do is add the fiops-iosched.c file. Whatever I/O scheduler you want to add will be named like this: {NAME-iosched.c} you can search Google or github for them, or take them from my source if you would like.

Once you put your fiops-iosched.c file in your kernel’s ./block/ folder, you can now edit two other files in that folder. You need to add the new scheduler to the make file, so it knows to make it, you can do that like so:

Open ./block/Makefile and add this line after the other *-iosched.o lines:

[CODE]
obj-$(CONFIG_IOSCHED_FIOPS) += fiops-iosched.o
[/CODE]

Notice that it just uses the name of the iosched file, but with an “.o” extension instead of a “.c” extension. The “.c” file you added earlier will create a “.o” (object) file that the Kernel needs to use to “make” the kernel.

Now edit the ./block/Kconfig.iosched file like so:

[CODE]
config IOSCHED_FIOPS
tristate “FIOPS I/O scheduler”
default y
—help—
The FIOPS I/O scheduler. WJH.
[/CODE]

This way, when you are moddifying your configuration, you can select to build it. Notice that it is a “default y”, essentially, I am telling the config file creator to allways assume I want to build this, unless I choose not to. You can also eddit the “—help—” portion to say anything you want. I put my initials in there so I can find it easily with the search tool.

Now open your configuration file. For the stock builds, that would be ./arch/arm/configs/ap88084_sec_defconfig, and add this line:

[CODE]
CONFIG_IOSCHED_FIOPS=y
[/CODE]

Note that you could also do this through

[CODE]$ make menuconfig [/CODE]

.
You may also note, since we gave it a “default y” in the Kconfig.iosched file, we don’t actually need to add this to our configs, as it will be built by default, but I like to declare what I am building in my configs so I remember what I am doing.

There you go! Now when you build your kernel again, the FIOPS I/O scheduler will be added in. It is remarkably simple, just the way I like it. You can read the commit here: [url]https://github.com/alaskalinuxuser/kernel_samsung_tblte/commit/f80320a895612bd1379ca789f88f1d6dfd6e68f9[/url]

Linux – keep it simple.

 

Building a kernel for an Android phone without the rom source

For the record, I do not recommend building kernels this way, I recommend that you build them within your ROM source. This method will work, but is far more labor intensive. However, here is how to build the kernel for a Samsung Galaxy Note Edge on Ubuntu 14.04.

Part 1 – The setup:
Go to

[CODE]
$ sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2 git make -y
[/CODE]

This will take a while. Then:

[CODE]
$ cd ~
$ mkdir playground
$ cd playground/
$ mkdir toolchain
$ cd toolchain
[/CODE]

Now type this for 4.9:

[CODE]
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9
[/CODE]

OR this for 4.8, but for this I recommend 4.8.

[CODE]
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8
[/CODE]

The output either way should look like this:

[CODE]
Cloning into ‘arm-linux-androideabi-4.8’…
remote: Sending approximately 170.26 MiB …
remote: Counting objects: 124, done
remote: Finding sources: 100% (124/124)
………EDITED FOR SPACE………………
Resolving deltas: 100% (652/652), done.
Checking connectivity… done.
[/CODE]

That will take a few minutes. Then:

[CODE]
$ mkdir kernel
$ cd kernel
$ git clone https://github.com/alaskalinuxuser/kernel_samsung_tblte.git
Cloning into ‘kernel_samsung_tblte’…
remote: Counting objects: 49082, done.
remote: Compressing objects: 100% (32/32), done.
………EDITED FOR SPACE………………
Checking connectivity… done.
Checking out files: 100% (46422/46422), done.
[/CODE]

This will take another few minutes, maybe longer, depending on your internet connection.

Part 2 – The kernel modifications

Before going further, this is when you can edit the files of the kernel, add things, remove things from the kernel itself. See the other posts here for how to do that. When you are ready, you can move onto the build.

Part 3 – The build

Open ~/playground/toolchain/kernel/kernel_samsung_tblte/Makefile, and go to line 195, it should say ARCH, edit it as such:

[CODE]
ARCH =arm
CROSS_COMPILE =/home/{YOURUSERNAME}/playground/toolchain/arm-linux-androideabi-4.8/bin/arm-linux-androideabi-
[/CODE]

[CODE]
$ cd ~/playground/toolchain/kernel/kernel_samsung_tblte/
$ make clean
$ make mrproper
[/CODE]

You will likely see an error about TARGET, that is okay, just ignore it.

[CODE]
$ make menuconfig apq8084_sec_defconfig
[/CODE]

OR

[CODE]
$ make menuconfig apq8084_sec_tblte_eur_defconfig
[/CODE]

After some scrolling text, you will see a menu option. Use the arrow keys and the space bar to make selections. Make any changes you want. Remember, not all changes are good. With this setup, you will need to make changes to make this function.

Once you are done, select exit. Then select yes to save your config.

Now that you are back at the command line, all you have to do is type one more command:

[CODE]
$ make
[/CODE]

You will see a lot of scrolling text, like this:

[CODE]
arch/arm/kernel/return_address.c:63:2: warning: #warning “TODO: return_address should use unwind tables” [-Wcpp]
#warning “TODO: return_address should use unwind tables”
^
CC arch/arm/kernel/sched_clock.o
CC arch/arm/kernel/setup.o
CC arch/arm/kernel/signal.o
CC arch/arm/kernel/stacktrace.o
CC arch/arm/kernel/sys_arm.o
CC arch/arm/kernel/time.o
CC arch/arm/kernel/traps.o
CC arch/arm/kernel/atags_parse.o
CC arch/arm/kernel/cpuidle.o
[/CODE]

This is good. Make is making your kernel.
If you are good, or lucky, then it will compile successfully, if not, it will error. Check your changes and use Google to search for errors if you need help. Again, I recommend to build kernels within the backdrop of ROM source, as I mentioned in the other post, it is much, much easier. This method will work, but you may have to add or change a lot of options in your config to make it happen.

Linux – keep it simple.

 

Overclock an apq8084 Samsung Galaxy Note Edge!

In my continuing quest to make a better kernel for the Samsung Galaxy Note Edge (TBLTE, N915T), I decided to tackle overclocking the kernel. There are already some overclocked kernels out there, but I decided to do something slightly different with mine. The distinguishing feature of my overclocked kernel is that it doesn’t use any more power than it did before, and to God be the glory, it worked!

I also feel that when you overclock a chip, you are increasing the rate of failure, and the induced heat load. So I like to keep my overclocking light, less than 10% of the overall capacity that the chip was designed for. It is my hope that this will reduce wear and tear on the device while still providing superior performance.

Editing the tables for this chip was a lot simpler than for other chips I have worked on.

It all took place within the kernel/samsung/tblte/arch/arm/boot/dts/qcom/apq8084.dtsi file. Here is how it used to look:

[CODE]
………….EDITED FOR SPACE…………….
/* 2.7GHz RC1 */
qcom,speed2-pvs0-bin-v1 =
< 0 0 0 >,
< 300000000 810000 76 >,
< 345600000 820000 88 >,
………….EDITED FOR SPACE…………….
< 2496000000 1120000 813 >,
< 2572800000 1135000 849 >,
< 2649600000 1150000 886 >;
[/CODE]

And here was my change:

[CODE]
………….EDITED FOR SPACE…………….
/* 2.7GHz RC1 */
qcom,speed2-pvs0-bin-v1 =
< 0 0 0 >,
< 300000000 810000 76 >,
< 345600000 820000 88 >,
………….EDITED FOR SPACE…………….
< 2496000000 1120000 813 >,
< 2572800000 1135000 849 >,
< 2688000000 1150000 886 >;
[/CODE]

That’s right, I only made a 39MHz change. I feel this was appropriate to keep the device cool and continue to use the same voltages. So it is essentially a 39MHz boost with no noticable consequences. Of course, I had to do the above to each speed and pvs table in that file.

Then, I needed to edit this portion:

[CODE]
………….EDITED FOR SPACE…………….
qcom,msm-cpufreq@0 {
reg = <0 4>;
compatible = “qcom,msm-cpufreq”;
qcom,cpu-mem-ports = <1 512>;

qcom,cpufreq-table =
< 300000 300000 1144 800 >,
< 422400 422400 2288 800 >,
………….EDITED FOR SPACE…………….
< 2572800 1728000 16250 10101 >,
< 2649600 1728000 16250 10101 >;
………….EDITED FOR SPACE…………….
[/CODE]

To this:

[CODE]
………….EDITED FOR SPACE…………….
qcom,msm-cpufreq@0 {
reg = <0 4>;
compatible = “qcom,msm-cpufreq”;
qcom,cpu-mem-ports = <1 512>;

qcom,cpufreq-table =
< 300000 300000 1144 800 >,
< 422400 422400 2288 800 >,
………….EDITED FOR SPACE…………….
< 2572800 1728000 16250 10101 >,
< 2688000 1728000 16250 10101 >;
………….EDITED FOR SPACE…………….
[/CODE]

It actually was the only time I have overclocked a kernel on the second try. Don’t think too highly of me, though, I spent hours reviewing kernel edits for overclocking by various other kernel developers on GitHub. If you are looking to do the same, you should spend some time looking at working code for others, and then make your own tables.

If you were to compare my tables with everyone elses, you would see that I have done it differently than my contemporaries, even though we reached similar, or in some cases, identical results. I like to keep the code clean, short, and sweet. Often when overclocking, most kernel developers will add more lines to the tables. I have found that while that may be the best to maximize use, my method is much simpler and easy to implement, as well as follow, and that is what Linux should be all about, keeping it simple.

Linux – keep it simple.