Enabling OneWire support on Raspberry Pi

258 views
Skip to first unread message

Zach Bussey

unread,
Apr 28, 2015, 1:10:38 PM4/28/15
to nerves-...@googlegroups.com

Frank, thanks for putting this project together.  I'm looking forward to making some great projects with Nerves!

Right now, I'm trying to setup a Raspberry Pi, Elixir configuration, with support for reading a OneWire temprature sensor.  After a lot of trial and error, I'm able to get part of the way there.

Following the example of commit 16462b527d7d376635eb5ff974b2c4819b0069a8  which added I2C support by default, I've added the following to the 3.18.defconfig files:

CONFIG_W1=y
CONFIG_W1_MASTER_DS2490
=y
CONFIG_W1_MASTER_DS2482
=y
CONFIG_W1_MASTER_DS1WM
=y
CONFIG_W1_MASTER_GPIO
=y
CONFIG_W1_SLAVE_THERM
=y


I've also added a line to the /board/raspberrypi/config.txt

dtoverlay=w1-gpio-pullup,gpiopin=4

Now, after building the image and booting, the w1 folder is present in /sys/bus.  However, there are no devices listed in /sys/bus/w1/devices.  If I add the same config line to a normal Raspbian image, in the /boot/config.txt file, I am able to see the devices, so I don't think it is an issue with the sensor, or the wiring setup to the Pi.

Are there any suggestions of where to look next?  I've been trying to find some more information on how to enable this, but it seems that documentation for buildroot configurations are pretty sparse, or I'm just looking in the wrong places.

Thanks

Frank Hunleth

unread,
Apr 28, 2015, 4:41:07 PM4/28/15
to nerves-...@googlegroups.com
Hi Zach,

On Tue, Apr 28, 2015 at 1:10 PM, Zach Bussey <zachar...@gmail.com> wrote:
>
> Frank, thanks for putting this project together. I'm looking forward to
> making some great projects with Nerves!
>
> Right now, I'm trying to setup a Raspberry Pi, Elixir configuration, with
> support for reading a OneWire temprature sensor. After a lot of trial and
> error, I'm able to get part of the way there.

Thanks for the persistence. I have not used OneWire, so it's not too
surprising that I broke support for it.

> Following the example of commit 16462b527d7d376635eb5ff974b2c4819b0069a8
> which added I2C support by default, I've added the following to the
> 3.18.defconfig files:
>
> CONFIG_W1=y
> CONFIG_W1_MASTER_DS2490=y
> CONFIG_W1_MASTER_DS2482=y
> CONFIG_W1_MASTER_DS1WM=y
> CONFIG_W1_MASTER_GPIO=y
> CONFIG_W1_SLAVE_THERM=y
>

This makes sense. You should just need the CONFIG_W1,
CONFIG_W1_MASTER_GPIO and CONFIG_W1_SLAVE_THERM lines, but that's not
the problem.

>
> I've also added a line to the /board/raspberrypi/config.txt
>
> dtoverlay=w1-gpio-pullup,gpiopin=4
>
> Now, after building the image and booting, the w1 folder is present in
> /sys/bus. However, there are no devices listed in /sys/bus/w1/devices. If
> I add the same config line to a normal Raspbian image, in the
> /boot/config.txt file, I am able to see the devices, so I don't think it is
> an issue with the sensor, or the wiring setup to the Pi.

Ok, it's great that you tried it on Raspbian. That's a huge hint. I
think that the problem is that the FAT partition with Nerves does not
contain an overlays directory. Could you manually create an overlays
directory and copy over w1-gpio-pullup-overlay.dtb to that directory?
I think that will make it work. You can get that file from a Raspbian
SDCard or from the buildroot/output/images/rpi-firmware directory.

If that works, that file can be added to the fwup.conf file to be
included automatically. Let me know, so that I know what to do to make
OneWire work out of the box with Nerves.

> Are there any suggestions of where to look next? I've been trying to find
> some more information on how to enable this, but it seems that documentation
> for buildroot configurations are pretty sparse, or I'm just looking in the
> wrong places.

Right, Buildroot is both awesome and daunting. The people on the
Buildroot IRC and mailing list are usually very friendly and helpful.
This may sound strange, but I find the Arch Wiki [1] handy when it
comes to Linux configuration with Buildroot.

Thanks,
Frank

[1] https://wiki.archlinux.org/index.php/Main_page

--
Frank Hunleth
Troodon Software LLC
Embedded Software Development
http://troodon-software.com/

Zach Bussey

unread,
Apr 28, 2015, 9:32:35 PM4/28/15
to nerves-...@googlegroups.com
Thanks for responding so quickly.

Looks like it is 20.312 degrees C.

Adding the overlay folder with the w1-gpio-pullup-overlay.dtb file worked right away.  Thank you so much for your help.  It would have taken me much longer to get that working.

Now I can get back to writing some Elixir code for this.

Thanks again,
Zach

PS.  I have a RPi 2 sitting here also.  If you need someone else to do some Nerves testing for that device, let me know.

Frank Hunleth

unread,
Apr 29, 2015, 9:35:16 AM4/29/15
to nerves-...@googlegroups.com
Great! When I get a chance, I'll add support in the fwup.conf file to
handle the overlays directory automatically. It looks like I need fix
fwup to handle directories, so I'll email you when I get a chance to
do that.

Regarding the RPi 2, yes please try it out when you get a chance. I'm
using my RPi2 for a different project and just took the opportunity to
merge my work into Nerves. I only made sure that it booted, Ethernet
worked, and the Erlang VM identified the 4 cores. I've had a good
experience with the Raspberry Pi's, but it's always good to have
independent confirmation.

Thanks!
Frank
> --
> You received this message because you are subscribed to the Google Groups
> "nerves-project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nerves-projec...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Frank Hunleth

unread,
Apr 29, 2015, 9:27:48 PM4/29/15
to nerves-...@googlegroups.com
Zach,

I updated fwup (the firmware update utility) to handle the overlays
directory and took a guess at your configuration. You can see my
attempt at:

https://github.com/nerves-project/nerves-sdk/tree/onewire

If I did it correctly, OneWire support will be compiled into the
Raspberry Pi Linux kernels and the device tree file will be copied to
the boot partition automatically. If you get a chance to try it out
and it works, I'll merge it into master.

Thanks again for reporting the issue,
Frank

Zach Bussey

unread,
May 5, 2015, 9:46:10 PM5/5/15
to nerves-...@googlegroups.com
Thanks for cutting a new branch.  I was able to try it out, and got it to work, but I still had to add that one line to the config.txt file.  Without that line, the /sys/bus/w1 directory was present, but there were no devices listed.

I guess everyone may not be using the same pin for OneWire devices, so I'm not sure that you would want that set in the default project configuration.

Thanks,
Zach

Frank Hunleth

unread,
May 5, 2015, 10:07:49 PM5/5/15
to nerves-...@googlegroups.com
Hi Zach,

On Tue, May 5, 2015 at 9:46 PM, Zach Bussey <zachar...@gmail.com> wrote:
> Thanks for cutting a new branch. I was able to try it out, and got it to
> work, but I still had to add that one line to the config.txt file. Without
> that line, the /sys/bus/w1 directory was present, but there were no devices
> listed.

Thanks for trying it out.

> I guess everyone may not be using the same pin for OneWire devices, so I'm
> not sure that you would want that set in the default project configuration.

Right, I just want to make it easier for the next person. Copying over
the overlay files is not obvious, and it's not a big deal to add to
Nerves. As you said, I won't be adding the config.txt line since that
could cause some problems for different setups, but I'm less worried
about people getting stuck on that. At least that part is documented
via a "OneWire on Raspberry Pi" search.

Thanks again,
Frank
Reply all
Reply to author
Forward
0 new messages