Saturday, March 20, 2010

Booting AT91SAM9G20-EK Android

With an AT91SAM9G20 board running a standard Linux you can now continue on to getting Android booted.

First of all you need a kernel with android specific patches. You can either build it yourself as explained in another post or you can download a prebuilt uImage here:

Boot your module and transfer the uImage using TFTP and write it to flash as you did with the regular kernel.

Then set the bootargs variable:

setenv bootargs 'mem=64M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2 init=init video=vfb: vfb_enable=1 vinput.vinput_devices=1'
saveenv

Now boot Linux using the boot command.

With the Android kernel booted edit /etc/fstab and add the following line to mount the second nand flash partition using the yaffs2 file system:

/dev/mtdblock2 /android yaffs2 defaults 0 0

Then run

mkdir /android
mount /android
chmod 777 android

Now upload the root and system tarballs to /android using scp:

root.tar.bz2 root@192.168.1.2:/android
system.tar.bz2 root@192.168.1.2:/android

And untar them on target:

cd /android
tar -xvjf root.tar.bz2
tar -xvjf system.tar.bz2


Create a symbolic link for /system:

ln -s /android/system /system


Now run /android/runandroid to start it all. This will also start a VNC server and you can connect to it at port 5901. Using ubuntu and vncviewer:

vncviewer 192.168.1.2:5901


Android will take over your console which will conflict with the shell you are currently running so if you want to execute commands on the target use SSH instead.

This will start Android from inside Ångström. If you want to start Android directly without you can do this by asking the linux kernel to use the /android partition as root filesystem.

Reboot the module and stop the boot process in u-boot. Then change the bootcmd variable:

setenv bootargs 'mem=64M console=ttyS0,115200 root=/dev/mtdblock2 rw rootfstype=yaffs2 init=init video=vfb: vfb_enable=1 vinput.vinput_devices=1'
saveenv

Then boot linux with the boot command.

If you only want to run from inside Ångström you might want to disable the Android console so you can continue to use the Ångström terminal. Edit /android/root/init.rc and out-comment the console service like this:

## Daemon processes to be run by init.
##
#service console /system/bin/sh
# console


To make networking in Android work correctly you must first edit /android/system/etc/init.at91sam9g20.sh to setup the Ethernet IP address, gateway and netmask. Edit the following lines to match your settings:

ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up
route add default gw 192.168.1.1 dev eth0

You should also edit /android/default.prop to setup your DNS server. Edit the following line to match your settings (leaving it at default will use an OpenDNS server):

net.dns1=208.67.222.222

2 comments:

  1. Bravo, do you think if it is possible to port android 1.0 onto the board with display like 9261EK?

    ReplyDelete
  2. I intend to play the music, but the AndRoid show this message "Your phone does not have an SD card inserted", although I mounted the SD card into the /sdcard directory before.

    Could you please show me how to solve this problem ?

    ReplyDelete