I am using pigpiod_if2.h to read the version of a shield on a Raspberry Pi 4B running a Buildroot distro as I need to have multiple C programs interacting with GPIO simultaneously -- the initialization uses pigpio_start, but returns error code -2003 on startup.
initGPIO = pigpio_start(NULL, NULL); // Initialise pigpio
if (initGPIO >= 0) {
printf("Initialised GPIO for HWConfig [pigpio]\n");
}
else {
printf("Failed to initialise GPIO for HWConfig [pigpio]\n");
printf("PIGPIO error code: %d\n", initGPIO);
}
According to the documentation (from what I can tell) -2000 refers to the pigpiod header in some way, though there is no detail:
#define PI_PIGIF_ERR_0 -2000
And -3 refers to incorrect GPIO pin numbers:
#define PI_BAD_GPIO -3 // GPIO not 0-53
However, I think this error may be a red herring, as when the process is relaunched (without rebooting the machine) it works perfectly, with a successful instantiation message and the correct version of the hardware read.
I would greatly appreciate troubleshooting help to try and identify the root cause of this issue. I have so far included a script that checks if pigpio is running before this program (it is), and removed all references to pigpio before this program, apart from the pigpio daemon check.
Thank you, H
It turns out this issue is related to placement of the PIGPIO initialisation within the boot sequence. I was initialising the requisite peripherals with script numbers S30-S39 in my Buildroot init.d/etc boot directory. Moving the script numbers to S60-S69 fixed the issue (HWConfig and other periphs. working as expected).
While it is still unclear to me exactly what caused the failure, my working theory is that required drivers had not been initialised at that point in the boot sequence (such as the SPI code I was using from PIGPIO, which went from displaying random characters on an OLED to functioning as expected).