Friday, July 11, 2008

5V for a target from OpenOCD USB Adapter

I recently bought OpenOCD USB Adapter. The adapter arrived as a kit which comprises of the assembled adapter board, two IDC male connectors (ten and twenty pins) and one D-type 9 pin male connector.
One feature which is missing in this adapter from my point of view is an option to power up a target from USB. A USB port can provide up to 500 mA. The adapter should not consume more then 250 mA according to FT2232D datasheet. This would leave approximately 250 mA for a target board. For example, Olimex LPC2103 prototype header board would consume about a hundred mA.
Fortunately, there is a place on the adapter board for four pin header right behind D-type serial connector. Two pins in the center are serial's TTL TX and RX and pins on both sides are Ground and +5V straight from USB's Vbus. (Note, there is no ferrite bead on the adapter board.) I assembled a little board with MOSFET (FDN302P) to control power output. I used schematic of "Bus Powered Circuit with Power Control" (Figure 12) from FT2232D datasheet. The most challenging for me was to solder a wire to PWREN# pin (41) of FT2232D. The chip comes in the LQFP-48 package with leads on a 0.5mm pitch. Finally, since I do not need standard serial interface and only two pins in the second row of the serial connector are utilized, I decided to put a two pin polarized header in the first row to serve as a power connector for a target.
Well... As it turned out when OpenOCD (see update below about version 0.2.0) initializes interface FT2232 pulls PWREN# pin to high level for several hundred mS. This switches power off for the target. Meanwhile, OpenOCD attempts to communicate to the powered off target. I had to add a one second delay in openocd.c between jtag_interface_init and jtag_init calls to make the modification work.

UPDATE: OpenOCD version 0.2.0 seems to fix the issue above. I was able to flash and debug code on Olimex STM32-H103 board powered from the JTAG adapter.

2 comments:

zoobab said...

Do you know if this adaptor supports power levels below 3.3v? I have an Amontec, and it seems to have problems with the power level.

Misha said...

Hi zoobab,
All targets I tried are 3V3. However, according to FT2232D datasheet voltage on VCCIOA which drives channel A (JTAG) must be from +3.0V to +5.25V. VCCIOA is connected directly to V_target. Thus, with some luck, the adapter might work with 2.5V target. I am pretty sure the adapter would not work with target below 2.5V.