LPC-P2148

Last week I got my LPC-P2148 ARM7 micro-controller. It’s a pretty nice development board with two serial ports, usb device controller, sd/mmc card slot, AD and DA converters and some other useful stuff.

At the start it was very hard to get it work for me. I’m a total newbie on arm controllers. In school we always had intel processors and programmed them with windows. But now I wanted to program it with Mac OS X so I needed an extra USB/Serial/JTAG adapter. In the starer kit I got an OpenOCD-USB adapter which is totally free under the GPL terms and works perfectly with Mac OS X.


LPC-P2148 Unpacking LPC-P2148 Assembled

To get that setup to work under Mac OS X (10.5.6) you need the following software parts:

Now how to get these things set up:

libusb and libftdi can you easy install with the following commands (execute them inside the corresponding directory):

./configure
make
sudo make install

For openocd you need to add some parameters for configure:

./configure --enable-ft2232_libftdi --enable-usbprog
make
sudo make install

Now we should be able to start openocd from the command with the following output:

oPostBookPro:~ tpost$ openocd
Open On-Chip Debugger 0.1.0 (2009-03-25-18:33) Release
BUGS? Read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS
$URL: https://kc8apf@svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.1.0/src/openocd.c $
Can't find openocd.cfg

So we need to configure openocd to work with the lpc-p2148 board. I use these two configs (openocd-usb.cfg and lpc2148.cfg) for the following openocd.cfg

source [find cfg/openocd-usb.cfg]
source [find cfg/lpc2148.cfg]

These two cfg’s are mostly copied from the configurations shipped with the oepnocd source. I only added a few lines.

#making gdb debugging work
gdb_breakpoint_override hard
gdb_memory_map enable

Now we are able to connect to the controller:

PostBookPro:openocd tpost$ openocd -f openocd.cfg
Open On-Chip Debugger 0.1.0 (2009-03-25-18:33) Release
BUGS? Read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS
$URL: https://kc8apf@svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.1.0/src/openocd.c $
jtag_speed: 5
force hard breakpoints
Info : JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)
Error: JTAG tap: lpc2148.cpu got: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
Error: JTAG tap: lpc2148.cpu expected 1 of 1: 0xffffffff (mfg: 0x7ff, part: 0xffff, ver: 0xf)
Error: trying to validate configured JTAG chain anyway...
Warn : no telnet port specified, using default port 4444
Warn : no gdb port specified, using default port 3333
Warn : no tcl port specified, using default port 6666

(Maybe someone can tell my why I get this error? I ignored it by now and I haven’t had any problems)

How we can see there is now running a telnet server on port 4444 (you can connect to it and take a look at the controller) and a gdb remote debugging daemon on 3333. I use the gdb with an init script. Which was very hard to make. The gdb init script:

#load the main.out for debugging symbols
file main.out
#connect to the remote debugging daemon
target remote localhost:3333
#reset and halt the controller
monitor reset
monitor halt
#set MEMMAP to User Flash Mode
monitor mww 0xE01FC040 0x0001

#finally upload your program image (.bin or .hex) and restart
monitor flash write_image erase /Path/To/Your/Compiled/Program/main.hex ihex
monitor soft_reset_halt
#break main
#continue

Finally we can start the gdb and play around with a program. Be aware that openocd must be started to connect gdb to your controller!

PostBookPro:BlinkAndBeep tpost$ arm-elf-gdb -command=arm-elf-gdb-init.sh
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
...

You can get my first try out project here. Press on B1 and you can see the LED1 and hear a beep on the BUZZER. By pressing B2 the LED2 flashes.

More resources:

I’m very glad that I got through all and my controller is now working perfectly fine under Mac OS X. Once again no Windows needed! I hope I find the time to play a bit around with the controller and post some stuff here soon.

No Comments »

Thomas Post on March 30th 2009 in Stuff, Tweaks with tags:, , , , , , , , ,

Trackback URI | Comments RSS

Leave a Reply