Jump to content

Recommended Posts

Posted

Hello does someone have the working configuration enabling the onewire master bus on the mainline version ?

 

I have tried to gather the information from several posts adding the missing configuration on the devicetree but as there is no real step by step guide and the kernel wiki entry makes no sense for the zero`s pins.

 

Overlay or straight settings into the boot configuration.

 

Posted

Here is my W1 Overlay that I use on OPi+2E, you can tweak it to change the pin number you wish to use.

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun8i-h3";

        fragment@0 {
                target-path = "/";
                __overlay__ {

                        w1: onewire@0 {
                                compatible = "w1-gpio";
                                pinctrl-names = "default";
                                pinctrl-0 = <&w1_pins>;
                                gpios = <&pio 3 14 0>; // PD14
                                status = "okay";
                        };
                };
        };

        fragment@1 {
                target = <&pio>;
                __overlay__ {
                        w1_pins: w1_pins {
                                allwinner,pins = "PD14";
                                allwinner,function = "gpio_in"; // in (initially)
                                allwinner,pull = <0>; // off
                        };
                };
        };

        __overrides__ {
                gpiopin =       <&w1>,"gpios:4",
                                <&w1_pins>,"allwinner,pins:0";
        };
};
Posted

Hi! I falling in similar problem - searching step by step guide with no success. Only thing that I found is http://linux-sunxi.org/1-Wire but I can not find &pio label in decompiled dtb (to dts) for opi zero. My kernel version is 4.9.  Please can you describe procedure of editing dtb, where is this damn &pio label?

 

I was trying compile code above, but native dtc gives "Syntax error". Where can find information about compiling and using above code? Please help!

Posted

"pio" is an alias in DTS simply pointing to "/soc/pinctrl@01c20800", looks at the __symbols__ table at the end of DTS.

Of course, for overlays, you need to use a DTC compiler that support overlays like the one from Pantoniou, and use the "-@" option : take "dt-overlays5" branch (or greater) from https://github.com/pantoniou/dtc.git

 

 

Posted

Thank you!

So this is step by step guide:

We need compile special dtc, compile code above into dtbo and  load dtbo overlay.

 

"Enable 1wire on Mainline kernel".

1. mkdir 1wire; cd 1wire

2. nano 1w.dts,  paste and save:

// Definitions for w1-gpio module (without external pullup)
/dts-v1/;
/plugin/;

/ {
    compatible = "allwinner,sun8i-h3";

    fragment@0 {
        target-path = "/";
        __overlay__ {

            onewire@0 {
                compatible = "w1-gpio";
                pinctrl-names = "default";
                pinctrl-0 = <&w1_pins>;
                gpios = <&pio 0 6 0>; // PWM1/PA06 pin on Orange Pi Zero (0 this is A port, 6 this is 06 pin. for PD14 use  <&pio 3 14 0>)
                status = "okay";
            };
        };
    };

    fragment@1 {
        target = <&pio>;
        __overlay__ {
            w1_pins: w1_pins {
                allwinner,pins = "PA06";
                allwinner,function = "gpio_in"; // in (initially)
                allwinner,pull = <0>; // off
            };
        };
    };

};

3. git clone -b dt-overlays8 https://github.com/pantoniou/dtc

4. cd dtc

5. sudo apt-get install flex bison

6. make

7. ./dtc -@ -O dtb -I dts -o 1w.dtbo 1w.dts   (Several warnings will pop up. it is ok.)

8. sudo mkdir /sys/kernel/config/device-tree/overlays/1wire

9. cat 1w.dtbo > /sys/kernel/config/device-tree/overlays/1wire/dtbo

 

you can read now /sys/kernel/config/device-tree/overlays/1wire/status

and look for new devices in /sys/bus/w1/devices/

 

4.7k resistor should be between VCC and 1wire wires

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines