Migration to Raspberry PI 3B+ problem with RF24 library and C code compiling

151 Views Asked by At

During update of my home automation server I decided to upgrade Raspberry PI from 2B to 3B+.

Used code is the same but on 3B I got following error

g++ -Wall -o pimain Server_HomeAutomation.o -I. -I/usr/local/include/RF24 -L/usr/local/lib -lrf24
/usr/bin/ld: /usr/local/lib/librf24.so: undefined reference to `gpioSetISRFunc'
/usr/bin/ld: /usr/local/lib/librf24.so: undefined reference to `gpioInitialise'
collect2: error: ld returned 1 exit status
make: *** [makefile:26: pimain] Error 1

The only diference I know about is that 3B uses RF24 in actual version from GitHub, the 2B version RF24 is old. (RF24 old source from 2B does not compile on 3B) I installed the RF24 as described in Cmake guide.

Because of different RF24 initialization of lib was changed from 2B code

RF24 radio(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ);

to (as per docs 1000000 == 1Mhz)

#define BCM2835_SPI_SPEED_8MHZ 8000000
RF24 radio(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ);

As macro BCM2835_SPI_SPEED_8MHZ is not available in RF24 any more.

Error description gpio indicates gpio issue, but I compiled RF24 with BCM2835 Driver (aka RPi) and when it was not working I tried also SPIDEV (most compatible, Default), when it still does not work I have also installed gpio as attempt to make the compiler happy, but it does not help. Anyone has experience with this error? Out of ideas for now ;-) Where should I search next?

1

There are 1 best solutions below

0
On

There have been several problems together. They might be specific for my setup, but maybe it helps someone else:

RF24: In version 1.3.7 the constants have been removed (backward compatibility change without increasing major version)

To fix my code I added:

#define RPI_V2_GPIO_P1_22 22
#define BCM2835_SPI_CS0 0
#define BCM2835_SPI_SPEED_8MHZ 8000000

WiringPi (Gordon original) somehow has problem on 64bit system, changed to unofficial version of WiringPi

And now all works