To enhance my bash script decoding the Revision returned by cat /proc/cpuinfo
I'd like to know what the RaspBerry Pi 4 codes for ModelName,Processor and Memory are.
(my own one is still underway)
Sample sanitized output:
LotPings@LegoBlack:~ $ ./pirevision.sh
Serial = 00000000a3123456
MAC-address(es) = b8:27:eb:12:34:56 b8:27:eb:ab:cd:ef
Revision = a020d3
PCBRevision = 3
ModelName = 3B+
Processor = BCM2837
Manufacturer = Sony UK
MemorySize = 1024 MB
EncodedFlag = revision is a bit field
WarrantyVoidOld = no
WarrantyVoidNew = no
EDIT: The documentation was updated in the meantime,
so the script should output official information now.
#!/bin/bash
## resources:
## https://github.com/AndrewFromMelbourne/raspberry_pi_revision
## http://elinux.org/RPi_HardwareHistory#Board_Revision_History
## https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
## https://github.com/raspberrypi/documentation/blob/master/hardware/raspberrypi/revision-codes/README.md
Revision=$(cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}')
Serial=$(cat /proc/cpuinfo|grep 'Serial'|awk '{print $3}')
MACs=$(ifconfig | grep '[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:'|awk '{print $2}')
echo 'Serial = ' $Serial
echo 'MAC-address(es) = ' $MACs
echo 'Revision = ' $Revision
Encoded=$((0x$Revision >> 23 & 1))
if [ $Encoded = 1 ]; then
PCBRevision=('0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
ModelName=('A' 'B' 'A+' 'B+' 'Pi2B' 'Alpha' 'CM1' 'unknown' '3B' 'Zero' 'CM3' 'unknown' 'Zero W' '3B+' '3A+' 'internal use only' 'CM3+' '4B' '18 ?' '19 ?' '20 ?')
Processor=('BCM2835' 'BCM2836' 'BCM2837' 'BCM2711' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
Manufacturer=('Sony UK' 'Egoman' 'Embest' 'Sony Japan' 'Embest' 'Stadium' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
MemorySize=('256 MB' '512 MB' '1024 MB' '2048 MB' '4096 MB' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
EncodedFlag=('' 'revision is a bit field')
WarrantyVoidOld=('no' 'warranty void - Pre Pi2')
WarrantyVoidNew=('no' 'warranty void - Post Pi2')
echo 'PCBRevision = ' ${PCBRevision[$((0x$Revision&0xf))]}
echo 'ModelName = ' ${ModelName[$((0x$Revision>>4&0xff))]}
echo 'Processor = ' ${Processor[$((0x$Revision>>12&0xf))]}
echo 'Manufacturer = ' ${Manufacturer[$((0x$Revision>>16&0xf))]}
echo 'MemorySize = ' ${MemorySize[$((0x$Revision>>20&7))]}
echo 'EncodedFlag = ' ${EncodedFlag[$((0x$Revision>>23&1))]}
echo 'WarrantyVoidOld = ' ${WarrantyVoidOld[$((0x$Revision>>24&1))]}
echo 'WarrantyVoidNew = ' ${WarrantyVoidNew[$((0x$Revision>>25&1))]}
fi
Current Revision
bit field explanation
# Bit NOs 3322 2222 2222 1111 1111 1100 0000 0000
# Decimal 1098 7654 3210 9876 5432 1098 7654 3210
# Fields uuuu uuHG FMMM CCCC PPPP TTTT TTTT RRRR
# WarrantyVoidNew/| |Mem Manu Proc ModelName PCB
# WarrantyVoidOld/ |Siz fact Rev
# EncodedFlag
#
# bits contains values
# R 00-03 PCBRevision ('0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15')
# T 04-11 ModelName ('A' 'B' 'A+' 'B+' 'Pi2B' 'Alpha' 'CM1' 'unknown' 'Pi3B' 'Zero' 'CM3' 'unknown' 'Zero W' 'Pi3B+' 'Pi3A+' 'internal use only' 'CM3+' '4B')
# P 12-15 Processor ('BCM2835' 'BCM2836' 'BCM2837' 'BCM2711)
# C 16-19 Manufacturer ('Sony UK' 'Egoman' 'Embest' 'Sony Japan' 'Embest' 'Stadium')
# M 20-22 MemorySize ('256 MB' '512 MB' '1024 MB' '2048 MB' '4096 MB')
# F 23-23 EncodedFlag ('' 'revision is a bit field')
# G 24-24 WarrantyVoidOld ('' 'warranty void - Pre Pi2')
# H 25-25 WarrantyVoidNew ('' 'warranty void - Post Pi2')
# u 26-31 unused