Problems with install of software Pi5 SATA HAT Top Board

Help. I can’t get my Penta SATA HAT Top board working correctly on my PI5 w/Bookworm. No fan/display.
I2C is enabled. and it can see it.
But it looks like something is wrong with it running in Python.

Could use some help.

pi@zomv:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – -- – -- – -- – --
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- 3c – -- –
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --

pi@zomv:~ $ sudo systemctl status rockpi-penta.service
○ rockpi-penta.service - Rockpi SATA Hat
Loaded: loaded (/lib/systemd/system/rockpi-penta.service; enabled; preset: enabled)
Active: inactive (dead) since Thu 2024-09-05 20:45:37 CDT; 9min ago
Duration: 1.847s
Process: 1215 ExecStart=/usr/bin/python3 /usr/bin/rockpi-penta/main.py (code=exited, status=0/SUCCESS)
Main PID: 1215 (code=exited, status=0/SUCCESS)
CPU: 132ms

Sep 05 20:45:37 zomv python3[1215]: File “/usr/lib/python3.11/threading.py”, line 975, in run
Sep 05 20:45:37 zomv python3[1215]: self._target(*self._args, **self._kwargs)
Sep 05 20:45:37 zomv python3[1215]: File “/usr/bin/rockpi-penta/fan.py”, line 101, in running
Sep 05 20:45:37 zomv python3[1215]: pin = Gpio(0.025)
Sep 05 20:45:37 zomv python3[1215]: ^^^^^^^^^^^
Sep 05 20:45:37 zomv python3[1215]: File “/usr/bin/rockpi-penta/fan.py”, line 58, in init
Sep 05 20:45:37 zomv python3[1215]: self.line = gpiod.Chip(os.environ[‘FAN_CHIP’]).get_line(int(os.environ[‘FAN_LINE’]))
Sep 05 20:45:37 zomv python3[1215]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 05 20:45:37 zomv python3[1215]: FileNotFoundError: [Errno 2] No such file or directory
Sep 05 20:45:37 zomv systemd[1]: rockpi-penta.service: Deactivated successfully.

I have exactly the same issue here.
I can’t seem to find the reason :confused:

Reinstalling rockpi-penta-0.2.2 package doesn’t seem to help either

It seems that there is confusion on gpio chip 0 or 4.

I solved for me like this

self.line = gpiod.Chip('0').get_line(int(os.environ['FAN_LINE']))

Everything you do - you do so at your own risk

1 Like

Thanks for the tip !
It fixed the FAN not running.

The OLED display is still not working though. I now have the following output for the systemctl status command :

~ $ sudo systemctl status rockpi-penta.service
[sudo] password for korhad:
● rockpi-penta.service - Rockpi SATA Hat
Loaded: loaded (/lib/systemd/system/rockpi-penta.service; enabled; preset: enabled)
Active: active (running) since Mon 2024-09-09 19:30:42 CEST; 1min 16s ago
Main PID: 843 (python3)
Tasks: 3 (limit: 9255)
CPU: 254ms
CGroup: /system.slice/rockpi-penta.service
└─843 /usr/bin/python3 /usr/bin/rockpi-penta/main.py

Sep 09 19:30:42 NASPi python3[843]: from digitalio import DigitalInOut
Sep 09 19:30:42 NASPi python3[843]: File “/usr/local/lib/python3.11/dist-packages/digitalio.py”, line 27, in
Sep 09 19:30:42 NASPi python3[843]: from adafruit_blinka.microcontroller.bcm2712.pin import *
Sep 09 19:30:42 NASPi python3[843]: File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm2712/>
Sep 09 19:30:42 NASPi python3[843]: D0 = Pin((4, 0))
Sep 09 19:30:42 NASPi python3[843]: ^^^^^^^^^^^
Sep 09 19:30:42 NASPi python3[843]: File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_>
Sep 09 19:30:42 NASPi python3[843]: self._chip = gpiod.Chip(str(pin_id[0]), gpiod.Chip.OPEN_BY_NUMBER)
Sep 09 19:30:42 NASPi python3[843]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 09 19:30:42 NASPi python3[843]: FileNotFoundError: [Errno 2] No such file or directory

I would love to know how you managed to find this solution BTW.
I’m not used to python, maybe you solved it by reading the scripts ?

For me I solved it with the change given above and the two changes below:

/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod/libgpiod_pin_1_x.py, line 30

self._chip = gpiod.Chip('0', gpiod.Chip.OPEN_BY_NUMBER)

/usr/bin/rockpi-penta/misc.py, line 110 (for the key)

chip = gpiod.Chip('0')

Everything you do - you do so at your own risk

Searching for a solution I sensed a repetive theme: “pi5 / gpio libraries / gpio chip 0 and 4”.
So my guess was that 4 is not a lucky number and I replaced it based on the errors shown in journalctl with 0 - and I have OLED, fan and key. Why? I have no details on that.
Maybe chatGPT could provide you some more explanations “pi5 mixing gpio chip 0 and 4”

1 Like

You saved my day ! :smiley:

I was almost ready to reinstall the whole thing.
I definitively did not think of looking in journalctl. I’ll make sure to have a look in there and try to understand a bit more on how to debug as you did.

Thanks a lot !

1 Like

What file and line # did you make the adjustment?
libgpiod_pin_1_x.py?

and what did it look like before you made the changes?

for the first recommendation.

Sorry i need a bit more help to understand…

for the second set of changes you recommend. For this line you showed 4?

Below is directly from my machine. and 0 is already there on my config.
self._chip = gpiod.Chip(str(pin_id[0]), gpiod.Chip.OPEN_BY_NUMBER)

and in misc.pi, i currently show this:
chip = gpiod.Chip(str(CHIP_NAME))

so you are overriding the variable all together? yes? and did read like this prior to the change?

and this what journactl shows for me:
: TTY=pts/0 ; PWD=/usr/bin/rockpi-penta ; USER=root ; COMMAND=/usr/bin/systemctl restart rockpi-penta.service
Sep 11 21:09:57 zomv sudo[3418101]: pam_unix(sudo:session): session opened for user root(uid=0) by pi(uid=1000)
Sep 11 21:09:57 zomv systemd[1]: Started rockpi-penta.service - Rockpi SATA Hat.
Sep 11 21:09:57 zomv sudo[3418101]: pam_unix(sudo:session): session closed for user root
Sep 11 21:09:57 zomv python3[3418105]: Traceback (most recent call last):
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/bin/rockpi-penta/main.py”, line 10, in
Sep 11 21:09:57 zomv python3[3418105]: import oled
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/bin/rockpi-penta/oled.py”, line 5, in
Sep 11 21:09:57 zomv python3[3418105]: import adafruit_ssd1306
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/local/lib/python3.11/dist-packages/adafruit_ssd1306.py”, line 17, in
Sep 11 21:09:57 zomv python3[3418105]: from adafruit_bus_device import i2c_device, spi_device
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/spi_device.py”, line 20, in
Sep 11 21:09:57 zomv python3[3418105]: from digitalio import DigitalInOut
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/local/lib/python3.11/dist-packages/digitalio.py”, line 27, in
Sep 11 21:09:57 zomv python3[3418105]: from adafruit_blinka.microcontroller.bcm2712.pin import *
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm2712/pin.py”, line 8, in
Sep 11 21:09:57 zomv python3[3418105]: D0 = Pin((4, 0))
Sep 11 21:09:57 zomv python3[3418105]: ^^^^^^^^^^^
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod/libgpiod_pin_1_x.py”, line 30, in init
Sep 11 21:09:57 zomv python3[3418105]: self._chip = gpiod.Chip(str(pin_id[0]), gpiod.Chip.OPEN_BY_NUMBER)
Sep 11 21:09:57 zomv python3[3418105]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 11 21:09:57 zomv python3[3418105]: FileNotFoundError: [Errno 2] No such file or directory
Sep 11 21:09:57 zomv python3[3418105]: Exception in thread Thread-1 (running):
Sep 11 21:09:57 zomv python3[3418105]: Traceback (most recent call last):
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/lib/python3.11/threading.py”, line 1038, in _bootstrap_inner
Sep 11 21:09:57 zomv python3[3418105]: self.run()
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/lib/python3.11/threading.py”, line 975, in run
Sep 11 21:09:57 zomv python3[3418105]: self._target(*self._args, **self._kwargs)
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/bin/rockpi-penta/fan.py”, line 101, in running
Sep 11 21:09:57 zomv python3[3418105]: pin = Gpio(0.025)
Sep 11 21:09:57 zomv python3[3418105]: ^^^^^^^^^^^
Sep 11 21:09:57 zomv python3[3418105]: File “/usr/bin/rockpi-penta/fan.py”, line 58, in init
Sep 11 21:09:57 zomv python3[3418105]: self.line = gpiod.Chip(os.environ[‘FAN_CHIP’]).get_line(int(os.environ[‘FAN_LINE’]))
Sep 11 21:09:57 zomv python3[3418105]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The errors i am getting quite different. i also, did take another SD card, perform a fresh install of bookworm, and tried to load everything. still did not work. So i have switched back to my original to resolve.

