Welcome, Guest

Author Topic: A13-SOM: spidev on OpenWRT  (Read 1172 times)


  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
A13-SOM: spidev on OpenWRT
« on: October 08, 2017, 11:21:37 PM »
Hello all,

in short: I am having a hard time getting spidev to work on an A13-SOM running OpenWRT, I would need some guidance to the best way to get SPI access.

The details:
I am interfacing an MGM111 module by Silabs to an A13-SOM using SPI.
I am using OpenWRT Designated Driver.

Silabs provides a little Linux daemon, called spi-server, for the MGM111. This daemon uses spidev.

As far as I understand I have two options in the kernel: using the SPI gpio bitbanging or the hardware SPI master support. i decided to go for the second option as I would expect it to be the most efficient.
Now, after setting CONFIG_SPI_MASTER=y, CONFIG_SPI_SUN4I=y and CONFIG_SPI_SPIDEV=y in the kernel config (and after having verified that the running kernel actually has them enabled) I still can't get a /dev/spidevn* to show up.
I think I might have to mess around with the device tree dts and/or the fex file, but this is where things get confused: are they both used by OpenWRT on the A13, or does one override the other, or...?

Would the suggested solution be to used gpio bitbanging instead? I don't expect to need extreme performance and I've read that GPIO bitbanging can do 1MHz SPI on the A13, so that should be fine.

However, before going forward I thought I'd ask for advice here.

Thanks in advance,


  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1819
  • Karma: +46/-2
Re: A13-SOM: spidev on OpenWRT
« Reply #1 on: October 09, 2017, 10:37:04 AM »
I can't really provide much help in that regard, yet I recommend you to also check/post in the OpenWRT's forum and maillist.

As you know we use Debian and some old instructions about getting SPI working can be found here: https://www.olimex.com/forum/index.php?topic=835.15

Usually, all it takes from software point of view looks like:

Code: [Select]
spi_used = 1
spi_cs_bitmap = 1
spi_cs0 = port:PE00<4><default><default><default>
spi_sclk = port:PE01<4><default><default><default>
spi_mosi = port:PE02<4><default><default><default>
spi_miso = port:PE03<4><default><default><default>

spi_dev_num = 1

modalias = "spidev"
max_speed_hz = 1000000
bus_num = 2
chip_select = 0
mode = 0
full_duplex = 1
manual_cs = 0

csi_used = 0

and recompile the Kernel
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun5i_defconfig

on menuconfig
<*>   SUN5I SPI Controller                                       │ │ 
  │ │    [*]     SUN5I SPI Normal DMA mode select

 <*>   User mode SPI device driver support

Also don't forget to add pull ups on SDA/SCL lines.
Technical support and documentation manager at Olimex


  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: A13-SOM: spidev on OpenWRT
« Reply #2 on: October 12, 2017, 12:15:24 PM »
Hello LubOlimex,

thanks for the quick response. Unfortunately I can't use the fex file contents as OpenWRT DD has migrated to Linux 4.4, which uses device tree blobs instead of the fex file (I guess it's an improvement, since it's a standardised representation rather than a chip-specific one)

Unfortunately the dts files in the mainline kernel do not include SPI master configuration, but I'm working on it.
When (if) I get it to work I will release them back to OpenWRT and, potentially, to the mainline kernel.