adafruit / adafruit-beaglebone-io-python

Adafruit's BeagleBone IO Python Library
http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black
477 stars 217 forks source link

SPIDEV ABI change on mainline Linux kernel #263

Open pdp7 opened 6 years ago

pdp7 commented 6 years ago

FYI - a solution will need to be decided upon for libraries like Adafruit_BBIO

---------- Forwarded message ----------
From: Robert Nelson 
Date: Tue, Jun 26, 2018 at 11:03 AM
Subject: [beagle-alpha] SPIDEV abi change on mainline

Mainline:

debian@beaglebone:~$ ls /sys/devices/platform/ocp/48030000.spi/spi_master/spi*/
device  of_node  power  spi0.0  spi0.1  statistics  subsystem  uevent
debian@beaglebone:~$ ls /sys/devices/platform/ocp/481a0000.spi/spi_master/spi*/
device  of_node  power  spi1.0  spi1.1  statistics  subsystem  uevent
debian@beaglebone:~$ ls /dev/spidev*
/dev/spidev0.0  /dev/spidev0.1  /dev/spidev1.0  /dev/spidev1.1

v4.1.x -> v4.9.x

debian@beaglebone:~$ ls /sys/devices/platform/ocp/48030000.spi/spi_master/spi*/
device  of_node  power  spi1.0  spi1.1  statistics  subsystem  uevent
debian@beaglebone:~$ ls /sys/devices/platform/ocp/481a0000.spi/spi_master/spi*/
device  of_node  power  spi2.0  spi2.1  statistics  subsystem  uevent
debian@beaglebone:/sys/devices/platform/ocp$ ls /dev/spi*
/dev/spidev1.0  /dev/spidev1.1  /dev/spidev2.0  /dev/spidev2.1

v3.8.13:

debian@beaglebone:~$ ls /sys/devices/ocp.*/48030000.spi/spi_master/spi*/
device    power  spi1.0  spi1.1  subsystem  uevent
debian@beaglebone:~$ ls /sys/devices/ocp.*/481a0000.spi/spi_master/spi*/
device  power  spi2.0  spi2.1  subsystem  uevent
debian@beaglebone:~$ ls /dev/spidev*
/dev/spidev1.0  /dev/spidev1.1  /dev/spidev2.0  /dev/spidev2.1

What to Do:

In v4.14.x i'm patching things so it's v4.1.x > v4.9.x compabile..

But, we should change all the libr's to use the "ocp" directory
lookup's shown above..

cc @RobertCNelson

pdp7 commented 6 years ago

For example: /sys/devices/platform/ocp/48030000.spi/spi_master/spi1/spi1.0/ who do I get to the actual character device file that I would open?

@RobertCNelson wrote: spi1.0 -> /dev/spidev1.0 /sys/devices/platform/ocp/*.spi/spi_master/spiX/spiX.Y/ = /dev/spidevX.Y

pdp7 commented 5 years ago

For reference, here is a commit to add the /dev/spi/X.Y properties to device tree: SPIDEV: use symlink label to help udev https://github.com/beagleboard/bb.org-overlays/commit/d21b116ebee9e581428acf2558ebf7a56b37de6c

And udev script that create the corresponding symlinks: https://github.com/mvduin/py-uio/blob/master/etc/udev/rules.d/10-of-symlink.rules

pdp7 commented 4 years ago

FYI - this will solve issues like this one: SPI No such file or directory

322

matthijskooijman commented 4 years ago

I also ran into this problem, which got me a bit by surprise.

However, it does seem the new names make more sense: Now it uses spidev0 and spidev1, which match the labels on the pinout and the overlays (e.g. BB-SPIDEV0-00A0.dtbo). However, it does seem that the /dev/spidev.x.x is rather arbitrary (e.g. like ethx labels used to be), so the new symlinks are probably the best way to target specific spi devices.