-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CE pin and rockchip 3588 boards #1017
Comments
|
This is my printDetails() - the output looks exactly the same on both the RPi2 and the Orange PI and it is exactly the same hardware (PA + LNA).
|
If you have libgpiod installed, then you can use the included CLI tools. This might help identify the pin number and gpiochipX number on your system. PS - I would also suggest using pyrf24 package instead of the individual wrapper in this repo. |
wow I figured it out! so it looks like spidev talks by default to |
Found it, the |
This was done to support RPi5. If the chip does not exist, then the lib will fallback to gpiochip0 (for backwards compatibility). Lines 78 to 88 in 6f3da43
If it the wrong chip for the system, then users can set the default at build time using RF24_LINUX_GPIO_CHIP defined.Lines 23 to 29 in 6f3da43
Building RF24
Building pyRF24
Requires cloning pyRF24 and init-ing the git submodules
This also affects the |
We won't be adding to the runtime overhead by adding a param to change this dynamically at runtime. |
This makes sense and not a big ordeal to change the |
@ErikApption what is the the output for I suspect that the lib does not fall back to gpiochip0 because a gpiochip4 exists (but it isn't the chip that exposes the desired GPIO pins). @TMRh20 Would it be possible to sym-link
The macro is documented, but the docs (build instructions and Linux usage doc) don't highlight this rare problem. TBH, this is the first time it has become a problem since we switched to Linux kernel's "character device" interface (for GPIO manipulation) almost a year ago. It would be better if we had a RPi OS specific macro to detect when building on the RPi OS, moreso to detect the RPi5 (or newer). |
this is how it looks on rk3588, but only few of these lines end up being usable
the current aarm64 python package is excellent - a major upgrade from older version because you don't need to build the binaries separately anymore. This might be a rare issue but after doing some searches, there are other people struggling to run this with exotic boards. Could be also as simple as adding the gpiochip device in the |
I also wrote a pure rust implementation (rf24-rs) with bindings to node.js and python. In the bindings' c'tors, there's optional parameters to select SPI bus and GPIO chip (separate from radio's CE and CSN pins). Unfortunately this hasn't been deployed yet. |
@2bndy5 I think something changed in RPi5... gpiochip4 is now a sym-link? |
That's what I suspected. On my RPi4 and RPi3,
Caution We also need to verify this on a 32-bit RPi OS install. I'm currently using 64-bit on all my RPi machines. I came across this when testing the node.js bindings of rf24-rs. examples/node/ts/gettingStarted.ts
export class App {
radio: RF24;
payload: Buffer;
/**
* @param radioNumber The number (0 or 1) that identifies the which radio is used in
* this example that requires 2 radios.
*/
constructor(radioNumber: number) {
// The radio's CE Pin uses a GPIO number.
// On Linux, consider the device path `/dev/gpiochip<N>`:
// - `<N>` is the gpio chip's identifying number.
// Using RPi4 (or earlier), this number is `0` (the default).
// Using the RPi5, this number is actually `4`.
// The radio's CE pin must connected to a pin exposed on the specified chip.
const cePin = 22; // for GPIO22
// try detecting RPi5 first; fall back to default
const gpioChip = fs.existsSync("/dev/gpiochip4") ? 4 : 0;
console.log(`using /dev/gpiochip${gpioChip}`); // ADDED FOR DEBUGGING (does not exist on remote)
// The radio's CSN Pin corresponds the SPI bus's CS pin (aka CE pin).
// On Linux, consider the device path `/dev/spidev<a>.<b>`:
// - `<a>` is the SPI bus number (defaults to `0`)
// - `<b>` is the CSN pin (must be unique for each device on the same SPI bus)
const csnPin = 0; // aka CE0 for SPI bus 0 (/dev/spidev0.0)
// create a radio object for the specified hardware config:
this.radio = new RF24(cePin, csnPin, {
devGpioChip: gpioChip,
});
// initialize the nRF24L01 on the spi bus
this.radio.begin();
// ... where const gpioChip = fs.existsSync("/dev/gpiochip4") ? 4 : 0;
console.log(`using /dev/gpiochip${gpioChip}`); always prints "using /dev/gpiochip4", even on my RPi3. BTW the examples work well (too well in case of scanner examples written for node.js) |
There are no gpiochip4 references in my 32-bit bookworm installs on RPi3 or RPi4 in So probably best to make gpiochip0 the default again? |
yep. Probably a good idea to add a note about @ErikApption It would be nice if you could provide a link to information that helped you find out about the rockchip pin numbers. |
I've added to the docs some info about GPIO chips on non-RPi systems. The docs preview for #1018 can be reviewed at our RTD project. I also cross-referenced the aforementioned Linux doc from the API docs about the CE pin parameter in Let me know if further changes are desired. |
@2bndy5 the edits in the PR are great. As for the pin numbering on the opi, the best is the official document that has the weird GPIO naming but I was not able to find any technical details on I guess one edit I would do is to say:
|
These details are specific to the Linux kernel. I don't know of any doc'd details for the RPi also, namely how the kernel API is mapped out to actual hardware. We just kind of poke around until something works and then abuse what works 😆 . There's probably something about it in the system's DeviceTreeOverlay config 🤷, but that syntax looks more confusing than helpful. |
Just skimming the OPi5B manual (found here), I see the pin numbers are described as such:
But this doesn't make any more sense as you found GPIO4_A6 = 6. The OPi (& BananaPi docs) still rely on installing a custom version of wiringPi (which has been officially dead for years). They then recommend using the hard-coded output of |
Indeed it is ridiculous and in addition to the wiringpi numbering they have the GPIO ones. The GPIO ones would be ultimately a good (and portable) convention because they combine bank + line into a single digit |
Arduino cores do this as well. I especially like how espressif aliased the ESP8266 pins with macros (like |
The doc changes are live and patch merged to master branch. It will take another week to get this fix into pyRF24 though. I'll have to add something about |
Fix released in pyRF24 v0.4.5. Thanks again for bringing this to our attention. |
What radio module do you use?
nrf24l01 lpna
What driver board(s) do you use?
Orange pi 5 max
If using Linux, what OS are you using?
If using Linux, what RF24 driver did you select?
SPIDEV (linux kernel)
Describe your problem
I am not able to receive anything on a RK3588 board. I suspect issue is the CE pin, because the numbering is unclear. The GPIO numbers (from
gpio
tool) always throw an invalid pin number but if I use the actual pin then I am not getting any reception. The radio is detected withspidev0.0
but I am not able to receive anything.I haven't done too much digging yet in the rk3588 kernel to see what is behind the spidev logic... Has anyone been able to run a nrf24 with a rk3588 based board?
What is the RX code?
What is the TX code?
// no tx
The text was updated successfully, but these errors were encountered: