Qball's Weblog

BeagleBone Black - Getting w1 bus to work

Tags BeagleBoneBlack 

Today I received my BeagleBone Black. I must say, it is good value for money: € 44, seems to be a lot better value for money then a raspberry pi. It is significantly faster, A 1GHz cortex A8 with neon and vfp unit versus a low end armv6. It has 2Gb emmc (onboard storage) for linux, an µSD slot, 512mb ram, ethernet not hooked up to the usb bus, loads of GPIO pins, battery support, etc. etc.

So hardware wise, it is a lot better. The integrated software (Web based developer UI) seems nice for starters, so I directly disabled it. My first experiment is always to get a simple w1 temperature sensor to work.

Getting DS1820 to work

Normally I would load ‘w1-gpio’ telling it what GPIO pin to use. So after some googling I found the way:

Create a device tree:

/ {
       compatible = "ti,beaglebone-black";
       part-number = "BB-BONE-W1";
       version = "00A0";
/* state the resources this cape uses or prepare to get winged! */ exclusive-use = “P9.11”, “gpio0_30”;
       fragment@0 {
               target = <&am33xx_pinmux>;
               __overlay__ {
                        w1cape_pins: pinmux_w1cape_pins {
                                pinctrl-single,pins = <
                                        0x70 0x37       /* gmpc_wait0.gpio0_30, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE7 - w1-gpio */
       fragment@1 {
               target = <&ocp>;
               __overlay__ {
                       onewire@0 {
                               compatible      = "w1-gpio";
                               pinctrl-names   = "default";
                               pinctrl-0       = <&w1cape_pins>;
                               status          = "okay";
                               gpios = <&gpio1 30 0>;

Then compile this into a firmware

dtc -O dtb -o /lib/firmware/w1cape-0A00.dtbo -b o -@ w1cape.dts

and load it:

echo w1cape >  /sys/devices/bone_capemgr.8/slots

This nicely loads a ‘cape’ that tells w1-gpio module to use pin 11 of header 9. Now, if you didn’t have a broken wire, it works out of the box. (yeah spend a hour failing). I kind of like this, it seems a nice way, it checks if pins are in use and all. Now to get this to load on bootup.

comments powered by Disqus