error: undefined reference to ‘wifi_start_fstman’

Ah, the continuing saga of the far far away dream of building OmniRom Nougat for the LG G4. Yet again, another set of errors:

[CODE]
system/qcom/softap/sdk/qsap.c:705: error: undefined reference to ‘wifi_start_fstman’
system/qcom/softap/sdk/qsap.c:714: error: undefined reference to ‘wifi_stop_fstman’
system/qcom/softap/sdk/qsap.c:722: error: undefined reference to ‘is_fst_enabled’
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[/CODE]

So I took a look at the lines in question of system/qcom/softap/sdk/qsap.c:

[CODE]
int qsap_prepare_softap()
{
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
}

int qsap_unprepare_softap()
{
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
}

int qsap_is_fst_enabled()
{
return is_fst_enabled();
}
[/CODE]

No big deal, I thought. I could just wrap them in an #ifdef (if defined) statement, and only use them if they are actually defined. So I did.

[CODE]
int qsap_prepare_softap()
{
/* WJH */
#ifdef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
#endif
}

int qsap_unprepare_softap()
{
/* WJH */
#ifdef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
#endif
}

int qsap_is_fst_enabled()
{
/* WJH */
#ifdef is_fst_enabled
return is_fst_enabled();
#endif
}
[/CODE]

You are all probably smarter than me, and see the error of my ways, but non the less, I ran it as so, and this was my next set of errors:

[CODE]
system/qcom/softap/sdk/qsap.c:707:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
system/qcom/softap/sdk/qsap.c:716:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
system/qcom/softap/sdk/qsap.c:724:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
[/CODE]

The problem was that the in int qsap_is_fst_enabled(), int qsap_unprepare_softap(), and int qsap_prepare_softap() integers all return nothing, or are “null”. That’s no good for follow on code, they have to have some value. So, I thought about it for a while, and right or wrong, I decided to use an #ifndef (if not defined) flag.
If the functions were defined, they would be used, if they are not defined, then I gave a return value, arbitrary as they may be, but what I suspect is the “right answer”. Take a look:

[CODE]
int qsap_prepare_softap()
{
/* WJH */
#ifdef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
#endif
#ifndef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return 1;
#endif
}

int qsap_unprepare_softap()
{
/* WJH */
#ifdef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
#endif
#ifndef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return 1;
#endif
}

int qsap_is_fst_enabled()
{
/* WJH */
#ifdef is_fst_enabled
return is_fst_enabled();
#endif
#ifndef is_fst_enabled
return 0;
#endif
}
[/CODE]

And viola! This time it worked. What result that will have in the end? I’m not sure. Hopefully it still functions properly, but that remains to be seen….

Linux – keep it simple.

 

Advertisements

Function “appears in overlay but not in the base package”

Ah, OmniRom. Yes, I am still working on it. Hopefully you are not getting tired of these errors, but I find it helpful to log them here, and hopefully others will also. Previously, we looked at ways to use <add-resource> to add functions into a rom, but here we are just going to disable an overlay that we can work on later.

[CODE]
FAILED: /bin/bash -c “(touch out/target/common/obj/APPS/framework-res_intermediates/zipdummy ) && ((cd out/target/common/obj/APPS/framework-res_intermediates/ && jar cf package-export.apk zipdummy) ) && (zip -qd out/target/common/obj/APPS/framework-res_intermediates/package-export.apk zipdummy ) && (rm out/target/common/obj/APPS/framework-res_intermediates/zipdummy ) && (out/host/linux-x86/bin/aapt package -u -x –private-symbols com.android.internal -z –pseudo-localize -M frameworks/base/core/res/AndroidManifest.xml -S device/lge/g4-common/overlay/frameworks/base/core/res/res -S frameworks/base/core/res/res -A frameworks/base/core/res/assets –min-sdk-version 25 –target-sdk-version 25 –product default –version-code 25 –version-name 7.1.2 –skip-symbols-without-default-localization -F out/target/common/obj/APPS/framework-res_intermediates/package-export.apk )”
device/lge/g4-common/overlay/frameworks/base/core/res/res/values/config.xml:277: error: Resource at config_supportDoubleTapWake appears in overlay but not in the base package; use <add-resource> to add.
[/CODE]

So, as you can see, we have something in our overlay that is supposed to lay over the top of some source code, but the base source code doesn’t have that function to be “overlayed”. Here is where we see the overlay in device/lge/g4-common/overlay/frameworks/base/core/res/res/values/config.xml:277:

[CODE]
<!– Whether device supports double tap to wake –>
<bool name=”config_supportDoubleTapWake”>true</bool>
[/CODE]

So, we changed it to:

[CODE]
<!– Whether device supports double tap to wake
<bool name=”config_supportDoubleTapWake”>true</bool> WJH –>
[/CODE]

By commenting it out, it will no longer “overlay” it onto something that doesn’t exist. Be sure to take a look at my other article for how to use <add resource> to actually add an overlay item to the base package.

Linux – keep it simple.

 

Failed to mmap at expected address

In the continuing OmniRom saga, another day with another fail:

[CODE]FAILED: /bin/bash -c “(mkdir -p out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/ && rm -f out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (find out/target/common/obj/APPS/CaptivePortalLogin_intermediates/ -maxdepth 1 -name \”classes*.dex\” | sort | xargs zip -0qjX out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (mv out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input ) && (rm -f out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (mkdir -p out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/ ) && (ANDROID_LOG_TAGS=\”*:e\” out/host/linux-x86/bin/dex2oatd –runtime-arg -Xms64m –runtime-arg -Xmx512m –runtime-arg -classpath –runtime-arg \”&\” –boot-image=out/target/product/h811/dex_bootjars/system/framework/boot.art –dex-file=out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input –dex-location=/system/app/CaptivePortalLogin/CaptivePortalLogin.apk –oat-file=out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex –android-root=out/target/product/h811/system –instruction-set=arm64 –instruction-set-variant=generic –instruction-set-features=default –include-patch-information –runtime-arg -Xnorelocate –no-generate-debug-info –abort-on-hard-verifier-error –no-inline-from=core-oj.jar   –compile-pic ) && (rm out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input )”dex2oatd E 16505 16505 art/runtime/gc/heap.cc:324] Could not create image space with image file ‘out/target/product/h811/dex_bootjars/system/framework/boot.art’. Attempting to fall back to imageless running. Error was: Failed to load /system image ‘out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art’: Failed to mmap at expected address, mapped at 0x2b038dbfd000 instead of 0x70ddd000 : Requested region 0x70ddd000-0x70dde000 overlaps with existing map 0x70ddd000-0x70dde000 (/home/alaskalinuxuser/compile/20170727_aospa7/out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art)dex2oatd E 16505 16505 art/runtime/gc/heap.cc:324] 0x70ddd000-0x70dde000 rw- /home/alaskalinuxuser/compile/20170727_aospa7/out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art[/CODE]
It took me a while to figure this out, but the heart and soul of this problem lies with ART’s AOT (Ahead Of Time) preoptimization. Fortunately, I found a helpful tidbit on how to disable the preoptimization of this app. I did so here, in the /frameworks/base/packages/captiveportallogin/AndroidManifest.xml file:

[CODE]
    <application android:label=”@string/app_name” android:vmSafeMode=”true” >        <activity            android:name=”com.android.captiveportallog
[/CODE]
By adding android:vmSafeMode=”true”, the AOT of ART is disabled for this app. You can read more about that here: https://developer.android.com/guide/topics/manifest/application-element.html#vmSafeMode
Linux – keep it simple.

To skia or not to skia?

What is skia? Well, skia is used for drawing 2d graphics, and that is pretty important in Android.
More specifics can be read here at their website.
Essentially, it is used for making menus and drawings.

Now you are wondering why we are talking about it. Well, because we had an error:

[CODE]
ninja: error: ‘out/target/product/h811/obj_arm/STATIC_LIBRARIES/libqc-skia_intermediates/libqc-skia.a’, needed by ‘out/target/product/h811/obj_arm/SHARED_LIBRARIES/libskia_intermediates/LINKED/libskia.so’, missing and no known rule to make it
[/CODE]

As it turns out, the open source skia project was forked and some closed material was added for specific hardware, like qcom boards. So, with a few edits in ./external/skia/Android.mk, we changed it to go back to using the open source method, rather than qual comm’s specific one. All that is lost is a little bit of efficiency on qcom chips, which is actually important, but not more important than working at all.

[CODE]
#ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
# LOCAL_WHOLE_STATIC_LIBRARIES += libqc-skia
#endif
# WJH
[/CODE]

A few comments here and there, keeping it from checking if the board is a qcom board allows us to build and use the open source variant. Simple!

Linux – keep it simple.

use BUILD_PREBUILT instead!

OmniRoms Nougat. An elusive dream of mine is building OmniRoms for my devices. In the past I just couldn’t seem to get them to work. Well, I have decided to give it another go, and here was one of my first errors:

[CODE]
build/core/Makefile:34: *** Prebuilt apk found in PRODUCT_COPY_FILES: vendor/lge/g4-common/proprietary/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk:system/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk, use BUILD_PREBUILT instead!.
[/CODE]

So, I took a look at g4-common-vendor-blobs.mk:

[CODE]
vendor/lge/g4-common/proprietary/lib/libloc_ds_api.so:system/lib/libloc_ds_api.so \
vendor/lge/g4-common/proprietary/lib/libalhdri.so:system/lib/libalhdri.so \
vendor/lge/g4-common/proprietary/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk:system/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk \
vendor/lge/g4-common/proprietary/vendor/firmware/libpn547_fw_C9.so:system/vendor/firmware/libpn547_fw_C9.so \
vendor/lge/g4-common/proprietary/vendor/firmware/BCM4335_003.001.009.0117.0620_LGE_P1_EU.hcd:system/vendor/firmware/BCM43…..
[/CODE]

Here we can see that the file in question “qcrilmsgtunnel.apk” is being copied over with the vendor blobs. The error is telling us that we need to install it as a prebuilt app, instead of copying the app over as a normal file. So, I edited out that line in the g4-common-vendor-blobs.mk file, and edited g4-common-vendor.mk by adding it like so:

[CODE]
PRODUCT_PACKAGES += \
qcrilmsgtunnel \
qcnvitems \
qcrilhook
[/CODE]

Notice that I did not move the apk file around, just redefined how to get it moved into the rom. Well, that took care of that error! 1 down, untold dozens to go!

Linux – keep it simple.

 

How to manually update your custom rom source code with security updates

For those of you who compile your own custom roms directly using AOSP source, the latest security updates are always added in as soon as they occure. For those of us using custom roms, such as SlimRoms, AOKP, PAC roms, and others, this is not always the case.

Because the custom rom community downloads AOSP source, and then manipulates it to their needs/tastes, they cannot always directly integrate AOSP security updates. Some of these updates may not apply. Others, if unedited, may cause some features not to function.

For this reason, custom roms can sometimes fall behind, because one of the developers on that team needs to manually apply a lot of the fixes. This can be quite tedious. For instance, the libvpx security issue found in March of 2016 changed over 800 files. For the most part, the custom rom teams do a great job updating the security patches for the current version of their rom. The question is, what do you do to update the security patches of older versions of the roms?

This is actually a problem that I ran into with my build of SlimLP for the SGH-M919, T-Mobile Galaxy S4. I am mainting a current build of SlimLP for that phone, because the Marshmallow builds have some Bluetooth issues on these phones. Thus, users who still want to use Lollipop roms still need up to date security. But how do I fix this problem? The SlimRom’s team has moved on to work on Slim6, and there is almost no activity on SlimLP. Well, by God’s grace, I figured it out, and I thought I would share that here with you, in case you face a similar problem.

First, you could apply these same methods to all levels of security, however, since there are so many security updates, I have decided to only manually update my SlimLP source code with Critical security updates. Yes, that does mean that I am skipping the High, Moderate, and Low security threats. As I mentioned before, some of the updates are over 800 files, and that would be a new full time job for me, which I don’t have time for. So, hopefully, these Critical updates will strike the balance between keeping my rom users safe, and allowing me to still have time for important things like family, work, and sleeping!

The first thing I noticed as I started building SlimLP in May was that the security updates had stopped in February. After syncing in August, I found that the security updates had still not changed. You can verify in your source (if it is Lollipop or later) by looking at /build/core/version_defaults.mk, where you should see this line:

[CODE]
ifeq “” “$(PLATFORM_SECURITY_PATCH)”
# Used to indicate the security patch that has been applied to the device.
# Can be an arbitrary string, but must be a single word.
#
# If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
PLATFORM_SECURITY_PATCH := 2016-02-01
endif
[/CODE]

Obviously, if it is now August, then the security patches are 6 months out of date. That is pretty old, and there were a lot of big security threats found since then, some of which are specific to Qualcomm phones. This prompted me to start the process of updating my source by hand.

Granted, you could also join the team of your favorite rom and help others by updating thier security patches too, but as I pointed out, I am only updating the Critical security updates, not all of them, so it would not meet all of the official requirements to push my source upstream. If that is something you are interested in doing, that is great!

The next thing I did was look at the current security updates by going here:
https://source.android.com/security/bulletin/index.html

I decided to work on one month at a time, and compile inbetween to make sure that each update did not break anything that is in my SlimLP rom. So, I clicked on March, 2016. There were 19 CVE’s, or Common Vulnerability and Exposures ID’s for that month, 7 of which were marked Critical. Those are the ones I decided to work on.

There are many different ways to go about this, but here is what worked best for me. I copied the CVE number, in this case, CVE-2016-0818, and punched it into Google. Google brought up several options, but I found a good one to click on is the NVD detail, which is teh National Vulnerability Database. In this case, it took me here:
https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-0818

The website has a poor color scheme, but is very informative. It tells you what type of threat this is, how it can be used, and other great information. There is also a section called “References to Advisories, Solutions, and Tools”, below which I found several hyperlinks, including this one, which contains the fixes:
https://android.googlesource.com/platform/external/conscrypt/+/4c9f9c2201116acf790fca25af43995d29980ee0

This Google Git page shows us where the file is located, and how many, and exactly which file(s) have been changed. For this particular CVE, it is a really small change of just one file:

src/platform/java/org/conscrypt/TrustedCertificateIndex.java [diff]

By clicking on the word [diff], you are brought to the next page, that shows you exactly which lines of code need to change, like so:

[CODE]
@@ -68,6 +68,15 @@
if (anchors == null) {
anchors = new ArrayList<TrustAnchor>(1);
subjectToTrustAnchors.put(subject, anchors);
+ } else {
+ // Avoid indexing the same certificate multiple times
+ if (cert != null) {
+ for (TrustAnchor entry : anchors) {
+ if (cert.equals(entry.getTrustedCert())) {
+ return;
+ }
+ }
+ }
}
anchors.add(anchor);
}
[/CODE]

