Menu

#190 /proc/cpuinfo identification needs updates for RPi 4

Done
None
Medium
Patch
2022-02-06
2020-09-11
No

I've found that the logic in get_rpi_info needs to be updated for Raspberry Pi 4 systems. I've noted this because I'm trying to use gpio in python inside a docker container and it doesn't work if I don't use the privileged flag when creating the container. I'm working to remove privileged from the container I have.

privileged ends up mapping over all of /sys to the container, which allows get_rpi_info to see /proc/device-tree/system/linux,revision. If this is used, then the Pi is successfully identified. If privileged is not specified, this interface isn't available and then it tries to use /proc/cpuinfo for identification, which fails because it hasn't been updated for RPi4s.

There's two changes that need to be made:

  1. The first is to update the if statement in the block handling parsing of /proc/cpuinfo. "BCM2711" needs to be allowed as a potential processor option. With that added, it will properly jump into the new scheme handling of the revision.
  2. Second, the larger memory size on the 8GB Pi4 needs to be handled in the switch statement on line 122. Adding a case for 5 mapping to "8G" will fix that.

Jason

Discussion

  • Emmanuel ANDRE

    Emmanuel ANDRE - 2020-10-25

    I agree I have a 8G rpi and it doesn't show the correct infos :

    python -u -c 'import RPi.GPIO as GPIO ; print(GPIO.RPI_INFO)'

    tail -n 4 /proc/cpuinfo | grep -v ^Serial
    Hardware : BCM2835
    Revision : d03114
    Model : Raspberry Pi 4 Model B Rev 1.4

    and according to https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md

    d03114 4B 1.4 8GB Sony UK

     
  • Kipjr

    Kipjr - 2021-01-25

    it is missing BCM2711 in cpuinfo.c and this causes an error.

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

    Last edit: Kipjr 2021-01-25
    • Emmanuel ANDRE

      Emmanuel ANDRE - 2021-02-01

      I'm not sure because according to this documentation : https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md

      Note: As of the 4.9 kernel, all Pis report BCM2835, even those with BCM2836, BCM2837 and BCM2711 processors. You should not use this string to detect the processor. Decode the revision code using the information below

       
  • Ben Croston

    Ben Croston - 2021-02-28
    • status: New --> Accepted
    • assigned_to: Ben Croston
     
  • Ben Croston

    Ben Croston - 2021-02-28

    Fixed in 0.7.1a4

     
    • Kjeld Flarup

      Kjeld Flarup - 2021-11-03

      When will this reach an official repository. And where can I download the patch?

       
      • Juerg Haefliger

        Juerg Haefliger - 2021-11-03

        Repo of what distro? Also, the upstream kernel is deprecating GPIO control via sysfs, so you might want to look into alternate Python solutions. This is the new world: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/

         
        • Kjeld Flarup

          Kjeld Flarup - 2021-11-03

          I use Raspberry Pi OS https://www.raspberrypi.com/software/

          Funny, I found that python 2 runs, but not python3

           
  • Ben Croston

    Ben Croston - 2022-02-06
    • status: Accepted --> Done
     
  • Ben Croston

    Ben Croston - 2022-02-06

    Fixed in 0.7.1

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.