Giter Club home page Giter Club logo

Comments (8)

ladyada avatar ladyada commented on July 21, 2024 1

nice - yes id rather mess with the pins/spi index definition than the core blinka SPI code. lets keep that neat and organized :)

from adafruit_blinka.

pdp7 avatar pdp7 commented on July 21, 2024

Short-term workaround for spidev path:

Install bone instead of ti kernel:

sudo /opt/scripts/tools/update_kernel.sh --bone-kernel --lts-4_14
reboot

SPI0 is now /dev/spidev0.0:

debian@beaglebone:~$ ls -ltar /dev/spidev*
crw-rw---- 1 root spi 153, 0 Apr 13 13:35 /dev/spidev0.0
crw-rw---- 1 root spi 153, 2 Apr 13 13:35 /dev/spidev1.1
crw-rw---- 1 root spi 153, 1 Apr 13 13:35 /dev/spidev1.0

from adafruit_blinka.

pdp7 avatar pdp7 commented on July 21, 2024

Long-term solution

@RobertCNelson added udev rules to add symlinks that will not change:

  • SPI0.0 will always be /dev/spi/0.0
  • SPI0.1 will always be /dev/spi/0.1
  • SPI1.0 will always be /dev/spi/1.0
  • SPI1.1 will always be /dev/spi/1.1

For reference the udev rule:

debian@beaglebone:/etc/udev/rules.d$ cat 10-of-symlink.rules 
# vim: ft=udevrules

#From: https://github.com/mvduin/py-uio/blob/master/etc/udev/rules.d/10-of-symlink.rules

# allow declaring a symlink for a device in DT

ATTR{device/of_node/symlink}!="", \
	ENV{OF_SYMLINK}="%s{device/of_node/symlink}"

ENV{OF_SYMLINK}!="", ENV{DEVNAME}!="", \
	SYMLINK+="%E{OF_SYMLINK}", \
	TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/dev/%E{OF_SYMLINK}"

With symlink properties added to the device tree, these symlinks are created by udev:

debian@beaglebone:~$ ls -la /dev/spi/
total 0
drwxr-xr-x  2 root root  100 Apr 13 13:35 .
drwxr-xr-x 16 root root 3180 Apr 13 13:35 ..
lrwxrwxrwx  1 root root   12 Apr 13 13:35 0.0 -> ../spidev0.0
lrwxrwxrwx  1 root root   12 Apr 13 13:35 1.0 -> ../spidev1.0
lrwxrwxrwx  1 root root   12 Apr 13 13:35 1.1 -> ../spidev1.1

from adafruit_blinka.

pdp7 avatar pdp7 commented on July 21, 2024

Issue with long-term solution

I'm uncertain of the correct approach to add logic in Adafruit_Blinka to use the /dev/spi/X.Y for BeagleBone and PocketBeagle. Currently, Adafruit_Blinka generic_linux SPI implementation just uses py-spidev Python module and I don't believe has a way to communicate the /dev/ path to use.

In theory, this logic could be added to py-spidev but I am not sure if the maintainer would approve of this approach, and how long it would take to get merged.

from adafruit_blinka.

pdp7 avatar pdp7 commented on July 21, 2024

Possible solution: create SPI class for am335x chip

Currently in busio, detector.board.any_beaglebone uses adafruit_blinka.microcontroller.generic_linux.spi:

    def configure(self, baudrate=100000, polarity=0, phase=0, bits=8):
        if detector.board.any_raspberry_pi:
            from adafruit_blinka.microcontroller.bcm283x.pin import Pin
            from adafruit_blinka.microcontroller.generic_linux.spi import SPI as _SPI
        elif detector.board.any_beaglebone:
            from adafruit_blinka.microcontroller.am335x.pin import Pin
            from adafruit_blinka.microcontroller.generic_linux.spi import SPI as _SPI

However, it is possible to create adafruit_blinka.microcontroller.am335x.spi and then do this:

        elif detector.board.any_beaglebone:
            from adafruit_blinka.microcontroller.am335x.pin import Pin
            from adafruit_blinka.microcontroller.am335x.spi import SPI as _SPI

I think that adafruit_blinka.microcontroller.am335x.spi could just implement the logic to handled the SPI port index and not re-implement everything in adafruit_blinka.microcontroller.generic_linux.spi. I need to experiment and see if that is possible.

from adafruit_blinka.

ladyada avatar ladyada commented on July 21, 2024

hiya the beaglbone maintainers need to fix onto one SPI naming, no other linux board changes the SPI port name - we'll go with whatever the latest is.

from adafruit_blinka.

RobertCNelson avatar RobertCNelson commented on July 21, 2024

@ladyada this situation pisses me off too, from 3.8.x to 4.4.x we dealt with uart/gpio/mmc renaming due to mainline changes. And now spi bit us in the butt with 4.14.x (but i reverted that change) to give us time to build a fix/workaround for 4.19.x. Since for me it's all personal time on this, if i have a choice between mainline and our hacks, i'll drop our patch like a rock (thank god the patchset is getting smaller). Now @jadonk, is proposing a workaround that would also a similar api naming for the incoming BeagleBone AI, such we can lock in something, while mainline will keep renaming things..

https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec

Regards,

from adafruit_blinka.

pdp7 avatar pdp7 commented on July 21, 2024

@RobertCNelson thanks for the explanation.

@ladyada
thanks, your comment made me realize that I can adjust the indexes in spiPorts inside microcontroller/am335x/pin.py

SPI0 is /dev/spidev1.x and SPI1 is /dev/spidev2.x on both:

I think spiPorts should changed from:

# ordered as spiId, sckId, mosiId, misoId
spiPorts = (
    (0, SPI0_SCLK, SPI0_D1, SPI0_D0),
    (1, SPI1_SCLK, SPI1_D1, SPI1_D0),
)

to:

# ordered as spiId, sckId, mosiId, misoId
spiPorts = (
    (1, SPI0_SCLK, SPI0_D1, SPI0_D0),
    (2, SPI1_SCLK, SPI1_D1, SPI1_D0),
)

By the way, the new BeagleBone AI should hopefully launch this Summer. It uses a much more powerful TI Sitara AM5729 SoC but keeps the traditional P8/P9 BeagleBone headers. @jadonk has been working on BeagleBone cape interface spec so that we can have consistency between the new and old BeagleBones.

from adafruit_blinka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.