Ubuntu Touch environment setup

I recently engaged in MultiRom Manger of Nexus 5 and experienced a pair of Ubuntu Touch and Android L. The overall feeling is pretty good, but there is still a problem with the NFC driver of Android L. The optimization of Ubuntu Touch is not enough and the screen is a bit stuck , And the backlight cannot be turned off. So the idea of participating in the development of Ubuntu Touch driver was born, and it can be regarded as a kind of interest.

Ubuntu Touch for Nexus 5 is unofficial, the official ones are only Nexus 4, 7, and 10. We can download the latest version of for Nexus 5 directly from MultiRom Manager.

Since there is no related tutorial in the Chinese blog, you can only refer to the official documents built in the Ubuntu Touch environment:

https://wiki.ubuntu.com/Touch/Building

The following records my process of building Ubuntu Touch (follow the wiki above).

Building Ubuntu Touch Android pieces from source
Whether you want to build Ubuntu Touch for the currently supported Nexus devices or want to port it to a new target, you need to set up your working environment to build Android from source. This setup is more or less the same whether you are building AOSP or a project based on it such as CyanogenMod, SEAndroid or Ubuntu Touch.
If you are new to building Android sources you may want to check out this document and others in the Getting Started section on the Google documentation site, as it covers the basics and terminology of AOSP building. While Ubuntu Touch uses some helper scripts as detailed below, if will nonetheless be helpful to understand what is going on under the hood especially if you want to work on this part of the project.
http://source.android.com/source/initializing.html
For Ubuntu Touch, you can find all the needed Android git repositories at https://code-review.phablet.ubuntu.com/#/admin/projects/. This is basically a mirror of AOSP 4.4.2_r1, but containing only the needed low level services used by Android (e.g. no Dalvik at all).
For any Android related project on our git server, you’ll find a branch named phablet-4.4.2_r1. This branch contains a static known git HEAD and the required changes needed for Ubuntu, including our custom Android manifest.

Compile the Android part of Ubuntu Touch from source#

Whether you want to compile a Nexus device that is now supported or port Ubuntu Touch to a new device, you need to build a compilation environment to compile the Android source code. This tutorial is roughly the same as you compile AOSP (Android Open Source Project) or AOSP-based projects, such as CyanogenMod, SeAndroid or Ubuntu Touch.

If you are compiling Android source code for the first time, you may need the following document and other related documents on the Getting Started chapter of the Google Docs website. The document explains the basics of AOSP compilation and some terminology. In the following sections, Ubuntu Touch will use some auxiliary scripts. If you plan to do related development on the project, you will better understand what you are doing in each next step by browsing these documents.

http://source.android.com/source/initializing.html

You can find all the Android git repositories needed to build Ubuntu Touch in https://code-review.phablet.ubuntu.com/#/admin/projects/ (repo is a multi-git project management tool, this thing is very difficult to use in the unstable network of China). This is an image based on AOSP 4.4.2_r1, but only contains the services required for low-level Android operation (for example, no Dalvik).

In any Android-related project on our git server, you will find a branch called phablet-4.4.2_r1. This branch contains a git HEAD and includes custom Android manifest (Manifest of Ubuntu Touch’s repo) , Contains all the basic git projects of Ubuntu Touch) and other codes that need to be modified for Ubuntu. (This paragraph does not quite understand what I want to say)

This paragraph is only an introduction, there is no part that needs to be implemented.

