Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/drivers/Makefile.raspbian
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
MODULE:= rtmouse
TARGET:= $(MODULE).ko

all: $(TARGET)

$(TARGET): $(MODULE).c
make -C /usr/src/linux M=$(PWD) modules

obj-m:= $(MODULE).o
clean-files:= *.o *.ko *.mod.[co] *~

LINUX_SRC_DIR:=/usr/src/linux
VERBOSE:=0

install:
insmod $(MODULE).ko
rtmouse.ko: rtmouse.c
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules

clean:
rm -f *.o *.order *.mod.c *.symvers *.ko
rm -rf .*.cmd .tmp_versions
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean
16 changes: 8 additions & 8 deletions src/drivers/Makefile.ubuntu14
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm
TARGET:= rtmouse.ko
MODULE:= rtmouse
obj-m:= $(MODULE).o
clean-files:= *.o *.ko *.mod.[co] *~

all: ${TARGET}
LINUX_SRC_DIR:=/usr/src/linux-headers-$(shell uname -r)
VERBOSE:=0

rtmouse.ko: rtmouse.c
make -C /usr/src/linux-headers-`uname -r` M=`pwd` V=1 modules
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) modules

clean:
make -C /usr/src/linux-headers-`uname -r` M=`pwd` V=1 clean

obj-m:= rtmouse.o
make -C $(LINUX_SRC_DIR) M=$(shell pwd) V=$(VERBOSE) clean

install: rtmouse.ko
cp ../../50-rtmouse.rules /etc/udev/rules.d/

uninstall:
rm /etc/udev/rules.d/50-rtmouse.rules

clean-files := *.o *.ko *.mod.[co] *~
#Reference: http://www.devdrv.co.jp/linux/kernel26-makefile.htm
11 changes: 9 additions & 2 deletions utils/build_install.bash
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/usr/bin/env bash
set -eu

SRC_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../; pwd)

if [ -e /usr/src/linux ]; then
# Raspbian/Raspberry Pi OS
$SRC_DIR/utils/build_install.raspbian.bash && exit 0
elif [ "$(ls /usr/src/linux-* 2> /dev/null)" != '' ]; then
$SRC_DIR/utils/build_install.ubuntu14.bash && exit 0
# Ubuntu
if grep -q "Raspberry Pi 4" /proc/cpuinfo; then
$SRC_DIR/utils/build_install.raspi4ubuntu.bash && exit 0
else
$SRC_DIR/utils/build_install.ubuntu14.bash && exit 0
fi
else
# Error
bash -e $SRC_DIR/utils/print_env.bash "No kernel header files found."
fi

14 changes: 10 additions & 4 deletions utils/build_install.raspbian.bash
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/bin/bash -vxe
#!/bin/bash -eu

dir=$(dirname $0)/../
[ ! -e /usr/src/linux ] && { bash -e $dir/utils/print_env.bash "No kernel header files found."; exit 1; }
cd $dir/src/drivers/
SRC_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../; pwd)

# check kernel headers
[ ! -e /usr/src/linux ] && { 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

# initialize the driver
sleep 1
sudo chmod 666 /dev/rt*
echo 0 > /dev/rtmotoren0
21 changes: 21 additions & 0 deletions utils/build_install.raspi4ubuntu.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -eu

SRC_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../; pwd)

# check kernel headers
[ ! -e /usr/src/linux-headers-$(uname -r) ] && { 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.ubuntu14 Makefile
make clean
# Update for Raspberry Pi 4
sed -i -e "s/#define RASPBERRYPI 2/#define RASPBERRYPI 4/g" rtmouse.c
make
sudo insmod rtmouse.ko

# initialize the driver
sleep 1
sudo chmod 666 /dev/rt*
echo 0 > /dev/rtmotoren0
14 changes: 10 additions & 4 deletions utils/build_install.ubuntu14.bash
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/bin/bash -vxe
#!/bin/bash -eu

dir=$(dirname $0)/../
[ ! -e /usr/src/linux-headers-$(uname -r) ] && { bash -e $dir/utils/print_env.bash "No kernel header files found."; exit 1; }
cd $dir/src/drivers/
SRC_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../; pwd)

# check kernel headers
[ ! -e /usr/src/linux-headers-$(uname -r) ] && { 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.ubuntu14 Makefile
make clean
make
sudo insmod rtmouse.ko

# initialize the driver
sleep 1
sudo chmod 666 /dev/rt*
echo 0 > /dev/rtmotoren0