37
Getting started with open mobile development on the Openmoko platform Presented at osbootcamp YYZ1 (Mobile embedded development conference - Waterloo, Canada) by Jean-Michel Bouffard <[email protected]>

Getting started with open mobile development on the Openmoko platform

Embed Size (px)

DESCRIPTION

Tutorial presentation about embedded development on the Openmoko platform. Presented at the fosslc.org event "Free/Open Source Mobile Development: An Introduction" in Waterloo, Canada

Citation preview

Page 1: Getting started with open mobile development on the Openmoko platform

Getting started withopen mobiledevelopment on theOpenmoko platformPresented at osbootcamp YYZ1 (Mobile embedded development conference ­ Waterloo, Canada)

by Jean­Michel Bouffard

<jean­[email protected]>

Page 2: Getting started with open mobile development on the Openmoko platform

2

Summary

✔ Setting up the development environment✔ OM toolchain✔ OpenEmbedded build system

✔ Creating a simple first project for the platform✔ Running the application

✔ Openmoko emulator✔ FreeRunner device

✔ Packaging a custom distribution✔ Adding new hardware components

Page 3: Getting started with open mobile development on the Openmoko platform

3

Introduction

✔ Openmoko OM2008.x distribution build environment is using:

✔ OpenEmbedded (http://wiki.openembedded.net)✔ Examples from this tutorial are done using:

✔ Ubuntu 8.10 i686 host system✔ Official OM2008.x Openmoko distributions

Page 4: Getting started with open mobile development on the Openmoko platform

4

Introduction

✔ Choose your development toolkit

Page 5: Getting started with open mobile development on the Openmoko platform

5

Introduction

✔ Choose your build system✔ Toolchain

✔ Installs only a cross­compiler and basic libraries for application development

✔ Can build applications only✔ Unstable and less recommended

✔ OpenEmbedded✔ Install the complete build system for Openmoko 

distributions✔ Can build applications and full OS images✔ More stable and recommended

Page 6: Getting started with open mobile development on the Openmoko platform

6

Setting up the development environment­ Toolchain

✔ Requirements✔ autotools build system✔ default packages:

✔ autoconf, automake, binutils, gcc, gcc­c++, libtool, ccache, intltool

✔ distro dependent packages (Ex. Ubuntu 8.10):✔ libglib2.0­dev libxrender­dev libmokoui2­dev libgconf2­dev 

mtools fakeroot alien check uboot­mkimage✔ Complete list available on the openmoko wiki at 

http://wiki.openmoko.org/wiki/Toolchain

Page 7: Getting started with open mobile development on the Openmoko platform

7

Setting up the development environment­ Toolchain

✔ Installation✔ download toolchain archive from 

http://downloads.openmoko.org/toolchains✔ extract archive to /

✔ Prepare environment variables✔ use “setup­env” script

> wget http://downloads.openmoko.org/toolchains/openmoko­i686­arm­linux­gnueabi­toolchain.tar.bz2

> cd /> tar ­xjvf ~/openmoko­i686­arm­linux­gnueabi­toolchain.tar.bz2> . /usr/local/openmoko/arm/setup­env

Page 8: Getting started with open mobile development on the Openmoko platform

8

Setting up the development environment­ Toolchain

✔ The clean toolchain is like a Linux system without any development libraries, so dependencies related to the new software project must be installed

✔ Preparation of environment✔ Modifications of the toolchain must be done as a “super user”✔ Set environment with the “setup­env” script

✔ Installation of libraries✔ Update packages list with “opkg­target”✔ Search and install packages with “opkg­target”

> sudo bash> . /usr/local/openmoko/arm/environment­setup> opkg­target update> opkg­target list | grep gtk+­dev> opkg­target install gtk+­dev

Page 9: Getting started with open mobile development on the Openmoko platform

9

Setting up the development environment­ Toolchain

✔ Application development can be done on the host system with desktop development tools

✔ Building for the target platform using the toolchain✔ Preparation of environment

✔ Application development can be done as a “normal user”✔ Set environment with the “setup­env” script

✔ Building applications✔ Configure application with “om­conf”✔ Build application as usual with “make”

> . /usr/local/openmoko/arm/environment­setup> cp ­r /usr/local/openmoko/source/openmoko­sample2 ~/> om­conf openmoko­sample2> cd openmoko­sample2> make

Page 10: Getting started with open mobile development on the Openmoko platform

10

Setting up the development environment­ OpenEmbedded

✔ Install required packages✔ Default packages:

✔ subversion, texi2html, texinfo, help2man✔ ncurses, zlib (or libz), OpenSSL, GTK++

✔ Complete list can be found at http://wiki.openmoko.org/wiki/MokoMakeFile#Required_software

✔ Download MokoMakefile✔ http://www.rwhitby.net/files/openmoko/Makefile

> mkdir ~/moko; cd ~/moko> wget http://www.rwhitby.net/files/openmoko/Makefile

Page 11: Getting started with open mobile development on the Openmoko platform

11

Setting up the development environment­ OpenEmbedded

✔ Start build:✔ make setup✔ To accelerate the build on a multi­core computer, add these two 

lines in the file “build/conf/local.conf”✔ PARALLEL_MAKE = "­j 4"✔ BB_NUMBER_THREADS = "4"

✔ make setup­machine­om­gta02✔ make image

✔ Wait (6220 steps generate 10GB of data in ~10 hours!)> make setup> make setup­machine­om­gta02> make image

Page 12: Getting started with open mobile development on the Openmoko platform

12

Setting up the development environment­ OpenEmbedded

✔ You will encounter build errors✔ Check errors in log files

✔ For instance, compilation log files for the alsa­utils package can be found in ~/moko/build/tmp/work/armv4t­angstrom­linux­gnueabi/alsa­utils­1.0.15­r1/temp/log.do_compile.xxxx

✔ Correct errors if any✔ Update environment, clean package and restart build

✔ make update­makefile setup update✔ make clean­package­<pkg_error>; make image

> tail ~/moko/build/tmp/work/armv4t­angstrom­linux­gnueabi/alsa­utils­1.0.15­r1/temp/log.do_compile.25688

> make update­makefile > make setup update> make clean­package­alsa­utils> make image

Page 13: Getting started with open mobile development on the Openmoko platform

13

Setting up the development environment­ OpenEmbedded

✔ Add additional requirements for the development✔ make build­package­<pkg_req>

✔ Newly built packages will be written to the deployment folder

✔ ~/moko/build/tmp/deploy/glibc/opk/armv4t/✔ Missing packages are not part of the generated 

OM2008.x image, they need to be installed along with the new application

> make build­package­libglade

Page 14: Getting started with open mobile development on the Openmoko platform

14

Creating a simple first project for the platform

✔ For this example, we will build a GTK+ application✔ Anjuta development environment✔ Glade Interface Designer

Page 15: Getting started with open mobile development on the Openmoko platform

15

Creating a simple first project for the platform

Page 16: Getting started with open mobile development on the Openmoko platform

16

Creating a simple first project for the platform

Page 17: Getting started with open mobile development on the Openmoko platform

17

Creating a simple first project for the platform

✔ Glade interface designer lets you create an interface easily for your new application

✔ Follow UI design recommendations✔ Instantaneous save, finger usage, efficient layout, etc

Page 18: Getting started with open mobile development on the Openmoko platform

18

Creating a simple first project for the platform

✔ An icon and desktop item must beadded

✔ /data/openmokocalc.png✔ /data/openmokocalc.desktop✔ /data/Makefile.am

[Desktop Entry]Encoding=UTF­8Name=Openmoko CalcComment=Simple calculator applicationExec=openmokocalcIcon=openmokocalcTerminal=falseType=ApplicationCategories=Application;Utilities;MimeType=text/x­vcard;SingleInstance=trueStartupNotify=true

## desktop integration: .desktop file#desktopdir = $(datadir)/applicationsdist_desktop_DATA = openmokocalc.desktop

## desktop integration: application icon#appicondir = $(datadir)/pixmapsdist_appicon_DATA = openmokocalc.png

/data/Makefile.am/data/openmokocalc.desktop

/data/openmokocalc.png

Page 19: Getting started with open mobile development on the Openmoko platform

19

Creating a simple first project for the platform

✔ Build the application for the host computer

Page 20: Getting started with open mobile development on the Openmoko platform

20

Creating a simple first project for the platform

✔ Test the application...

✔ ...then create a source tarball

Page 21: Getting started with open mobile development on the Openmoko platform

21

Creating a simple first project for the platform

✔ BitBake is used to manage builds in OpenEmbedded✔ A BitBake recipe is needed to identify how to build a 

packageDESCRIPTION = "Openmoko Calculator"AUTHOR = "Jean­Michel Bouffard <jean­[email protected]>"HOMEPAGE = "http://www.crc.ca/mmb"SECTION = "console/applications"PRIORITY = "optional"LICENSE = "GPL"DEPENDS = ""RDEPENDS = ""PN = "openmokocalc"PV = "0.1"PR = "r0"EXTRA_OECONF += ""

SRC_URI = "file://openmokocalc­0.1.tar.gz"

inherit autotools

/openmokocalc.bb

Page 22: Getting started with open mobile development on the Openmoko platform

22

Creating a simple first project for the platform

✔ Build application for Openmoko using the “bitbake” command

✔ configuration script is executed with flags for cross­compiler✔ compiler and linker are executed✔ application installation is validated✔ ipk package is created

✔ application can be found in:✔ ~/moko/build/tmp/deploy/glibc/opk/armv4t/

> cd ~/moko/build> . ../setup­env> bitbake ­b ~/workspace/openmoko_calc/openmokocalc.bb> cp ~/moko/build/tmp/deploy/glibc/opk/armv4t/openmokocalc_0.1­r0_arm4t.ipk ~/.

Page 23: Getting started with open mobile development on the Openmoko platform

23

Running the application­ Emulator

✔ An emulator base on the QEMU project is available✔ The use of the emulator is not recommended

✔ The emulator supports the Neo 1973 only✔ The latest ON2008.x distributions do not support the Neo 

1973✔ To use the emulator anyway:

✔ The MokoMakefile can build and install the emulator automatically

> cd ~/moko> make qemu

Page 24: Getting started with open mobile development on the Openmoko platform

24

Running the application­ Device

✔ Flashing the operating system into the device✔ Two main partitions must be written into internal flash memory

✔ The Linux kernel (kernel)✔ The OS and applications files (rootfs)

✔ Start the phone in flashing mode by holding the option button while pressing the power button

✔ Use “dfu­util” (distributed with OpenEmbedded)✔ “dfu­util ­l“ confirms that the phone is working if listed✔ “dfu­util ­a <partition> ­R ­D <image>” starts flashing

> ./dfu­util ­l> sudo ./dfu­util ­a kernel ­R ­D ./uImage­2.6.24+gitr0­r2.01­om­gta02.bin (takes 1­2 

minutes)> sudo ./dfu­util ­a rootfs ­R ­D ./openMoko­asu­image­om­gta02.jffs2 (takes 10­15 minutes)

Page 25: Getting started with open mobile development on the Openmoko platform

25

Running the application­ Device

✔ Boot Neo FreeRunner by pressing the power button✔ Connect USB connector✔ Activate networking

✔ By default, the usb0 interface is enabled on the FreeRunner at address 192.168.0.202

✔ Use “ifconfig” to enable usb0 interface on host✔ Add “route” to usb0 if host main address is 192.168.0.x

> sudo ifconfig usb0 192.168.0.200 netmask 255.255.255.0> sudo route add ­host 192.168.0.202 dev usb0 (required if host address is in 192.168.0.x 

range)

Page 26: Getting started with open mobile development on the Openmoko platform

26

Running the application­ Device

✔ Transfer application package to device✔ Use Secure copy (scp) to [email protected]

✔ Connect to device✔ Use secure shell (ssh) connection [email protected]

✔ Install application✔ Use opkg package manager to install .ipk files

host> scp *.ipk [email protected]:.host> ssh [email protected] (no password)freerunner> opkg install libglade­2.0­0_2.6.2­r2_arm4t.ipkfreerunner> opkg install openmokocalc_0.1­r0_arm4t.ipkfreerunner> exit

Page 27: Getting started with open mobile development on the Openmoko platform

27

Running the application­ Device

✔ Run application from OM2008.x menu using the installed icon

Page 28: Getting started with open mobile development on the Openmoko platform

28

Packaging a custom distribution

✔ Custom distribution can be generated by using the “local overlay” option from OpenEmbedded

✔ Provides a local structure for custom code and build configurations

✔ Create the following file structure in ~/moko✔ local local/conf local/classes local/packages 

local/packages/images local/packages/tasks

> mkdir local local/conf local/classes local/packages local/packages/images local/packages/tasks ­p

Page 29: Getting started with open mobile development on the Openmoko platform

29

Packaging a custom distribution

✔ Copy the main configuration file into the local overlay✔ from “build/conf/site.conf” to “local/conf/site.conf”

✔ Edit these lines✔ BBFILES := "${OMDIR}/openembedded/packages/*/*.bb $

{OMDIR}/oe/packages/*/*.bb ${OMDIR}/local/packages/*/*.bb"✔ BBFILE_COLLECTIONS = "upstream local overlay"

✔ Add these lines✔ BBFILE_PATTERN_overlay = " ^ ${OMDIR}/local/"✔ BBFILE_PRIORITY_overlay = "20"

> cp build/conf/site.conf local/conf/site.conf> vi local/conf/site.conf

Page 30: Getting started with open mobile development on the Openmoko platform

30

Packaging a custom distribution

✔ Modify “~/moko/setup­env” script to take into account the new local overlay

✔ export BBPATH="${OMDIR}/local:${OMDIR}/build:${OMDIR}/openembedded"

✔ The local overlay will now be taken into account when building packages

> vi ~/moko/setup­env

Page 31: Getting started with open mobile development on the Openmoko platform

31

Packaging a custom distribution

✔ Generate the new build configuration files✔ local/packages/images/example­openmoko­devel­image.bb

require creator­openmoko­image.bbIMAGE_INSTALL += "task­openmoko­debug"

#­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­# OpenMoko Image Recipe#­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­export IMAGE_BASENAME = "${PN}"export IMAGE_LINGUAS = ""export IMAGE_INSTALL = "\${MACHINE_TASK_PROVIDER} \task­openmoko­linux \task­openmoko­net \task­openmoko­ui \task­openmoko­base \task­openmoko­phone \task­openmoko­games \task­openmoko­pim \task­openmoko­example \"inherit imageLICENSE = MITROOTFS_POSTPROCESS_COMMAND += 'date "+%m%d%H%M%Y" >${IMAGE_ROOTFS}/etc/timestamp'

✔ local/packages/images/example­openmoko­image.bb

Page 32: Getting started with open mobile development on the Openmoko platform

32

Packaging a custom distribution

✔ local/packages/tasks/task­openmoko­creator.bb

✔ Start build operation✔ Using the “bitbake” command

DESCRIPTION = "OpenMoko: Example of a custom configuration"SECTION = "openmoko/base"LICENSE = "original"PR = "r0"inherit taskRDEPENDS_task­openmoko­example = "\libglade \openmokocalc \"

> cd ~/moko/build> . ../setup­env> bitbake example­openmoko­devel­image

Page 33: Getting started with open mobile development on the Openmoko platform

33

Adding new hardware components

✔ Different connections are available to extend hardware capabilities:

✔ USB✔ SDIO✔ Bluetooth✔ I2C✔ Serial interfaces

✔ USB port is available outside the case. Other connections would require further modifications

Page 34: Getting started with open mobile development on the Openmoko platform

34

Adding new hardware components­ USB peripherals

✔ Internal USB test points can be used to integrate a USB component

✔ Schematics available from http://openmoko.com

✔ Marked on FreeRunner schematic as H­TP4901, H­TP4902, H­TP4903, H­TP4904

✔ Configuration✔ USB port must be switched from 

device to host mode of operation✔ USB power mode can be selected to 

provide power to the device from the FreeRunner battery

Page 35: Getting started with open mobile development on the Openmoko platform

35

Conclusion

✔ Application development for the Openmoko platform is comparable to desktop development

✔ Many new improvements of the operating system and the available software are expected in the next months

✔ Development tools need to be improved to offer better stability and ease of use

✔ The toolchain should be the way to go for easy software development, but configuration issues make it difficult to use

✔ The OpenEmbedded environment is not practical because of the large disk space and build time requirements

Page 36: Getting started with open mobile development on the Openmoko platform

36

Conclusion

✔ More information at:✔ Openmoko ­ Open. Mobile. Free.

http://wiki.openmoko.org✔ Openmoko developer guide

http://wiki.openmoko.org/wiki/Openmoko_developer_guide✔ OpenEmbedded ­ Cross­compile environment to create a 

complete Linux Distribution for embedded systems.http://wiki.openembedded.net/index.php/Main_Page

Page 37: Getting started with open mobile development on the Openmoko platform

37

THANK YOU