I use the latest system.

cat /proc/version
Linux version 6.6.31+rpt-rpi-2712 (serge@raspberrypi.com) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29)

But it works.
Can you tell me the version of your system.

By the way you can change the file in /etc/rockpi-penta.env.

I’m using DietPi 9.6.1.

Linux version 6.6.47+rpt-rpi-2712 (serge@raspberrypi.com) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 1:6.6.47-1+rpt1 (2024-09-02)

I tried changing the rpi5.env and rockpi-penta.env with effect on fan, but no effect on OLED and key.

Disclaimer: This demonstrates only a temporary workaround.

Taking the journalctl of post above, it points to two failures.

The trace is going down from main.py to oled.py to … to libgpiod_pin_1_x.py
and indicates the file and with ^^^ the line which failed.


Can be workaround with
/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod/libgpiod_pin_1_x.py, line 30

self._chip = gpiod.Chip('0', gpiod.Chip.OPEN_BY_NUMBER)

 
For the second failure (the one from thread start)


Can be workaround with
/usr/bin/rockpi-penta/fan.py, line 58

self.line = gpiod.Chip('0').get_line(int(os.environ['FAN_LINE']))

 
Likely there is as a third one to solve

Can be workaround with
/usr/bin/rockpi-penta/misc.py, line 110

chip = gpiod.Chip('0')

Everything you do - you do so at your own risk

Run sudo apt update and sudo apt full-upgrade will fix this error.

You need to restart after the update, remember to save and back up your important data.

Thank you for pointing to the interesting thread.

The OLED issue remains after upgrade and even with envs on 0 or on 4.

Sep 13 08:54:50 pi5 python3[387]: File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod/libgpiod_pin_1_x.py", line 30, in __init__ Sep 13 08:54:50 pi5 python3[387]: self._chip = gpiod.Chip(str(pin_id[0]), gpiod.Chip.OPEN_BY_NUMBER)

rpi@raspberrypi:~ $ ls -l /dev/gpiochip*
crw-rw----+ 1 root gpio 254,  0 Sep 13 04:33 /dev/gpiochip0
crw-rw----+ 1 root gpio 254, 10 Sep 13 04:33 /dev/gpiochip10
crw-rw----+ 1 root gpio 254, 11 Sep 13 04:33 /dev/gpiochip11
crw-rw----+ 1 root gpio 254, 12 Sep 13 04:33 /dev/gpiochip12
crw-rw----+ 1 root gpio 254, 13 Sep 13 04:33 /dev/gpiochip13
lrwxrwxrwx  1 root root       9 Sep 13 04:33 /dev/gpiochip4 -> gpiochip0
rpi@raspberrypi:~ $ sudo journalctl -u rockpi-penta
Sep 13 04:36:08 raspberrypi systemd[1]: Started rockpi-penta.service - Rockpi SATA Hat.
-- Boot f430a839bc5d4fbc9f90dabba851f8f2 --
Sep 13 04:53:30 raspberrypi systemd[1]: Started rockpi-penta.service - Rockpi SATA Hat.
rpi@raspberrypi:~ $ uname -a
Linux raspberrypi 6.6.47+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.47-1+rpt1 (2024-09-02) aarch64 GNU/Linux

It works on my side. Have you modified anything?

crw-rw---- 1 root gpio 254,  0 Sep 13 09:08 /dev/gpiochip0
crw-rw---- 1 root gpio 254, 10 Sep 13 09:08 /dev/gpiochip10
crw-rw---- 1 root gpio 254, 11 Sep 13 09:08 /dev/gpiochip11
crw-rw---- 1 root gpio 254, 12 Sep 13 09:08 /dev/gpiochip12
crw-rw---- 1 root gpio 254, 13 Sep 13 09:08 /dev/gpiochip13

