USB Port Select for Open On-Chip Debugger


(Ekkehard Blanz) #1

After having played around with the HiFive1 a bit using the Arduino IDE, I wanted to integrate it in my tool environment and leave the Arduino IDE behind. I understand the Open On-Chip Debugger is used not only for debugging but also to just load newly compiled and linked programs to the HiFive1. It appears to find the correct USB port automagically (likely by finding the one with VID 0x0403 and PID 0x6010), but what if there are more than one HiFive1-s attached? The Arduino IDE apparently ignores the selected USB port, and the Makefile that comes with the SDK does not include an option to select the USB port (pair). How do I tell openocd which USB port (pair) to use in cases where more than one HiFive1 boards are attached?


(Bruce Hoult) #2

I think probably no one has needed to do this so there isn’t support worked out for it in either the freedom-e-sdk scripts or the Arduino IDE.

However OpenOCD does have a way to specify it. You can set the ftdi_location property in a .cfg file and then use different .cfg files for each board and then invoke OpenOCD with the correct .cfg file using the -f argument.


(Ekkehard Blanz) #3

Thanks a bunch @bruce - that works for me - I can integrate this into my stuff! I looked at the OpenOCD manual but couldn’t find it - probably because I was just a tad overwhelmed as I haven’t read it cover-to-cover (yet). But now I know where to look.

Glad a guy with my hair color could help me out here :grinning:


(Bruce Hoult) #4

“None of the Above”?


(Ekkehard Blanz) #5

I’s not the amount that matters, it is the color that stems from spending enough time with all this stuff and ultimately puts you in a position to share all this knowledge acquired over decades :grinning::grinning:

So thanks again for sharing some of it with us here!


(Ekkehard Blanz) #6

Under (the Arduino-installed) .../sifive/hardware/riscv/1.0.2/freedom-e-sdk/bsp/tools there is a bash script openocd_upload.sh, which does exactly what you recommended. I couldn’t find it in the regular SDK install. Here is what it does

#! /bin/bash -x
openocd -f ${2} \
    	-c "flash protect 0 64 last off; program ${1} verify; resume 0x20400000; exit" \
    	2>&1 | tee openocd_upload.log

in other words, it takes the loadable program as the first and the USB port as the second parameter - works exactly as you said :grinning: