Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/raspicom-module: new aport

From: Marian Buschsieweke <mari.hahn_at_wwu.de>
Date: Thu, 7 May 2015 09:31:11 +0200

http://www.amescon.com/products/raspicomm/

Kernel module for RS-485 Port and OpenRC services to set up RTC, Joystick and
LEDs of Amescon's RasPiComm module

*fixed Patch
---
 testing/raspicomm-module/APKBUILD                  | 83 ++++++++++++++++++++++
 testing/raspicomm-module/raspicomm-joystick        | 46 ++++++++++++
 testing/raspicomm-module/raspicomm-leds            | 40 +++++++++++
 testing/raspicomm-module/raspicomm-module.8        | 45 ++++++++++++
 .../raspicomm-module/raspicomm-module.pre-install  |  2 +
 testing/raspicomm-module/raspicomm-rtc             | 14 ++++
 6 files changed, 230 insertions(+)
 create mode 100644 testing/raspicomm-module/APKBUILD
 create mode 100644 testing/raspicomm-module/raspicomm-joystick
 create mode 100644 testing/raspicomm-module/raspicomm-leds
 create mode 100644 testing/raspicomm-module/raspicomm-module.8
 create mode 100644 testing/raspicomm-module/raspicomm-module.pre-install
 create mode 100644 testing/raspicomm-module/raspicomm-rtc
diff --git a/testing/raspicomm-module/APKBUILD b/testing/raspicomm-module/APKBUILD
new file mode 100644
index 0000000..bf3dd99
--- /dev/null
+++ b/testing/raspicomm-module/APKBUILD
_at_@ -0,0 +1,83 @@
+# Contributor: Marian Buschsieweke <mari.hahn_at_wwu.de>
+
+_flavor=rpi
+_kpkg=linux-$_flavor
+_kver=3.18.12
+_kpkgrel=0
+_mypkgrel=0
+_realname=raspicomm-module
+
+# verify the kernel version before entering chroot
+if [ -f ../../main/linux-${_flavor}/APKBUILD ]; then
+	. ../../main/linux-${_flavor}/APKBUILD
+	[ "$_kver" != "$pkgver" ] && die "${_realname}: please update _kver to $pkgver"
+	[ "$_kpkgrel" != "$pkgrel" ] && die "${_realname}: please update _kpkgrel to $pkgrel"
+fi
+
+_kpkgver="$_kver-r$_kpkgrel"
+_abi_release=${_kver}-${_kpkgrel}-${_flavor}
+
+pkgname=${_realname} # This package is only useful on the Raspberry Pi, so no need to tag pkgname with kernel flavor
+pkgver=$_kver
+# when chaning _raspicommver we *must* bump _mypkgrel
+_raspicommver=1.12
+pkgrel=$(( $_kpkgrel + $_mypkgrel ))
+
+pkgdesc="Kernel module for RS-485 Port and OpenRC services to set up RTC, Joystick and LEDs of Amescon's RasPiComm module"
+url="http://www.amescon.com/products/raspicomm/"
+arch="all"
+license="GPL2" # See module.h line 7
+depends="linux-${_flavor}=${_kpkgver}"
+depends_dev="linux-${_flavor}-dev=${_kpkgver}"
+makedepends="$depends_dev"
+install="${pkgname}.pre-install"
+subpackages="$pkgname-doc"
+source="saveas-http://github.com/amescon/${_realname}/archive/v${_raspicommver}.tar.gz/raspicomm-module-v${_raspicommver}.tar.gz
+        raspicomm-rtc
+        raspicomm-joystick
+        raspicomm-leds
+        ${pkgname}.8"
+pkggroups="gpio"
+
+_builddir="${srcdir}/${_realname}-${_raspicommver}"
+_module_name="raspicommrs485"
+
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+	cd "$_builddir"
+	export GCC_SPECS=hardenednopie.specs
+	make -f Makefile_rpi
+}
+
+package() {
+	cd "$_builddir"
+	install -Dm644 ${_module_name}.ko "${pkgdir}/lib/modules/${_abi_release}/kernel/custom/${_module_name}.ko"
+	install -Dm755 ../raspicomm-rtc "${pkgdir}/etc/init.d/raspicomm-rtc"
+	install -Dm755 ../raspicomm-joystick "${pkgdir}/etc/init.d/raspicomm-joystick"
+	install -Dm755 ../raspicomm-leds "${pkgdir}/etc/init.d/raspicomm-leds"
+	install -Dm644 "../${pkgname}.8" "${pkgdir}/usr/share/man/man8/${pkgname}.8"
+}
+md5sums="8d42142190e5e2794e74a244322bf8b2  raspicomm-module-v1.12.tar.gz
+31897ade3059f4835711f5e7239977bf  raspicomm-rtc
+6bb85ad9e849f5774688be96166dd1d4  raspicomm-joystick
+afcda01e94f534e807255ffd2806782b  raspicomm-leds
+4d4dc6caa33c81f8a0fb5ce94bf8b814  raspicomm-module.8"
+sha256sums="b55de7e3a0304a6868a5bed6f15cea0f62cb99bc2f07474b563d413ea5787ebb  raspicomm-module-v1.12.tar.gz
+964e7a9c459cfcb6f46c92e8a20bd35409b271d680f62734342803df94a61557  raspicomm-rtc
+c1c78ee6e759fb64c190a6227607e997f8f5889af4507c70046de2805cc2f7e9  raspicomm-joystick
+9c9226439e7ca3ae3a7f144488df56e13de07537ca4b0473807d5919f377d2e7  raspicomm-leds
+e722858a4d440192bf20d5665a18299f94d1f95f909fc10639d98a846ad4e81f  raspicomm-module.8"
+sha512sums="d088d62536690b9abfcdf73b2ff2fb45a8fdbfa03a50108bafa66fde07cea221cb882f999cb88e28f8c51538b515dbd13ae33f435267018d6458a2dca5fc38fa  raspicomm-module-v1.12.tar.gz
+445759da30783a1aeb32f88b0fc3241417028fbd2b2ff510817bdbff49be653839f8d7cb460805999e1c943dea7b66ad1dfe37c43f47cf5736690ed5e239b467  raspicomm-rtc
+5d76fd8121574993ef6710a80d54ce2dcd8a7a55609c00f3394322f90ac58b72f311ee0b02251679758ac7f6bd9ac9db226676dc55bafc3857df6f64550d409d  raspicomm-joystick
+12c791a27f38db94bc7e2222d5a517d79f6ee495122d50c3687e94a29dc0126291fb0f17327b704d0be4549e2b85b5d5ac9be1f7cb3e96e5e497c7ac91f40a41  raspicomm-leds
+25ae7b0356f866c3e74b4f447f5121c868bfaa154266752d29658ef3640866037fa08607833364c463566b46e61281e02212dc02f70779fc00561d81b30e37f6  raspicomm-module.8"
diff --git a/testing/raspicomm-module/raspicomm-joystick b/testing/raspicomm-module/raspicomm-joystick
new file mode 100644
index 0000000..f7d342c
--- /dev/null
+++ b/testing/raspicomm-module/raspicomm-joystick
_at_@ -0,0 +1,46 @@
+#!/sbin/openrc-run
+# Enable the joystick on Amescon's RasPiComm module
+
+gpio_up() {
+	if [ ! -e "/sys/class/gpio/gpio$1" ]; then
+		echo $1 > /sys/class/gpio/export
+	fi
+	echo $2 > "/sys/class/gpio/gpio$1/direction"
+
+	chmod 664 "/sys/class/gpio/gpio$1/value"
+	chown root:gpio "/sys/class/gpio/gpio$1/value"
+	ln -s "/sys/class/gpio/gpio$1/value" "/dev/raspicomm/$3"
+}
+
+gpio_down() {
+	if [ -e "/sys/class/gpio/gpio$1" ]; then
+		echo $1 > /sys/class/gpio/unexport
+	fi
+
+	rm -f "/dev/raspicomm/$2"
+}
+
+prepare_folder() {
+	mkdir -p "/dev/raspicomm"
+}
+
+start() {
+	ebegin "Exporting RasPiComm's joystick"
+	prepare_folder
+	gpio_up  "4" "in" "js_right"
+	gpio_up "22" "in" "js_push"
+	gpio_up "23" "in" "js_down"
+	gpio_up "24" "in" "js_left"
+	gpio_up "25" "in" "js_up"
+	eend $?
+}
+
+stop() {
+	ebegin "Unexporting RasPiComm's joystick"
+	gpio_down  "4" "js_right"
+	gpio_down "22" "js_push"
+	gpio_down "23" "js_down"
+	gpio_down "24" "js_left"
+	gpio_down "25" "js_up"
+	eend $?
+}
diff --git a/testing/raspicomm-module/raspicomm-leds b/testing/raspicomm-module/raspicomm-leds
new file mode 100644
index 0000000..ecbd003
--- /dev/null
+++ b/testing/raspicomm-module/raspicomm-leds
_at_@ -0,0 +1,40 @@
+#!/sbin/openrc-run
+# Enable the joystick on Amescon's RasPiComm module
+
+gpio_up() {
+	if [ ! -e "/sys/class/gpio/gpio$1" ]; then
+		echo $1 > /sys/class/gpio/export
+	fi
+	echo $2 > "/sys/class/gpio/gpio$1/direction"
+
+	chmod 664 "/sys/class/gpio/gpio$1/value"
+	chown root:gpio "/sys/class/gpio/gpio$1/value"
+	ln -s "/sys/class/gpio/gpio$1/value" "/dev/raspicomm/$3"
+}
+
+gpio_down() {
+	if [ -e "/sys/class/gpio/gpio$1" ]; then
+		echo $1 > /sys/class/gpio/unexport
+	fi
+
+	rm -f "/dev/raspicomm/$2"
+}
+
+prepare_folder() {
+	mkdir -p "/dev/raspicomm"
+}
+
+start() {
+	ebegin "Exporting RasPiComm's LEDs"
+	prepare_folder
+	gpio_up  "18" "out" "led_1"
+	gpio_up  "27" "out" "led_2"
+	eend $?
+}
+
+stop() {
+	ebegin "Unexporting RasPiComm's LEDs"
+	gpio_down "18" "led_1"
+	gpio_down "27" "led_2"
+	eend $?
+}
diff --git a/testing/raspicomm-module/raspicomm-module.8 b/testing/raspicomm-module/raspicomm-module.8
new file mode 100644
index 0000000..d1fe242
--- /dev/null
+++ b/testing/raspicomm-module/raspicomm-module.8
_at_@ -0,0 +1,45 @@
+.TH "raspicomm-module" "8" "May 06, 2015"
+.SH
+NAME
+.PP
+raspicomm\-module \- A alpine package containing a kernel module and OpenRC
+services to access Ameson's RasPiComm module
+.SH
+DESCRIPTION
+.PP
+With this packet all features of the RaspiComm Module are available.
+.SS
+RS\-232 port
+.PP
+The RS\-232 port is supported out of the box by Alpine Linux's kernel. The
+device is found at \f[C]/dev/ttyAMA0\f[]\&.
+.SS
+i2c connector
+.PP
+The i2c connector is supported out of the box \- it just connects a fancy plug
+to the Raspberry Pis i2c pins.
+.SS
+RS\-485 port
+.PP
+The RS\-485 port is supported by the kernel module \f[C]raspicommrs485\f[] included
+in this package. The device is found at \f[C]/dev/ttyRPC0\f[]\&.
+.SS
+Real time clock
+.PP
+The real time clock can be set up with the OpenRC service \f[C]raspicomm\-rtc\f[]\&. You
+can "unexport" the clock by stopping the service.
+.SS
+Joystick
+.PP
+The joysticks GPIO pins can be set up with the OpenRC service
+\f[C]raspicomm\-joystick\f[]\&. For convenience the GPIOs can be accessed by users in
+the group \f[C]gpio\f[] and symlinks to the GPIO's value will be stored at
+\f[C]/dev/raspicomm\f[] with human readable names. By stopping the service the GPIOs
+will be unexported.
+.SS
+LEDs
+.PP
+The LEDs GPIO pins can be set up with the OpenRC service \f[C]raspicomm\-leds\f[]\&. For
+convenience the GPIOs can be accessed by users in the group \f[C]gpio\f[] and symlinks
+to the GPIO's value will be stored at \f[C]/dev/raspicomm\f[] with human readable
+names. By stopping the service the GPIOs will be unexported.
diff --git a/testing/raspicomm-module/raspicomm-module.pre-install b/testing/raspicomm-module/raspicomm-module.pre-install
new file mode 100644
index 0000000..5f42b5b
--- /dev/null
+++ b/testing/raspicomm-module/raspicomm-module.pre-install
_at_@ -0,0 +1,2 @@
+#!/bin/sh
+adduser -S gpio 2>/dev/null
diff --git a/testing/raspicomm-module/raspicomm-rtc b/testing/raspicomm-module/raspicomm-rtc
new file mode 100644
index 0000000..fbcf45c
--- /dev/null
+++ b/testing/raspicomm-module/raspicomm-rtc
_at_@ -0,0 +1,14 @@
+#!/sbin/openrc-run
+# Enable the real time clock on Amescon's RasPiComm module
+
+start() {
+	ebegin "Setting up RaspiComm's real time clock"
+	echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
+	eend $?
+}
+
+stop() {
+	ebegin "Disabling RaspiComm's real time clock"
+	echo 0x68 > /sys/class/i2c-adapter/i2c-1/delete_device
+	eend $?
+}
-- 
2.4.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Thu May 07 2015 - 09:31:11 GMT