Set up your development environment
At this moment we’re using the Android code base provided by Android AOSP.
Everything we take from Android is just C/C++, so you’ll notice that your Android build environment will be way smaller than when comparing to the traditional Android builds.
For development you can run any 64-bit Desktop version of Ubuntu between 12.04 LTS and 13.04.
It’s not strictly necessary, but it’s helpful to install ccache. (http://source.android.com/source/initializing.html#ccache in the general Android Setup guide should help with this.)
Additional packages which are used to build the host tools:

< span id="line-1" class="anchor">$ sudo apt-get install git gnupg flex bison gperf build-essential zip bzr 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
1
< span id="line-1" class="anchor">$ sudo apt-get install git gnupg flex bison gperf build-essential zip bzr 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

On Utopic (and maybe other) the 4.8 version of g++ is needed:

< span id="line-1-1" class="anchor">$ sudo apt-get install g++-4.8-multilib
1
< span id="line-1-1" class="anchor">$ sudo apt-get install g++-4.8-multilib

Before 14.04 Trusty you’ll also need to set up the tools PPA.
Then you need to install phablet-tools:

< span id="line-1-2" class="anchor">$ sudo apt-get install phablet-tools
1
< span id="line-1-2" class="anchor">$ sudo apt-get install phablet-tools

This will also install the repo tool, used to sync the Android repositories. Learn more about the repo tool. If you already have a repo tool in your $PATH from previous android development, be sure to remove it or make sure it’s after the system repo command in the path. To check that the right repo command is used, you can issue $ which repo. This should return /usr/bin/repo.
You can check out the source code using the repo and git tools already familiar to Android ROM developers, as described here
https://wiki.ubuntu.com/Touch/AndroidDevel
Alternately, all the Android code can be downloaded using the phablet-dev-bootstrap tool provided by the phablet-tools package installed in the previous step. This tool is a Python wrapper around repo and used to also check out bzr repositories before all code was managed by repo and git. For the purposes of getting the source code for development it is no longer needed.
To get the code setup run:

< span id="line-1-3" class="anchor">phablet-dev-bootstrap [target_directory]
1
< span id="line-1-3" class="anchor">phablet-dev-bootstrap [target_directory]

If for some reason the sync ends midway, you can continue the sync with the -c switch, so the command would be:

< span id="line-1-4" class="anchor">phablet-dev-bootstrap -c [target_directory]
1
< span id="line-1-4" class="anchor">phablet-dev-bootstrap -c [target_directory]

Alternatively, if you are just building an image for an already supported device, you can specify the -v switch:

< span id="line-1-5" class="anchor">phablet-dev-bootstrap -v [device codenames] [target_directory]
1
< span id="line-1-5" class="anchor">phablet-dev-bootstrap -v [device codenames] [target_directory]

The phablet-dev-bootstrap command will automatically use the repo tool with the Ubuntu Touch Preview custom manifest to download all the git repositories and needed data. Be aware that this step takes a long time and requires at least 15GB (plus 2-3GB for the binary output).

Set up your compilation environment##

We will use Android basic components (based on Android AOSP) to compile.

We will only use the C/C++ code in Android, so you will find that your compilation environment will be smaller than the traditional Android compilation environment.

You can use the 64-bit desktop version of Ubuntu 12.04LTS to 13.04 to develop Ubuntu Touch. (The blogger uses Mint 14.04, based on Ubuntu 14.04)

We can install ccache (ccache will speed up the Android compilation speed), but it is not necessary. (http://source.android.com/source/initializing.html#ccache Android configuration wizard will guide you how to install)

We also need these installation packages to compile the compilation tools on the host:

$ sudo apt-get install git gnupg flex bison gperf build-essential zip bzr 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

1 $ sudo apt-get install git gnupg flex bison gperf build-essential  zip bzr 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

In Utopic (Ubuntu 14.10) (or other), you also need to install g-4.8

$ sudo apt-get install g++-4.8-multilib

1 $ sudo apt-get install g++-4.8-multilib

Before Ubuntu 14.04 is stable, you also need install PPA tool. (You only need to execute the "Add PPAs (pre Trusty only)" step.)

Then install phablet-tools:

$ sudo apt-get install phablet-tools

1 $ sudo apt-get install phablet-tools

This will install the repo tool, which is used to synchronize Android repositories. [Click to learn about repo tools] (http://source.android.com/source/using-repo.html). If you already have the repo tool and have added the execution path to the $PATH in the previous Android development, please delete the repo, or make sure that the repo path in the $PATH is in the system repo command path (such as /bin /repo). You can use $ which repo to verify that the repo path is correct. If it is correct, it will return to /usr/bin/repo.

(I haven't figured out the meaning of this paragraph yet, because I haven't compiled it yet, so I should make sure it is /usr/bin/repo. I will come back to add it at that time)

Then use repo and git (just need to install git, do not need to actually execute, repo will call the git tool), get the Android source code from the following URL. This step should be familiar to Android Rom developers.

https://wiki.ubuntu.com/Touch/AndroidDevel

(This link will write another article, and the work of downloading the source code is in this link)

Using the phablet-dev-bootstrap that has been installed in the previous step, you can download all the Android codes one by one (about 640). This tool uses Python to encapsulate the repo. Before all the code is managed by repo and git, this tool can also be used to download the project of bzr repositories (a management tool similar to repo). But if it is only used to obtain the source code for development, this function is no longer needed.

Next let the code run:

phablet-dev-bootstrap [target_directory]

1 phablet-dev-bootstrap [target_directory]

If some error occurs that causes sync to stop halfway, you can use the -c parameter to continue syncing:

phablet-dev-bootstrap -c [target_directory]

1 phablet-dev-bootstrap -c [target_directory]

If you just compile a burning file of a supported device, you can use the -v parameter:

phablet-dev-bootstrap -v [device codenames] [target_directory]

1 phablet-dev-bootstrap -v [device codenames] [target_directory]

The phablet-dev-bootstrap command will use the repo tool to automatically download the manifest (project list) and then download all the git projects and the required data. Note that this step takes a long time and requires at least 15GB (plus 2-3GB of binary file output) of space.

Recommended Posts

Ubuntu Touch environment setup
ubuntu16.04 deploy GPU environment
Ubuntu configuration development environment
Ubuntu development environment configuration
Python virtual environment: Ubuntu16.04
Ubuntu18.10 configure Java environment
ubuntu environment deployment project
ubuntu sets python2.5 environment variables
ubuntu14.0464 Ros environment install halcon13.01
ubuntu build python development environment
ubuntu builds common development environment
Initial setup of Ubuntu 16.04 server
ubuntu offline installation python environment
Ubuntu 18.04.1 build Java environment and HelloWorld
Deploy JobConverter + Ibreoffice environment on Ubuntu
Ubuntu environment variables and ADB configuration
Ubuntu16.04 build php5.6 Web server environment
Docker ubuntu: install python-PIL-image environment on 14.04
Install Python virtual environment on Ubuntu 18.04
Ubuntu 19.1 installation and configuration Chinese environment
Install Spark stand-alone environment on Spark Ubuntu18
Install Hadoop system environment on Ubuntu 18.04
Use Ubuntu 16.04 for initial server setup
Build a LAMP development environment on Ubuntu 16.04
JDK environment variable configuration method under ubuntu
Build the C++ compilation environment under ubuntu
Tencent Cloud ubuntu 16.04 ZenTao integrated environment construction
About installing node environment in Ubuntu server
Download OpenJDK11 source code in Ubuntu environment
Ubuntu Server builds Hyperledger Fabric 2.1 learning environment
Vagrant quickly builds Ubuntu virtual machine environment
GPU programming (1): CUDA8.0 environment construction under Ubuntu
Build a python development environment under Ubuntu
Disable the TinkPad touch screen in Ubuntu
Configure Nginx + PHP 7.0 + MySQL environment under Ubuntu 16.04
Docker those things in the Ubuntu environment
Edit OpenJDK11 source code in Ubuntu environment