BLOX2: “Wakey, Wakey, Mouse!”

sleep2wake

That quote is from one of my son’s favorite books, “Max the Brave”!

Another update to the BLOX2 (BLU Life One X2) kernel, I just added Sweep2Wake and DoubleTap2Wake! You can check out the commit on GitLab, but my phone’s screen and proximity sensor are smashed, so I’m not sure it all works properly. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel: https://www.youtube.com/channel/UCnGqG_jyyXmTzdamBpKfeHA

Linux – keep it simple.

BLOX2: Voltage Control for the CPU!

cpuvolt

Another update to the BLOX2 (BLU Life One X2) kernel, I just added the ability to adjust the voltage of the CPU on the fly! You can check out the commit on GitLab, but it currently only controls the voltage on the “big” 4 CPU’s, not on the “small” 4 CPU’s. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel: https://www.youtube.com/channel/UCnGqG_jyyXmTzdamBpKfeHA

Linux – keep it simple.

BLOX2: Adding autoSMP Hotplug!

hotplug

Another update to the BLOX2 (BLU Life One X2) kernel, I just added another hot-plug controller called autoSMP. Hot-plug controllers can turn of CPU cores if they are not in use, to save power. You can check out the commit on GitLab, but it is very straight forward. It’s all part of my video series for modifying 64 bit kernels, which you can check out on my YouTube channel: https://www.youtube.com/channel/UCnGqG_jyyXmTzdamBpKfeHA

Linux – keep it simple.

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.

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.