Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

V2b2 to really make it work with raspberry pi 3 #110

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,26 @@ License
<http://www.gnu.org/licenses/lgpl-3.0-standalone.html>


Building for Development
------------------------

On the Raspberry Pi:

sudo apt-get install python-dev python3 python3.2-dev

On the developer machine::

fab upload
fab build_gpio
fab build_pwm


Special Thanks
--------------

Andy Baker and Reik Hua for supplying compatibility updates for the
Raspberry Pi 0, 2 and 3.

`csegit <https://github.com/csegit>`_, `waveform80 <https://github.com/waveform80>`_,
`nils-werner <https://github.com/nils-werner>`_, `friedcell <https://github.com/friedcell>`_,
`zejn <https://github.com/zejn>`_, `dbeal <https://github.com/dbeal>`_,
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.1
2.0.0-beta1
12 changes: 12 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
rpio (2.0.0-b2) unstable; urgency=low

* Enhance support for Raspberry Pi 3

-- Doom <[email protected]> Thu, 28 Jul 2016

rpio (2.0.0-beta1) unstable; urgency=low

* Support for Raspberry Pi 0, 2, 3 (thanks to Andy Baker and Reik Hua)

-- Chris Hager <[email protected]> Thu, 02 Jun 2016 21:32:58 +0100

rpio (0.10.1) unstable; urgency=low

* Updated debian/control Standards-Version to 3.9.3.1
Expand Down
Empty file modified debian/rules
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion documentation/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# built documents.
#
# The short X.Y version.
version = '0.10.1'
version = '2.0.0-b2'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
11 changes: 8 additions & 3 deletions documentation/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Documentation
News
----

* v2.0.0-beta1: RPIO works with Raspberry Pi Zero, 2 and 3 (Thanks to Andy Baker and Reik Hua)
* v0.9.2: :ref:`PWM via DMA <ref-rpio-pwm-py>`
* v0.8.4: ``rpio-curses``
* v0.8.2: Socket server callbacks with :ref:`RPIO.add_tcp_callback(port, callback, threaded_callback=False) <ref-rpio-py>`
Expand Down Expand Up @@ -113,6 +114,10 @@ License & Copyright
Changes
-------

* v2.0.0-beta1

* RPIO works with Raspberry Pi Zero, 2 and 3 (Thanks to Andy Baker and Reik Hua)

* v0.11.0

* Merged various pull requests: Arch package link, bugfixes, allow Pi to control
Expand Down Expand Up @@ -157,9 +162,9 @@ Changes
* v0.8.2

* Added TCP socket callbacks
* ``RPIO`` does not auto-clean interfaces on exceptions anymore, but will auto-clean them
* ``RPIO`` does not auto-clean interfaces on exceptions anymore, but will auto-clean them
as needed. This means you should now call ``RPIO.cleanup_interrupts()`` to properly close
the sockets and unexport the interfaces.
the sockets and unexport the interfaces.
* Renamed ``RPIO.rpi_sysinfo()`` to ``RPIO.sysinfo()``


Expand All @@ -176,7 +181,7 @@ Changes


* v0.7.1