If you have never read these before, the + signs tell you to add these lines. Any – signs tell you to delete those lines. At the top, the @@ -68,6 +68,15 @@ is used to tell you which line numbers to look for, such as the case here, of line 68. Pretty straightforward. So, in this case, I found that file, and made these changes of adding these new lines. Note, in some of the files I changed, the line numbers were not correct for where to find this portion of code. The easy thing to do is copy a snipit of the code and do a search in the file, corrolating that with the surounding code and approximate line numbers for guidance. This is especially true if that file has been hacked to add some function or feature to your rom.

The next step is to go back to where we started. If you recall, we looked in /build/core/version_defaults.mk, where we saw this line:

[CODE]
PLATFORM_SECURITY_PATCH := 2016-02-01
[/CODE]

Now we can update it if we desire. Granted, if you are not doing all of the updates, you may not wish to change this, as you do not want to intentionally mislead anyone. In my case, I did update it, but was very sure to write in my rom’s long description that the security updates are only the Critical updates that I applied by hand, as of 2016-02-01. How you handle this is up to you.

Obviously, the last step is to go ahead and compile your new code, and see if it still works right! Hopefully, you now have a more secure rom for your phones.

Linux – keep it simple.

Setting up your compile environment for OmniRom 6.0.1

I’ve talked about how to compile Android variants before, and for the most part, it works the same no matter what variant you build. One caveat to that, however, is OmniRom. When I setup to build OmniRom 6.0.1, I have to set it up differently than the other builds that I do. It took me a while to figure it out (probably because I’m not very smart), so I thought I would share my findings with others, in the event that they couldn’t figure it out either.

