DoctorD90 icon

rpi_revision2

DoctorD90 | PRO | 05/28/15 07:20:27 PM UTC | 0 ⭐ | 6701 👁️ | Never ⏰ | []
TCL |

2.01 KB

|

None

|

0 👍

/

0 👎

# [USER:8][NEW:1][MEMSIZE:3][MANUFACTURER:4][PROCESSOR:4][TYPE:8][REV:4]
# NEW          23: will be 1 for the new scheme, 0 for the old scheme
# MEMSIZE      20: 0=256M 1=512M 2=1G
# MANUFACTURER 16: 0=SONY 1=EGOMAN 2=EMBEST
# PROCESSOR    12: 0=2835 1=2836
# TYPE         04: 0=MODELA 1=MODELB 2=MODELA+ 3=MODELB+ 4=Pi2 MODELB 5=ALPHA 6=CM
# REV          00: 0=REV0 1=REV1 2=REV2
#For 1 bit,  AND 0x1.
#For 3 bits, AND 0x7.
#For 4 bits, AND 0xf.
#For 8 bits, AND 0xff.   
 
# pi2       = 1<<23 | 2<<20 | 1<<12 | 4<<4          = 0xa01040
# rev1.1 B+ = 1<<23 | 1<<20 | 0<<12 | 3<<4 | 0xf<<0 = 0xa0003f
 
proc getfield {hex offset mask} {return [expr {(($hex >> $offset) & $mask)}]}
 
proc humanize {typ num} {
  set r "unknown - $num"
  switch $typ {
    new {
      switch $num {
        0 {set r "Old Scheme"}
        1 {set r "New Scheme"}
      }
    }
    memsize {
      switch $num {
        0 {set r 256MB}
        1 {set r 512MB}
        2 {set r 1GB}
      }
    }
    manufacturer {
      switch $num {
        0 {set r SONY}
        1 {set r EGOMAN}
        2 {set r EMBEST}
      }
    }
    processor {
      switch $num {
        0 {set r 2835}
        1 {set r 2836}
      }
    }
    type {
      switch $num {
        0 {set r "rPi1 Model A"}
        1 {set r "rPi1 Model B"}
        2 {set r "rPi1 Model A+"}
        3 {set r "rPi1 Model B+"}
        4 {set r "rPi2 Model B"}
        5 {set r ALPHA}
        6 {set r CM}
      }
    }
    rev {
      switch $num {
        0 {set r rev0}
        1 {set r rev1}
        2 {set r rev2}
      }
    }
  }
  return $r
}
 
 
set hex 0xa01040
set hex 0xa0003f
#set hex 0x0010
puts "NEW:\t\t[humanize new [getfield $hex 23 0x1]]"
puts "MEMSIZE:\t[humanize memsize [getfield $hex 20 0x7]]"
puts "MANUFACTURER:\t[humanize manufacturer [getfield $hex 16 0xf]]"
puts "PROCESSOR:\t[humanize processor [getfield $hex 12 0xf]]"
puts "TYPE:\t\t[humanize type [getfield $hex 04 0xff]]"
puts "REV:\t\t[humanize rev [getfield $hex 00 0xf]]"

Comments