Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@caius 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

This comment has been minimized.

Copy link
Owner Author

@jperkin jperkin commented Oct 18, 2019

Thanks!

@sperreault

This comment has been minimized.

Copy link

@sperreault sperreault commented Oct 20, 2019

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

@nshalman

This comment has been minimized.

Copy link

@nshalman 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

This comment has been minimized.

Copy link
Owner Author

@jperkin jperkin commented Oct 20, 2019

Thanks both!

@YoloSwagDogDiggity

This comment has been minimized.

Copy link

@YoloSwagDogDiggity YoloSwagDogDiggity 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

This comment has been minimized.

Copy link

@xthedeus 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

This comment has been minimized.

Copy link

@Papouchcom 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

This comment has been minimized.

Copy link

@nshalman 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment