Last active
August 29, 2015 14:22
-
-
Save jadonk/ebeef7fb784226fdc80b to your computer and use it in GitHub Desktop.
Install LSM303DLHC driver on BeagleBone (Debian)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
apt-get install linux-headers-`uname -r` | |
mkdir lsm303 | |
cd lsm303 | |
wget http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/driver/stsw-mems026.tar | |
tar xvf stsw-mems026.tar | |
tar xvf lsm303dlhc.v.1.0.13.tar | |
cat <<MAKEFILE >Makefile | |
obj-m += lsm303dlhc_acc.o | |
obj-m += lsm303dlhc_mag.o | |
MAKEFILE | |
cp lsm303dlhc.h /lib/modules/`uname -r`/build/include/linux/input/ | |
# Note: http://elinux.org/Kernel_3.4_to_3.10_porting_guide | |
patch -p0 <<PATCH | |
--- lsm303dlhc_acc.c.orig 2015-05-28 02:21:48.419725347 +0000 | |
+++ lsm303dlhc_acc.c 2015-05-28 02:25:49.009569126 +0000 | |
@@ -1547,7 +1547,7 @@ | |
return err; | |
} | |
-static int __devexit lsm303dlhc_acc_remove(struct i2c_client *client) | |
+static int lsm303dlhc_acc_remove(struct i2c_client *client) | |
{ | |
struct lsm303dlhc_acc_status *stat = i2c_get_clientdata(client); | |
@@ -1610,7 +1610,7 @@ | |
.name = LSM303DLHC_ACC_DEV_NAME, | |
}, | |
.probe = lsm303dlhc_acc_probe, | |
- .remove = __devexit_p(lsm303dlhc_acc_remove), | |
+ .remove = lsm303dlhc_acc_remove, | |
.suspend = lsm303dlhc_acc_suspend, | |
.resume = lsm303dlhc_acc_resume, | |
.id_table = lsm303dlhc_acc_id, | |
--- lsm303dlhc_mag.c.orig 2015-05-28 02:35:34.734178571 +0000 | |
+++ lsm303dlhc_mag.c 2015-05-28 02:38:15.105272340 +0000 | |
@@ -45,6 +45,7 @@ | |
#include <linux/mutex.h> | |
#include <linux/input-polldev.h> | |
#include <linux/slab.h> | |
+#include <linux/module.h> | |
#include <linux/input/lsm303dlhc.h> | |
/* #include "lsm303dlhc.h" */ | |
@@ -1091,7 +1092,7 @@ | |
.pm = &lsm303dlhc_pm, | |
}, | |
.probe = lsm303dlhc_mag_probe, | |
- .remove = __devexit_p(lsm303dlhc_mag_remove), | |
+ .remove = lsm303dlhc_mag_remove, | |
.id_table = lsm303dlhc_mag_id, | |
}; | |
PATCH | |
make -C /lib/modules/`uname -r`/build M=$PWD modules | |
make -C /lib/modules/`uname -r`/build M=$PWD modules_install | |
cd /lib/modules/`uname -r` | |
depmod -a | |
modprobe lsm303dlhc_acc | |
echo lsm303dlhc_acc 0x19 > /sys/bus/i2c/devices/i2c-1/new_device | |
echo 1 > /sys/bus/i2c/devices/1-0019/enable_device | |
evtest /dev/input/event1 |
Rebuilding with http://builds.beagleboard.org/builders/build-kernel/builds/38 is now giving me errors:
root@beaglebone:~# ./install_lsm303.sh Reading package lists... Done Building dependency tree Reading state information... Done linux-headers-3.8.13-gite2e5c8a5eff6f939f8789bdd67a0c9d2bfe02cb3 is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 54 not upgraded. --2015-05-28 14:48:27-- http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/driver/stsw-mems026.tar Resolving www.st.com (www.st.com)... 83.231.249.162 Connecting to www.st.com (www.st.com)|83.231.249.162|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 92160 (90K) [application/x-tar] Saving to: `stsw-mems026.tar' 100%[======================================>] 92,160 118K/s in 0.8s 2015-05-28 14:48:28 (118 KB/s) - `stsw-mems026.tar' saved [92160/92160] lsm303dlhc.v.1.0.13.tar lsm303dlhc_acc.c lsm303dlhc_mag.c lsm303dlhc.h patching file lsm303dlhc_acc.c patching file lsm303dlhc_mag.c make: Entering directory `/usr/src/linux-headers-3.8.13-gite2e5c8a5eff6f939f8789bdd67a0c9d2bfe02cb3' CC [M] /root/lsm303/lsm303dlhc_acc.o scripts/basic/fixdep: 1: scripts/basic/fixdep: Syntax error: "(" unexpected make[1]: *** [/root/lsm303/lsm303dlhc_acc.o] Error 2 make: *** [_module_/root/lsm303] Error 2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's what I get right now: