nRF24 / RF24

OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices

Home Page:https://nrf24.github.io/RF24

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SPIException Exception on OrangePi Zero 3

eduardoeberhardt15 opened this issue · comments

I'm using the orange pi zero 3 with python 3.11 with wiringOp and wiringOp-Python installed and i'm trying to running this rf24 lib

image
This is my pinout

spidev1.1 and spidev1.0 are enabled

The csn rf24 pinout it's on physic 24 pin
The ce rf24 pinout it's on physic 3 pin like is GPIO2

the radio config i'm try already RF24 radio(2, 11), radio (2,10)
trying also many others ce pinouts but always got the same error like

terminate called after throwing an instance of 'SPIException'
what(): can't open device
Aborted

image

If i change csn to 0 i got the GPIOException instead.

Could you guys help me please?

Yeah, I saw that as soon as a posted it, so I deleted the comment.

I should note that wiringPi support is deprecated because the original library is no longer maintained. The version of wiringPi that you are using in the OrangePi is a third-party port of the original library (& not officially supported by the RF24 library).

How did you install the RF24 library? Did you select WiringPi as your driver? I think the SPIException is coming from the SPIDEV driver.

If i change csn to 0 i got the GPIOException instead.

Again, this means you are using the SPIDEV driver because that's where the GPIOException exception is coming from. But I think the proper CE pin number (according to your chart in OP & using SPIDEV) should be 229, right?

Should i remove the wiringPi?
i ran sudo ./configure --driver=SPIDEV, that is, i'm not running with wiringpi, but also i already test with all drivers and nothing work
I run this code to test the spi.
image

If i change csn to 0 i got the GPIOException instead.

Again, this means you are using the SPIDEV driver because that's where the GPIOException exception is coming from. But I think the proper CE pin number (according to your chart in OP & using SPIDEV) should be 229, right?

I had tried all kid of number

I'm not sure where you got the spidev_test program... But I think that test requires a jumper from MOSI to MISO as it is likely a loop-back test.

I'm not sure where you got the spidev_test program... But I think that test requires a jumper from MOSI to MISO as it is likely a loop-back test.

Yes, needs a jumper.
I used the orangepi doc above.
https://drive.google.com/file/d/1nqr1LWQKs2SN5GZzboN5SLwoNZHkSJ7b/view

And that was the output with the jumper attached (not the nRF24L01)?

And that was the output with the jumper attached (not the nRF24L01)?

Not, with jumper, rx is same tx.

Just so I understand, the loop back test works with the jumper? Your English is hard to understand.

Just so I understand, the loop back test works with the jumper? Your English is hard to understand.

Yes, with the jumper work normal.

As far as I can tell, it should work with RF24 radio(229, 11) using the SPIDEV driver. I don't know anybody that has an OPi3 to try or test.

BTW, you don't need sudo permission when using the SPIDEV driver.

Should i remove the wiringPi?

It should make no difference if you remove WiringPi because the compiler shouldn't be linking into that library if you configured RF24 to use SPIDEV.

BTW, you don't need sudo permission when using the SPIDEV driver.

Should i remove the wiringPi?

It should make no difference if you remove WiringPi because the compiler shouldn't be linking into that library if you configured RF24 to use SPIDEV.

Now I started from scratch again. I deleted the folder, cloned it in git and ran the commands in the attached image and it gave an access error.
image

CPU=aarch64

If you are using a 64-bit OS, then you should be installing RF24 with CMake instead. The older configure script is meant to prepare builds with armhf compilers, and it has not aged well with 64-bit environments.

I see you are using the automated install script, and it shows that there is already a rf24libs folder with contents. It is best to start from a clean slate
You can delete the rf24libs folder and start again or install it manually from source:

# navigate to the RF24 library source
cd RF24

# reset the git repository
git reset --hard

# remove old build artifacts
rm Makefile.inc utility/includes.h

# uninstall previous RF24 installation
sudo rm /usr/local/lib/librf24.*
sudo rm /usr/local/lib/librf24-bcm.so
sudo rm -r /usr/local/include/RF24

# now install using cmake
mkdir build
cd build
cmake .. -DRF24_DRIVER=SPIDEV
make
sudo make install

Building the examples with CMake is similar to building the library

cd RF24/examples_linux
mkdir build
cd build
cmake .. -DRF24_DRIVER=SPIDEV
make

# run the gettingstarted example
./gettingstarted

I see you are using the automated install script, and it shows that there is already a rf24libs folder with contents. It is best to start from a clean slate You can delete the rf24libs folder and start again or install it manually from source:

# navigate to the RF24 library source
cd RF24

# reset the git repository
git reset --hard

# remove old build artifacts
rm Makefile.inc utility/includes.h

# uninstall previous RF24 installation
sudo rm /usr/local/lib/librf24.*
sudo rm /usr/local/lib/librf24-bcm.so
sudo rm -r /usr/local/include/RF24

# now install using cmake
mkdir build
cd build
cmake .. -DRF24_DRIVER=SPIDEV
make
sudo make install

Building the examples with CMake is similar to building the library

cd RF24/examples_linux
mkdir build
cd build
cmake .. -DRF24_DRIVER=SPIDEV
make

# run the gettingstarted example
./gettingstarted

Seems the same problem.

orangepi@orangepizero3:/RF24/examples_linux$ sudo nano gettingstarted.cpp
orangepi@orangepizero3:/RF24/examples_linux$ cd build
orangepi@orangepizero3:/RF24/examples_linux/build$ sudo cmake .. -DRF24_DRIVER=SPIDEV
-- detected SoC: sun50i-h616
-- detected CPU type: aarch64
-- tool name being used: aarch64-linux-gnu
-- Using driver: SPIDEV
-- using RF24 library: /usr/local/lib/librf24.so
-- Configuring done
-- Generating done
-- Build files have been written to: /RF24/examples_linux/build
orangepi@orangepizero3:/RF24/examples_linux/build$ sudo make
Consolidate compiler generated dependencies of target gettingstarted
[ 7%] Building CXX object CMakeFiles/gettingstarted.dir/gettingstarted.cpp.o
[ 14%] Linking CXX executable gettingstarted
[ 14%] Built target gettingstarted
Consolidate compiler generated dependencies of target acknowledgementPayloads
[ 28%] Built target acknowledgementPayloads
Consolidate compiler generated dependencies of target manualAcknowledgements
[ 42%] Built target manualAcknowledgements
Consolidate compiler generated dependencies of target streamingData
[ 57%] Built target streamingData
Consolidate compiler generated dependencies of target multiceiverDemo
[ 71%] Built target multiceiverDemo
Consolidate compiler generated dependencies of target scanner
[ 85%] Built target scanner
Consolidate compiler generated dependencies of target interruptConfigure
[100%] Built target interruptConfigure
orangepi@orangepizero3:/RF24/examples_linux/build$ sudo ./gettingstarted
terminate called after throwing an instance of 'GPIOException'
what(): can't access /sys/class/gpio/gpio%d/direction GPIO pin. check access rights
Aborted
orangepi@orangepizero3:/RF24/examples_linux/build$ ./gettingstarted
terminate called after throwing an instance of 'SPIException'
what(): can't open device
Aborted (core dumped)

Have you added your user to the dialout group? That is required for SPIDEV driver to have access to /dev/spidevX.Y.

usermod -a -G dialout $USER

Also, I think you have to add your user to whatever group the GPIO pins are registered to. I don't remember exactly how to do this; off the top of my head I think I had to install a udev rule from RPi.GPIO sources in Ubuntu on my RPi4.

Note
You can get the groups that are associated with your user by running groups

A reboot is required for changes to the user groups to take effect.

What I see on my RPi4:

brendan@rpi4-ubuntu-64bit:~$ groups
brendan adm dialout cdrom sudo dip plugdev lpadmin lxd sambashare
brendan@rpi4-ubuntu-64bit:~$ ls /dev/spi* -l
crw-rw---- 1 root dialout 153, 0 Mar 20  2023 /dev/spidev0.0
crw-rw---- 1 root dialout 153, 1 Mar 20  2023 /dev/spidev0.1
brendan@rpi4-ubuntu-64bit:~$ ls /dev/gpio* -l
crw-rw---- 1 root dialout 254, 0 Mar 20  2023 /dev/gpiochip0
crw-rw---- 1 root dialout 254, 1 Mar 20  2023 /dev/gpiochip1
crw-rw---- 1 root dialout 504, 0 Mar 20  2023 /dev/gpiomem

I don't remember what else I did to get non-root access to GPIO, but it wasn't as easy as adding a group to my user's groups. I think this is an ongoing and unsolved issue with OrangePi.

What I see on my RPi4:

brendan@rpi4-ubuntu-64bit:~$ groups
brendan adm dialout cdrom sudo dip plugdev lpadmin lxd sambashare
brendan@rpi4-ubuntu-64bit:~$ ls /dev/spi* -l
crw-rw---- 1 root dialout 153, 0 Mar 20  2023 /dev/spidev0.0
crw-rw---- 1 root dialout 153, 1 Mar 20  2023 /dev/spidev0.1
brendan@rpi4-ubuntu-64bit:~$ ls /dev/gpio* -l
crw-rw---- 1 root dialout 254, 0 Mar 20  2023 /dev/gpiochip0
crw-rw---- 1 root dialout 254, 1 Mar 20  2023 /dev/gpiochip1
crw-rw---- 1 root dialout 504, 0 Mar 20  2023 /dev/gpiomem

I don't remember what else I did to get non-root access to GPIO, but it wasn't as easy as adding a group to my user's groups. I think this is an ongoing and unsolved issue with OrangePi.

image

What OS are you using?

This issue is beginning to seem like a problem with OrangePi3 and less of a problem with RF24.

What OS are you using?

This issue is beginning to seem like a problem with OrangePi3 and less of a problem with RF24.

My OS is Ubuntu
The RF24 is working on espcam32 and arduino UNO.

The RF24 is working on espcam32 and arduino UNO.

That just tells me the radio is in working condition.

I'm not sure what to tell you at this point. I don't have an OPi to play with, and I probably never will. Personally, I try to avoid using Chinese-cloned hardware.

commented

Well we use PiGPIO for GPIO with SPIDEV so I would start looking at getting that working/testing that, as that seems to be where your problem is. As per @2bndy5 this is likely not an RF24 issue, but we don't have the hardware to confirm.

I think that i'll use arduino.
Thanks by trying help me.