diff options
author | Chris Severance | 2017-07-17 20:48:25 -0400 |
---|---|---|
committer | Chris Severance | 2017-07-17 20:48:25 -0400 |
commit | 1955020042b741a1ba98a5843d113fb06da820af (patch) | |
tree | d8d952e174adfc801aac09ca6e29dba0a1d4cc1c | |
download | aur-1955020042b741a1ba98a5843d113fb06da820af.tar.gz |
Initial Import
-rw-r--r-- | .SRCINFO | 27 | ||||
-rw-r--r-- | PKGBUILD | 223 | ||||
-rw-r--r-- | comtrol-rocketport-upci-install.sh | 40 | ||||
-rwxr-xr-x | rocketport-upci-firmware.sh | 78 |
4 files changed, 368 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..ea01dc4e2313 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,27 @@ +# Generated by mksrcinfo v8 +# Tue Jul 18 00:47:39 UTC 2017 +pkgbase = comtrol-rocketport-upci + pkgdesc = kernel module driver for Comtrol RocketPort PCI Plus Universal uPCI CPCI Rocketmodem serial RS-232 422 port + pkgver = 4.05 + pkgrel = 1 + url = http://downloads.comtrol.com/html/RPuPCI_drivers.htm + install = comtrol-rocketport-upci-install.sh + arch = i686 + arch = x86_64 + license = GPL + makedepends = gzip + makedepends = findutils + makedepends = sed + makedepends = diffutils + makedepends = patch + depends = linux + depends = dkms + depends = linux-headers + backup = etc/modprobe.d/rocketupci.conf + source = http://downloads.comtrol.com/rport/drivers/u_pci/linux/rocketport-linux-4.05.tar.gz + source = rocketport-upci-firmware.sh + sha256sums = 370f65a2dc5128e57cb7480aff5756996ceb24ad4312d1454f5debb1611fe5da + sha256sums = 6fa93b24ffe0ff6849b9b05bcd55dcaf4eb09c13321c55bbb2f04b369008d149 + +pkgname = comtrol-rocketport-upci + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..7d43e949c86e --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,223 @@ +# Maintainer: Chris Severance aur.severach aATt spamgourmet dott com + +# TODO: The Linux kernel in tree rocket module is (C)2003 and should be updated to this driver. +# TODO: Test firmware updater. +# TODO: Could the RocketModem II firmware updater be launched by udev? +# TODO: Should the firmware updater be set to an earlier target to minimize conflicts with programs that use the modems? +# TODO: kernel bug lspci: The RocketPort PCI 4J is claimed to have RJ11 connectors. It has RJ45 connectors. The 8J has RJ11 connectors. + +# This is for PCI and uPCI, not Express or Infinity + +_opt_DKMS=1 # This can be toggled between installs + +# ls -l /dev/ttyR* +# lsmod | grep rocket +# lspci -v | grep -A4 -i rocket +# sudo cat /proc/tty/driver/rocketupci + +# dmesg | grep -A8 -i rocket +#[ 4.138731] rocketupci: Comtrol RocketPort driver version 4.05 Arch Linux https://aur.archlinux.org/packages/comtrol-rocketport-upci/ +#[ 4.138880] rocketupci 0000:07:02.0: found RP UPCI Plus 4 port RJ45 with 4 ports +#[ 4.139228] 0000:07:02.0: ttyR0 at I/O 0x1c000 (irq = 18, base_baud = 921600) is a RP UPCI Plus 4 port RJ45 +#[ 4.139622] 0000:07:02.0: ttyR1 at I/O 0x1c002 (irq = 18, base_baud = 921600) is a RP UPCI Plus 4 port RJ45 +#[ 4.140027] 0000:07:02.0: ttyR2 at I/O 0x1c004 (irq = 18, base_baud = 921600) is a RP UPCI Plus 4 port RJ45 +#[ 4.140448] 0000:07:02.0: ttyR3 at I/O 0x1c006 (irq = 18, base_baud = 921600) is a RP UPCI Plus 4 port RJ45 +#[ 4.140504] rocketupci 0000:07:02.0: polling at 100Hz + +set -u +pkgname='comtrol-rocketport-upci' +pkgver='4.05' +pkgrel='1' +pkgdesc='kernel module driver for Comtrol RocketPort PCI Plus Universal uPCI CPCI Rocketmodem serial RS-232 422 port' +arch=('i686' 'x86_64') +url='http://downloads.comtrol.com/html/RPuPCI_drivers.htm' +license=('GPL') +makedepends=('gzip' 'findutils' 'sed' 'diffutils' 'patch') +backup=('etc/modprobe.d/rocketupci.conf') +install="${pkgname}-install.sh" +_srcdir="rocketport-linux-${pkgver}" +source=("http://downloads.comtrol.com/rport/drivers/u_pci/linux/rocketport-linux-${pkgver}.tar.gz" 'rocketport-upci-firmware.sh') +sha256sums=('370f65a2dc5128e57cb7480aff5756996ceb24ad4312d1454f5debb1611fe5da' + '6fa93b24ffe0ff6849b9b05bcd55dcaf4eb09c13321c55bbb2f04b369008d149') + +_modulename='rocketupci' + +if [ "${_opt_DKMS}" -ne 0 ]; then + depends+=('linux' 'dkms' 'linux-headers') +else + makedepends+=('linux-headers') +fi + +# We can't modify .install but we can stop and force the user to fix it. +_install_check() { + local _ckvar + local _ckline + local _pkgname="${pkgname}" + for _ckvar in _pkgname _modulename; do + _ckline="${_ckvar}='${!_ckvar}'" + if ! grep -q "^${_ckline}"'$' "${startdir}/${install}"; then + set +u + msg "${install} must be fixed" + echo "${_ckline}" + false + fi + done +} + +prepare() { + set -u + _install_check + cd "${_srcdir}" + find -type 'f' -exec chmod 644 '{}' '+' + chmod 755 *.sh + + # Fix umbrella makefile + sed -e 's:/lib/:/usr/lib/:g' -i 'Makefile' + + # Branding + sed -e '/printk/ s@DRV_VERS@& " Arch Linux'" https://aur.archlinux.org/packages/${pkgname}/"'" @g' -i 'rocket.c' + + # Change module name to prevent conflict with rocket.ko (C)2003 for RocketPort PCI + if [ "${_modulename}" != 'rocket' ]; then + sed -e "s:rocket:${_modulename}:g" -i 'Makefile' + sed -e "s|rocket:|${_modulename}:|g" \ + -e "/DRV_NAME/ s:rocket:${_modulename}:g" \ + -i 'rocket.c' + sed -e "s:rocket:${_modulename}:g" -i 'install.sh' + mv 'rocket.c' "${_modulename}.c" + fi + + # Fix loadrm2 makefile + sed -e 's:/sbin:/usr/bin:g' \ + -e 's: /usr/: $(DESTDIR)/usr/:g' \ + -e 's: /etc: $(DESTDIR)/etc:g' \ + -i 'loadrm2/Makefile' + + # Move the firmware out of /etc + sed -e "s:/etc/:/usr/lib/firmware/${pkgname}/:g" -i 'loadrm2/loadrm2.h' + + # Make installer package compatible + cp -p 'install.sh' 'install.Arch.sh' # debugging + sed -e '1a set -e' -e '1a set -u' -e '#1a set -x' -e '1a DESTDIR=' -i 'install.sh' + sed -e '# Fix sbin and lib' \ + -e 's:/usr/sbin/:/usr/bin/:g' \ + -e 's:/sbin/:/usr/bin/:g' \ + -e 's:/lib/:/usr/lib/:g' \ + -e '# Add DESTDIR' \ + -e 's:/usr/:"${DESTDIR}"&:g' \ + -e 's:/etc/:"${DESTDIR}"&:g' \ + -e 's:""${DESTDIR}":"${DESTDIR}:g' \ + -i 'install.sh' + set +u +} + +build() { + set -u + cd "${_srcdir}" + make -s -j1 # too small for parallel make + set +u +} + +package() { + set -u + cd "${_srcdir}" + if [ "${_opt_DKMS}" -eq 0 ]; then + # I don't want Linux version info showing on AUR web. After a few months 'linux<0.0.0' makes it look like an out of date package. + local _kernelversionsmall="$(uname -r)" + _kernelversionsmall="${_kernelversionsmall%%-*}" + _kernelversionsmall="${_kernelversionsmall%\.0}" # trim 4.0.0 -> 4.0, 4.1.0 -> 4.1 + # prevent the mksrcinfo bash emulator from getting these vars! + eval 'conf''licts=("linux>${_kernelversionsmall}" "linux<${_kernelversionsmall}")' + eval 'dep''ends+=("linux=${_kernelversionsmall}")' + fi + + sed -e 's:^\(DESTDIR\)=.*$'":\1=${pkgdir}:g" -i 'install.sh' + install -d \ + "${pkgdir}/usr/bin" \ + "${pkgdir}/usr/lib/modules/$(uname -r)/kernel/drivers" \ + "${pkgdir}/etc" \ + "${pkgdir}/etc/modules-load.d" \ + "${pkgdir}/etc/modprobe.d" + ln -s '/usr/bin/true' "${pkgdir}/usr/bin/depmod" + make -s -j1 DESTDIR="${pkgdir}" install rm2_install + rm "${pkgdir}/usr/bin/depmod" + install -Dp "${pkgdir}/etc"/*.rm -t "${pkgdir}/usr/lib/firmware/${pkgname}" + rm "${pkgdir}/etc"/*.rm + + # Modern kernels detect and load automatically + rm -r "${pkgdir}/etc/modules-load.d" + + # Blacklist exiting incomplete rocket module + cat >> "${pkgdir}/etc/modprobe.d/rocketupci.conf" << EOF +# Do not load old rocket module that only supports RocketPort PCI +blacklist rocket +EOF + + # The module is in the same folder as DKMS. Compress to a different name to prevent conflict. + # When future versions of DKMS compress we'll stop doing this. + find "${pkgdir}/usr/lib/modules/" -type 'f' -name '*.ko' -exec 'gzip' '-9' '{}' ';' + + # Install the setcountry script with a name findable by tab completion + install -Dpm755 'setcountry.sh' "${pkgdir}/usr/bin/setcountry-rocketmodem.sh" + + # Install RocketPort II firmware helper + install -Dpm755 "${srcdir}/rocketport-upci-firmware.sh" -t "${pkgdir}/usr/bin" + sed -e 's:^\(module\)=.*$'":\1='${_modulename}':g" -i "${pkgdir}/usr/bin/rocketport-upci-firmware.sh" + + # Install RocketPort II firmware service + install -Dm644 <(cat << EOF +# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ + +[Unit] +Description=Comtrol RocketModem II Firmware Loader +After=network.target + +[Service] +Type=notify +# We want the logs to show that the modems were initialized +ExecStart=/usr/bin/rocketport-upci-firmware.sh --systemd -p +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +EOF + ) "${pkgdir}/usr/lib/systemd/system/rocketport-upci-firmware.service" + + if [ "${_opt_DKMS}" -ne 0 ]; then + rm -rf "${pkgdir}/usr/lib/modules/" + local _dkms="${pkgdir}/usr/src/${pkgname}-${pkgver}" + install -Dm644 <(cat << EOF +# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/ + +PACKAGE_NAME="${pkgname}" +PACKAGE_VERSION="${pkgver}" +AUTOINSTALL="yes" + +BUILT_MODULE_NAME[0]="${_modulename}" +BUILT_MODULE_LOCATION[0]="" +# Using all processors doesn't compile this tiny module any faster. +MAKE[0]="make -j1" +CLEAN[0]="make -j1 clean" +# The install version is .ko.gz. The DKMS version is .ko. No conflicts. +DEST_MODULE_LOCATION[0]="/kernel/drivers/tty" +EOF + ) "${_dkms}/dkms.conf" + install -dm755 "${_dkms}/" + cp -pr './' "${_dkms}/" + pushd "${_dkms}" > /dev/null + rm 'HISTORY' *.sh + rm -r 'loadrm2' + popd > /dev/null + sed -e '# No DKMS instructions say to do this but it works and keeps the MAKE line real simple' \ + -e 's:shell uname -r:KERNELRELEASE:g' \ + -e '# Disable compile loadrm2' \ + -e '/loadrm2/ s:^:#:g' \ + -i "${_dkms}/Makefile" + make -s -C "${_dkms}/" clean + fi + set +u +} + +set +u diff --git a/comtrol-rocketport-upci-install.sh b/comtrol-rocketport-upci-install.sh new file mode 100644 index 000000000000..252f621c5ae9 --- /dev/null +++ b/comtrol-rocketport-upci-install.sh @@ -0,0 +1,40 @@ +_pkgname='comtrol-rocketport-upci' +_modulename='rocketupci' + +post_upgrade() { + set -u + systemctl daemon-reload + if [ ! -d "/usr/src/${_pkgname}"-*/ ]; then + depmod -a + if ! lsmod | cut -d' ' -f1 | grep -q "^${_modulename}"'$'; then + #echo 'Reboot or load now with:' + #echo " sudo modprobe '${_modulename}'" + if [ "${_modulename}" != 'rocket' ]; then + rmmod 'rocket' 2> /dev/null # blacklisted on boot + fi + modprobe "${_modulename}" + rocketport-upci-firmware.sh -p + fi + fi + set +u +} + +post_install() { + set -u + post_upgrade + systemctl enable 'rocketport-upci-firmware.service' + set +u +} + +pre_remove() { + set -u + if [ ! -d "/usr/src/${_pkgname}"-*/ ]; then + rmmod "${_modulename}" + fi + systemctl disable 'rocketport-upci-firmware.service' + set +u +} + +post_remove() { + systemctl daemon-reload +} diff --git a/rocketport-upci-firmware.sh b/rocketport-upci-firmware.sh new file mode 100755 index 000000000000..41bc34ef25f2 --- /dev/null +++ b/rocketport-upci-firmware.sh @@ -0,0 +1,78 @@ +#!/usr/bin/bash + +# 2017-07-17 -CJS (GPL) + +# switches: +# --systemd - run notify at end. This MUST be the first switch +# Add any of the loadrm2 switches you want +# Examples +# rocketport-upci-firmware.sh -p +# rocketport-upci-firmware.sh --systemd -p + +#ROCKETMODEM II NOTE + +#If you are using a RocketModem II board, further installation and +#setup is required. Note: this does not apply to RocketModem IIs +#boards. + +# Load firmware onto all RocketModem II +# The instructions say to load it on all ports but that +# causes long delays. + +# sudo sed -e 's:^:#:g' '/proc/tty/driver/rocketupci' +#serinfo:1.0 driver revision: +#0: uart:RP UPCI Plus 4 port RJ45 port:0001B000 irq:18 tx:30 rx:0 +#1: uart:RP UPCI Plus 4 port RJ45 port:0001B002 irq:18 tx:30 rx:0 +#2: uart:RP UPCI Plus 4 port RJ45 port:0001B004 irq:18 tx:30 rx:0 +#3: uart:RP UPCI Plus 4 port RJ45 port:0001B006 irq:18 tx:30 rx:0 + +#No response from RocketModem on /dev/ttyR0, trying reset... +#No response from RocketModem on /dev/ttyR1, trying reset... +#No response from RocketModem on /dev/ttyR2, trying reset... +#No response from RocketModem on /dev/ttyR3, trying reset... +#No response from RocketModem on /dev/ttyR0, couldn't initialize. +#No response from RocketModem on /dev/ttyR1, couldn't initialize. +#No response from RocketModem on /dev/ttyR2, couldn't initialize. +#No response from RocketModem on /dev/ttyR3, couldn't initialize. + +# The right modems are easy to detect. + +set -e +set -u + +module='rocket' + +if [ "${EUID}" -ne 0 ]; then + echo 'root is required to load firmware' + exit 1 +fi + +_opt_systemd=0 +if [ "${1:-}" = '--systemd' ]; then + _opt_systemd=1 + shift +fi + +# just in case the boot is too fast +if [ ! -f "/proc/tty/driver/${module}" ]; then + echo "wait for online: /proc/tty/driver/${module}" + sleep 5 +fi + +if readarray -t rockets < "/proc/tty/driver/${module}"; then + #declare -p rockets + rocketmodems=() + for rocket in "${rockets[@]}"; do + #echo "Checking ${rocket}" + if [[ "${rocket^^}" =~ ^[0-9]+:.*' PCI RocketModem II ' ]]; then + rocketmodems+=("/dev/ttyR${rocket%%:*}") + fi + done + if [ "${#rocketmodems[@]}" -ne 0 ]; then + loadrm2 "$@" "${rocketmodems[@]}" + fi +fi + +if [ "${_opt_systemd}" -ne 0 ]; then + systemd-notify --ready +fi |