Developing on an Embedded System

To productively develop and programm on the Beagle Board with Android we recommend the following Setup

  • Linux Machine (Ubuntu did very fine) with USB/Ethernet
  • IDC-10 to USB Converter or IDC-10 to COM to USB Setup (with minicom for serial communication)
  • SD-Card preferably ? 512 MB
  • USB-To-Ethernet Converter
  • and of course a little bit of patience :)

Following sources were extremely helpfull in terms of Beagle Board Setup and Android Documentation.

embinux android port – http://labs.embinux.org/index.php/Android_Porting_Guide_to_Beagle_Board

eLinux Beagle Board Wiki – http://elinux.org/BeagleBoard

Android OSS Project Website – http://source.android.com/

Sadly all detailed knowledge of the Android source is found mainly distributed in the source tree itself. If you need to know exact facts, don’t be afraid to browse the source; it helps a lot.

Booting the Beagle Board

The Beagle Board uses u-Boot as its default Stage-1-Bootloader. U-Boot will initiate the Kernel and pass the Kernel arguments; after the Kernel is up it will call the init executable in the Root File System.

The complete user manual of u-Boot can be found here.

However, on your SD/MMC-Card is another u-Boot image called “u-boot.bin”. By default the Beagle Board will bring up the MMC’s uBoot with it’s hardcoded arguments. To Change those you can compile your own “u-boot.bin” from the sources with the codesourcery cross compiler.

Code Sourcery Toolchain
U-Boot source at sourceforge

You can get u-Boot with git:

git clone git://git.denx.de/u-boot.git u-boot-main
cd u-boot-main
git checkout --track -b omap3 origin/master

If you need to make adjustments to the Kernel Arguments, do it in the header file:
u-boot/u-boot-main/include/configs/omap/omap3_beagle.h

Using the following 3 commands you can build you own uBoot image for your MMC-Card. Note: replace arm-none-linux-gnueabi- with your toolchain.

make CROSS_COMPILE=arm-none-linux-gnueabi- mrproper
make CROSS_COMPILE=arm-none-linux-gnueabi- omap3_beagle_config
make CROSS_COMPILE=arm-none-linux-gnueabi-

Source: eLinux

To customize your u-Boot Splash Screen see our post.

Layout of the SD/MMC

Layout of the SD/MMC

Asuming you want to boot from the SD/MMC you will have to create two Partitions on your Card.

  1. FAT32 Partition containing Kernel Image, u-Boot.bin, MLO, optional boot.src
  2. EXT3 Partition containing the Android Root File System

If you don’t want to go all the fdisk-commandline pain just get a graphical partitioner like gparted for ubuntu.

sudo apt-get install gparted

Just make sure that the first section is your FAT32 partition.

The MLO file is used for CPU initialisation. -> Zipped MLO

Last but not least you need to have a Kernel Image. For now we used the Kernel Source from the embinux team . They offer a git repository for the kernel and detailed instructions how to build it.

As for the Root File System, we are using the original from Google with adjustments described in our Platform Porting Guide.

Following the directions, your SD/MMC Card should now be ready to boot. Next you will need a Root File System.

Using NFS as root file system (RFS)

Make sure that you have an NFS Kernel Server installed on your Hostsystem.

sudo apt-get install nfs-kernel-server

Now, in the configuration file under /etc/exports add a line to specify the folder containing the RFS and other options. In our example this is

/opt/android/google/out/target/product/generic/root       10.196.132.0/24(rw,no_root_squash,sync,crossmnt,no_subtree_check)

This will export the specified folder and make it available to all ip numbers in the form of 10.196.132.*. Also pay special attention that you correctly insert the additional parameters like rw,no_root_squash, etc. We for instance didn’t bother much about these parameters in the beginning; and therefore wasted at least two hours of our lives. If you are still planning to alter those parameters, then be aware that you will always have to restart your NFS server after doing so. Now restart the NFS Server with the following commands

sudo /etc/init.d/nfs-kernel-server restart
sudo exportfs -a

If you didnt see any errors your NFS server should be working fine.

The next step is to configure U-Boot on the Beagleboard to mount the exported RFS via NFS. We found that the easiest solution is to write a custom U-Boot script and save it as boot.scr on the MMC boot partition. If you havent changed the standard bootcmd environment variable, then u-boot will automatically look for a boot.scr file on the MMC and execute it. If you did mess up all environment variables just like us, then you might want to reset them to the original settings (see Validating Beagle Board for further information).

Create a simple text file nfsbooting.txt and paste in the following lines:

echo running NFS bootscript
echo serverip is ${serverip}
echo serverpath is ${serverpath}
echo ip is ${ip}

setenv nfsroot ${serverip}:${serverpath},nolock,tcp,rsize=1024,wsize=1024
setenv bootargs console=ttyS2,115200n8 rw rootwait rootfstype=ext3 rootdelay=1 androidboot.console=ttyS2 nfsroot=${nfsroot} ip=${ip} root=/dev/nfs init=./init

fatload mmc 0 ${loadaddr} uImage.bin
bootm ${loadaddr}

Note that you will have to save the additional environment variables on the Beagle Board: $serverip, $serverpath and $ip ($loadaddr should already be specified). But first, save nfsbooting.txt and convert it to an u-boot script file named boot.scr with mkimage (of course you might have to sudo apt-get install mkimage beforehands).

mkimage -T script -C none -n 'NFS Script File' -d nfsbooting.txt boot.scr

Finally copy boot.scr to the boot partition of your MMC. Insert MMC into Beagleboard again, reset and stop the autoboot process throught minicom by hitting any key on your keyboard. Now we’ll set the missing environment variables mentioned above. Of course you need to adjust those for your needs. This is just our working example.

setenv serverip 10.196.132.201
setenv serverpath /opt/android/google/out/target/product/generic/root/
setenv ip dhcp
saveenv

Now you should be good to go! Restart the Beagle Board and wait for autoboot to kick in. Android will now always automatically boot with the provided RFS over NFS. If you ever change your server ip, or the export path in which the RFS is installed, simply redo the last one of the above steps with your new values!

Eclipse Debugging on the Beagleboard

Eclipse Debugging works great and out of the box with the provided Android Virtual Device (AVD) Emulator. However, if you want to debug your Applications directly on the Beagleboard from within Eclipse, you may have to adjust some settings. Here we show you how:

First of all, make sure that you have the latest Android SDK and Eclipse ADT Plugin installed! Go to Download Android SDK page, if you are unsure about that. The official Developing on a Device section describes how to setup an Android Device for debugging.

Following the tutorial in the above link suggests that you create the following file

/etc/udev/rules.d/51-android.rules

and paste in this line

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

However, this will not work with the Beagleboard, because it uses a different USB Vendor id specified in SYSFS(idVendor)==”xxx”. To find out which Vendor id your beagleboard uses type

lsusb

in a terminal when the Beagleboard’s USB-OTG is disconnected. You should see a list of attached USB devices, ie

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
...

Now connect your Beagleboard via USB-OTG (“USB On-The-Go”, the small USB connector) and once again, type lsusb in a terminal. This time you should see a slightly different List. For example:

Bus 002 Device 011: ID 18d1:0002
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
...

Try to find out which new device has been listed. Here it is on the first line which ends with ID 18d1:0002. The number before the colon is 18d1 and this is the Beagleboard USB vendor id we’ve been looking for (in case you forgot)!

Thus, we’ll create a new file by issuing

sudo gedit /etc/udev/rules.d/55-beagle.rules

and paste in the following

SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"

Save and close gedit, then execute:

chmod a+rx /etc/udev/rules.d/55-beagle.rules

Unplug your beagleboard and replug again. (Alternatively you could restart udev). Now from your Android SDK folder let adb list all available devices with

tools/adb devices

You should see something like

List of devices attached
0123456789ABCDEF    device

This means your Beagleboard has been recognized by adb and you can use it in Eclipse to upload and debug your applications! In Eclipse, simply go to Run > Run configurations > Target.. and select manual to choose the Beagleboard as the default Target.

One thought on “Developing on an Embedded System

  1. Pingback: Using Android in Industrial Automation » Changing the uBoot Splash Screen

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>