Flyswatter2 LPC2148 How To

From eLinux.org
Jump to: navigation, search

This guide will walk you through connecting the Flyswatter2 and the Olimex LPC-P2148 Prototype Board to your Linux PC, and installing and running OpenOCD. This guide was written with Ubuntu 10.04.


Connecting the Flyswatter2 and the LPC2148 board

To hook up the Flyswatter2 and the LPC2148 board, you will need:


Connect the RS-232 Cable to the Flyswatter2.

Fs2 rs323.png


Connect the Other End of the Ribbon Cable to the LPC2148 board.

Fs2 lpc2148 rs323.png

There are two serial ports on the LPC2148. Either will work. If you use the port on the left (not the one shown in the picture), be sure the two switches in the blue housing near the port are set to OFF.


Connect the JTAG Cable.

Fs2 lpc2148 connected.png

Your cable should have a notch on each end to force it into correct alignment on the pins. If it doesn't align Pin 1 as shown in the image to the left. The red stripe on the cable marks Pin 1.


Connect the USB cable to the Flyswatter2.

Fs2 lpc2148 usb.png

Find the USB cable that comes with the Flyswatter2. Connect the B end (the square end, not the flat end) to the Flyswatter2.


Connect the Power Adapter to the LPC2148 board.

Fs2 lpc2148 power.png

The LPC2148 board's power supply is next to the right serial port.


Plug the Power Adapter into a Wall Outlet.

The red LED next to the LPC2148 board's power supply should come on and remain on.

Plug the USB Cable into your PC.

The green power LED on the Flyswatter2 should come on and remain on.


Installing OpenOCD

OpenOCD (Open On-Chip Debugger) is open-source software that interfaces with the Flyswatter2. OpenOCD provides debugging and in-system programming for embedded target devices. You will need to compile OpenOCD from source, and patch the source with one of the OpenOCD Patches for Flyswatter 2 support.

Whichever guide you use, be sure to install the patch! Both guides include instructions on downloading and installing the patch.


Compiling OpenOCD Linux

Compiling OpenOCD Linux D2XX


The first set of instructions uses libFTDI, an open-source driver library for FTDI devices. The second set uses FTD2XX, a closed-source driver library from Future Technology Devices International.


Running OpenOCD

Now you are ready to run OpenOCD. If you installed the OpenOCD Ubuntu package, open a terminal window and type the following from any directory:

openocd -f interface/flyswatter2.cfg -f board/olimex_lpc_h2148.cfg

If you compiled OpenOCD yourself, navigate to the openocd-bin directory you created in the compile guide and type:

cd ~/openocd-bin
sudo ./openocd -f interface/flyswatter2.cfg -f board/olimex_lpc_h2148.cfg

For general information on running OpenOCD, see Running OpenOCD on Linux. When you start OpenOCD, you should see this:

LPC2148 ocdstartup.png

You should also hear a high-pitched beep from the buzzer on the LPC2148 board.

Telnet Connection

You cannot enter commands directly to OpenOCD. Open a new terminal window and type:

telnet localhost 4444

You will should see this prompt:

Telnet.png

You can give commands to OpenOCD through this prompt.


Common OpenOCD Commands

To see a full list of OpenOCD commands, enter help in the telnet window.

reset

Resets the LPC2148 board. The output of the Reset command should look like this:

Lpc2148 reset warnings.png

You should also hear a high-pitched beep from the board's buzzer.

Notice the two warnings about slow performance. If you want to speed up the board, you can enable fast memory access and DCC downloads by entering:

> arm7_9 fast_memory_access enable
> arm7_9 dcc_downloads enable

LPC2148 fastenable.png

With fast memory access and DCC downloads enabled, you should be able to reset the board with no warnings:

LPC2148 reset.png

halt

Sends a halt request to the LPC2148 board. If the LPC2148 board halts, you will see text output in the telnet window. (If the LPC2148 board is already halted, you will see no output.)

Lpc2148 halt.png

halt [timeout]

You can also use halt followed by a time in milliseconds. OpenOCD waits for the target to halt the specified amount of time, then gives up if the target has not halted. You can use this to avoid OpenOCD hanging because the LPC2148 board fails to halt. For example, to send a halt command with a timeout of one second, type:

halt 1000

resume

Enter resume to end a halt. You will not see any text output in the telnet window.

reg

Displays a numbered list of all of the LPC2148 board's registers.

Lpc2148 reg.png

reg [entry]

Run reg with a register number to display the contents of a register, in hexadecimal. The register number corresponds to the output of the reg command with no arguments, above. You must run the halt command before reading registers.

Lpc2148 reg0.png

If you run reg while the LPC2148 board is not halted, you will still see the value stored in the register. However, registers change contents very quickly while the device is running; by the time you see the value, the value actually in the register may be different. If you try to run reg while the device is not halted, you will see this:

Lpc2148 reg0 nothalted.png


reg [entry] [value]

Sets the value of a register. The register number corresponds to the output of the reg command with no arguments, above. Make sure the LPC2148 board is halted (with the halt command) before you change the value of a register!

You can enter registry values in either decimal, by typing a number by itself, or in hexadecimal, by prefacing the value with 0x.

Lpc2148 regset.png


GDB Debugger

GDB, the GNU Project Debugger is a debugging tool provided with the GNU Compiler Collection (GCC). GDB allows you to stop and start a running program, examine its functioning, and make changes. GDB is installed on Ubuntu 10.04 by default, but you will need a different version of GDB build for embedded targets. Follow the instructions on the GDB Debugger page below.

GDB Debugger

The GDB debugger page will walk you through installing GDB for use with OpenOCD, and loading and testing a simple program.