Saturday, July 31, 2010

OpenEmbedded under OSX.

So, as a result of getting the little android tablet I mentioned before, I've been playing with OpenEmbedded. Unfortunately (for me), it's not supported (or at least not fully) under OSX - even getting the native tools up and running is painful. There's a *load* of gnu-isms in the source, which break strict POSIX compliance, and frankly make it a massive pain to get stuff working.

Much of this can be got around by using precompiled stuff (either pulled from one of the OSX package repositories, fink etc, or, in my case, compiled manually), and then explicitly removed from the OE build system using ASSUME_PROVIDED.

This doesn't fix a few overall issues, though, much of which comes from OE assuming it's built on a system that uses ELF as its binary format.

A large part of this can be fixed with one patch, which I've attached here. $OEBASE/$CHECKOUT/classes/relocatable.bbclass tries to fix up the rpath in any binaries having it, but simply assumes all binaries are ELF format. Obviously, this crashes and burns horribly under OSX, where the runtime format for native binaries is Mach-O. Patch below, apply from $OEBASE/$CHECKOUT with patch -p1

diff --git a/classes/relocatable.bbclass b/classes/relocatable.bbclass
index 2af3a7a..3a4c119 100644
--- a/classes/relocatable.bbclass
+++ b/classes/relocatable.bbclass
@@ -3,6 +3,19 @@ SYSROOT_PREPROCESS_FUNCS += "relocatable_binaries_preprocess"
CHRPATH_BIN ?= "chrpath"

+def is_elf_file (fullpath):
+ import subprocess as sub
+ p = sub.Popen(['file', '-b', fullpath],stdout=sub.PIPE,stderr=sub.PIPE)
+ err, out = p.communicate()
+ if p.returncode != 0:
+ return 0
+ if out.startswith('ELF'):
+ return 1
+ else:
+ return 0
def process_dir (directory, d):
import subprocess as sub
import stat
@@ -24,7 +37,8 @@ def process_dir (directory, d):

if os.path.isdir(fpath):
process_dir(fpath, d)
- else:
+ if is_elf_file(fpath) == 1:
+ # only try to relocate ELF files
#bb.note("Testing %s for relocatability" % fpath)

# We need read and write permissions for chrpath, if we don't have
@@ -85,7 +99,7 @@ def rpath_replace (path, d):
bindirs ="${bindir} ${sbindir} ${base_sbindir} ${base_bindir} ${libdir} ${base_libdir} ${PREPROCESS_RELOCATE_DIRS}", d).split()

for bindir in bindirs:
- #bb.note ("Processing directory " + bindir)
+ bb.note ("Processing directory " + bindir)
directory = path + "/" + bindir
process_dir (directory, d)

I'll post more in a little while, including full instructions on getting oe up and running under OSX, but I'm off on holiday for a week.

1 comment:

  1. Hi.
    Did you get anywhere with an open source programmer for the STM8S Discovery ? I had a look at the USB data but couldn't figure out enough to make it work properly.

    I'm considering bypassing it and programming the board using the SWIM interface directly (which is documented), probably using an Arduino board as a programmer.