So I want to compile OmniRom 6.0.1 for my Samsung Galaxy S4 T-Mobile phone (SGH-M919, JFLTETMO). God has graciously enabled me to build other roms for this phone, and I thought that it would be pretty straightforward to build the ol’ trusty OmniRom. Was I ever wrong! The setup was not intuitive and was unlike the setup for LiquidSmooth, AOKP, CM, PAC, and so forth. So here is what I did, and perhaps by looking at that, if you have the same problem you can fix it too.

Of course, you need to set up your compile environment by getting all the right programs and tools to run the compiler. I have already done this on my machine, but here is how you can do that too:

[CODE]
$ sudo apt-get install bison build-essential bzip2 curl dpkg-dev flex g++-multilib git git-review gnupg gperf lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev openjdk-7-jdk libbz2-1.0 libbz2-dev libc6-dev libghc-bzlib-dev libgl1-mesa-dev libgl1-mesa-glx:i386 libncurses5-dev libreadline6-dev libreadline6-dev:i386 libx11-dev:i386 libxml2-utils lzop maven pngcrush pngquant python-markdown schedtool squashfs-tools tofrodos x11proto-core-dev xsltproc zip zlib1g-dev zlib1g-dev:i386
[/CODE]

This will take a while. Once it is done, do this:

[CODE]
$ mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

$ gedit ~/.bashrc
[/CODE]

Now you should see gedit open up your .bashrc file, to which you should add this at the very end, and save it:

[CODE]
export PATH=~/bin:$PATH
[/CODE]

Now you need to close your terminal and open a new one to get the PATH variables to stick. Actually, it wouldn’t hurt to reboot your system after installing all of those programs we just installed. Your computer should now be primed and ready to go.

So once that is done, you can now get started. First things first, I downloaded the source:

[CODE]
$ cd ~
$ mkdir omni6
$ cd omni6
$ repo init -u git://github.com/omnirom/android.git -b android-6.0
$ repo sync
[/CODE]

As I have pointed out before, this sync takes a long time to download the files. We are talking about 10+ GB of files, so it will depend on your internet connection, but that is a lot of source code!

Next, I download the device trees, kernel source, and vendor blobs. You could choose any source for these that you want, CyanogenMod’s source is usually pretty good. AOKP, Slimroms, and others have trees available also. One group that has been less of a hassle to borrow trees from is DU, and here is how you can do that:

[CODE]
$ cd ~/omni6/
$ cd device
$ mkdir samsung
$ cd samsung
$ git clone https://github.com/DirtyUnicorns/android_device_samsung_jfltetmo -b m-caf jfltetmo
$ git clone https://github.com/DirtyUnicorns/android_device_samsung_jf-common -b m-caf jf-common
$ git clone https://github.com/DirtyUnicorns/android_device_samsung_msm8960-common -b m-caf msm8960-common
$ git clone https://github.com/DirtyUnicorns/android_device_samsung_qcom-common -b m-caf qcom-common
$ cd ..
$ git clone https://github.com/DirtyUnicorns/android_device_qcom_common -b m-caf qcom-common
$ mkdir qcom
$ cd qcom
$ git clone https://github.com/DirtyUnicorns/android_device_qcom_sepolicy -b m-caf sepolicy
$ cd ~/omni6/
$ mkdir -p kernel/samsung
$ cd kernel/samsung
$ git clone https://github.com/DirtyUnicorns/android_kernel_samsung_jf -b m-caf jf
$ cd ~/omni6/vendor/
$ git clone https://github.com/TheMuppets/proprietary_vendor_samsung -b cm-13.0 samsung
[/CODE]

Now you have all of the kernel source for the JFLTETMO/JF cell phones, and you have the device trees and vendor blobs to match! But if you run the build commands now, it will simply error out stating that it cannot find “omni_jfltetmo” and ask you if you have the right repo manifest. So here is what we need to do to make the Dirty Unicorn trees buildable in OmniRom: go to the omni6/device/samsung/jfltetmo folder and rename du.dependencies to omni.dependencies. Now open the file and edit it to say this:

[CODE]
[
]
[/CODE]

Yes, I realize that says nothing. But the file is needed and must be a valid file with those brackets in it. Now rename du.mk to omni_jfltetmo.mk and edit it like so:

[CODE]
$(call inherit-product, device/samsung/jfltetmo/full_jfltetmo.mk)

# Enhanced NFC
# WJH not present in omni $(call inherit-product, vendor/omni/config/nfc_enhanced.mk)

# Inherit some common DU stuff.
$(call inherit-product, vendor/omni/config/common.mk)

PRODUCT_BUILD_PROP_OVERRIDES += \
PRODUCT_NAME=jfltetmo \
TARGET_DEVICE=jfltetmo \
BUILD_FINGERPRINT=”samsung/jfltetmo/jfltetmo:4.4.4/KTU84P/M919UVUFNK2:user/release-keys” \
PRIVATE_BUILD_DESC=”jfltetmo-user 4.4.4 KTU84P M919UVUFNK2 release-keys”

PRODUCT_NAME := omni_jfltetmo
PRODUCT_DEVICE := jfltetmo
[/CODE]

Now make a new file called AndroidProducts.mk and put this in it:

[CODE]
#
# Copyright (C) 2011 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.
#

PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/omni_jfltetmo.mk
[/CODE]

Now your trees are “pruned” and ready for a build! Let’s give it a try:

First Run:

[CODE]
omni6$ . build/envsetup.sh
including sdk/bash_completion/adb.bash
omni6$ brunch jfltetmo
WARNING: Trying to fetch a device that’s already there
found the jfltetmo device repo

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.1
TARGET_PRODUCT=omni_jfltetmo
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=krait
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-73-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=MOB30M
OUT_DIR=/home/alaskalinuxuser/Documents/projects/phones/compile/omni6/out
============================================

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=6.0.1
TARGET_PRODUCT=omni_jfltetmo
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=krait
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-73-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=MOB30M
OUT_DIR=/home/alaskalinuxuser/Documents/projects/phones/compile/omni6/out
============================================
including ./abi/cpp/Android.mk …
<<<<<<<<<<EDITED FOR SPACE>>>>>>>>>>>>>
build/core/base_rules.mk:157: *** hardware/qcom/display/msm8960/liblight: MODULE.TARGET.SHARED_LIBRARIES.lights.msm8960 already defined by device/samsung/jf-common/liblights. Stop.

real 2m42.540s
user 0m54.729s
sys 0m24.030s
[/CODE]

Not an uncommon problem, I have run into this before. You cannot have something defined twice, or make will not know who is right or wrong when they differ. So the easy fix here was to edit device/samsung/jf-common/liblights/Android.mk like so:

[CODE]
# WJH LOCAL_PATH:= $(call my-dir)
# HAL module implemenation stored in
# hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.board.platform>.so
# WJH include $(CLEAR_VARS)

