Photon, programmer shield & openocd

Has anyone succeed using the Programmershield with a Photon and openocd.

I have previously sucessfully used the core with an Olimex USB-TINY-H, also FTDI-based, with opened 0.7

I have currently tried connecting to the programmer shield, populated with a photon using Openocd 0.7 and 0.9 using following config:

# Script for connecting with the STM32F3DISCOVERY board
source [find interface/ftdi/openocd-usb-hs.cfg]
source [find target/stm32f2x.cfg]

the VID and PID of the FT2232H, on the shield, matches the settings in interfaces/ftdi/openocd-usb-hs.cfg
but i get following log from opened

Debug: 283 4 ftdi.c:625 ftdi_initialize(): ftdi interface using shortest path jtag state transitions
Error: 284 10 mpsse.c:161 open_matching_device(): no device found
Error: 285 10 mpsse.c:304 mpsse_open(): unable to open ftdi device with vid 0403, pid 6010, description 'Dual RS232-HS' and serial '*'
Debug: 286 10 command.c:628 run_command(): Command failed with error code -100
User : 287 10 command.c:689 command_run_line(): 

Any clues, or perhaps a successful configuration would be much appreciated :slight_smile:

Yes - I’ve got it working - are you using the latest programmer shield with the on-board dual-channel FTDI chip ?

I’ll save the long-winded reply until we establish the basics.

Oh, and what host OS ? If it’s not linux, I fear my learnings will be of little direct use.

yes Programmer Shield 1.0.0 with the FTDI2232H

I’m running OS X 10.10.3 have openocd 0.7 and 0.9 installed

I have been debugging successfully on the Core with an Olimex-arm-usb-tiny-h (also FTDI based), using openocd 0.7

The programmer shield enumerates successfully on USB
The photon is inserted, correctly, and i have compiled with USE_SWD_JTAG=y

working configscripts (*.cfg) would be useful, i think, and perhaps other needed tweaks :wink:

The key for me was reprogramming the VID/PID in the FTDI part to emulate an existing device that enumerates differently when the driver loads. Under linux, instead of instantiating 2 full serial ports, the ftdi-sio driver skips hooking up the serial subsystem to the first device, and connects the second port up as a serial device.

I picked the VID/PID pair 0x0403:0xbdc8 which emulates a turtelizer2 - at least as far as the ftdi-sio driver is concerned and triggers the above behaviour in the driver.

Here is the contents of my particle-shield.cfg that works with a shield that has had the VID/PID reprogrammed:

interface ft2232
ft2232_layout usbjtag
ft2232_vid_pid 0x0403 0xbdc8
adapter_khz 1000

I honestly have no idea if the same approach will work under OSX.

To change the VID/PID on the chip, I used the FTDI utility, FT_Prog.

1 Like

thanks, well, at least this lets me connect to the target.
Now i just need to figure out if there are any missing compile options or similar, the JTAG does not seem to be able to read from the device just yet.
I have downloaded the image, compiled with USE_SWD_JTAG=y, using DFU, to the photon, and hope to be able to attach to the running target, or possible reset and run it from boot…

Info : 402 336767 server.c:91 add_connection(): accepting 'gdb' connection on tcp/3333
Debug: 403 336767 breakpoints.c:359 breakpoint_clear_target_internal(): Delete all breakpoints for target: stm32f2x.cpu
Debug: 404 336767 breakpoints.c:499 watchpoint_clear_target(): Delete all watchpoints for target: stm32f2x.cpu
Debug: 405 336767 target.c:1465 target_call_event_callbacks(): target event 23 (gdb-attach)
Error: 406 336767 target.c:2169 target_read_u32(): Target not examined yet
Error: 407 336767 core.c:217 get_flash_bank_by_num(): auto_probe failed
Error: 408 336767 gdb_server.c:984 gdb_new_connection(): Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: 409 336767 server.c:95 add_connection(): attempted 'gdb' connection rejected

Can you put the device into DFU mode (hold setup after reset untilit flashes yellow) - I believe that the JTAG port is still active while the bootloader is active, so being able to read/write memory via openocd will be a really good validation step.

There’s enough to go wrong with gdb/jtag-enabled-fw/openocd that establishing that openocd works on it’s own was a key step for me.

“telnet localhost 4444” is your friend here.

1 Like

Putting it in DFU mode takes me a bit further… GDB can connect to openocd, it seems writing through the FT2232 fails.
But since the DFU takes me further, it seems my ovn application might be missing something, rgd. enabling the JTAG port.

Next step i think is trying the Olimex JTAG on a Photon, to figure out whether it is the JTAG adapter settings or target setting that i am struggling with

User : 14139 99687299 target.c:2540 handle_target(): Examination failed, GDB will be halted. Polling again in 6300ms
Error: 14140 99693860 ft2232.c:539 ft2232_write(): ftdi_write_data: usb bulk write failed
Error: 14141 99693860 ft2232.c:825 ft2232_send_and_recv(): couldn't write MPSSE commands to FT2232
Debug: 14142 99693860 target.c:1465 target_call_event_callbacks(): target event 0 (gdb-halt)
User : 14143 99693860 target.c:2532 handle_target(): Polling target stm32f2x.cpu failed, trying to reexamine
Debug: 14144 99693860 target.c:1465 target_call_event_callbacks(): target event 21 (examine-start)
Debug: 14145 99693860 arm_adi_v5.c:649 ahbap_debugport_init():

found this post on the programmer shield repository:

It uses the most recent ftdi driver. But since i have reprogrammed the PID, i haven’t unloaded the Apple OS X driver, as described, instead just gone with my new PID

Dunno, writing a new PID might actually be easier that fiddling with the OS X fetid driver
# Particle Industries, Inc.
# Configuration file for the Particle Programmer Shield
# Author: Mohit Bhoite
# v0.0.1

interface ftdi
#ftdi_vid_pid 0x0403 0x6010
ftdi_vid_pid 0x0403 0xbdc8
#ftdi_device_desc "Particle-Programmer-Shield"

ftdi_layout_init 0x0008 0x180b
ftdi_layout_signal nTRST -data 0x0200 -oe 0x0010
ftdi_layout_signal nSRST -data 0x0090 -oe 0x0040

It allows reprogramming the flash, and somewhat attaching to the device in DFU mode, stepping a bit through assembly. Now whats left is to get the bin build correctly with JTAG enable, so i can connect to my own application, and hopefully load the elf…

@opprud, I’m having issues getting my Programmer Shield v1.0 working on Yosemite. The programmer shield github page links to a discussion on Yosemite issues, particularly disabling kext signature checking:

However, I tried the steps suggested and still can’t get openocd running properly:

Have you encountered this? Interestingly, even after attempting to disable one of the FTDI drivers, I still get the following two ports listed:

Running sudo kextunload -bundle results in this error:

Well i started out from the responses of another post, and therefore my first action was to change the PID of the FT2232 chip, using FT_PROG: this avoided me the trouble of having to unload the existing FTDI drivers.
I have used PID 0xBDC8 for my programmer shield
Furthermore i changed the expected PID in the openocd script, to match my changed PID, in the FT2232 eprom, the scrip can be found on github, mentioned earlier in this thread.

I can successfully launch openocd, and control the ProgrammerShield.
Furthermore i can single step through assembly code in the photon, ONLY when in DFU mode, but i am missing the ability to build a full successful application with JTAG enabled, and be able to load the symbolics from the elf file and debug it…

-currently i am a bit stuck loading and running the correct binaries, since a am missing an overview on the libraries for firmware and HAL, and how much of these are affected and needs to be reloaded when i program the flash, and expect to debug.

Sigh… Anyone know of any Windows instructions?

I can find heaps of instructions for Linux and Mac, but nothing for the system that most everyone outside of California and New York uses on their desktop… I can pirate MacOS X and run it on a PC, or I can run Linux, but both of those are a heap of headache and I’d rather not.

1 Like

Simplest way ive found, rather than fighting wit Windows, is just setup a vm with ubuntu as a guest.
Everything works great

1 Like

That doesn’t solve my problem. I can’t use VMs at work.