File tree Expand file tree Collapse file tree 6 files changed +65
-29
lines changed Expand file tree Collapse file tree 6 files changed +65
-29
lines changed Original file line number Diff line number Diff line change 11MODULE:= rtmouse
2- TARGET:= $(MODULE).ko
3-
4- all: $(TARGET)
5-
6- $(TARGET): $(MODULE).c
7- make -C /usr/src/linux M=$(PWD) modules
8-
92obj-m:= $(MODULE).o
3+ clean-files:= *.o *.ko *.mod.[co] *~
4+
5+ LINUX_SRC_DIR:=/usr/src/linux
6+ VERBOSE:=0
107
11- install:
12- insmod $(MODULE).ko
8+ rtmouse.ko: rtmouse.c
9+ make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules
1310
1411clean:
15- rm -f *.o *.order *.mod.c *.symvers *.ko
16- rm -rf .*.cmd .tmp_versions
12+ make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean
Original file line number Diff line number Diff line change 1- #Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm
2- TARGET:= rtmouse.ko
1+ MODULE:= rtmouse
2+ obj-m:= $(MODULE).o
3+ clean-files:= *.o *.ko *.mod.[co] *~
34
4- all: ${TARGET}
5+ LINUX_SRC_DIR:=/usr/src/linux-headers-$(shell uname -r)
6+ VERBOSE:=0
57
68rtmouse.ko: rtmouse.c
7- make -C /usr/src/linux-headers-`uname -r` M=` pwd` V=1 modules
9+ make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules
810
911clean:
10- make -C /usr/src/linux-headers-`uname -r` M=`pwd` V=1 clean
11-
12- obj-m:= rtmouse.o
12+ make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean
1313
1414install: rtmouse.ko
1515 cp ../../50-rtmouse.rules /etc/udev/rules.d/
1616
1717uninstall:
1818 rm /etc/udev/rules.d/50-rtmouse.rules
1919
20- clean-files := *.o *.ko *.mod.[co] *~
20+ #Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2+ set -eu
23
34SRC_DIR=$( cd $( dirname ${BASH_SOURCE:- $0 } ) /../; pwd)
45
56if [ -e /usr/src/linux ]; then
7+ # Raspbian/Raspberry Pi OS
68 $SRC_DIR /utils/build_install.raspbian.bash && exit 0
79elif [ " $( ls /usr/src/linux-* 2> /dev/null) " != ' ' ]; then
8- $SRC_DIR /utils/build_install.ubuntu14.bash && exit 0
10+ # Ubuntu
11+ if grep -q " Raspberry Pi 4" /proc/cpuinfo; then
12+ $SRC_DIR /utils/build_install.raspi4ubuntu.bash && exit 0
13+ else
14+ $SRC_DIR /utils/build_install.ubuntu14.bash && exit 0
15+ fi
916else
17+ # Error
1018 bash -e $SRC_DIR /utils/print_env.bash " No kernel header files found."
1119fi
12-
Original file line number Diff line number Diff line change 1- #! /bin/bash -vxe
1+ #! /bin/bash -eu
22
3- dir=$( dirname $0 ) /../
4- [ ! -e /usr/src/linux ] && { bash -e $dir /utils/print_env.bash " No kernel header files found." ; exit 1; }
5- cd $dir /src/drivers/
3+ SRC_DIR=$( cd $( dirname ${BASH_SOURCE:- $0 } ) /../; pwd)
4+
5+ # check kernel headers
6+ [ ! -e /usr/src/linux ] && { bash -e $SRC_DIR /utils/print_env.bash " No kernel header files found." ; exit 1; }
7+
8+ # build and install the driver
9+ cd $SRC_DIR /src/drivers/
610rm Makefile
711ln -s Makefile.raspbian Makefile
812make clean
913make
1014sudo insmod rtmouse.ko
15+
16+ # initialize the driver
1117sleep 1
1218sudo chmod 666 /dev/rt*
1319echo 0 > /dev/rtmotoren0
Original file line number Diff line number Diff line change 1+ #! /bin/bash -eu
2+
3+ SRC_DIR=$( cd $( dirname ${BASH_SOURCE:- $0 } ) /../; pwd)
4+
5+ # check kernel headers
6+ [ ! -e /usr/src/linux-headers-$( uname -r) ] && { bash -e $SRC_DIR /utils/print_env.bash " No kernel header files found." ; exit 1; }
7+
8+ # build and install the driver
9+ cd $SRC_DIR /src/drivers/
10+ rm Makefile
11+ ln -s Makefile.ubuntu14 Makefile
12+ make clean
13+ # Update for Raspberry Pi 4
14+ sed -i -e " s/#define RASPBERRYPI 2/#define RASPBERRYPI 4/g" rtmouse.c
15+ make
16+ sudo insmod rtmouse.ko
17+
18+ # initialize the driver
19+ sleep 1
20+ sudo chmod 666 /dev/rt*
21+ echo 0 > /dev/rtmotoren0
Original file line number Diff line number Diff line change 1- #! /bin/bash -vxe
1+ #! /bin/bash -eu
22
3- dir=$( dirname $0 ) /../
4- [ ! -e /usr/src/linux-headers-$( uname -r) ] && { bash -e $dir /utils/print_env.bash " No kernel header files found." ; exit 1; }
5- cd $dir /src/drivers/
3+ SRC_DIR=$( cd $( dirname ${BASH_SOURCE:- $0 } ) /../; pwd)
4+
5+ # check kernel headers
6+ [ ! -e /usr/src/linux-headers-$( uname -r) ] && { bash -e $SRC_DIR /utils/print_env.bash " No kernel header files found." ; exit 1; }
7+
8+ # build and install the driver
9+ cd $SRC_DIR /src/drivers/
610rm Makefile
711ln -s Makefile.ubuntu14 Makefile
812make clean
913make
1014sudo insmod rtmouse.ko
15+
16+ # initialize the driver
1117sleep 1
1218sudo chmod 666 /dev/rt*
1319echo 0 > /dev/rtmotoren0
You can’t perform that action at this time.
0 commit comments