mirror of
https://github.com/leifliddy/macbook12-bluetooth-driver.git
synced 2024-09-11 12:55:15 +03:00
Compare commits
5 Commits
a20de75643
...
9c6d5bc5ce
Author | SHA1 | Date | |
---|---|---|---|
|
9c6d5bc5ce | ||
|
9be66a7b01 | ||
|
6349c03ecc | ||
|
80e41d7767 | ||
|
f8bb9b1453 |
20
Makefile
20
Makefile
@ -1,16 +1,18 @@
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
KERNELDIR ?= /lib/modules/$(KERNELRELEASE)/build
|
||||
ifdef KERNELRELEASE
|
||||
KERNELDIR := /lib/modules/$(KERNELRELEASE)
|
||||
else
|
||||
## KERNELRELEASE not set.
|
||||
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
KERNELDIR := /lib/modules/$(shell uname -r)
|
||||
endif
|
||||
|
||||
all:
|
||||
make -C $(KERNELDIR) M=$(shell pwd)/build/bluetooth modules
|
||||
clean:
|
||||
make -C $(KERNELDIR) M=$(shell pwd)/build/bluetooth clean
|
||||
KERNELBUILD := $(KERNELDIR)/build
|
||||
|
||||
ifeq ($(KERNELRELEASE),)
|
||||
all:
|
||||
make -C $(KERNELBUILD) M=$(shell pwd)/build/bluetooth modules
|
||||
|
||||
clean:
|
||||
make -C $(KERNELBUILD) M=$(shell pwd)/build/bluetooth clean
|
||||
|
||||
ifndef KERNELRELEASE
|
||||
install:
|
||||
cp $(shell pwd)/build/bluetooth/hci_uart.ko /lib/modules/$(shell uname -r)/updates
|
||||
depmod -a
|
||||
|
12
README.md
12
README.md
@ -33,16 +33,15 @@ pacman -S dkms gcc make linux-headers wget
|
||||
```
|
||||
1. **build and install dkms module** (experimental feature)
|
||||
this will build the module for the current/active kernel
|
||||
and "should" auto-compile this module whenever you install a newer kernel
|
||||
and will auto-compile this module whenever you install a newer kernel
|
||||
```
|
||||
git clone https://github.com/leifliddy/macbook12-bluetooth-driver.git
|
||||
cd macbook12-bluetooth-driver/
|
||||
# run the following command as root or with sudo
|
||||
./install.dkms.sh
|
||||
reboot
|
||||
./install.bluetooth.sh -i
|
||||
|
||||
# to uninstall the dkms feature run:
|
||||
./install.dkms.sh -u
|
||||
./install.bluetooth.sh -u
|
||||
```
|
||||
|
||||
2. (backup method if dkms didn't work) **manually build and install module for current kernel**
|
||||
@ -55,8 +54,3 @@ reboot
|
||||
```
|
||||
|
||||
```install.bluetooth.sh``` will auto-patch the ```hci_bcm.c``` source file and then compile and install the ```hci_uart``` module
|
||||
|
||||
|
||||
```install.bluetooth.sh``` is designed to be run on the Macbook itself (running Linux obviously).
|
||||
It will compile the ```hci_uart``` module for the currently running/active kernel (based on the ```uname -r``` output)
|
||||
However, this script can be easily modified to suit any number of use-case scenarios.
|
||||
|
@ -1,6 +1,6 @@
|
||||
PACKAGE_NAME="macbook12-bluetooth"
|
||||
PACKAGE_VERSION="0.1"
|
||||
PRE_BUILD="install.bluetooth.sh $kernelver"
|
||||
PRE_BUILD="install.bluetooth.sh -k $kernelver"
|
||||
MAKE="make"
|
||||
BUILT_MODULE_NAME[0]="hci_uart"
|
||||
BUILT_MODULE_LOCATION[0]="build/bluetooth"
|
||||
|
6
install.dkms.sh → dkms.sh
Executable file → Normal file
6
install.dkms.sh → dkms.sh
Executable file → Normal file
@ -10,18 +10,20 @@ while getopts :ru arg
|
||||
do
|
||||
case "${arg}" in
|
||||
r) dkms_remove=true;;
|
||||
u) dkms_remove=true;;
|
||||
u) dkms_remove=true;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $dkms_remove = true ]]; then
|
||||
[[ -e $var_dkms_dir ]] && rm -rf $var_dkms_dir && echo "removed $var_dkms_dir"
|
||||
[[ -e $src_dir ]] && rm -f $src_dir && echo "removed $src_dir"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
pushd $cur_dir > /dev/null
|
||||
[[ ! -L $src_dir ]] && ln -sfn $cur_dir $src_dir
|
||||
|
||||
[[ ! -e $src_dir ]] && ln -sfn $cur_dir $src_dir
|
||||
echo "dkms install -c dkms.conf --force -m $dkms_name"
|
||||
dkms install -c dkms.conf --force -m $dkms_name
|
||||
|
||||
popd > /dev/null
|
@ -1,14 +1,35 @@
|
||||
#!/bin/bash
|
||||
[[ -n $1 ]] && dkms=true
|
||||
[[ $dkms = true ]] && uname_r=$1 || uname_r=$(uname -r)
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case $1 in
|
||||
-i|--install) dkms_action='install';;
|
||||
-k|--kernel) dkms_kernel=$2; [[ -z $dkms_kernel ]] && echo '-k|--kernel must be followed by a kernel version' && exit 1;;
|
||||
-r|--remove) dkms_action='remove';;
|
||||
-u|--uninstall) dkms_action='remove';;
|
||||
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
|
||||
(*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ $dkms_action == 'install' ]]; then
|
||||
bash dkms.sh
|
||||
exit
|
||||
elif [[ $dkms_action == 'remove' ]]; then
|
||||
bash dkms.sh -r
|
||||
exit
|
||||
fi
|
||||
|
||||
[[ -n $dkms_kernel ]] && uname_r=$dkms_kernel || uname_r=$(uname -r)
|
||||
kernel_version=$(echo $uname_r | cut -d '-' -f1) #ie 6.4.15
|
||||
|
||||
major_version=$(echo $kernel_version | cut -d '.' -f1)
|
||||
minor_version=$(echo $kernel_version | cut -d '.' -f2)
|
||||
major_minor=${major_version}${minor_version}
|
||||
kernel_short_version="$major_version.$minor_version" #ie 5.2
|
||||
|
||||
build_dir="build"
|
||||
build_dir="buildx"
|
||||
patch_dir='patch_bluetooth'
|
||||
bluetooth_dir="$build_dir/bluetooth"
|
||||
|
||||
@ -29,8 +50,7 @@ fi
|
||||
# remove old kernel tar.xz archives
|
||||
find build/ -type f | grep -E linux.*.tar.xz | grep -v $kernel_version.tar.xz | xargs rm -f
|
||||
|
||||
tar --strip-components=2 -xvf $build_dir/linux-$kernel_version.tar.xz linux-$kernel_version/drivers/bluetooth --directory=build/
|
||||
mv bluetooth $bluetooth_dir
|
||||
tar --strip-components=2 -xvf $build_dir/linux-$kernel_version.tar.xz --directory=build/ linux-$kernel_version/drivers/bluetooth
|
||||
mv $bluetooth_dir/Makefile $bluetooth_dir/Makefile.orig
|
||||
cp -p $bluetooth_dir/hci_bcm.c $bluetooth_dir/hci_bcm.c.orig
|
||||
cp $patch_dir/Makefile $bluetooth_dir/
|
||||
@ -58,11 +78,9 @@ sed -i '/^err_revert_shutdown:$/,+1 d' hci_bcm.c
|
||||
###########################################################################################################
|
||||
popd > /dev/null
|
||||
|
||||
if [[ -z $dkms ]]; then
|
||||
update_dir="/lib/modules/$(uname -r)/updates"
|
||||
[[ ! -d $update_dir ]] && mkdir $update_dir
|
||||
make
|
||||
make install
|
||||
echo -e "\ncontents of $update_dir" && ls -lA $update_dir
|
||||
exit 0
|
||||
fi
|
||||
update_dir="/lib/modules/$(uname -r)/updates"
|
||||
[[ ! -d $update_dir ]] && mkdir $update_dir
|
||||
make
|
||||
make install
|
||||
echo -e "\ncontents of $update_dir" && ls -lA $update_dir
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user