Skip to content

Instantly share code, notes, and snippets.

@jperkin
Last active January 8, 2024 13:39
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jperkin/c37a574379ef71e339361954be96be12 to your computer and use it in GitHub Desktop.
Save jperkin/c37a574379ef71e339361954be96be12 to your computer and use it in GitHub Desktop.
raspberry pi cpuinfo vs device-tree

Raspberry Pi cpuinfo vs device-tree

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.

Data

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
B+ (1.2) 0010 Raspberry Pi Model B Plus Rev 1.2 7e000000 20000000 02000000 10
CM (1.0) 0014 Raspberry Pi Compute Module Rev 1.0 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
CM 3 (1.0) a020a0 Raspberry Pi Compute Module 3 Rev 1.0 7e000000 3f000000 01000000 10
CM 3+ (1.0) a02100 Raspberry Pi Compute Module 3 Plus Rev 1.0 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
4 B 8GB (1.4) d03114 Raspberry Pi 4 Model B Rev 1.4 7e000000 00000000 fe000000 20

Open Questions

  • 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?.

How To Generate

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"
@caius
Copy link

caius commented Oct 18, 2019

From the two I happen to have booted currently:

cpuinfo:	9000c1
dtmodel:	Raspberry Pi Zero W Rev 1.1
socranges:	7e000000 20000000 02000000
os:		9
cpuinfo:	a01041
dtmodel:	Raspberry Pi 2 Model B Rev 1.1
socranges:	7e000000 3f000000 01000000
os:		9

@jperkin
Copy link
Author

jperkin commented Oct 18, 2019

Thanks!

@sperreault
Copy link

sperreault commented Oct 20, 2019

cpuinfo: a22042
dtmodel: Raspberry Pi 2 Model B Rev 1.2
socranges: 7e000000 3f000000 01000000
os: 8

@nshalman
Copy link

nshalman commented Oct 20, 2019

cpuinfo:	a020d3
check.sh: line 6: warning: command substitution: ignored null byte in input
dtmodel:	Raspberry Pi 3 Model B Plus Rev 1.3
socranges:	7e000000 3f000000 01000000
os:		9

line 6 being:

$ printf "dtmodel:\t%s\n" "$(</proc/device-tree/model)"
-bash: warning: command substitution: ignored null byte in input
dtmodel:	Raspberry Pi 3 Model B Plus Rev 1.3

I upgraded to buster (after realizing from this exercise that I could) which bumps the os version number as expected:

cpuinfo:	a020d3
check.sh: line 6: warning: command substitution: ignored null byte in input
dtmodel:	Raspberry Pi 3 Model B Plus Rev 1.3
socranges:	7e000000 3f000000 01000000
os:		10

@jperkin
Copy link
Author

jperkin commented Oct 20, 2019

Thanks both!

@EthyMoney
Copy link

EthyMoney commented Oct 22, 2019

Here's mine from my pi 4 2GB model:

cpuinfo:      b03111
dtmodel:      Raspberry Pi 4 Model B Rev 1.1
socranges:    7e000000 00000000 fe000000
os:           10

@xthedeus
Copy link

xthedeus commented Nov 21, 2019

Pi 4, 4GB model:

cpuinfo:	c03111
dtmodel:	Raspberry Pi 4 Model B Rev 1.1
socranges:	7e000000 00000000 fe000000
os:		10

@Papouchcom
Copy link

Papouchcom commented Oct 6, 2020

RPi CM 3+ (eMMC 8GB/16GB):

cpuinfo:	a02100
dtmodel:	Raspberry Pi Compute Module 3 Plus Rev 1.0
socranges:	7e000000 3f000000 01000000
os:		10

RPi CM 3 (eMMC 4GB):

cpuinfo:	a020a0
dtmodel:	Raspberry Pi Compute Module 3 Rev 1.0
socranges:	7e000000 3f000000 01000000
os:		10

RPi CM 1

cpuinfo:	0014
dtmodel:	Raspberry Pi Compute Module Rev 1.0
socranges:	7e000000 20000000 02000000
os:		10

@nshalman
Copy link

nshalman commented Oct 6, 2020

4B 8GB (currently running Ubuntu 20.04) reports:

cpuinfo:        d03114
dtmodel:        Raspberry Pi 4 Model B Rev 1.4
socranges:      7e000000 00000000 fe000000
os:             20.04

@hellresistor
Copy link

cpuinfo:
./tester.sh: line 6: warning: command substitution: ignored null byte in input
dtmodel:        Raspberry Pi 4 Model B Rev 1.2
socranges:      7e000000 00000000 fe000000
os:             11

My OS debian 11 ( https://raspi.debian.net/tested-images/ )

uname -a
Linux FIFUrpi 5.10.0-9-arm64 #1 SMP Debian 5.10.70-1 (2021-09-30) aarch64 GNU/Linux

lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

@leon-anavi
Copy link

leon-anavi commented Jan 8, 2024

Raspberry Pi 5 Rev 1.0 4GB returns an empty /proc/device-tree/soc/ranges:

cat /proc/device-tree/soc/ranges
||

as a result:

cpuinfo:	c04170
./test.sh: line 6: warning: command substitution: ignored null byte in input
dtmodel:	Raspberry Pi 5 Model B Rev 1.0
socranges:	7c000000 00000010 7c000000
os:		12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment