Building Android on Beagle

Note: these instructions are now out of date and refer to URLs which no longer exist. See the elinux.org wiki for more recent instructions.

These instructions are derived from Embinux.org’s Android Porting Guide to Beagle Board (the corresponding web page no longer exists), based on their work to port Android on the Beagle board. They correct multiple inaccuracies in this guide, and also add many useful details.

These instructions were tested on xubuntu 9.04. There shouldn’t be many differences if you use other recent Ubuntu or Debian versions.

Install needed software packages

At the time of this writing, note that Android requires Sun’s Java5 JDK, and doesn’t support the Java6 one.

apt-get update
apt-get dist-upgrade
apt-get install git-core bison sun-java5-jdk flex g++ zlib1g-dev
apt-get install  libx11-dev libncurses5-dev gperf uboot-mkimage

Android also uses its own repo script as a git front-end:

mkdir -p ~/bin
cd ~/bin
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > repo
chmod +x repo

We are also going to need a 2007q3 toolchain from Code Sourcery

cd
wget http://www.codesourcery.com/sgpp/lite/arm/portal/package1787/public/arm-none-linux-gnueabi/arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
cd /opt
sudo tar jxf arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

You could also get this toolchain from our website:

cd
wget /pub/demos/beagleboard/android/arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.lzma
cd /opt
sudo tar --lzma -xf ~/arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.lzma

Download sources

Our instructions create a directory in your home directory, but of course, it can be placed anywhere!

 mkdir ~/beagledroid
 cd ~/beagledroid
 repo init -u git://labs.embinux.org/repo/android/platform/beaglemanifest.git/
 repo sync

Caution: this can take a lot of time, as this downloads and extracts 2.4 GB of data. On a fast workstation with a 500KB/s Internet connection, it took about 90 minutes.

Building Android

make

If your workstation has multiple CPUs, you could save a lot of time by running multiple jobs in parallel:

make -j 4

On our machine, this took about 4 hours!

Building the kernel

export CC_PATH=/opt/arm-2007q3/bin/arm-none-linux-gnueabi-
cd ~/beagledroid/kernel
../vendor/embinux/support-tools/beagle_build_kernel.sh

Copying the Android root filesystem

Android’s root file system is generated in ~/beagledroid/out/target/product/generic

