Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pins/local: Add fallback device-tree method for hardware revision detection #871

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theyoyojo
Copy link

@theyoyojo theyoyojo commented Jun 19, 2020

This patch adds support for gpiozero in Fedora Linux via RPi.GPIO2

See https://github.com/underground-software/python3-libgpiod-rpi and https://pypi.org/project/RPi.GPIO2/

Currently, only the Raspberry Pi 3 Model B is supported as this PR is just a proof-of-concept for now.

Signed-off-by: Joel Savitz joelsavitz@gmail.com

Signed-off-by: Joel Savitz <joelsavitz@gmail.com>
@theyoyojo theyoyojo changed the title pins/local: Add fallback device-tree method hardware revision detection pins/local: Add fallback device-tree method for hardware revision detection Jun 19, 2020
@bennuttall
Copy link
Member

Is there a way you can get the actual revision code? It's useful to know the exact specs of the Pi at runtime, e.g. RAM. Not vital but useful for the pinout command line tool, which with a patch like this would "lie" to the user.

@lurch

@lurch
Copy link
Contributor

lurch commented Jun 20, 2020

A few lines above the code being added in this PR, it does:

io.open('/proc/device-tree/system/linux,revision', 'rb')

Does that not work on Fedora Linux? @theyoyojo

the exact specs of the Pi at runtime, e.g. RAM.

I think it's only the Pi4 which has different amounts of RAM for the same "model" string?

P.S. @bennuttall Any idea why this file is using io.open() rather than the regular open()?

@theyoyojo
Copy link
Author

@lurch Yes, unfortunately that file is not present on the official Fedora Linux images.

@waveform80
Copy link
Member

Hmmm, I would suggest Fedora would be better served by figuring out how to add that chunk of the d-t.

The model name is not a terribly reliable mechanism under certain circumstances. For instance, booting a Pi400 or CM4 is possible with firmware that pre-dates their release (consider the case of someone booting an SD card they've been using on a Pi4 but haven't upgraded after the release of a new Pi). However, when doing so, the model name in the d-t (which is patched by the start.elf bootloader to match the board it thinks it's on) becomes "Raspberry Pi Model ? Rev 1.0". By contrast, in these circumstances, the linux,revision node is still correct (as is the revision code in /proc/cpuinfo, when that's present).

My other objection is that this would introduce yet another lookup table that'd need maintaining (got quite enough of those already in pins/data :). As it stands, I'll have to reject this; if you could revise this to pull the revision code from some other location on Fedora I'd be happy to merge that?

I'll leave this open for now in case that's a possibility.

@theyoyojo
Copy link
Author

My other objection is that this would introduce yet another lookup table that'd need maintaining (got quite enough of those already in pins/data :). As it stands, I'll have to reject this; if you could revise this to pull the revision code from some other location on Fedora I'd be happy to merge that?

Ok, I'll look into it, thanks for the review 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants