~alpine/aports

2 2

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

Marian Buschsieweke <mari.hahn@wwu.de>
Details
Message ID
<1430983871-915-1-git-send-email-mari.hahn@wwu.de>
Sender timestamp
1430983871
DKIM signature
missing
Download raw message
Patch: +230 -0
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
@@ -0,0 +1,83 @@
# Contributor: Marian Buschsieweke <mari.hahn@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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Timo Teras <timo.teras@iki.fi>
Details
Message ID
<20150604084345.43b3d6ba@vostro>
In-Reply-To
<1430983871-915-1-git-send-email-mari.hahn@wwu.de> (view parent)
Sender timestamp
1433396625
DKIM signature
missing
Download raw message
Hi,

Sorry for the very late reply. Few additional notes based on attempt
to apply it. Also few spots that maybe @ncopa can comment also?

On Thu,  7 May 2015 09:31:11 +0200
Marian Buschsieweke <mari.hahn@wwu.de> wrote:

> 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
> 
> 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
> @@ -0,0 +1,83 @@
> +# Contributor: Marian Buschsieweke <mari.hahn@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
> +

main/linux-rpi now ships linux-rpi and linux-rpi2 flavors. Both are
included in the 3.2.0 rpi tarball, and correct version is automatically
used based on bootloader's hardware detection.

I wonder if this should be made somehow to build for both flavors too?

> +build() {
> +	cd "$_builddir"
> +	export GCC_SPECS=hardenednopie.specs

@ncopa, Could we drop GCC_SPECS here, and infact all of the aports
tree? The gcc pie-patches have longtime disabled esp support if
__KERNEL__ is defined.	

> +	make -f Makefile_rpi

This failed with:

 raspicomm-module:
 Unpacking /var/cache/distfiles/raspicomm-module-v1.12.tar.gz...
 raspicomm-module: Creating group gpio
make -C /lib/modules/3.18.12-1-grsec/build
M=/home/tteras/aports/testing/raspicomm-module/src/raspicomm-module-1.12
modules make[1]: *** /lib/modules/3.18.12-1-grsec/build: No such file
or directory.  Stop. Makefile_rpi:6: recipe for target 'all' failed

I suspect you need to explicitly specify the kernel source tree to use.
So it'll use /lib/modules/$_kpkg-$_kver-$_kpkgrel-$_flavor. The reason
is that raspberry pi stuff is complied on wandboard, and the running
kernel will not match what we want to build.

Otherwise it's starting to look good.

Thanks,
Timo


---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Natanael Copa <ncopa@alpinelinux.org>
Details
Message ID
<20150609160034.29a01e11@ncopa-desktop.alpinelinux.org>
In-Reply-To
<20150604084345.43b3d6ba@vostro> (view parent)
Sender timestamp
1433858434
DKIM signature
missing
Download raw message
On Thu, 4 Jun 2015 08:43:45 +0300
Timo Teras <timo.teras@iki.fi> wrote:

> Hi,
> 
> Sorry for the very late reply.

+1

> Few additional notes based on attempt to apply it. Also few spots
> that maybe @ncopa can comment also?
> 
> On Thu,  7 May 2015 09:31:11 +0200
> Marian Buschsieweke <mari.hahn@wwu.de> wrote:
> 
> > 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
> > 
> > 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
> > @@ -0,0 +1,83 @@
> > +# Contributor: Marian Buschsieweke <mari.hahn@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
> > +
> 
> main/linux-rpi now ships linux-rpi and linux-rpi2 flavors. Both are
> included in the 3.2.0 rpi tarball, and correct version is
> automatically used based on bootloader's hardware detection.
> 
> I wonder if this should be made somehow to build for both flavors too?

It would be nice. But I don't know how. We would need linux-rpi-dev and
linux-rpi2-dev then.
 
> > +build() {
> > +	cd "$_builddir"
> > +	export GCC_SPECS=hardenednopie.specs
> 
> @ncopa, Could we drop GCC_SPECS here, and infact all of the aports
> tree? The gcc pie-patches have longtime disabled esp support if
> __KERNEL__ is defined.

Yes. I think we can drop this.

> 
> > +	make -f Makefile_rpi
> 
> This failed with:
> 
>  raspicomm-module:
>  Unpacking /var/cache/distfiles/raspicomm-module-v1.12.tar.gz...
>  raspicomm-module: Creating group gpio
> make -C /lib/modules/3.18.12-1-grsec/build
> M=/home/tteras/aports/testing/raspicomm-module/src/raspicomm-module-1.12
> modules make[1]: *** /lib/modules/3.18.12-1-grsec/build: No such file
> or directory.  Stop. Makefile_rpi:6: recipe for target 'all' failed
> 
> I suspect you need to explicitly specify the kernel source tree to
> use. So it'll use /lib/modules/$_kpkg-$_kver-$_kpkgrel-$_flavor. The
> reason is that raspberry pi stuff is complied on wandboard, and the
> running kernel will not match what we want to build.
> 
> Otherwise it's starting to look good.
> 
> Thanks,
> Timo

-nc


---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)