@@ -26,10 +26,9 @@ tools to this end
2626 - :ref: `kuiper ` has matured considerably, with broad support for ADI devices
2727 and popular processor and FPGA development platforms
2828
29- - The very popular :adi: `ADXL355 Pmod <eval-adxl355-pmdz> ` would have been
30- used initially, but the Linux driver had not been upstreamed yet. It has since
31- been released, and is being added as an option for this tutorial. (The original
32- ADXL345 / Digilent Pmod-ACL is still included.)
29+ - The :adi: `ADXL355 Pmod <eval-adxl355-pmdz> ` has since been released, and
30+ is being added as an option for this tutorial. (The original ADXL345 /
31+ Digilent Pmod-ACL is still included.)
3332
3433 - LibIIO now supports HWMON devices (if these terms aren't familiar, you'll
3534 learn about them soon), enabling the use of the absolute **best ** device to
@@ -194,7 +193,7 @@ correct image shortly. This is a fairly common step in bringing up embedded
194193computers - Raspberry Pi, BeagleBone, Zedboard, Arrow SoCkit, or any machine
195194that boots from an SD card. There are lots of ways to burn images, but the most
196195straightforward way is to use the standard Raspberry Pi Imager, available here:
197- `Raspberry Pi OS (including Raspbery Pi Imager <https://www.raspberrypi.com/software/ >`__
196+ `Raspberry Pi OS (including Raspbery Pi Imager) <https://www.raspberrypi.com/software/ >`__
198197
199198There are instructions for Windows, Mac, and Linux. The imager also works on
200199machines that encrypt data being written to external drives since it's writing
@@ -310,27 +309,50 @@ find anything. While we do have our ADXL3x5/LM75 physically connected to the
310309board, Linux doesn't know about it yet because UNlike USB, PCI, SCSI, Firewire,
311310HDMI, etc, SPI and I2C devices do not support enumeration. How do we tell the
312311Linux kernel what we've connected to the expansion header? The answer is the
313- "Device Tree Overlay"g
312+ "Device Tree Overlay".
314313
315314While you won't have to do anything more than editing a couple of files in this
316315tutorial, it helps to understand a bit about what is going on under the
317316surface. A "Device Tree" contains information about a system's hardware - what
318317peripherals exist (like displays, memory, USB, Ethernet controllers, GPIO pins,
319318etc.) A "Device Tree Overlay" contains information about additional connected
320- hardware, like our ADXL3x5/LM75. :numref: `fig-device_tree ` shows a screenshot
321- of the ADXL345's overlay source .
319+ hardware, like our ADXL3x5/LM75. :numref: `code-device-tree ` shows the devicetree
320+ of the ADXL345's overlay targetting the Raspberry Pi .
322321It shows that the ADXL345 is connected to the SPI port, using
323322the first CS signal (CS0), the maximum SPI clock frequency is 1MHz, and the
324323interrupt signal is connected to Pin 19 (as shown in the connection diagram
325324above.)
326325
327- .. _ fig-device_tree :
326+ .. _ code-device-tree :
328327
329- .. figure :: device_tree.png
330- :align: center
331- :width: 600
328+ .. code-block :: dts
329+ :caption: Partial ADXL345 overlay source (dts)
330+
331+ // SPDX-License-Identifier: GPL-2.0
332+ /dts-v1/;
333+ /plugin/;
334+
335+ #include <dt-bindings/interrupt-controller/irq.h>
336+
337+ &{/} {
338+ compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
339+ };
340+
341+ &spi0 {
342+ adxl345: adxl345@0 {
343+ compatible = "adi,adxl345";
344+ reg = <0>;
345+ spi-max-frequency = <1000000>;
346+ spi-cpha;
347+ spi-cpol;
348+ interrupts = <19 IRQ_TYPE_LEVEL_HIGH>;
349+ interrupt-parent = <&gpio>;
350+ };
351+ };
332352
333- Partial ADXL345 overlay source (dts)
353+ &spidev0 {
354+ status = "disabled";
355+ };
334356
335357 The device tree source is then compiled into a "flattened" device tree that the
336358Linux kernel reads directly. While this process is fairly straightforward, it's
@@ -342,12 +364,11 @@ Any changes to the connections - SPI CS line, interrrupt line, etc. will
342364require a corresponding modification to the overlay.)
343365
344366For reference, here are the overlay source files for the three devices in this
345- tutorial. These are in the Linux rpi-5.15.y branch, used for Kuiper Linux
346- 2022_r2 release:
367+ tutorial. These are in the Linux rpi-6.12.y branch:
347368
348- - `LM75 Device Tree Overlay <https://github.com/analogdevicesinc/linux/blob/rpi-5.15 .y/arch/arm/boot/dts/overlays/rpi-lm75-overlay.dts >`__
349- - `ADXL345 Device Tree Overlay <https://github.com/analogdevicesinc/linux/blob/rpi-5.15 .y/arch/arm/boot/dts/overlays/rpi-adxl345-overlay.dts >`__
350- - `ADXL355 Device Tree Overlay <https://github.com/analogdevicesinc/linux/blob/rpi-5.15 .y/arch/arm/boot/dts/overlays/rpi-adxl355-overlay.dts >`__
369+ - `LM75 Device Tree Overlay <https://github.com/analogdevicesinc/linux/blob/rpi-6.12 .y/arch/arm/boot/dts/overlays/rpi-lm75-overlay.dts >`__
370+ - `ADXL345 Device Tree Overlay <https://github.com/analogdevicesinc/linux/blob/rpi-6.12 .y/arch/arm/boot/dts/overlays/rpi-adxl345-overlay.dts >`__
371+ - `ADXL355 Device Tree Overlay <https://github.com/analogdevicesinc/linux/blob/rpi-6.12 .y/arch/arm/boot/dts/overlays/rpi-adxl355-overlay.dts >`__
351372
352373.. NOTE ::
353374
@@ -431,6 +452,21 @@ To shut down at the end of the day, type:
431452Hello, ADXL345, ADXL355, or LM75!
432453---------------------------------
433454
455+ .. caution ::
456+
457+ The ADXL345 has two drivers:
458+
459+ - :git-linux: `drivers/iio/accel/adxl345.h ` (``ADXL345_I2C/SPI ``)
460+ - :git-linux: `drivers/input/misc/adxl34x.h ` (``INPUT_ADXL34X ``)
461+
462+ And the IIO driver ``ADXL345_I2C/SPI `` cannot be selected if the inputs
463+ ``INPUT_ADXL34X `` driver is selected! Make sure to do ``make menufconfig `` to
464+ disable ``INPUT_ADXL34X ``, then enable ``ADXL345_I2C/SPI ``.
465+
466+ Kuiper and RPI ships with ``INPUT_ADXL34X `` compiled as a module.
467+ Make sure to `blacklist <https://wiki.debian.org/KernelModuleBlacklisting >`__
468+ the one that won't be used before attaching the devicetree.
469+
434470If all went well, Linux should have booted, found the ADXL3x5 or LM75, and
435471loaded its driver. Run IIO Oscilloscope again. locate the DMM screen, check the
436472ADXL345, select all channels, and click the triangular "play" button. You
0 commit comments