Search This Blog

Thursday, November 10, 2011

How To CrossCompile OpenJDK for ARMv7


How To CrossCompile OpenJDK for ARMv7

This document describes the steps needed to cross-compile OpenJDK using
OpenEmbedded process, which is clearly described in the following link.
The same sequence of steps are copied here.
Steps for build-setup: ======================
1. First make sure the following packages have been installed on your host PC.
$ sudo apt-get install git python-ply python-progressbar texi2html cvs subversion
gawk chrpath texinfo
2. On Ubuntu you will need to change /bin/sh to point to bash instead of dash,
you can do this by running the following command and answer "No" if you want
to use dash in the question box that gets displayed.
$ sudo dpkg-reconfigure dash
3. Create a directory to be used for openembedded with sufficient disk space.
$ mkdir ~/openembedded
        $ cd ~/openembedded
4. Now you will have to create your own copy of bitbake, openembedded from
its various sources. The openembedded git tree are quite heavy about
500Mb in size, so be patient.
$ wget http://download.berlios.de/bitbake/bitbake-1.12.0.tar.gz
                If you face any problem in wget, download bitbake package manually, and
                copy it to ~/openembedded/.
$ tar zxvf bitbake-1.12.0.tar.gz
$ git clone git://git.openembedded.org/openembedded org.openembedded.dev
                If you are unable to clone git using the above command, you can also clone 
                with http as below,
        $ git clone http://git.openembedded.org/openembedded org.openembedded.dev
5. Create your build directory
$ mkdir build
        $ mkdir build/conf
6. Create your own local.conf.
A tested minimal build/conf/local.conf configuration can look like this.
$ vi build/conf/local.conf

  1. look in org.openembedded.dev/conf/distro
  2. for various preconfigured distro targets.
    DISTRO = "angstrom-2010.x"
  1. look in org.openembedded.dev/conf/machine
  2. for various preconfigured machine targets.
  3. If you want to build packages for the same architecture
  4. as bitbake are running on then change this to MACHINE = "native"
    MACHINE = "beagleboard"
  1. Comment out one of the two lines below
    #DISTRO_TYPE = "debug"
    DISTRO_TYPE = "release"
#This row instructs bitbake to both create jffs2 compressed filesystems for embedded
flash disks
#and tar.gz tarballs to be unpacked on removable compact flash sd cards.
IMAGE_FSTYPES = "jffs2 tar.gz "
#
  1. The default build uses glibc
  2. Uncomment the line below if you want uclibc instead of glibc
  3. be prepared for a lot of package breakage!
  4. 'uclibc' or 'glibc' or 'eglibc'
    ANGSTROMLIBC = "glibc"
#
  1. If you enable glibc and encounter qemu-native build issues
  2. uncomment the line below.
    ENABLE_BINARY_LOCALE_GENERATION=0
  1. specifies where BitBake should place the downloaded sources
    DL_DIR = "${OETOP}/sources"
  1. specifies where BitBake should create its temporary files
    TMPDIR = ${OETOP}/${MYBUILDDIR}/tmp
  1. specifies that BitBake should emit the log if a build fails
    BBINCLUDELOGS = "yes"
  1. collection setup
    BBFILES="${OEBRANCH}/recipes/*/*.bb ${USERBRANCH}/packages/*/*.bb"
BBFILE_COLLECTIONS="oe user"
BBFILE_PATTERN_oe="^${OEBRANCH}/packages"
BBFILE_PATTERN_user="^${USERBRANCH}/packages"
BBFILE_PRIORITY_oe="5"
BBFILE_PRIORITY_user="15"
  1. Uncomment these lines to enable parallel make.
  2. This allows make to spawn mutliple processes to take advantage of multiple
  3. processors. Useful on SMP machines
    PARALLEL_MAKE = "-j 4"
    BB_NUMBER_THREADS = "4"
  1. some of the OE provided native tools are a bit buggy
  2. uncomment the line below if you run into build failures due to the packages listed
    below
  3. you will also need to install your distro's version of these packages on your
    build machine
    #ASSUME_PROVIDED += "gdk-pixbuf-csource-native imagemagick-native librsvg-native
    ------------------------------------------------------------------------------------
7. Then you have to configure your environment variables to place 
bitbake in your path Do this by creating a simple bash script like this: #
  1. Environment setup for oe #
$ vi run.sh
------------------------------------------------------------------------------------
export MYBUILDDIR="build"
export BB_ENV_EXTRAWHITE="MACHINE DISTRO ANGSTROM_MODE OETOP OEBRANCH USERBRANCH
MYBUILDDIR"
export OETOP="~/openembedded"
export OEBRANCH="${OETOP}/org.openembedded.dev"
export USERBRANCH="${OETOP}/user.collection"
export PATH="${OETOP}/bitbake-1.12.0/bin/:$PATH"
export BBPATH="${OETOP}/${MYBUILDDIR}:${USERBRANCH}:${OEBRANCH}"
umask 0002
bash #
  1. end oe setup #
    ------------------------------------------------------------------------------------
now run this script before you want to build something using oe.
$ chmod +x run.sh
        $ ./run.sh
8. Now cross-compile OpenJDK using bitbake command.
simply do the following:
$ bitbake openjdk-6
9. Once the compilation successfull, openJDK binaries can be found at,
$ cd
~/openembedded-openjdk/build/tmp/work/armv7a-angstrom-linux-gnueabi/openjdk-6-jre-6b18-1.8.5-r11.1/.
OpenJDK JRE specific binaries can be found at,
$ cd
~/openembedded-openjdk/build/tmp/work/armv7a-angstrom-linux-gnueabi/openjdk-6-jre-6b18-1.8.5-r11.1/image/usr/lib/jvm/java-6-openjdk/jre/*
Issues faced during build-setup: ================================
1. Proxy settings.
During the build process, bitbake tools will try to download many required packages
from the console.
To run this behind the proxy, need to set proper proxy settings to access from the
console.
a. Add following proxy details to the end of ~/.bashrc file.
export
http_proxy="http://&lt;PROXY_USER&gt;:&lt;PROXY_PASSWORD&gt;<PROXY_ADDRESS>:<PROXY_PORT_NUM>/" 
        export
https_proxy="https://<PROXY_USER>:<PROXY_PASSWORD>&lt;PROXY_ADDRESS&gt;:&lt;PROXY_PORT_NUM&gt;/" 
        export
ftp_proxy="ftp://&lt;PROXY_USER&gt;:&lt;PROXY_PASSWORD&gt;@&lt;PROXY_ADDRESS&gt;:&lt;PROXY_PORT_NUM&gt;/"
b. Command wget uses to donwload required packages.  
           So, add following proxy details to /etc/wgetrc file, under proxy section.
http_proxy="http://&lt;PROXY_USER&gt;:&lt;PROXY_PASSWORD&gt;<PROXY_ADDRESS>:<PROXY_PORT_NUM>/" 
        https_proxy="https://<PROXY_USER>:<PROXY_PASSWORD>&lt;PROXY_ADDRESS&gt;:&lt;PROXY_PORT_NUM&gt;/" 
        ftp_proxy="ftp://&lt;PROXY_USER&gt;:&lt;PROXY_PASSWORD&gt;@&lt;PROXY_ADDRESS&gt;:&lt;PROXY_PORT_NUM&gt;/"
c. Above 'a' and 'b' are for a normal proxy settings to access net from console.
           Command "bitbake" executes its own environment where it won't get access to
these proxy settings.  So,
           it tries to access the net directly instead of behind the proxy.
To resolve this, there is a work around used for wget.
1. go to wget binary path
                $ which wget
                /usr/local/bin/wget
2. go to /usr/local/bin/wget
                $ cd /usr/local/bin/
3. Rename "wget" to some thing like, "wget.exe"  (you need to have a super user
permissions)
                $ sudo mv wget wget.exe
4. Add the below script to file name "wget" 
                $ sudo vi wget
--------------------------------------
#!/bin/bash
echo "Using alternative wget .."
wget.exe --execute
http_proxy="http://<PROXY_USER>:<PROXY_PASSWORD><PROXY_ADDRESS>:<PROXY_PORT>/" $
--------------------------------------
5. Save and exit.
2. Checksum mismatch error for a downloaded packages.
Bitbake tries to download many required packages and matches for their check sum.
It check sum doesn't match, the package may be corrupted.
In this case give a try to download manually the corrupted package and place it
to the source
directory.
~/openembedded-openjdk/sources
3. If the proxy password/username contains a combination of @ symbol, use its hex
value in place of @
 character.  hex of @ character is %40
E.g., PROXY_PASSWORD - "passw@rd"
        HTTP_PROXY="http://username:passw:8080/" 
       

1 comment:

  1. Hi
    I am getting the following error

    bitbake openjdk-7-jre
    ERROR: Unable to parse conf/bitbake.conf: file conf/bitbake.conf not found in ~/openembedded/build:~/openembedded/user.collection:~/openembedded/org.openembedded.dev

    ReplyDelete