User:SNMoore
From Openmoko
Mac OS X Recipe 1: Install MacPorts
Install MacPorts
See http://trac.macosforge.org/projects/macports/wiki/InstallingMacPorts
Install X11 before Xcode Tools; that way the X11 SDK will be automatically selected when installing Xcode Tools
Install all the GCC variants when installing Xcode Tools
- Customize > Cross Development > all
Verify shell environment
Finder > Applications > Utilities > Terminal.app
$ cat ~/.profile # Your previous .profile (if any) is saved as .profile.mpsaved # Setting the path for MacPorts. export PATH=/opt/local/bin:/opt/local/sbin:$PATH export DISPLAY=:0.0
Verify gcc & make
Finder > Applications > Utilities > Terminal.app
$ gcc_select --list Available compiler versions: 3.3 3.3-fast 4.0
$ which gcc make /usr/bin/gcc /usr/bin/make
$ gcc --version i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367) Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ make --version GNU Make 3.80 Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Update MacPorts
Finder > Applications > Utilities > Terminal.app
$ sudo port selfupdate MacPorts base version 1.5 installed Downloaded MacPorts base version 1.5 The MacPorts installation is not outdated and so was not updated selfupdate done!
Mac OS X Recipe 2: Build & Install dfu-util
Install Pre-Requisites: Subversion
Finder > Applications > Utilities > Terminal.app
$ sudo port install subversion ---> Installing apr 1.2.9_0 ---> Installing db44 4.4.20_1+darwin_8 ---> Installing expat 2.0.1_0 ---> Installing libiconv 1.11_4+darwin_8 ---> Installing ncursesw 5.6_0+darwin_8 ---> Installing ncurses 5.6_0+darwin_8 ---> Installing readline 5.2.001_0 ---> Installing sqlite3 3.4.1_0+darwin_8 ---> Installing apr-util 1.2.8_2 ---> Installing gettext 0.16.1_0 ---> Installing zlib 1.2.3_1 ---> Installing openssl 0.9.8e_0+darwin_8 ---> Installing neon 0.26.3_1 ---> Installing subversion 1.4.4_0
$ which svn /opt/local/bin/svn
$ svn --version svn, version 1.4.4 (r25188) compiled Aug 4 2007, 17:32:39 Copyright (C) 2000-2006 CollabNet. Subversion is open source software, see http://subversion.tigris.org/ This product includes software developed by CollabNet (http://www.Collab.Net/). The following repository access (RA) modules are available: * ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol. - handles 'http' scheme - handles 'https' scheme * ra_svn : Module for accessing a repository using the svn network protocol. - handles 'svn' scheme * ra_local : Module for accessing a repository on local disk. - handles 'file' scheme
Install Pre-Requisites: autoconf & automake
Finder > Applications > Utilities > Terminal.app
$ sudo port install autoconf automake ---> Installing perl5.8 5.8.8_0+darwin_8 ---> Installing p5-locale-gettext 1.05_0 ---> Installing help2man 1.36.4_0+darwin_8 ---> Installing libtool 1.5.24_0 ---> Installing m4 1.4.9_0 ---> Installing autoconf 2.61_1 ---> Installing automake 1.10_0
$ which autoconf automake /opt/local/bin/autoconf /opt/local/bin/automake
$ autoconf --version autoconf (GNU Autoconf) 2.61 Copyright (C) 2006 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. Written by David J. MacKenzie and Akim Demaille.
$ automake --version automake (GNU automake) 1.10 Written by Tom Tromey <tromey@redhat.com> and Alexandre Duret-Lutz <adl@gnu.org>. Copyright 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Install Pre-Requisites: pkg-config
Finder > Applications > Utilities > Terminal.app
$ sudo port install pkgconfig ---> Installing pkgconfig 0.22_0
$ which pkg-config /opt/local/bin/pkg-config
$ pkg-config --version 0.22
Install Pre-Requisites: libusb
Finder > Applications > Utilities > Terminal.app
$ sudo port install libusb ---> Installing libusb 0.1.12_0
Verify Existing Pre-Requisites: gcc & make
Finder > Applications > Utilities > Terminal.app
$ which gcc make /usr/bin/gcc /usr/bin/make
$ gcc --version i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367) Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ make --version GNU Make 3.80 Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Get the dfu-util source code using Subversion
Finder > Applications > Utilities > Terminal.app
$ mkdir -p /Volumes/OE/workspace/tools $ cd /Volumes/OE/workspace/tools
$ svn checkout http://svn.openmoko.org/trunk/src/host/dfu-util/ A dfu-util/m4 A dfu-util/configure.ac A dfu-util/src A dfu-util/src/dfu.c A dfu-util/src/commands.c A dfu-util/src/dfu.h A dfu-util/src/main.c A dfu-util/src/commands.h A dfu-util/src/sam7dfu.c A dfu-util/src/Makefile.am A dfu-util/src/sam7dfu.h A dfu-util/src/usb_dfu.h A dfu-util/COPYING A dfu-util/Makefile.am A dfu-util/autogen.sh Checked out revision 2648.
Configure dfu-util, installing into the MacPorts /opt/local tree
Finder > Applications > Utilities > Terminal.app
$ cd /Volumes/OE/workspace/tools/dfu-util
$ ./autogen.sh $ ./configure --prefix=/opt/local
Use a dirty little hack to avoid the static build of dfu-util
Finder > Applications > Utilities > Terminal.app
$ cd /Volumes/OE/workspace/tools/dfu-util
$ sed -i.bak '/bin_PROGRAMS =/ s/dfu-util_static.*$//g' src/Makefile
Patch to work around NULL dev->config structures on OS X (Bug #672)
Either get the patch content out of Bug #672, or use one I created: http://www.snmoore.net/openmoko/patches/dfu-util-osx_null_config.patch
Finder > Applications > Utilities > Terminal.app
$ cd /Volumes/OE/workspace/tools/dfu-util
$ wget http://www.snmoore.net/openmoko/patches/dfu-util-osx_null_config.patch $ patch -p0 < dfu-util-osx_null_config.patch
Patch to work around byteswap.h and endian.h errors on OS X
Index: src/main.c =================================================================== --- src/main.c (revision 3079) +++ src/main.c (working copy) @@ -26,9 +26,35 @@ #include <getopt.h> #include <usb.h> #include <errno.h> -#include <byteswap.h> -#include <endian.h> + +// #include <byteswap.h> + +#ifndef _BYTESWAP_H +#define _BYTESWAP_H + +//#warning "byteswap.h is an unportable GNU extension! Don't use!" + +static inline unsigned short bswap_16(unsigned short x) { + return (x>>8) | (x<<8); +} + +static inline unsigned int bswap_32(unsigned int x) { + return (bswap_16(x&0xffff)<<16) | (bswap_16(x>>16)); +} + +static inline unsigned long long bswap_64(unsigned long long x) { + return (((unsigned long long)bswap_32(x&0xffffffffull))<<32) | +(bswap_32(x>>32)); +} + +#endif + + + + +#include <machine/endian.h> + #include "dfu.h" #include "usb_dfu.h" #include "sam7dfu.h"
Build and Install dfu-util
Finder > Applications > Utilities > Terminal.app
$ cd /Volumes/OE/workspace/tools/dfu-util
$ make $ sudo make install
$ which dfu-util /opt/local/bin/dfu-util
$ dfu-util --version dfu-util - (C) 2007 by OpenMoko Inc. This program is Free Software and has ABSOLUTELY NO WARRANTY You need to specify one of -D or -U Usage: dfu-util [options] ... -h --help Print this help message -V --version Print the version number -l --list List the currently attached DFU capable USB devices -d --device vendor:product Specify Vendor/Product ID of DFU device -c --cfg config_nr Specify the Configuration of DFU device -i --intf intf_nr Specify the DFU Interface number -a --alt alt Specify the Altsetting of the DFU Interface by name or by number -t --transfer-size Specify the number of bytes per USB Transfer -U --upload file Read firmware from device into <file> -D --download file Write firmware from <file> into device -R --reset Issue USB Reset signalling once we're finished
Mac OS X Recipe 3: Use dfu-util to flash the firmware
WARNING: this works ok for me and my Neo, but try this at your own risk
Note that I found it was usually necessary to disconnect and reconnect the USB cable each time I ran dfu-util, sometimes waiting a few seconds
Get the Latest Openmoko Firmware
The two images listed here are just examples; pick appropriate ones, see Flashing_openmoko
Finder > Applications > Utilities > Terminal.app
$ mkdir -p /Volumes/OE/workspace/images $ cd /Volumes/OE/workspace/images
$ wget http://buildhost.openmoko.org/tmp/deploy/images/uImage-2.6.21.6-moko11-r1_0_0_2388_0-fic-gta01.bin $ wget http://buildhost.openmoko.org/tmp/deploy/images/openmoko-devel-image-fic-gta01-20070803091138.rootfs.jffs2
Boot the Neo1973 Into uBoot Mode
Hold the Alt button whilst pressing the Power button
Verify the DFU Interface
Disconnect & reconnect the USB cable
Finder > Applications > Utilities > Terminal.app
$ dfu-util --list dfu-util - (C) 2007 by OpenMoko Inc. This program is Free Software and has ABSOLUTELY NO WARRANTY Found Runtime: [0x1457:0x5119] devnum=0, cfg=0, intf=2, alt=0, name="USB Device Firmware Upgrade" Found Runtime: [0x05ac:0x8205] devnum=0, cfg=0, intf=2, alt=0, name="UNDEFINED"
Note that the 0x1457:0x5119 device is my Neo, the other is (I think) the Bluetooth adapter on my MacBook Pro
Flash the Kernel
Disconnect & reconnect the USB cable
Finder > Applications > Utilities > Terminal.app
$ cd /Volumes/OE/workspace/images
$ sudo dfu-util -d 0x1457:0x5119 -a 3 -R -D ./uImage-2.6.21.6-moko11-r1_0_0_2388_0-fic-gta01.bin dfu-util - (C) 2007 by OpenMoko Inc. This program is Free Software and has ABSOLUTELY NO WARRANTY Opening USB Device 0x1457:0x5119... Found Runtime: [0x1457:0x5119] devnum=0, cfg=0, intf=0, alt=3, name="kernel" Claiming USB DFU Interface... Setting Alternate Setting ... Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing Transfer Size = 0x1000 bytes_per_hash=31814 Starting download: [##################################################] finished! state(2) = dfuIDLE, status(0) = No error condition is present Done! Resetting USB to switch back to runtime mode
Flash the Root Filesystem
Disconnect & reconnect the USB cable
Finder > Applications > Utilities > Terminal.app
$ cd /Volumes/OE/workspace/images
$ sudo dfu-util -d 0x1457:0x5119 -a 5 -R -D ./openmoko-devel-image-fic-gta01-20070803091138.rootfs.jffs2 dfu-util - (C) 2007 by OpenMoko Inc. This program is Free Software and has ABSOLUTELY NO WARRANTY Opening USB Device 0x1457:0x5119... Found Runtime: [0x1457:0x5119] devnum=0, cfg=0, intf=0, alt=5, name="rootfs" Claiming USB DFU Interface... Setting Alternate Setting ... Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing Transfer Size = 0x1000 bytes_per_hash=644874 Starting download: [##################################################] finished! state(2) = dfuIDLE, status(0) = No error condition is present Done! Resetting USB to switch back to runtime mode
Boot the Neo1973 Normally
Just press the Power button