# Issues uploading code to Hifive1 revb via jlink

**URL:** <https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342>\
**Category:** HiFive1 Rev B\
**Created:** [May 17, 2019, 11:36pm UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342 "2019-05-17T23:36:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![penguinwashere](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/penguinwashere/32/683_2.png) [@penguinwashere](https://forums.sifive.com/u/penguinwashere)\
**Post date:** [May 17, 2019, 11:36pm UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342/1 "2019-05-17T23:36:49Z")

</div>

If I try and upload to the board, I get the following errors:

> Failed to execute MI command:  
> tbreak main  
> Error message from debugger back end:  
> Cannot access memory at address 0x20010188  
> Failed to execute MI command:  
> tbreak main  
> Error message from debugger back end:  
> Cannot access memory at address 0x20010188  
> Cannot access memory at address 0x20010188

I have already installed the Jlink drivers and software. If I type “lsusb” into my terminal, I can clearly see my device enumerating as a JLink USB device:

Bus 001 Device 011: ID 1366:1051 SEGGER

Is there anything I can do to troubleshoot this? Or is my board simply dead? I can load the serial terminal just fine, and I see the SiFive welcome text as I should. I just can’t upload to the board.

---

<div class="post-metadata">

**Author:** ![thornschuh](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/thornschuh/32/134_2.png) [@thornschuh](https://forums.sifive.com/u/thornschuh)\
**Post date:** [May 18, 2019, 11:46pm UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342/2 "2019-05-18T23:46:56Z")

</div>

It would help to have some additional information.  
Which command are you using?  
Which OS are you using?

Which program you try to upload?

---

<div class="post-metadata">

**Author:** ![yksflip](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yksflip](https://forums.sifive.com/u/yksflip)\
**Post date:** [May 20, 2019, 8:41am UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342/3 "2019-05-20T08:41:06Z")

</div>

I’m experiencing the same error, [see](http://forums.sifive.com/t/freedomstudio-jlink-debugging-fails/2320).  
Did you try using the jlink tool from the terminal?

```auto
freedom-e-sdk/scripts/upload --hex ~/wsFreedomStudio/test/src/debug/hello.hex --jlink JLinkExe

```

You could also try to upload a hex file by copying it to the usb flash device that should be present when you connect your board.

---

<div class="post-metadata">

**Author:** ![penguinwashere](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/penguinwashere/32/683_2.png) [@penguinwashere](https://forums.sifive.com/u/penguinwashere)\
**Post date:** [May 22, 2019, 5:38pm UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342/4 "2019-05-22T17:38:17Z")

</div>

Sorry I haven’t responded. I haven’t given up. I’m putting together a giant log of useful stuff, but for the time being heres some info:

OS: Linux (Arch)  
Command: I’ve tried uploading via FreedomStudio IDE and the command line. Heres the actual command:  
make BSP=metal [PROGRAM=hello] [TARGET=sifive-hifive1-revb] upload

The errors I get when I run that are here:  
/bin/sh: riscv64-unknown-elf-gcc: command not found  
make[1]: \*\*\* [Makefile:982: src/drivers/libriscv\_\_mmachine\_\_sifive-hifive1\_a-fixed-clock.o] Error 127  
make[1]: Leaving directory ‘/home/penguin/FreedomStudio/SiFive/freedom-e-sdk/freedom-e-sdk-v201903/bsp/sifive-hifive1/build/debug’  
make: \*\*\* [scripts/libmetal.mk:34: /home/penguin/FreedomStudio/SiFive/freedom-e-sdk/freedom-e-sdk-v201903/bsp/sifive-hifive1/install/lib/debug/stamp] Error 2

I have the riscv toolchain. I just dont know what I need to export its location as.

---

<div class="post-metadata">

**Author:** ![thornschuh](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/thornschuh/32/134_2.png) [@thornschuh](https://forums.sifive.com/u/thornschuh)\
**Post date:** [May 22, 2019, 7:21pm UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342/5 "2019-05-22T19:21:19Z")

</div>

The error message clearly states the problem:  
Make does not find the gcc executable.

You need to set the RISCV\_PATH environment variable as described in the readme for the freedom sdk:

> **[sifive/freedom-e-sdk](https://github.com/sifive/freedom-e-sdk)**
>
> Open Source Software for Developing on the Freedom E Platform - sifive/freedom-e-sdk

This detail is not described in the HiFive rev B getting started guide

---

<div class="post-metadata">

**Author:** ![penguinwashere](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/penguinwashere/32/683_2.png) [@penguinwashere](https://forums.sifive.com/u/penguinwashere)\
**Post date:** [May 22, 2019, 9:36pm UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342/6 "2019-05-22T21:36:59Z")

</div>

Alright I look like an idiot, and I probably am one, BUT I have some context to this. Originally I had the riscv64-unknown-elf-gcc + riscv64-unknown-elf-binutils installed from AUR. Apparently these don’t work with the revb (or sifive boards in general?). So I uninstalled this, and I did as you said and now I think I’m just stuck on getting jlink to push from the terminal. So I think my problems are solved. Thank you!

Nevermind, I also got jlink uploading to work, thanks to [yksflip](http://forums.sifive.com/u/yksflip)

---

<div class="post-metadata">

**Author:** ![bruce](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/bruce/32/452_2.png) [@bruce](https://forums.sifive.com/u/bruce)\
**Post date:** [May 22, 2019, 11:26pm UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342/7 "2019-05-22T23:26:43Z")

</div>

The meaning of “AUR” eludes me?

A generic gcc toolchain will work fine for application code on SiFive chips and boards, including the HiFive1 RevB.

In particular I think only a generic toolchain is needed for the old v1\_0 branch of the freedom-e-sdk. Sadly we don’t have a BSP for the RevB there.

The new “Metal” library in the master branch of freedom-e-sdk (where we do have a BSP for the RevB) directly refers to some interrupt controller CSRs that are proposed to be a future RISC-V standard, but aren’t yet, and generic gcc doesn’t yet know about them.

---

<div class="post-metadata">

**Author:** ![penguinwashere](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/penguinwashere/32/683_2.png) [@penguinwashere](https://forums.sifive.com/u/penguinwashere)\
**Post date:** [May 23, 2019, 2:19am UTC](https://forums.sifive.com/t/issues-uploading-code-to-hifive1-revb-via-jlink/2342/8 "2019-05-23T02:19:34Z")

</div>

Sorry, the AUR is the Arch User Repository.  
When running this command with the toolchain from the AUR:  
**“make BSP=metal [PROGRAM=hello] [TARGET=sifive-hifive1-revb] upload”**

I get the following errors:

**/home/penguin/FreedomStudio/SiFive/freedom-e-sdk/freedom-e-sdk-v201903/freedom-metal/src/drivers/riscv,cpu.c: Assembler messages:**  
**/home/penguin/FreedomStudio/SiFive/freedom-e-sdk/freedom-e-sdk-v201903/freedom-metal/src/drivers/riscv,cpu.c:139: Error: unknown CSR `mtvt'</b> <b>/home/penguin/FreedomStudio/SiFive/freedom-e-sdk/freedom-e-sdk-v201903/freedom-metal/src/drivers/riscv,cpu.c:161: Error: unknown CSR `mtvt’**  
**/home/penguin/FreedomStudio/SiFive/freedom-e-sdk/freedom-e-sdk-v201903/freedom-metal/src/drivers/riscv,cpu.c:165: Error: unknown CSR `mtvt’**  
**make[1]: \*\*\* [Makefile:1010: src/drivers/libriscv\_\_mmachine\_\_sifive-hifive1\_a-riscv,cpu.o] Error 1**  
**make[1]: Leaving directory ‘/home/penguin/FreedomStudio/SiFive/freedom-e-sdk/freedom-e-sdk-v201903/bsp/sifive-hifive1/build/debug’**  
**make: \*\*\* [scripts/libmetal.mk:34: /home/penguin/FreedomStudio/SiFive/freedom-e-sdk/freedom-e-sdk-v201903/bsp/sifive-hifive1/install/lib/debug/stamp] Error 2**

These errors don’t occur if I use the toolchain provided with Freedom Studio.  
Sources:

> [@Building Hello World on Freedem-E-SDK fails with "unknown CSR \`mtvt'"](http://forums.sifive.com/t/building-hello-world-on-freedem-e-sdk-fails-with-unknown-csr-mtvt/2353/2):
>
> You have to use a SiFive toolchain, because freedom-e-sdk requires support for the proposed CLIC extension, which is only supported in SiFive toolchains currently, because it is still a proposal. mtvt is one of the CSRs added by the CLIC extension. CLIC support is needed even if you are building for a target that doesn’t support the CLIC extension. There is an open issue for that problem, reported against freedom-metal I think. You can download binaies from our web site. Or you can check ou…

and me trying it =P
