4

I'm trying to get SPI working on my board. That's what I came up:

  • SPI is not enabled by default in armbian, we need to enable it first (enable corresponding DT overlay)
  • in linux SPI can only be accessed via /dev/spidev*.* files
  • if I don't see any spi devices in my dev folder then SPI is not enabled on my board
  • in the latest versions of armbian spi can be enabled in armbain-config (under System/Hardware/spi-spidev)
  • in previous versions it was needed to decompile /boot/script.bin into fex file,  enable SPI there and compile it back

I did clean install of Armbian Bionic (I also did try Stretch earlier), updated it and enabled spi-spidev,  restarted the board but still got no spidev files. 

Here is my armbianmonitor log. That's how I check if SPI is enabled:

dima@orangepipcplus:~$ cat /boot/armbianEnv.txt
verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
rootdev=UUID=09e9478d-c7f2-4b16-a2d7-66f5313ff813
rootfstype=ext4
overlays=spi-add-cs1 spi-jedec-nor spi-spidev
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
dima@orangepipcplus:~$ ls /dev/*spi*
ls: cannot access '/dev/*spi*': No such file or directory

BTW, my goal is to create smart home project with nrf24l01 communication, but I'm stuck on script error that says could not open /dev/spidev0.0 (not exact paste)

So my question is: how to enable spi so that /dev/spidev*.* files will appear?

1
  • 1
    I would guess you would need to edit a dts compile it to a dtb, then swap it with the one uboot is useing (might need to remake a initial-ram-disk if that is in use, and recompile the kernel) Jan 22, 2019 at 21:38

2 Answers 2

4

Okay, this was really stupid. I just needed to read about Device Tree overlays carefully.

I didn't set the required SPI parameter param_spidev_spi_bus. Here is my armbianEnv.txt now:

verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
rootdev=UUID=09e9478d-c7f2-4b16-a2d7-66f5313ff813
rootfstype=ext4
overlays=spi-spidev
param_spidev_spi_bus=0
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

Note that armbain-config does not set this parameter, so you can't get SPI working using this tool only. So for now it's easier just to edit armbianEnv.txt directly.

1

I have an Orange Pi Lite with Armbian installed.I have a MCP3208 analog to digital converter retrieving data from some sensors and I did what rattrapper said, but, in my case, the SPI interface didn't work. I finally solved it doing the following:

  1. In the command line: sudo armbian-config -> system -> hardware -> enable spi-spidev
  2. Check the SPI parameter param_spidev_spi_bus = 0 just like rattraper explained in the file /boot/armbianEnv.txt. In overlays must be spi-spidev written.
  3. Make sure that the library spidev is installed with the following command: sudo pip3 install spidev
  4. Finally, make sure that you are importing the spidev library in your script: import spidev

This is what worked for me, so I hope that it works for you too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .