LuckfoxTECH / luckfox-pico

luckfox-pico sdk
239 stars 82 forks source link

1-wire sensors device tree help #90

Open vjoco opened 3 months ago

vjoco commented 3 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 3 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 3 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 3 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 1 month ago

@vjoco Have you managed it to run?

vjoco commented 1 month 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 1 month ago

Thanks, that was my other option too