WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: GPIO on the Raspberry Pi  (Read 21055 times)

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
GPIO on the Raspberry Pi
« on: November 21, 2012, 02:40:29 PM »
I tried following this tutorial for accessing the GPIO on the Raspberry Pi with Python.  But ran into problems (lots of error messages) when I tried to install the python code with this command:

Code: [Select]
sudo python setup.py install
So I tried to access the GPIO pins via bash as instructed here.  But I get an error message on the very first command I type:

Code: [Select]
echo "4" > /sys/class/gpio/export
I get this error message:

Quote
-sh: can't create /sys/class/gpio/export: Permission denied

And yes I tried using sudo and I get the same error message.

Has anyone else tried to access the GPIO on Tiny Core?  I am about to try this on Arch but I am really impressed with Tiny Core and would like to use it for my project.  Let me know.  Thank you so much in advance. =)

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: GPIO on the Raspberry Pi
« Reply #1 on: November 21, 2012, 02:49:39 PM »
Code: [Select]
echo "4" > /sys/class/gpio/export<snip>
And yes I tried using sudo and I get the same error message.
Just to clarify, did you try:
$ sudo echo "4"> /sys/class/gpio/export

Or did you try:
$ sudo -s
# echo "4" > /sys/class/gpio/export

I would expect the first version to fail, but the second version should work (disclaimer: I don't have a raspberry pi to test on, but you have the same issues piping sudo output on regular x86 machines)

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
Re: GPIO on the Raspberry Pi
« Reply #2 on: November 21, 2012, 03:53:38 PM »
Just to clarify, did you try:
$ sudo echo "4"> /sys/class/gpio/export

Or did you try:
$ sudo -s
# echo "4" > /sys/class/gpio/export

I would expect the first version to fail, but the second version should work (disclaimer: I don't have a raspberry pi to test on, but you have the same issues piping sudo output on regular x86 machines)

I tried both

Code: [Select]
sudo echo "21"> /sys/class/gpio/export
and

Code: [Select]
sudo su -
echo "21"> /sys/class/gpio/export

and they both failed.  But

Code: [Select]
sudo -s
echo "21" > /sys/class/gpio/export

executes without an error.  Thank you!  But the voltage on pin 13 is not changing when I type this:

Code: [Select]
echo "21" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio21/direction
echo "1" > /sys/class/gpio/gpio21/value
echo "0" > /sys/class/gpio/gpio21/value

I think I have this mapped right.  I am using this reference.  I also am going to have to get the python thing fixed since that is what I plan to build my project with.

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: GPIO on the Raspberry Pi
« Reply #3 on: November 21, 2012, 08:08:26 PM »
Code: [Select]
sudo -s
echo "21" > /sys/class/gpio/export

executes without an error.  Thank you!  But the voltage on pin 13 is not changing when I type this:

Code: [Select]
echo "21" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio21/direction
echo "1" > /sys/class/gpio/gpio21/value
echo "0" > /sys/class/gpio/gpio21/value

I think I have this mapped right.  I am using this reference.
Unfortunately, until I get my hands on a pi, I can't help you with that error message.
Quote
I also am going to have to get the python thing fixed since that is what I plan to build my project with.
Post the python errors and I might be able to give you some direction/extra help, if you like. Python is the language most of my not-day-job code is written in.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: GPIO on the Raspberry Pi
« Reply #4 on: November 21, 2012, 11:03:12 PM »
Check you have the latest python extension installed, Nov 9 2012.

Install openssl-1.0.0.tcz,  compile-essentials.tcz and python-dev.tcz extensions.  In QEMU RPi.GPIO-0.4.1a builds fine. I did not try it on real hw, 5:02 AM here :(
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: GPIO on the Raspberry Pi
« Reply #5 on: November 21, 2012, 11:55:32 PM »
I wouldn't know if that's of any relevance for what you try to achieve, but posted output is from ash, not bash.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: GPIO on the Raspberry Pi
« Reply #6 on: February 14, 2013, 01:43:50 AM »
python-RPi.GPIO.tcz added to repository

http://code.google.com/p/raspberry-gpio-python/
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline cattail

  • Newbie
  • *
  • Posts: 16
Re: GPIO on the Raspberry Pi
« Reply #7 on: February 16, 2013, 10:58:28 PM »
HI every one.
 
I test this:
piCore-qemu-20130123.tar.bz2

Download:  Qemu-1.3.1-windows.zip , it has :
 qemu-system-armw.exe

piCore's  start.sh( rename to start.bat) use
 qemu-system-arm.exe , 

So must rename: qemu-system-armw.exe  --> qemu-system-arm.exe

After tce-load -i python.tcz , I had python works.
 tce-load -i python-RPi.GPIO.tcz , OK

but if in python
import RPi.GPIO as GPIO
I get:
ImportError: No module named GPIO

I found dep files (tree files) in URL:
distro.ibiblio.org/tinycorelinux/4.x/armv6/tcz/python-RPi.GPIO.tcz.tree

and I use: tce-load -i python-distribute.tcz,
also I had download and tce-load -i 22 tcz files that python-RPi.GPIO.tcz.tree in list, GPIO module also missing.

What step(s) I had miss?

sorry , I can't use \[code\] \[/code\] without mistake...
« Last Edit: February 16, 2013, 11:40:39 PM by cattail »

Offline cattail

  • Newbie
  • *
  • Posts: 16
Re: GPIO on the Raspberry Pi
« Reply #8 on: February 16, 2013, 11:32:02 PM »
And I also try to build it in python
I download RPi.GPIO-0.4.2a.tar.gz from   pypi.python.org
  (and also RPi.GPIO-0.4.1a.tar.gz, the same as 0.4.2a)

After wget and tar it, I run:
(Installed openssl-1.0.0.tcz,  compile-essentials.tcz ,python-dev.tcz and gcc.tcz)

Code: (bash) [Select]
cd ./RPi.GPIO-0.4.2a
tce-load -i python-dev.tcz
 ...
sudo su
python setup.py install

When building "RPi.GPIO" extension, I get :
Code: (bash) [Select]
In file included from /tmp/tcloop/gcc/usr/local/bin/../lib/gcc/armv6l-unknown-linux-gnueabi/4.6.3/include-fixed/syslimits.h:7:0,
                 from /tmp/tcloop/gcc/usr/local/bin/../lib/gcc/armv6l-unknown-linux-gnueabi/4.6.3/include-fixed/limits.h:34,
                 from /usr/local/include/python2.7/Python.h:19,
                 from source/py_gpio.c:23:
/tmp/tcloop/gcc/usr/local/bin/../lib/gcc/armv6l-unknown-linux-gnueabi/4.6.3/include-fixed/limits.h:169:61: fatal error: limits.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1


I guess I was missing a "limits.h" file , how can i get it?
miss a *-dev.tcz ?

And I test 0.4.1a.tar.gz , the same.

python.tcz  version 2.7.3 (default Dec 26 2012 , 17:02:32)
[GCC 4.6.3] on linux 2
Code: (bash) [Select]
uname -a
Linux box 3.2.27 #2 Sat Sep 15 04:44:32 PDT 2012 armv6l GNU/Linux
« Last Edit: February 16, 2013, 11:35:06 PM by cattail »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: GPIO on the Raspberry Pi
« Reply #9 on: February 17, 2013, 01:45:38 AM »
cattail@

Are you trying GPIO in QUEMU?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: GPIO on the Raspberry Pi
« Reply #10 on: February 17, 2013, 01:58:04 AM »
Hi cattail
Quote
I guess I was missing a "limits.h" file , how can i get it?
miss a *-dev.tcz ?
Maybe  eglibc_base-dev.tcz

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: GPIO on the Raspberry Pi
« Reply #11 on: February 17, 2013, 02:27:13 AM »
I can reproduce the issue on a real RPi with a clean system. Will investigate why module not recognised.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline cattail

  • Newbie
  • *
  • Posts: 16
Re: GPIO on the Raspberry Pi
« Reply #12 on: February 17, 2013, 02:41:12 AM »
bmarkus@

yes, I test (try) RPi.GPIO python module  in QEMU 1.3.1(in windows 7)


Rich@
Thank you for the tip,  limits.h error not any more.
But maybe my gcc has something wrong, I'll renew a clean piCore to test it.



« Last Edit: February 17, 2013, 02:58:21 AM by cattail »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: GPIO on the Raspberry Pi
« Reply #13 on: February 17, 2013, 09:40:18 AM »
Hi cattail
Quote
(Installed openssl-1.0.0.tcz,  compile-essentials.tcz ,python-dev.tcz and gcc.tcz)
You should not need to install gcc.tcz or eglibc_base-dev.tcz separately. Compile-essentials.tcz includes the
following as dependencies:
Code: [Select]
autoconf.tcz
automake.tcz
eglibc_base-dev.tcz
file.tcz
gcc.tcz
libtool.tcz
m4.tcz
make.tcz
patch.tcz
which should be installed automatically.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: GPIO on the Raspberry Pi
« Reply #14 on: February 17, 2013, 03:27:11 PM »
Updated python-RPi.GPIO.tcz installation issue fixed. Please note, it requires root access to run.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."