How to use SPI (easiest way)

Hi,

I’m really new in linux and rockpi4.
I want to use the rockpi4 to address a DAC-converter via SPI.

First I tried Armbian (Raxda Downloads) and used the libmraa-rockpi4 package
(https://wiki.radxa.com/Rockpi4/dev/libmraa). But it’s not possible to download the required packages ( Armbian support, error: mount: mount point vfat does not exist ).

Then I tried with Debian Desktop. Installing libmraa package was no problem. But when I try to test it, I always get the error: Error initialising SPI bus
In another thread it was said that libmraa does not work for armhf. (Enable SPI in Debian)

So now I don’t know how to go on. Is someone using SPI and can help me? Which is the easiest way to usw SPI?

Hi, @Alex

Both Debian desktop and Ubuntu server support libmraa (arm64 and armf).

On ROCK Pi 4, you can use SPI by libmraa. See https://wiki.radxa.com/Rockpi4/dev/libmraa.

when I execute the steps mentioned at this guide, on a Armbian Ubuntu image I can see a slight error after

root@rockpi:~# sudo apt-get install -y rockchip-fstab
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  rockchip-fstab
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1036 B of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://apt.radxa.com/bionic bionic/main arm64 rockchip-fstab all 0.1 [1036 B]
Fetched 1036 B in 0s (3218 B/s)
Selecting previously unselected package rockchip-fstab.
(Reading database ... 30719 files and directories currently installed.)
Preparing to unpack .../rockchip-fstab_0.1_all.deb ...
Unpacking rockchip-fstab (0.1) ...
Setting up rockchip-fstab (0.1) ...
sed: -e expression #1, char 0: no previous regular expression
mount all partitions
mount: vfat: mount point does not exist.
dpkg: error processing package rockchip-fstab (--configure):
 installed rockchip-fstab package post-installation script subprocess returned error exit status 32
Errors were encountered while processing:
 rockchip-fstab
E: Sub-process /usr/bin/dpkg returned an error code (1)

continuing with

sudo apt-get install -y rockpi4-dtbo

worked fine and also

apt-get install rockpi4b-rk-u-boot-latest

but then when I execute

root@rockpi:~# /usr/local/sbin/rockpi4b_upgrade_bootloader.sh
Doing this will overwrite bootloader stored on your boot device. it might break your system.
If this happens you will have to manually fix that outside of your ROCK Pi 4.

You are currently running on different board:
RockPi-4B
It may brick your device or the system unless
you know what are you doing.

Type YES to continue or Ctrl-C to abort.
^C

This sounds too risky to me. Why does it warn when it effectively is a RockPi 4B ?
Is it because Armbian uses a slightly different board model name as the original Radxa Ubuntu ?

When I continue and install

apt-get install libmraa-rockpi4

it seems to work, but

mraa-gpio list

returns “no pins”

also after compiling spi.c to a.out it says

root@rockpi:~# ./a.out
Failed to initialize SPI
1 Like