radxa-build / rock-pi-s

ROCK Pi S
https://wiki.radxa.com/RockpiS
20 stars 1 forks source link

installing mraa, python3-mraa #3

Closed rOY369 closed 2 months ago

rOY369 commented 2 months ago

Hi

I am using this latest debian bookworm cli rockpi-s image from https://github.com/radxa-build/rock-pi-s/releases/tag/b40

I have installed libmraa2, libmraa-dev and mraa-tools.

then why mraa-gpio list shows No pins

Also not able to install python3-mraa.

What am I missing here?

Screenshot from 2024-09-03 18-58-07 Screenshot from 2024-09-03 18-56-36

RadxaYuntian commented 2 months ago

MRAA currently does not support ROCK Pi S: https://github.com/eclipse/mraa/tree/master/src/arm

RadxaYuntian commented 2 months ago

Python package is also currently built for Debian 11. We will release for Debian 12 later.

rOY369 commented 2 months ago

@RadxaYuntian I was able to build mraa successfully from steps mentioned in the radxa mraa wiki.

I am currently using this Debian 11 image -> https://github.com/radxa-build/rock-pi-s/releases/tag/b38

mraa-gpio list now shows all available pins.

PWM3 is enabled from rsetup.

but still it is showing error while initialising any pwm or gpio pin from python.

>>> import mraa
>>> pin = mraa.Gpio(32)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/dist-packages/mraa.py", line 413, in __init__
    _mraa.Gpio_swiginit(self, _mraa.new_Gpio(pin, owner, raw))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Invalid GPIO pin specified

mraa logs

Sep 03 21:55:07 new-controller libmraa[937]: libmraa version v2.1.0-26-gd59936f initialised by user 'pi' with EUID 1001
Sep 03 21:55:07 new-controller libmraa[937]: gpio: platform doesn't support chardev, falling back to sysfs
Sep 03 21:55:07 new-controller libmraa[937]: libmraa initialised for platform 'Radxa ROCK Pi S' of type 25
Sep 03 21:55:30 new-controller libmraa[937]: pwm_init: pwm0. Failed to open export for writing: No such file or directory
Sep 03 22:33:50 new-controller libmraa[3724]: gpio73: init: Failed to open 'export' for writing: No such file or directory

Can you confirm whether mraa works properly with python bindings in Debian 11 or not?

The oldest Debian 10 image available on wiki works with mraa but has an outdated kernel. We want to update the image.

Can you point me to the latest image for rockpi-s which support mraa and its python bindings working correctly and what would be the steps to install mraa?

RadxaYuntian commented 2 months ago

@RadxaYuntian I was able to build mraa successfully from steps mentioned in the radxa mraa wiki.

Wiki is deprecated and reference our own fork. You are welcome to use it still, but it is not officially supported anymore.

File "/usr/local/lib/python3.11/dist-packages/mraa.py", line 413, in init

Debian 11 uses python 3.9, not 3.11 as shown in your error log. You need to rebuild it natively.

rOY369 commented 2 months ago

@RadxaYuntian

My bad. The logs were from Debian 12. Same error is showing in Debian 11 with python3.9.

I have built mraa from source from these steps

git clone -b master https://github.com/radxa/mraa.git

Changed these lines in CMakeLists.txt

-option (BUILDSWIGNODE "Build swig node modules." ON)
+option (BUILDSWIGNODE "Build swig node modules." OFF)

Changed these lines in include/version.h

-const char* gVERSION;
-const char* gVERSION_SHORT;
+extern const char* gVERSION;
+extern const char* gVERSION_SHORT;

Ran these steps with root user

mkdir build
cd build/
cmake ..
make
make install
ldconfig

mraa-gpio shows correct output

root@rock-pi-s:/home/rock/mraa/build# mraa-gpio version
Version v2.1.0-26-gd59936f on Radxa ROCK Pi S
root@rock-pi-s:/home/rock/mraa/build# mraa-gpio list
01         3V3: 
02          5V: 
03     I2C_SDA: GPIO I2C  
04          5V: 
05     I2C_SCL: GPIO I2C  
06         GND: 
07 I2S0_8CH_MC: GPIO 
08    UART0_TX: GPIO UART 
09         GND: 
10    UART0_RX: GPIO UART 
11 PWM2,I2C3_S: GPIO I2C  PWM  
12 I2S0_8CH_SC: GPIO 
13 PWM3,I2C3_S: GPIO I2C  PWM  
14         GND: 
15    SPDIF_TX: GPIO 
16 I2S0_8CH_SD: GPIO 
17         3V3: 
....
...
...

Enabled pwm3 from rsetup image

After this tried initialising pwm and gpio with python mraa, and same error is showing

>>> import mraa
>>> pin = mraa.Pwm(13)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/mraa.py", line 511, in __init__
    _mraa.Pwm_swiginit(self, _mraa.new_Pwm(pin, owner, chipid))
ValueError: Error initialising PWM on pin
>>> pin = mraa.Gpio(32)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/mraa.py", line 420, in __init__
    _mraa.Gpio_swiginit(self, _mraa.new_Gpio(pin, owner, raw))
ValueError: Invalid GPIO pin specified
Sep 04 07:10:34 rock-pi-s libmraa[5717]: libmraa version v2.1.0-26-gd59936f initialised by user 'root' with EUID 0
Sep 04 07:10:34 rock-pi-s libmraa[5717]: gpio: platform doesn't support chardev, falling back to sysfs
Sep 04 07:10:34 rock-pi-s libmraa[5717]: libmraa initialised for platform 'Radxa ROCK Pi S' of type 25
Sep 04 07:10:42 rock-pi-s libmraa[5717]: pwm_init: pwm0. Failed to open export for writing: No such file or directory
Sep 04 07:10:52 rock-pi-s libmraa[5717]: gpio79: init: Failed to open 'export' for writing: No such file or directory

I installed image b38 tag from the rockpi-s build releases - https://github.com/radxa-build/rock-pi-s/releases.

root@rock-pi-s:/home/rock# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:    11
Codename:   bullseye

My objective is to access gpio, pwm etc. via mraa python in the most updated debian image for rock pi-s.

We are currently using the oldest official radxa rock pi s image from the wiki downloads but we want an image with the updated kernel.

We are using rock pi-s for our fleet of IoT-controllers and we are stuck in this. Your help will be highly appreciated.

Can you please provide answers to the following questions?

RadxaYuntian commented 2 months ago

This issue is closed so further discussion will occur on our forum.