Bringing up the LPC-P212x

This page logs the tools and resources I had to pull together and install to be able to compile and load my own code on the LPC.  I found that the resources on the internet where hard to find known good versions.  It took more time than I thought it should.

The components of the development tool set include:
I found that gathering the current versions of these bits somewhat a pain in the butt so I'm logging what I learned here.

GnuARM tool chain:

You need the arm-elf tool chain to build for the LPC target.  Get your tool chain from http://www.gnuarm.org/ .  I had trouble building the newer tool chain for my Ubuntu 6.6 x86_64 host so I just installed the pre-compiled bits from http://www.gnuarm.org/bu-2.16.1_gcc-4.0.2-c-c++_nl-1.14.0_gi-6.4_x86-64.tar.bz2 . I untar-ed it into ~/bin/gnuarm-4.0.2 and updated my ~/.bash_profile file to include ~/bin/gnuarm-4.0.2/bin in my path.

Initial attempts to build the tool chain under x86_64 Ubuntu failed and attempts on i386 Ubuntu had problems with the gcc compile.  After google'ing I found some tips and the following is the script I have used to succesfully build my tool chain.  Note: the latest compiler and nelib versions failed to build hex files that would work as expected with the newlib-lpc rel 5a, so I'm running the 4.1.1 compiler now.
#!/bin/bash

PREFIX=/usr/local/lpc4.1.1
DIR=`pwd`

rm -rf $PREFIX
mkdir $PREFIX
cd $PREFIX
tar -xvf $DIR/newlib-1.14.0.tar.gz
mkdir $PREFIX/info
mkdir $PREFIX/info/dir
mkdir $PREFIX/info/dir/dir

export PATH=$PATH:$PREFIX/bin

cd $DIR/binutils
rm -rf *

$DIR/binutils-2.17/configure --target=arm-elf --prefix=$PREFIX --enable-interwork --enable-multilib --with-float=soft --enable-languages="c,c++"
make -j2
make install

cd $DIR/gcc
rm -rf *
$DIR/gcc-4.1.1/configure --target=arm-elf --prefix=$PREFIX --enable-interwork --enable-multilib --with-float=soft --enable-languages="c,c++"
make -j2
make install

cd $DIR/newlib
rm -rf *
$PREFIX/newlib-1.14.0/configure --target=arm-elf --prefix=$PREFIX --enable-interwork --enable-multilib --with-float=soft
make -j2
make install

cd $DIR/gcc2
rm -rf *
$DIR/gcc-4.1.1/configure --target=arm-elf --prefix=$PREFIX --enable-interwork --enable-multilib --with-float=soft --enable-languages="c,c++" --with-newlib --with-headers=$PREFIX/newlib-1.14.0/newlib/libc/include
make -j2
make install

cd $DIR/gdb
rm -rf *
$DIR/gdb-6.6/configure --target=arm-elf --prefix=$PREFIX --enable-interwork --enable-multilib --with-float=soft
make -j2
make install

cd $DIR/insight
rm -rf *
$DIR/insight-6.6/configure --target=arm-elf --prefix=$PREFIX --enable-interwork --enable-multilib --with-float=soft
make -j2
make install


Newlib-lpc:

NewLib is an open source libc for embedded / non-OS runtime environments such as my while (1) loop.  Its a left over from RedHats Cygnus purchase and is community maintained at this time.  Get your copy of newlib from http://www.gnuarm.org/files.html.  You need this for the tool chain (unless your using the pre-built ones) but to build an executable that will load on the LPC you still need the newlib-lpc bits.  http://www.aeolusdevelopment.com/Articles/download.html has the newlib port layer you need for using newlib with your LPC.  Today I am using http://www.aeolusdevelopment.com/Files/newlib-lpc_rel_5a.zip, with some success.  It is released by AEOLUS Development under a BSD styled license.

The way I'm using it is to include the files of the newlib-lpc port layer within the build directory of my program.  (I'm just hacking the example's within the new lpc-newlib directory.  One of these days I'll figure out how to put the port layer within the tool chain properly, but that is not high on my list of things to do today.)  Note within the sample programs there a few items you will want to change.  To have the baud rate work correctly for the OLiMEX P212x board you need to change the SetNativeSpeed(10000uL) to SetNativeSpeed(14745uL).  lpc-newlib.tar.bz2 has my tweaks to the original code.  Just type make, to produce the *.hex files needed to load the P212x.

lpc21isp

This took me a while to get the right version.  There are a number of versions out on the network that may or may not work for you.  I thrashed about for a while before I found the version that worked for me is maintained within a yahoo group site for the lpc21isp.  Its not an OSS licensed module but its available in source form and works ok for me.  I'm using lsp21isp_148.zip posted to the lpc21isp yahoo group on April 20, 2007.  Join the Yahoo group http://tech.groups.yahoo.com/group/lpc21isp/ and get your copy.

Command line for uploading test10.hex from newlip-lpc test:
  lpc21isp -term test10.hex /dev/ttyUSB0 38400 14746
You can play with the baud rate.  I chose the same baud rate I wedged into the test10.c file so that the -term option would provide readable output.  The 14746 parameter is the speed of the crystal oscillator on the OLiMEX development board.

Working with the NXP (Phillips) ISP

To use the built in boot loader on the LPC you need to pull the pin 0.14 low at reset time for ~4ms to get into the ISP boot loader mode.  Once in this mode you don't need to hold pin0.14 low.  the LPC-P212x board has a pull up on the pin and I have a reset switch from an old PC case connected to the jumpers.  BTW the jumper is labeled BSL on the OLiMEX board, and I'm jumpering the BSL with the pin next to it in the plane of the serial connectors.

BTW there are 2 serial connectors on the P212x.  Use the one closest to the BSL pin, and don't use any null modem hardware.

At this point you should be able to compile and load your own code on the LPC-P212x from your Linux host environment.

Open-OCD JTAG:

I have gotten initial signs of life on working with the LPC and the wiggler styled JTAG.  I'm still new to using the JTAG but this is what I've done so far to get something working:
I'm just getting started on GDB, but I do get register data that "looks" like it could be correct...

JTAG GDB Insight debug tools

As I learn enough to get around I'll add more.