Hi, folks!
I'm trying to control GPIO using HiPi module.
Here's my code :
use strict;
use warnings;
use HiPi::GPIO;
my $gpio = HiPi::GPIO->new();
my $level = $gpio->get_pin_level( 2 );
print "level = $level";
And here's the output :
Undefined subroutine &HiPi::GPIO::xs_gpio_read called at /usr/local/lib/aarch64-linux-gnu/perl/5.36.0/HiPi/GPIO.pm line 71.
Here's the board info :
--------------------------------------------------
Raspberry Pi Board Info
--------------------------------------------------
Model Name : Raspberry Pi 4 Model B Rev 1.5
Released : Q1 2022
Manufacturer : Sony UK
Memory : 8192
Processor : BCM2711
Hardware : BCM2709
Description : Type 3 40 pin GPIO header
Revision : d03115
Serial Number : 10000000bc1d47af
Short Serial No : bc1d47af
GPIO Header Type : 3
Revision Number : 5
Device Tree : Yes
Is Raspberry : No
Is Raspberry 2 : No
Is Raspberry 3 : No
Is Raspberry 4 : Yes
Is Raspberry 5 : No
Alt Function Map : Version 2
ARM Core : Cortex-A72
Number of Cores : 4
Architecture : Width 64 bit
OS arch support : armhf, arm64
Since it says " Is Raspberry : No " (despite " Is Raspberry 4 : Yes "), the GPIO library don't get loaded (HiPi/GPIO.pm, lines 26-32) :
if ( HiPi::is_raspberry_pi() ) {
if ( HiPi::RaspberryPi::has_rp1() ) {
XSLoader::load('HiPi::GPIO::RP1', $VERSION);
} else {
XSLoader::load('HiPi::GPIO', $VERSION);
}
}
The variable $HiPi::RaspberryPi::israspberry gets undefined here (line 519 or HiPi/RaspberryPi.pm) :
$israspberry = $_cpuinfostash{Hardware} && $_cpuinfostash{Hardware} =~ /^BCM(27|28)/;
because $_cpuinfostash{Hardware} is undefined :
$ cat /proc/cpuinfo
processor : 0
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 1
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 2
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
processor : 3
BogoMIPS : 108.00
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd08
CPU revision : 3
Revision : d03115
Serial : 10000000bc1d47af
Model : Raspberry Pi 4 Model B Rev 1.5
I'm not quite sure what exactly is_raspberry means - does it mean the device type is Raspberry Pi, or it means that device is the first generation Rapsberry Pi.
If I edit the module code to forcefully set $israspberry to true, then the error about undefined subroutine disappears. (Though, I didn't test yet if GPIO actually starts working).
So I wonder what's the best way to correct the module code?
Here's my system data :
$ uname -a
Linux ts 6.1.0-rpi8-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.73-1+rpt1 (2024-01-25) aarch64 GNU/Linux
$ perl -v
This is perl 5, version 36, subversion 0 (v5.36.0) built for aarch64-linux-gnu-thread-multi
(with 53 registered patches, see perl -V for more detail)
$ perl -mHiPi -e 'print $HiPi::VERSION . "\n";'
0.90
$ perl -mHiPi::GPIO -e 'print $HiPi::GPIO::VERSION . "\n";'
0.90
The module was installed with apt :
$ sudo apt install libhipi-perl
Thanks in advance.