Building

Differences between revisions 1 and 17 (spanning 16 versions)
Revision 1 as of 2013-03-27 13:19:37
Size: 6470
Editor: 79-119-112-234
Comment: Add building from source page
Revision 17 as of 2015-04-13 03:43:05
Size: 7160
Editor: 162-250-12-202
Comment: correct bzr spelling
Deletions are marked like this. Additions are marked like this.
Line 13: Line 13:
For Ubuntu Touch, you can find all the needed Android git repositories at http://phablet.ubuntu.com/gitweb. This is basically a mirror of Cyanogen``Mod 10.1, but containing only the needed low level services used by Android (e.g. no Dalvik at all). 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).
Line 15: Line 15:
For any Android related project on our git server, you'll find a branch named phablet-10.1. This branch contains a static known git HEAD and the required changes needed for Ubuntu, including [[http://phablet.ubuntu.com/gitweb?p=CyanogenMod/android.git;a=blob;f=default.xml;hb=refs/heads/phablet-10.1|our custom Android manifest]]. 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 [[https://code-review.phablet.ubuntu.com/gitweb?p=aosp%2Fplatform%2Fmanifest.git;a=shortlog;h=refs%2Fheads%2Fphablet-4.4.2_r1|our custom Android manifest]].
Line 19: Line 19:
To support a wide range of devices, we decided to use Cyanogen``Mod as a base for the Android system. You could safely use AOSP, as we don't use a lot of the customizations and improvements done at the App/Java side, but it's easier with Cyanogen``Mod due the scripts and build procedures available for it. At this moment we're using the Android code base provided by Android AOSP.
Line 28: Line 28:
Additional packages which are used to build the host tools: {{{ Additional packages which are used to build the host tools:
 
{{{
Line 33: Line 34:
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386 schedtool}}}   python-markdown libxml2-utils xsltproc zlib1g-dev:i386 schedtool
}}}
Line 35: Line 37:
You'll also need to [[../Install#Step_1_-_Desktop_Setup|set up the tools PPA]]. This will also install the {{{repo}}} tool, used to sync the Android repositories. [[http://source.android.com/source/using-repo.html|Learn more about the repo tool]]. On Utopic (and maybe other) the 4.8 version of g++ is needed:
 {{{
$ sudo apt-get install g++-4.8-multilib
}}}
Line 37: Line 42:
All the Android code can be downloaded from the `phablet-dev-bootstrap` tool provided by the `phablet-tools` package installed in the previous step: Before 14.04 Trusty you'll also need to [[../Install#Step_1_-_Desktop_Setup|set up the tools PPA]].

Then you need to install phablet-tools:
 {{{
$ sudo apt-get install phablet-tools
}}}

This will also install the {{{repo}}} tool, used to sync the Android repositories. [[http://source.android.com/source/using-repo.html|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.
Line 42: Line 60:
}}}

Note: You may need to specify it as:
 {{{
phablet-dev-bootstrap --repo-branch phablet-4.4.2_r1 --sources aosp [target_directory]
Line 55: Line 78:
== Getting the vendor blobs ==

In order to have a functional Android image some proprietary bits need to be included for all devices. These are not redistributable so they should be grabbed from a running device booted into Android.
These files go under vendor/<vendorname>/<devicename> in our case vendor/lge/mako.
Make sure you have the device running Android and connected via USB, with USB Debugging under Developer Settings enabled and run the ./extract-file.sh script under device/lge/mako . This will populate
that directory with files from the device.

For Nexus devices google provides factory images
https://developers.google.com/android/nexus/images

At the moment Google provides factory images for 4.2.2 which on the Nexus 4 at least are not compatible with Ubuntu Touch, the latter being still based on 4.2.1
Better grab the blobs from here for the moment

https://github.com/gdetal/vendor_lge_mako
Finally, the binary blobs for the officially supported devices need to be downloaded separately, with this command from the target directory:
 {{{
bzr branch lp:~phablet-team/phablet-tools/aosp-vendor-4.4.2 vendor
}}}
Line 74: Line 87:
Since only a subset of the whole Android tree is used and built for Ubuntu Touch, the build is much faster than a full AOSP or CyanogenMod build. Since only a subset of the whole Android tree is used and built for Ubuntu Touch, the build is much faster than a full AOSP build.
Line 76: Line 89:
Build for the target you want. Valid names are mako (Nexus 4) grouper (Nexus 7) manta (Nexus 10) maguro (Galaxy Nexus) Build for the target you want. Valid names are mako (Nexus 4) flo (Nexus 7 2013) manta (Nexus 10) hammerhead (Neux 5) generic (Emulator).
Line 78: Line 91:
{{{
export USE_CCACHE=1
. build/envsetup.sh
brunch mako
}}
 {{{
$ export USE_CCACHE=1
$ . build/envsetup.sh
$ lunch aosp_mako-userdebug
$ make -j4 # Or any other amount of threads

}}}
Line 86: Line 100:
After the build out/target/product/mako will have the device specific build artifacts such as boot.img, system.img, recovery.img which can be flashed using fastboot to the respective partitions like:
Line 87: Line 102:
After the build out/target/product/mako will have all device specific build artifacts such as boot.img, system.img, userdata.img, recovery.img which can be flashed using fastboot to the respective partitions like
fastboot flash boot boot.img.
 {{{
$ fastboot flash boot boot.img
$ fastboot flash recovery recovery.img
}}}
Line 90: Line 107:
Another way of installing the system is by just flashing recovery.img (a Clockworkmod image with some Ubuntu changes) via fastboot and then loading zip files via Clockworkmod, either by explicitly installing from the menu, or pushing the image as autodeploy.zip. First install the Android image and then the Ubuntu image.
The Android image is in the same out/target/produce/mako directory.
The latest Ubuntu image can be found here:
http://cdimage.ubuntu.com/ubuntu-touch-preview/daily-preinstalled/current/quantal-preinstalled-phablet-armhf.zip
As our Ubuntu image is not built by the Android build system, the best approach is to just flash it directly using rootstock, like described bellow (from bootloader):
 {{{
$ fastboot boot out/target/product/mako/recovery.img
$ bzr branch lp:project-rootstock-ng
$ cd project-rootstock-ng/
$ ./rootstock-touch-install utopic-preinstalled-touch-armhf.tar.gz out/target/product/mako/system.img
}}}
Line 95: Line 115:
adb push cm-10.1-20130322-UNOFFICIAL-mako.zip /sdcard/autodeploy.zip
adb reboot recovery
adb push quantal-preinstalled-phablet-armhf.zip /sdcard/autodeploy.zip
adb reboot recovery
You can find the latest Ubuntu rootfs image at http://cdimage.ubuntu.com/ubuntu-touch/daily-preinstalled/current/utopic-preinstalled-touch-armhf.tar.gz.

== Updating the Android system image ==

Once you have a working Ubuntu Touch image on your device, do the following to update the Android system image (from bootloader):
 {{{
$ fastboot flash boot out/target/product/mako/boot.img
$ fastboot boot out/target/product/mako/recovery.img
$ ./build/tools/update-system-img.sh out/target/product/mako/system.img
}}}

== Porting ==

Now that you are comfortable with building Ubuntu Touch and have tested it on an existing device, you may want to take another step and port it to new hardware.

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

Warning /!\ Ubuntu Touch is no longer maintained as a core product by Canonical. However, the Ubports community are continuing development.

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.

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:

  • $ 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:

  • $ 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:

  • $ 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:

  • phablet-dev-bootstrap [target_directory]

Note: You may need to specify it as:

  • phablet-dev-bootstrap --repo-branch phablet-4.4.2_r1 --sources aosp [target_directory]

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

  • 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:

  • 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).

Finally, the binary blobs for the officially supported devices need to be downloaded separately, with this command from the target directory:

  • bzr branch lp:~phablet-team/phablet-tools/aosp-vendor-4.4.2 vendor

Building for an existing device

Here's how to build Ubuntu Touch for the Nexus 4 (Android codename mako)

Since only a subset of the whole Android tree is used and built for Ubuntu Touch, the build is much faster than a full AOSP build. Still using CCACHE can help if you are doing multiple builds or have multiple target devices Build for the target you want. Valid names are mako (Nexus 4) flo (Nexus 7 2013) manta (Nexus 10) hammerhead (Neux 5) generic (Emulator).

  • $ export USE_CCACHE=1
    $ . build/envsetup.sh
    $ lunch aosp_mako-userdebug
    $ make -j4 # Or any other amount of threads

Flashing the image

After the build out/target/product/mako will have the device specific build artifacts such as boot.img, system.img, recovery.img which can be flashed using fastboot to the respective partitions like:

  • $ fastboot flash boot boot.img
    $ fastboot flash recovery recovery.img

As our Ubuntu image is not built by the Android build system, the best approach is to just flash it directly using rootstock, like described bellow (from bootloader):

  • $ fastboot boot out/target/product/mako/recovery.img
    $ bzr branch lp:project-rootstock-ng
    $ cd project-rootstock-ng/
    $ ./rootstock-touch-install utopic-preinstalled-touch-armhf.tar.gz out/target/product/mako/system.img

You can find the latest Ubuntu rootfs image at http://cdimage.ubuntu.com/ubuntu-touch/daily-preinstalled/current/utopic-preinstalled-touch-armhf.tar.gz.

Updating the Android system image

Once you have a working Ubuntu Touch image on your device, do the following to update the Android system image (from bootloader):

  • $ fastboot flash boot out/target/product/mako/boot.img
    $ fastboot boot out/target/product/mako/recovery.img
    $ ./build/tools/update-system-img.sh out/target/product/mako/system.img

Porting

Now that you are comfortable with building Ubuntu Touch and have tested it on an existing device, you may want to take another step and port it to new hardware.

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

Touch/Building (last edited 2015-06-23 15:25:02 by dpm)