Unable to flash target code on CW312-T A35 ibex

Hi everyone,

my goal is to measure the power consumption of some RISCV software that should be executed on a soft-core Ibex on an artix-7 FPGA.

I have looked through the Q&A section here before, but could not find an answer which solves my problem.

Some preliminaries regarding my setup:

  • Running on Windows
  • CW boards: Husky, CW313 support board, CW312T-XC7A35 target board
  • Tigard programmer

I will closely follow the procedure from here so everyone can (hopefully) understand my thought process.

First, I compiled my software, where i closely follow the structure of other software i compiled before and which looks roughly like this:

uint8_t get_pt(uint8_t* pt, uint8_t len)
{
   //...
    trigger_high();
    // code to measure
    trigger_low();
    // ...
    simpleserial_put('r', 8, pt);
    return 0x00;
}

int main(void)
{

    platform_init();
    init_uart();
    trigger_setup();
    simpleserial_init();
    simpleserial_addcmd('i', 16, get_pt);
    while(1)
        simpleserial_get();
}

Using the riscv32-unknown-elf-gcc, I successfully generated my .elf file.
In the next step, I loaded the bitfile (lowrisc_ibex_demo_system.bit) using the setup script from here, with PLATFORM=CW312_IBEX.

The script tells me that the FPGA was successfully programmed. Which means the next step is to program the firware using the load_demo_system.sh command from the Ibex repository.

To program the firware I use Tigard as for example noted here.
To do so I used Self-powered mode as stated here.

I connected TDI/TDO/TCK/TMS from Tigard to the pins of the CW313 board and set the DIP switches 5-8 on the CW312-T to “on”. No JTAG programmer is connected to the CW312T-A35

The load_demo_system.sh script requires three parameters: run elf_file tcl_file
In my understanding is the elf_file the software i previously compiled.
For the tcl file I used this, which I will shown below:

adapter driver ftdi
transport select jtag

ftdi vid_pid 0x0403 0x6010

ftdi channel 0
ftdi layout_init 0x0088 0x008b
ftdi layout_signal nTRST -data 0x0010
ftdi layout_signal nSRST -data 0x0020
reset_config none

# Configure JTAG chain and the target processor
set _CHIPNAME riscv

# Configure JTAG expected ID
# arty-a7-35t
set _EXPECTED_ID 0x0362D093
# arty-a7-100t
# set _EXPECTED_ID 0x13631093

jtag newtap $_CHIPNAME cpu -irlen 6 -expected-id $_EXPECTED_ID -ignore-version
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME

riscv set_ir idcode 0x09
riscv set_ir dtmcs 0x22
riscv set_ir dmi 0x23

adapter speed 10000

riscv set_mem_access sysbus
gdb_report_data_abort enable
gdb_report_register_access_error enable
gdb_breakpoint_override hard

reset_config none

init
halt

when running now in jupyter notebooks:

%%sh
./load_demo_system.sh run my_software.elf arty_a7_openocd_cfg.tcl

I get this output:

xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2022-03-25-17:32)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
force hard breakpoints
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 '*', serial '*' at bus location '*'

And this is the point were I get stuck.
In my device manager I can see under Ports (COM&LPT) the USB Serial Port from Tigard, where vid and pid matches the one from the tcl file.
I already used Zadig to install WinUSB (libusb) drivers, however the error persists.
I played around with the ftdi channels but this does not change anything.

I also tried to connect the pins from Tigard to the JTAG TDI/TDO/TCK/TMS pins on the CW312T-A35 board, which I read from the schematic together with every combination of DIP switches (1-4, 5-8) to check if I made an error when connecting the pins, but I always get the same error.

Running other targets (e.g. STM32F405) using the husky and CW313 board works without any problems.

Is this a common problem, or has anyone encountered this problem before and knows how to fix this?
If more information is required (about other drivers, versions etc) I am happy to share them.

Any help is much appreciated.
Cheers :slight_smile:

OpenOCD is giving you a “LIBUSB_ERROR_NOT_FOUND” error; this is some sort of driver issue.

There is no point in trying different things in the configuration file or on your CW312 target board until this is resolved.

Check your driver installation (see Windows drivers · Issue #47 · tigard-tools/tigard · GitHub).

Hi @jpthibault,

thanks for the quick response, I appreciate it!
After re-installing the driver I got a little closer to programming the firmware, however I ran afterwards in another error, which is now:

xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2022-03-25-17:32)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
force hard breakpoints
Info : clock speed 2000 kHz
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: riscv.cpu: IR capture error; saw 0x3f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: Unsupported DTM version: 15
Warn : target riscv.cpu examination failed
Info : starting gdb server for riscv.cpu on 3333
Info : Listening on port 3333 for gdb connections
Error: Target not examined yet

Error: Unsupported DTM version: 15

Searching for this type of error, especially JTAG scan chain interrogation failed: all ones led me to this github issue, which says that there is still some issue with my JTAG connection.
Especially connecting TDO to ground should have given me instead of […] all ones an error […] all zeros, however this is not the case for me.

Again, I played around with the ftdi channel in my .tcl file and changed adapter speed to lower and higher speeds, but always get the same error.

Is this still a driver issue or something I did wrong when connecting the pins from Tigard to the board? Again I tried to followed the steps from here, which says:

[…] you’ll need to program your target firmware separately, using an external JTAG programmer connected to the A35’s FPGA JTAG port, not the soft-core port (e.g. connect your programmer TDI/TDO/TCK/TMS to those header pins on the CW313 board, set DIP switches 5-8 to “on” on the A35 target board, and disconnect any other JTAG programmer from the A35’s “jaytag” header).

So I connected these header pins to the CW313 board, have set the DIP switches 5-8 to “on” on the A35 and had no JTAG progammer on the A35 “jaytag” header

I saw that there are three other questions ([1], [2], [3]), however [2] refers to debugging, which is not what I wanted to do and also does not use the CW313 board. [3] uses the CW308 UFO and in [1] a CW305 board was used, and it was said that

“FPGA JTAG” header (lower left corner of the CW305)

on the CW305 should be used.
Trying to apply this to the CW312T-A35 target seems to suggest to connect the programmer pins to the “FPGA Jaytag”, but if I understand it correctly this is not the way it is described here.

I feel like I made some stupid mistake when connecting the Tigard pins to the CW313 board, but as all error messages that I get from openocd are the same for what I tried so far, I am pretty stuck at this point.

Is there any suggestion or explanation that I can find to solve this issue? :slight_smile:

You’ll find the openocd config file that I’ve used with Tigard and the Ibex target in this thread:

That was for our CW305 target; it also works for the CW312-A35, just make sure to set EXPECTED_ID to the correct FPGA part.