OpenOCD (Win7) and the Photon Programmer Shield

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

@jvanier,

Thanks! I finally got things going with OpenOCD following your advice. The only minor probelm I ran into is that in Zadig, I had to select Options > List_All_Devices before the Particle_FT2232 (Interface_#) would show up in the drop-down. Also, I loaded the WinUSB driver and everything seems okay. I’m able to read/erase/write flash.

Thanks 1e6.

Tom

2 Likes

@jvanier, thanks for your instructions! Everything is working except that I had to change to gdb port 4444. :smile:

2 Likes

Welcome!

I'm curious about this comment.

OpenOCD opens port 4444 for its own remote protocol that you can access through telnet, and if you pass openocd -c "gdb_port 3333" it will open port 3333 for the gdb remote protocol.

You'd connect with telnet or PuTTY to port 4444 to send commands to OpenOCD like erase, flash, etc.

You'd connect with GDB to port 3333 with arm-none-eabi-gdb -ex "target remote localhost:3333"

Why did you change the GDB port to 4444? Was it in the openocd command line or the gdb command line? Didn't it conflict with the OpenOCD remote interface?

@jvanier, actually now that you mention it, I tried to connect with telnet via port 3333 and it failed - of course! SO, no need for change, just more intelligence on this user’s side :flushed:

@jvanier, thanks for your tutorial, it worked just as you said without any problems :+1:

I’m just curious why you suggest to copy stm32f3x.cfg and not stm32f2x.cfg to bin-x64.
When opening OpenOCD you’re referencing the stm32f2x.cfg (I just copied both into the dir)

'Tis but a typo. Thanks for pointing it out! I fixed it.

1 Like