Octopus
Octopus

Reputation: 8325

How do I use bitbake to cross compile this simple program for beagleboard?

I am trying to understand how I compile programs that will run on my beagle board. I need to compile some complex programs that I currently run in fedora, but understanding how to use Open Embedded and BitBake has proved troublesome. I think there have been some significant changes to openembedded recently and the directory structure of my OE installation doesn't even match what I am finding elsewhere online as far as tutorials and how-tos go.

I followed the directions here for setting up OE-Core, which gave me the following directory structure:

[user@localhost ~]$ ls oe-core -al
total 52
drwxr-xr-x   9 user user 4096 May 13 13:31 .
drwx------. 31 user user 4096 May 13 12:56 ..
drwxr-xr-x   9 user user 4096 May 10 11:52 bitbake
drwxrwxr-x   8 user user 4096 May 13 13:36 build
drwxr-xr-x   8 user user 4096 May 13 13:33 .git
-rw-r--r--   1 user user  165 May 10 11:51 .gitignore
-rw-r--r--   1 user user  545 May 10 11:51 LICENSE
drwxr-xr-x  21 user user 4096 May 10 11:51 meta
drwxr-xr-x   4 user user 4096 May 10 11:51 meta-hob
drwxr-xr-x   6 user user 4096 May 10 11:51 meta-skeleton
-rwxr-xr-x   1 user user 1592 May 10 11:51 oe-init-build-env
-rw-r--r--   1 user user  495 May 10 11:51 README
drwxr-xr-x   8 user user 4096 May 10 11:51 scripts

I've tried to boil it down to an ultra-simplistic start. If I can figure out how to BitBake this simple program I would be leaps and bounds ahead of where I currently am.

#include <stdio.h>

void main(int argc, char* argv[]) {
    printf("Hello World.\r\n");
}

I'm finding that the OpenEmbedded website is too immature to be of any use. For example, I found this page which doesn't tell me which files should contain the contents shown and has nothing more than 'TODO' marked in some of the sections.

So if anybody has experience using BitBake, some pointers on how to cross-compile my simple program would be really helpful. Where do my recipe files go? How do I invoke them with bitbake? Thanks.

Upvotes: 6

Views: 12888

Answers (2)

GrandAdmiral
GrandAdmiral

Reputation: 1408

I've found the Yocto Project documentation to be more current than the OpenEmbedded documentation. In particular, I would recommend:

I recently created a simple recipe to test something out, and it might help you. I put the recipe in my own meta layer. In your example, the new meta layer would be in the oe-core directory (next to meta, meta-skeleton, etc.). Set up the meta layer like the others. The recipe's directory structure looks like this:

$ ls -al uinput-test/
drwxrwxr-x 2 me me 4096 Apr 24 09:45 files
-rwxr--r-- 1 me me  321 Apr 24 11:33 uinput-test_1.0.bb

The source code (uinput.c) is in the files directory. The recipe then looks like this:

DESCRIPTION = "uinput test"
PR = "r0"
LICENSE = "CLOSED"
RM_WORK_EXCLUDE += "uinput-test"

SRC_URI = "file://uinput.c \
          "
do_compile() {
    ${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/uinput.c -o uinput-test
}

do_install() {
    install -m 0755 -d ${D}${bindir}
    install -m 0755 ${S}/uinput-test ${D}${bindir}
}

Upvotes: 6

FooF
FooF

Reputation: 4482

I think checking out the activity around Linux Foundation's Yocto project might help for this kind of undertakings. The Wikpedia page for Open Embedded says this:

The OpenEmbedded-Core Project (OE-Core for short) resulted from the merge of the Yocto Project with OpenEmbedded.[7] This is the most recent version of OpenEmbedded and many of the OE-dev recipes are available in OE-Core. Newer versions of package recipes may only get ported for OpenEmbedded-Core.

It seems OpenEmbedded (or what became OpenEmbedded-core) underwent quite a restructuring, which maybe explains why things do not quite match with older documentation.

The Yocto project documentation seems much more comprehensive and up-to-date. The Yocto project also appears more active. It is backed-up by big corporations (including Intel, TI, etc), and it seems the quality control has seen investment. These to me seems like good reasons to get familiar with Yocto Project even if still want to just stick with OpenEmbedded-core. Based on my memory from years ago, it seems the scope of the OpenEmbedded-core is much limited than it used to be.

For more complicated application development, you probably benefit from learning about and using different OE/Yocto layers.

Anyway, what specifically comes to Beagle Board, Yocto project includes board support layer for that; Texas Instruments is member of Yocto Project (see Yocto Project member list). If you want to build apps for Beagle Board, I would imagine meta-beagle layer and/or meta-ti layers to be useful. You can see the important public OE/Yocto layers listed here:

Upvotes: 0

Related Questions