Search by Tags

One Wire (Linux)

 

Article updated at 28 Feb 2019
Compare with Revision

The One Wire (or 1-Wire, OWR or 1W, see Wikipedia driver for the Colibri T20 is not compiled into the kernel by default.

In order to activate it the driver platform data has to be changed and the kernel configuration amended. Please refer to this article to get the instructions how to recompile and update the kernel.

The following configuration options are needed. Depending on the required slaves other/additional slave drivers might be needed.

CONFIG_W1=y
# 1-wire Bus Masters
CONFIG_W1_MASTER_TEGRA=y
# 1-wire Slaves
CONFIG_W1_SLAVE_SMEM=y

With the driver compiled in you can use the sysfs filesystem to communicate over one wire:

Output during driver load:

 
[   21.292445] Driver for 1-wire Dallas network protocol.
[   21.301498] Driver for Tegra SoC 1-wire controller

Enable/disable one wire master debug output

root@colibri_t20:~# echo 3 > /sys/module/tegra_w1/parameters/debug

[ 4731.621221] (w1_wait: line 167) timeout
[ 4731.625056] (tegra_w1_reset_bus: line 331) no slaves present
[ 4746.620999] (w1_wait: line 167) timeout
[ 4746.624833] (tegra_w1_reset_bus: line 331) no slaves present
[ 4756.621979] (tegra_w1_reset_bus: line 331) no slaves present
[ 4766.621973] (tegra_w1_reset_bus: line 333) slaves present
[ 4776.651977] (tegra_w1_reset_bus: line 333) slaves present

root@colibri_t20:~# echo 0 > /sys/module/tegra_w1/parameters/debug

Show the number of slaves found

root@colibri_t20:/sys# cat /sys/devices/w1\ bus\ master/w1_master_slave_count
1

Get the serial of the attached DS1990 Serial Number iButton

root@colibri_t20:/sys# cat /sys/bus/w1/drivers/w1_slave_driver/01-0000134ad3ea/name
01-0000134ad3ea

Get the serial in a binary format, family code / serial, little endian / crc

root@colibri_t20/# hexdump /sys/bus/w1/drivers/w1_slave_driver/01-0000134ad3ea/id -C
00000000  01 ea d3 4a 13 00 00 9e                           |...J....|
00000008