My attempt at gathering information on how to detect exactly which Raspberry Pi model we are running on for https://github.com/jperkin/node-rpio. The goal is to come up with an optimal way of detecting the host across a wide range of hardware and OS.
| Name (Rev) | cpuinfo | 
/proc/device-tree/model | 
device-tree/soc/ranges | 
OS | 
|---|---|---|---|---|
| B (1.0) | 0002 | 
Raspberry Pi Model B | 
7e000000 20000000 01000000 | 
7 | 
| B (1.0) | 0002 | 
Raspberry Pi Model B Rev 1 | 
7e000000 20000000 02000000 | 
10 | 
| B (1.0) | 0003 | 
Raspberry Pi Model B | 
7e000000 20000000 01000000 | 
7 | 
| B (1.0) | 0003 | 
Raspberry Pi Model B Rev 1 | 
7e000000 20000000 02000000 | 
10 | 
| Zero W (1.1) | 9000c1 | 
Raspberry Pi Zero W Rev 1.1 | 
7e000000 20000000 02000000 | 
9 | 
| 2 B (1.1) | a01041 | 
Raspberry Pi 2 Model B Rev 1.1 | 
7e000000 3f000000 01000000 | 
9 | 
| 2 B (1.1) | a01041 | 
Raspberry Pi 2 Model B Rev 1.1 | 
7e000000 3f000000 01000000 | 
10 | 
| 2 B (1.2) | a22042 | 
Raspberry Pi 2 Model B Rev 1.2 | 
7e000000 3f000000 01000000 | 
8 | 
| 3 B (1.2) | a02082 | 
Raspberry Pi 3 Model B Rev 1.2 | 
7e000000 3f000000 01000000 | 
10 | 
| 3 B (1.3) | a020d3 | 
Raspberry Pi 3 Model B Plus Rev 1.3 | 
7e000000 3f000000 01000000 | 
9 | 
| 4 B 2GB (1.1) | b03111 | 
Raspberry Pi 4 Model B Rev 1.1 | 
7e000000 00000000 fe000000 | 
10 | 
| 4 B 4GB (1.1) | c03111 | 
Raspberry Pi 4 Model B Rev 1.1 | 
7e000000 00000000 fe000000 | 
10 | 
- Is there any way to detect rev 1.0 vs rev 2.0 with the original Model B when running 7?  Only newer releases identify the revision in 
/proc/device-tree/model. Just assume/proc/cpuinfo?. 
The following script can be used to generate the data (assuming Raspbian or similar).
#!/bin/bash
. /etc/os-release
printf "cpuinfo:\t%s\n" "$(awk '/^Revision/ { print $NF }' /proc/cpuinfo)"
printf "dtmodel:\t%s\n" "$(</proc/device-tree/model)"
set -- $(xxd -l 16 -g 4 < /proc/device-tree/soc/ranges)
printf "socranges:\t%s %s %s\n" $2 $3 $4
printf "os:\t\t%s\n" "$VERSION_ID"