Skip to content

The raspbian build script updated, and some startup scripts added. #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2023
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
File renamed without changes.
11 changes: 11 additions & 0 deletions etc/rtmouse.service
Original file line number Diff line number Diff line change
@@ -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
73 changes: 73 additions & 0 deletions etc/rtmouse.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/drivers/Makefile
17 changes: 15 additions & 2 deletions src/drivers/Makefile.raspbian
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 2 additions & 0 deletions utils/build_install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions utils/build_install.raspbian.bash
Original file line number Diff line number Diff line change
@@ -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
Expand Down
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