pimoroni/unicornhatmini-python

Unicornhatmini library broken following the last raspberry update

Cthuga opened this issue · 5 comments

Hello,

Just updated the raspberry pi 4 to the last update this morning, since then :

File "/usr/local/lib/python3.7/dist-packages/unicornhatmini-0.0.1-py3.7.egg/unicornhatmini/init.py", line 56, in init
SystemError: error return without exception set

I tried to reinstall it, but the error stays.

Could you look into it?

What are you running when you encounter this error?

Looks like line 56 is something to do with setting up SPI, in this case changing the polarity of chip select:

Could potentially be a bug with the system itself, or maybe this was just never fully supported.

Is this the latest Raspberry Pi OS, or is it the Raspberry Pi OS 64bit beta?

Nothing much.
It happend as soon, I try to define an object
from unicornhatmini import UnicornHATMini
unicornhatmini = UnicornHATMini()

I'm using the latest Pi OS not the 64bit.

It was working fine this morning, I did :
sudo apt update
sudo apt full-upgrade
sudo reboot

And after that my python program would not work anymore.

I'm not sure if this is a bug in Python SpiDev or a bug in the new Raspberry Pi 5.x kernel. I am looking into it and have reported it upstream here- raspberrypi/linux#3745

Not sure if cshigh = False is actually necessary, or if it's the default, but omitting this line allows the library to work on 5.x. Patch:

diff --git a/library/unicornhatmini/__init__.py b/library/unicornhatmini/__init__.py
index 8cae250..d76204c 100644
--- a/library/unicornhatmini/__init__.py
+++ b/library/unicornhatmini/__init__.py
@@ -53,7 +53,7 @@ class UnicornHATMini():

         for device, pin, offset in self.left_matrix, self.right_matrix:
             device.no_cs = True
-            device.cshigh = False
+            # device.cshigh = False
             device.max_speed_hz = spi_max_speed_hz
             GPIO.setup(pin, GPIO.OUT, initial=GPIO.HIGH)
             self.xfer(device, pin, [CMD_SOFT_RESET])

Thanks you for your help.
I made the comment as sugested, everything is back to normal.

Thanks again.