Temperature from DS18B20

[0][10:37][root@rock][/] $ dmesg|grep w1
[    8.591184] rockchip-pinctrl pinctrl: unable to find group for node w1_pins
[   29.262471] w1_master_driver w1_bus_master1: w1_search: max_slave_count 64 reached, will continue next search.
[  141.171302] w1_slave_driver 28-01186bce26ff: Read failed CRC check
[  162.083267] w1_slave_driver 28-01186bce26ff: Read failed CRC check
[0][10:37][root@rock][/] $ cat /sys/kernel/debug/gpio
GPIOs 0-31, platform/pinctrl, gpio0:
 gpio-4   (                    |bt_default_wake_host) in  lo
 gpio-9   (                    |bt_default_reset    ) out lo
 gpio-10  (                    |reset               ) out lo

GPIOs 32-63, platform/pinctrl, gpio1:
 gpio-35  (                    |vcc5v0_otg          ) out hi
 gpio-46  (                    |vsel                ) out lo
 gpio-49  (                    |vsel                ) out lo

GPIOs 64-95, platform/pinctrl, gpio2:
 gpio-83  (                    |bt_default_rts      ) in  hi
 gpio-90  (                    |vcc3v3_pcie         ) out hi
 gpio-91  (                    |bt_default_wake     ) in  lo

GPIOs 96-127, platform/pinctrl, gpio3:
 gpio-111 (                    |mdio-reset          ) out hi
 gpio-124 (                    |?                   ) out lo
 gpio-125 (                    |?                   ) out lo

GPIOs 128-159, platform/pinctrl, gpio4:
 gpio-153 (                    |vcc5v0_host         ) out hi
 gpio-158 (                    |w1                  ) in  hi
[0][10:38][root@rock][/] $
[0][10:38][root@rock][/] $ cat /sys/kernel/debug/pinctrl/pinctrl-devices
name [pinmux] [pinconf]
rockchip-pinctrl yes yes
[0][10:38][root@rock][/] $
[0][10:38][root@rock][/] $ ls /sys/bus/w1/devices/
28-01186bce26ff  w1_bus_master1
[0][10:38][root@rock][/] $ cat /sys/bus/w1/devices/28*/w1_slave
ff ff ff ff ff ff ff ff ff : crc=c9 NO
00 00 00 00 00 00 00 00 00 t=-62

cat /sys/bus/w1/devices/28-01186bce26ff/w1_slave

It is already above.

@Stephen did you turn off UART on Rock for this thermal sensor to make it work?

I didn’t turn UART off.

Ok, I’ve changed Radxa Ubuntu to Armbian for RK3399 (Rock Pi 4 B) and according to this thread pages 3 and 4:


there is no support on Rock Pi 4 B for DS18B20 without recompiling the overlays exclusively.
So I don’t know how Stephen has make it work, but I’ve spent few days reading and trying and with no success. I give up for now. I’ll wait for guys making the sensor reading available to average mortal.

@Stephen which pin did you mention on Armbian for param_w1_pin?

[0][16:30][root@rock][/] $ dmesg | grep gpio
[   48.810859] rk808-regulator rk808-regulator: there is no dvs0 gpio
[   48.812924] rk808-regulator rk808-regulator: there is no dvs1 gpio
[   49.789021] rockchip-pinctrl pinctrl: pin gpio3-28 already requested by leds; cannot claim for ff880000.i2s
[   49.789041] rockchip-pinctrl pinctrl: could not request pin 124 (gpio3-28) from group i2s0-8ch-bus  on device rockchip-pinctrl
[   53.304092] gpio-36 (onewire@0): enforced open drain please flag it properly in DT/ACPI DSDT/board file
[   53.304146] OF: /onewire@0: could not get #gpio-cells for /opp-table2
[   53.304162] w1-gpio onewire@0: gpio_request_one (ext_pullup_enable_pin) failed
[   53.304194] w1-gpio: probe of onewire@0 failed with error -22

On Ubuntu 18.04,
Linux rock 4.4.154-95-rockchip-gd2ab1f26e1b3 #1 SMP Mon Oct 21 06:42:35 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
the dmesg | grep gpio gives:

[    0.335135] gpiochip_add_data: registered GPIOs 0 to 31 on device: gpio0
[    0.335209] gpiochip_add_data: registered GPIOs 32 to 63 on device: gpio1
[    0.335283] gpiochip_add_data: registered GPIOs 64 to 95 on device: gpio2
[    0.335353] gpiochip_add_data: registered GPIOs 96 to 127 on device: gpio3
[    0.335427] gpiochip_add_data: registered GPIOs 128 to 159 on device: gpio4
[    1.445754] of_get_named_gpiod_flags: parsed 'rockchip,power-ctrl' property of node '/rockchip-suspend[0]' - status (0)
[    1.445795] of_get_named_gpiod_flags: parsed 'rockchip,power-ctrl' property of node '/rockchip-suspend[1]' - status (0)
[    1.446021] of_get_named_gpiod_flags: can't parse 'gpio' property of node '/vcc1v8-s0[0]'
[    1.446263] of_get_named_gpiod_flags: can't parse 'gpio' property of node '/vcc-sys[0]'
[    1.446490] of_get_named_gpiod_flags: can't parse 'gpio' property of node '/vcc-phy-regulator[0]'
[    1.446700] of_get_named_gpiod_flags: can't parse 'gpio' property of node '/vcc3v3-sys[0]'
[    1.447144] of_get_named_gpiod_flags: parsed 'gpio' property of node '/vcc3v3-pcie-regulator[0]' - status (0)
[    1.447568] of_get_named_gpiod_flags: parsed 'gpio' property of node '/vcc5v0-host-regulator[0]' - status (0)
[    1.447966] of_get_named_gpiod_flags: parsed 'gpio' property of node '/vcc5v0-otg-regulator[0]' - status (0)
[    1.883715] of_get_named_gpiod_flags: parsed 'ep-gpios' property of node '/pcie@f8000000[0]' - status (0)
[    2.414484] of_get_named_gpiod_flags: can't parse 'enable-gpios' property of node '/vdd-log[0]'
[    2.414493] of_get_named_gpiod_flags: can't parse 'enable-gpio' property of node '/vdd-log[0]'
[    2.486035] of_get_named_gpiod_flags: parsed 'snps,reset-gpio' property of node '/ethernet@fe300000[0]' - status (0)
[    2.902684] of_get_named_gpiod_flags: parsed 'vsel-gpios' property of node '/i2c@ff3c0000/syr827@40[0]' - status (0)
[    2.909986] of_get_named_gpiod_flags: parsed 'vsel-gpios' property of node '/i2c@ff3c0000/syr828@41[0]' - status (0)
[    2.922824] of_get_named_gpiod_flags: can't parse 'dvs-gpios' property of node '/i2c@ff3c0000/pmic@1b[0]'
[    2.922834] of_get_named_gpiod_flags: can't parse 'dvs-gpio' property of node '/i2c@ff3c0000/pmic@1b[0]'
[    2.922857] rk808-regulator rk808-regulator: there is no dvs0 gpio
[    2.925412] of_get_named_gpiod_flags: can't parse 'dvs-gpios' property of node '/i2c@ff3c0000/pmic@1b[1]'
[    2.925420] of_get_named_gpiod_flags: can't parse 'dvs-gpio' property of node '/i2c@ff3c0000/pmic@1b[1]'
[    2.925442] rk808-regulator rk808-regulator: there is no dvs1 gpio
[    3.008342] rockchip-iodomain ff770000.syscon:io-domains: Looking up gpio1830-supply from device tree
[    3.066126] of_get_named_gpiod_flags: can't parse 'wp-gpios' property of node '/dwmmc@fe310000[0]'
[    3.066135] of_get_named_gpiod_flags: can't parse 'wp-gpio' property of node '/dwmmc@fe310000[0]'
[    3.078201] of_get_named_gpiod_flags: can't parse 'cd-gpios' property of node '/dwmmc@fe320000[0]'
[    3.078210] of_get_named_gpiod_flags: can't parse 'cd-gpio' property of node '/dwmmc@fe320000[0]'
[    3.078250] of_get_named_gpiod_flags: can't parse 'wp-gpios' property of node '/dwmmc@fe320000[0]'
[    3.078257] of_get_named_gpiod_flags: can't parse 'wp-gpio' property of node '/dwmmc@fe320000[0]'
[    3.120602] of_get_named_gpiod_flags: can't parse 'wp-gpios' property of node '/sdhci@fe330000[0]'
[    3.120610] of_get_named_gpiod_flags: can't parse 'wp-gpio' property of node '/sdhci@fe330000[0]'
[    3.174202] of_get_named_gpiod_flags: parsed 'gpios' property of node '/gpio-leds/user-led1[0]' - status (0)
[    3.174630] of_get_named_gpiod_flags: parsed 'gpios' property of node '/gpio-leds/user-led2[0]' - status (0)
[    3.221731] of_get_named_gpiod_flags: can't parse 'spk-con-gpio' property of node '/i2c@ff110000/es8316@11[0]'
[    3.221744] es8316 1-0011: Can not read property spk_ctl_gpio
[    3.226645] of_get_named_gpiod_flags: can't parse 'hp-det-gpio' property of node '/i2c@ff110000/es8316@11[0]'
[    3.226655] es8316 1-0011: Can not read property hp_det_gpio
[    3.359149] [WLAN_RFKILL]: wlan_platdata_parse_dt: wifi power controled by gpio.
[    3.361717] of_get_named_gpiod_flags: can't parse 'WIFI,poweren_gpio' property of node '/wireless-wlan[0]'
[    3.361725] of_get_named_gpiod_flags: can't parse 'WIFI,vbat_gpio' property of node '/wireless-wlan[0]'
[    3.361733] of_get_named_gpiod_flags: can't parse 'WIFI,reset_gpio' property of node '/wireless-wlan[0]'
[    3.361773] of_get_named_gpiod_flags: parsed 'WIFI,host_wake_irq' property of node '/wireless-wlan[0]' - status (0)
[    3.366963] [WLAN_RFKILL]: rfkill_wlan_probe: init gpio
[    3.374699] of_get_named_gpiod_flags: parsed 'uart_rts_gpios' property of node '/wireless-bluetooth[0]' - status (0)
[    3.374705] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: uart_rts_gpios = 83.
[    3.376740] of_get_named_gpiod_flags: can't parse 'BT,power_gpio' property of node '/wireless-bluetooth[0]'
[    3.376760] of_get_named_gpiod_flags: parsed 'BT,reset_gpio' property of node '/wireless-bluetooth[0]' - status (0)
[    3.376766] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,reset_gpio = 9.
[    3.378816] of_get_named_gpiod_flags: parsed 'BT,wake_gpio' property of node '/wireless-bluetooth[0]' - status (0)
[    3.378821] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,wake_gpio = 91.
[    3.380818] of_get_named_gpiod_flags: parsed 'BT,wake_host_irq' property of node '/wireless-bluetooth[0]' - status (0)
[    4.160422] of_get_named_gpiod_flags: can't parse 'wp-gpios' property of node '/dwmmc@fe310000[0]'
[    4.160429] of_get_named_gpiod_flags: can't parse 'wp-gpio' property of node '/dwmmc@fe310000[0]'
[    4.160622] of_get_named_gpiod_flags: parsed 'reset-gpios' property of node '/sdio-pwrseq[0]' - status (0)
[    4.211131] of_get_named_gpiod_flags: can't parse 'simple-audio-card,hp-det-gpio' property of node '/es8316-sound[0]'
[    4.211148] of_get_named_gpiod_flags: can't parse 'simple-audio-card,mic-det-gpio' property of node '/es8316-sound[0]'
[    4.454364] of_get_named_gpiod_flags: can't parse 'simple-audio-card,hp-det-gpio' property of node '/hdmi-codec[0]'
[    4.454375] of_get_named_gpiod_flags: can't parse 'simple-audio-card,mic-det-gpio' property of node '/hdmi-codec[0]'
[    7.100139] of_get_named_gpiod_flags: parsed 'gpios' property of node '/onewire@0[0]' - status (0)
[    7.100169] of_get_named_gpiod_flags: can't parse 'gpios' property of node '/onewire@0[1]'
[    7.572578] dhd_wlan_init_gpio: GPIO(WL_REG_ON) = -1
[    7.572582] dhd_wlan_init_gpio: GPIO(WL_HOST_WAKE) = -1
[    7.572597] dhd_wlan_init_gpio: host_oob_irq: 65
[    7.572603] dhd_wlan_init_gpio: host_oob_irq_flags=0x414

one-wire pin: GPIO4_D6 (Pin#37 on 40-pin header)

Yes, this is the one I’ve connected the sensor to.

I was asking for param_w1_pin in Armbian kernel config file in /boot/ folder…

rockchip-w1-gpio.dts

/dts-v1/;
/plugin/;

/ {
compatible = “rockchip,rk3399”;

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

                    w1: onewire@0 {
                            compatible = "w1-gpio";
                            pinctrl-names = "default";
                            gpios = <&gpio4 30 0 0xae>;
                            status = "okay";
                    };
            };
    };

};

Armbian:
overlays=w1-gpio uart4 i2c7
param_w1_pin=PD6

Official:
nano hw_intfc.conf
intfc:dtoverlay=rockchip-w1-gpio

modprobe wire
modprobe w1-gpio
modprobe w1-therm

dmesg|grep w1
cat /sys/kernel/debug/gpio

ls /sys/bus/w1/devices/
cd /sys/bus/w1/devices/
cat /sys/bus/w1/devices/28*/w1_slave
cat /sys/bus/w1/devices/28-000003718020/w1_slave
cat /sys/bus/w1/devices/w1_bus_master1/28-000003718020/w1_slave

awk -F= ‘/t=/ {printf “%.03f\n”, $2/1000}’ /sys/devices/w1_bus_master1/28-0315549dd0ff/w1_slave
cat /sys/bus/w1/devices/28*/w1_slave | grep t= | awk -F= ‘{ printf “%.3f C\n”, $2/1000}’

It works!

I’ve made only 2 changes:

/plugin/;
...
gpios = < &gpio4 30 0 0xae >;

and adding w1: does stop booting the system so don’t add it.

So I have now working sensor!

Thank you!

[0][03:40][root@rock][/sys/bus/w1/devices/28-01186bce26ff] $ cat ./w1_slave
96 01 4b 46 7f ff 0c 10 a0 : crc=a0 YES
96 01 4b 46 7f ff 0c 10 a0 t=25375

First measure after reboot is ok, but each next not. I tried to reconnect resistor because it seems like it was failing here (its wires are garbled but not touching) but for now it is not working beside 1st time…

Still the problem is not solved.

When getting a 5.5-rc6 version of kernel running on the ROCK Pi 4 board, I find that data read from DS18B20 is correct. ROCK Pi 4 read data every ten seconds.

Now we need to apply some patches to the current version (4.4.154) of the kernel.

Thanks for the info. Then I will be awaiting new kernel patiently.

Hi, any chance to get 1wire support for RockPiS? Will modified rockchip-w1-gpio.dts file work for rk3308 instead of rk3399 SoC of RockPi4? Thx.

Hi Stephen,

when will be released new version of kernel?

Bump? Anything guyz? :slight_smile:

Bumping up, @Stephen!

After digging out, the w1 driver for ds18b20 is related to hwmon, gpio subsystem, etc. To fix the issue of read error, also need apply the patches for hwmon, gpio subsystem, etc. The question is, those subsystem changes a lot from 4.4 to 5.x in the recent years. Applying patches will bring a lot of risks.