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

AOKP 7.1.1 for the Galaxy Note Edge!

To God be the glory, my AOKP NOUGAT project finally works!

My fellow T-Mobile-ians, (N915T) you have been left out of AOSP development long enough! By God’s grace I was able to use mickey387’s great tbltexx work, and completely adapt it to our tbltetmo after extracting all of the needed firmware from our 6.0.1 stock roms! No data zips are required here! It is all built in!

I also have made an international version (N915G/F/FY) as well!
This is not a dirty unicorn. This is the original unicorn, the AOKP. Now made out of Nougat! That’s right, all of the AOKP stuff you love, plus LineageOS, plus a built in side bar, and more! All wrapped up into one! With tons of settings from status bar tweaks to button remaps, it’s all here and ready to rumble!

**** This is an UNOFFICIAL ROM. Install at your own risk! ****

Features and Screenshots!

– Advanced Reboot
– Omni-Switcher
– Kernel Adiutor

+ Rom Control:

+ App Launchers
– App Circle Bar
– App Side Bar
– Gesture Anywhere

+ General
– cLock settings
– Recents settings
– Wakelock Blocker

+ Hardware Keys
– Backlight control
– Power button options
– Launch vibration control
– Home button controls
– Recents button controls
– Long press options, double tap options
– Kill app back button option
– Volume buttons wake
– Volume button playback controls
– Keyboard cursor controls
– Volume button reorientation
– IME features

+ Lockscreen
– Media Cover art
– Display music visualizer
– Show weather
– Blur background
– Fingerprint auth vibration
– Double tap to sleep (DT2S)
– Disable quick settings
– Show lockscreen clock and date
– Lockscreen notification count

+ Notification Drawer
– Brightness slider
– Brightness icon
– Rows in portrait and landscape modes
– Columns
– Tile Animations
– Advanced data tile
– Smart pulldown
– Quick pulldown

+ Power Menu
– Animation choices
– Screenshots
– Screenrecord
– Airplane mode
– Sound Panel

+ Sound
– Various sound settings
– Volumn step control

+ Status Bar tweaks
– Network traffic
– Clock style
– Double tap to sleep (DT2S)
– Superuser indicator
– Icon controls
– AOKP logo

+ User interface
– Toast controls
– AOKP animations
– Transparency controls

AND MORE!!!

Background image:
https://qlfiles.net/2017/01/07/upload-fractal-images/
The background images that I used in this ROM came from the Quiet Learner. You should check out his mathematical artwork, including 3D mandelbox images!

Ready to download? Check it out under my menu –> Homemade Roms –> Galaxy Note Edge!

Linux – keep it simple.

TBLTETMO data fix zips!

Praise God! The TBLTETMO data fix finally works!

What is this for?
-These data fix zips allow you to use a TBLTEXX rom on your phone (provided that you can flash it, see “flashing tbltexx roms” for details on that). If you edit a TBLTEXX rom and flash it to your phone, you will not be able to use the cellular, but now you can with these data fix zips!

THIS IS FOR THE 6.0.1 BOOTLOADER ONLY! THIS ONLY WORKS ON ROMS BUILT FOR THE TBLTEXX ON THE 6.0.1 BOOTLOADER! PLEASE USE WITH CAUTION!

Flashing TBLTEXX roms:
You have two choices, either flash a TBLTEXX recovery, so you can flash TBLTEXX roms, or you can use a TBLTETMO recovery and follow the steps below.
Steps:
1. Download the TBLTEXX rom that was built using the 6.0.1 bootloader.
2. Unzip the rom.
3. Open ./META-INF/com/google/android/updater-script in gedit or notepad++.
4. Delete the first line – should say something like

[CODE]assert(getprop(“ro.product.device”) == “tblte” || getprop(“ro.build.product”) == “tblte” || getprop(“ro.product.device”) == “tbltexx” || getprop(“ro.build.product”) == “tbltexx” || getprop(“ro.product.device”) == “tbltedt” || getprop(“ro.build.product”) == “tbltedt” || abort(“E3004: This package is for device: tblte,tbltexx,tbltedt; this device is ” + getprop(“ro.product.device”) + “.”););[/CODE]
5. Save the file.
6. zip the contents back up.
7. Flash!

