BPI-R3, OpenWRT, w1, GPIO, DTO

Hi, I would like to connect w1 device (DS18B20 etc) to GPIO of BPI-R3 and got a big headache. OpenWRT v25.12.0

  1. Select a free pin of GPIO by command: “cat /sys/kernel/debug/gpio”. Chose 18pin (GPIO44, UART1_CTS)

  2. Created partition with FS FAT on a free space of eMMC - mmcblk0p6 (I found 20M free eMMC space.)

  3. Wrote compiled w1-gpio.dts file to the mmcblk0p6 partition. ( dtc -@ -I dts -O dtb -o w1-gpio.dtbo w1-gpio.dts )

/dts-v1/;
/plugin/;

/ {
   compatible = "bananapi,bpi-r3", "mediatek,mt7986a";

   fragment@0 {
       target = <&pio>;
       __overlay__ {
           w1_pins: w1-gpio-pins {
               pins = "GPIO44";
               function = "gpio";
           };
       };
   };

   fragment@1 {
       target = <&uart1>;
       __overlay__ {
          status = "disabled"; 
       };
   };

   fragment@2 {
       target-path = "/";
       __overlay__ {
           onewire {
               compatible = "w1-gpio";
               gpios = <&pio 44 0>;   /* GPIO44, pin 18 */
               pinctrl-names = "default";
               pinctrl-0 = <&w1_pins>;
               status = "okay";
           };
       };
   };
};
  1. I tried loading changes to U-Boot bootloader by fw_setenv command.
fw_setenv load_w1 ‘fatload mmc 0:6 $loadaddr w1-gpio.dtbo && fdt addr $loadaddr && fdt resize 8192 && fdt apply $loadaddr’

fw_setenv boot_production ‘run boot_update_conf ; led $bootled_pwr on ; run load_w1 ; run emmc_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off’

As a result of reboot, nothing good happened. Folder /sys/bus/w1/devices is empty.

Please, help. Has anyone connected the w1 bus to GPIO?

I’m nearly sure that your overlay is not loaded…afaik for openwrt you have to modify bootconf in uboot. You can check with cat in /sys/firmware/devicetree/base/… If your nodes are changed (uart1 disable and pinctl node visible via ls)

I agree with you. I don’t see my changes in /sys/firmware/devicetree/base/ My problem is loading the dtbo file into U-Boot. I don’t know how to do this without compiling the kernel (by changing the configuration).

Additionally openwrt should use fit inage on R3 too,so you have to add the overlay to this fit too.

This definition is in target/linux/mediatek/image/filogic.mk

You have to copy your dtsi to the dts folder and add a patch for dts makefile in kernel.

Maybe look at our R4Pro changes to be done. There should be a patch in packages/boot/uboot-mediatek which adds R3 environment where you can then point to your overlay.