Arduino Problems

My arduino setup is not able to flash my SiFive. I get the following error:

openocd: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory

I installed libusb-1.0; same error. It would appear that the package is installed:

sudo find / -name ‘libusb-1.0
[…]
/lib/x86_64-linux-gnu/libusb-1.0.so.0
/lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0

Any ideas?

Any ideas?

Try running ldd on the openocd binary to see what happens. This should report info about shared libraries being used. and might give a clue as to what is wrong.

One possibility is that you have a 32-bit openocd binary in which case you would need 32-bit libraries. Try running file on the openocd binary to see what it says.

I just tried ‘which openocd’ and got nothing. I tried running it, and it said it was not installed. So I installed openocd, and now I get this:

robin@robin-VirtualBox:~$ ldd /usr/bin/openocd
linux-vdso.so.1 (0x00007ffe8a9b2000)
libusb-0.1.so.4 => /lib/x86_64-linux-gnu/libusb-0.1.so.4 (0x00007fd6af577000)
libftdi1.so.2 => /usr/lib/x86_64-linux-gnu/libftdi1.so.2 (0x00007fd6af369000)
libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007fd6af151000)
libhidapi-hidraw.so.0 => /usr/lib/x86_64-linux-gnu/libhidapi-hidraw.so.0 (0x00007fd6aef4d000)
libjaylink.so.0 => /usr/lib/x86_64-linux-gnu/libjaylink.so.0 (0x00007fd6aed41000)
libjim.so.0.77 => /usr/lib/x86_64-linux-gnu/libjim.so.0.77 (0x00007fd6aeafd000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd6ae70c000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007fd6ae4ee000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd6ae2cf000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd6ae0cb000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd6afc5b000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd6adec3000)

The Arduino upload still fails with the exact same error message.

Looking at the error message, it would appear that the arduino package installed some version of openocd deep inside its directory structure:

/home/robin/snap/arduino-mhall119/3/.arduino15/packages/sifive/tools/openocd/9bab0782d313679bb0bfb634e6e87c757b8d5503/bin/openocd: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory

Here is the ldd of that version:

ldd /home/robin/snap/arduino-mhall119/3/.arduino15/packages/sifive/tools/openocd/9bab0782d313679bb0bfb634e6e87c757b8d5503/bin/openocd
linux-vdso.so.1 (0x00007ffe54b5c000)
libusb-1.0.so.0 => /lib/x86_64-linux-gnu/libusb-1.0.so.0 (0x00007f5bff7f4000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5bff456000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5bff252000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5bfee61000)
libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007f5bfec43000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5bfea24000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5bffa0c000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5bfe81c000)

Other things: this is a brand new virtual machine running a fresh install of Ubuntu 18.04.

One other strange behavior is that when I connect a minicom to the SiFive and hit reset, I get the superman logo as expected. For some reason though, I can’t type the ‘y’ to indicate that I see the LED fading. The board ignores (or isn’t getting) my keyboard input.

Brand new fresh install of Ubuntu 17.10 has the same result. Arduino builds fine, but can’t upload:

openocd: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory

That is after I installed libusb.

There has to be something simple missing here…

OK, it was simple.

The issue is that I was installing Arduino from the Ubuntu software center. As enticing as it was to install that way, the version in the Ubuntu software center does not work with SiFive, as per what I discovered above. If you want it to work, you MUST install directly from Arduino.com.

To make openocd run on my machine with Ubuntu 18.04 I symlinked /lib/x86_64-linux-gnu/libusb-1.0.so.0 -> libusb-1.0.so.0.1.0