# WJH LOCAL_SRC_FILES := lights.c

# WJH LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw

# WJH LOCAL_SHARED_LIBRARIES := liblog

# WJH LOCAL_MODULE := lights.msm8960

# WJH LOCAL_MODULE_TAGS := optional

# WJH include $(BUILD_SHARED_LIBRARY)
[/CODE]

So, now you are off and running! I included this first error, which showed up only 2 minutes into the build to show you that just having all the “right stuff” doesn’t mean that you will have a successfull build. Hopefully this will get you pointed in the right direction though!

Linux – Keep it simple.

 

Error: ‘memcmp’ was not declared in this scope!

Here is a problem that I occasionally come across while compiling. Since it is so common for me to see this, I would like to re-iterate an earlier post I made about this problem. Before I only mentioned it in brief, and here I would like to break it down just a little bit more. I thought I had previously gone over this in detail, but I couldn’t find it in my posts, so I decided to talk about it here.

There are ways that this problem can manifest himself, but the overall problem is that the header file “strings.h” was not included in the build. It may be something that was supposed to be declared elsewhere, or added in later, but in either event, it is not present and cannot perform the actions required. Let’s take a look at the error itself:

[CODE]
device/samsung/jf-common/gps/utils/loc_target.cpp: In function ‘unsigned int loc_get_target()’:
device/samsung/jf-common/gps/utils/loc_target.cpp:208:53: error: ‘memcmp’ was not declared in this scope
if( !memcmp(baseband, STR_AUTO, LENGTH(STR_AUTO)) )
^
device/samsung/jf-common/gps/utils/loc_target.cpp:214:51: error: ‘memcmp’ was not declared in this scope
if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){
^
make: *** [/home/alaskalinuxuser/Documents/projects/phones/compile/aokp6/out/target/product/jfltetmo/obj/SHARED_LIBRARIES/libgps.utils_intermediates/loc_target.o] Error 1
make: *** Waiting for unfinished jobs….
make: Leaving directory `/home/alaskalinuxuser/Documents/projects/phones/compile/aokp6′

#### make failed to build some targets (28:01 (mm:ss)) ####
[/CODE]

What memcmp is supposed to do is compare memory areas. So the code is asking the compiler to make a memory comparison, and the compiler says it doesn’t know how! To fix this problem, you need to add this line to device/samsung/jf-common/gps/utils/loc_target.cpp:

[CODE]
#include <string.h>
[/CODE]

And then put the file string.h in the device/samsung/jf-common/gps/utils/ directory. Simple, you say, but where do I get the string.h file? That part is actually pretty simple. You can download it here: http://linux.die.net/include/string.h and save it where you need it to be. This file will also solve errors about:

strerror, strerror_r – return string describing error number
strlen – calculate the length of a string
strcpy, strncpy – copy a string
strcmp, strncmp – compare two strings
and others!

The main takeaway from this is that any “not declared in this scope” errors should be run through the http://www.die.net/search/ website to see what code pieces are missing. It will show you what header files are needed to perform that function, which is really handy!

Linux – keep it simple.

Stop: Recovery theme is not valid!

While compiling OmniRom 6.0.1 for the Samsung Galaxy S4, T-Mobile variant (JFLTETMO, SGH-M919), I ran into this problem, which halted the compiling process:

[CODE]
bootable/recovery/gui/Android.mk:127: ****************************************************************************
bootable/recovery/gui/Android.mk:128: * TW_THEME is not valid: ”
bootable/recovery/gui/Android.mk:129: * Please choose an appropriate TW_THEME or create a new one for your device.
bootable/recovery/gui/Android.mk:130: * Available themes:
bootable/recovery/gui/Android.mk:131: * landscape_hdpi landscape_mdpi portrait_hdpi portrait_mdpi watch_mdpi
bootable/recovery/gui/Android.mk:132: ****************************************************************************
bootable/recovery/gui/Android.mk:133: *** stopping. Stop.
[/CODE]

The problem appears to be that the bootable/recovery/gui/Android.mk file is expecting someone to tell it the default theme to set the recovery to. Fortunately it was kind enough to tell us the available options and the name of the variable it was expecting: TW_THEME. So, I added these two lines to the JFLTETMO BoardConfig.mk file:

[CODE]
# WJH TWRP theme options = landscape_hdpi landscape_mdpi portrait_hdpi portrait_mdpi watch_mdpi
TW_THEME := portrait_hdpi
[/CODE]

The best part was that this actually solved the problem! I really like it when the problem actually gets fixed, rather than just putting in a workaround, or removing a feature.

Linux – Keep it simple.

Error: That is already defined!

After a quick re-run of compiling OmniRom for my Samsung Galaxy S4, T-Mobile variant (JFLTETMO SGH-M919), I ran into another issue:

[CODE]
including ./hardware/qcom/display/Android.mk …
build/core/copy_headers.mk:15: warning: overriding commands for target `/home/alaskalinuxuser/Documents/projects/phones/compile/omni5/out/target/product/jfltetmo/obj/include/qcom/display/copybit.h’
build/core/copy_headers.mk:15: warning: ignoring old commands for target `/home/alaskalinuxuser/Documents/projects/phones/compile/omni5/out/target/product/jfltetmo/obj/include/qcom/display/copybit.h’
build/core/copy_headers.mk:15: warning: overriding commands for target `/home/alaskalinuxuser/Documents/projects/phones/compile/omni5/out/target/product/jfltetmo/obj/include/qcom/display/copybit_priv.h’
build/core/copy_headers.mk:15: warning: ignoring old commands for target `/home/alaskalinuxuser/Documents/projects/phones/compile/omni5/out/target/product/jfltetmo/obj/include/qcom/display/copybit_priv.h’
build/core/copy_headers.mk:15: warning: overriding commands for target `/home/alaskalinuxuser/Documents/projects/phones/compile/omni5/out/target/product/jfltetmo/obj/include/qcom/display/c2d2.h’
build/core/copy_headers.mk:15: warning: ignoring old commands for target `/home/alaskalinuxuser/Documents/projects/phones/compile/omni5/out/target/product/jfltetmo/obj/include/qcom/display/c2d2.h’
build/core/base_rules.mk:156: *** hardware/qcom/display/msm8960/liblight: MODULE.TARGET.SHARED_LIBRARIES.lights.msm8960 already defined by device/samsung/jf-common/liblights. Stop.

real 5m41.413s
user 1m59.811s
sys 0m29.481s
[/CODE]

Here the problem is that liblight is already defined in the hardware settings for qcom (which is what is at the heart of the SGH-M919), and it conflicts with the device liblights definition. The compiler is confused because there can only be one definition or object. So, to make ammends, I edited device/samsung/jf-common/liblights/Android.mk and commented out all of the lines, like so:

[CODE]
#WJH LOCAL_PATH:= $(call my-dir)
# HAL module implemenation stored in
# hw/<COPYPIX_HARDWARE_MODULE_ID>.<ro.board.platform>.so
#WJH include $(CLEAR_VARS)

#WJH LOCAL_SRC_FILES := lights.c

#WJH LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw

#WJH LOCAL_SHARED_LIBRARIES := liblog

#WJH LOCAL_MODULE := lights.msm8960

#WJH LOCAL_MODULE_TAGS := optional

#WJH include $(BUILD_SHARED_LIBRARY)
[/CODE]

I try to always insert my initials when I do an edit, so I can easily find my personal edits later. A quick word search for my own initials makes finding my changes an easy task. In this case it is important, because I may need to comment out the hardware liblights and keep the device liblights definition if that function doesn’t work in the rom. I typically try to edit or comment out the device tree changes first, before messing with the source code, to keep the source code “clean”. This way, if those code changes work, I can copy this tree to another source to build it as well, provided they work. Let’s give it another run and see what happens.

Linux – Keep it simple.