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 hidden or 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 |
Author
Author
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:
root@beaglebone:~# ./install_lsm303.sh --2015-05-28 02:59:09-- 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 191K/s in 0.5s 2015-05-28 02:59:10 (191 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-bone70' CC [M] /root/lsm303/lsm303dlhc_acc.o CC [M] /root/lsm303/lsm303dlhc_mag.o /root/lsm303/lsm303dlhc_mag.c: In function ‘lsm303dlhc_mag_suspend’: /root/lsm303/lsm303dlhc_mag.c:1054:26: warning: unused variable ‘stat’ [-Wunused-variable] /root/lsm303/lsm303dlhc_mag.c: In function ‘lsm303dlhc_mag_resume’: /root/lsm303/lsm303dlhc_mag.c:1067:26: warning: unused variable ‘stat’ [-Wunused-variable] Building modules, stage 2. MODPOST 2 modules WARNING: "input_register_polled_device" [/root/lsm303/lsm303dlhc_mag.ko] undefined! WARNING: "input_allocate_polled_device" [/root/lsm303/lsm303dlhc_mag.ko] undefined! WARNING: "input_free_polled_device" [/root/lsm303/lsm303dlhc_mag.ko] undefined! WARNING: "input_unregister_polled_device" [/root/lsm303/lsm303dlhc_mag.ko] undefined! CC /root/lsm303/lsm303dlhc_acc.mod.o LD [M] /root/lsm303/lsm303dlhc_acc.ko CC /root/lsm303/lsm303dlhc_mag.mod.o LD [M] /root/lsm303/lsm303dlhc_mag.ko make: Leaving directory `/usr/src/linux-headers-3.8.13-bone70' make: Entering directory `/usr/src/linux-headers-3.8.13-bone70' INSTALL /root/lsm303/lsm303dlhc_acc.ko INSTALL /root/lsm303/lsm303dlhc_mag.ko DEPMOD 3.8.13-bone70 make: Leaving directory `/usr/src/linux-headers-3.8.13-bone70' Input driver version is 1.0.1 Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0 Input device name: "lsm303dlhc_acc" Supported events: Event type 0 (EV_SYN) Event type 3 (EV_ABS) Event code 0 (ABS_X) Value -43 Min -16000 Max 16000 Event code 1 (ABS_Y) Value -16 Min -16000 Max 16000 Event code 2 (ABS_Z) Value -1008 Min -16000 Max 16000 Event code 8 (ABS_WHEEL) Value 0 Min -2147483648 Max 2147483647 Event code 40 (ABS_MISC) Value 0 Min -2147483648 Max 2147483647 Properties: Testing ... (interrupt to exit) Event: time 1432781991.694921, type 3 (EV_ABS), code 1 (ABS_Y), value -15 Event: time 1432781991.694921, type 3 (EV_ABS), code 2 (ABS_Z), value -1012 Event: time 1432781991.694921, -------------- SYN_REPORT ------------ Event: time 1432781991.796505, type 3 (EV_ABS), code 0 (ABS_X), value -40 Event: time 1432781991.796505, type 3 (EV_ABS), code 1 (ABS_Y), value -17 Event: time 1432781991.796505, type 3 (EV_ABS), code 2 (ABS_Z), value -1011