Skip to content
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

add installation with dkms #31

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@
modules.order
Module.symvers
Mkfile.old
dkms.conf
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ obj-m += acer-wmi-battery.o
PWD := $(CURDIR)

all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
make -C /lib/modules/$(KERNELVERSION)/build M=$(PWD) modules
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to be able to pass a kernel version to the Makefile, it would be better to make this optional, i.e. specify a default value for KERNELVERSION. This can be accomplished by defining the variable at the top of the Makefile like this:
KERNELVERSION ?= "$(shell uname -r)".


clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
make -C /lib/modules/$(KERNELVERSION)/build M=$(PWD) clean
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Any feedback on how it works on other Acer laptops would be appreciated.
## Building

Make sure that you have the kernel headers for your kernel installed
and type `make` in the cloned project directory. In more detail,
and type `make KERNELVERSION=$(uname -r)` in the cloned project directory. In more detail,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build instructions should not need to change once you adapt the Makefile as described above.

on a Debian or Ubuntu system, you can build by:
```
sudo apt install build-essential linux-headers-$(uname -r) git
git clone https://github.com/frederik-h/acer-wmi-battery.git
cd acer-wmi-battery
make
make KERNELVERSION=$(uname -r)
```

## Using
Expand Down Expand Up @@ -72,7 +72,33 @@ of the calibration is not yet handled by the module:
echo 0 | sudo tee /sys/bus/wmi/drivers/acer-wmi-battery/calibration_mode
```

### Related work
## Persistent installation (DKMS)

If you found this driver to be working on your laptop, you may want to install it into your system for ease of use.

1) Install DKMS and generic kernel headers (this will always get you the latest headers), on Debian or Ubuntu it can be done with:

```
sudo apt install dkms linux-headers-generic
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked what linux-headers-generic would install on my system and you are right, it depends on the package for the latest kernel headers. But what if you are not running the latest kernel version - as I am. Since the build instructions already describe how to install the headers for the current kernel, I would remove the "linux-headers-generic" from this apt invocation.

```

2) Install the driver: in the cloned project directory execute:

```
chmod +x install.sh uninstall.sh
sudo ./install.sh
```

The driver will now automatically load at boot and be recompiled after a kernel upgrade. Reboot to use it.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reboot to use it.

modprobe should also work?


### Uninstallation
In the cloned project directory execute:

```
sudo ./uninstall.sh
```

## Related work

There exists [another driver](https://github.com/maxco2/acer-battery-wmi) with
similar functionality of which I have not been aware when starting the work
Expand Down
2 changes: 2 additions & 0 deletions acer-wmi-battery.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Load Acer battery health driver
acer_wmi_battery
8 changes: 8 additions & 0 deletions dkms.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PACKAGE_NAME=acer_wmi_battery
PACKAGE_VERSION=1.0
MAKE[0]="make KERNELVERSION=${kernelver}"
CLEAN[0]="make clean KERNELVERSION=${kernelver}"
BUILT_MODULE_NAME[0]=acer-wmi-battery
BUILT_MODULE_LOCATION[0]="./"
DEST_MODULE_LOCATION[0]="/kernel/updates/dkms"
AUTOINSTALL="YES"
15 changes: 15 additions & 0 deletions install.sh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this file and the other dkms related files to a new directory contrib/dkms, move your instructions to contrib/dkms/README.md and link to this file from README.md?

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# remove previous version if present
./uninstall.sh

# copy project directory into kernel sources
cp -R . /usr/src/acer-wmi-battery-1.0

# register module in dkms and install
dkms add -m acer-wmi-battery -v 1.0
dkms build -m acer-wmi-battery -v 1.0
dkms install -m acer-wmi-battery -v 1.0

# auto-load module at boot
cp acer-wmi-battery.conf /etc/modules-load.d
5 changes: 5 additions & 0 deletions uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

dkms remove -m acer-wmi-battery/1.0 --all
rm -rf /usr/src/acer-wmi-battery-1.0
rm /etc/modules-load.d/acer-wmi-battery.conf