RPi.GPIO port

Post Reply
jfath
Posts: 29
Joined: Wed Apr 08, 2015 10:35 pm
languages_spoken: english
ODROIDs: C1, XU4, XU4Q
Has thanked: 0
Been thanked: 0
Contact:

RPi.GPIO port

Unread post by jfath » Wed Mar 28, 2018 1:05 am

I have ported a subset of RPi.GPIO to work on the C1, C2, XU4, and RPi. Only simple GPIO read and write are currently implemented.

I started with the most recent source from RPi.GPIO and Hardkernels's wiringPi. I also used swkim01's C1 RPi.GPIO port as reference.

https://github.com/jfath/RPi.GPIO-Odroid


I don't actually have a C2 for testing, but the Hardkernel code used for register access handles doing the correct thing for the discovered ODROID platform, so it will likely work. I did take care not to break RPi support, so this library can also be used anywhere the stock RPi.GPIO library was being used.

User avatar
mad_ady
Posts: 7577
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 397 times
Been thanked: 302 times
Contact:

Re: RPi.GPIO port

Unread post by mad_ady » Wed Mar 28, 2018 1:45 am

That's great! @odroid - you should add this info to the wiki.

User avatar
odroid
Site Admin
Posts: 33698
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 515 times
Been thanked: 507 times
Contact:

Re: RPi.GPIO port

Unread post by odroid » Wed Mar 28, 2018 9:10 am

Yeah! Fantastic news.
We will test it on C1/C2/XU4 boards and make WiKi pages within a couple of weeks.

jfath
Posts: 29
Joined: Wed Apr 08, 2015 10:35 pm
languages_spoken: english
ODROIDs: C1, XU4, XU4Q
Has thanked: 0
Been thanked: 0
Contact:

Re: RPi.GPIO port

Unread post by jfath » Wed Mar 28, 2018 9:37 pm

I just noticed that wiringPi has been ported to the N1 and all of the code significantly refactored in the dev branch. Somebody is doing really nice work there.

I took the code I used from the master branch, so I didn't benefit from that work, but the new structure should make it really easy to grab N1 specific code and add it to my RPi.GPIO port. I'll do that as soon as I can get my hands on an N1.

User avatar
odroid
Site Admin
Posts: 33698
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 515 times
Been thanked: 507 times
Contact:

Re: RPi.GPIO port

Unread post by odroid » Thu Mar 29, 2018 11:23 am

We found a minor issue and sent a pull-request. It was already merged. :)
https://github.com/jfath/RPi.GPIO-Odroi ... c6e62b254d
After doing some more tests, we will make a wiki page early next week.

Once we make a decision of N1 project development planning in the middle of April, we will let you know.
Because N1 SoC (RK3399) still has some critical issues such very slow GPIO toggling speed, weird 3.0volt interface instead of 3.3Volt, strange GPIO-IRQ behaviors and so on, we need further investigation.

joshua.yang
Posts: 355
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 12 times
Been thanked: 66 times
Contact:

Re: RPi.GPIO port

Unread post by joshua.yang » Mon Apr 02, 2018 4:38 pm


jfath
Posts: 29
Joined: Wed Apr 08, 2015 10:35 pm
languages_spoken: english
ODROIDs: C1, XU4, XU4Q
Has thanked: 0
Been thanked: 0
Contact:

Re: RPi.GPIO port

Unread post by jfath » Mon Apr 02, 2018 10:28 pm

Looks good to me - thanks! The explanation of BCM numbering and the RPi pinout diagram are really nice.

The only thing you might tweak is noting that root permissions are required, so 'sudo python simplerw.py' is usually the right way to execute the example. Not essential since the test app will return a permissions error, but it might avoid some confusion.

joshua.yang
Posts: 355
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 12 times
Been thanked: 66 times
Contact:

Re: RPi.GPIO port

Unread post by joshua.yang » Tue Apr 03, 2018 10:10 am

Thanks for your review.

To avoid some confusion, I've updated Wiki page to insert sudo command before two Python commands, installation and execute. :)

StefanS
Posts: 4
Joined: Thu Apr 07, 2016 5:03 pm
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: RPi.GPIO port

Unread post by StefanS » Thu Jul 25, 2019 6:25 am

I always got "segmentation fault" when i try to "import RPi.GPIO as GPIO".
Any ideas?

Code: Select all

# cat /etc/debian_version
9.9

Code: Select all

# uname -a
Linux odroid-jessie 3.10.106+ #1 SMP PREEMPT Wed Feb 6 09:01:54 CET 2019 armv7l GNU/Linux

Code: Select all

# sudo python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
Speicherzugriffsfehler
regards

joshua.yang
Posts: 355
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 12 times
Been thanked: 66 times
Contact:

Re: RPi.GPIO port

Unread post by joshua.yang » Thu Jul 25, 2019 9:14 am

StefanS wrote:
Thu Jul 25, 2019 6:25 am
I always got "segmentation fault" when i try to "import RPi.GPIO as GPIO".
Any ideas?

Code: Select all

# cat /etc/debian_version
9.9

Code: Select all

# uname -a
Linux odroid-jessie 3.10.106+ #1 SMP PREEMPT Wed Feb 6 09:01:54 CET 2019 armv7l GNU/Linux

Code: Select all

# sudo python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
Speicherzugriffsfehler
regards
Hi,

What is your board?
Could you try our fork?
https://github.com/joshua-yang/RPi.GPIO-Odroid

Then let me know the result. :)

StefanS
Posts: 4
Joined: Thu Apr 07, 2016 5:03 pm
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: RPi.GPIO port

Unread post by StefanS » Thu Jul 25, 2019 3:09 pm

Board is XU4. This is the result of the wiki-page.
I wonder if no other user had the problem and i don´t know how to determine the problem.

regards

User avatar
odroid
Site Admin
Posts: 33698
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 515 times
Been thanked: 507 times
Contact:

Re: RPi.GPIO port

Unread post by odroid » Thu Jul 25, 2019 3:14 pm

You have to use our Kernel 4.14 on our Ubuntu image for the same GPIO access.

Do you know who made the Debian OS image? Is there Kernel 4.14 update?

StefanS
Posts: 4
Joined: Thu Apr 07, 2016 5:03 pm
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: RPi.GPIO port

Unread post by StefanS » Thu Jul 25, 2019 3:21 pm

I don´t know if there is a kernel update. Image is from meveric (jessie) viewtopic.php?f=96&t=17542#p114709 and updated with
update, upgrade and dist-upgrade. Do you think its possible?

User avatar
odroid
Site Admin
Posts: 33698
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 515 times
Been thanked: 507 times
Contact:

Re: RPi.GPIO port

Unread post by odroid » Thu Jul 25, 2019 3:34 pm


StefanS
Posts: 4
Joined: Thu Apr 07, 2016 5:03 pm
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: RPi.GPIO port

Unread post by StefanS » Sat Jul 27, 2019 6:03 am

This worked for me: Kernel 4.14 :D
But still "segmentation fault" with the import of RPi.GPIO :(

joshua.yang
Posts: 355
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 12 times
Been thanked: 66 times
Contact:

Re: RPi.GPIO port

Unread post by joshua.yang » Mon Jul 29, 2019 9:50 am

StefanS wrote:
Sat Jul 27, 2019 6:03 am
This worked for me: Kernel 4.14 :D
But still "segmentation fault" with the import of RPi.GPIO :(
It should work on Python REPL. I just have tested on my XU4. Please see the below.

Code: Select all

root@odroid:~# uname -a
Linux odroid 4.14.133-165 #1 SMP PREEMPT Mon Jul 15 22:14:09 -03 2019 armv7l armv7l armv7l GNU/Linux
root@odroid:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.2 LTS
Release:	18.04
Codename:	bionic
root@odroid:~# python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.input(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: You must setup() the GPIO channel first
>>> GPIO.setup(4, GPIO.IN)
>>> GPIO.input(4)
1
>>> GPIO.setup(4, GPIO.OUT)
>>> GPIO.output(4, GPIO.HIGH)
>>> GPIO.input(4)
1
>>> GPIO.output(4, GPIO.LOW)
>>> GPIO.input(4)
0
>>>
I think something goes wrong in your system. How about getting rid of all of RPi.GPIO-odroid things and installing it again?

dan.t
Posts: 1
Joined: Sat Jan 25, 2020 2:41 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: RPi.GPIO port

Unread post by dan.t » Thu Mar 26, 2020 1:12 am

Hey, hoping you guys can help me troubleshoot some installation problems I ran into trying to get this installed on an Odroid C2 with Ubuntu 16.04.

Here's the terminal output: (Note that I deleted most of the 'error' lines because they were repetitive)

root@odroid64:~# git clone https://github.com/joshua-yang/RPi.GPIO-Odroid
Cloning into 'RPi.GPIO-Odroid'...
remote: Enumerating objects: 192, done.
remote: Total 192 (delta 0), reused 0 (delta 0), pack-reused 192
Receiving objects: 100% (192/192), 76.71 KiB | 0 bytes/s, done.
Resolving deltas: 100% (129/129), done.
Checking connectivity... done.
root@odroid64:~# cd RPi.GPIO-Odroid
root@odroid64:~/RPi.GPIO-Odroid# sudo python setup.py build install
running build
running build_py
creating build
creating build/lib.linux-aarch64-2.7
creating build/lib.linux-aarch64-2.7/RPi
copying RPi/__init__.py -> build/lib.linux-aarch64-2.7/RPi
creating build/lib.linux-aarch64-2.7/RPi/GPIO
copying RPi/GPIO/__init__.py -> build/lib.linux-aarch64-2.7/RPi/GPIO
running build_ext
building 'RPi._GPIO' extension
creating build/temp.linux-aarch64-2.7
creating build/temp.linux-aarch64-2.7/source
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c source/py_gpio.c -o build/temp.linux-aarch64-2.7/source/py_gpio.o
In file included from /usr/include/aarch64-linux-gnu/bits/local_lim.h:39:0,
from /usr/include/aarch64-linux-gnu/bits/posix1_lim.h:160,
from /usr/include/limits.h:143,
from /usr/lib/gcc/aarch64-linux-gnu/5/include-fixed/limits.h:168,
from /usr/lib/gcc/aarch64-linux-gnu/5/include-fixed/syslimits.h:7,
from /usr/lib/gcc/aarch64-linux-gnu/5/include-fixed/limits.h:3,
from /usr/include/python2.7/Python.h:19,
from source/py_gpio.c:23:
/usr/include/linux/limits.h:1:1: error: stray ‘\272’ in program
? 7? ? ? 8?
^
/usr/include/linux/limits.h:1:1: error: stray ‘\1’ in program
/usr/include/linux/limits.h:1:1: error: stray ‘\2’ in program
/usr/include/linux/limits.h:1:5: error: expected identifier or ‘(’ before numeric constant
? 7? ? ? 8?
^
/usr/include/linux/limits.h:1:5: error: stray ‘\17’ in program
/usr/include/linux/limits.h:1:5: error: stray ‘\10’ in program
/usr/include/linux/limits.h:1:5: error: stray ‘\17’ in program
/usr/include/linux/limits.h:1:5: error: stray ‘\10’ in program
/usr/include/linux/limits.h:1:5: error: stray ‘\317’ in program
/usr/include/linux/limits.h:1:5: error: stray ‘\1’ in program
/usr/include/linux/limits.h:1:5: error: stray ‘\307’ in program
/usr/include/linux/limits.h:1:5: error: stray ‘\272’ in program
/usr/include/linux/limits.h:1:5: error: stray ‘\1’ in program

/usr/include/linux/limits.h:4:111: error: stray ‘\241’ in program
/usr/include/linux/limits.h:4:111: error: stray ‘\252’ in program
/usr/include/linux/limits.h:4:111: error: stray ‘\247’ in program
/usr/include/linux/limits.h:4:111: error: stray ‘\3’ in program
/usr/include/linux/limits.h:4:111: error: stray ‘\252’ in program
/usr/include/linux/limits.h:4:111: error: stray ‘\247’ in program
/usr/include/linux/limits.h:4:111: error: stray ‘\3’ in program
/usr/include/linux/limits.h:4:111: error: stray ‘\374’ in program
In file included from /usr/include/aarch64-linux-gnu/bits/local_lim.h:39:0,
from /usr/include/aarch64-linux-gnu/bits/posix1_lim.h:160,
from /usr/include/limits.h:143,
from /usr/lib/gcc/aarch64-linux-gnu/5/include-fixed/limits.h:168,
from /usr/lib/gcc/aarch64-linux-gnu/5/include-fixed/syslimits.h:7,
from /usr/lib/gcc/aarch64-linux-gnu/5/include-fixed/limits.h:3,
from /usr/include/python2.7/Python.h:19,
from source/py_gpio.c:23:
/usr/include/linux/limits.h:4:171: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘|’ token
~ q ? U? ? ? V? ?{ ? W? '~ ?
^
/usr/include/linux/limits.h:4:171: error: stray ‘\276’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\1’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\2’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\17’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\10’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\317’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\1’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\272’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\241’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\253’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\247’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\3’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\253’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\247’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\3’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\374’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\376’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\375’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\335’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\244’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\277’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\1’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\2’ in program
/usr/include/linux/limits.h:4:171: error: stray ‘\321’ in program
/usr/include/linux/limits.h:4:219: error: expected identifier or ‘(’ before ‘%’ token
V? ?{ ? W? '~ ? X? ? ? Y? {? ?? ?? *?

/usr/include/linux/limits.h:4:219: error: stray ‘\7’ in program
In file included from /usr/include/linux/errno.h:1:0,
from /usr/include/aarch64-linux-gnu/bits/errno.h:24,
from /usr/include/errno.h:35,
from /usr/include/python2.7/Python.h:40,
from source/py_gpio.c:23:
/usr/include/aarch64-linux-gnu/asm/errno.h:1:31: fatal error: /usr/include/asm-generic/errno.h: Input/output error
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
root@odroid64:~/RPi.GPIO-Odroid#


Thank you for your consideration, please let me know if I can provide other information that may be useful.

Dan

User avatar
tobetter
Posts: 4673
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 89 times
Been thanked: 338 times
Contact:

Re: RPi.GPIO port

Unread post by tobetter » Thu Mar 26, 2020 1:19 am

I suspect the file system on your memory card has somehow defected? Can you please flash the new OS image and try again?

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 4 guests