pi@pi5:~$ sudo journalctl -u rockpi-penta
Sep 13 09:32:06 pi5 systemd[1]: Started rockpi-penta.service - Rockpi SATA Hat.
Sep 13 09:32:06 pi5 python3[2328]: Traceback (most recent call last):
Sep 13 09:32:06 pi5 python3[2328]:   File "/usr/bin/rockpi-penta/main.py", line 10, in <module>
Sep 13 09:32:06 pi5 python3[2328]:     import oled
Sep 13 09:32:06 pi5 python3[2328]:   File "/usr/bin/rockpi-penta/oled.py", line 5, in <module>
Sep 13 09:32:06 pi5 python3[2328]:     import adafruit_ssd1306
Sep 13 09:32:06 pi5 python3[2328]:   File "/usr/local/lib/python3.11/dist-packages/adafruit_ssd1306.py", line 17, in <module>
Sep 13 09:32:06 pi5 python3[2328]:     from adafruit_bus_device import i2c_device, spi_device
Sep 13 09:32:06 pi5 python3[2328]:   File "/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/spi_device.py", line 20, in <module>
Sep 13 09:32:06 pi5 python3[2328]:     from digitalio import DigitalInOut
Sep 13 09:32:06 pi5 python3[2328]:   File "/usr/local/lib/python3.11/dist-packages/digitalio.py", line 27, in <module>
Sep 13 09:32:06 pi5 python3[2328]:     from adafruit_blinka.microcontroller.bcm2712.pin import *
Sep 13 09:32:06 pi5 python3[2328]:   File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm2712/pin.py", line 8, in <module>
Sep 13 09:32:06 pi5 python3[2328]:     D0 = Pin((4, 0))
Sep 13 09:32:06 pi5 python3[2328]:          ^^^^^^^^^^^
Sep 13 09:32:06 pi5 python3[2328]:   File "/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/generic_linux/libgpiod/libgpiod_pin_1_x.py", line 30, in __init__
Sep 13 09:32:06 pi5 python3[2328]:     self._chip = gpiod.Chip(str(pin_id[0]), gpiod.Chip.OPEN_BY_NUMBER)
Sep 13 09:32:06 pi5 python3[2328]:                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 13 09:32:06 pi5 python3[2328]: FileNotFoundError: [Errno 2] No such file or directory

pi@pi5:~$ uname -a
Linux pi5 6.6.47+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.47-1+rpt1 (2024-09-02) aarch64 GNU/Linux

To me it seems at least the expected link to gpiochip0 is missing.
My recent base is DietPi 9.6.1, no modifications.
I noticed during “apt install -y ./rockpi-penta-0.2.2.deb” some messages looking quite similiar to the ones I recorded before on a non DietPi full Debian installion attempt

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. 
It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Created symlink /etc/systemd/system/multi-user.target.wants/rockpi-penta.service → /lib/systemd/system/rockpi-penta.service.
N: Download is performed unsandboxed as root as file '/home/pi/rockpi-penta-v0.2.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)

You might create a symlink yourself, or wait for DietPi to update.

rpi@raspberrypi:~ $ sudo ln -s /dev/gpiochip0 /dev/gpiochip4
rpi@raspberrypi:~ $ sudo systemctl restart rockpi-penta.service

Thanks again.
With symlink created no more workarouds needed.
But after reboot the symlink is lost, how to make it persitent?

Here is a temporary solution

sudo sed -i "2iimport os\ntry: os.symlink(\"/dev/gpiochip0\", \"/dev/gpiochip4\")\nexcept FileExistsError: pass" /usr/bin/rockpi-penta/main.py

Add a symlink when the program starts.

I’m sure DietPi will be updated soon. You may need to reinstall or delete these lines.

1 Like

I am using
Linux version 6.6.47-v8-16k+ (dom@buildbot) (aarch64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1794 SMP PREEMPT Thu Aug 29 16:30:28 BST 2024

i think cat /etc/os-release might show more correctly
cat /etc/os-release

PRETTY_NAME=“Debian GNU/Linux 12 (bookworm)”

NAME=“Debian GNU/Linux”

VERSION_ID=“12”

VERSION=“12 (bookworm)”

VERSION_CODENAME=bookworm

ID=debian

Quick update. full-upgrade fixed it. working now.
It looks like they fixed it in wiring-pi about 4 days ago.

Apparently i just needed to wait… lol.

Thank you.