Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Guido Sohne http://sohne.net

« Newer Snippets
Older Snippets »
1 total  XML / RSS feed 

Building a uClinux toolchain on Mac OS X (10.4.4)

[Article originally posted at http://sohne.net/articles/2006/02/13/building-a-motorola-coldfire-uclinux-toolchain-for-mac-os-x]

GETTING SOURCES

You'll need Bernardo Innocenti's sources available from

http://www.develer.com/uclinux/

It's probably wise to choose the most recent version of his sources, and hope for the best. Stick to the exact version of each source required (e.g. gcc 3.4.0 != gcc 3.4.3). I tried 3.4.3 but it crashed inside xgcc due to my incompetence at patching the sources.


BUILDING YOUR OWN

Your experience may differ from mine. What I do know is that building this takes quite some time and you won't enjoy doing it again and again to fix problems (unless that's your sort of fun!)

Before building, install DarwinPorts and
        sudo port install coreutils
        sudo port install gsed
        
        sudo ln -s /opt/local/bin/gcp /opt/local/bin/cp
        sudo ln -s /opt/local/bin/gnused /opt/local/bin/sed
        
        export PATH=/opt/local/bin:$PATH 
        
        sudo gcc_select 3.3

Start the build process by editing the build-uclinux-tools.sh script as per your needs. I used Apple gcc 3.3 with the following settings in build-uclinux-tools.sh ...
        TARGET=m68k-elf
        PREFIX=/usr/local/m68k-uclinux-tools
        BINUTILSVERS="2.14.90.0.8"
        GCCVERS="3.4.0"
        GDBVERS="6.1"
        BDMVERS="1.3.0"
        UCLIBCVERS="0.9.26"
        ELF2FLTVERS="20040326"
        ROOTDIR="${BASEDIR}/uClinux-dist"
        KERNEL="${ROOTDIR}/linux-2.4.x"

After setting up the build-uclinux-tools.sh script and downloading the necessary additional files and patches, you can do
        cd where-ever-your-buildroot-is
        sh build-uclinux-tools build

and each time you encounter an error (and hopefully fix what's causing it) you can do
        sh build-uclinux-tools continue


BUILD ERRORS (AND SOLUTIONS)

You're going to run into various errors during the build. These steps document how I managed to get past them. There are probably mistakes in them, or at least better ways to do them. Suggestions and improvements are most welcome. It should be easy to make this into a patch. Maybe I'll do that the next time around, but it took so long to build that I wouldn't hold my breath for it.


1) Building elf2flt-20040326

You'll get an error saying "elf.h not found" (it's not present on Darwin systems)
        cp uClibc-0.9.26/include/elf.h elf2flt-20040326

Edit elf2flt-20040326/elf.h and uncomment the #include line. During linking, you'll get an error saying crt0.a not found. Edit Makefile.in, and change
                LDFLAGS = @LDFLAGS@ -static

to
                LDFLAGS = @LDFLAGS@ 

And that should take care of it for you. Continue building via
        sh build-uclinux-tools continue    


2) Building m68k-bdm-1.3.0

This will fail because BDM hardware access hasn't been written for Darwin yet. The ioperm system call is missing, and there's no native driver, so edit build-uclinux.tools.sh and in the stageA function, replace the following lines

        --with-libiberty=${BASEDIR}/${TARGET}-binutils/libiberty/libiberty.a \
        ${PREFIXOPT}

with the lines below

     --with-libiberty=${BASEDIR}/${TARGET}-binutils/libiberty/libiberty.a \
        --disable-ioperm --disable-driver \
        ${PREFIXOPT}

i.e. add --disable-ioperm and --disable-driver to the configure stanza.


3) Building m68k-bdm-1.3.0

This will fail again since its trying to build a static executable. Apparently, that's a no-no on Darwin. Edit Makefile.in and Makefile.am in the utils directory and remove the -static lurking as below:-
        bdmctrl_LDFLAGS = -static

should be changed to
        bdmctrl_LDFLAGS =

You should be still able to connect to a remote server that's running BDM. Since I'm running on a Powerbook, which doesn't even have a parallel port, it's not a big deal to not build the hardware interface bits of BDM. Your mileage may vary. You should be able to continue your build now.


4) Building gdb-6.1

You will receive an error due to an incorrect gdb.texinfo file. Edit gdb-6.1/gdb/doc/gdb.texinfo and around line 6961 (or whatever makeinfo complained about) and change
@strong{Note:} a trace experiment and data collection may stop automatically if any tracepoint's passcount is reached
(@pxref{Tracepoint Passcounts}), or if the trace buffer becomes full.

to become
Note: a trace experiment and data collection may stop automatically if any tracepoint's passcount is reached
(@pxref{Tracepoint Passcounts}), or if the trace buffer becomes full.

After this, you should have a successful build. All the tools will be installed on your system by Bernardo's excellent build script.
« Newer Snippets
Older Snippets »
1 total  XML / RSS feed