How to set up multiple w1-gpio for a capeless BeagleBoneBlack?

1,694 views
Skip to first unread message

Russell Senior

unread,
May 17, 2013, 5:04:45 AM5/17/13
to beagl...@googlegroups.com

I've spent the last few days hacking my way through a thick jungle to
figure out how to create a device tree or whatever I need to configure
one or more pins on a BeagleBoneBlack with Angstrom to talk one-wire
(with the w1-gpio driver, I presume). Can anyone give me some hints?
I'm still wrapping my head around device tree (why aren't the source
files included in the image? or are they?), pinctl, bone_capemgr,
etc.

There don't appear to be any examples of one-wire usage in the device
tree source files I find in the Angstrom build tree, e.g. here:

build/tmp-angstrom_v2012_12-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-mainline-3.8.13-r23a/git/arch/arm/boot/dts

Thanks in advance!


--
Russell Senior, President
rus...@personaltelco.net

Koen Kooi

unread,
May 17, 2013, 5:33:05 AM5/17/13
to beagl...@googlegroups.com

Op 17 mei 2013, om 11:04 heeft Russell Senior <rus...@personaltelco.net> het volgende geschreven:

>
> I've spent the last few days hacking my way through a thick jungle to
> figure out how to create a device tree or whatever I need to configure
> one or more pins on a BeagleBoneBlack with Angstrom to talk one-wire
> (with the w1-gpio driver, I presume). Can anyone give me some hints?
> I'm still wrapping my head around device tree (why aren't the source
> files included in the image? or are they?), pinctl, bone_capemgr,
> etc.
>
> There don't appear to be any examples of one-wire usage in the device
> tree source files I find in the Angstrom build tree, e.g. here:
>
> build/tmp-angstrom_v2012_12-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-mainline-3.8.13-r23a/git/arch/arm/boot/dts

firmware/capes/cape-bone-weather-00A0.dts

Russell Senior

unread,
May 17, 2013, 6:51:50 AM5/17/13
to beagl...@googlegroups.com

Beauty.  Thank you!


Russell Senior

unread,
May 17, 2013, 6:18:26 PM5/17/13
to beagl...@googlegroups.com
>>>>> "Koen" == Koen Kooi <ko...@beagleboard.org> writes:

Koen> Op 17 mei 2013, om 11:04 heeft Russell Senior
Koen> <rus...@personaltelco.net> het volgende geschreven:

>> I've spent the last few days hacking my way through a thick jungle
>> to figure out how to create a device tree or whatever I need to
>> configure one or more pins on a BeagleBoneBlack with Angstrom to
>> talk one-wire (with the w1-gpio driver, I presume). Can anyone
>> give me some hints? I'm still wrapping my head around device tree
>> (why aren't the source files included in the image? or are they?),
>> pinctl, bone_capemgr, etc.
>>
>> There don't appear to be any examples of one-wire usage in the
>> device tree source files I find in the Angstrom build tree,
>> e.g. here:
>>
>> build/tmp-angstrom_v2012_12-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-mainline-3.8.13-r23a/git/arch/arm/boot/dts

Koen> firmware/capes/cape-bone-weather-00A0.dts

Okay, there's a few things I'm having trouble parsing, though they
became a lot clearer when I read the contents of:

build/tmp-angstrom_v2012_12-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-mainline-3.8.13-r23a/git/Documentation/devicetree

(with the overlay discussion, in particular):

/*
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;
/plugin/;

/ {
compatible = "ti,beaglebone";
part-number = "BB-BONE-WTHR-01";
version = "00A0";

fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
weather_cape_w1_pins: pinmux_weather_cape_w1_pins {

hmm, so "weather_cape_w1_pins" is a label, and
"pinmux_weather_cape_w1_pins" is a node name. Why both? I see the
reference below (pinctrl-0). Ah, you can only reference a label, not a
name, I guess, according to Appendix A Device Tree Source Format
(version 1), in the Power_ePAPR_APPROVED_v1.1.pdf.


pinctrl-single,pins = <
0x0c 0x37 /* gpmc_ad3.gpio1_3, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE7 - w1-gpio */

I get this part, I can decode the 0x0c and 0x37 using Table 9-10 in spruh73h.pdf.

>;
};
};
};

[...]

fragment@2 {
target = <&ocp>;
__overlay__ {
onewire@0 {
compatible = "w1-gpio";
pinctrl-names = "default";
pinctrl-0 = <&weather_cape_w1_pins>;
status = "okay";

gpios = <&gpio2 3 0>;

What does this magic number represent? What is &gpio2 referring to?
and the 3 and 0? I now realize that gpio2 is a label to something,
but where is it defined? How do I figure out what I need for my
random pins?

};
};
};
};

Thanks!

Russell Senior

unread,
May 18, 2013, 1:42:16 PM5/18/13
to beagl...@googlegroups.com
>>>>> "Simon" == Simon van der Sluis <svand...@gmail.com> writes:

Simon> Hi Russell From what I've seen at
Simon> http://dominion.thruhere.net/koen/cms/using-1-wire-on-a-beaglebone
Simon> I suspect that gpio2 points to the P8 header and 3 to pin 3. I
Simon> think the last 0 is a flag for parasitic power, which is not
Simon> supported.

gpio2 is that the BBB_SRM seems to call gpio1 (0-3, inseat of 1-4).
Table 10 of the BBB_SRM says mode 7 of P8 pin 6 (mux mode 7) is
gpio1_3, which seems to translate the the <&gpio2 3 0>. Section 8 of
that document tells you which pins are in use for onboard devices.

Simon> Have you managed to get the module loaded? I have managed to
Simon> install a 3.8.3 kernel onto my BBB and have some w1 modules,
Simon> none of which are w1-gpio. I built the kernel using git clone
Simon> git://github.com/Angstrom-distribution/setup-scripts.git

Simon> But I'm lost as to what to do to get a w1-gpio kernel module
Simon> out of it. Can you point me at any documentation that that
Simon> explains the device tree, or something that helped you get
Simon> further along the path to getting w1-gpio working

The issue is that the beaglebone black is using the pin defined in the
the weather cape device tree overlay thing for eMMC. So, it's
necessary to pick a different pin and modify the device tree
accordingly.

It looks like pin 11 will work, so the gpio switches to <&gpio2 13 0>
and the 0x0c changes to 0x34.

Russell Senior

unread,
May 19, 2013, 1:58:50 AM5/19/13
to beagl...@googlegroups.com
>>>>> "Russell" == Russell Senior <rus...@personaltelco.net> writes:

Here's what I did to get a one-wire bus working on BeagleBone Black.
I created (modified from the weather cape's) a DTS file:

/*
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;
/plugin/;

/ {
compatible = "ti,beaglebone";
part-number = "BB-BONE-W1";
version = "00A0";

fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
nocape_w1_pins: pinmux_nocape_w1_pins {
pinctrl-single,pins = <
0x34 0x37 /* gpmc_ad13.gpio1_13, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE7 - w1-gpio */
>;
};
};
};

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

gpios = <&gpio2 13 0>;
};
};
};
};

then compiled it into a binary blob:

dtc -@ -O dtb -I dts -o /lib/firmware/nocape-w1-00A0.dtbo nocape-w1-00A0.dts

then loaded the overlay:

echo nocape-w1 > /sys/devices/bone_capemgr.9/slots

then I could cd to

/sys/devices/w1_bus_master1

plug in a one-wire device (e.g. ds18b20) appropriately, and start
reading from the device:

while true ; do echo $(date) $(cat 28-000003612e9f/w1_slave) ; done

where 28-000003612e9f is the id of my device.

Sat Jan 1 00:19:21 UTC 2000 4d 01 4b 46 7f ff 03 10 d8 : crc=d8 YES 4d 01 4b 46 7f ff 03 10 d8 t=20812
Sat Jan 1 00:19:21 UTC 2000 4d 01 4b 46 7f ff 03 10 d8 : crc=d8 YES 4d 01 4b 46 7f ff 03 10 d8 t=20812
[...]

I presume that by mutating the dts appropriately, I can create
multiple w1-gpio pins so I can read more than 10 devices, the maximum
slaves per pin according to

/sys/devices/w1_bus_master1/w1_master_max_slave_count.

Cheers!

Simon van der Sluis

unread,
May 19, 2013, 4:48:50 PM5/19/13
to beagl...@googlegroups.com
Thank you Russell.  I'll hopefully find some time later this week to try that out.  Still getting my head around the build system etc, it's more like a learning wall than a curve at moment.

Cheers

Simon

Simon van der Sluis

unread,
May 22, 2013, 3:54:31 AM5/22/13
to beagl...@googlegroups.com

Wow it works.
You've made this too easy.  Thank you again for your help.

sebastian

unread,
May 26, 2013, 5:38:49 AM5/26/13
to beagl...@googlegroups.com
Hello,

On Sunday, May 19, 2013 7:58:50 AM UTC+2, Russell Senior wrote:
>>>>> "Russell" == Russell Senior <rus...@personaltelco.net> writes:

Here's what I did to get a one-wire bus working on BeagleBone Black.
I created (modified from the weather cape's) a DTS file:

i must patch the dts for working with the BBB
12c12
<        compatible = "ti,beaglebone";
---
>        compatible = "ti,beaglebone","ti,beaglebone-black";
40a41
>

best regards
sebastian
Reply all
Reply to author
Forward
Message has been deleted
0 new messages