Openmoko under QEMU on MacOSX
From Openmoko
Warning: this is draft!
I try to put here my notes on setting up OpenMoko environment (Qemu and MokoMakefile) on Mac OS X.
Contents |
Introduction
Some time ago I ask if anyone has ever set up OpenMoko environment on MacOS X. No one has answered that he did but several people were interested. So I deceided to wrote some directions on how to do that.
As for now I was not successful but I am still trying ;)
Setting up environment
Prequisites
Install fink and darwinports (both have neccesary packages).
Follow instructions on: http://www.openembedded.org/wiki/BuildOnOSX to set up OE environment.
It is neccessary to create new disk image, just as BuildOnOSX says.
If you're compiilng something connected with X11 be sure to install X11devel package from your MacOS X CD1.
You can get mentioned packages using darwinports:
sudo port install quilt sudo port install py-psyco sudo port install cogito sudo port install gawk fink install sed
Then get Q[kju] project: http://www.kju-app.org/proj/wiki/CompilingQ into /Volumes/OE/Q but do not compile it yet (run only "prepare the sources"). This will be needed for compiling Neo1973 emulator.
Set up environment as described in MokoMakefile:
cd /Volumes/OE mkdir moko; cd moko wget http://www.rwhitby.net/files/openmoko/Makefile make setup
Making developers image
make openmoko-devel-image
I had problems with bitbake - it does not run correctly with psyco (I got "Illegal instruction error" and make exited with error 132) so I had to disable it: I run bitbake -d openmoko-devel-image in MokoMakefile.
Also, I ended up with:
ERROR: Error in executing: /Volumes/OE/moko/openembedded/packages/quilt/quilt-native_0.45.bb ERROR: Exception:exceptions.UnboundLocalError Message:local variable 'md5data' referenced before assignment
I found out that I did not have md5sum which is used by bitbake. I found it in testutils packages from fink. Installing it did not help... I got pissed and temporarily changed
vim /Volumes/OE/moko/bitbake/lib/bb/fetch/wget.py +114
so it look like this
# supposedly complete.. write out md5sum md5data = "" if bb.which(data.getVar('PATH', d), 'md5sum'): try: md5pipe = os.popen('md5sum ' + dl) md5data = (md5pipe.readline().split() or [ "" ])[0] md5pipe.close() except OSError: md5data = "" # verify the md5sum #if not verify_md5sum(wanted_md5sum, md5data): # raise MD5SumError(uri)
As you can see there I disabled md5sum verification.
(Note: Mac OS X has md5, create a link as follows: ln -s /Volumes/Data/sbin/md5 /usr/bin/md5sum)
If you have error like this
| checking for sed... /usr/bin/sed | checking whether /usr/bin/sed understands (foo|bar)... no | configure: error: | Sorry, you have a version of sed which doesn't understand constructs | of the form (foo|bar). quilt needs it. If you have access to | a version of sed which does understand such constructs, you can supply | its path with the '--with-sed=' option.
Install GNU sed from fink.
Now you should have:
| libbb.h:53:22: error: features.h: No such file or directory
while compiling ipkg. Run following patches in folder:
cd /Volumes/OE/moko/build/tmp/work/i386-darwin/ipkg-native-0.99.163-r1/ipkg-0.99.163/
apply this patch
perl -pi -e 's,struct errlist\*,extern struct errlist\*,g' ipkg.h.in perl -pi -e 's,#include "libbb.h",#include "libbb.h"\nstruct errlist\* error_list;,g' libbb/error_msg.c ### fix endian.h include in md5.c perl -pi -e 's,#include \<endian.h\>,#ifndef __APPLE__\n# include \<endian.h\>\n#else\n# include \<machine/endian.h\>\n#endif,g' md5.c ### fix vfs.h include in ipkg_utils.c perl -pi -e 's,#include \<sys/vfs.h\>,#ifndef __APPLE__\n# include \<sys/vfs.h\>\n#else\n# include \<sys/mount.h\>\n#endif,g' ipkg_utils.c ### remove un-needed features.h include from libbb/libbb.h perl -pi -e 's,#include \<features.h\>,#ifndef __APPLE__\n# include \<features.h\>\n#endif,g' libbb/libbb.h ### dirname already defined OS X perl -pi -e 's,char \*dirname \(char \*path\);,#ifndef __APPLE__\nchar \*dirname \(char \*path\);\n#endif,g' libbb/libbb.h ### Use fink dir for etc perl -pi -e 's,/etc,%p/etc,g' args.h ### Add define for strndup perl -pi -e "s,#include \"xsystem.h\",#include \"xsystem.h\"\n\n#ifndef HAVE_STRNDUP\nstatic void\*\nstrndup \(const char \*src\, size_t n\)\n\{\n size_t i;\n char \*dst;\n\n if \(src == NULL\)\n return NULL;\n\n dst = \(char*\) malloc \(n + 1\);\n if \(dst != NULL\) \{\n for \(i = 0; i \< n \&\& src\[i\]; i++\)\n dst\[i\] = src\[i\];\n dst\[i\] = '\\\0';\n \}\n\n return dst;\n\}\n#endif,g" ipkg_conf.c
Now I get:
| Extracting /Volumes/OE/moko/build/tmp/work/i386-darwin/ipkg-native-0.99.163-r1/ipkg-0.99.163/libbb/.libs/libbb.a | gcc -dynamiclib ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/libipkg.0.0.0.dylib .libs/libipkg_la-args.o .libs/libipkg_la-libipkg.o .libs/libipkg_la-user.o .libs/libipkg_la-ipkg_cmd.o .libs/libipkg_la-ipkg_configure.o .libs/libipkg_la-ipkg_download.o .libs/libipkg_la-ipkg_install.o .libs/libipkg_la-ipkg_upgrade.o .libs/libipkg_la-ipkg_remove.o .libs/libipkg_la-ipkg_conf.o .libs/libipkg_la-ipkg_utils.o .libs/libipkg_la-pkg.o .libs/libipkg_la-pkg_depends.o .libs/libipkg_la-pkg_extract.o .libs/libipkg_la-hash_table.o .libs/libipkg_la-pkg_hash.o .libs/libipkg_la-pkg_parse.o .libs/libipkg_la-pkg_vec.o .libs/libipkg_la-file_util.o .libs/libipkg_la-ipkg_message.o .libs/libipkg_la-md5.o .libs/libipkg_la-sprintf_alloc.o .libs/libipkg_la-str_util.o .libs/libipkg_la-xregex.o .libs/libipkg_la-xsystem.o .libs/libipkg_la-conffile.o .libs/libipkg_la-conffile_list.o .libs/libipkg_la-nv_pair.o .libs/libipkg_la-nv_pair_list.o .libs/libipkg_la-pkg_dest.o .libs/libipkg_la-pkg_dest_list.o .libs/libipkg_la-pkg_src.o .libs/libipkg_la-pkg_src_list.o .libs/libipkg_la-str_list.o .libs/libipkg_la-void_list.o .libs/libipkg.lax/libbb.a/libbb_la-all_read.o .libs/libipkg.lax/libbb.a/libbb_la-ask_confirmation.o .libs/libipkg.lax/libbb.a/libbb_la-concat_path_file.o .libs/libipkg.lax/libbb.a/libbb_la-copy_file.o .libs/libipkg.lax/libbb.a/libbb_la-copy_file_chunk.o .libs/libipkg.lax/libbb.a/libbb_la-error_msg.o .libs/libipkg.lax/libbb.a/libbb_la-error_msg_and_die.o .libs/libipkg.lax/libbb.a/libbb_la-gz_open.o .libs/libipkg.lax/libbb.a/libbb_la-last_char_is.o .libs/libipkg.lax/libbb.a/libbb_la-make_directory.o .libs/libipkg.lax/libbb.a/libbb_la-messages.o .libs/libipkg.lax/libbb.a/libbb_la-mode_string.o .libs/libipkg.lax/libbb.a/libbb_la-parse_mode.o .libs/libipkg.lax/libbb.a/libbb_la-perror_msg.o .libs/libipkg.lax/libbb.a/libbb_la-perror_msg_and_die.o .libs/libipkg.lax/libbb.a/libbb_la-safe_strncpy.o .libs/libipkg.lax/libbb.a/libbb_la-time_string.o .libs/libipkg.lax/libbb.a/libbb_la-unarchive.o .libs/libipkg.lax/libbb.a/libbb_la-unzip.o .libs/libipkg.lax/libbb.a/libbb_la-verror_msg.o .libs/libipkg.lax/libbb.a/libbb_la-vperror_msg.o .libs/libipkg.lax/libbb.a/libbb_la-wfopen.o .libs/libipkg.lax/libbb.a/libbb_la-xfuncs.o .libs/libipkg.lax/libbb.a/libbb_la-xreadlink.o -L/Volumes/OE/moko/build/tmp/staging/i386-darwin/lib -install_name /Volumes/OE/moko/build/tmp/staging/i386-darwin/lib/libipkg.0.dylib -Wl,-compatibility_version -Wl,1 -Wl,-current_version -Wl,1.0 | ld: multiple definitions of symbol _error_list | .libs/libipkg_la-args.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-libipkg.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-user.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_cmd.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_configure.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_download.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_install.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_upgrade.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_remove.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_conf.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_utils.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_depends.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_extract.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-hash_table.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_hash.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_parse.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_vec.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-file_util.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-ipkg_message.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-sprintf_alloc.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-str_util.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-xregex.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-xsystem.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-conffile.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-conffile_list.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-nv_pair.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-nv_pair_list.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_dest.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_dest_list.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_src.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-pkg_src_list.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-str_list.o definition of _error_list in section (__DATA,__common) | .libs/libipkg_la-void_list.o definition of _error_list in section (__DATA,__common) | .libs/libipkg.lax/libbb.a/libbb_la-error_msg.o definition of _error_list in section (__DATA,__common) | /usr/bin/libtool: internal link edit command failed | make[3]: *** [libipkg.la] Error 1 | make[2]: *** [all-recursive] Error 1 | make[1]: *** [all] Error 2 | FATAL: oe_runmake failed NOTE: Task failed: /Volumes/OE/moko/build/tmp/work/i386-darwin/ipkg-native-0.99.163-r1/temp/log.do_compile.16640 NOTE: package ipkg-native-0.99.163-r1: task do_compile: failed ERROR: TaskFailed event exception, aborting NOTE: package ipkg-native-0.99.163: failed ERROR: Build of openmoko-devel-image failed make: *** [openmoko-devel-image] Error 1
Patching qemu-neo1973
The main idea is to get patches for gcc-4.x from Q project and apply it to qemu-neo1973 branch. I'm still working on it.
Building emulator
TODO
Building dfu-util
First install libusb: sudo port install libusb
Get dfu-util: svn co http://svn.openmoko.org/trunk/src/host/dfu-util/
run ./autogen.sh
Then, for some reason, my libusb lib was not detected. I needed to set my paths by hand:
comment out line 18 and 19 in configure ac:
- PKG_CHECK_MODULES(USB, libusb >= 0.1.4,,
- AC_MSG_ERROR([*** Required libusb >= 0.1.4 not installed ***]))
and add libusb libs manually to line 20, so it looks like:
LIBS="$LIBS -L/opt/local/lib -lusb -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -I/opt/local/include"
run ./configure
goto src and:
comment out dfu static because this is not supported on Mac:
dfu_util_static_LDFLAGS = #-static
add lib by hand:
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -I/opt/local/include -L/opt/local/lib -lusb -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -I/opt/local/include
(I know that this is totaly unpure, dirty hack, yet it works).
Run make in src dir. You should have working binary - I don't know if this works on the real phone because I do not have one yet. Can anyone confirm?