Skip to contentSkip to conversation

are 1-wire devices "discoverable"?

DISCUSSION Trevor Woerner 2 participants 2 messages Feb 13, 2021 – Mar 19, 2021

lore
Share & tools
lore
#0 lore raw

Hi,

I just watched the amazing device tree presentation recently done by Thomas Petazzoni (from Bootlin) for ST[1]. During the presentation, which is amazing, by the way ;-), Thomas describes the 1-wire protocol as not being discoverable.

I was recently playing with the DS18B20 temperature sensor, which uses the 1-wire bus.[2] In fact, I was playing with a bunch of different temperature sensors with a RaspberryPi, and then gave a talk at a local RaspberryPi Meetup group that I regularly attend.[3]

My only experience with the 1-wire bus is with this one device, so maybe the details of how the DS18B20 work are specific to the DS18B20 and not the way 1-wire devices work in general? But my (humble) conclusion is that the 1-wire bus is discoverable (or at least quasi-discoverable).

It's true that you do need a device tree overlay to tell the kernel that you want to use the 1-wire bus, and you have to tell the kernel which GPIO pin you want to use as the 1 wire, but after that, attaching DS18B20 devices to a running system works quite magically.[4]

Each DS18B20 has a unique 64-bit number burned into it, the first 8 bits specify the device type (i.e. the DS18B20), the next 48 bits are a unique serial number, and the last 8 bits are a CRC of the previous 56 bits. Due to the inclusion of the 8-bit device type, when I plug a DS18B20 into my board, the kernel automatically creates a sysfs entry for it with a "temperature" file that I can read to obtain the temperature in Celcius.

I don't know if that qualifies as "discoverable"? It's certainly a lot more discoverable than I2C or SPI, although maybe not quite as discoverable as, say, PCI. Specifying the 1 wire is not discoverable, but plugging 1-wire devices into my board is maybe something that could be described as discoverable?

Best regards,
Trevor

[1] https://www.youtube.com/watch?v=a9CZ1Uk3OYQ
[2] https://twoerner.blogspot.com/2020/12/temperature-readings-with-ds18b20-and.html
[3] https://twoerner.blogspot.com/2021/01/sensing-temperature-with-raspberrypi.html
[4] https://twoerner.blogspot.com/2020/12/multiple-ds18b20-temperature-probes.html

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#1 lore raw
Quoted 10 lines · Trevor Woerner

Hi,

It's true that you do need a device tree overlay to tell the kernel that you
want to use the 1-wire bus, and you have to tell the kernel which GPIO pin you
want to use as the 1 wire, but after that, attaching DS18B20 devices to a running system works quite magically.[4]

Quoted 10 lines

Each DS18B20 has a unique 64-bit number burned into it, the first 8 bits specify the device type (i.e. the DS18B20), the next 48 bits are a unique serial number, and the last 8 bits are a CRC of the previous 56 bits. Due to
the inclusion of the 8-bit device type, when I plug a DS18B20 into my board,
the kernel automatically creates a sysfs entry for it with a "temperature" file that I can read to obtain the temperature in Celcius.

so, this device looks discoverable on a bus, once you know the bus is there.
thats the 1st distinction to make.
there are degrees/features.
Id also ask:
is that ID at a standard location ?
via some base transaction that all devices support ?

in my own house, I can find a switch in the dark.
I dont have Alexa listening to render help.

Quoted 17 lines

I don't know if that qualifies as "discoverable"? It's certainly a lot more discoverable than I2C or SPI, although maybe not quite as discoverable as, say, PCI. Specifying the 1 wire is not discoverable, but plugging 1-wire devices into my board is maybe something that could be described as discoverable?

Best regards,
Trevor

[1] https://www.youtube.com/watch?v=a9CZ1Uk3OYQ
[2]
https://twoerner.blogspot.com/2020/12/temperature-readings-with-ds18b20-and.html
[3]
https://twoerner.blogspot.com/2021/01/sensing-temperature-with-raspberrypi.html
[4]
https://twoerner.blogspot.com/2020/12/multiple-ds18b20-temperature-probes.html

Quoted 5 lines

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies