Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 486
Octopus Avatar asked May 13 '13 19:05

Octopus


1 Answers

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

  • Quick Start Guide
  • App Developer's Guide
  • Reference Manual

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}
}
like image 56
GrandAdmiral Avatar answered Oct 31 '22 20:10

GrandAdmiral