jperkin / node-rpio

Raspberry Pi GPIO library for node.js
857 stars 123 forks source link

Pin control on RPi Compute module does not work #132

Closed Papouchcom closed 3 years ago

Papouchcom commented 3 years ago

Pin control on the Raspberry Compute module 3+ does not work. This code:

    rpio.init({
        gpiomem: true,
        mapping: 'physical',
        mock: undefined,
        close_on_exit: true
    });
    rpio.open(70, rpio.OUTPUT, rpio.HIGH);

...crashes with this error: Pin 70 is not valid when using physical mapping (GPIO mode with pin number setting of 40 does not work either.)

jperkin commented 3 years ago

Yeh, I've never had any users with a Compute Module who can verify what the pinmap is, or what it detects as.

Could you fill in the values from https://gist.github.com/jperkin/c37a574379ef71e339361954be96be12 to help out, and ideally verify the correct pin mapping? It should be pretty easy to then add support. Thanks.

Papouchcom commented 3 years ago

Thanks a lot for the quick response! I added logs from different versions of CM to the comments in gist.

I think the pin map for CM is this (on page 9): https://www.raspberrypi.org/documentation/hardware/computemodule/datasheets/rpi_DATA_CM3plus_1p0.pdf#page=10 How could I try it, please?

Papouchcom commented 3 years ago

Here is a modified file with a array (PINMAP_200) of GPIO pins on the CM: rpio.zip

jperkin commented 3 years ago

Thanks! Have you verified it works correctly? If so I'll merge it.

Papouchcom commented 3 years ago

I tested only with CM 3+ and only with two GPIO pins. I also modified the module detection, but I don't know if it detects standard RPi correctly.

jperkin commented 3 years ago

Support was added a while back, and should now include CM4 too.

shaynem commented 2 years ago

I've been trying to figure out the problem I was having when using the sourcekit PiTray - it exposes the default 40 pin GPIO, therefore I had to change

line 577

PINMAP_40

I'm not sure if there is a way to detect the PITray pragmatically, however if I do a PR, would you accept config done via

rpio.init([options])

pinmap: 'PINMAP_40'

or another suggestion?