BlackSpark Posted September 2, 2018 Posted September 2, 2018 I'm relatively new to embedded linux so apologies if there's a simple answer to this question or if I'm not providing the necessary information. And if there's a concept here that I clearly don't understand please point it out as I'm doing all of this as a learning exercize. I am attempting to use the ADXL345 accelerometer with my Orange Pi One. Using the i2c tools I'm able to communicate with the device but would like to use the linux drivers found here: https://wiki.analog.com/resources/tools-software/linux-drivers/input-misc/adxl345 I've tried using modprobe to insert the module but it seems it's not available and I'm unsure why as I believe they're mainline kernel drivers: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/input/misc/adxl34x.c?id=HEAD I have checked /lib/modules/4.14.18-sunxi/kernel/drivers/input/misc and the module definitely isn't there so I'm unsure where to go from here. Should I be compiling and inserting the driver myself? Or do I need to rebuild the kernel with the driver? Are the drivers I'm trying to use even possible with Armbian? Thanks in advance for your help.
martinayotte Posted September 2, 2018 Posted September 2, 2018 This driver is present in Dev builds 4.18.5 : CONFIG_ADXL345=m CONFIG_ADXL345_I2C=m BTW, the final location you've look is wrong, it should be there : /lib/modules/4.18.5-sunxi/kernel/drivers/iio/accel/adxl345_i2c.ko /lib/modules/4.18.5-sunxi/kernel/drivers/iio/accel/adxl345_spi.ko /lib/modules/4.18.5-sunxi/kernel/drivers/iio/accel/adxl345_core.ko
Larry Bank Posted September 2, 2018 Posted September 2, 2018 If you can't get that going, you can use my project as a starting point. Talking to the ADXL345 over I2C is extremely easy and writing your own code will allow you to have better control of it. Here's my code: https://github.com/bitbank2/accelerometers
BlackSpark Posted September 3, 2018 Author Posted September 3, 2018 16 hours ago, martinayotte said: This driver is present in Dev builds 4.18.5 : CONFIG_ADXL345=m CONFIG_ADXL345_I2C=m BTW, the final location you've look is wrong, it should be there : /lib/modules/4.18.5-sunxi/kernel/drivers/iio/accel/adxl345_i2c.ko /lib/modules/4.18.5-sunxi/kernel/drivers/iio/accel/adxl345_spi.ko /lib/modules/4.18.5-sunxi/kernel/drivers/iio/accel/adxl345_core.ko Thanks martinayotte! I'll have a go at building the 4.18.5 Dev build. Any idea why it's in two locations? 14 hours ago, Larry Bank said: If you can't get that going, you can use my project as a starting point. Talking to the ADXL345 over I2C is extremely easy and writing your own code will allow you to have better control of it. Here's my code: https://github.com/bitbank2/accelerometers Cheers Larry, however I've already written code similar to yours (but not nearly as tidy as yours haha) and am trying to learn more about embedded Linux so going to keep persevering with the mainline kernel drivers, thanks though!
martinayotte Posted September 3, 2018 Posted September 3, 2018 7 hours ago, BlackSpark said: Any idea why it's in two locations? What do you mean ? They are at only one location "kernel/drivers/iio/accel" ...
BlackSpark Posted September 4, 2018 Author Posted September 4, 2018 On 9/4/2018 at 12:11 AM, martinayotte said: What do you mean ? They are at only one location "kernel/drivers/iio/accel" ... There are C and header files for the 'adxl345' driver here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iio/accel?id=HEAD While there are also C and header files for similar 'adxl34x' device drivers here: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/input/misc?id=HEAD And the second link is the link that is provided on the official Analog Devices wiki here: https://wiki.analog.com/resources/tools-software/linux-drivers/input-misc/adxl345
abhi Posted September 5, 2018 Posted September 5, 2018 Old one is using Input sub system, new one is using IIO. Both the drivers are working for me.
martinayotte Posted September 5, 2018 Posted September 5, 2018 Ah ! Ok ! I think the second one sit on top of the first to get "input events" functionality. This means you would need to compile your own kernel with CONFIG_INPUT_ADXL34X_SPI=m.
BlackSpark Posted September 7, 2018 Author Posted September 7, 2018 Ah right, thanks guys! Appreciate the help
Recommended Posts