PiRogueToolSuite / deb-packages

PiRogue Debian packages
https://pts-project.org/
GNU General Public License v3.0
2 stars 2 forks source link

pirogue-screen-st7789-240x240: prepare for hardware+software auto-detection #12

Closed CyrilBrulebois closed 1 year ago

CyrilBrulebois commented 1 year ago

Debian packages shipping systemd units tend to have the unit enabled by default (see dh_installsystemd).

Depending on what we decide regarding pirogue-base vs. pirogue-base-pc, we might scrap the latter, focus on the former, and have pirogue-base pull this package on PC architectures as well (amd64 and possibly i386).

It seems to me this package's postinst should determine which hardware+software platform it's running on, and do something along those lines:

I'm happy to write a PoC for this.

I'm not sure whether we need to clean everything up in the postrm script. It would be cleaner, but does it change anything practically?

CyrilBrulebois commented 1 year ago

In the Debian case, the DTBO could be named <package>.dtbo so that it's clear where it comes from. We would probably ship it somewhere below /usr and have it copied and enabled in config.txt via postinst.

For this package, we could stick to pirogue-screen.dtbo since the virtual package is going to prevent other pirogue-screen-* from being co-installed.

CyrilBrulebois commented 1 year ago

Since /etc/os-release is unchanged in Raspberry OS (no comment…), detecting raspi-firmware as an installed package is likely to be a very reliable way to tell Debian from Raspberry OS.

CyrilBrulebois commented 1 year ago

In the Debian case, it seems there's no way to ensure /dev/spidev* entries are created by the kernel because compatible = "spidev" is wrong and rejected (according to Linux upstream). The Raspberry OS kernel has a revert of that rejection code, so is unaffected when a SPI overlay is enabled.

Provided the systemd unit is started as root, we might want to have some ExecStartPre that would do the required echo dance to create what python3-spidev expects for the SPI-based device:

echo spidev > /sys/bus/spi/devices/spi0.0/driver_override
echo spi0.0 > /sys/bus/spi/drivers/spidev/bind

Or just have the “main” screen program deal with it when starting up.

U039b commented 1 year ago
CyrilBrulebois commented 1 year ago

The detection is now implemented in a new pirogue-hardware-detection package that creates flag files depending on the detected hardware and software situation:

CyrilBrulebois commented 1 year ago

We still need to investigate whether we can write a DTS for the DTBO that doesn't require modifying the base DTS. Since that's the first time I touched SPI things, I decided to play safe initially and mimic what's done on the vendor side, but it's probably OK to just reference the whole 7-11 pins without splitting them into two different groups; the CS (chip select) distinction is probably not relevant either. But we should test that before merging either version of the DTS/DTBO.

CyrilBrulebois commented 1 year ago

Confirmed OK by @U039b, at least on Debian 12. If there are issues on Raspberry OS, please file a separate issue with details.