Subject: Re: Embedded development platform
To: Brian Rose <lists@brianrose.net>
From: Berndt Josef Wulf <wulf@ping.net.au>
List: tech-embed
Date: 08/05/2004 08:09:23
On Thu, 5 Aug 2004 05:17, Brian Rose wrote:
> I have some questions for those doing development with the Coldfire 
processors using NetBSD.
> 
> I would like to use NetBSd as an embedded development platform. My plan is 
to be able to compile, download and debug via a P&E BDM connector.
> 
> Right now I need to set up the development tools. Since some of these builds 
can take a while (on my 400MHz box that is hosting this experiment), I wanted 
to make sure I am not doing anything wrong or leaving anything out. Anyway, 
here is my plan.
> 
> 1) Install NetBSD and make sure to get the development tarball.
> 2) Configure the machine as normal to get net access, etc.
> 3) Fetch the sources from the website (src.tgz, gnu.tgz, etc) and install 
to /usr/src
> 4) Patch the gnu compiler with the Coldfire patch available on 
http://www.fiddes.net/coldfire/
> 5) Patch the gnu debugger with the BDM patch on Sourceforge 
(http://sourceforge.net/projects/bdm/)
> 6) Build the toolchain - './build.sh tools'
> 7) Build the tools for the Coldfire (M68K) - './build.sh -m m68k tools'
> 
> Once this is done, I would like to test out my setup by building a small 
application that blinks a few lights on the development board. For now I will 
download using the built in firmware and a terminal program to send the S19 
file via RS232. I will need a makefile that will build the assembly code file 
into a S19 file. The assembly file currently works using Windriver's Diab 
compiler and assembler.
> 
> This is where I need some help. Does anyone have a short makefile that they 
can share with me to help me along? 
> 
> Also if there are any other things I should know about, please let me know.

Hi,

I was in a similar situation when I setup a development environment for TI 
MSP430 processors. There are a few issues that needed to be taken care of 
namely:

1.) build binutils for target
2.) build compiler for target
3.) build libc for target
4.) build debugger for target

Packages were installed into /usr/pkg using --prefix=/usr/pkg with msp430 
specific parts, such as libraries and header files ending up 
into /usr/pkg/msp430/{bin,include/lib}. I created a number of packages 
(pkgsrc) to make things easier.

Binaries installed into the /usr/pkg/bin directory are preceded with msp430 
(don't know which prefix coldfire uses):

husky: {155} ls /usr/pkg/bin/msp430-*
/usr/pkg/bin/msp430-addr2line           /usr/pkg/bin/msp430-ld
/usr/pkg/bin/msp430-ar                  /usr/pkg/bin/msp430-nm
/usr/pkg/bin/msp430-as                  /usr/pkg/bin/msp430-objcopy
/usr/pkg/bin/msp430-c++filt             /usr/pkg/bin/msp430-objdump
/usr/pkg/bin/msp430-cpp                 /usr/pkg/bin/msp430-ranlib
/usr/pkg/bin/msp430-gcc                 /usr/pkg/bin/msp430-readelf
/usr/pkg/bin/msp430-gcc-3.4.0           /usr/pkg/bin/msp430-size
/usr/pkg/bin/msp430-gccbug              /usr/pkg/bin/msp430-strings
/usr/pkg/bin/msp430-gcov                /usr/pkg/bin/msp430-strip

and binaries and files that otherwise would conflict with the native compiler 
installation are installed into /usr/pkg/msp430, e.g.:

husky: {158} ls /usr/pkg/msp430/bin/*
/usr/pkg/msp430/bin/ar                  /usr/pkg/msp430/bin/nm
/usr/pkg/msp430/bin/as                  /usr/pkg/msp430/bin/ranlib
/usr/pkg/msp430/bin/gcc                 /usr/pkg/msp430/bin/strip
/usr/pkg/msp430/bin/ld

Once done, all you need to do is to write an appropriate makefile such as the 
example  below in order to create binaries for the target processor.
You may need to use other options for the coldfire target, but you will get 
the idea:

---------------------------------8<---------------------------------
CPU     = msp430x149
CC      = msp430-gcc
OBJCOPY = msp430-objcopy
OBJDUMP = msp430-objdump
RM      = rm -f

CFLAGS  += -s -mmcu=${CPU} -O2 -Wall -D__MSPGCC__

OBJ     = command.o monitor.o usart.o utilities.o version.o
TARGET  = monitor

${TARGET}: ${OBJ}
        ${CC} ${CFLAGS} -o $@ ${OBJ}
        ${OBJCOPY} -O ihex $@ $@.a43
        ${OBJCOPY} -O srec $@ $@.sre
        ${OBJDUMP} -DS $@ >$@.lst

clean:
        ${RM} ${TARGET} *.a43 *.sre *.lst *.o

---------------------------------8<---------------------------------

Hope this helps,

cheerio Berndt