This guide will walk you through connecting the Flyswatter2 and the mikroElektronika mikroBoard for ARM 144-pin to your Linux PC, and installing and running OpenOCD. The mikroBoard used in this guide is mounted on the MikroElektronika UNI-DS6 development system.
This guide was written for Ubuntu 12.04 LTS.
Contents
- 1 Connecting the Flyswatter2 and the LPC2214 mikroBoard
- 1.1 Mount the mikroBoard LPC2214 on the UNI-DS6 motherboard
- 1.2 Check the Jumper Settings on the UNI-DS6 motherboard.
- 1.3 Check the Jumper Settings on the mikroBoard.
- 1.4 Connect the JTAG cable to the Flyswatter2.
- 1.5 Connect the Flyswatter2’s 20-pin JTAG cable to the mikroBoard.
- 1.6 Connect the USB Cable to the Flyswatter2.
- 1.7 Connect the Other End of the USB Cable to your PC.
- 1.8 Connect the Power Cable to the UNI-DS6.
- 1.9 Plug the Power Cable into a Wall Outlet.
- 1.10 Set the UNI-DS6’s Power Switch to ON.
- 2 Installing OpenOCD
- 3 The LPC2214 Config File
- 4 Running OpenOCD
- 5 Common OpenOCD Commands
- 6 Setting up Eclipse for ARM Cross-Development and Debugging
Connecting the Flyswatter2 and the LPC2214 mikroBoard
To hook up the Flyswatter2 and the LPC2214 mikroBoard, you will need:
- Flyswatter2
- USB Male A/Male B Cable
- 20-pin JTAG Ribbon Cable
- MikroElektronika mikroBoard for ARM 144-Pin (LPC2214)
- MikroElektronika UNI-DS6 development system
- 9V DC Power Cable
Mount the mikroBoard LPC2214 on the UNI-DS6 motherboard
Look for the silkscreen “mikroBoard Socket” on your UNI-DS6. Carefully align the pins on the bottom of the mikroBoard with the socket, and press firmly on all four corners to secure the connection. Make sure the 20-pin JTAG and mini-USB connectors are oriented to the top of the board.
Your UNI-DS6 and mikroBoard may have shipped with the mikroBoard already mounted, as shown in the picture to the left. If so, skip this step.
Check the Jumper Settings on the UNI-DS6 motherboard.
The LPC2214 mikroBoard has 3.3V I/O so you must set the UNI-DS6 motherboard to 3.3V I/O as well. Set the J16 jumper to 3.3V as shown in the picture. This is located in the upper left corner of the motherboard in the POWER SUPPLY section.
Check the Jumper Settings on the mikroBoard.
The J1 “ENABLE” jumper should be connected (shorted) and the J2 “STANDALONE” jumper should be left open, as shown in the image to the left.
Note: You can leave the J2 jumper installed at a 90 degree angle so you will not loose the yellow jumper.
Connect the JTAG cable to the Flyswatter2.
Plug the 20-pin ribbon cable into the Flyswatter2’s JTAG interface. Note the position of PIN 1, indicated by the red stripe on the cable in the image.
Connect the Flyswatter2’s 20-pin JTAG cable to the mikroBoard.
Connect the Flyswatter2’s 20-pin JTAG ribbon cable to the mikroBoard’s JTAG interface. The mikroBoard’s JTAG interface does not have a shrouded header to prevent connecting the cable “backwards”, so take careful note of the position of the pins. Pin #1 on the mikroBoard is on the inner left, marked on the board with a small white triangle. Make sure it aligns with Pin #1 on the ribbon cable. In the picture to the left, Pin #1 is marked with a red stripe on the cable.
Notice the “loop” in the JTAG ribbon cable. This “loop” helps align Pin #1 on the JTAG ribbon cable connector to Pin #1 on the mikroBoard’s JTAG connector.
Connect the USB Cable to the Flyswatter2.
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 Other End of the USB Cable to your PC.
Plug the USB cable into your PC, connecting it to the Flyswatter 2. You should see the green “Power” LED light up on the Flyswatter2.
Connect the Power Cable to the UNI-DS6.
Connect the 9V-DC power cable to the Uni-DS6’s power jack (connector). The power jack is at the UNI-DS6’s upper left corner.
Plug the Power Cable into a Wall Outlet.
The UNI-DS6 has a power switch, so if the power is OFF you won’t see anything happen.
Set the UNI-DS6’s Power Switch to ON.
The power switch is just below the power adapter. Slide the switch to the right to turn power ON. The power LED should illuminate.
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. For instructions, see the guide below:
Compiling OpenOCD v07 Linux
The LPC2214 Config File
OpenOCD uses specific configuration files for different devices. The config file for the Flyswatter2 is included with OpenOCD, but you will need to download or create a config file for the mikroBoard LPC2214. You can download the file here:
Download lpc2214.cfg (Right Click and “Save As”)
Or you can create the file yourself. Open a text editor and create a new file called lpc2214.cfg. Select the following text and copy it all into the file:
jtag_rclk 500 source [find target/lpc2xxx.cfg] reset_config trst_and_srst srst_pulls_trst proc init_targets {} { echo "Warning - assuming default core clock 14MHz! Flashing may fail if actual core clock is different." setup_lpc2xxx lpc2214 0x4f1f0f0f 0x40000 lpc2000_v1 0x4000 14000 1666 }
Save the file into OpenOCD’s /target/ directory. If you followed the compile guides above, you can find the /target/ directory
at
~/openocd-bin/target.
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 target/lpc2214.cfg -c init -c "reset init"
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 target/lpc2214.cfg -c init -c "reset init"
Your terminal window should now look something like this:
Pay careful attention to this line:
Info : JTAG tap: lpc2214.cpu tap/device found: 0x4f1f0f0f (mfg: 0x787, part: 0xf1f0, ver: 0x4)
If you don’t see that, you’ve got an error of some kind. Check the connections on the JTAG ribbon cable or refer to OpenOCD Troubleshooting, and try again.
Telnet Connection
You cannot enter commands directly into OpenOCD. Open a new terminal window and start a telnet session by typing:
telnet localhost 4444
You will should see this prompt:
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 mikroBoard. The output of the Reset command should look like this:
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
With fast memory access and DCC downloads enabled, you should be able to reset the board with no warnings:
halt
Sends a halt request to the mikroBoard. If the mikroBoard halts, you will see text output in the telnet window. (If the mikroBoard is already halted, you will see no output.)
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 mikroBoard 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 mikroBoard’s registers.
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.
If you run reg while the mikroBoard 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:
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 mikroBoard 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.
Setting up Eclipse for ARM Cross-Development and Debugging
For information on setting up cross-development toolchain, Eclipse, and GDB Debugger for use with the UNI-DS6 and mikroBoard, see the following guide: