File tree Expand file tree Collapse file tree 7 files changed +105
-7
lines changed Expand file tree Collapse file tree 7 files changed +105
-7
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =rtmouse driver
3
+
4
+ [Service]
5
+ Type =oneshot
6
+ ExecStart =/etc/init.d/rtmouse.sh start
7
+ ExecReload =/etc/init.d/rtmouse.sh restart
8
+ ExecStopt =/etc/init.d/rtmouse.sh stop
9
+
10
+ [Install]
11
+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ #
4
+ # ## BEGIN INIT INFO
5
+ # Provides: rtmouse
6
+ # Required-Start: $all
7
+ # Required-Stop:
8
+ # Default-Start: 2 3 4 5
9
+ # Default-Stop:
10
+ # Short-Description: RT_Mouse_Driver
11
+ # Description: RaspPiMouse Driver
12
+ # ## END INIT INFO
13
+
14
+ SCRIPTNAME=rtmouse.sh
15
+ PROC_FILE=/proc/modules
16
+ GREP=/bin/grep
17
+ MODPROBE=/sbin/modprobe
18
+ MODULE_NAME=rtmouse
19
+ DEP_MODULE_NAME=mcp320x
20
+
21
+ [ -f $PROC_FILE ] || exit 0
22
+ [ -x $GREP ] || exit 0
23
+ [ -x $MODPROBE ] || exit 0
24
+
25
+ RES=` $GREP $MODULE_NAME $PROC_FILE `
26
+
27
+ # installing rtmouse.ko
28
+ install_rtmouse ()
29
+ {
30
+ if [ " $RES " = " " ]; then
31
+ $MODPROBE $MODULE_NAME
32
+ echo " Module Install $MODULE_NAME "
33
+ else
34
+ echo " Module '$MODULE_NAME ' is already installed"
35
+ fi
36
+ }
37
+
38
+ # uninstalling rtmouse.ko
39
+ remove_rtmouse ()
40
+ {
41
+ if [ " $RES " = " " ]; then
42
+ echo " Module '$MODULE_NAME ' isn't installed yet."
43
+ else
44
+ $MODPROBE -r $MODULE_NAME
45
+ $MODPROBE -r $DEP_MODULE_NAME
46
+ echo " Module '$MODULE_NAME ' is rmoved."
47
+ fi
48
+ }
49
+
50
+ case " $1 " in
51
+ start)
52
+ install_rtmouse
53
+ sleep 1
54
+ /bin/chmod a+rw /dev/rt*
55
+ ;;
56
+ stop)
57
+ remove_rtmouse
58
+ ;;
59
+ status)
60
+ if [ " $RES " = " " ]; then
61
+ echo " Module '$MODULE_NAME ' isn't installed yet."
62
+ exit 0
63
+ else
64
+ echo " Module '$MODULE_NAME ' is already installed"
65
+ exit 0
66
+ fi
67
+ ;;
68
+ * )
69
+ echo " Usage: $SCRIPTNAME {start|stop|status}" >&2
70
+ exit 3
71
+ esac
72
+
73
+ exit 0
Original file line number Diff line number Diff line change 1
- Makefile.ubuntu14
1
+ Makefile.raspbian
Original file line number Diff line number Diff line change @@ -2,11 +2,24 @@ MODULE:= rtmouse
2
2
obj-m:= $(MODULE).o
3
3
clean-files:= *.o *.ko *.mod.[co] *~
4
4
5
- LINUX_SRC_DIR:=/usr/src/linux
5
+ LINUX_SRC_DIR:=/usr/src/linux-headers-$(shell uname -r)
6
6
VERBOSE:=0
7
7
8
8
rtmouse.ko: rtmouse.c
9
9
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules
10
10
11
11
clean:
12
- make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean
12
+ make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean
13
+
14
+ install: rtmouse.ko
15
+ cp rtmouse.ko /lib/modules/$(shell uname -r)/kernel/drivers/
16
+ cp ../../etc/50-rtmouse.rules /etc/udev/rules.d/
17
+ cp ../../etc/rtmouse.sh /etc/init.d/
18
+ chmod 755 /etc/init.d/rtmouse.sh
19
+ cp ../../etc/rtmouse.service /etc/systemd/system/
20
+ systemctl enable rtmouse
21
+
22
+ uninstall:
23
+ rm /etc/udev/rules.d/50-rtmouse.rules
24
+
25
+ #Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ elif [ "$(ls /usr/src/linux-* 2> /dev/null)" != '' ]; then
10
10
# Ubuntu
11
11
if grep -q " Raspberry Pi 4" /proc/cpuinfo; then
12
12
$SRC_DIR /utils/build_install.raspi4ubuntu.bash && exit 0
13
+ elif grep -q " Raspberry Pi" /proc/cpuinfo; then
14
+ $SRC_DIR /utils/build_install.raspbian.bash && exit 0
13
15
else
14
16
$SRC_DIR /utils/build_install.ubuntu14.bash && exit 0
15
17
fi
Original file line number Diff line number Diff line change 1
1
#! /bin/bash -eu
2
2
3
3
SRC_DIR=$( cd $( dirname ${BASH_SOURCE:- $0 } ) /../; pwd)
4
+ KERNEL_SRC=/usr/src/linux-headers-$( uname -r)
4
5
5
6
# check kernel headers
6
- [ ! -e /usr/src/linux ] && { bash -e $SRC_DIR /utils/print_env.bash " No kernel header files found." ; exit 1; }
7
+ [ ! -e $KERNEL_SRC ] && { bash -e $SRC_DIR /utils/print_env.bash " No kernel header files found." ; exit 1; }
7
8
8
9
# build and install the driver
9
10
cd $SRC_DIR /src/drivers/
10
- rm Makefile
11
- ln -s Makefile.raspbian Makefile
12
11
make clean
13
12
make
14
- sudo insmod rtmouse.ko
13
+ sudo make install
15
14
16
15
# initialize the driver
17
16
sleep 1
You can’t perform that action at this time.
0 commit comments