SiFive Rev B Cannot connect to target Error

I am using the latest versions of Visual Studio, PIO and the SiFive Rev B Firmware, every time I try to Compile code (C++) I get this error, has anyone encountered this before?

Target connection not established yet but required for command.
Device “FE310” selected.

Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 4, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x00000001, IRLen: 04, Unknown device
RISC-V behind DAP detected
No core base addr. configured. Assuming: 0x00000000
No AP specified by user. Using AP[0], assuming APB-AP
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 4, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x00000001, IRLen: 04, Unknown device

****** Error: Failed to power-up DAP
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 4, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x00000001, IRLen: 04, Unknown device
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 4, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x00000001, IRLen: 04, Unknown device
Cannot connect to target.

Target connection not established yet but required for command.
Device “FE310” selected.

Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 4, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x00000001, IRLen: 04, Unknown device
RISC-V behind DAP detected
No core base addr. configured. Assuming: 0x00000000
No AP specified by user. Using AP[0], assuming APB-AP
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 4, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x00000001, IRLen: 04, Unknown device

****** Error: Failed to power-up DAP
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 4, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x00000001, IRLen: 04, Unknown device
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 4, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x00000001, IRLen: 04, Unknown device
Cannot connect to target.

Script processing completed.

I thought these were good instructions below to get started with SiFive HiFive1 rev B and Visual Studio.

That was definitely a step in the right direction, The hardware debugger output this:

SEGGER J-Link GDB Server V6.52 Command Line Version

JLinkARM.dll V6.52 (DLL compiled Sep 27 2019 17:50:11)

Command line: -singlerun -if JTAG -select USB -speed 1000 -jtagconf -1,-1 -device FE310 -port 2331
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: FE310
Target interface: JTAG
Target interface speed: 1000kHz
Target endian: little

Connecting to J-Link…
J-Link is connected.
Firmware: J-Link OB-K22-SiFive compiled Nov 22 2019 12:57:38
Hardware: V1.00
S/N: 979014500
Checking target voltage…
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target…
ERROR: Failed to power-up DAP
ERROR: Could not connect to target.
Target connection failed. GDBServer will be closed…Restoring target state and closing J-Link connection…
Shutting down…
undefinedCould not connect to target.
Please check power, connection and settings.
Reading symbols from c:\Users\Nick\Documents\PlatformIO\Projects\Lab 3.pio\build\hifive1-revb\firmware.elf…
PlatformIO Unified Debugger -> http://bit.ly/pio-debug
PlatformIO: debug_tool = jlink
PlatformIO: Initializing remote target…
.pioinit:16: Error in sourced command file:
:2331: No connection could be made because the target machine actively refused it

Both of the error messages you’ve reported seem to have an incorrect JTAG ID “0x00000001”. I’m expecting a JTAG ID: 0x20000913 for the HiFive1 revB. The JTAG ID is read from the FE310 by the J-Link debugger using JTAG interface on HiFive1 rev B.

It does appear that you have connectivity from host machine to HiFive1 rev B because J-Link firmware is being reported.

You could try the “Bootloader recovery” mentioned in the getting started guide in case there’s something in the program of HiFive1 rev B that’s causing the issue. https://sifive.cdn.prismic.io/sifive%2F4f5a7851-1b52-463b-a293-f352036bc809_hifive1b-getting-started-guide_v1.1.pdf

This is an example of a successful connection with the same command line parameters that you seem to be using:

jims@jims-NUC7i5DNHE:/opt/SEGGER/JLink_V646c$ JLinkGDBServer -singlerun -if JTAG -select USB -speed 1000 -jtagconf -1,-1 -device FE310 -port 2331
SEGGER J-Link GDB Server V6.46c Command Line Version

JLinkARM.dll V6.46c (DLL compiled Jun 3 2019 18:36:33)

Command line: -singlerun -if JTAG -select USB -speed 1000 -jtagconf -1,-1 -device FE310 -port 2331
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: yes
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: FE310
Target interface: JTAG
Target interface speed: 1000kHz
Target endian: little

Connecting to J-Link…
J-Link is connected.
Firmware: J-Link OB-K22-SiFive compiled Jul 30 2019 12:24:12
Hardware: V1.00
S/N: 979000015
Checking target voltage…
Target voltage: 3.30 V
Listening on TCP/IP port 2331
Connecting to target…
J-Link found 1 JTAG device, Total IRLen = 5
JTAG ID: 0x20000913 (RISC-V)
Connected to target
Waiting for GDB connection…

@BrokeStudent1 are you using good, capable and well-filtered power adapters for the HiFive? Do you use the raspberry pi or other pc like a desktop?
Barring power supply issues, it looks like there something mis-configured in the jtag adapter interface. In openocd, this is in a .cfg file

@pds the HiFive1 rev B doesn’t use OpenOCD by default because it has and integrated Segger J-Link debugger.

The original HiFive1 board used OpenOCD but @BrokeStudent1 seems to be using HiFive1 rev B based on the subject of this thread.