🛠 Noyau mainline avec Armbian : vérifier le device tree, ajouter un overlay, lire le SARADC

Radxa ZERO 3W · intermediaire · IMG-rz3w-intermediaire-6-rz3w-armbian-mainline-overlay-saradc.svg — Radxa ZERO 3W sous Armbian : terminal cat /proc/device-tree/compatible (radxa,zero-3w rockchip,rk3566), fichier /boot/armbianEnv.txt avec la ligne overlays=, dossier /boot/dtb/rockchip/overlay/ ; à droite, une tension analogique appliquée sur SARADC_IN5 via un pont diviseur et la lecture in_voltage5_raw.

Objectives

The device tree rk3566-radxa-zero-3w.dts entered the mainline kernel via commit 1a5c8d307c83 (Jonas Karlman, merged on May 27, 2024, first release: Linux 6.10), with eMMC/SD/HDMI/USB support; an MMC alias fix (060c1950) followed in June 2024. Armbian ships this mainline kernel for the board. This tutorial covers: switching to Armbian, verifying that you are indeed using the mainline descriptor, mastering the Armbian overlay mechanism, and reading the analog input SARADC_IN5 (3.3 V max) exposed by the rockchip-saradc IIO driver.

Hardware

1) Verify the mainline board description

cat /proc/device-tree/compatible   # -> radxa,zero-3w rockchip,rk3566
uname -a                           # noyau mainline Armbian (>= 6.10)
ls /boot/dtb/rockchip/ | grep zero3 # le DTB embarqué

2) Armbian Overlays

ls /boot/dtb/rockchip/overlay/     # liste les overlays livrés avec VOTRE release
sudo nano /boot/armbianEnv.txt      # ajoutez : overlays=pwm1i2pwm (exemple)
sudo reboot
# Overlay maison :\ncat > my.dts << 'EOF'
/dts-v1/; /plugin/;
/ {
    fragment@0 {
        target-path = "/";
        __overlay__ {
            vcc_cam: vcc-cam {
                compatible = "regulator-fixed";
                regulator-name = "vcc-cam";
                regulator-min-microvolt = <3300000>;
                regulator-max-microvolt = <3300000>;
            };
        };
    };
};
EOF
dtc -@ -I dts -O dtb -o my.dtbo my.dts   # puis déclarez-le dans armbianEnv.txt

3) SARADC via IIO

ls /sys/bus/iio/devices/iio:device*/          # l'un a name = rockchip-saradc
cat /sys/bus/iio/devices/iio:device0/in_voltage5_raw    # code brut du canal 5
cat /sys/bus/iio/devices/iio:device0/in_voltage_scale   # LSB -> mV
awk 'NR==FNR{r=$1;next}{printf "%.3f V\n", r*$1/1e9}' \
    /sys/bus/iio/devices/iio:device0/in_voltage5_raw \
    /sys/bus/iio/devices/iio:device0/in_voltage_scale

Expected Verification

compatible correctly returns radxa,zero-3w rockchip,rk3566; after adding an overlay, ls /proc/device-tree/ or ls /sys/firmware/devicetree/base/ shows the added node; when turning the potentiometer, in_voltage5_raw follows and the awk calculation displays 0.000 to 3.300 V.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials