From ce18eb6740b3996c8d965bdfe970c0f77b419ef3 Mon Sep 17 00:00:00 2001 From: n-ando Date: Sun, 3 Oct 2021 11:43:10 +0900 Subject: [PATCH] build script updated. startup scripts added. --- 50-rtmouse.rules => etc/50-rtmouse.rules | 0 etc/rtmouse.service | 11 ++++ etc/rtmouse.sh | 73 ++++++++++++++++++++++++ src/drivers/Makefile | 2 +- src/drivers/Makefile.raspbian | 17 +++++- utils/build_install.bash | 2 + utils/build_install.raspbian.bash | 7 +-- 7 files changed, 105 insertions(+), 7 deletions(-) rename 50-rtmouse.rules => etc/50-rtmouse.rules (100%) create mode 100644 etc/rtmouse.service create mode 100755 etc/rtmouse.sh diff --git a/50-rtmouse.rules b/etc/50-rtmouse.rules similarity index 100% rename from 50-rtmouse.rules rename to etc/50-rtmouse.rules diff --git a/etc/rtmouse.service b/etc/rtmouse.service new file mode 100644 index 0000000..3afb510 --- /dev/null +++ b/etc/rtmouse.service @@ -0,0 +1,11 @@ +[Unit] +Description=rtmouse driver + +[Service] +Type=oneshot +ExecStart=/etc/init.d/rtmouse.sh start +ExecReload=/etc/init.d/rtmouse.sh restart +ExecStopt=/etc/init.d/rtmouse.sh stop + +[Install] +WantedBy=multi-user.target diff --git a/etc/rtmouse.sh b/etc/rtmouse.sh new file mode 100755 index 0000000..befd125 --- /dev/null +++ b/etc/rtmouse.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# +### BEGIN INIT INFO +# Provides: rtmouse +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: RT_Mouse_Driver +# Description: RaspPiMouse Driver +### END INIT INFO + +SCRIPTNAME=rtmouse.sh +PROC_FILE=/proc/modules +GREP=/bin/grep +MODPROBE=/sbin/modprobe +MODULE_NAME=rtmouse +DEP_MODULE_NAME=mcp320x + +[ -f $PROC_FILE ] || exit 0 +[ -x $GREP ] || exit 0 +[ -x $MODPROBE ] || exit 0 + +RES=`$GREP $MODULE_NAME $PROC_FILE` + +# installing rtmouse.ko +install_rtmouse() +{ + if [ "$RES" = "" ]; then + $MODPROBE $MODULE_NAME + echo "Module Install $MODULE_NAME" + else + echo "Module '$MODULE_NAME' is already installed" + fi +} + +# uninstalling rtmouse.ko +remove_rtmouse() +{ + if [ "$RES" = "" ]; then + echo "Module '$MODULE_NAME' isn't installed yet." + else + $MODPROBE -r $MODULE_NAME + $MODPROBE -r $DEP_MODULE_NAME + echo "Module '$MODULE_NAME' is rmoved." + fi +} + +case "$1" in + start) + install_rtmouse + sleep 1 + /bin/chmod a+rw /dev/rt* + ;; + stop) + remove_rtmouse + ;; + status) + if [ "$RES" = "" ]; then + echo "Module '$MODULE_NAME' isn't installed yet." + exit 0 + else + echo "Module '$MODULE_NAME' is already installed" + exit 0 + fi + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status}" >&2 + exit 3 +esac + +exit 0 diff --git a/src/drivers/Makefile b/src/drivers/Makefile index 1086ef4..9d4d655 120000 --- a/src/drivers/Makefile +++ b/src/drivers/Makefile @@ -1 +1 @@ -Makefile.ubuntu14 \ No newline at end of file +Makefile.raspbian \ No newline at end of file diff --git a/src/drivers/Makefile.raspbian b/src/drivers/Makefile.raspbian index 2222e8d..986697c 100644 --- a/src/drivers/Makefile.raspbian +++ b/src/drivers/Makefile.raspbian @@ -2,11 +2,24 @@ MODULE:= rtmouse obj-m:= $(MODULE).o clean-files:= *.o *.ko *.mod.[co] *~ -LINUX_SRC_DIR:=/usr/src/linux +LINUX_SRC_DIR:=/usr/src/linux-headers-$(shell uname -r) VERBOSE:=0 rtmouse.ko: rtmouse.c make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules clean: - make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean \ No newline at end of file + make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean + +install: rtmouse.ko + cp rtmouse.ko /lib/modules/$(shell uname -r)/kernel/drivers/ + cp ../../etc/50-rtmouse.rules /etc/udev/rules.d/ + cp ../../etc/rtmouse.sh /etc/init.d/ + chmod 755 /etc/init.d/rtmouse.sh + cp ../../etc/rtmouse.service /etc/systemd/system/ + systemctl enable rtmouse + +uninstall: + rm /etc/udev/rules.d/50-rtmouse.rules + +#Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm diff --git a/utils/build_install.bash b/utils/build_install.bash index 03225cb..5c48c22 100755 --- a/utils/build_install.bash +++ b/utils/build_install.bash @@ -10,6 +10,8 @@ elif [ "$(ls /usr/src/linux-* 2> /dev/null)" != '' ]; then # Ubuntu if grep -q "Raspberry Pi 4" /proc/cpuinfo; then $SRC_DIR/utils/build_install.raspi4ubuntu.bash && exit 0 + elif grep -q "Raspberry Pi" /proc/cpuinfo; then + $SRC_DIR/utils/build_install.raspbian.bash && exit 0 else $SRC_DIR/utils/build_install.ubuntu14.bash && exit 0 fi diff --git a/utils/build_install.raspbian.bash b/utils/build_install.raspbian.bash index 19e4c99..c323622 100755 --- a/utils/build_install.raspbian.bash +++ b/utils/build_install.raspbian.bash @@ -1,17 +1,16 @@ #!/bin/bash -eu SRC_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../; pwd) +KERNEL_SRC=/usr/src/linux-headers-$(uname -r) # check kernel headers -[ ! -e /usr/src/linux ] && { bash -e $SRC_DIR/utils/print_env.bash "No kernel header files found."; exit 1; } +[ ! -e $KERNEL_SRC ] && { bash -e $SRC_DIR/utils/print_env.bash "No kernel header files found."; exit 1; } # build and install the driver cd $SRC_DIR/src/drivers/ -rm Makefile -ln -s Makefile.raspbian Makefile make clean make -sudo insmod rtmouse.ko +sudo make install # initialize the driver sleep 1 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy