Forum

Full Version: Temperature Sensor Ds18b20 does not work on other pins, only on 4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Once upon a time there was a problem with 1-wire devices and raspberry, 1-wire devices worked only with pin 4, because in kernel driver this pin 4 has been hardcoded. But in december 2013 this problem was solved https://github.com/raspberrypi/linux/pull/457
and in Raspbian-2014-01-07 1-wire device works with all pins, if we add:
Code:
bcm2708.w1_gpio_pin=22
in
/boot/cmdline.txt for work with pin 22.

In Xbian RC1(3.12.7+) kernel fresher than in my raspbian (3.10.25+), but in xbian 1-wire work only with pin 4.
How I can use ds18b20 with pin 22 ?
I never had issue with 1-wire sensors on any of the other pins.
In cmdline.txt I put the string "bcm2708.w1_gpio_pin=22"
Terminal
xbian@xbian ~ $ uname -a
Linux xbian 3.12.7+ #5 Sun Jan 19 19:08:40 CET 2014 armv6l GNU/Linux
xbian@xbian ~ $ cat /boot/cmdline.txt
telnet zswap.enabled=1 zswap.compressor=lz4 sdhci-bcm2708.sync_after_dma=0 dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootflags=subvol=root/@,thread_pool=2,autodefrag,compress=lzo,commit=120 rootfstype=btrfs rootwait smsc95xx.turbo_mode=N elevator=cfq logo.nologo quiet noswap loglevel=0 mod_scsi.scan=sync partswap startevent=mountall splash nohdparm --startup-event mountall bcm2708.w1_gpio_pin=22
xbian@xbian ~ $

But if I connect ds18b20 on pin 22, it not works. If I connect seonsor on pin 4, it immediately works.
I think the xbian kernel does not contain a patch for 1-wire devices.
I will test it myself, because i think i never had issues.

What kernel version are you running?
Code:
root@pi:~# dpkg --list | grep xbian-package-kernel
ii  xbian-package-kernel              1.3-6.20                      armhf        Latest XBian kernel for the Raspberry Pi (3.12.20+)
I updated the kernel
Terminal
xbian@xbian ~ $ uname -a
Linux xbian 3.13.7+ #16 Sun May 25 19:23:24 CEST 2014 armv6l GNU/Linux

But the 1-wire sensor is still working only on pin 4.

Modules loaded
Terminal
xbian@xbian ~ $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

snd-bcm2835

# for temperature sensor ds18b20
w1-gpio
w1-therm

# for lirc
lirc_dev
lirc_rpi gpio_in_pin=11 gpio_out_pin=9
Terminal
xbian@xbian ~ $ lsmod
Module Size Used by
uinput 5156 1
frandom 3284 1
lirc_rpi 4892 3
lirc_dev 9020 1 lirc_rpi
rc_core 12616 1 lirc_dev
w1_therm 1872 0
snd_bcm2835 12804 0
snd_pcm 50000 1 snd_bcm2835
snd_page_alloc 2696 1 snd_pcm
snd_timer 13564 1 snd_pcm
snd 32588 3 snd_bcm2835,snd_timer,snd_pcm
soundcore 472 1 snd
vchiq 183240 3 snd_bcm2835
w1_gpio 1480 0
wire 17284 2 w1_gpio,w1_therm

In /boot/cmdline.txt specified pin 22
Terminal
xbian@xbian ~ $ cat /boot/cmdline.txt
telnet zswap.enabled=1 zswap.compressor=lz4 sdhci-bcm2708.sync_after_dma=0 dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootflags=subvol=root/@,thread_pool=2,autodefrag,compress=lzo,commit=120 rootfstype=btrfs rootwait smsc95xx.turbo_mode=N elevator=cfq logo.nologo quiet noswap loglevel=0 mod_scsi.scan=sync partswap startevent=mountall splash nohdparm --startup-event mountall bcm2708.w1_gpio_pin=22

On raspbian all works with this settings.
What is kernel package version by xbian?
Terminal
xbian@xbian ~ $ dpkg --list | grep xbian-package-kernel
ii xbian-package-kernel 1.3.7-3 armhf Latest XBian kernel for the Raspberry Pi (3.13.7+)

Does you device work on pin 22 ?
Can you try:
Code:
apt-get install xbian-package-kernel=1.3-6.20

The latest kernel has some GPIO issues.
I downgraded kernel to version 3.12.20+
Terminal
xbian@xbian ~ $ dpkg --list | grep xbian-package-kernel
ii xbian-package-kernel 1.3-6.20 armhf Latest XBian kernel for the Raspberry Pi (3.12.20+)

But I can't see 1-wire device on pin 22
Terminal
xbian@xbian ~ $ ls /sys/bus/w1/devices/
w1_bus_master1
Can you download the kernel headers and check if the hardcoded pin is there or not. Then we'll know if it is actually a kernel problem.
I downloaded linux-header 3.12.20 from git
Terminal
xbian@xbian /usr/src $ sudo git clone --depth 1 https://github.com/raspberrypi/linux.git
And I see that w1 pin hardcoded
Terminal
xbian@xbian /usr/src $ head -n 100 linux-header-3.12.20+/arch/arm/mach-bcm2708/bcm2708.c
......
// use GPIO 4 for the one-wire GPIO pin, if enabled
#define W1_GPIO 4
......

Next, linux-header-3.12.20+/drivers/w1/masters/w1-gpio.c don't patched to make change pin in /boot/cmdline.txt.
Patch here https://github.com/raspberrypi/linux/pull/457/files
There is your issue. Please notify the Raspberry Pi foundation about this issue and put a reference on the xbian github so mk01 can fix it.
I found that in the new kernel rpi-3.14 this patch included, in 3.13 not included.
https://github.com/raspberrypi/linux/blob/rpi-3.14.y/drivers/w1/masters/w1-gpio.c
With this kernel w1 pin configuration works:
Reference URL's