SiFive have made available pre-built versions of GCC and openocd on their boards page. You can visit that page and scroll down until you find the GCC and openocd links, or you can use these convenience links below (which I’ll try to keep updated):
- riscv-openocd-0.10.0-2019.02.0 for Windows (64-bit)
- riscv-openocd-0.10.0-2019.02.0 for macOS (64-bit)
- riscv-openocd-0.10.0-2019.02.0 for Linux (CentOS 6 64-bit)
- riscv-openocd-0.10.0-2019.02.0 for Linux (Ubuntu 64-bit)
If, for whatever reason, this doesn’t work for you, you could try using an older version. See the next section.
Because the HiFive1 is intended to have at least some Arduino compatibility – it has the right form factor the shields, for instance – SiFive have made pre-built binary versions of the GCC toolchain and the RISC-V port of
openocd available for consumption by the Arduino IDE.
But we can use them too!
Here is how. First, download the
package_sifive_index.json file that the IDE uses to find the toolchain and debug binaries. Currently the freedom-e-sdk repo shows that we want
openocd at commit 9bab0782, so, using
less or the editor of your choice, search for that commit string in the JSON file you just downloaded.
You’ll find several choices of binary packages to download: for x86 and x86_64 Linux, and x86_64 Apple Darwin (OSX). Download the one that suits you. I think you can use HTTPS even though the URLs specify HTTP. If you are careful, you probably want to check the SHA256 hash of the downloaded archive against the one in the packages file. If it matches, untar it somewhere.
Unfortunately, we are not yet done.
openocd has been dynamically-linked against
libusb. The OSX binary points to
/usr/local/opt/, suggesting that the builder had used Homebrew. The Linux versions simply reference
libusb-1.0.so, hoping to find it somewhere on the load path.
I run NixOS on my laptop, and use Nix and nixpkgs on my Mac, so my solution(s) may not map well to your situation, but here is what I did.
On my Mac, I installed
libusb1 via Nix and then created symlinks in
/usr/local/opt/. (If you already use Homebrew, simply use it to install
libusb and you should be good to go.)
On NixOS, it’s possible to use
patchelf to rewrite both the ELF interpreter and the RPATH of the
openocd executable. There is some discussion of this technique here.
For non-NixOS Linux users, simply installing
libusb via your package manager should be sufficient.
You’re done! You’ve now got a working copy of
openocd that you can use with muforth and RISC-V platforms.