Programming the LPC2148 from scratch

I have just jumped from the world of AVR’s into the world of ARM, have an Uber Board on the way to help me develop a project I am working on.

I am also designing the schematic/pcb for the project I am working on, which will use an LPC2148 and a modified version of the Sparkfun USB bootloader.

What I am struggling to get my head around is how to initially program the LPC with the bootloader, without using the 2x10pin huge JTAG interface.

As this board needs to be as small as possible I can’t afford to break out a huge JTAG connector.

After looking over some of the other SFE products that use the LPC2148, like the logo and the mp3 board, it seems they both break out a 6 pin header for use with I assume this: http://www.sparkfun.com/commerce/produc … cts_id=714

By “LPC Serial Port Boot Loader Interface”, does that mean I can just use a bootloader to load flash, or can I use it to actually program in a bootloader?

So, how do SFE load up their bootloader in the first place?? Any ideas??

The LPC2000 chips have an on-chip bootloader from the factory that you use over your PC’s COM port in conjunction with the LPC2000 Flash Utility (the version I use is 2.2.3). If you look at the schematic for Olimex’s LPC-P2148 board, you’ll see that you’ll need to hook up P0.14, RX0, TX0, and (optionally) RESET on the LPC2148 to your serial port (through level-shifting circuitry).

Thanks Brennen. :wink:

So can this factory bootloader be used to upload a new (the SFE USB for example) bootloader onto the LPC?

My first thought is no, a bootloader can not overwrite itself while its running. Yet this serial header is the only programming header on the Logomatic and MP3 Dev board, which SFE somehow get their USB bootloader onto.

The on-board bootloader can load any code you want into the internal FLASH memory of the LPC2148. To my knowledge, you have to execute specific steps to overwrite the factory bootloader, so you shouldn’t have to worry about overwriting it.

If SFE has connected P0.14 and RESET up to the COM port (over DTR and RTS, but not sure which goes to which), use the option “Use DTR/RTS for Reset and Boot Loader Selection” in the LPC2000 Flash Utility. This handles entering the bootloader and resetting the device automatically so all you have to do is push the “Upload to Flash” button and everything is handled for you.

The only pain with that is that you have to be able to disconnect RESET and P0.14 when you’re not programming the chip if you’re using terminal emulation programs (i.e., HyperTerminal). This is because these programs will keep your chip in reset indefinitely because of the state they leave the RTS pin in. This is the reason that the Olimex boards have switches on both of these signals.

brennen:
If SFE has connected P0.14 and RESET up to the COM port (over DTR and RTS, but not sure which goes to which), use the option “Use DTR/RTS for Reset and Boot Loader Selection” in the LPC2000 Flash Utility. This handles entering the bootloader and resetting the device automatically so all you have to do is push the “Upload to Flash” button and everything is handled for you.

Correct, SFE do have P0.14 and RESET connected to the "programming header". What your saying confirms my thoughts that this is how they load their custom bootloader.

brennen:
The only pain with that is that you have to be able to disconnect RESET and P0.14 when you’re not programming the chip if you’re using terminal emulation programs (i.e., HyperTerminal). This is because these programs will keep your chip in reset indefinitely because of the state they leave the RTS pin in. This is the reason that the Olimex boards have switches on both of these signals.

Interesting. I don't think this will be a problem for me as I am not using a COM port. I am using the UART0 for GPS comms but that is just basic TXD and RXD, no RTS so I think I should be fine.

Thanks for your help Brennen :wink:

You don’t necessarily need to break out P0.14 and reset to connect them to DTR/RTS. You can also design your board so that it has two buttons connected to those pins. So your bootloader connector can have only 3 pins (GND, TXD, RXD). Then to enter the on chip boot loader, follow this sequence:

1)hold down reset button

2)push and hold down P0.14 button

3)release reset button

4)release P0.14 button

after this your chip will be waiting for data through the serial port.

Note that the button on P0.14 can be reused for other purposes, like for the user interface, as long as it is not held down together with reset.