LPC2K_PGM Linux Bootloader Utility
For Philips LPC 2000 ARM7 Chips

This utility downloads code to Philip LPC 2000 series chips, using the bootloader communication protocol. This program was originally developed using a LPC2106. It has also been tested with LPC2131 & LPC2138 (thanks to New Micros for providing eval boards), and the LPC2103. It may work with other Philips ARM LPC parts.

Download

Søren Holm has published a version with additional chipid and gtk2 support. Please contact him for any questions regarding this modified version (do not email Paul...)

Version 1.05:

Download Source Code: lpc2k_pgm_1.05.tar.gz
Download Semi-Static Linux Binary: lpc2k_pgm

Version 1.04:

Download Source Code: lpc2k_pgm_1.04.tar.gz

Version 1.03:

Download Source Code: lpc2k_pgm_1.03.tar.gz

Version 1.02:

Download Source Code: lpc2k_pgm_1.02.tar.gz

Usage

When you start the program, it's small control window appears, and a xterm communication window is launched. The Xterm window allows you to simply leave lpc2k_pgm running and communicate with the LPC uart using that window. Most people configure "printf" on in their code to print to UART0, which will appear in the xterm window.


Control Window

This program has 4 simple settings:

Firmware:The intel-hex file with your LPC firmware to program.
Port:Which serial device to use.
Baud:The baud rate to communicate.
Crystal:The speed of the crystal on your LPC board.

Once you have set up these values, simply press the "Program Now" button to write your firmware to the LPC flash memory, and automatically run it. If your firmware communicates on UART0, its messages will appear in the xterm window, and anything you type in that window will be transmitted to your board.

The "Reboot" button may be used to reboot your code (assuming you have connected DTR appropriately). The "Bootloader" button may be used to stop your code by rebooting into the bootloader, rather than your program.


Communication Window (Xterm)

Hardware Requirements:

You must have a compatible Philips LPC chip with its UART0 interfaced to a serial port on your PC.

You must be able to reset the chip and cause it to enter bootloader mode. Normally, this is done by connecting the (TTL level translated) DTR signal to the LPC reset, so that when DTR is high (the TTL version is low), the Philips chip is in reset mode. Alternately, a pushbutton may be used, but you will need to manually press the button every time you want to get back into bootloader mode (while this program attempts to sync baud rates), rather than letting DTR do it automatically. A few minutes spent wiring up your circuit so DTR can reset the board will save you much trouble as you develop code. If you have used a resistor and capacitor for reset, a DTR reset feature can be added using only 3 cheap parts.


Adding DTR reset using 3 cheap parts

P0.14 must be connected low shortly after reset. Normally, this pin is just shorted to ground using a jumper. Starting with version 1.02, you can simply leave this shorted to ground. If your design needs to use this pin, you may also build a simple circuit that forces this pin to ground when RTS is high.

Software Requirements:

You must have a Linux-based system running X Windows. This code has been tested with Linux kernel 2.4.20 and 2.6.8, and should work with almost any linux system.

You must have the "xterm" program installed. Nearly all linux distrubtions provide this, and it is often installed by default. If you do not have it, simply install from your linux distribution.

Your serial port device file (usually /dev/ttyS0 or /dev/ttyS1) must allow permission for you to use the serial port.

GTK 1.2 is used for the GUI. Many newer systems only have GTK version 2 (or higher). If you have one of these systems, perhaps you can install GTK 1.2 (including the development libraries) to allow you to compile this code. Alternately, you may be able to use the semi-static build, which includes a copy of this code built into the program.

Building and Installation:

This software is provided as a semi-static binary and source code form.

To use the semi-static binary, simply copy it to a location where you can run it, and change the permissions if necessary:

        cp lpc2k_pgm /usr/local/bin
        chmod 755 /usr/local/bin/lpc2k_pgm

The semi-static binary has all of the GTK and X11 libraries statically linked into it, for maximum compatibility with all linux distributions. The disadvantage is, of course, that this uses an extra 1.4 megs of RAM, with (might) otherwise be shared with other programs. If the built-in GTK and X11 code is likely to work on most GNU/Linux systems. If you simply want to run this program with minimal work, using the semi-static binary may be the easiest way.

If you compile from the source code, the result should be a small binary that is optimal for your system. If the semi-static binary does not work, you must build a binary specific for your system.

To build from source, you must have GTK+ 1.2 development libraries and GCC properly installed. Nearly all linux distributions provide these as packages, but you may need to install them before you can compile the code.

Type "make" to build the code. The resulting "lpc2k_pgm" program can be run from any location. Simply copy to /usr/local/bin, or where ever you like.

If the GTK "dev" libraries are not installed, the "gtk-config" command will not be found. You may get hundreds of errors about undeclared symbol and implicit declarations, all due to an error near the beginning that "gtk/gtk.h" does not exist. These are sure signs you do not have the GTK 1.2 development libraries installed. See below for info about how to install these, or refer to the package manager provided with your linux distribution, or (experts only) download GTK 1.2 and install it manually.

Debian Stable

TODO: specific instructions for installing GTK+ 1.2 development libraries on Debian stable
Please help. If you know exactly what command to type or package to install, please contact me.

Debian Testing/Unstable

Type "apt-get install libgtk1.2-dev" at a shell prompt. Debian's apt-get system will automatically install any other required packages.

Fedora

TODO: specific instructions for installing GTK+ 1.2 development libraries on Fedora
Please help. If you know exactly what command to type or package to install, please contact me.

Suse

sudo zypper install gtk-devel

Asuming you already have installed

sudo zypper install gcc make

(contributed by Daniel Schürman)

Contact Info

Paul Stoffregen
paul@pjrc.com
http://www.pjrc.com/arm/lpc2k_pgm
http://www.pjrc.com

If you discover a bug, you want to request a new feature, or you have a new Philips LPC chip which is not recognized, please attempt to provide COMPLETE information in your message.

If you have problems building from source, please contact me with ALL of the following:

  1. Complete copy of all messages during the build.
  2. Output of "gtk-config --version"
  3. Output of "gtk-config --libs"
  4. Output of "gtk-config --cflags"
  5. Output of "uname -a"
  6. If it won't run normally, does "export LPC2K_RUNNING_AS_EMULATOR=yep ; xterm -e /usr/local/bin/lpc2k_pgm" work?
  7. Other info... which linux distribution, version, other software

If you get "Command not found" when trying to run "gtk-config", this is a sure sign that you do not have GTK+ 1.2 installed.

Other Linux Options

http://guest.engelschall.com/~martin/lpc21xx/isp/index.html
http://groups.yahoo.com/group/lpc2000/files/lpc_host_tools.tar.gz