Flyswatter2 PIC32MX Windows How To
This guide will walk you through connecting the Flyswatter2 and the Olimex PIC-P32MX board to your Windows PC, and installing and running OpenOCD. This guide was tested with Windows XP and Windows 7. Instructions are identical on 32-bit and 64-bit versions of Windows unless otherwise noted.
- 1 Connecting the Flyswatter2 and the Olimex Development Board
- 1.1 Connect the MIPS JTAG Adapter Board to the Flyswatter2.
- 1.2 Connect the 14-pin ribbon cable to the Adapter Board.
- 1.3 Connect the JTAG cable to the PIC-P32MX.
- 1.4 Connect the RS232 Serial Cable.
- 1.5 Connect the USB cable to the Flyswatter2.
- 1.6 Plug the 9V power adapter into a wall outlet.
- 1.7 Plug the power adapter into the PIC-P32MX.
- 1.8 Connect the USB cable to your PC.
- 2 Installing OpenOCD
- 3 Running OpenOCD
- 4 Common OpenOCD Commands
- 5 GDB Debugger
Connecting the Flyswatter2 and the Olimex Development Board
To hook up the Flyswatter2 and the PIC-P32MX board, you will need:
- Olimex PIC-32MX development board
- 20-pin ARM to 14-pin MIPS JTAG Adapter Board
- 9V DC Power Adapter
- 14-pin JTAG Ribbon Cable
- RS-232 Serial Cable with one male, one female connector
- USB Male A/Male B cable
Connect the MIPS JTAG Adapter Board to the Flyswatter2.
Connect the 14-pin ribbon cable to the Adapter Board.
Connect the JTAG cable to the PIC-P32MX.
Connect the RS232 Serial Cable.
Connect the USB cable to the Flyswatter2.
Plug the 9V power adapter into a wall outlet.
Plug the power adapter into the PIC-P32MX.
Connect the USB cable to your PC.
You should see a green LED light up on the Flyswatter2.
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 3 support.
Whichever guide you use, be sure to install the patch! All four guides include instructions on downloading and installing the patch.
Use Windows 7 guides if compiling for Windows Vista.
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.
Now you are ready to run OpenOCD. Open a command line window; if you're not sure how to do this, see Running OpenOCD on Windows. Navigate to the folder containing openocd.exe (the openocd-bin folder you created in the compile guide) and type:
cd C:\openocd-bin openocd -f interface/flyswatter2.cfg -f board/olimex_pic32mx.cfg
For general information on running OpenOCD, see Running OpenOCD on Windows. When you start OpenOCD, you should see this:
You cannot enter commands directly to OpenOCD. Open a new command window and type:
telnet localhost 4444
You will should see this prompt:
You can give commands to OpenOCD through this prompt. If you don't see the prompt on Windows 7, you may need to enable the Telnet client. See Configuring Windows 7 for OpenOCD.
Common OpenOCD Commands
To see a full list of OpenOCD commands, enter help in the telnet window.
Resets the PIC-P32MX. The output of the Reset command should look like this:
Sends a halt request to the PIC-P32MX. If the PIC-P32MX halts, you will see text output in the telnet window. (If the PIC-P32MX is already halted, you will see no output.)
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 PIC-P32MX fails to halt. For example, to send a halt command with a timeout of one second, type:
Enter resume to end a halt. You will not see any text output in the telnet window.
Displays a numbered list of all of the PIC-P32MX's registers.
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 PIC-P32MX 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:
Note that unlike with some other boards, OpenOCD provides no warning that the device is not halted. Be careful.
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 PIC-P32MX 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.
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. To install and use GDB with OpenOCD, follow the instructions on the Windows GDB Debugger page below.
The GDB debugger page will walk you through installing GDB for use with OpenOCD, and loading and testing a simple program.