Bug 1471731 - SystemError: This module can only be run on a Raspberry Pi!
Summary: SystemError: This module can only be run on a Raspberry Pi!
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 27
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Peter Robinson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-17 11:02 UTC by Aleksandra Fedorova
Modified: 2018-07-23 15:05 UTC (History)
24 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-07-23 15:05:51 UTC
Type: Bug


Attachments (Terms of Use)

Description Aleksandra Fedorova 2017-07-17 11:02:52 UTC
Description of problem:

  On Fedora 26 RPIO._GPIO python module can not be imported due to unsupported hardware version.

Version-Release number of selected component (if applicable):

  Raspberry Pi 3 Model B
  Fedora 26 with latest updates
  python3-RPi.GPIO-0.6.3-2.fc26.armv7hl.rpm

How reproducible:

  Always

Steps to Reproduce:

  1. dnf install python3-RPi.GPIO
  2. python
  3. > import RPIO

Actual results:

  Import fails with 

    import RPIO._GPIO as _GPIO
    SystemError: This module can only be run on a Raspberry Pi!

Expected results:

  Module is imported

Additional info:

It seems that library uses /proc/cpuinfo to determine the hardware and revision of raspberry pi.

See
https://sourceforge.net/p/raspberry-gpio-python/code/ci/default/tree/source/cpuinfo.c

   if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
      return -1;
   while(!feof(fp)) {
      fgets(buffer, sizeof(buffer), fp);
      sscanf(buffer, "Hardware	: %s", hardware);
      if (strcmp(hardware, "BCM2708") == 0 ||
          strcmp(hardware, "BCM2709") == 0 ||
          strcmp(hardware, "BCM2835") == 0 ||
          strcmp(hardware, "BCM2836") == 0 ||
          strcmp(hardware, "BCM2837") == 0 ) {
         found = 1;
      }
      sscanf(buffer, "Revision	: %s", revision);
   }

On some random raspbian system /proc/cpuinfo looks as follows:

  ...
  processor       : 3
  model name      : ARMv7 Processor rev 4 (v7l)
  BogoMIPS        : 76.80
  Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
  CPU implementer : 0x41
  CPU architecture: 7
  CPU variant     : 0x0
  CPU part        : 0xd03
  CPU revision    : 4

  Hardware        : BCM2709
  Revision        : a02082

On Fedora 26 we have

  # cat /proc/cpuinfo
  ...
  processor	: 3
  model name	: ARMv7 Processor rev 4 (v7l)
  BogoMIPS	: 38.40
  Features	: half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
  CPU implementer	: 0x41
  CPU architecture: 7
  CPU variant	: 0x0
  CPU part	: 0xd03
  CPU revision	: 4

  Hardware	: Generic DT based system
  Revision	: 0000

So Hardware is not shown and revision is 0.

If it is not possible to get a proper hardware information due to firmware issues, can we maybe patch the library so it relies on device-tree/model string or maybe even some configuration file in /etc/rpi/ ?

Comment 1 John Florian 2017-12-10 02:03:14 UTC
I can confirm this with Fedora 27 and python3-RPi.GPIO-0.6.3-4.fc27.armv7hl.  I was able to use this module on the same hardware back with Fedora 23 albeit I was using python-rpi-gpio-0.5.11-1.fc23.armv7hl (for Python 2).

$ python3 
Python 3.6.3 (default, Oct  9 2017, 11:35:41) 
[GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Tab completion has been enabled.
>>> import RPi.GPIO
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
>>>

Comment 2 John Florian 2017-12-10 16:07:49 UTC
It does appear that the difference in /proc/cpuinfo determines whether this module works or fails.

This case has no problem importing the module:

$ grep PRETTY_NAME= /etc/os-release ; grep -A9 '^Hardware' /proc/cpuinfo
PRETTY_NAME="Fedora 23 (Twenty Three)"
Hardware        : BCM2709
Revision        : a02082
Serial          : 00000000f82def87

Whereas this case fails to import the module (on the same hardware):

$ grep PRETTY_NAME= /etc/os-release ; grep -A9 '^Hardware' /proc/cpuinfo
PRETTY_NAME="Fedora 27 (Twenty Seven)"
Hardware        : Generic DT based system
Revision        : 0000
Serial          : 0000000030a816e4



Given this difference, I think reassigning this bug to the kernel is appropriate.  I also bumped the package version to 27 since the problem is still reproducible there.

Comment 3 Justin M. Forbes 2018-07-23 14:56:15 UTC
*********** MASS BUG UPDATE **************

We apologize for the inconvenience.  There are a large number of bugs to go through and several of them have gone stale.  Due to this, we are doing a mass bug update across all of the Fedora 27 kernel bugs.

Fedora 27 has now been rebased to 4.17.7-100.fc27.  Please test this kernel update (or newer) and let us know if you issue has been resolved or if it is still present with the newer kernel.

If you have moved on to Fedora 28, and are still experiencing this issue, please change the version to Fedora 28.

If you experience different issues, please open a new bug report for those.

Comment 4 Peter Robinson 2018-07-23 15:05:51 UTC
The RPIO._GPIO module needs to be updated to work with the new kernel interfaces, probably via libgpio so it will work  with distros other than Raspbian plus what ever kernel hacks they have in place


Note You need to log in before you can comment on or make changes to this bug.