Jump to content

OPi Lite 2 + RPi.GPIO


cond080

Recommended Posts

Hello I have Opi lite 2 + 28byj-48 driver and step motor, and I want to play around, but can't find RPi.GPIO for OPi lite 2,  how can I make it work ?

 

I find pretty good example with raspberry pi http://www.raspberryproject.pl/en/automation/28byj-48-stepper-motor-raspberry-pi/   , I rearranged GPIOs to fit my board but I have error:

  File "testy.py", line 4, in <module>
    import RPi.GPIO as GPIO
ModuleNotFoundError: No module named 'RPi'

 

Welcome to ARMBIAN 5.67.181116 nightly Ubuntu 18.04.1 LTS 4.19.2-sunxi64   
 

Link to comment
Share on other sites

 

On 11/18/2018 at 3:24 AM, martinayotte said:

You can look at this library, but you will need to tweak base register address to meet the one for H6 :

https://github.com/Jeremie-C/OrangePi.GPIO

Just trying to follow up on this GPIO lib thing. I've tried the above suggested OPi.GPIO library and made some mods to match H6 configuration. But I cannot even compile and build successfully due to a missing 'Python.h' header file. Wondering if anyone has made such GPIO module work on Lite 2 or any H6 based board. I'd appreciate any help on this front. Thanks!

Link to comment
Share on other sites

Thanks, Martin. I've fixed that problem. 

I ported library and modified the base addresses to match H6. However, cannot get the designated GPIO pin to work. I tried reading back the port control register, but always got 0x0 value, even the default value, according to the DS, should be 0x7777_7777 or any non-zero value. I'm wondering if this has to do with the 32-bit addressing vs 64-bit. Can anyone point me how to proceed? Really appreciated!

Link to comment
Share on other sites

On 1/28/2019 at 3:23 AM, Hazeline said:

However, cannot get the designated GPIO pin to work

I must admit that I've never used this library, and therefore I don't know how to fix it.

But instead I've used this one https://github.com/duxingkei33/orangepi_PC_gpio_pyH3

I've tweaked it to support 64bits pointers, like I did previously for H5, and then adjusted the SW_PORTC_IO_BASE define to point to H6 registers at 0x0300B000..

 

Link to comment
Share on other sites

On 11/23/2020 at 8:33 AM, pako said:

Perhaps someone will be interested in my contribution.
I have successfully modified the library https://github.com/Jeremie-C/OrangePi.GPIO, so it also works for H6.
You can find the modified library here:
https://github.com/Pako2/OrangePi.GPIO.

Hello Pako, I am absolutely interested in your contribution. I have been trying to mak Orangepi3 LTS GPIO work with Python. No luck so far. As WiFi does not work in Orangepi 3 LTS Jammy Armbian, I have been forced to use Ubuntu and I have not been succesful in compiling your OrangePi.GPIO. Does the library work in Ubuntu at all?

Link to comment
Share on other sites

Hi Cryptimo!
I haven't tried it, but I assume it should work. Unfortunately, I don't own OPi 3 LTS, so I can't even try it.
I looked in the documentation and I see that fortunately the GPIO layout on the header is exactly the same as on the older OPi 3.
When compiling, you can proceed as described on the page https://github.com/Pako2/OrangePi.GPIO.

I only have one patch that I haven't published yet (but I have it ready including the H616/OPi Zero 2 support adding).
For newer versions of Python (3.9 and greater) command

sudo python setup.py install

usually ends with the error message error: command 'aarch64-linux-gnu-gcc' failed with exit status 1.
In that case, the compilation command must be modified as follows (for boards with H6):

sudo CFLAGS="-fcommon" python3 setup.py install --force-h6

Please write here how it went. If there is a problem, I will try to solve it.

 

Pako

Link to comment
Share on other sites

Hello @pako, with "sudo CFLAGS="-fcommon" python3 setup.py install --force-h6" it did compile, thanks fo the help!

 

However, I am now stuck in a new problem, and I do not know if you can help? I can not find the BCM GPIO pinout mappings for Orangepi 3 anywhere. Do you know where to find a mapping of Board-BCM-GPIO numbers?

 

Link to comment
Share on other sites

I am not 100% sure that I will answer this question accurately and truthfully.
In my opinion, the BCM numbering on Orange Pi boards makes no sense (I don't use it myself in principle). This only makes sense for Raspberry Pi boards (BCM is short for Broadcom - the manufacturer of the SoC on RPi boards).
OrangePi.GPIO is "RPi.GPIO drop-in replacement library for Orange Pi Boards" and its original author (Jeremie-C) apparently wanted (for Allwinner SoC boards) to maintain some degree of compatibility with the original RPi.GPIO library.
I actually only made a fork (but extended and fixing some bugs) of the mentioned Jeremie-C project and I did not change the numbering methods introduced by the author.
I prefer to use BOARD numbering, which in my opinion makes the most sense (e.g. it greatly facilitates the portability of code between different Orange Pi boards). SOC numbering can also be beneficial in some cases. The SOC number of a GPIO pin can be easily calculated if you know the pin name (like PH18). You can find the procedure here.
Or you can use the "GPIO" column from the table for the relevant OPi board from this page.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines