SPI device in linux

Hey folks,
My VIM4 does not show any SPI device in linux by default.
The dtb appears to have SPI controllers in it, but not sure if they are mapped anywhere onto the GPIO pins.

Is it possible (with some overlay) to enable/use SPI in linux on the VIM4 using the standard spi device interface the kernel provides?

Hello @dberlin

It seems that, this part is missing at this moment, we will add support in next release.


Thanks - none of the SPI devices are marked as status=“okay”, and it’s not obvious from the pinmux controls which ones are expose on the GPIO. Only one has a comment :slight_smile:

I"m happy to write an overlay file manually if y’lal let me know which one it is.

You can try the steps below:

Install the new package to spport spi.

$ wget https://dl.khadas.com/.test/linux-dtb-amlogic-5.4_1.1.1_arm64.deb
$ wget https://dl.khadas.com/.test/khadas-vim4-linux-5.4-dt-overlays_1.0~20220629_arm64.deb
$ sudo dpkg -i linux-dtb-amlogic-5.4_1.1.1_arm64.deb khadas-vim4-linux-5.4-dt-overlays_1.0~20220629_arm64.deb

Enable spidev via overlay, edit file /boot/dtb/amlogic/kvim4.dtb.overlay.env, add spi0 to node fdt_overlays.

$ cat /boot/dtb/amlogic/kvim4.dtb.overlay.env

Save and reboot. You can find the spi node /dev/spidev1.0.

$ ls /dev/spidev1.0 

Thanks - seems to work at a glance, gonna hook up a few more peripherals, but i expect thtey’ll work fine as well

1 Like

Which pins are used for SPI0? I’m not super knowledgeable when it comes to determining the proper pins. I’m would like to interface a can bus. Thanks.

Hello @BrightPrincess

You can check the schematic here: https://dl.khadas.com/products/vim4/schematic/vim4_v12_sch.pdf


  • PIN25 - SPI_A_SCLK
  • PIN26 - SPI_A_SS0
  • PIN36 - SPI_A_MOSI
  • PIN37 - SPI_A_MISO
1 Like

Thank you for the information!