* Refactoring and cleanup of c_gpio
* Added new constants and methods (see documentation above)
* Bugfixes
Expand Down
10 changes: 7 additions & 3 deletions examples/example3_pwm_servo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
RPIO Documentation: http://pythonhosted.org/RPIO
"""
from RPIO import PWM
import time

servo = PWM.Servo()

# Add servo pulse for GPIO 17 with 1200µs (1.2ms)
servo.set_servo(17, 1200)
servo.set_servo(2, 1200)

# Add servo pulse for GPIO 17 with 2000µs (2.0ms)
servo.set_servo(17, 2000)
#servo.set_servo(17, 2000)

# Clear servo on GPIO17
servo.stop_servo(17)
#servo.stop_servo(17)

time.sleep(20)
print('ended')
3 changes: 2 additions & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

# Set default hosts
if not env.hosts:
env.hosts = ["raspberry_dev_local"]
# env.hosts = ["raspberry_dev_local"]
env.hosts = ["omxdev"]


def _get_cur_version():
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ def read(fname):

setup(
name="RPIO",
version="0.10.1",
version="2.0.0-b2",
package_dir={"": "source"},
packages=['RPIO', 'RPIO.PWM'],
ext_modules=[
Extension('RPIO._GPIO', ['source/c_gpio/py_gpio.c',
'source/c_gpio/c_gpio.c', 'source/c_gpio/cpuinfo.c'],
extra_compile_args=["-Wno-error=declaration-after-statement"]),
Extension('RPIO.PWM._PWM', ['source/c_pwm/pwm.c',
Extension('RPIO.PWM._PWM', ['source/c_pwm/pwm.c', 'source/c_pwm/mailbox.c',
'source/c_pwm/pwm_py.c'],
extra_compile_args=["-Wno-error=declaration-after-statement"])],
scripts=["source/scripts/rpio", "source/scripts/rpio-curses"],
Expand Down
2 changes: 1 addition & 1 deletion source/RPIO/PWM/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def set_servo(self, gpio, pulse_width_us):
if _subcycle_us != self._subcycle_time_us:
raise AttributeError(("Error: DMA channel %s is setup with a "
"subcycle_time of %sus (instead of %sus)") % \
(self._dma_channel, _subcycle_us,
(self._dma_channel, _subcycle_us,
self._subcycle_time_us))
else:
init_channel(self._dma_channel, self._subcycle_time_us)
Expand Down
3 changes: 2 additions & 1 deletion source/RPIO/_RPIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ def add_interrupt_callback(self, gpio_id, callback, edge='both',
if RPIO.gpio_function(int(gpio_id)) == RPIO.IN:
RPIO.set_pullupdn(gpio_id, pull_up_down)
else:
index=RPIO.gpio_function(int(gpio_id))
debug("- changing gpio function from %s to INPUT" % \
(GPIO_FUNCTIONS[RPIO.gpio_function(int(gpio_id))]))
(GPIO_FUNCTIONS[index] if index in GPIO_FUNCTIONS else '???'))
RPIO.setup(gpio_id, RPIO.IN, pull_up_down)

# Prepare the callback (wrap in Thread if needed)
Expand Down
11 changes: 7 additions & 4 deletions source/RPIO/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def socket_callback(socket, val):
from RPIO._RPIO import Interruptor


VERSION = "0.10.1"
VERSION = "2.0.0-b2"

# Exposing constants from RPi.GPIO
VERSION_GPIO = _GPIO.VERSION_GPIO
Expand Down Expand Up @@ -159,7 +159,9 @@ def socket_callback(socket, val):
'd': ('B', '2.0', 512, 'Egoman'),
'e': ('B', '2.0', 512, 'Sony'),
'f': ('B', '2.0', 512, 'Qisda'),
'10': ('B+', '1.0', 512, 'Sony')
'10': ('B+', '1.0', 512, 'Sony'),
'a02082': ('B', '3.0', 1024, '?')

}

# List of valid bcm gpio ids for raspberry rev1, rev2 and rev3. Used for inspect-all.
Expand All @@ -183,7 +185,8 @@ def socket_callback(socket, val):

def sysinfo():
""" Returns (model, revision, mb-ram, maker) for this raspberry """
return (RPI_REVISION_HEX,) + MODEL_DATA[RPI_REVISION_HEX.lstrip("0")]
infos=MODEL_DATA[RPI_REVISION_HEX.lstrip("0")] if RPI_REVISION_HEX.lstrip("0") in MODEL_DATA else ('?','?',-1,'?')
return (RPI_REVISION_HEX,) + infos


def version():
Expand Down Expand Up @@ -266,7 +269,7 @@ def cleanup_interrupts():
"""
Removes all callbacks and closes used GPIO interfaces and sockets. After
this you'll need to re-add the interrupt callbacks before waiting for
interrupts again. Since RPIO v0.10.1 this is done automatically on exit.
interrupts again. Since RPIO v2.0.0-beta1 this is done automatically on exit.
"""
_rpio.cleanup_interrupts()

Expand Down
4 changes: 2 additions & 2 deletions source/c_gpio/c_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ setup(void)
if ((uint32_t)gpio_mem % PAGE_SIZE)
gpio_mem += PAGE_SIZE - ((uint32_t)gpio_mem % PAGE_SIZE);

gpio_map = (uint32_t *)mmap( (void *)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, GPIO_BASE);
gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, GPIO_BASE);

if ((uint32_t)gpio_map < 0)
return SETUP_MMAP_FAIL;
Expand Down Expand Up @@ -163,5 +163,5 @@ void
cleanup(void)
{
// fixme - set all gpios back to input
munmap((void *)gpio_map, BLOCK_SIZE);
munmap((caddr_t)gpio_map, BLOCK_SIZE);
}
8 changes: 6 additions & 2 deletions source/c_gpio/cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// revision_hex will be four characters revision id (eg. '0004'),
// the over-voltage header, if present, is removed (since it is
// not consistently present on all overclocked boards).
int
int
get_cpuinfo_revision(char *revision_hex)
{
FILE *fp;
Expand All @@ -49,7 +49,11 @@ get_cpuinfo_revision(char *revision_hex)
while(!feof(fp)) {
fgets(buffer, sizeof(buffer) , fp);
sscanf(buffer, "Hardware : %s", hardware);
if (strcmp(hardware, "BCM2708") == 0)
if (strcmp(hardware, "BCM2708") == 0||
strcmp(hardware, "BCM2709") == 0||
strcmp(hardware, "BCM2835") == 0||
strcmp(hardware, "BCM2836") == 0
)
rpi_found = 1;
sscanf(buffer, "Revision : %s", revision_hex);
}
Expand Down
4 changes: 2 additions & 2 deletions source/c_gpio/py_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* http://pythonhosted.org/RPIO
*
* py_gpio.c is based on RPi.GPIO by Ben Croston, and provides a Python interface to
* interact with the gpio-related C methods.
* interact with the gpio-related C methods.
*/
#include "Python.h"
#include "c_gpio.h"
Expand Down Expand Up @@ -547,7 +547,7 @@ PyMODINIT_FUNC init_GPIO(void)
rpi_revision_hex = Py_BuildValue("s", revision_hex);
PyModule_AddObject(module, "RPI_REVISION_HEX", rpi_revision_hex);

version = Py_BuildValue("s", "0.10.1/0.4.2a");
version = Py_BuildValue("s", "2.0.0-b2/0.4.2a");
PyModule_AddObject(module, "VERSION_GPIO", version);

// set up mmaped areas
Expand Down
9 changes: 6 additions & 3 deletions source/c_pwm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ pwm:

py2.6:
mkdir -p build
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c mailbox.c -o build/mailbox.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c pwm.c -o build/pwm.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c pwm_py.c -o build/pwm_py.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/pwm.o build/pwm_py.o -o _PWM.so
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/mailbox.o build/pwm.o build/pwm_py.o -o _PWM.so
rm -rf build

py2.7:
mkdir -p build
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c mailbox.c -o build/mailbox.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pwm.c -o build/pwm.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pwm_py.c -o build/pwm_py.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/pwm.o build/pwm_py.o -o _PWM.so
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/mailbox.o build/pwm.o build/pwm_py.o -o _PWM.so
rm -rf build

py3.2:
mkdir -p build
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python3.2mu -c mailbox.c -o build/mailbox.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python3.2mu -c pwm.c -o build/pwm.o
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python3.2mu -c pwm_py.c -o build/pwm_py.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/pwm.o build/pwm_py.o -o _PWM.so
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/mailbox.o build/pwm.o build/pwm_py.o -o _PWM.so
rm -rf build
Loading