OpenEmbedded: Development

Aus BECOM Systems Support
Zur Navigation springen Zur Suche springen

Building an image

Before you can use BitBake and OpenEmbedded, you have to set some environment variables. Change your working directory to btmxc:

robert@bltLinux:~/oe$ cd btmxc
robert@bltLinux:~/oe/btmxc$ ls
bitbakeenv  conf  oeenv  scripts  tmp

and source the oeenv file (mind the space after the dot):

robert@bltLinux:~/oe/btmxc$ . oeenv
robert@bltLinux:~/oe/btmxc$

If you got your own copy of BitBake and you installed it in oe/bitbake/, you must also source the bitbakeenv file. It will add BitBake's path to your $PATH. (Note that you have to do this step after sourcing oeenv, because oeenv sets the $OEBASE variable.)

robert@bltLinux:~/oe/btmxc$ . bitbakeenv
robert@bltLinux:~/oe/btmxc$

Every time you execute bitbake you should be in this directory. BitBake will generate a subfolder tmp here, where it stores everything!

Now lets build our first image. Note that we use blt-image generically here. You have to use the correct image name for your board according to the list below.

robert@bltLinux:~/oe/btmxc$ bitbake blt-image
NOTE: Handling BitBake files: \ (6638/6638) [100 %]
NOTE: Parsing finished. 6345 cached, 0 parsed, 293 skipped, 0 masked.
NOTE: Cache is clean, not saving.
NOTE: build 200904142114: started
OE Build Configuration:
BB_VERSION = "1.8.12"
METADATA_BRANCH = "stable/2009"
METADATA_REVISION = "13e3e087e4d45555ee29caf09576961db9e5f30e"
TARGET_ARCH = "arm"
TARGET_OS = "linux-gnueabi"
MACHINE = "btmxc31"
DISTRO = "angstrom"
DISTRO_VERSION = "2009.X-test-20090414"
TARGET_FPU = "hard"
NOTE: Resolving any missing task queue dependencies
...

The first compilation of an image will take several hours since BitBake will build everything, starting from the cross tool chain and ending with the root file system.

Afterwards you can find the image ready at

/oe/btmxc/tmp/deploy/glibc/images/[machine]/

Usually, there are two types of image files:

[name][machine].tar.bz2
This is a bzip2-compressed tar-archive containing the complete root file system. Unpack it for mounting via NFS or setting up an SD card.
[name][machine].jffs2
This is a jffs2 image (Journalling Flash File System) you can place in NOR or NAND flash.

Images for Bluetechnix hardware

We provide recipes for one or more demo images in our OpenEmbedded repo for each module. Image recipes are contained in oe/openembedded/recipes/images/.

SBC-i.MX51
sbc-imx51-console-image.bb
sbc-imx51-qtembedded-image.bb
sbc-imx51-gnome-image.bb
CM-i.MX27 with DEV-i.MX27/35
btmxc27-image.bb

(To compile, don't enter the ".bb" suffix, e.g. bitbake sbc-imx51-gnome-image.)

Building and installing a package

Similarly to building an image, you can build a single package or application with OpenEmbedded. For example, to build the mtdutils package, enter

robert@bltLinux:~/oe/btmxc$ bitbake mtdutils

BitBake also offers a "dry-run" option -n. It is useful if you want to check in advance which dependencies must be compiled for your package.

robert@bltLinux:~/oe/btmxc$ bitbake -n mtd-utils

This package is not automatically added to an image, but BitBake generates an .ipk install package. These package files are placed in

oe/btmxc/tmp/deploy/glibc/ipk/[architecture]

You can use find to get all the mtd-utils .ipks, if you don't know what architecture the package has (it is either your machine, something starting with arm, or "all"):

harald@WS-HP4600-35:~/oe/btmxc/tmp/deploy/glibc/ipk$ find . -name "mtd-utils*ipk"
./armv7a/mtd-utils_1.2.0+git-r4.5_armv7a.ipk
./armv7a/mtd-utils-dbg_1.2.0+git-r4.5_armv7a.ipk
./armv7a/mtd-utils-dev_1.2.0+git-r4.5_armv7a.ipk
harald@WS-HP4600-35:~/oe/btmxc/tmp/deploy/glibc/ipk$

Now, if you want to install the package mtd-utils on your target, copy the .ipk file to your i.MX board and enter the following (on the TARGET!):

opkg install mtd-utils_1.2.0+git-r4.5_armv7a.ipk

Cleaning/removing a package

To clean a package with OpenEmbedded, type e.g.

robert@bltLinux:~/oe/btmxc$ bitbake -c clean mtd-utils

This of course works also with image files. If you modify image recipes (e.g., by adding or removing packages), you have to clean and rebuild the image with OpenEmbedded for the changes to take effect in the .tar.bz2 and .jffs files.

If you want to remove a package on the target, i.e. your i.MX board, type e.g. (on the TARGET)

opkg remove mtd-utils

Devshell

The BitBake development shell (devshell) places you inside the source code of a package and sets all environment variables (for compiler, etc.) that BitBake would also set while building the package. It can be useful during development if you want to modify the source code and interrupt BitBake between unpacking the source and compiling the source.

If the package was built before, clean it before starting the devshell. Otherwise BitBake detects that the package was successfully built and refuses to do it again.

harald@WS-HP4600-35:~/oe/btmxc$ bitbake -c clean mtd-utils

To open the devshell for e.g. mtd-utils, type

harald@WS-HP4600-35:~/oe/btmxc$ bitbake -c devshell mtd-utils

A new terminal window will be opened automatically. You can look e.g. at the $CC variable:

harald@WS-HP4600-35:~/imx/oe51/btmxc/tmp/work/armv7a-angstrom-linux-gnueabi/mtd-utils-1.2.0+git-r4/git$ echo $CC
ccache arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp

With some packages, you can also try to directly compile within the devshell, mostly by simply typing make in the appropriate directory.

Troubleshooting

Invalid MD5 sum

If the build fails because of an invalid md5 sum, run the fetch task on the recipe causing this error, then build again. The re-fetch might solve the problem.

harald@WS-HP4600-35:~/oe/btmxc$ bitbake -c fetch [packagename]

Package fails to build

In case a package fails to build, run the clean task on it, then build again. E.g.

bitbake -c clean [packagename]
bitbake failed-image

If the problem persists, you may try disabling concurrent building by editing btmxc/conf/local.conf. PARALLEL_MAKE defines a flag to the compiler GCC and gives the number of parallel make threads. BB_NUMBER_THREADS decides how many threads bitbake will start.

#PARALLEL_MAKE = "-j 4"
PARALLEL_MAKE = "-j 1"
#BB_NUMBER_THREADS = "2"
BB_NUMBER_THREADS = "1"