<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.V1ru8.net &#187; lpc-p2148</title>
	<atom:link href="http://blog.v1ru8.net/tag/lpc-p2148/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.v1ru8.net</link>
	<description></description>
	<lastBuildDate>Mon, 28 Sep 2009 15:55:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>LPC-P2148</title>
		<link>http://blog.v1ru8.net/2009/03/30/lpc-p2148/</link>
		<comments>http://blog.v1ru8.net/2009/03/30/lpc-p2148/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 20:10:50 +0000</pubDate>
		<dc:creator>Thomas Post</dc:creator>
				<category><![CDATA[Stuff]]></category>
		<category><![CDATA[Tweaks]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[arm7]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[lpc-p2148]]></category>
		<category><![CDATA[lpc2148]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[olimex]]></category>
		<category><![CDATA[openocd]]></category>

		<guid isPermaLink="false">http://blog.v1ru8.net/?p=255</guid>
		<description><![CDATA[Last week I got my LPC-P2148 ARM7 micro-controller. It&#8217;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&#8217;m a total newbie on arm controllers. In school [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I got my LPC-P2148 ARM7 micro-controller. It&#8217;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.
<p>At the start it was very hard to get it work for me. I&#8217;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.</p>
<p><center><br />
<table>
<tr>
<td> <a href="http://img.skitch.com/20090330-re7c4ysjf8p6kd5tfnsm68s2ij.jpg" rel="lightbox[groupname]" title="New LPC-P2148"><img src="http://img.skitch.com/20090330-re7c4ysjf8p6kd5tfnsm68s2ij.preview.png" width="200" height="150" alt="LPC-P2148 Unpacking" /></a></td>
<td>
<a href="http://img.skitch.com/20090330-chmfxkirrayrhi2c2d8q961wgy.jpg" rel="lightbox[groupname]" title="Assembled LPC-P2148"><img src="http://img.skitch.com/20090330-chmfxkirrayrhi2c2d8q961wgy.preview.png" width="200" height="150" alt="LPC-P2148 Assembled" /></a></td>
</tr>
</table>
<p></center></p>
<p>To get that setup to work under Mac OS X (10.5.6) you need the following software parts:</p>
<ul>
<li>OpenOCD
<ul>
<li><a href="http://libusb.wiki.sourceforge.net/">libusb-1.0.0</a></li>
<li><a href="http://www.intra2net.com/en/developer/libftdi/download.php">libftdi-0.15</a></li>
<li><a href="http://developer.berlios.de/project/showfiles.php?group_id=4148">openocd-0.1.0</a></li>
</ul>
</li>
<li><a href="http://embdev.net/articles/ARM_GCC_toolchain_for_Linux_and_Mac_OS_X">ARM-ELF-GCC</a> (Download the compiler and follow the instructions under &#8220;Installation&#8221;)</li>
<li>Of corse you need the apple developer tools installed for make and some other useful tools <img src='http://blog.v1ru8.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ul>
<p><strong>Now how to get these things set up:</strong><br />
<span id="more-255"></span></p>
<p><em>libusb</em> and <em>libftdi</em> can you easy install with the following commands (execute them inside the corresponding directory):</p>
<p><code>./configure<br />
make<br />
sudo make install<br />
</code> </p>
<p>For openocd you need to add some parameters for <em>configure</em>:</p>
<p><code>./configure --enable-ft2232_libftdi --enable-usbprog<br />
make<br />
sudo make install<br />
</code></p>
<p>Now we should be able to start <em>openocd</em> from the command with the following output:</p>
<p><code>oPostBookPro:~ tpost$ openocd<br />
Open On-Chip Debugger 0.1.0 (2009-03-25-18:33) Release<br />
BUGS? Read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS<br />
$URL: https://kc8apf@svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.1.0/src/openocd.c $<br />
Can't find openocd.cfg<br />
</code></p>
<p>So we need to configure openocd to work with the lpc-p2148 board. I use these two configs (<a href="http://files.v1ru8.net/openocd/openocd-usb.cfg">openocd-usb.cfg</a> and <a href="http://files.v1ru8.net/openocd/lpc2148.cfg">lpc2148.cfg</a>) for the following openocd.cfg</p>
<p><code>source [find cfg/openocd-usb.cfg]<br />
source [find cfg/lpc2148.cfg]<br />
</code></p>
<p>These two cfg&#8217;s are mostly copied from the configurations shipped with the oepnocd source. I only added a few lines.</p>
<p><code>#making gdb debugging work<br />
gdb_breakpoint_override hard<br />
gdb_memory_map enable</code></p>
<p>Now we are able to connect to the controller:</p>
<p><code>PostBookPro:openocd tpost$ openocd -f openocd.cfg<br />
Open On-Chip Debugger 0.1.0 (2009-03-25-18:33) Release<br />
BUGS? Read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS<br />
$URL: https://kc8apf@svn.berlios.de/svnroot/repos/openocd/tags/openocd-0.1.0/src/openocd.c $<br />
jtag_speed: 5<br />
force hard breakpoints<br />
Info : JTAG tap: lpc2148.cpu tap/device found: 0x4f1f0f0f (Manufacturer: 0x787, Part: 0xf1f0, Version: 0x4)<br />
Error: JTAG tap: lpc2148.cpu             got: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)<br />
Error: JTAG tap: lpc2148.cpu expected 1 of 1: 0xffffffff (mfg: 0x7ff, part: 0xffff, ver: 0xf)<br />
Error: trying to validate configured JTAG chain anyway...<br />
Warn : no telnet port specified, using default port 4444<br />
Warn : no gdb port specified, using default port 3333<br />
Warn : no tcl port specified, using default port 6666<br />
</code>
<p>(Maybe someone can tell my why I get this error? I ignored it by now and I haven&#8217;t had any problems)</p>
</p>
<p>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:</p>
<p><code>#load the main.out for debugging symbols<br />
file main.out<br />
#connect to the remote debugging daemon<br />
target remote localhost:3333<br />
#reset and halt the controller<br />
monitor reset<br />
monitor halt<br />
#set MEMMAP to User Flash Mode<br />
monitor mww 0xE01FC040 0x0001</p>
<p>#finally upload your program image (.bin or .hex) and restart<br />
monitor flash write_image erase /Path/To/Your/Compiled/Program/main.hex ihex<br />
monitor soft_reset_halt<br />
#break main<br />
#continue</code></p>
<p>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!</p>
<p><code>PostBookPro:BlinkAndBeep tpost$ arm-elf-gdb -command=arm-elf-gdb-init.sh<br />
GNU gdb 6.4<br />
Copyright 2005 Free Software Foundation, Inc.<br />
...</code></p>
<p>You can get my first try out project <a href="http://files.v1ru8.net/openocd/BlinkAndBeep.zip">here</a>. Press on B1 and you can see the LED1 and hear a beep on the BUZZER. By pressing B2 the LED2 flashes.</p>
<p>More resources:</p>
<ul>
<li><a href="http://www.olimex.com/dev/images/ARM/LPC/LPC-P2148-REV-D-sch.gif">Schema</a></li>
<li><a href="http://files.v1ru8.net/openocd/lpc2141_42_44_46_48.pdf">Controller Manual</a></li>
</ul>
<p>I&#8217;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.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.v1ru8.net/2009/03/30/lpc-p2148/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

