OpenOCD (Win7) and the Photon Programmer Shield

Hi,

I’m trying to build OpenOCD (under Cygwin under Win7)… but I can’t get beyond:

$ ./configure --enable-ftdi

configure: error: libusb-1.x is required for the MPSSE mode of FTDI based devices

Any suggerstions?

Thanks,

Tom

I have been meaning to get the programmer shield working on Windows and post detailed instructions but I haven’t had time yet. Did anyone else get this working?

Julien,

(background) A while ago, I cobbled together an ICP (in-circuit programmer) for the ATmega328p (Arduino). It’s basically just a SPI interface (but it works when the AVR is in reset). You can use that interface to program the internal flash. And you HAVE to use that interface to change some of the “fuses.”

I assume there’s a similar sort of thing going on with the STM32 (on the P0/Photon), and this would be the “cha-cha” that goes on between the programmer shield and the Photon. Do you know where that interface is specified/documented?

Thanks,

Tom

If I understand correctly you’re asking what kind of debug interface is used in the STM32? It’s JTAG.

The Particle team was using an ST-LINK/V2 in-circuit debugger/programmer but they recently started selling a Programmer Shield. It’s a USB JTAG powered by a chip by FTDI. To use it with a debugger like GDB or Eclipse you need some sort of bridge software that understands the GDB protocol. That bridge is OpenOCD.

Is that what you were asking about?

Hi @k2tom

@jvanier is completely right with his comments about JTAG programming but normally you don’t have to use this interface for anything but the lowest level debugging and programming.

The Particle products ship with a bootloader program that allows you to download to your device over USB, which is more convenient to use. Even more convenient is the over-the-air programming using the Particle cloud.

1 Like

@jvanier, I have been trying to get openocd to work on win7x64 with little luck. The open OCD documentation is really awful. So far, I have installed MSYS2 x64, then installed mingw-w64-x86_64-gcc from within the MSYS2 shell. I can run the ./configure… but then it stops on:

configure: error: libusb-1.x is required for the MPSSE mode of FTDI based devices

I can’t seem to find a resolution for that. If I try and make install, it simply says make: Nothing to be done for install.

Any guidance from anyone would be great at this point :cry:

Have you tried using a binary from here : http://www.freddiechopin.info/en/download/category/4-openocd

@jvanier, does it support the particle ftdi?

@jvanier and @bko,

I understand that the FTDI FT2232H on the programmer shield functions as a USB-to-JTAG converter, and that JTAG is how the programmer talks to the Photon (target). But I was looking for a pointer to a spec of some sort that details the instructions/commands that are sent via the JTAG connection - especially as they relate to programming the STM32F205’s internal flash. Since the STM’s flash is STM-specific, I assume there’s some STM document that specifies it. I have used the information in STM’s “PM0059 Programming Manual (Doc 15687 Rev 5)” for IAP (in-application programming) in the past, but I’m not sure how that relates to ICP (in-circuit programming via the JTAG interface).

My first goal (in a long list) is to replace the bootloader.

Regards,

Tom

@jvanier,

I received my programmer shield… I plugged it in and it seems to have installed properly. I tried the windows binary you suggested (freddiechopin), using the CFG file (particle-ftdi.cfg) from the programmer-shield repository.


[startup] 516 /cygdrive/c/trash/openocd-0.9.0/bin> openocd -f c:/trash/particle-ftdi.cfg
Open On-Chip Debugger 0.9.0 (2015-05-19-12:06)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description ‘’ and serial '


0403 and 6010 ARE the vendor and product IDs associated with the “Particle FT2232” device. I’ve never uses OpenOCD before… am I missing additional options?

Any thoughts?

Thanks,

Tom

@k2tom, you seem to have confirmed my concern that the pre-built image is NOT compatible with the particle-ftdi device. Which basically means we have to compile openOCD with the particle cfg file present. However, compiling on Win7 is the problem I am having.

I found this note on Freddie Chopin’s website:

One important information from my side - currently all interfaces using libftdi library require WinUSB driver (previously libusb-win32 was required) - this change is related to switching to the new version of library - libftdi1. The easiest way to install the driver is to use zadig software, and a short description of the process can be found in “drivers\libusb-1.0 drivers.txt” file, which is a part of the package.

Zadig link: http://zadig.akeo.ie/

@k2tom @peekay123 let us know if that fixes the dependency.

1 Like

It did not seem to help me.

But just to “calibrate” things… here’s where I stand now.

I’m NOT able to build OpenOCD because of the missing libusb-1.x.

I used Zadig to install the WinUSB driver for when the Photon is connected directly (i.e., NO programmer shield) to my PC and in “Photon DFU Mode” (which shows up under “Universal Serial Bus devices” in “Device Manager”).

When I plug the Photon into the Programming Shield and connect it (the shield) to my PC, I see three (3) devices listed in “Device Manager” under “Universal Serial Bus controllers”: (1) “USB Composite Device” (vendor/rpoduct IDs 046d/c52f), (2) “USB Serial Converter A” (vendor/product IDs 0403/6010), and (3) “USB Serial Converter B” (same vendor/product IDs as Converter A). Then I used the pre-built Windows version of OpenOCD with two configuration files:


$ openocd -f c:/trash/particle-ftdi.cfg -f c:/trash/stm32f2x.cfg

Info : auto-selecting first available session transport “jtag”. To override use
’transport select '.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description ‘’ and serial '


At the end of the day, what I’m really trying to do here is to update the STM32F205’s flash, INCLUDING sector 0 (where the bootloader lives). If there’s a better way of doing this, I’m all ears.

Regards,

Tom

I finally got around to trying the Programmer Shield on Windows 10, and fortunately I didn’t run into any issues*. I was able to make it work by installing all the software and the drivers. I documented all my steps.

Debugging Particle on Windows

I relied on the the toolchain installer by @mumblepins so thanks a lot for that!

*. Not entirely true… I solved the libusb_open() failed with LIBUSB_ERROR_NOT_FOUND by trying all the drivers with both Particle FT2232 (Interface 0) and Particle FT2232 (Interface 1) until I found one that worked :slight_smile:

1 Like

@jvanier, so you used the pre-compiled versin of openocd, used zadig and played with which drivers for the Particle FT2232?

Yes. Nothing custom on the debugger side, all pre-compiled binaries for the tools. I only recompiled the firmware.

What did you mean by that?

In Zadig, you can pick a device from a dropdown and a driver from a dropdown. I tried a bunch of combinations of Particle devices and different drivers and got several different libusb errors. This combination ended up working for me:

I am such a newbie at this. So I downloaded the pre-compiled openocd v0.9, added the bin folder to the path and did openocd -v. All good. Not sure what to do next. There is no openocd-0.9.0/tcl/interface/ftdi/ directory to put the cfg file into. Can I ask HOW you run openocd so it actually works?

Sure. Here are the steps from my guide:

  • Download the Particle debugger config file particle-ftdi.cfg and copy it to C:\Particle\openocd\bin-x64\
  • Copy C:\Particle\openocd\scripts\target\stm32f2x.cfg to C:\Particle\openocd\bin-x64\
  • Open a command line to C:\Particle\openocd\bin-x64
  • Start openocd with
    openocd.exe -f particle-ftdi.cfg -f stm32f2x.cfg -c "gdb_port 3333"

You should see this:

1 Like