cd ~/beagledroid/out/target/product/generic
mkdir ~/beagledroid/rootfs
cp -a root/* ~/beagledroid/rootfs/
cp -a system/* ~/beagledroid/rootfs/system/
cd ~/beagledroid/rootfs
sudo chown -R root.root .
sudo chmod -R a+rwX data system 

Formatting an MMC/SD card

First connect your card reader to your workstation, with the MMC/SD card inside. Type the dmesg command to see which device is used by your workstation. Let’s assume that this device is /dev/sdb

Type the mount command to check your currently mounted partitions. If MMC/SD partitions are mounted, unmount them.

In a terminal edit partitions with fdisk:

sudo fdisk /dev/sdb

Delete any existing partition with the d command.

Now, create the boot partition:

Command (m for help): n 
Command action 
   e   extended 
   p   primary partition (1-4) 
p 
Partition number (1-4): 1 
First cylinder (1-239, default 1): 1 
Last cylinder, +cylinders or +size{K,M,G} (1-239, default 239): +64M

Change its type to FAT32:

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Using the n command again, create a second partition filling up the rest of your card (just accept default values).

Now, format the partitions in your card:

sudo mkfs.vfat -n beagleboot -F 32 /dev/sdb1
sudo mkfs.ext3 /dev/sdb2

Remove and insert your card again. Your new partitions should be mounted automatically.

Copying data to the MMC/SD card

Start by copying the X-loader and U-boot on the first partition.

cd /media/beagleboot
wget /pub/demos/beagleboard/android/MLO
/pub/demos/beagleboard/android/u-boot.bin
cp ~/beagledroid/kernel/arch/arm/boot/uImage .

Now copy the Android root filesystem to the second partition (assuming it is mounted on /media/disk:

sudo rsync -a ~/beagledroid/rootfs/ /media/disk/

Finish by unmounting your MMC/SD partitions:

sudo umount /media/beagleboot
sudo umount /media/disk

Boot setup

The last thing left to do is to specify how the board boots Linux.

Plug the Beagle board on your computer, and also connect it to a DVI-D monitor. Start minicom (corresponding to Hyperterminal in Windows) on /dev/ttyS0, or on /dev/ttyUSB0 if you are using a serial to USB adapter. Power up the board.

First, stop Minicom from truncating long lines by typing [Ctrl] [a] followed by z and w.

In the U-boot prompt, make the board boot automatically on the MMC/SD card:

setenv bootcmd 'mmc init;fatload mmc 0 80000000 uImage;bootm 80000000'
saveenv

Now set the kernel command line arguments:

setenv bootargs console=ttyS2,115200n8 noinitrd root=/dev/mmcblk0p2 video=omapfb.mode=dvi:1280x720MR-24@50 init=/init rootfstype=ext3 rw rootdelay=1 nohz=off androidboot.console=ttyS2

You may need to adapt the video settings to the capabilities of your DVI display. You should now see Android boot!

Author: Michael Opdenacker

Michael Opdenacker is the founder of Bootlin, and was its CEO until 2021. He is best known for all the free embedded Linux and kernel training materials that he created together with Thomas Petazzoni. He is always looking for ways to increase performance, reduce size and boot time, and to maximize Linux' world domination. More details...

31 thoughts on “Building Android on Beagle”

  1. Hi Sanjeev,

    Are you using Windows to extract these archives? In this case, we can’t help you?

    If you use GNU/Linux, you will find examples about how to use wget to download these files and how to extract the .tar.lzma archives. That’s what we recommend.

    Good luck,

    Cheers,

    Michael.

  2. Hi Sany,

    Try to run the following command:
    mkimage -l ~/beagledroid/kernel/arch/arm/boot/uImage

    … and give us the output (if you use Debian or Ubuntu, you may need the uboot-mkimage package). This way, we will be able to check whether the image looks correct or not.

    Here’s what we got:

    Image Name: Linux-2.6.29-omap1-07174-g7fbc41
    Created: Mon Jun 1 17:37:32 2009
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 1913608 Bytes = 1868.76 kB = 1.82 MB
    Load Address: 0x80008000
    Entry Point: 0x80008000

    Cheers,
    Michael.

  3. Thank you for this guide. I was able to build Android for Beagle Board painlessly just following your instructions. I spent a day wrestling with the original Embinux guide to no avail.

    1. I have followed all the steps, i have created SD card with u-boot,MLO,uImage and copied file system in the second partition.
      but when i insert it into beagle board xM Rev.b, No result on Hyperterminal. no LED on the Memory Card also not glown.
      But when i insert Memory Card which is provided by Beagle Board supplies its working( This is just for confirming that Memory card slot and other parts are working on beagle board)

      Please help on this

    1. When i say “uncompress”,i refer to “tar –lzma -xvf beagledroid-git-20090603.tar.lzma”.

      it still give me the following errors:
      EOF in archive
      tar: Unexpected EOF in archive
      tar: Error is not recoverable: exiting now

      any idea to solve this problem? Btw, I can extract the file “arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.lzma” with no problem..

  4. Hi all,
    I am trying to create filesystem of android but when i run make command
    it gives following error..
    please help me out.
    Thanks in advance.

    Copying out/target/common/obj/JAVA_LIBRARIES/core-tests_intermediates/classes-full-debug.jar
    target Jar: core-tests (out/target/common/obj/JAVA_LIBRARIES/core-tests_intermediates/javalib.jar)
    java.util.zip.ZipException: duplicate entry: hyts_Foo.c
    at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:192)
    at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
    at sun.tools.jar.Main.addFile(Main.java:731)
    at sun.tools.jar.Main.update(Main.java:585)
    at sun.tools.jar.Main.run(Main.java:220)
    at sun.tools.jar.Main.main(Main.java:1167)
    make: *** [out/target/common/obj/JAVA_LIBRARIES/core-tests_intermediates/javalib.jar] Error 1
    make: *** Deleting file `out/target/common/obj/JAVA_LIBRARIES/core-tests_intermediates/javalib.jar’

  5. Hello Everyone,
    I got the tools installed …..compiled the code. my problem is in the directory ~/beagledroid/kernel/arch/arm/boot/ i only find files zImage and Image. I do not see any file named uImage.

    I would appreciate if people can explain this problem.
    Thanks a lot,
    chris

  6. Thanks for this article, great.
    Having trouble. In particular, the error I get is during the boot process:
    Failed to execute /init. Attempting defaults…
    Kernel panic – not syncing: No init found. Try passing init= option to kernel.

    Has anyone gotten past this error?

    1. Hi,

      Try adding this option “init=init” in the bootargs and ensure init is executable in in your rootfs or at a symbolic link in /sbin/init linking to /link.

      I manage to complete the above from free-electrons files. I am now able to boot Android in my beagleboard.

  7. When I try to download the source, it gets aborted at this stage

    Getting manifest …
    from http:// labs.embinux.org/embinux-android-build/android-omap3/repo/android/platform/manifest.git
    fatal: http:// labs.embinux.org/embinux-android-build/android-omap3/repo/android/platform/manifest.git/info/refs not found: did you run git update-server-info on the server?
    fatal: cannot obtain manifest http:// labs.embinux.org/embinux-android-build/android-omap3/repo/android/platform/manifest.git

    (Note: the above links are now broken… we added a space in them so that they are not turned into real, broken, links)

  8. It would be great if you make actual this post… I’m sure than exist more options to Sun’s Java5 JDK, It can’t be found at ubuntu 10.10 repos… wich alternative jdk can we use? Thank you.

    1. Until Froyo (2.2), you need Sun’s java5 JDK. You can find it here

      With gingerbread (2.3) and newer, the openjdk distributed with ubuntu works fine. We use it every day here.

  9. ERROR the labs.embinux server seems to be down…

    * [new tag] v1.7.4.2 -> v1.7.4.2
    * [new tag] v1.7.4.3 -> v1.7.4.3
    Getting manifest …
    from git://labs.embinux.org/repo/android/platform/beaglemanifest.git
    labs.embinux.org[0: 59.160.172.206]: errno=Connection timed out
    fatal: unable to connect a socket (Connection timed out)
    fatal: cannot obtain manifest git://labs.embinux.org/repo/android/platform/beaglemanifest.git
    alejandro@wil:~/bb1/bin$

    This was the most interesting post about Android on BeagleBoard… idk where i have to go now :S

    1. You can take a look at rowboat instead, which is an android distribution for TI’s SoC-based boards. They have some pages on their wiki explaining how to build a system from the source for the Beagle.

  10. hye. thanx 4 this cool article. i’hve try it and faced some problems..
    i have downloaded the sources but can’t run this command:
    tar –lzma -xvf beagledroid-git-20090603.tar.lzma

    the output:
    tar: beagledroid/system/core/.git/description: Cannot create symlink to `../../../.repo/projects/system/core.git/description’: Operation not permitted
    ……….
    tar: beagledroid/.repo/projects/external/bsdiff.git/hooks: Directory renamed before its status could be extracted
    …………..
    tar: beagledroid/development: Directory renamed before its status could be extracted
    tar: Exiting with failure status due to previous errors

    can anyone guide me..? thanx 🙂

  11. Hi,
    I am trying to build this image to run android on a beagleboard xm
    I get to the 7th line and this it can’t find the server

    sudo wget http:// android.git.kernel.org/repo
    –2011-09-10 16:21:56– http:// android.git.kernel.org/repo
    Resolving android.git.kernel.org… failed: Name or service not known.
    wget: unable to resolve host address `android.git.kernel.org’

    How do I fix this?
    Thanks

    (Webmaster note: the repo URL has changed. We added a space in its http address so that WordPress doesn’t turn it into a real, broken link)

  12. beagleboard does not recognize a USB Hub. needs the self-powered USB Hub?
    sorry for bad english.

  13. Hi everybdY,

    I compiled the android (kernel, sgx, rowboat, using eclair config), after android install I get the pretty android screen. But, android hangs up !!! I don’t know if there is a pb with sgx because I get some patch in uboot to get the 24bit color.

    10x

  14. Hi,
    This is a very nice article. Thanks. I am facing a problem, where by with given uboot, my USB port is not working. So that I cann’t use mouse or keyboard. I am usning C4 beagleboard. Please help.

    Rgds,
    Ashwin.

  15. Hi,
    Thank you for source and your inputs.
    I would like to clarify that these steps and source code can i use it for Beagle Rev B series boards. ?
    or where can i get the exact source for Beagle Rev B boards.

    regards
    Kaykay

  16. hi, i want to ported android O.S. on beagleboard Rev C4 3530 i got uImage.bin ,Oxkernel-beagle.bin,android-beagle.ubi i kept these in first partition of sd card Fat32
    then to boot and run android on beagle board what i need more. please guide me
    thanks,

  17. Hi, I have a problem with rootfs. All the main folders under out/target/product/generic/root are empty although the compilation finished with no problems. Did any of you faced this problem already.

    thanks

  18. i hav openJDK java6 installed on my system and i dont want to install any other version of java like Sun jdk5 because it may create problem to me in future as lot of applications are using this .. i need to change the PATH variable n all ..

    Is there any other way so that i can work with my current JDK6 versoin .. pls reply .. thnx in advance…

  19. [Build Android for the BeagleBoard] : compiler stuck

    someone can help me ?

    ***setup***

    Linux ngaza-k 3.8.0-31-generic #46~precise1-Ubuntu SMP Wed Sep 11 18:21:16 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

    $ gcc -v
    Utilisation des specs internes.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
    Target: x86_64-linux-gnu
    Configuré avec: ../src/configure -v –with-pkgversion=’Ubuntu/Linaro 4.6.3-1ubuntu5′ –with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs –enable-languages=c,c++,fortran,objc,obj-c++ –prefix=/usr –program-suffix=-4.6 –enable-shared –enable-linker-build-id –with-system-zlib –libexecdir=/usr/lib –without-included-gettext –enable-threads=posix –with-gxx-include-dir=/usr/include/c++/4.6 –libdir=/usr/lib –enable-nls –with-sysroot=/ –enable-clocale=gnu –enable-libstdcxx-debug –enable-libstdcxx-time=yes –enable-gnu-unique-object –enable-plugin –enable-objc-gc –disable-werror –with-arch-32=i686 –with-tune=generic –enable-checking=release –build=x86_64-linux-gnu –host=x86_64-linux-gnu –target=x86_64-linux-gnu
    Modèle de thread: posix
    gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

    ***

    Utilisation des specs internes.
    COLLECT_GCC=g++
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
    Target: x86_64-linux-gnu
    Configuré avec: ../src/configure -v –with-pkgversion=’Ubuntu/Linaro 4.6.3-1ubuntu5′ –with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs –enable-languages=c,c++,fortran,objc,obj-c++ –prefix=/usr –program-suffix=-4.6 –enable-shared –enable-linker-build-id –with-system-zlib –libexecdir=/usr/lib –without-included-gettext –enable-threads=posix –with-gxx-include-dir=/usr/include/c++/4.6 –libdir=/usr/lib –enable-nls –with-sysroot=/ –enable-clocale=gnu –enable-libstdcxx-debug –enable-libstdcxx-time=yes –enable-gnu-unique-object –enable-plugin –enable-objc-gc –disable-werror –with-arch-32=i686 –with-tune=generic –enable-checking=release –build=x86_64-linux-gnu –host=x86_64-linux-gnu –target=x86_64-linux-gnu
    Modèle de thread: posix
    gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
    [error]
    external/jpeg/jdmainct.c: In function ‘jinit_d_main_controller’:
    external/jpeg/jdmainct.c:480:15: warning: ‘main’ is usually a function [-Wmain]
    target thumb C: libjpeg <= external/jpeg/jdmarker.c
    external/jpeg/jdmarker.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jdmaster.c
    target thumb C: libjpeg <= external/jpeg/jdmerge.c
    external/jpeg/jdmaster.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    external/jpeg/jdmerge.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    external/sqlite/dist/sqlite3.c: In function 'fkLookupParent':
    external/sqlite/dist/sqlite3.c:47952:5: warning: assuming signed overflow does not occur when assuming that (X – c) <= X is always true [-Wstrict-overflow]
    target thumb C: libjpeg <= external/jpeg/jdphuff.c
    external/jpeg/jdphuff.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jdpostct.c
    external/jpeg/jdpostct.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jdsample.c
    external/jpeg/jdsample.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jdtrans.c
    external/jpeg/jdtrans.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jerror.c
    external/jpeg/jdtrans.c: In function 'jpeg_build_huffman_index_progressive':
    external/jpeg/jdtrans.c:171:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    external/jpeg/jerror.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jfdctflt.c
    external/jpeg/jfdctflt.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jfdctfst.c
    target thumb C: libjpeg <= external/jpeg/jfdctint.c
    external/jpeg/jfdctint.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    external/jpeg/jfdctfst.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jidctflt.c
    external/jpeg/jidctflt.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jidctfst.c
    external/jpeg/jidctfst.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jidctint.c
    external/jpeg/jidctint.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jidctred.c
    external/jpeg/jidctred.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jquant1.c
    external/jpeg/jquant1.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    target thumb C: libjpeg <= external/jpeg/jquant2.c
    external/jpeg/jfdctfst.c: In function 'jpeg_fdct_ifast':
    external/jpeg/jfdctfst.c:222:1: internal compiler error: in gen_thumb_movhi_clobber, at config/arm/arm.md:6155
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See for instructions.
    external/jpeg/jquant2.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libjpeg_intermediates/jfdctfst.o] Erreur 1
    make: *** Attente des tâches non terminées….
    target thumb C: libjpeg <= external/jpeg/jutils.c
    external/jpeg/jutils.c:1:0: warning: -fprefetch-loop-arrays not supported for this target (try -march switches) [enabled by default]
    external/sqlite/dist/sqlite3.c: In function 'sqlite3VdbeExec':
    external/sqlite/dist/sqlite3.c:58248:14: warning: 'pc' may be used uninitialized in this function [-Wuninitialized]
    external/sqlite/dist/sqlite3.c: In function 'sqlite3Fts3UpdateMethod':
    external/sqlite/dist/sqlite3.c:106140:9: warning: 'isEmpty' may be used uninitialized in this function [-Wuninitialized]
    ngaza@ngaza-k:~/felabs/android/linaro/scr$

Comments are closed.