tlhackque

revinfo - Identify your Pi

Jun 10th, 2017
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # Identify RPI model
  4. #
  5. # Based on data from:
  6. #   https://www.element14.com/community/community/raspberry-pi/blog/2016/11/21/how-to-identify-which-model-of-the-raspberry-pi-you-have
  7. #
  8. # Copyright 2017 Timothe Litt litt at acm ddot org
  9. #
  10. # Use at your own risk; otherwise unrestricted provided
  11. # this notice is included in all copies.
  12. #
  13.  
  14. declare -A revs
  15. revs=( [Beta]="Q1 2012|B(Beta)|?|256MB|Beta Board"
  16.        [0002]="Q1 2012|B|1.0|256MB|"
  17.        [0003]="Q3 2012|B (ECN0001)|1.0|256MB|Fuses mod and D4 removed"
  18.        [0004]="Q3 2012|B|2.0|256MB|Mfg by Sony"
  19.        [0005]="Q4 2012|B|2.0|256MB|Mfg by Qisda"
  20.        [0006]="Q4 2012|B|2.0|256MB|Mfg by Egoman"
  21.        [0007]="Q1 2013|A|2.0|256MB|Mfg by Egoman"
  22.        [0008]="Q1 2013|A|2.0|256MB|Mfg by Sony"
  23.        [0009]="Q1 2013|A|2.0|256MB|Mfg by Qisda"
  24.        [000d]="Q4 2012|B|2.0|512MB|Mfg by Egoman"
  25.        [000e]="Q4 2012|B|2.0|512MB|Mfg by Sony"
  26.        [000f]="Q4 2012|B|2.0|512MB|Mfg by Qisda"
  27.        [0010]="Q3 2014|B+|1.0|512MB|Mfg by Sony"
  28.        [0011]="Q2 2014|Compute Module|1.0|512MB|Mfy by Sony"
  29.        [0012]="Q4 2014|A+|1.1|256MB|Mfg by Sony"
  30.        [0013]="Q1 2015|B+|1.2|512MB|Mfg by Embest"
  31.        [0014]="Q2 2014|Compute Module|1.0|512MB|Mfg by Embest"
  32.        [0015]="?|A+|1.1|256MB/512MB|Mfg by Embest"
  33.        [a01040]="Unknown|2 Model B|1.0|1GB|Unknown"
  34.        [a01041]="Q1 2015|2 Model B|1.1|1GB|Mfg by Sony"
  35.        [a21041]="Q1 2015|2 Model B|1.1|1GB|Mfg by Embest"
  36.        [a22042]="Q3 2016|2 Model B(with BCM2837)|1.2|1GB|Mfg by Embest"
  37.        [a02082]="Q1 2016|3 Model B|1.2|1GB|Mfg by Sony"
  38.        [a22082]="Q1 2016|3 Model B|1.2|1GB|Mfg by Embest"
  39. )
  40.  
  41. function prev() {
  42.     local rev="$1"
  43.  
  44.     if [ -z "${revs[$rev]}" ]; then
  45.         printf "Revision %-6s Unknown\n" "$rev"
  46.         return
  47.     fi
  48.  
  49.     IFS='|' read -ra RI <<< "${revs[$rev]}"
  50.  
  51.     printf "Revision %-6s %-7s %-32s %-4s %-11s %s\n" \
  52.         "$rev" "${RI[0]}" "${RI[1]}" "${RI[2]}" "${RI[3]}" "${RI[4]}"
  53. }
  54.  
  55. printf "         %-6s %-7s %-32s %-4s %-11s %s\n" \
  56.     "" "R.Date" "Model" "PCB" "Mem" "Notes"
  57.  
  58. if [ -n "$1" ]; then
  59.     ( for rev in "${!revs[@]}"; do
  60.             prev "$rev"
  61.             done
  62.     ) | sort
  63. else
  64.     pi_rev=(`cat /proc/cpuinfo | grep Revision`)
  65.     prev "${pi_rev[2]}"
  66. fi
RAW Paste Data