GithubHelp home page GithubHelp logo

zeronote / lx_lis3dh Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 289 KB

Simple DTBO and out-of-tree driver module for ST LIS3DH accelerometer.

License: GNU General Public License v3.0

Makefile 1.12% C 92.83% Shell 6.05%

lx_lis3dh's Introduction

BBB Pin Mapping Table

BBB P9 header LIS3DH
Pin 1 (DGND) GND
Pin 3 (VDD_3V3) Vin
Pin 15 (GPIO_48) INT
Pin 19 (I2C2_SCL) SCL
Pin 20 (I2C2_SDA) SDA

TOOLCHAIN SETUP

Really important disclaimer

My first really important assumption is that you are working on a Beaglebone Black system with the following:

  • U-Boot 2016.01-00001-g4eb802e (Jan 13 2016 - 11:14:31 -0600)
  • Linux beaglebone 4.1.15-ti-rt-r43

otherwise, depending on u-boot and kernel version, some of the followings steps could be erroneous or lead to undefined results.

Packages

The following packages are needed if you are on a Debian/Ubuntu based host machine:

  • lib32stdc++6
  • lzop
  • lib32z1
  • zlibc
  • device-tree-compiler
  • build-essential

Pre-setup

To avoid problems during kernel module insmod, replace the Module.symvers_beaglebone in this repo with the one in you kernel headers. E.g.

scp [email protected]:/usr/src/$(uname -r)/Module.symvers Module.symvers_beaglebone

this should prevent errors like:

insmod error: inserting './lxdriver.ko': -1 Invalid module format

which, looking at dmesg, point us to the Module.symvers root cause:

lxdriver.ko: no symbol version for module_layout

Setup

Simply executing setup.sh should download, configure and cross-compile everything for you except the LIS3DH kernel module that you're supposed to cross-compile by yourself using make once the setup.sh script exit. If everything went well, you should have the followings in your current directory:

  • lxdriver.ko
  • BB-LX-ACCEL-00A0.dtbo

Once gained any kind of access to your BBB, copy the kernel lxdriver.ko in /lib/modules/$(uname -r)and BB-LX-ACCEL-00A0.dtboto /lib/firmware.

Testing

Since the universal_cape overlay is enabled by default, we need to disable it to avoid race conditions on the GPIO_48 pin once our overlay is loaded: with sudo vim /boot/uEnv.txt change this line:

cmdline=coherent_pool=1M quiet cape_universal=enable

to

cmdline=coherent_pool=1M quiet

and reboot your BBB.

Finally we can load the dtb overlay

sudo sh -c 'echo BB-LX-ACCEL-00A0.DTBO > /sys/devices/platform/bone_capemgr/slots'

load the kernel module:

sudo insmod /lib/firmware/lxdriver.ko

and check our 3-axis accelerations:

sudo cat /dev/lxaccell

debian@beaglebone:~$ sudo cat /dev/lxaccell
787,298,540
787,298,540
780,304,541
780,304,541
780,304,541
780,304,541
780,304,541
780,304,541
780,304,541
780,304,541
780,304,541
780,304,541
780,304,541

lx_lis3dh's People

Contributors

zeronote avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.