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

Broken on 64-bit Linux #95

Open
daguej opened this issue Sep 5, 2019 · 1 comment
Open

Broken on 64-bit Linux #95

daguej opened this issue Sep 5, 2019 · 1 comment

Comments

@daguej
Copy link

daguej commented Sep 5, 2019

Using this module on a Pi running a 64-bit Linux distro (eg Ubuntu 18.04 arm64) errors out when you call setup().

Error: Unable to match Revision in /proc/cpuinfo: processor       : 0
BogoMIPS        : 38.40
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
BogoMIPS        : 38.40
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 2
BogoMIPS        : 38.40
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 3
BogoMIPS        : 38.40
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

(thrown here)

This happens because /proc/cpuinfo does not contain the expected Revision: … line under 64-bit Linux.

To test, I followed this advice, bind-mounting a fake cpuinfo file on /proc/cpuinfo and adding Revision: a02082. With this, the rpi-gpio library started working.

It appears the correct place to look on a 64-bit system is /proc/device-tree/system/linux,revision.

$ cat /proc/device-tree/system/linux,revision | hexdump
0000000 a000 d320
0000004

(unsure if 32-bit systems have the same thing)

@JamesBarwell
Copy link
Owner

Thanks for the detailed report.

It looks like at the very least, it's a bug that it assumes the value of /proc/cpuinfo. It shouldn't break. At the moment I'm thinking that a patch to ensure it doesn't break, and to default to the v2 schema when it couldn't find the info, would be a good basic fix.

Reading /proc/device-tree could then be a second phase enhancement. I'm just wondering if it's worth doing given that it looks like that version of Ubuntu only supports Pi 2 and above anyway, which would all use the v2 schema. I'm not very familiar with these alternative OS's for the Pi, so am a bit unsure whether this functionality would be useful, and whether Device Tree would always be available anyway.

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

No branches or pull requests

2 participants