Thanks!
Mickey387 – For continued development for the TBLTEXX!
louforgiveno – For making the 5.1.1 bootloader data zips for the trlte, which inspired this set of datazips. (Same principle, different files.)

Known working TBLTEXX roms:

[ROM][7.1.1] AOKP Nougat with built in sidebar launcher! [tbltexx]
This rom is available in the T-Mobile thread also for direct use on the T-Mobile phones!
https://forum.xda-developers.com/note-edge/development/rom-aokp-nougat-built-sidebar-launcher-t3558296
Instructions: After downloading this, you do not need to edit the zip, it is ready for flashing, flash rom, gapps. Reboot, let it settle, then, go back into recovery and flash datazip #1. Reboot. Now you will see your cell phone signal as empty, select your apn, and set your phone to 3g mode. Then, after you get the H+ by your cell signal, you can switch back to LTE.

[ROM][OFFICIAL]NOUGAT Resurrection remix 5.8.0 (7.1.1)
https://forum.xda-developers.com/note-edge/development/rom-nougat-resurrection-remix-5-8-0-7-1-t3509295
Instructions: After making it flashable, flash rom, gapps. Reboot, let it settle, then, go back into recovery and flash datazip #1. Reboot. Now you will see your cell phone signal as empty, select your apn, and set your phone to 3g mode. Then, after you get the H+ by your cell signal, you can switch back to LTE.

[rom][6.0.1] aokp mm [n915t/n915f/n915fy/n915g]
https://forum.xda-developers.com/note-edge/development/rom-aokp-mm-t3484354
Instructions: After downloading the 6.0.1 bootloader version, you do not need to edit the zip, it is ready for flashing. Flash the rom, the gapps, and reboot. After it boots up the first time, go back to recovery and flash data zip #1. You should be good to go! If you have trouble, choose your apn, cycle between 3g and lte!

finnigen2 found that this also works with Resurrection remix 5.8.1 (7.1.1) with the data fix with Mickey’s TWRP 3.0.3.1_915F.

unimatrix725 found that this also works with TekX EPE2 [6.0.1] on a SM-N915R4 (U.S. Cellular).

JeremySS found that if you upgrade from TBLTEXX RR 5.8.0 to 5.8.1, you can flash data zip 2 to fix your issues.

The data zips.

Data Zip #1:
http://www.mediafire.com/file/12bi5tf16dx2jiy/601_915T_datazip1_20170127.zip

Data Zip #2:
http://www.mediafire.com/file/ct843vgvcco6v8k/601_915T_datazip2_20170127.zip

You can also check it out on XDA: https://forum.xda-developers.com/note-edge/tmobile-note-edge-android-development/ril-data-fixes-6-0-1-bootloader-t3546110

Linux – keep it simple.

Another example of a dirty fix….

[CODE] ninja: error: ‘/home/alaskalinuxuser/compile/build_lineageos/out/target/common/obj/APPS/ValidityService_intermediates/with-local/classes.dex’, needed by ‘/home/alaskalinuxuser/compile/build_lineageos/out/target/common/obj/APPS/ValidityService_intermediates/classes.dex’, missing and no known rule to make it make: *** [ninja_wrapper] Error 1 make: Leaving directory `/home/alaskalinuxuser/compile/build_lineageos’ [/CODE]

That was the error I received. I was trying to build LineageOS (the CyanogenMod replacement) for the TBLTEXX/TBLTETMO Samsung Galaxy Note Edge. There were several ways to fix this, but first let’s understand the problem a little better.

The isse is that the classes.dex file is missing from that location. What is it for? Well, in this case, it is for the ValidityService app. Note that it is under APPS, and ValidityService. Now you may ask, what does that do? Well, my limited understanding is that it is a nessessary component of the fingerprint sensor, for validating that you have the correct fingerprint.

So, what could we do to fix this? Well, we could edit the TBLTEXX device tree and remove the ValidityService folder, and remove the reference to it in the config files. That would definately solve the error issue, but then would prevent you from using the fingerprint sensor.

We could rifle through all of the files and see what is missing that needs to be built in order to make that work. This is the BEST option, but very time consuming.

Or, we could just copy the out/target/common/obj/APPS/ValidityService_intermediates folder from another sucessfull build, if we have one, which, as a matter of fact, I do, AOKP. So, I copied the folder over and continued with the build. No issues there! At least, not with the fingerprint sensor…. Now if I can only make a phone call with my cell phone.

Linux – keep it simple.

keyCode=KEYCODE_UNKNOWN, When your buttons don’t work!

While building roms for the Samsung Galaxy Note Edge (TBLTETMO, TBLTEXX) I ran into an issue where the recents button was not working. So, I pulled a logcat, and here is what I saw:

KeyEvent { action=ACTION_UP, keyCode=KEYCODE_UNKNOWN, scanCode=254, metaState=0, flags=0x208, repeatCount=0, eventTime=182478, downTime=182375, deviceId=18, source=0x101 }

This lead me on a wild goose chase accross the internet, but praise God, I caught that goose!

Here is the article that helped me the most:
https://chris.boyle.name/blog/2010/08/android-keymaps/

However, it was only close to solving my issue. Sometime between 2010 and now, Android stopped using qwerty.kl as the main file for setting the keymap. So, I also had to edit Generic.kl to make it work.

Here is the whole thing if you are doing this on your phone:

Using ES File Explorer or similar, open /system/usr/keylayout/Generic.kl.

Go down past “key 226 HEADSETHOOK”
and add “key 254 MENU”

Save and close that.

Then, open /system/usr/keylayout/qwerty.kl.

Go down past “key 212 CAMERA”
and add “key 254 MENU”

Save and close that.

Then, open /system/usr/keylayout/sec_touchkey.kl.

Edit “key 254 MENU”

Save and close that.

Now, reboot your phone and the recents button will be a menu button!

If you are editing your source code, you can see the commit I did and do likewise, here:
https://github.com/alaskalinuxuser/aokp_device_samsung_tblte-common/commit/ef9f1d600f372e69c15b05bb40771e9ba4aa7a61

Essentially, I added the Generic.kl file from my phone to my build, and made the build copy it over when making a rom. Pretty simple, once you know what to do!

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.

 

Adding a kernel governor can be a Nightmare!

Okay, so a little play on words, especially since I am adding the Nightmare governor to the tblte (Samsung Galaxy Note Edge) kernel, but it did turn out to be a bit of a problem child, fortunately, it was quickly corrected. As you can see, I did the standard additions, as well as adding the cpufreq_nightmare.c file:

Added to Makefile:

[CODE]
………….EDITED FOR SPACE…………………..
obj-$(CONFIG_CPU_FREQ_GOV_NIGHTMARE) += cpufreq_nightmare.o
………….EDITED FOR SPACE…………………..
[/CODE]

Added to Kconfig:

[CODE]
………….EDITED FOR SPACE…………………..
config CPU_FREQ_DEFAULT_GOV_NIGHTMARE
bool “nightmare”
select CPU_FREQ_GOV_NIGHTMARE
help
Use the CPUFreq governor ‘nightmare’ as default. -WJH
………….EDITED FOR SPACE…………………..
config CPU_FREQ_GOV_NIGHTMARE
tristate “‘nightmare’ cpufreq policy governor”
help
‘nightmare’ – This driver is a modified PegasusQ.

To compile this driver as a module, choose M here: the
module will be called cpufreq_nightmare.

For details, take a look at linux/Documentation/cpu-freq.

If in doubt, say N. -WJH
………….EDITED FOR SPACE…………………..
[/CODE]

Added to cpufreq.h:

[CODE]
………….EDITED FOR SPACE…………………..
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_NIGHTMARE)
extern struct cpufreq_governor cpufreq_gov_nightmare;
#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_nightmare)
………….EDITED FOR SPACE…………………..
[/CODE]

Added to config:

[CODE]
………….EDITED FOR SPACE…………………..
CONFIG_CPU_FREQ_GOV_NIGHTMARE=y
………….EDITED FOR SPACE…………………..
[/CODE]

But, when I ran the compiler, I got this output:

[CODE]
/home/alaskalinuxuser/Documents/projects/phones/compile/build_slim6/kernel/samsung/tblte/drivers/cpufreq/cpufreq_nightmare.c: In function ‘nightmare_check_cpu’:
/home/alaskalinuxuser/Documents/projects/phones/compile/build_slim6/kernel/samsung/tblte/drivers/cpufreq/cpufreq_nightmare.c:540:2: error: implicit declaration of function ‘cpufreq_notify_utilization’ [-Werror=implicit-function-declaration]
cpufreq_notify_utilization(policy, max_load);
[/CODE]

So I edited that line out in build_slim6/kernel/samsung/tblte/drivers/cpufreq/cpufreq_nightmare.c:

[CODE]
// WJH cpufreq_notify_utilization(policy, max_load);
[/CODE]

And viola! By God’s grace it even worked! That usually doesn’t get fixed so easily, so I guess that wasn’t so bad.

Linux – keep it simple.

 

When symbolic links don’t work?

Recently, while compiling CM12 for the TBLTETMO, Galaxy Note Edge, I ran into an odd error. I did not get a chance to copy the error message, but essentially it said that the file[CODE]linux/dqblk_qtree.h[/CODE]

did not exist.

Normally, this would not cause concern, nor even a raised eyebrow. However, when I went to the location, the file DID exist. I thought that was really odd. Then I realized that it was a symbolic link to another file. Sometimes, for whatever reason, the symbolic links don’t always work for the compiler. In this case, I simply replaced the file with the linked one. If you don’t have the file, I found it online here: http://lxr.free-electrons.com/source/include/linux/dqblk_qtree.h?v=4.0

The point being, if you find a “missing file” that actually exists, check to see if it is a link to another file. If so, copy the linked file in its entirety to the proper location, as that will work much better.

Linux – keep it simple.

Stop. No rule to make android.hardware.fingerprint.xml

Stop. No rule to make android.hardware.fingerprint.xml

As I continue to attempt successful builds on the TBLTETMO, TBLTEXX, and TBLTESPR, I came accross this error:

[CODE]
make: *** No rule to make target `frameworks/native/data/etc/android.hardware.fingerprint.xml’, needed by `/home/alaskalinuxuser/Documents/projects/phones/compile/build_cm12_mickey/out/target/product/tbltexx/system/etc/permissions/android.hardware.fingerprint.xml’. Stop.
[/CODE]

Obviously, just a missing file. I searched around a bit on Google, and finally found the answer. I copied this text and made my own file at frameworks/native/data/etc/android.hardware.fingerprint.xml, it looks like this:

[CODE]
<?xml version=”1.0″ encoding=”utf-8″?>
<!– Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
–>
<!– This is the standard set of features for a biometric fingerprint sensor. –>
<permissions>
<feature name=”android.hardware.fingerprint” />
</permissions>
[/CODE]

Or you can download it here: https://android.googlesource.com/platform/frameworks/native/+/master/data/etc/android.hardware.fingerprint.xml

For better or worse, the error has cleared. Apparently all it needed was a feature name, but that’s good enough for me!

Linux – keep it simple.

 

New builds! New device! The N915T Galaxy Note Edge!

While I don’t have one yet, I have decided that I will be getting one of these Galaxy Note Edge phones. They are a couple years old, and the price on them is going down significantly. In the meantime, I noticed that there were not very many custom roms available for them. Actually, there are only 2 roms that are not just modifications of stock roms. Those two roms are CM 12.1 (Lollipop) and Resurrection Remix (Marshmallow).

So, I decided to build some of my own. To God be the glory, it worked! Well, sort of.

Working with a group of willing testers, I have put together this rom:

http://www.mediafire.com/download/lccy75jfrx8itmt/pac_tbltetmo__20160909-125802.zip

At this time, it does not have functioning WiFi or Cellular, but it is a start. It is my hope to continue working on this and get it squared away. For now, it is a fun Alpha teaser to try out.

Some of the main problems with custom roms on this phone is the “edge” feature. The curved glass edge has never truly been done justice by a non-touchwiz rom, which I suspect is why most stick with the stock roms, or modifications thereof.

My long term goals are to find a way to put the edge back into play, and to also make the s-pen fully functional. Short term goals are to get the usual hardware working. If you have a N915T, feel free to try out this alpha build, but remember, it is not a daily driver yet.

Linux – keep it simple.