rm-hull/luma.led_matrix

Failed to find SPI device? But OS believes the device exists?

Closed this issue · 1 comments

Pi OS 11, latest, patched, firmware latest official version, Pi Model B 1, yes older Pi, but solid thus far, still believe so. Attempted to run examples/sevensegment_demo,py got the following error:

# uname -a
Linux template 5.15.84+ #1613 Thu Jan 5 11:58:09 GMT 2023 armv6l GNU/Linux
# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

# python --version
Python 3.9.2

# python3 -m pip --version
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)

Steps to recreate issue...

# cd ~
# python3 -m pip install --upgrade luma.led_matrix
# git clone https://github.com/rm-hull/max7219.git
# cd max7219/
# python3 examples/sevensegment_demo.py
Traceback (most recent call last):
File "/root/max7219/examples/sevensegment_demo.py", line 13, in
from luma.led_matrix.device import max7219
File "/usr/local/lib/python3.9/dist-packages/luma/led_matrix/device.py", line 38, in
from luma.core.device import device
File "/usr/local/lib/python3.9/dist-packages/luma/core/device.py", line 9, in
from PIL import Image
File "/usr/local/lib/python3.9/dist-packages/PIL/Image.py", line 103, in
from . import _imaging as core
ImportError: libopenjp2.so.7: cannot open shared object file: No such file or directory

# apt-file search libopenjp2
libopenjp2-7: /usr/lib/arm-linux-gnueabihf/libopenjp2.so.2.4.0
libopenjp2-7: /usr/lib/arm-linux-gnueabihf/libopenjp2.so.7
libopenjp2-7: /usr/share/doc/libopenjp2-7/changelog.Debian.gz
libopenjp2-7: /usr/share/doc/libopenjp2-7/changelog.gz
libopenjp2-7: /usr/share/doc/libopenjp2-7/copyright

Tried, seems to resolve issue with missing library but then error that SPI not enabled...

# pip3 install --upgrade pip *** not sure this was required just did as sanity check pip3 seemed old ***
pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)
root@template:~# pip3 install --upgrade pip
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pip in /usr/lib/python3/dist-packages (20.3.4)
Collecting pip
Downloading https://www.piwheels.org/simple/pip/pip-23.0.1-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 177 kB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.3.4
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-23.0.1

# apt install libopenjp2-7
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libgnutls-dane0 libunbound8 raspinfo
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
libopenjp2-7
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 150 kB of archives.
After this operation, 412 kB of additional disk space will be used.
Get:1 http://raspbian.phirephly.design/raspbian bullseye/main armhf libopenjp2-7 armhf 2.4.0-3 [150 kB]
Fetched 150 kB in 1s (107 kB/s)
Selecting previously unselected package libopenjp2-7:armhf.
(Reading database ... 132335 files and directories currently installed.)
Preparing to unpack .../libopenjp2-7_2.4.0-3_armhf.deb ...
Unpacking libopenjp2-7:armhf (2.4.0-3) ...
Setting up libopenjp2-7:armhf (2.4.0-3) ...
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u5) ...

Next issue...

# python3 examples/sevensegment_demo.py
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/luma/core/interface/serial.py", line 309, in init
self._spi.open(port, device)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/max7219/examples/sevensegment_demo.py", line 117, in
main()
File "/root/max7219/examples/sevensegment_demo.py", line 71, in main
serial = spi(port=0, device=0, gpio=noop())
File "/usr/local/lib/python3.9/dist-packages/luma/core/interface/serial.py", line 320, in init
raise luma.core.error.DeviceNotFoundError('SPI device not found')
luma.core.error.DeviceNotFoundError: SPI device not found

SPI is enabled per the system configuration...

# raspi-config nonint get_spi
0

# lsmod | grep spi
bmp280_spi 16384 0
bmp280 20480 2 bmp280_spi,bmp280_i2c
spidev 20480 0
spi_bcm2835 20480 0

# ls -l /dev/spidev0.*
crw-rw---- 1 root spi 153, 0 Mar 6 02:59 /dev/spidev0.1

Any assistance or suggestions welcome, thanks.

Found the issue, one of the active dtoverlay (devices) was taking control of 0.0. Once I removed the dtoverlay, device 0.0 appeared as expected after reboot.