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

Commit

Permalink
v2.0.0-beta1: Merged changes from Andy Baker and Reik Hua for compati…
Browse files Browse the repository at this point in the history
…bility with Pi 0, 2 and 3
  • Loading branch information
Chris Hager committed Jun 2, 2016
1 parent c4e8b73 commit 07c776f
Show file tree
Hide file tree
Showing 20 changed files with 462 additions and 101 deletions.
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
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
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
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-beta1'
# 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
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-beta1",
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
4 changes: 2 additions & 2 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-beta1"

# Exposing constants from RPi.GPIO
VERSION_GPIO = _GPIO.VERSION_GPIO
Expand Down Expand Up @@ -266,7 +266,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.

This comment has been minimized.

Copy link
@lurch

lurch Jun 2, 2016

As I mentioned somewhere else - this particular version number shouldn't be being updated with search'n'replace :-(

This comment has been minimized.

Copy link
@metachris

metachris Jun 2, 2016

Owner

Thanks! Updated in the next commit.

"""
_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

This comment has been minimized.

Copy link
@lurch

lurch Jun 2, 2016

Do you need to add "BCM2837" too?
(and I also see some references in google to BCM2710)

This comment has been minimized.

Copy link
@metachris

metachris Jun 2, 2016

Owner

Great input, although I'm not sure on which versions of the Pi it would report "BCM2837" or "BCM2710" with cat /proc/cpuinfo. My Pi3 reports "BCM2709".

This comment has been minimized.

Copy link
@lurch

lurch Jun 2, 2016

Fair enough - I was just guessing, given that the Pi1 has a BCM2835 SoC, the Pi2 has a BCM2836 SoC, and the Pi3 has a BCM2837 SoC. I didn't actually check, sorry.

)
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-beta1/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

0 comments on commit 07c776f

Please sign in to comment.