Issue uploading code with Jlink: Error while determining flash info (Bank @ 0x20000000)

Hello!

I’ve been developing on the hifive1 revb for several months now and I’ve been successfully writing code and uploading hex format binaries to the board. The forums have been very helpful too!

Starting a couples days ago (April 1?) I setup my environment on a different computer than what I had been using and followed the same steps I had used previously. Everything worked out and I’ve been writing and uploading on my new setup just fine for the past 24 hours or so. However, just today I started to get an error on jlink upload:

...
Detected: RV32 core
CSR access via abs. commands: No
Temp. halted CPU for NumHWBP detection
HW instruction/data BPs: 0
Support set/clr BPs while running: No
BG memory access support: No
RISC-V identified.
Downloading file [target/riscv32imac-unknown-none-elf/debug/examples/hello_world.hex]...

****** Error: Failed to prepare for programming.
Could not preserve target memory.
Error while determining flash info (Bank @ 0x20000000)
Unspecified error -1
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 5, IRPrint = 0x01
JTAG chain detection found 1 devices:
 #0 Id: 0x20000913, IRLen: 05, Unknown device
Debug architecture:
  RISC-V debug: 0.13
  AddrBits: 7
  DataBits: 32
  IdleClks: 5
Memory access:
  Via system bus: No
  Via ProgBuf: Yes (16 ProgBuf entries)
  Via abstract command (AAM): May be tried as last resort
...

I’m using Jlink version 7.64 which is from April 1. In fact, when I ran an upload for the first time on my new setup jlink told me I should upgrade the firmware, and so I did. This is the output regarding the versions:

SEGGER J-Link Commander V7.64 (Compiled Apr  1 2022 16:09:33)
DLL version V7.64, compiled Apr  1 2022 16:09:18

Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-K22-SiFive compiled Jul 23 2021 12:54:10
Hardware version: V1.00
S/N: 979015578
VTref=3.300V
Device "FE310" selected.

A Segger forum post suggests that it’s an old version of Jlink, however I have the latest, only 2 days old: [SOLVED] Error while determining flash info - J-Link/Flasher related - SEGGER - Forum

But the version correction for that forum poster seems to have worked. I wonder, is my jlink version too new? Anyone else have similar issues?

Thanks for any help,
Eric

Hi Eric,

I just downloaded JLink 7.64 and it is working fine on my Hifive1RevB target using the ‘hello’ example from freedom-e-sdk using Freedom Studio.

Are you using Freedom Studio or a CLI environment (looks like maybe CLI)?
What is your host env (Linux, Windows, Mac, should not matter, but just good to know)?
Is the Hifive1RevB the only Jlink connected target on your system?
Is this the very same example project that was working up until today?

-Kevin

One more thought. Have you tried booting in safe mode before trying to connect the debugger?

From the Hifive1RevB User Guide:

To activate “safe” boot mode, press the RESET button. When the green LED flashes, immediately press the RESET button again. After 1 second, the red LED will blink. The user program will not execute, and the programmer can connect. To exit “safe” boot mode, press the RESET button a final time.

I’m using a CLI environment. I don’t totally remember where I grabbed the scrip from at this point to upload(I imagine from a sifive example project), but this is the script I’m using: rustbox-hifive1-revb/upload at main · rustbox/rustbox-hifive1-revb · GitHub, and I use scripts/upload --hex path/to/code.hex --jlink JLinkExe.

I’m also using Linux mint 20, and yes, the hifive1 revb is the only thing connected via jlink, and it was all the same project up until things got wonky. I tried to upload an example “hello world” program and the jlink “error while determining flash” error continued to prevent further uploads.

I haven’t booted in safe mode and connected with the debugger. I’ll try that. What’s the best way to get connected with the debugger? I haven’t had an opportunity to connect yet with the debugger. Thanks!

Hi Eric @dougli1sqrd this happens to me all the time when I change hosts and platforms. I use OpenOCD and have made its tcl scripts a little bit more intuitive with its output. See the cfg file here Dystifying OpenOCD
Note some improvements and fixes in the subbranch of that github link.
Of course, you would specify -f interface/jlink/… or something like that; I use ftdi/olimex/…

In the init stage, there’s some critical assertion widths and (post-init) delays. Most likely, one or more of these timings are not long enough for your new platform.

Also, check the GND connection! is it only a thin wire in or beside the jlink usb cable? You might attach a more solid ground to host chassis, if so. Electrical noise or unstable ground goves me these messages that you show.