1wire DS18b20 on Rock64?
#1
Has anyone got DS18b20 to work on rock64? If you can point in the right direction, I would appreciate that very much. I've been searching and cant find anything other the a post for pine64 that said that I need to use pin 12.
  Reply
#2
(12-23-2018, 12:32 PM)mypineme Wrote: Has anyone got DS18b20 to work on rock64?

Yes. Step by step:
  1. Hardware setup: I suppose pin12 is unusable (works only as input). Let's make following pin connection setup - rock64 pin1 (3.3V) = DS18B20 pin3 (VDD), rock64 pin7 (GPIO1_D4) = DS18B20 pin2 (DQ), rock64 pin9 (GND) = DS18B20 pin1 (GND) and pullup resistor 4k7 ohm between DS18B20 pin3 and DS18B20 pin2.
  2. Prepare DTOVERLAY for "w1_gpio" driver association. Let's assume GPIO1_D4 == id 60, GPIO1_D4 == GPIO1 + bit 28.
    Code:
    $ cat > w1_pin60.dts << 'EOF'
    /dts-v1/;
    /plugin/;

    / {
        compatible = "pine64,rock64", "rockchip,rk3328";
        fragment@0 {
            target-path = "/";
            __overlay__ {
                w1: onewire@0 {
                    compatible = "w1-gpio";
                    pinctrl-names = "default";
                    pinctrl-0 = <&w1_pins>;
                    gpios = <&gpio1 28 0>;
                    status = "okay";
                };
            };
        };
        fragment@1 {
            target = <&gpio1>;
            __overlay__ {
                w1_pins: w1_pins@0 {
                    rockchip,pins = <1 28 0 &pcfg_pull_up>;
                };
            };
        };
    };
    EOF
    $ dtc -I dts -O dtb -@ w1_pin60.dts -o w1_pin60.dtbo
    $ ### ignore warnings
  3. Successful load of DTOVERLAY depends on your device tree (DTB symbols must be included). Check DTB symbols if exists skip to step 5.
    Code:
    $ dtc /boot/dtbs/$(uname -r)/rockchip/rk3328-rock64.dtb -o - 2>/dev/null | grep __symbols__
        __symbols__ {
    $ ### ^^^^ symbols included or not included if no output
  4. Symbols are NOT present in latest stable 0.7.9 based on kernel 4.4.132-1075 Sad
    So you must rebuild rk3328-rock64.dtb with symbols.
    Code:
    $ uname -a
    Linux rock64 4.4.132-1075-rockchip-ayufan-ga83beded8524 #1 SMP Thu Jul 26 08:22:22 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux
    $ sudo bash
    # wget https://github.com/ayufan-rock64/linux-kernel/archive/4.4.132-1075-rockchip-ayufan.tar.gz
    # tar xzf 4.4.132-1075-rockchip-ayufan.tar.gz
    # cd linux-kernel-4.4.132-1075-rockchip-ayufan/
    # export ARCH=arm64
    # make rockchip_linux_defconfig
    # make DTC_FLAGS="-@" dtbs
    # mv /boot/dtbs/4.4.132-1075-rockchip-ayufan-ga83beded8524/rockchip/rk3328-rock64.dtb /boot/dtbs/4.4.132-1075-rockchip-ayufan-ga83beded8524/rockchip/rk3328-rock64.dtb_orig
    # cp arch/arm64/boot/dts/rockchip/rk3328-rock64.dtb /boot/dtbs/4.4.132-1075-rockchip-ayufan-ga83beded8524/rockchip/rk3328-rock64.dtb
    # reboot
    # ### after reboot check presented symbols
  5. Load DTOVERLAY:
    Code:
    $ sudo bash
    # ### speedup minimum CPU frequency due to polling behavior of w1-gpio
    # echo 600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq

    # ### load DTOVERLAY
    # mkdir -p /sys/kernel/config/device-tree/overlays/w1
    # cat w1_pin60.dtbo > /sys/kernel/config/device-tree/overlays/w1/dtbo
    # lsmod | grep w1
    w1_gpio                16384  0
    wire                   32768  1 w1_gpio

    # find /sys/bus/w1/
    /sys/bus/w1/
    /sys/bus/w1/devices
    /sys/bus/w1/devices/w1_bus_master1
    /sys/bus/w1/drivers
    /sys/bus/w1/drivers/w1_master_driver
    /sys/bus/w1/drivers/w1_master_driver/bind
    /sys/bus/w1/drivers/w1_master_driver/w1_bus_master1
    /sys/bus/w1/drivers/w1_master_driver/uevent
    /sys/bus/w1/drivers/w1_master_driver/unbind
    /sys/bus/w1/drivers/w1_slave_driver
    /sys/bus/w1/drivers/w1_slave_driver/bind
    /sys/bus/w1/drivers/w1_slave_driver/uevent
    /sys/bus/w1/drivers/w1_slave_driver/unbind
    /sys/bus/w1/uevent
    /sys/bus/w1/drivers_probe
    /sys/bus/w1/drivers_autoprobe

    # ### autoprobe should discover sensor after few seconds
    # find /sys/bus/w1/
    /sys/bus/w1/
    /sys/bus/w1/devices
    /sys/bus/w1/devices/w1_bus_master1
    /sys/bus/w1/devices/28-000000423711
    /sys/bus/w1/drivers
    /sys/bus/w1/drivers/w1_master_driver
    /sys/bus/w1/drivers/w1_master_driver/bind
    /sys/bus/w1/drivers/w1_master_driver/w1_bus_master1
    /sys/bus/w1/drivers/w1_master_driver/uevent
    /sys/bus/w1/drivers/w1_master_driver/unbind
    /sys/bus/w1/drivers/w1_slave_driver
    /sys/bus/w1/drivers/w1_slave_driver/bind
    /sys/bus/w1/drivers/w1_slave_driver/28-000000423711
    /sys/bus/w1/drivers/w1_slave_driver/uevent
    /sys/bus/w1/drivers/w1_slave_driver/unbind
    /sys/bus/w1/uevent
    /sys/bus/w1/drivers_probe
    /sys/bus/w1/drivers_autoprobe

    # ### check w1
    # grep '' /sys/bus/w1/devices/w1_bus_master1/w1_master_slave_count /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves
    /sys/bus/w1/devices/w1_bus_master1/w1_master_slave_count:1
    /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves:28-000000423711

    # ### thermal driver automatically loaded
    # lsmod | grep w1
    w1_therm               16384  0
    w1_gpio                16384  0
    wire                   32768  2 w1_gpio,w1_therm

    # ### read temperature
    # cat /sys/bus/w1/devices/*/w1_slave
    6b 01 4b 46 7f ff 05 10 49 : crc=49 YES
    6b 01 4b 46 7f ff 05 10 49 t=22687

Merry Xmas and buy me a Beer.
I left this community in Aug 2019 due to PINE64 refusal to produce/deliver ROCK64-1G version 3 after more than one year of changing statuses to "planning", "evaluating", "releasing", "availability", "estimated availability" and finally "no schedule" Angry. ROCK64 is dead platform without any advantage. Buy Raspberry PI 4 !
Away
  Reply
#3
@mcerveny

I think you can give us a little help here too Wink

We are trying to use a DHT22 sensor on a rockpro64...
  Reply
#4
@{-DesT-},

Look again at mcerveny signature.  I don't think you will be getting a reply any time soon.  Wink  The fact he thinks RPi 4 is in any way better than what Pine64 is offering is, well...  I don't even know what to say about that.

Anyway, ROCKPro64 is completely different SoC (RK3399) than ROCK64 (RK3328) so there is good possibility the process is completely different.  I would search in ROCKPro64 section of forums (and around the Internet) and if you can't find anything there, then just make a new thread over in ROCKPro64 subforum (to keep things better organized, help others find relevant info, etc.).
  Reply
#5
Hello, even knowing it is a quite old thread ....

This thread helped me to get 1wire DS18b20 work on Rock64 rk3328. BUT, only on kernel 4.4.x

Sadly I started with kernel 5.8.x. After one week of investigation how device trees may work I gave up, partly Smile 

I tried kernel 4.4.x and it worked. At least I know now that the HW set up is ok.


Does anybody has an idea what I could try to get 1 wire work on kernel 5.x.x?


And no, I don't want to buy an Raspberry. I like the Rock64 Big Grin Big Grin Big Grin .
  Reply
#6
May it helps someone, finally I got 1wire work on kernel 5.x.x

Main hint was on github.com from Tonymac32 --- Many thanks!!!

This DT overly worked for me [<&gpio3 4 0> means GPIO3_A4; id100; Pin15] :

Overlay file: rockchip-w1-gpio.dts
Code:
/dts-v1/;
/plugin/;

/ {
    compatible = "pine64,rock64", "rockchip,rk3328";
    fragment@0 {
        target-path = "/";
        __overlay__ {
            w1: onewire@0 {
                compatible = "w1-gpio";
                pinctrl-names = "default";
                gpios = <&gpio3 4 0>;
                status = "okay";
            };
        };
    };
};


Compiling to binary:
dtc -I dts -O dtb rockchip-w1-gpio.dts -o rockchip-w1-gpio.dtbo



Overwriting of existing file:
boot/dtb-5.x.x-rockchip64/rockchip/overlay/rockchip-w1-gpio.dtbo

Than 1Wire can be activated in:
sudo armbian-config
(Activation before changing the overly file crashed my Rock)
  Reply
#7
(09-22-2021, 08:42 AM)Rocky64 Wrote: May it helps someone, finally I got 1wire work on kernel 5.x.x

[...]

This DT overly worked for me

[...]

Great news! And thanks (+rep) for sharing the solution!

(09-22-2021, 08:42 AM)Rocky64 Wrote: Main hint was on github.com from Tonymac32 --- Many thanks!!!

I don't know if your solution is general enough or not, if it is perhaps consider contributing it back to Armbian (in the form of a PR), in order to help even more people?
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Information How to Setup Serial Console Cable Over the Rock64 SBC MarkHaysHarris777 9 20,613 09-28-2021, 10:52 AM
Last Post: lewiscamron72
  Rock64 4K60P HDR Media Board Computer 64 bit MarkHaysHarris777 8 9,278 07-14-2021, 11:52 PM
Last Post: jontumontu
  Any way to tell the rock64's hardware revision? kittyland 1 506 07-01-2021, 09:42 PM
Last Post: evilbunny
  Configuring Python GPIO Pin Control Rock64 www139 3 3,968 06-22-2021, 06:57 AM
Last Post: Mrfixit2001
  POE support for the Rock64 v3 h64poe 0 467 05-30-2021, 07:40 AM
Last Post: h64poe
  3D-Printable Button Pegs for the ROCK64 Aluminium Case CounterPillow 1 688 05-21-2021, 05:44 PM
Last Post: tllim
  How to enable ES9023-based DAC hat on Rock64? lowry 2 964 03-18-2021, 03:44 PM
Last Post: zborgerd
  Display options for the Rock64 joey49 1 1,437 11-23-2020, 09:52 AM
Last Post: joey49
  Are HW design files available for ROCK64? irenek 1 1,755 09-29-2020, 05:57 PM
Last Post: tllim
  No sound from Rock64 DAC codebreaker 2 1,827 09-29-2020, 02:14 PM
Last Post: codebreaker

Forum Jump:


Users browsing this thread: 1 Guest(s)