LuckfoxTECH / luckfox-pico

luckfox-pico sdk
318 stars 134 forks source link

1-wire sensors device tree help #90

Open vjoco opened 8 months ago

vjoco commented 8 months ago

I want to access DS18b20 1-wire temperature sensors. The kernel have support for W1_SLAVE_THERM, that includes DS18b20.

But I have no idea how to map the pin in the device tree.... This dts extra code code gives errors:

onewire {
    compatible = "w1-gpio";
    gpios = <&gpio0_pa4 7 GPIO_ACTIVE_HIGH>;
    status = "enabled";
    };
vjoco commented 8 months ago

I can compile the kernel if i put:

    onewire {
        compatible = "w1-gpio";
        gpios = <&gpio0_pa4 7 GPIO_ACTIVE_HIGH>;
        status = "enabled";
    };

and then 
&pinctrl {
//Victor
    gpio0-pa4 {
        gpio0_pa4:gpio0-pa4 {
            rockchip,pins = <0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>;
        };
    };

In kernel i enabled CONFIG_W1_MASTER_GPIO=y CONFIG_W1=y CONFIG_W1_SLAVE_THERM=y

but i see no devices .... .. and no activity on the gpio pin on an osciloscope .. with or without pull up

vjoco commented 8 months ago

I just observed problems on kernel messages: [ 0.126144] Driver for 1-wire Dallas network protocol. [ 0.126540] OF: /onewire: could not get #gpio-cells for /pinctrl/gpio0-pa4/gpio0-pa4 [ 0.126569] w1-gpio onewire: gpio_request (pin) failed [ 0.126618] w1-gpio: probe of onewire failed with error -22 ---- let's see

luckfox-eng33 commented 8 months ago

I don’t have DS18B20 on hand, so I can’t test it at the moment. I'm not sure whether it can be achieved, because the real-time performance of regular Linux systems is not very high, and the support for this kind of single bus is not very good.

kawapiki commented 5 months ago

@vjoco Have you managed it to run?

vjoco commented 5 months ago

@kawapiki I gave up. I switch to dht111 , they have a kernel driver example. It's quite a pitty but I dont have more time to dig in.

kawapiki commented 5 months ago

Thanks, that was my other option too

BoAC-Tech commented 4 months ago

I got 1-wire devices working by using this module: https://github.com/pstolarz/w1-gpio-cl/ Also enabled mentioned kernel modules and now I can runtime enable/disable w1-masters for gpio ports.