PM9G45-Android

From Ronetix
Jump to navigation Jump to search
Pm9g45 top.png

Needed Tools

Android source repository tool

repo(a git script) is a tool to facilitate the use of git with Android code, to install it:

$ mkdir -p ~/usr/local/bin
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/usr/local/bin/repo
$ chmod a+x ~/usr/local/bin/repo
$ export PATH=$PATH:~/usr/local/bin


Packing Linux kernel suitable for usage by U-Boot

When building U-Boot in the tools directory a tool mkimage will be build, too. To be successful "make uImage" command from the Linux kernel tree, mkimage must be in a directory from the PATH list.

A static executable for GNU/Linux at

http://download.ronetix.at/boards/tools/linux/

Serial communication or terminal emulation software

Use screen or minicom to get connected to the pm9g45 board through RS-232 port.

Java JDK required version for building Android v2.1 file system is 1.5.

JAVA version is required to be 1.5. Get JDK 1.5.0 update 22 and execute:

$ export JAVA_HOME=<java installation path>
$ export PATH=$JAVA_HOME/bin:$PATH

If "undefined reference to symbol 'dlsym@@GLIBC_2.0" appears take a look at [4], and add "LOCAL_LDLIBS += -ldl" before each "LOCAL_MODULE_TAGS := tests" in system/core/libacc/tests/Android.mk file.

Tool for creating JFFS2 root fs file system

The needed tool mkfs.jffs2 is part of mtd-utils and mtd-tools.

A static executable for GNU/Linux at

http://download.ronetix.at/boards/tools/linux/

Get Android sources

Android sources

The Android codes from their primary locations can be obtained as described in http://www.at91.com/android4sam/bin/view/Android4SAM/GetAndroid

The working directory is assumed to be ~/usr/src/pm9g45/ and could be changed.

FIXME:see http://source.android.com/source/downloading.html

$ mkdir -p ~/usr/src/pm9g45/android
$ mkdir -p ~/usr/src/pm9g45/u-boot
$ mkdir -p ~/usr/src/pm9g45/linux
$ cd ~/usr/src/pm9g45/android
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.1_r2
$ cd hardware
$ git clone git://android.git.kernel.org/platform/hardware/alsa_sound.git
$ cd alsa_sound
$ git checkout origin/eclair
$ cd ../external
$ git clone git://android.git.kernel.org/platform/external/alsa-lib.git
$ cd alsa-lib
$ git checkout origin/eclair
$ cd ..
$ git clone git://android.git.kernel.org/platform/external/alsa-utils.git
$ cd alsa-utils
$ git checkout origin/eclair

The PM9G45 BSP is based on Atmel AT91SAM9G45 port for Android.

$ cd ~/usr/src/pm9g45/android/vendor
$ wget http://download.ronetix.at/boards/android/v2.1/patches/Android-2.1_r2-ver1.1-ronetix-14102011.tar.bz2
$ wget http://download.ronetix.at/boards/android/v2.1/patches/Android-2.1_r2-ver1.1.tar.bz2
$ tar xjvf Android-2.1_r2-ver1.1.tar.bz2
$ tar xjvf Android-2.1_r2-ver1.1-ronetix-14102011.tar.bz2


Toolchain

Android sources comes with prebuilt toolchains and the one mentioned is used.

$ export CROSS_COMPILE=~/usr/src/pm9g45/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-


At91bootstrap

No modifications of the bootstrap required. But for some reason a change is needed see the AT91Bootstrap README. An already built bin file is ready for use(x. Pre-built images)


Bootloader

U-Boot for Android usage requires no special treatment. See U-Boot README to configure and build the boot loader if customizations are needed, else and prebuilt one can be used.(x. Pre-built images)


Linux Kernel

The commands below shows how to build Linux kernel. For demo and evaluation purposes there is an prebuilt Linux kernel image file (x. Pre-built images).

$ wget http://download.ronetix.at/boards/linux/kernel/2.6.30/linux-2.6.30.tar.bz2
$ tar xjf linux-2.6.30.tar.bz2
$ cd linux-2.6.30
$ git init
$ git add *
$ git add .gitignore .mailmap
$ git commit -m "Initial commit after linux-2.6.30.tar.bz2 extraction"
$ wget http://download.ronetix.at/boards/android/v2.1/patches/2.6.30-at91-exp.4-android_2.1_r2-pm9g45_v1.3-09122011.tar.bz2
$ tar xjf 2.6.30-at91-exp.4-android_2.1_r2-pm9g45_v1.3-09122011.tar.bz2
$ git am 2.6.30-at91-exp.4-android_2.1_r2-pm9g45_v1.3-09122011/*.patch
$ export CROSS_COMPILE=~/usr/src/pm9g45/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
$ export ARCH=arm
$ cp pm9g45_v1.3_android_config .config
$ make oldconfig

To build it run:

$ make uImage

The result arch/arm/boot/uImage is to be written to the PM9G45 NAND.

Building Android file system

In the vendor/ronetix/README file from the Android package are available these commands for reminder.

Setup environment

$ cd ~/usr/src/pm9g45/android/
$ make clean
$ source build/envsetup.sh
$ chmod a-x vendor/atmel/cmd/partner_setup
$ partner_setup pm9g45
$ choosecombo device release pm9g45 eng
...
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=pm9g45
TARGET_BUILD_VARIANT=user
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ERE27
============================================

Build it

Here it takes a lot of drinks, and finally the result is at out/target/product/pm9g45

$ make -j4

Pack the images in file for writing to the target

$ cd ~/usr/src/pm9g45/android/
$ _C_PWD=`pwd`
$ cd out/target/product/pm9g45
$ cp -T system root/system -r
$ chmod 0777 root/ -R
$ mkfs.jffs2 -l -s 0x800 -e 0x20000 -p 0x4000000 -d root/ -o pm9g45-android.jffs2 -n -q
$ cd $_C_PWD
$ unset _C_PWD

Move the pm9g45-android.jffs2 file in a TFTP/FTP reachable place or SD card to be programmed faster with PEEDI. SAM-BA v2.10 can be used to program the file system, too.

RootFS to be written at 0x500000 with JFFS2 OOB.


Burning images

In case you compile all the sources the produced files will be:

  • AT91Bootstap - binaries/pm9g45-nandflashboot-2.13.bin
  • U-Boot - u-boot.bin
  • Linux kernel - arch/arm/boot/uImage
  • Android - out/target/product/pm9g45/pm9g45-android.jffs2

The files are given with respect from the place the build command is issued. If you use the demo prebuilt images, their list is in the prebuilt images topic.

Using SAM-BA v2.10

TODO: SAM-BA build instructions.

Using PEEDI flash programmer

Flash Section 0 and 1 have to be with OOB Info set to FF, but flash sections 2 and 3 must be with OOB Info set to JFFS2.

PEEDI> f s 0
PEEDI> f e ; Erase the whole NAND with 0xFF set in the spare area
PEEDI> f p pm9g45-nandflashboot-2.13.bin bin 0x0
PEEDI> f s 1
PEEDI> f p u-boot.bin bin 0x20000 erase
PEEDI> f s 2
PEEDI> f p uImage bin 0x200000 erase
PEEDI> f s 3
PEEDI> f p pm9g45-android.jffs2 bin 0x500000 erase

If you wish to waste the data saved by Android, play the next two commands:

PEEDI> f s 0
PEEDI> f e 0x2780000 0x10000000

Initial run

After the program completes unplug the power cord, then detach the JTAG cable or in PEEDI run "ta de", plug the Ethernet and RS-232 cable and finally plug the power cord.

The first run will take around 2 minutes.

Applications Developing

Here are some specifics for Android applications:

  • "dx" which allows to convert Java Class files into "dex" (Dalvik Executable) files.
  • Android applications are packed into an .apk (Android Package) file by the program "aapt" (Android Asset Packaging Tool)
  • To simplify development Google provides the Android Development Tools (ADT) for Eclipse
  • ADT from the URL https://dl-ssl.google.com/android/eclipse/ and requires "org.eclipse.jdt" to be installed.
  • Android supports 2-D and 3-D graphics using the OpenGL libraries and supports data storage in a SQLite database.
  • Every Android applications runs in its own process and under its own user id which is generated automatically by the Android system during deployment.
  • Steps to instal the Andoid SDK http://developer.android.com/sdk/installing.html
  • Insrall JDK plugin for Eclipse Helios: In "Install new window" enter "Helios-http://download.eclipse.org/releases/helios/" then hit enter. From the list select "Eclipse IDE for Java Developers" and "Eclipse Java Development Tools"
  • Each application must be signed in order to be accepted by Android, even the applications in the developing phase must be signed with the standard debugkey to be uploaded on the target. The target have to be enabled to accept debuggable applications. Signing and building noted here http://developer.android.com/guide/developing/building/building-cmdline.html


Android Compatible devices

Even though the software is open-source, device manufacturers cannot use Google's Android trademark unless Google certifies that the device complies with their Compatibility Definition Document (CDD). Devices must also meet this definition to be eligible to license Google's closed-source applications, including the Android Market.

http://source.android.com/compatibility/index.html


Tip and tricks

LCD Resolution

For a custom screen edit file "common/packages/apps/Calibrate/src/com/android/calibrate/AndroidCalibrate.java" locate where UI_SCREEN_<WIDTH and HEIGHT> are set and modify them.

Modifying ramdisk.img

When building the Android file system a three img files are produced in the out/target/product/pm9g45/ directory: ramdisk.img wich contains the root/ directory, system.img which is the same as system/ directory and userdata.img which is data/ directory. Crating the file system for pm9g45 is descried above.

extract:

$ gnucpio -iz -F ramdisk.img

create:

gnucpio -i -t -F ../ramdisk.img | gnucpio -o -H newc -O ../rootfs.img


BB9G45 button functions

A list of Android KeyEvents is lested at

A kaymap table can be found:

  • out/target/product/pm9g45/system/usr/keylayout/qwerty.kl

The SW3 and SW4 buttons are defined as:

KEY_MENU is SW4
KEY_BACK is SW3

How to Unlock the Screen

Press a SW3 or SW4 then drag the lock icon over the yellow-green spot next to the other end.

IP over Ethernet

The software gets IP over Ethernet if the cable is attached. The board IP can be seen by executing the following command on the board serial console.

$ ifconfig eth0
eth0: ip 192.168.10.88 mask 255.255.255.0 flags [up broadcast running multicast]

This IP is used to attach ADB to the board.

There is an errors in the way the DHCP is processed, so take a look at "13.1. Enabling the DNS service".


IP over USB0

Connect the J3 USB device port of the target to the USB port of the host computer. On the host a CDC Ethernet Device driver have to be available.

Set the IP of the target:

# ifconfig usb0 192.168.0.200 netmask 255.255.255.0 up

Set the IP of the host and connect to the target:

# ifconfig usb0 192.168.0.1 netmask 255.255.255.0 up # adb connect 192.168.0.200:5555

Android Debug Bridge

This mechanism gives easy to push(put) and pull(get) files from the target memory, provides command shell access, Eclipse ADT plugin easy software developing and getting the Android stack log on the host computer.

The command "adb devices" shows the already connected devices if any, this command do not make connection to the device even through USB. To connect to a device use "adb connect <device IP here>". Where <device IP here could be IP over Ethernet or over USB.

# export PATH=$PATH:~/usr/src/pm9g45/android/out/host/linux-x86/bin/
# adb connect 192.168.10.88:5555
* daemon not running. starting it now *
* daemon started successfully *

connected to 192.168.10.88:5555

# adb devices

List of devices attached

192.168.10.88:5555      device
# adb shell

Android log

The Linux kernel log can be seen as running "dmesg" command in the Android shell. Android stack logs useful for testing and debug can be shown with "catlog" command from the target command shell or with "adb logcat" from the host computer.

Micro SD card

The Micro SD card must be formatted with FAT16 file system. On GNU/Linux host you can use mkdosfs like this:

$ mkdosfs /dev/sdc1

Sound

asound.conf and asound.state and asla_amixer names differ. Using "alsa_amixer" you will get the below names to set the sound.

# alsa_amixer set 'Master' 100
# alsa_amixer set 'Master Playback ZC' unmute
# alsa_amixer set 'Sidetone' 0
# alsa_amixer set 'Line' nocap
# alsa_amixer set 'Mic' cap
# alsa_amixer set 'Mic Boost (+20dB)' mute
# alsa_amixer set 'Playback De-emphasis' '32Khz'
# alsa_amixer set 'Capture' 31
# alsa_amixer set 'ADC High Pass Filter' unmute
# alsa_amixer set 'Input Mux' 'Mic'
# alsa_amixer set 'Output Mixer HiFi' unmute
# alsa_amixer set 'Output Mixer Line Bypass' mute
# alsa_amixer set 'Store DC Offset' unmute

Then do "asla_ctl store -f asound.state", next take the slightly changed names and correct asound.conf. In asound.state are listed parameters ranges and it allowable values.

Recalibrate touch screen from command line

# ps
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
...
# kill "here put the PID of com.android.calibrate"
# rm /data/etc/pointercal 
# am start -a android.intent.action.MAIN -n com.android.calibrate/.AndroidCalibrate 

Errata, bugs and uncouth

Enabling the DNS service

FIXME: DNS and IP address equivalently in getprop and netcfg after running "netcfg eth0 dhcp".

On the first boot the IPs set on eth0 and on dhcp.eth0.ipaddress are the same, but the DNS server is not set(host names are unresolvable).

To set the DNS server do these commands in the Android stack console:

$ getprop dhcp.eth0.dns1
192.168.10.1
$ setprop net.dns1 192.168.10.1

Note that if the dhcp service is taken again with the next two commnds the IP addresses shown by ipconfig and in dhcp.eth0.ipaddress will differ, also the DNS server have to be set if it defers from the previous one.

$ netcfg eth0 up
$ netcfg eth0 dhcp


The initial logo of Atmel is not shown properly

Pre-built images

A set of images which are ready to use for demo and evaluation purposes.

AT91BootStrap
http://download.ronetix.at/boards/linux/bootstrap/nandflashboot/pm9g45-nandflashboot-2.13.bin
U-Boot
http://download.ronetix.at/boards/android/v2.1/u-boot-pm9g45_v1.3-android_v2.1.bin
Linux kernel
http://download.ronetix.at/boards/android/v2.1/uImage-pm9g45_v1.3-andoird_v2.1
Andoid RootFS
http://download.ronetix.at/boards/android/v2.1/pm9g45_v1.3-android_v2.1-rootfs.jffs2

Build environment in Virtual Machine

The provided VM(virtual machine) environment has the ARM toolchain, AT91Bootstrap, U-Boot, Linux kernel and Android stuff. The purpose is to test, easy try,

The VM image and its companian manuals can de dowloaded from [5].

Reference

Articles, documents used to write this text.