Just tried this out…
- enable overlay
- install python3-spidev
- fix permissions
- test
Enable overlay
Edited /boot/firmware/extlinux/extlinux.conf to add overlay “k3-am67a-beagley-ai-spidev0.dtbo”:
menu title BeagleY-AI microSD (extlinux.conf) (swap enabled)
timeout 50
default microSD (default)
label microSD (production test)
kernel /Image
append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0 quiet
fdtdir /
fdt /ti/k3-am67a-beagley-ai.dtb
fdtoverlays /overlays/k3-am67a-beagley-ai-hdmi-dss0-dpi1.dtbo /overlays/k3-am67a-beagley-ai-lincolntech-185lcd-panel.dtbo /overlays/k3-am67a-beagley-ai-csi0-imx219.dtbo /overlays/k3-am67a-beagley-ai-csi1-imx219.dtbo
#initrd /initrd.img
label transfer microSD rootfs to NVMe (advanced)
kernel /Image
append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0 init=/usr/sbin/init-beagle-flasher-mv-rootfs-to-nvme
fdtdir /
fdt /ti/k3-am67a-beagley-ai.dtb
initrd /initrd.img
label microSD (debug)
kernel /Image
append console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02800000 root=/dev/mmcblk1p3 ro rootfstype=ext4 rootwait net.ifnames=0
fdtdir /
fdt /ti/k3-am67a-beagley-ai.dtb
#initrd /initrd.img
label microSD (default)
kernel /Image
append console=ttyS2,115200n8 root=/dev/mmcblk1p3 ro rootfstype=ext4 resume=/dev/mmcblk1p2 rootwait net.ifnames=0 quiet
fdtdir /
fdt /ti/k3-am67a-beagley-ai.dtb
fdtoverlays /overlays/k3-am67a-beagley-ai-spidev0.dtbo
#initrd /initrd.img
Then I rebooted:
sudo shutdown -r now
Install python3-spidev
By default, I didn’t see this python library installed, so my import was failing.
sudo apt-get update
sudo apt-get install -y python3-spidev
Fix permissions
By default, the /dev/spidev* files were not accessible by the default user.
sudo chmod ugo+rwx /dev/spidev*
Test
beagle@beagle:~$ python3
Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import spidev
>>> x = spidev.SpiDev()
>>> x.open(0,0)
>>> x
<SpiDev object at 0xffff8a88ad90>
>>> dir(x)
['__class__', '__delattr__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'bits_per_word', 'close', 'cshigh', 'fileno', 'loop', 'lsbfirst', 'max_speed_hz', 'mode', 'no_cs', 'open', 'read0', 'readbytes', 'threewire', 'writebytes', 'writebytes2', 'xfer', 'xfer2', 'xfer3']
I don’t have any SPI devices connected right now, so I don’t know if I can generate any traffic.
Let me know how it goes!