12-24-2018, 07:09 AM
(This post was last modified: 12-24-2018, 03:21 PM by mcerveny.
Edit Reason: need faster cpu
)
(12-23-2018, 12:32 PM)mypineme Wrote: Has anyone got DS18b20 to work on rock64?
Yes. Step by step:
- 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.
- 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 - 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 - Symbols are NOT present in latest stable 0.7.9 based on kernel 4.4.132-1075
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 - 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" . ROCK64 is dead platform without any advantage. Buy Raspberry PI 4 !