RockPi Sata Hat Quad

Hi!)
Ubuntu 24.04.01
Raspberry Pi 4
LCD Screen do not work after script installation-

How I can solve this issue ?

Have You turned i2c and spi bus?
Try to run script manually to see what are errors

sa@lilnas:/etc $ sudo systemctl status rockpi-quad.service
● rockpi-quad.service - Rockpi SATA Hat
Loaded: loaded (/lib/systemd/system/rockpi-quad.service; enabled; preset: enabled)
Active: active (running) since Wed 2024-12-04 22:12:48 MSK; 17s ago
Main PID: 10231 (python3)
Tasks: 2 (limit: 8735)
CPU: 243ms
CGroup: /system.slice/rockpi-quad.service
└─10231 /usr/bin/python3 /usr/bin/rockpi-quad/main.py

Dec 04 22:12:48 lilnas python3[10231]: self.__probe_for_device()
Dec 04 22:12:48 lilnas python3[10231]: File “/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py”, line 184, >
Dec 04 22:12:48 lilnas python3[10231]: raise ValueError(“No I2C device at address: 0x%x” % self.device_address)
Dec 04 22:12:48 lilnas python3[10231]: ValueError: No I2C device at address: 0x3c
Dec 04 22:12:48 lilnas python3[10231]: OSError: [Errno 16] Device or resource busy
Dec 04 22:12:48 lilnas python3[10231]: During handling of the above exception, another exception occurred:
Dec 04 22:12:48 lilnas python3[10231]: Traceback (most recent call last):
Dec 04 22:12:48 lilnas python3[10231]: File “/usr/bin/rockpi-quad/fan.py”, line 25, in init
Dec 04 22:12:48 lilnas python3[10231]: with open(f"/sys/class/pwm/{chip}/export", ‘w’) as f:
Dec 04 22:12:48 lilnas python3[10231]: OSError: [Errno 16] Device or resource busy

What is it - i2c and spy bus?

I enabled i2c and spy bus logging in raspy-config -nothing changed

sa@lilnas:~ $ sudo systemctl status rockpi-quad.service
● rockpi-quad.service - Rockpi SATA Hat
Loaded: loaded (/lib/systemd/system/rockpi-quad.service; enabled; preset: enabled)
Active: active (running) since Wed 2024-12-04 22:21:38 MSK; 2min 19s ago
Main PID: 548 (python3)
Tasks: 2 (limit: 8735)
CPU: 412ms
CGroup: /system.slice/rockpi-quad.service
└─548 /usr/bin/python3 /usr/bin/rockpi-quad/main.py

Dec 04 22:21:40 lilnas python3[548]: disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, reset=digitalio.DigitalInOut(RESET))
Dec 04 22:21:40 lilnas python3[548]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 04 22:21:40 lilnas python3[548]: File “/usr/local/lib/python3.11/dist-packages/adafruit_ssd1306.py”, line 245, in init
Dec 04 22:21:40 lilnas python3[548]: self.i2c_device = i2c_device.I2CDevice(i2c, addr)
Dec 04 22:21:40 lilnas python3[548]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 04 22:21:40 lilnas python3[548]: File “/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py”, line 62, in >
Dec 04 22:21:40 lilnas python3[548]: self.__probe_for_device()
Dec 04 22:21:40 lilnas python3[548]: File “/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py”, line 184, in>
Dec 04 22:21:40 lilnas python3[548]: raise ValueError(“No I2C device at address: 0x%x” % self.device_address)
Dec 04 22:21:40 lilnas python3[548]: ValueError: No I2C device at address: 0x3c

Script version 0.3.0

How I can do that?

this is easy, service definition is:

~# find /etc/ | grep sata
/etc/rockpi-sata.conf
/etc/systemd/system/multi-user.target.wants/rockpi-sata.service


~# cat /etc/systemd/system/multi-user.target.wants/rockpi-sata.service
[Unit]
Description=Rockpi SATA Hat
After=pigpiod.service

[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/bin/rockpi-sata/main.py on
ExecStop=/usr/bin/python3 /usr/bin/rockpi-sata/main.py off
Restart=on-failure
WorkingDirectory=/usr/bin/rockpi-sata

[Install]
WantedBy=multi-user.target

so it’s as easy as:

cd /usr/bin/ && /usr/bin/python3 /usr/bin/rockpi-sata/main.py on

I have there rockpi-quad.conf and rock-quad.env and

     root@lilnas:/home/sa# cd /usr/bin/ && /usr/bin/python3 /usr/bin/rockpi-quad/main.py on

Traceback (most recent call last):
File “/usr/bin/rockpi-quad/misc.py”, line 58, in read_conf
conf[‘fan’][‘lv0’] = cfg.getfloat(‘fan’, ‘lv0’)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/configparser.py”, line 839, in getfloat
return self._get_conv(section, option, float, raw=raw, vars=vars,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/configparser.py”, line 824, in _get_conv
return self._get(section, conv, option, raw=raw, vars=vars,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/configparser.py”, line 819, in _get
return conv(self.get(section, option, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/configparser.py”, line 797, in get
d = self._unify_values(section, vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/configparser.py”, line 1168, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: ‘fan’
Traceback (most recent call last):
File “/usr/bin/rockpi-quad/main.py”, line 10, in
import oled
File “/usr/bin/rockpi-quad/oled.py”, line 33, in
disp = disp_init()
^^^^^^^^^^^
File “/usr/bin/rockpi-quad/oled.py”, line 25, in disp_init
RESET = getattr(board.pin, os.environ[‘OLED_RESET’])
~~~~~~~~~~^^^^^^^^^^^^^^
File “”, line 679, in getitem
KeyError: ‘OLED_RESET’
Traceback (most recent call last):
File “/usr/bin/rockpi-quad/main.py”, line 36, in
misc.disk_turn_on()
File “/usr/bin/rockpi-quad/misc.py”, line 167, in disk_turn_on
line1 = gpiod.Chip(os.environ[‘SATA_CHIP’]).get_line(int(os.environ[‘SATA_LINE_1’]))
~~~~~~~~~~^^^^^^^^^^^^^
File “”, line 679, in getitem
KeyError: ‘SATA_CHIP’

Check log for pigpiod.service service, is it working correctly?

root@lilnas:/usr/bin# systemctl status pigpiod.service
○ pigpiod.service - Daemon required to control GPIO pins via pigpio
Loaded: loaded (/lib/systemd/system/pigpiod.service; disabled; preset: enabled)
Active: inactive (dead)
root@lilnas:/usr/bin# systemctl start pigpiod.service
root@lilnas:/usr/bin# systemctl enable pigpiod.service
Created symlink /etc/systemd/system/multi-user.target.wants/pigpiod.service → /lib/systemd/system/pigpiod.service.
root@lilnas:/usr/bin#

oh, so this service is not working correctly,
check out logs for it, as earlier try to run it manually and see error output

Seems like service io OK right now

sa@lilnas:~ $ sudo systemctl status pigpiod.service
● pigpiod.service - Daemon required to control GPIO pins via pigpio
Loaded: loaded (/lib/systemd/system/pigpiod.service; enabled; preset: enabled)
Active: active (running) since Thu 2024-12-05 14:02:47 MSK; 19h ago
Main PID: 17589 (pigpiod)
Tasks: 4 (limit: 8735)
CPU: 1h 10min 26.674s
CGroup: /system.slice/pigpiod.service
└─17589 /usr/bin/pigpiod -l

Dec 05 14:02:47 lilnas systemd[1]: Starting pigpiod.service - Daemon required to control GPIO pins via pigpio…
Dec 05 14:02:47 lilnas systemd[1]: Started pigpiod.service - Daemon required to control GPIO pins via pigpio.

root@lilnas:/home/sa# systemctl status rockpi-quad.service
● rockpi-quad.service - Rockpi SATA Hat
Loaded: loaded (/lib/systemd/system/rockpi-quad.service; enabled; preset: enabled)
Active: active (running) since Fri 2024-12-06 09:48:23 MSK; 18min ago
Main PID: 619 (python3)
Tasks: 2 (limit: 8735)
CPU: 453ms
CGroup: /system.slice/rockpi-quad.service
└─619 /usr/bin/python3 /usr/bin/rockpi-quad/main.py

But

Dec 06 09:48:25 lilnas python3[619]: disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c, reset=digitalio.DigitalInOut(RESET))
Dec 06 09:48:25 lilnas python3[619]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 06 09:48:25 lilnas python3[619]: File “/usr/local/lib/python3.11/dist-packages/adafruit_ssd1306.py”, line 245, in init
Dec 06 09:48:25 lilnas python3[619]: self.i2c_device = i2c_device.I2CDevice(i2c, addr)
Dec 06 09:48:25 lilnas python3[619]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 06 09:48:25 lilnas python3[619]: File “/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py”, line 62, in __in>
Dec 06 09:48:25 lilnas python3[619]: self.__probe_for_device()
Dec 06 09:48:25 lilnas python3[619]: File “/usr/local/lib/python3.11/dist-packages/adafruit_bus_device/i2c_device.py”, line 184, in __p>
Dec 06 09:48:25 lilnas python3[619]: raise ValueError(“No I2C device at address: 0x%x” % self.device_address)
Dec 06 09:48:25 lilnas python3[619]: ValueError: No I2C device at address: 0x3c

Do You have i2c turned on?
use i2ctools to inspect this one, it should return device on this address:

:~ $ 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: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Yeap - it’s turned on

 `sa@lilnas:~ $ i2cdetect -y 1
 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00: – -- – -- – -- – --
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – 51 – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --`

Obviously - it cannot find device at 0x3c address
double check connection, wires and LCD, something is wrong there, it should be visible at this address when correctly connected