You are visiting this site as:
WikiGuest
Users
Home
Boot Loader
Development Tools
File Systems
Kernels
Platforms
Reference
You are here:
LinuxKernel Web
>
LinuxAndroidPlatform
(14 Aug 2012)
(raw view)
---+ Building Android on ARM Platforms ---++ Commands and tools on Linux based host _(instructions are for Ubuntu/Debian)_ The information here is according to http://source.android.com/source/download.html instuctions. Please always check the above page. ---+++ Notes There are some more things to bare in mind: 1 You will need a 64-bit Linux box to built Android now 1 The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used. ---++++ Java 6: for Gingerbread and newer <verbatim> sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner" sudo apt-get update sudo apt-get install sun-java6-jdk sudo update-java-alternatives -s java-6-sun </verbatim> ---++++ Java 5: for Froyo and older <verbatim> sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper main multiverse" sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper-updates main multiverse" sudo apt-get update sudo apt-get install sun-java5-jdk sudo update-java-alternatives -s java-1.5.0-sun </verbatim> ---+++ Preparation To set up your development environment, install the following required packages: <verbatim> $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev </verbatim> You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc. ---++++ Not valid anymore - you need a 64-bit box to build Android (see http://source.android.com/source/download.html) <strike> To set up your Linux development environment, make sure you have the following: * Required Packages: * Git 1.5.4 or newer and the GNU Privacy Guard. * JDK 5.0, update 12 or higher.Java 6 is not supported, because of incompatibilities with @Override. * flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl. <verbatim>$ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-devbuild-essential zip curl libncurses5-dev zlib1g-dev </verbatim> * You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc. * <verbatim>$ sudo apt-get install valgrind </verbatim> * Intrepid (8.10) users may need a newer version of libreadline: * <verbatim>$ sudo apt-get install lib32readline5-dev </verbatim> </strike> ---++ Install, initialize, and configure Repo To install, initialize, and configure Repo, follow these steps: <br /> 1 Make sure you have a =~/bin= directory in your home directory, and check to be sure that this bin directory is in your path: <br /> <verbatim> $ cd ~ $ mkdir bin $ echo $PATH</verbatim> 1 Download the repo script and make sure it is executable: <br /> <verbatim> $ curl http://android.git.kernel.org/repo > ~/bin/repo $ chmod a+x ~/bin/repo </verbatim> ---+++ Initializing a Repo client 1. Create an empty directory to hold your working files: <verbatim>$ mkdir mydroid $ cd mydroid</verbatim> 2. Run "repo init" to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest: <verbatim>$ repo init -u git://android.git.kernel.org/platform/manifest.git </verbatim> * If you would like to check out a branch other than "master", specify it with -b, like: <verbatim>$ repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo </verbatim> 3. When prompted, configure Repo with your real name and email address. If you plan to submit code, use an email address that is associated with a [[https://www.google.com/accounts][Google account]] . A successful initialization will end with a message such as _repo initialized in /mydroid_ Your client directory should now contain a =.repo= directory where files such as the manifest will be kept. To pull down files to your working directory from the repositories as specified in the default manifest, run : <blockquote> =$ repo sync= </blockquote> <em> <br /></em> The Android source files will be located in your working directory under their project names. ---++ Patching and building the kernel Please jump to the section that contains the info for the kernel version you wish to use. ---+++ Kernel version 2.6.33 There are various routes to getting the kernel. You could clone the http://linux-arm.org/git?p=linux-2.6-stable.git;a=summary repo and checkout the *2.6.33-armdroid* branch, which will also give you access to the latest patchset to support Android. In this case, you just need to use the respective .config files for the ARM board you want to use it on. If you have a copy of the upstream vanilla 2.6.33 Linux kernel (http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.33.y.git;a=summary ), you need to get the [[http://www.linux-arm.org/git?p=ael.git;a=blob_plain;f=kernel/src/patch-2.6.33-arm1.gz;hb=2010q2][2.6.33-arm1.gz]] and the [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=kernel/src/patch-2.6.33-arm1-droid1.gz][2.6.33-arm1-droid1.gz]] patches and apply them for the top of your git tree in the following order: * =$ git apply <PATH-TO-patch-2.6.33-arm1>= * =$ git apply <PATH-TO-patch-2.6.33-arm1-droid1>= Once you have reached this point, form either routes, use the appropriate Linux kernel =.config= files, that you can get from [[http://linux-arm.org/git?p=armdroid.git;a=tree;f=kernel/config][here]] To use them, just copy the over in the top level of the kernel tree: * =$ cp 2.6.33-pba8-armdroid1.config /.config= and then build the kernel with: * =$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage= which will give you a *uImage* in =arch/arm/boot/= . ---+++ Kernel version 2.6.35 For the 2.6.35 kernel, use http://linux-arm.org/git?p=linux-2.6-armdroid.git;a=heads repo and checkout the *2.6.35-armdroid* branch. As for the 2.6.33 kernel above, this approach will give you access to the latest patchset to support Android. If you have a copy of the upstream vanilla 2.6.35 Linux kernel (see [[http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.35.y.git;a=tag;h=d786bf1b8352facdde8cc28725e1e6e067e1854d][here]]), you need to get the [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=kernel/src/patch-2.6.35-arm1-droid1.gz;hb=HEAD][patch-2.6.35-arm1-droid1.gz]] patches and apply them for the top of your git tree: * =$ git apply <PATH-TO-patch-2.6.35-arm1-droid1>= This patchset contains the 2.6.35-arm1 patches. Now get the appropriate Linux kernel =.config= file for the board you are using, from [[http://linux-arm.org/git?p=armdroid.git;a=tree;f=kernel/config]], and copy it to the top of the kernel tree as =.config= file: * =$ cp 2.6.35-pba8-armdroid1.config /.config= The get the kernel to build with: * =$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage= This will give you a *uImage* in =arch/arm/boot/= in this example for the PB-A8. ---+++ Kernel version 2.6.38 For the 2.6.38 kernel, use http://linux-arm.org/git?p=linux-2.6-armdroid.git;a=heads repo and checkout the *2.6.38-armdroid* branch. As for the 2.6.33 kernel above, this approach will give you access to the latest patchset to support Android. If you have a copy of the upstream vanilla 2.6.38.7 Linux kernel (see [[http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.38.y.git;a=tag;h=ae222b6e763dc85e8517ee5be12b4bf50ef4039f][here]]), you need to get the [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=kernel/src/patch-2.6.38-arm1-droid1.gz;hb=HEAD][patch-2.6.38-arm1-droid1.gz]] patches and apply them for the top of your git tree. Then use the appropriate =.config= for your board from [[http://linux-arm.org/git?p=armdroid.git;a=tree;f=kernel/config]] and build the kernel as outlined above. ---+++ Kernel version 3.3 For the 3.3 kernel, use [[http://linux-arm.org/git?p=linux-2.6-armdroid.git;a=summary]] and checkout <I>linux-3.3-armdroid</I> branch. As for the kernel above, this will give you access to the latest patchset to support Android. If you have a copy of the upstream vanilla 3.3 rc7 (see [[http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary][ here]]), you need to get the [[%ATTACHURL%/kernel_src_patch-3.3rc7-arm1-droid1.gz][kernel_src_patch-3.3rc7-arm1-droid1.gz]] patch and apply to the top of your GIT tree. Then use the appropriate ARM dts (device tree structure – see [[http://linux-arm.org/git?p=arm-dts.git;a=summary][here]]) and follow the booting instructions outlined [[http://linux-arm.org/git?p=armdroid.git;a=commit;h=3baa6a09028e75b210a659bc9b5c7631943edd44][here]] . ---+++ Patching the Android Source ---++++ Eclair You will need to apply the following patches from the respective paths (indicated in the patches names) in the source tree of Android. * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Eclair/Eclair-armboards-bionic.patch;hb=cb99a77fdcc209a0a68d4af78a38cea8d27ca0b5][Eclair-armboards-bionic.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Eclair/Eclair-armboards-build.patch;hb=cb99a77fdcc209a0a68d4af78a38cea8d27ca0b5][Eclair-armboards-build.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Eclair/Eclair-armboards-dalvik.patch;hb=cb99a77fdcc209a0a68d4af78a38cea8d27ca0b5][Eclair-armboards-dalvik.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Eclair/Eclair-armboards-frameworks-base.patch;hb=cb99a77fdcc209a0a68d4af78a38cea8d27ca0b5][Eclair-armboards-frameworks-base.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Eclair/Eclair-vendor-arm.tar.bz2;hb=cb99a77fdcc209a0a68d4af78a38cea8d27ca0b5][Eclair-vendor-arm.tar.bz2]] These patches are amending the TLS so that is uses the kernel helper functions, in bionic C library and in GLES v1.1 , v2. They also add support for the armv6k architecture as well as enabling the use of TLS in the armv7 architectures. To apply then, navigate to the indicated directory, and apply each patch. E.g: <verbatim> $ cd bionic $ git apply <path-to-Eclair-armboards-bionic.patch> </verbatim> Please note that the =Eclair-vendor-arm.tar.bz2= is a tarball that should be decompressed in the =vendors= directory.<br /> This will add the ARM board targets for the Android build system. ---++++ Froyo Same approach for Froyo but we have a set of slightly different patches, as well as an additional patch to support the ARMv6k architecture: * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Froyo/Froyo-armboards-bionic.patch;hb=6706399926a700f2f9b939277349f7196671af21][Froyo-armboards-bionic.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Froyo/Froyo-armboards-build.patch;hb=6706399926a700f2f9b939277349f7196671af21][Froyo-armboards-build.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Froyo/Froyo-armboards-dalvik.patch;hb=6706399926a700f2f9b939277349f7196671af21][Froyo-armboards-dalvik.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Froyo/Froyo-armboards-frameworks-base.patch;hb=6706399926a700f2f9b939277349f7196671af21][Froyo-armboards-frameworks-base.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Froyo/Froyo-armboards-system-core.patch;hb=6706399926a700f2f9b939277349f7196671af21][Froyo-armboards-system-core.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Froyo/Froyo-device.tar.bz2;hb=6706399926a700f2f9b939277349f7196671af21][Froyo-device-arm.tar.bz2]] Please note that the =Froyo-device-arm.tar.bz2= is a tarball that should be decompressed in the =device= directory.<br /> This will add the ARM board targets for the Android build system. ---++++ Gingerbread For Gingerbread we have fewer patches and a couple of changes in the device folder. You would just need: * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Gingerbread/Gingerbread-armboards-build.patch;hb=HEAD][Gingerbread-armboards-build.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/Gingerbread/Gingerbread-device-arm.tar.bz2;hb=HEAD][Gingerbread-device-arm.tar.bz2]] Please note that the =Gingerbread-device-arm.tar.bz2= is a tarball that should be decompressed in the =device= directory.<br /> This will add the =armboard_v7a= and =armboard_v7a_noneon= targets for the android build system.<br> Please also note that these patches are for ARMv7a, and they don't support ARMv6k architecture version yet. Note: If you are using kernel version 2.6.38 ([[http://linux-arm.org/git?p=linux-2.6-armdroid.git;a=shortlog;h=refs/heads/2.6.38-armdroid][git repository]], then you would need to apply the patches that amend the deprecation of =oom_adj=, to replace it with the newer =oom_score_adj=. This patch is [[http://linux-arm.org/git?p=armdroid.git;a=tree;f=fs/src/Gingerbread/2.6.38-related;hb=HEAD][here]]. ---++++ Ice Cream Sandwich For Ice Cream Sandwich you will need to apply the following patches from the respective paths (indicated in the patch names) in the source tree of Android. * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/IceCreamSandwich/ICS-armboards_frameworks-base_systemui.patch;hb=58fb51bf42b867b6f3639fbaa74beba114f03fb5][ICS-frameworks-base.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/IceCreamSandwich/ICS-armboards_build_tls.patch;hb=58fb51bf42b867b6f3639fbaa74beba114f03fb5][ICS-armboards-build.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob;f=fs/src/IceCreamSandwich/Android-ICS-device-arm.tar.bz2;h=18440e7f1ee9d8045e01d52d091f01598e7750cb;hb=58fb51bf42b867b6f3639fbaa74beba114f03fb5][ICS-device-arm.tar.bz2]] Please note that <I>ICS-device-arm.tar.bz2</I> is a tarball that should be decompressed in the device directory. This will add the <I>armboard_v7a</I> and <I>armboard_v7a_neon</I> targets to the android build system. Please also note that these patches are for ARMv7a. <B>Note</B>: If you are using a kernel versions newer than 3.3, you need to apply the patch that amends the deprecation of FB_EARLYSUSPEND. This patch can be found [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/IceCreamSandwich/ICS-armboards_frameworks-base_displayhardware.patch;hb=cf44b9fade2d6d7515deeb5ddaac2a0cb8dfc52e][here]]. ---++++ Jelly Bean For Jelly Bean you will need to apply the following patches from the respective paths (indicated in the patch names) in the source tree of Android. * [[http://linux-arm.org/git?p=armdroid.git;a=blob_plain;f=fs/src/JellyBean/JB-armboards_frameworks-base_systemui.patch;hb=656995549e44830afb8afb92c02fbcb6efae0e7b][JB-frameworks-base.patch]] * [[http://linux-arm.org/git?p=armdroid.git;a=blob;f=fs/src/JellyBean/Android-JB-device-arm.tar.bz2;h=27545e238cbe2886029c6ec7a0544c0df1a98e4a;hb=656995549e44830afb8afb92c02fbcb6efae0e7b][JB-device-arm.tar.bz2]] Please note that JB-device-arm.tar.bz2 is a tarball that should be decompressed in the device directory. This will add the armboard_v7a and armboard_v7a_neon targets to the android build system. Also, please note that these patches are for ARMv7a. <!-- ---++ Building Android - Eclair and Froyo To build Android, e.g. for an ARMv7 board, you now need to issue the following command: <blockquote> =$ make PRODUCT-ARMv7-eng= </blockquote> Specifically for Froyo you need to enter: <blockquote> =$ make PRODUCT-ARMv7a-eng= </blockquote> that will build Android with optimisations for boards using ARMv7 architectures - boards include Versatile Express V2, RealView PB-A8 and PBX. For RealView PB11MPCore that uses ARMv6k core, you should use: <blockquote> =$ make PRODUCT-ARMv6k-eng= </blockquote> --> ---++ Building Android To build Android for armboard_v7a, you now need to issue the following command: <blockquote> =$ make PRODUCT-armboard_v7a-eng= </blockquote> That will build Android with optimisations for boards using ARMv7a architectures taking also advantage of NEON. The tested boards include Versatile Express V2, RealView PB-A8 and PBX. ---++ Filesystem and Images The android system is designed to boot from flash using YAFFS2 filesystems. After you have build Android, you can either dump the filesystem image to an SD Card or USB key, without having to change anything. Or you can use the Android filesystem over the network, using NFS. ---+++NFS If you want to work over NFS, you need to copy the built sources to specific places:<br> <verbatim>$ cp <ANDROID_ROOT>/out/target/product/<BOARD_NAME>/root/* /var/nfs4/armv7-board-fs</verbatim> <verbatim>$ cp <ANDROID_ROOT>/out/target/product/<BOARD_NAME>/system/* /var/nfs4/armv7-board-fs/system</verbatim> Also, make sure you make the following changes in =init.rc.= Comment out the following lines: <verbatim> mount rootfs rootfs /ro remount mount yaffs mtd@system /system mount yaffs2 mtd@system /system ro remout mount yaffs2 mtd@userdata /data nosuid nodev mount yaffs2 mtd@cache /cache nosuid nodev </verbatim> The =/etc/exports= file should have the settings for the shared folder set : <verbatim> /srv/nfs4/android-fs *(rw,sync,no_root_squash,no_subtree_check) </verbatim> In addition to that, please make sure that the permissions and the ownership of the files in the fs are retained as they come out of the build directory. Your local user in your Linux box *should not* own anything in there! ---+++ Filesystem Changes ---++++ Keyboard navigation By default the keyboard mapping for Android doesn't have the Esc key mapped for navigating "back".<br /> To enable that you should edit the =system/usr/keylayout/qwerty.kl= file in your filesystem, and add the following line: * =key 1 BACK= ---++++ DNS server We need to set the DNS server to enable web browsing in Android. This can be done by adding the<br /> indicated line bellow, in init.rc. <verbatim> # basic network init ifup lo hostname localhost domainname localdomain ---> setprop net.dns1 <DNS> </verbatim> ---++++ Gingerbread In addition to the above changes in init.rc, you also need to comment out line 92 that reads: <verbatim> on fs </verbatim> ---++ Running Android You need to have U-boot running on your board, and to set the correct bootargs. Example of setting the boot arguments in U-boot for Android running over NFS with ARM RealView platforms: * *PB11-MPCore:* <verbatim>setenv bootargs root=/dev/nfs rw nfsroot=<NFS_IP>:/srv/nfs4/android-v6k,nolock,wsize=1024,rsize=1024 ip=dhcp console=ttyAMA init=/init noinitrd user_debug=31</verbatim> * *PB-A8:* <verbatim>setenv bootargs root=/dev/nfs rw nfsroot=<NFS_IP>:/srv/nfs4/android-v7,nolock,wsize=1024,rsize=1024 ip=dhcp console=ttyAMA init=init noinitrd user_debug=31</verbatim> * *PB-X single-core, NEON:* <verbatim>setenv bootargs root=/dev/nfs rw nfsroot=<NFS_IP>:/srv/nfs4/android-v7,nolock,wsize=1024,rsize=1024 ip=dhcp console=ttyAMA init=init noinitrd user_debug=31 nosmp</verbatim> * *PB-X dual-core, no-NEON:* <verbatim>setenv bootargs root=/dev/nfs rw nfsroot=<NFS_IP>:/srv/nfs4/android-v7-noneon,nolock,wsize=1024,rsize=1024 ip=dhcp console=ttyAMA init=init noinitrd user_debug=31</verbatim> * *Versatile Express:* <verbatim>setenv bootargs root=/dev/nfs rw nfsroot=<NFS_IP>:/srv/nfs4/android-v7,nolock,wsize=1024,rsize=1024 ip=dhcp console=ttyAMA init=init noinitrd mem=1024M user_debug=31</verbatim> Once this is set up, you can bootm your board. <verbatim>bootm <KERNEL_ADDRESS></verbatim> ---++ Using ADB Once you have Android source built, you will have __adb__ (Android Debug Bridge) that functions as a probing/investigating mechanism. Add the path to adb binary to your PATH environment variable, to be able to execute it from everywhere: <verbatim> $ export PATH=<PATH_TO_ANDROID>/out/host/linux-x86/bin:$PATH </verbatim> If you know the IP of your target device, set it in the ADBHOST environment variable. E.g: <verbatim> $ export ADBHOST=10.0.0.50 </verbatim> You can now get information about booting/starting Android with: =$ adb logcat= Or get a shell to the target: =$ adb shell= ADB supports connection to the target that is running Android, over Ethernet or USB. ~
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r26
<
r25
<
r24
<
r23
<
r22
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Toolbar
Create New Topic
Index
Search
Changes
Notifications
Statistics
Preferences
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki?
Send feedback
zenweb1 : 0.07 secs
More Info