-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmypi
executable file
·113 lines (92 loc) · 3.76 KB
/
mypi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash
#########################################################################
# Made by : Ewoud Dronkert
# Licence : GNU GPL v3
# Platform : Raspberry Pi
# Requires : bash, vcgencmd
# Location : ~/bin, /usr/local/bin
# Name : mypi
# Version : 1.1.0
# Date : 2018-11-17
# Purpose : Identify the Raspberry Pi by model, board revision, etc.
# Parameters : none
# Settings : none
# Exit 0 : No script errors
# Credits : https://elinux.org/RPi_HardwareHistory#Board_Revision_History
#########################################################################
# Revision identifier
# strip optional "1000" prefix which is added for overvoltage
id=$(awk '/^Revision/ {sub("^1000", "", $3); print $3}' /proc/cpuinfo)
# Serial number
s=$(awk '/^Serial/ {print $3}' /proc/cpuinfo)
# Processor count
c=$(cat /proc/cpuinfo | grep ^processor | wc -l)
# Configured RAM, calculate total
m1=$(vcgencmd get_mem arm | grep -oP '\d+')
m2=$(vcgencmd get_mem gpu | grep -oP '\d+')
(( m0 = m1 + m2 ))
# Clock frequencies
f1=$(vcgencmd get_config arm_freq | grep -oP '\d+')
f2=$(vcgencmd get_config core_freq | grep -oP '\d+')
f3=$(vcgencmd get_config gpu_freq | grep -oP '\d+')
f4=$(vcgencmd get_config sdram_freq | grep -oP '\d+')
# Compute number width
max=$(( f1 > m0 ? f1 : m0 ))
w=1
[ "$max" -ge 10 ] && w=2
[ "$max" -ge 100 ] && w=3
[ "$max" -ge 1000 ] && w=4
[ "$max" -ge 10000 ] && w=5
[ "$max" -ge 100000 ] && w=6
case "$id" in
0007 ) n='1A'; b='2.0'; d='Q1 2013'; p='Egoman';;
0008 ) n='1A'; b='2.0'; d='Q1 2013'; p='Sony';;
0009 ) n='1A'; b='2.0'; d='Q1 2013'; p='Qisda';;
0012 ) n='1A+'; b='1.1'; d='Q4 2014' ; p='Sony';;
0015 ) n='1A+'; b='1.1'; d='(unknown)'; p='Embest';;
900021 ) n='1A+'; b='1.1'; d='Q3 2016' ; p='Sony';;
9020e0 ) n='3A+'; b='1.0'; d='Q4 2018'; p='Sony';;
Beta ) n='1B'; b='-' ; d='Q1 2012'; p='-';;
0002 ) n='1B'; b='1.0'; d='Q1 2012'; p='(unknown)';;
0003 ) n='1B'; b='1.0'; d='Q3 2012'; p='(unknown)';;
0004 ) n='1B'; b='2.0'; d='Q3 2012'; p='Sony';;
0005 ) n='1B'; b='2.0'; d='Q4 2012'; p='Qisda';;
0006 ) n='1B'; b='2.0'; d='Q4 2012'; p='Egoman';;
000d ) n='1B'; b='2.0'; d='Q4 2012'; p='Egoman';;
000e ) n='1B'; b='2.0'; d='Q4 2012'; p='Sony';;
000f ) n='1B'; b='2.0'; d='Q4 2012'; p='Qisda';;
0010 ) n='1B+'; b='1.0'; d='Q3 2014'; p='Sony';;
0013 ) n='1B+'; b='1.2'; d='Q1 2015'; p='Embest';;
900032 ) n='1B+'; b='1.2'; d='Q2 2016'; p='Sony';;
a01040 ) n='2B'; b='1.0'; d='Q1 2015'; p='Sony';;
a01041 ) n='2B'; b='1.1'; d='Q1 2015'; p='Sony';;
a21041 ) n='2B'; b='1.1'; d='Q1 2015'; p='Embest';;
a22042 ) n='2B'; b='1.2'; d='Q1 2015'; p='Embest';;
0011 ) n='CM1'; b='1.0'; d='Q2 2014'; p='Sony';;
0014 ) n='CM1'; b='1.0'; d='Q2 2014'; p='Embest';;
a020a0 ) n='CM3'; b='1.0'; d='Q1 2017'; p='Sony';;
900092 ) n='Zero'; b='1.2'; d='Q4 2015'; p='Sony';;
900093 ) n='Zero'; b='1.3'; d='Q2 2016'; p='Sony';;
920093 ) n='Zero'; b='1.3'; d='Q4 2016'; p='Embest';;
9000c1 ) n='Zero W'; b='1.1'; d='Q1 2017'; p='Sony';;
a02082 ) n='3B'; b='1.2'; d='Q1 2016'; p='Sony';;
a22082 ) n='3B'; b='1.2'; d='Q1 2016'; p='Embest';;
a32082 ) n='3B'; b='1.2'; d='Q4 2016'; p='Sony Japan';;
a020d3 ) n='3B+'; b='1.3'; d='Q1 2018'; p='Sony';;
c03111 ) n='4B'; b='1.1'; d='Q1 2019'; p='Sony';;
* ) n='(unknown)'; b='(unknown)'; d='(unknown)'; p='(unknown)';;
esac
# Report
echo "Raspberry Pi : $n"
echo "Serial number : $s"
printf "Memory : %${w}u MB\n" $m0
printf " ARM : %${w}u MB\n" $m1
printf " GPU : %${w}u MB\n" $m2
printf "Clock ARM : %${w}u MHz x%u\n" $f1 $c
printf " Core : %${w}u MHz\n" $f2
printf " GPU : %${w}u MHz\n" $f3
printf " SDRAM : %${w}u MHz\n" $f4
echo "Board revision : $b"
echo "Release date : $d"
echo "Manufacturer : $p"
exit 0