[T-Mobile Samsung Galaxy Note II] T-Macgnolia:
Ubuntu Touch Preview for the SGH-T889 Note II​

I am posting this so others that are interested in building Ubuntu Touch for the SGH-T889 can have a better starting point.. As of right now this will not build a booting ROM as it is still a work in progress, but it should build. I have some edititng I need to do to the guide but knot able to do just yet, I will get this done as soon as possible.

Edit: For download link, instructions on how to flash and what is working go to the second post.

Thanks!

Thanks to CyanogenMod, Canonical Ltd, drapalyuk, chasmodo, Gerrett,codeworkx, GhostOfTheNet, mgale88, and a special thanks to my friend DragunKorr. Sorry if I missed anyone, if I find I have I will update the thanks section.

Official Porting guide

How to build​

To start with we you should be running Ubuntu 10.04 or higher. You might be able to use another Linux distro, but I have not seen anyone posting they were running a different Linux distro and building for the Preview. You also need to have a android build environment already set up. Now start by getting the additional packages you will need. Open a terminal by holding ctrl+Alt+t and paste the below command into the terminal.

$ sudo apt-get install git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386 schedtool

Next you need to get the phablet-tools package.

$ sudo add-apt-repository ppa:phablet-team/tools
$ sudo apt-get update
$ sudo apt-get install phablet-tools android-tools-adb android-tools-fastboot

Next you need to create a folder to sync your Android source tree too. You can name this folder anything you like. But for the purpose of this guide it will be named UPP (UbuntuPhonePort).

$ mkdir UPP

Now you need to set up the .repo in your UPP folder. To do this you need to cd to your UPP folder and run the following command in terminal.

$ phablet-dev-bootstrap UPP

Enter your name and email when pronpted for them then answer yes and press enter. This will set up your repo and start your sync. Be prepared this will take a good while. If you stop for some reason you can resume your sync by using the following command. (You probably will have to)

$ phablet-dev-bootstrap -c UPP

When your sync is done you need to set up your device tree for this you can either use CyanogenMod repositories on github or you can use my github repositories. I forked all of my repositories straight from CM and have made edits to allow it to compile.

You will have to be in your UPP folder in your file explorer and press ctrl+h to see the .repo folder. You will need to add the following lines to the manifest.xml in the .repo folder by opening the manifest.xml with a text editor. For this guide I am using my repositories but you can easily see how to use any other repositories here. Doing this will let the repositories you use sync if you do a resync of your work tree.

<project path="device/samsung/t0lte" name="T-Macgnolia/android_device_samsung_t0lte" remote="github" revision="cm-10.1" />
<project path="kernel/samsung/smdk4412" name="T-Macgnolia/android_kernel_samsung_smdk4412" remote="github" revision="cm-10.1" />
<project path="hardware/samsung" name="T-Macgnolia/android_hardware_samsung" remote="github" revision="cm-10.1" />
<project path="device/samsung/smdk4412-common" name="T-Macgnolia/android_device_samsung_smdk4412-common" remote="github" revision="cm-10.1" />

Alternatively you can clone your device repositories. For each folder you need to cd to where the folder needs to go. For example if you was cloning the device folder you would type in the following to get to the correct directory.

$ cd UPP/device/samsung

Here is the clone commands for all for of my repositories.

git clone git://github.com/T-Macgnolia/android_device_samsung_t0lte.git -b cm-10.1 t0lte
git clone git://github.com/T-Macgnolia/android_device_samsung_smdk4412-common.git -b cm-10.1 smdk4412-common
git clone git://github.com/T-Macgnolia/android_kernel_samsung_smdk4412.git -b cm-10.1 smdk4412
git clone git://github.com/T-Macgnolia/android_hardware_samsung.git -b cm-10.1 samsung

Last step before building is to flash a CM nightly to your device so you can pull your proprietary files from your device. You can pull them from a stock ROM but stock ROMs do not have all the files where as CM or others source built ROMs will. Because of a problem with the new mali driver r3p1I suggest you use this CM nightly build as it is the only official CM build before the 22nd of Febuary. Now you need to cd to your device folder like so.

$ cd UPP/device/samsung/t0lte

Now connect your device via USB to your computer, make sure you have ADB Debugging on in settings and that you allow the device to communicate with your computer. Now run the following command.

$ ./extract-files.sh

Now if you used my repositories you can jump ahead to the bottom of this post for the build commands. If you did not you may want to keep reading..

These changes are per the official guide.

Go to device/samsung/t0lte/rootdir/fstab.smdk4x12 and remove the "nosuid" from the following line.

/dev/block/mmcblk0p16 /data ext4 noatime,nosuid,nodev,discard,noauto_da_alloc,journal_async_commit,errors=panic

Go to kernel/samsung/smdk4412/arch/arm/configs/ cyanogenmod_t0lte_defconfig and add the following to the file in the "# Userspace binary formats" section of the file at line 750.

CONFIG_SYSVIPC=y
CONFIG_NAMESPACES=y
CONFIG_UTS_NS=y
CONFIG_IPC_NS=y
CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_NS=y
CONFIG_DEVTMPFS=y
CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
CONFIG_FSNOTIFY=y
CONFIG_DNOTIFY=y
CONFIG_INOTIFY_USER=y
CONFIG_FANOTIFY=y
CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
CONFIG_FSNOTIFY=y
CONFIG_SWAP=y
# CONFIG_ANDROID_PARANOID_NETWORK is not set

Go to device/samsung/t0lte/init.smdk4x12.rc and add the following beneath line 185.

chmod 0666 /sys/class/backlight/panel/brightness

Changes I made to get to build.

In device/samsung/t0lte/t0lte.mk I commited line 50 like below.

#PRODUCT_PACKAGES += \
GalaxyNote2Settings

Also in device/samsung/t0lte/t0lte.mk removed below line from PRODUCT_COPY_FILES += \

packages/apps/Nfc/migrate_nfc.txt:system/etc/updatecmds/migrate_nfc.txt \

Remove libandroid_runtime \ from the line 33 of hardware/samsung/exynos/multimedia/openmax/osal/Android.mk.

Last remove lines 2671 and 2674 in device/samsung/t0lte/audio/audio_hw.c. below is what it should look like before and after.

Before:

// Wideband AMR
ret = str_parms_get_str(parms, "wb_amr", value, sizeof(value));
if (ret >= 0) {
if (csd_wide_voice == NULL) {
ALOGE("dlsym: Error:%s Loading csd_wide_voice", dlerror());
} else {
if (strcmp(value, "on") == 0) {
ALOGE("%s: enabling csd_wide_voice", __func__);
csd_wide_voice(VX_WB_SAMPLING_RATE);
} else {
ALOGE("%s: disabling csd_wide_voice", __func__);
csd_wide_voice(VX_NB_SAMPLING_RATE);

After:

// Wideband AMR
ret = str_parms_get_str(parms, "wb_amr", value, sizeof(value));
if (ret >= 0) {
if (csd_wide_voice == NULL) {
ALOGE("dlsym: Error:%s Loading csd_wide_voice", dlerror());
} else {
if (strcmp(value, "on") == 0) {
ALOGE("%s: enabling csd_wide_voice", __func__);
} else {
ALOGE("%s: disabling csd_wide_voice", __func__);

Missing Lib Files

This is a list of the missing lib files, where to get them, and where to pit them.

After pulling proprietary files from my device I went to system/lib of the CM ROM and copied and pasted the following lib files to vendor/samsung/t0lte/proprietary/system/lib of my work tree.

libandroid_runtime.so
libdvm.so
libharfbuzz.so
libhwui.so
libnativehelper.so
libmali.so
libUMP.so
libfimc.so

In system/lib/hw in the CM ROM copied and pasted the following lib files to vendor/samsung/t0lte/proprietary/system/lib/hw of my work tree.

camera.exynos4.so
gps.goldfish.so

In /system/lib/ of a stock ROM copied and pasted the following lib file to vendor/samsung/t0lte/proprietary/system/lib of my work tree.

libfactoryutil.so

In systemlib/egl of the CM ROM copied of and pasted the following lib files to vendor/samsung/t0lte/proprietary/system/lib/egl of my work tree.

libEGL_mali.so
libGLESv1_CM_mali.so
libGLESv2_mali.so

In system/vendor/lib of the CM ROM copied and pasted the following lib files to vendor/samsung/t0lte/proprietary/system/vendor/lib of my work tree.

libpn544_fw.so
mfc_fw.bin

In system/cameradata of the CM ROM copied and pasted the following files to vendor/samsung/t0lte/proprietary/system/cameradata of my work tree.

datapattern_420sp.yuv
datapattern_front_420sp.yuv

In system/bin of the CM ROM copied and pasted the following files to vendor/samsung/t0lte/proprietary/system/bin of myr work tree.

bcm4334.hcd
bcm4334_murata.hcd
bcm4334_semcosh.hcd

How to make to make the compiler use the added lib files. The lines highlighted are the ones I added.

# Copyright (C) 2013 The CyanogenMod 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.

LOCAL_PATH := vendor/samsung/t0lte

PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/proprietary/system/bin/at_distributor:system/bin/at_distributor \
$(LOCAL_PATH)/proprietary/system/bin/efsks:system/bin/efsks \
$(LOCAL_PATH)/proprietary/system/bin/gsiff_daemon:system/bin/gsiff_daemon \
$(LOCAL_PATH)/proprietary/system/bin/ks:system/bin/ks \
$(LOCAL_PATH)/proprietary/system/bin/netmgrd:system/bin/netmgrd \
$(LOCAL_PATH)/proprietary/system/bin/qcks:system/bin/qcks \
$(LOCAL_PATH)/proprietary/system/bin/qmiproxy:system/bin/qmiproxy \
$(LOCAL_PATH)/proprietary/system/bin/qmuxd:system/bin/qmuxd \
$(LOCAL_PATH)/proprietary/system/bin/rild:system/bin/rild \
$(LOCAL_PATH)/proprietary/system/bin/sec-ril:system/bin/sec-ril \
$(LOCAL_PATH)/proprietary/system/bin/sensorhubservice:system/bin/sensorhubservice \
$(LOCAL_PATH)/proprietary/system/bin/smdexe:system/bin/smdexe \
$(LOCAL_PATH)/proprietary/system/etc/Diag.cfg:system/etc/Diag.cfg \
$(LOCAL_PATH)/proprietary/system/etc/Diag_zero.cfg:system/etc/Diag_zero.cfg \
$(LOCAL_PATH)/proprietary/system/lib/libakm.so:system/lib/libakm.so \
$(LOCAL_PATH)/proprietary/system/lib/libatparser.so:system/lib/libatparser.so \
$(LOCAL_PATH)/proprietary/system/lib/libcsd-client.so:system/lib/libcsd-client.so \
$(LOCAL_PATH)/proprietary/system/lib/libdiag.so:system/lib/libdiag.so \
$(LOCAL_PATH)/proprietary/system/lib/libdsi_netctrl.so:system/lib/libdsi_netctrl.so \
$(LOCAL_PATH)/proprietary/system/lib/libdsutils.so:system/lib/libdsutils.so \
$(LOCAL_PATH)/proprietary/system/lib/libfactoryutil.so:system/lib/libfactoryutil.so \
$(LOCAL_PATH)/proprietary/system/lib/libgps.so:system/lib/libgps.so \
$(LOCAL_PATH)/proprietary/system/lib/libgps.utils.so:system/lib/libgps.utils.so \
$(LOCAL_PATH)/proprietary/system/lib/libidl.so:system/lib/libidl.so \
$(LOCAL_PATH)/proprietary/system/lib/libloc_adapter.so:system/lib/libloc_adapter.so \
$(LOCAL_PATH)/proprietary/system/lib/libloc_api_v02.so:system/lib/libloc_api_v02.so \
$(LOCAL_PATH)/proprietary/system/lib/libloc_eng.so:system/lib/libloc_eng.so \
$(LOCAL_PATH)/proprietary/system/lib/libnetmgr.so:system/lib/libnetmgr.so \
$(LOCAL_PATH)/proprietary/system/lib/libomission_avoidance.so:system/lib/libomission_avoidance.so \
$(LOCAL_PATH)/proprietary/system/lib/libqcci_legacy.so:system/lib/libqcci_legacy.so \
$(LOCAL_PATH)/proprietary/system/lib/libqdi.so:system/lib/libqdi.so \
$(LOCAL_PATH)/proprietary/system/lib/libqdp.so:system/lib/libqdp.so \
$(LOCAL_PATH)/proprietary/system/lib/libqmi.so:system/lib/libqmi.so \
$(LOCAL_PATH)/proprietary/system/lib/libqmi_cci.so:system/lib/libqmi_cci.so \
$(LOCAL_PATH)/proprietary/system/lib/libqmi_client_qmux.so:system/lib/libqmi_client_qmux.so \
$(LOCAL_PATH)/proprietary/system/lib/libqmi_common_so.so:system/lib/libqmi_common_so.so \
$(LOCAL_PATH)/proprietary/system/lib/libqmi_csi.so:system/lib/libqmi_csi.so \
$(LOCAL_PATH)/proprietary/system/lib/libqmi_encdec.so:system/lib/libqmi_encdec.so \
$(LOCAL_PATH)/proprietary/system/lib/libqmiservices.so:system/lib/libqmiservices.so \
$(LOCAL_PATH)/proprietary/system/lib/libril.so:system/lib/libril.so \
$(LOCAL_PATH)/proprietary/system/lib/libril-qc-qmi-1.so:system/lib/libril-qc-qmi-1.so \
$(LOCAL_PATH)/proprietary/system/lib/libril-qcril-hook-oem.so:system/lib/libril-qcril-hook-oem.so \
$(LOCAL_PATH)/proprietary/system/lib/libsecnativefeature.so:system/lib/libsecnativefeature.so \
$(LOCAL_PATH)/proprietary/system/lib/libsecril-client.so:system/lib/libsecril-client.so \
$(LOCAL_PATH)/proprietary/system/lib/libsensorhubservice.so:system/lib/libsensorhubservice.so \
$(LOCAL_PATH)/proprietary/system/lib/hw/vendor-camera.exynos4.so:system/lib/hw/vendor-camera.exynos4.so \
$(LOCAL_PATH)/proprietary/system/lib/hw/gps.default.so:system/lib/hw/gps.default.so \
$(LOCAL_PATH)/proprietary/system/lib/hw/sensorhubs.smdk4x12.so:system/lib/hw/sensorhubs.smdk4x12.so \
$(LOCAL_PATH)/proprietary/system/lib/hw/sensors.smdk4x12.so:system/lib/hw/sensors.smdk4x12.so \
$(LOCAL_PATH)/proprietary/system/usr/idc/sec_e-pen.idc:system/usr/idc/sec_e-pen.idc \
$(LOCAL_PATH)/proprietary/system/usr/keylayout/sec_e-pen.kl:system/usr/keylayout/sec_e-pen.kl \
$(LOCAL_PATH)/proprietary/system/usr/keylayout/sec_touchkey.kl:system/usr/keylayout/sec_touchkey.kl \
$(LOCAL_PATH)/proprietary/system/vendor/firmware/SlimISP_GK.bin:system/vendor/firmware/SlimISP_GK.bin \
$(LOCAL_PATH)/proprietary/system/vendor/firmware/SlimISP_ZK.bin:system/vendor/firmware/SlimISP_ZK.bin[COLOR="Red"] \

PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/proprietary/system/lib/libandroid_runtime.so:system/lib/libandroid_runtime.so \
$(LOCAL_PATH)/proprietary/system/lib/libdvm.so:system/lib/libdvm.so \
$(LOCAL_PATH)/proprietary/system/lib/libharfbuzz.so:system/lib/libharfbuzz.so \
$(LOCAL_PATH)/proprietary/system/lib/libhwui.so:system/lib/libhwui.so \
$(LOCAL_PATH)/proprietary/system/lib/libnativehelper.so:system/lib/libnativehelper.so \
$(LOCAL_PATH)/proprietary/system/lib/libMali.so:system/lib/libMali.so \
$(LOCAL_PATH)/proprietary/system/lib/libUMP.so:system/lib/libUMP.so \
$(LOCAL_PATH)/proprietary/system/lib/lib/libfimc.so:system/lib/libfimc.so \

PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/proprietary/system/lib/hw/camera.exynos4.so:system/lib/hw/camera.exynos4.so \
$(LOCAL_PATH)/proprietary/system/lib/hw/gps.goldfish.so:system/lib/hw/gps.goldfish.so \

PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/proprietary/system/lib/egl/libEGL_mali.so:system/lib/egl/libEGL_mali.so \
$(LOCAL_PATH)/proprietary/system/lib/egl/libGLESv1_CM_mali.so:system/lib/egl/libGLESv1_CM_mali.so \
$(LOCAL_PATH)/proprietary/system/lib/egl/libGLESv2_mali.so:system/lib/egl/libGLESv_mali.so \

PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/proprietary/system/vendor/firmware/libpn544_fw.so:system/vendor/firmware/libpn544_fw.so \
$(LOCAL_PATH)/proprietary/system/vendor/firmware/mfc_fw.bin:system/vendor/firmware/mfc_fw.bin \

PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/proprietary/system/cameradata/datapattern_420sp.yuv:system/cameradata/datapattern_420sp.yuv \
$(LOCAL_PATH)/proprietary/system/cameradata/datapattern_front_420sp.yuv:system/cameradata/datapattern_front_420sp.yuv \

PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/proprietary/system/bin/bcm4334.hcd:system/bin/bcm4334.hcd \
$(LOCAL_PATH)/proprietary/system/bin/bcm4334_murata.hcd:system/bin/bcm4334_murata.hcd \
$(LOCAL_PATH)/proprietary/system/bin/bcm4334_semcosh.hcd:system/bin/bcm4334_semcosh.hcd

[/COLOR]

BUILD COMMANDS

$ . build/envsetup.sh
$ brunch full_t0lte-userdebug

It will make a cm.zip and a full_t0lte-ota-eng. username.zip in UPP/out/target/product/t0lt. You can use either one, I was told that the full_t0lte zip is not optimized but to be honest I do not know why it makes two zip files.

​