Problems getting DS18B20 running on BeagleBone

I try to read a DS18B20 with a BeagleBone (BB green wireless) and encountered some problems with the device tree after switching to the latest available Debian version for BB.

I will describe the steps to make it with the default version first, the main problem description see the second posting

Wiring

BeagleBone       --  DS18B20
----------------------------
P9.01 DGND       --  GND
P9.03 VDD 3.3 V  --  Vcc
P9.12 GPIO1_28   --  Data

and a 4K7 resistor between Vcc and Data

Device Tree

I found this tutorials and device tree examples:

so I did

cd /lib/firmware
nano DS1820-00A0.dts

DS1820-00A0.dts

/dts-v1/;
/plugin/;

/ {
    compatible = "ti,beaglebone", "ti,beaglebone-black";
    part-number = "DS1820";
    version = "00A0";

    exclusive-use = "P9.12";

    fragment@0 {
        target = <&am33xx_pinmux>;
        __overlay__ {
             ds1820_pins: pinmux_ds1820_pins {
                 pinctrl-single,pins =  <0x78 0x37>;
             };
        };
    };

    fragment@1 {
        target = <&ocp>;
        __overlay__ {
            onewire@0 {
                status          = "okay";
                compatible      = "w1-gpio";
                pinctrl-names   = "default";
                pinctrl-0       = <&ds1820_pins>;
                gpios           = <&gpio1 28 0>;
            };
        };
    };
};

First trial with Linux beaglebone 4.4.x

Linux beaglebone 4.4.9-ti-r25

In the Tutorial …

… you should build the tree with

sudo dtc -O dtb -o /lib/firmware/DS1820-00A0.dtbo -b 0 -@ DS1820-00A0.dts

and enable this part of the device tree (at every boot) with this command

sudo echo DS1820 > /sys/devices/bone_capemgr.*/slots

Problems and Solution

but

echo DS1820 > /sys/devices/bone_capemgr.*/slots

leds to

-bash: /sys/devices/bone_capemgr.*/slots: No such file or directory

seems that bone_capemgr is no loger in /sys/devices/ but in /sys/devices/platform/

So I tried /sys/devices/platform/bone_capemgr/slots

echo DS1820 > /sys/devices/platform/bone_capemgr/slots

Becauso of permission problems I tried it with sudo echo ... with no success, but after switching to root it seems to work:

debian@beaglebone:/sys/devices/platform/bone_capemgr$ sudo su
root@beaglebone:/sys/devices/platform/bone_capemgr# echo DS1820 > /sys/devices/platform/bone_capemgr/slots
root@beaglebone:/sys/devices/platform/bone_capemgr#

You can see the successful change at

root@beaglebone:/sys/devices/platform/bone_capemgr# cat slots
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,DS1820

Now you should find the devices at
/sys/bus/w1/devices/

Minor (?) problem: Hmm, something went wrong, no real sensor ID in the form 28-0000065e9caf there! I noticed in the tutorials that they wrote in the text GPIO1_28 but used in the code gpios = <&gpio2 28 0>;So I changed in the dts file gpios = <&gpio1 28 0>; After a reboot and the procedure above I got the sensor showing up: Yeah!!

debian@beaglebone:/sys/bus/w1/devices$ ls
28-0000065e9caf  w1_bus_master1

And I can read the temperature with

debian@beaglebone:/sys/bus/w1/devices/28-0000065e9caf$ cat w1_slave
80 01 4b 46 7f ff 10 10 c6 : crc=c6 YES
80 01 4b 46 7f ff 10 10 c6 t=24187

What means that we have 24.2 °C!

2 Likes

Problems with latest Linux beaglebone 4.14.x

I updated my BeagleBone to the latest stable version
Linux beaglebone 4.14.71-ti-r80

And tried to do the same as above but got this warning messages:

debian@beaglebone:~$ sudo dtc -O dtb -o /lib/firmware/DS1820-00A0.dtbo -b 0 -@ DS1820-00A0.dts
/lib/firmware/DS1820-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
/lib/firmware/DS1820-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@1 has a unit name, but no reg property
/lib/firmware/DS1820-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@1/__overlay__/onewire@0 has a unit name, but no reg property

so enabling the device did not work also:

debian@beaglebone:~$ sudo su
root@beaglebone:/home/debian# echo DS1820 > /sys/devices/platform/bone_capemgr/slots

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.085514] Internal error: Oops: 17 [#1] PREEMPT SMP ARM

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.202084] Process bash (pid: 1001, stack limit = 0xdc3f8218)

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.207942] Stack: (0xdc3f9d58 to 0xdc3fa000)

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.212320] 9d40:                                                       00000000 014000c0

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.220537] 9d60: 00000000 c0dacbd0 dc3f9d94 dc3f9d78 c016d908 dc507684 c15d9930 dc5076a0

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.228755] 9d80: c1504dc8 dc3f9d90 dc507698 c0db9a50 dc3f9dac 00000000 c0db9a50 da929000

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.236973] 9da0: c11c2c9c dc3f9db0 00000010 c0b92718 dc47c010 dc3f9e3c 0000006d b674d272

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.245191] 9dc0: c1504dc8 dc47c010 00000014 db513a18 00000000 c1504dc8 db513a18 c1169c34

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.253409] 9de0: dc3f9dfc dc3f9df0 c0b93c24 c0b930b0 dc3f9e74 dc3f9e00 c0962190 c0b93c10

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.261626] 9e00: 00000000 dc3f9e10 c03869c4 c0962e84 00000000 c1504dc8 db513a20 00000001

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.269844] 9e20: dc23da10 00000001 db513a10 da929000 dc47c25b dc23da10 dc23da10 e08b10a4

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.278061] 9e40: c0930cb4 b674d272 dc3f9e70 db1a4b80 c1504dc8 db513a10 db1a45c0 dc23da10

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.286279] 9e60: 00000000 dc47c010 dc3f9eb4 dc3f9e78 c0963304 c0961d1c 00000000 c0197b48

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.294495] 9e80: c1504dc8 b674d272 0000000a c09631b4 dc507f80 00000000 00000000 dc3f9f68

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.302713] 9ea0: db1a45c0 dc507f90 dc3f9ecc dc3f9eb8 c092f108 c09631c0 c092f0e0 dc507f80

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.310930] 9ec0: dc3f9ee4 dc3f9ed0 c03855c4 c092f0ec 00000007 dc507f80 dc3f9f1c dc3f9ee8

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.319148] 9ee0: c0384c10 c0385580 00000000 00000000 db548d88 c0384b18 dc59b780 01d57a08

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.327365] 9f00: dc3f9f68 00000000 01d57a08 00000007 dc3f9f34 dc3f9f20 c02f9258 c0384b24

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.335582] 9f20: 00000007 dc59b780 dc3f9f64 dc3f9f38 c02f943c c02f923c dc59b780 c031bba0

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.343800] 9f40: c1504dc8 dc59b780 00000000 00000000 dc59b780 01d57a08 dc3f9fa4 dc3f9f68

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.352016] 9f60: c02f96a4 c02f9394 00000000 00000000 c031ba60 b674d272 00000000 00000007

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.360234] 9f80: 01d57a08 b6f55d60 00000004 c01090e4 dc3f8000 00000000 00000000 dc3f9fa8

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.368451] 9fa0: c0108f00 c02f9654 00000007 01d57a08 00000001 01d57a08 00000007 00000000

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.376668] 9fc0: 00000007 01d57a08 b6f55d60 00000004 01d57a08 00000007 00000000 00000000

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.384886] 9fe0: 00000000 bea4c2cc b6eb81bb b6ef4af6 000b0030 00000001 00000000 00000000

Message from syslogd@beaglebone at Oct  7 16:45:20 ...
 kernel:[  309.472383] Code: e584902c e5843034 e584403c e584a028 (e590500c)

What you discover is the ongoing transition from kernel device tree overlays to uboot overlays:

Where did the slots file go?

Kernel Overlays are going bye-bye, too many bugs, too many race conditions, no kernel maintainers interested. […]

(from Beagleboard:BeagleBoneBlack Debian - eLinux.org )

First you saw that manipulating the sysfs via can be done by userspace tools, but even if they run as root, it won’t work; you have to be root. This was introduced to prevent users echoing their system dead via sysfs.

Stage 1: Disable Kernel Overlays (bone_capemgr.uboot_capemgr_enabled=1 is passed thru /proc/cmdline)
Stage 2: Disable the slots file (/sys/devices/platform/bone_capemgr/slots) (v4.4.x -> 4.14.x)
Stage 3: Disable bone_capemgr dir (/sys/devices/platform/bone_capemgr/) (v4.15.x+)

Stage 1 is complete, all current images use U-Boot Overlays by default. Stage 2 is currently in progress, as it is not recommended to “load” anything into the slots file while U-Boot Overlays are in control. Stage 3, will take longer, as many applications only need to know the “bone_capemgr” directory is available.

If you don’t like the direction we are heading, simply disable, “enable_uboot_overlays=1” in /boot/uEnv.txt…

#I will be on my own with Kernel Overlays:
#enable_uboot_overlays=1

(link see above)

Right now, four kernels are maintained for BB: 4.4., 4.9., 4.14 and 4.19.
With 4.14 and later, you have to rely on uboot device tree overlays. Thats why you don’t get it enabled, and the reason behind should let you stick on 4.4 for now to make progress! ;)

You can of course go with uboot overlays and 4.14 and 4.19 (and compile everything into uboot and manage it via /boot/uEnv.txt).

2 Likes

On my BeagleBone Wireless Green Debian 8.5 was by default running. What newer version can I use from this list? BeagleBoard.org - latest-images while staying on 4.4?

Can not find a list with Debian version and correspoinding Linux Kernels.

Edit: I installed Debain 8.10 with the Linux kernel 4.4.113-ti-r145 and got the error messages above also

DS1820-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property
DS1820-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@1 has a unit name, but no reg property