Advertisement
DoctorD90

rpi_revision2

May 28th, 2015
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # [USER:8][NEW:1][MEMSIZE:3][MANUFACTURER:4][PROCESSOR:4][TYPE:8][REV:4]
  2. # NEW          23: will be 1 for the new scheme, 0 for the old scheme
  3. # MEMSIZE      20: 0=256M 1=512M 2=1G
  4. # MANUFACTURER 16: 0=SONY 1=EGOMAN 2=EMBEST
  5. # PROCESSOR    12: 0=2835 1=2836
  6. # TYPE         04: 0=MODELA 1=MODELB 2=MODELA+ 3=MODELB+ 4=Pi2 MODELB 5=ALPHA 6=CM
  7. # REV          00: 0=REV0 1=REV1 2=REV2
  8. #For 1 bit,  AND 0x1.
  9. #For 3 bits, AND 0x7.
  10. #For 4 bits, AND 0xf.
  11. #For 8 bits, AND 0xff.  
  12.  
  13. # pi2       = 1<<23 | 2<<20 | 1<<12 | 4<<4          = 0xa01040
  14. # rev1.1 B+ = 1<<23 | 1<<20 | 0<<12 | 3<<4 | 0xf<<0 = 0xa0003f
  15.  
  16. proc getfield {hex offset mask} {return [expr {(($hex >> $offset) & $mask)}]}
  17.  
  18. proc humanize {typ num} {
  19.   set r "unknown - $num"
  20.   switch $typ {
  21.     new {
  22.       switch $num {
  23.         0 {set r "Old Scheme"}
  24.         1 {set r "New Scheme"}
  25.       }
  26.     }
  27.     memsize {
  28.       switch $num {
  29.         0 {set r 256MB}
  30.         1 {set r 512MB}
  31.         2 {set r 1GB}
  32.       }
  33.     }
  34.     manufacturer {
  35.       switch $num {
  36.         0 {set r SONY}
  37.         1 {set r EGOMAN}
  38.         2 {set r EMBEST}
  39.       }
  40.     }
  41.     processor {
  42.       switch $num {
  43.         0 {set r 2835}
  44.         1 {set r 2836}
  45.       }
  46.     }
  47.     type {
  48.       switch $num {
  49.         0 {set r "rPi1 Model A"}
  50.         1 {set r "rPi1 Model B"}
  51.         2 {set r "rPi1 Model A+"}
  52.         3 {set r "rPi1 Model B+"}
  53.         4 {set r "rPi2 Model B"}
  54.         5 {set r ALPHA}
  55.         6 {set r CM}
  56.       }
  57.     }
  58.     rev {
  59.       switch $num {
  60.         0 {set r rev0}
  61.         1 {set r rev1}
  62.         2 {set r rev2}
  63.       }
  64.     }
  65.   }
  66.   return $r
  67. }
  68.  
  69.  
  70. set hex 0xa01040
  71. set hex 0xa0003f
  72. #set hex 0x0010
  73. puts "NEW:\t\t[humanize new [getfield $hex 23 0x1]]"
  74. puts "MEMSIZE:\t[humanize memsize [getfield $hex 20 0x7]]"
  75. puts "MANUFACTURER:\t[humanize manufacturer [getfield $hex 16 0xf]]"
  76. puts "PROCESSOR:\t[humanize processor [getfield $hex 12 0xf]]"
  77. puts "TYPE:\t\t[humanize type [getfield $hex 04 0xff]]"
  78. puts "REV:\t\t[humanize rev [getfield $hex 00 0xf]]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement