Post Go back to editing

Linux Kuiper overlay setup

Category: Software
Product Number: AD7386-4 , AD7386
Software Version: 2025-03-18-ADI-Kuiper-ful

Hi,

I tried to interface the AD7386-4 with the Kuiper Linux and modified the rpi-ad738x-overlay.dts like:

/dts-v1/;
/plugin/;

/ {
        compatible = "brcm,bcm2708";

        fragment@0 {
                target-path = "/";
                __overlay__ {
                        adc_vref: fixedregulator@0 {
                                compatible = "regulator-fixed";
                                regulator-name = "fixed-supply";
                                regulator-min-microvolt = <2500000>;
                                regulator-max-microvolt = <2500000>;
                                regulator-boot-on;
                        };
                };
        };

        fragment@1 {
                target = <&spi0>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "okay";

                        ad7386-4@0 {
                                compatible = "adi,ad7386-4";
                                reg = <0>;
                                spi-max-frequency = <1000000>;
                                spi-cpol;
                                vref-supply = <&adc_vref>;
                        };
                };
        };
};

it works half and the driver loads but when I look at the device info with iio_info it displays

only 4 channels. I know the -4 version has a MUX in front of 4 channels but I dont know how

to include this in the overlay.

root@analog:/boot/overlays# iio_info
iio_info version: 0.26 (git tag:5e1e9cb5)
Libiio version: 0.26 (git tag: 5e1e9cb) backends: local xml ip usb serial
IIO context created with local backend.
Backend version: 0.26 (git tag: 5e1e9cb)
Backend description string: Linux analog 6.1.54-v7l+ #1 SMP Mon Dec  2 10:56:39 UTC 2024 armv7l
IIO context has 4 attributes:
        hw_carrier: Raspberry Pi 4 Model B Rev 1.4
        dtoverlay: vc4-kms-v3d,dwc2,rpi-ad7386-4
        local,kernel: 6.1.54-v7l+
        uri: local:
IIO context has 3 devices:
        hwmon0: cpu_thermal
                1 channels found:
                        temp1:  (input)
                        2 channel-specific attributes found:
                                attr  0: crit value: 110000
                                attr  1: input value: 38459
                No trigger on this device
        hwmon1: rpi_volt
                1 channels found:
                        in0:  (input)
                        1 channel-specific attributes found:
                                attr  0: lcrit_alarm value: 0
                No trigger on this device
        iio:device0: ad7386-4 (buffer capable)
                4 channels found:
                        voltage0:  (input, index: 0, format: be:S16/16>>0)
                        2 channel-specific attributes found:
                                attr  0: raw value: 0
                                attr  1: scale value: 0.076293945
                        voltage1:  (input, index: 1, format: be:S16/16>>0)
                        2 channel-specific attributes found:
                                attr  0: raw value: 0
                                attr  1: scale value: 0.076293945
                        voltage2:  (input, index: 2, format: be:S16/16>>0)
                        2 channel-specific attributes found:
                                attr  0: raw value: 0
                                attr  1: scale value: 0.076293945
                        voltage3:  (input, index: 3, format: be:S16/16>>0)
                        2 channel-specific attributes found:
                                attr  0: raw value: 0
                                attr  1: scale value: 0.076293945
                1 device-specific attributes found:
                                attr  0: waiting_for_supplier value: 0
                2 buffer-specific attributes found:
                                attr  0: data_available value: 0
                                attr  1: direction value: in
                1 debug attributes found:
                                debug attr  0: direct_reg_access value: 0x0
ERROR: checking for trigger : Input/output error (5)

Can you provide me some guidance how to enable all channels and deactivate triggering?

/Jan

Thread Notes

  • Hi  ,

    Not sure I'm getting what you mean by 'enable all channels and deactivate triggering?'

    The ADC channels should be enabled by default. Does `cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw` errors or fails to bring ADC output codes?

    The device trigger is used for triggered buffer data capture. It should be fine to do single-shot ADC readings without any trigger.

    Linux kernel 6.1 is a bit old now and the AD7386 driver got many updates in 2024 and 2025. Can you try newer versions of Linux Kuiper and/or Linux kernel?

    Also, if switching to a newer kernel, have a look at device tree documentation to properly update the dt overlay.

    https://github.com/analogdevicesinc/linux/blob/main/Documentation/devicetree/bindings/iio/adc/adi%2Cad7380.yaml

    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/iio/adc/adi,ad7380.yaml?h=v6.17-rc6

  • Hey!

    Thank you for your reply.

    Looking through the kernel source, the newer versions of the AD7386-4 driver support indeed 8 channels. The driver included in the latest Kuiper Linux, only supports 4 channels.

    I updated the kernel to the newest (rpi-6.12.y) from github and compiled it. Everything works fine except the driver.

    Now, with this overlay (I know the voltages might be wrong, but just for testing): 

    // SPDX-License-Identifier: GPL-2.0
    /dts-v1/;
    /plugin/;
    
    / {
            compatible = "brcm,bcm2708";
    
            fragment@0 {
                    target-path = "/";
                    __overlay__ {
                            adc_vref: fixedregulator@0 {
                                    compatible = "regulator-fixed";
                                    regulator-name = "fixed-supply";
                                    regulator-min-microvolt = <2500000>;
                                    regulator-max-microvolt = <2500000>;
                                    regulator-boot-on;
                            };
                    };
            };
    
            fragment@1 {
                    target = <&spi0>;
                    __overlay__ {
                            #address-cells = <1>;
                            #size-cells = <0>;
                            status = "okay";
    
                            ad7386-4@0 {
                                    compatible = "ad7386-4";
                                    reg = <0>;
                                    spi-max-frequency = <1000000>;
                                    vcc-supply = <&adc_vref>;
                                    vlogic-supply = <&adc_vref>;
                            };
                    };
            };
    };

    The overlay gets loaded but using dmesg I got the following errors:

    [    5.192162] spi spi0.0: chipselect 0 already in use
    [    5.192182] spi_master spi0: spi_device register error /soc/spi@7e204000/spidev@0
    [    5.192207] spi_master spi0: Failed to create SPI device for /soc/spi@7e204000/spidev@0
    
    [    6.775424] ad7380 spi0.0: probe with driver ad7380 failed with error -22
    

    Then, also using iio_info is showing no device:

    iio_info version: 0.26 (git tag:5e1e9cb5)
    Libiio version: 0.26 (git tag: 5e1e9cb) backends: local xml ip usb serial
    IIO context created with local backend.
    Backend version: 0.26 (git tag: 5e1e9cb)
    Backend description string: Linux analog 6.12.41-v7l+ #2 SMP Tue Oct  7 19:32:36 BST 2025 armv7l
    IIO context has 4 attributes:
            hw_carrier: Raspberry Pi 4 Model B Rev 1.4
            dtoverlay: vc4-kms-v3d,dwc2,rpi-ad738x
            local,kernel: 6.12.41-v7l+
            uri: local:
    IIO context has 2 devices:
            hwmon0: cpu_thermal
                    1 channels found:
                            temp1:  (input)
                            1 channel-specific attributes found:
                                    attr  0: input value: 46738
                    No trigger on this device
            hwmon1: rpi_volt
                    1 channels found:
                            in0:  (input)
                            1 channel-specific attributes found:
                                    attr  0: lcrit_alarm value: 0
                    No trigger on this device
    

    Is it a problem with the overlay? I also tried to disable spidev0 in the overlay too, but it also doesn't work.

    It is also curious that iio_info shows the overlay but according to the 'dtoverlay -l' command it is not loaded.