I would expect this to be an easy question, but it has been beating me severely about the head and shoulders for the past week. I am running the 11.7 iot emmc flasher version (5.10) on a BBB. I have installed smbus2 If I attempt to use uboot_overlay_addr4=/lib/firmware/ADAFRUIT-SPI0-00A0.dtbo in the uEnv.txt file it doesn’t seem to work. I have switched to uboot_overlay_addr4=/lib/firmware/BB-SPIDEV0-00A0.dtbo. I am working out of VScode if that makes a difference. on just my SPI loopback test I get the following:
debian@BeagleBone:/dev$ python -u “/home/debian/examples/BeagleBone/test-spi.py”
Traceback (most recent call last):
File “/home/debian/examples/BeagleBone/test-spi.py”, line 11, in
spi = SPI(0,0)
PermissionError: [Errno 13] Permission denied
debian@BeagleBone:/dev$ sudo python -u “/home/debian/examples/BeagleBone/test-spi.py”
[32, 11, 110, 22, 220]
so I am not sure how to get the code window to run in sudo… Then the next issue pops up if I try to add smbus2 to the test.
debian@BeagleBone:/etc/udev/rules.d$ python -u “/home/debian/examples/BeagleBone/test-spi.py”
Traceback (most recent call last):
File “/home/debian/examples/BeagleBone/test-spi.py”, line 12, in
spi = SPI(0,0)
PermissionError: [Errno 13] Permission denied
debian@BeagleBone:/etc/udev/rules.d$ sudo python -u “/home/debian/examples/BeagleBone/test-spi.py”
Traceback (most recent call last):
File “/home/debian/examples/BeagleBone/test-spi.py”, line 2, in
import smbus2
ModuleNotFoundError: No module named ‘smbus2’
at this point my test code looks like this:
from Adafruit_BBIO.SPI import SPI
import smbus2
From Adafruit Learning System:
SPI | Setting up IO Python Library on BeagleBone Black | Adafruit Learning System
#spi = SPI(bus, device) #/dev/spidev.
#spi = SPI(0,0) #/dev/spidev1.0
#spi = SPI(0,1) #/dev/spidev1.1
#spi = SPI(1,0) #/dev/spidev2.0
#spi = SPI(1,1) #/dev/spidev2.1
bus = smbus2.SMBus(1)
spi = SPI(0,0)
spiResponse= spi.xfer2([32, 11, 110, 22, 220])
print (spiResponse)
spi.close()
So how is it that smbus2 only runs not as root, and SPI on runs as root?
debian@BeagleBone:/dev$ ls /dev/spi* -al
crw-rw---- 1 root spi 153, 0 Sep 2 18:02 /dev/spidev0.0
crw------- 1 root root 153, 1 Sep 2 18:02 /dev/spidev0.1
crw------- 1 root root 153, 2 Sep 2 18:02 /dev/spidev1.0
crw------- 1 root root 153, 3 Sep 2 18:02 /dev/spidev1.1