Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: phillip.toone on November 21, 2012, 02:40:29 PM

Title: GPIO on the Raspberry Pi
Post by: phillip.toone on November 21, 2012, 02:40:29 PM
I tried following this (http://lwk.mjhosting.co.uk/?p=343) 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 (http://log.liminastudio.com/writing/tutorials/tutorial-how-to-use-your-raspberry-pi-like-an-arduino).  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. =)
Title: Re: GPIO on the Raspberry Pi
Post by: althalus 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)
Title: Re: GPIO on the Raspberry Pi
Post by: phillip.toone 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 (http://elinux.org/RPi_BCM2835_GPIOs) reference.  I also am going to have to get the python thing fixed since that is what I plan to build my project with.
Title: Re: GPIO on the Raspberry Pi
Post by: althalus 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 (http://elinux.org/RPi_BCM2835_GPIOs) 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.
Title: Re: GPIO on the Raspberry Pi
Post by: bmarkus 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 :(
Title: Re: GPIO on the Raspberry Pi
Post by: tinypoodle 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.
Title: Re: GPIO on the Raspberry Pi
Post by: bmarkus on February 14, 2013, 01:43:50 AM
python-RPi.GPIO.tcz added to repository

http://code.google.com/p/raspberry-gpio-python/
Title: Re: GPIO on the Raspberry Pi
Post by: cattail 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...
Title: Re: GPIO on the Raspberry Pi
Post by: cattail 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
Title: Re: GPIO on the Raspberry Pi
Post by: bmarkus on February 17, 2013, 01:45:38 AM
cattail@

Are you trying GPIO in QUEMU?
Title: Re: GPIO on the Raspberry Pi
Post by: Rich 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
Title: Re: GPIO on the Raspberry Pi
Post by: bmarkus 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.
Title: Re: GPIO on the Raspberry Pi
Post by: cattail 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.



Title: Re: GPIO on the Raspberry Pi
Post by: Rich 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.
Title: Re: GPIO on the Raspberry Pi
Post by: bmarkus on February 17, 2013, 03:27:11 PM
Updated python-RPi.GPIO.tcz installation issue fixed. Please note, it requires root access to run.
Title: Re: GPIO on the Raspberry Pi
Post by: cattail on February 17, 2013, 09:15:09 PM
(Just write here to memory)
After a clean QEMU piCore ,
use:   tce , press "s" 4 search, "q" 4 quit info, "i" 4 install these  tcz(s)

Xorg-7.6
Xprogs
flwm
wbar

I install XWINDOW on mini CLI mode piCore  , and startx can working.
(So I can use Apps select fastest mirror to speed up install tczs.)

install gcc.tcz (tree), python.tcz (tree) , eglibc_base-dev.tcz, openssl-1.0.0.tcz,
(compile-essentials.tcz is not requited?)
I can do this OK
   cd RPi.GPIO-0.4.2a
   sudo python setup.py install

----------------
Finaly I get RPi.GPIO response , but not know by python setup.py install or new RPi.GPIO(tcz) in repo :

>>>import RPi.GPIO as GPIO
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
RPi.GPIO.SetupException: This module can only be run on a Raspberry Pi!

I guess QEMU not supply GPIO HW simulate .
 I have a real Pi board, I'll test on it ( but maybe it have some usb power supply issue...)