When the raspberry Pi model A was announced a few days ago, I ordered one straight away. With three different models of raspberry Pi now available (or four, if you count the red Chinese variant), working out the capabilities of the board is becoming increasingly important. It’s vital for anyone involved in making hardware or software for other people to use, and it’s even pretty important for personal projects – you never know when you might want to use your hardware and software with a different board.
From my experimentation, here are the revision number values, and some useful things you can deduce from them:
Rev. No. | Model | Capabilities |
---|---|---|
0x2 | B1 | Original Model B, 256MB RAM, Ethernet, two USB sockets, five LEDs, (P2) JTAG pins, no mounting holes, Pin3=GPIO0, Pin5=GPIO1, Pin13=GPIO21, I2C-0 |
0x3 | B1+ | Original Model B with no polyfuses, 256MB RAM, Ethernet, two USB sockets, five LEDs, no mounting holes, Pin3=GPIO0, Pin5=GPIO1, Pin13=GPIO21, I2C-0 |
0x4 | B2 | Model B, 256MB RAM, Ethernet, two USB sockets, five LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1, 8 extra IO pads (P5) |
0x5 | B2 | Model B, 256MB RAM, Ethernet, two USB sockets, five LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1, 8 extra IO pads (P5) |
0x6 | B2 | Model B, 256MB RAM, Ethernet, two USB sockets, five LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1, 8 extra IO pads (P5) |
0x7 | A | Model A, 256MB RAM, no Ethernet, one USB socket, two LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, I2C-1, 8 extra IO pads (P5) |
0x8 | A | Model A, 256MB RAM, no Ethernet, one USB socket, two LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, I2C-1, 8 extra IO pads (P5) |
0x9 | A | Model A, 256MB RAM, no Ethernet, one USB socket, two LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, I2C-1, 8 extra IO pads (P5) |
0xd | B2 | Rev2 Model B, 512MB RAM, Ethernet, two USB sockets, five LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1, 8 extra IO pads (P5) |
0xe | B2 | Rev2 Model B, 512MB RAM, Ethernet, two USB sockets, five LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1, 8 extra IO pads (P5) |
0xf | B2 | Rev2 Model B, 512MB RAM, Ethernet, two USB sockets, five LEDs, mounting holes, Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1, 8 extra IO pads (P5) |
Update: The above table has been extended based on Dom’s answer on the Raspberry Pi board
Apparently codes 0x4, 0x5, and 0x6 are allocated to B2 boards with 256MB RAM, although I have never seen one “in the wild”. If you have a board which responds with one of these numbers, or indeed anything else not in my table, please let me know!
Personally I have a B1 (0x2), a B2 (0xe) and an A (0x8). Now that I know how many there are, it kind of makes me want to collect them all ;)
Luckily the Raspberry Pi firmware provides ways to query the system about its revision number.
Here’s a few ways to find the revision number of the board your software is running on:
If you are running on Raspbian, check /proc/cmdline:
Language | Code |
---|---|
bash | cat /proc/cmdline \| awk -v RS=" " -F= '/boardrev/ { print $2 } |
python | import re def getrevision(): revision = "unknown" with open('/proc/cmdline', 'r') as f: line = f.readline() m = re.search('bcm2708.boardrev=(0x[0123456789abcdef]*) ', line) revision = m.group(1) |
ruby | def getrevision line = File.open("/proc/cmdline").first m = line.match /bcm2708.boardrev=(0x[0123456789abcdef]*) / return m[1] end puts getrevision |
perl | open my $file, '<', "/proc/cmdline"; my $firstline = <$file>; close $file; $firstline =~ /bcm2708.boardrev=(0x[0123456789abcdef]*) /; print "$1\n"; |
lua | io.input("/proc/cmdline") s = io.read("*a") print(s:match("bcm2708.boardrev=(0x%x*) ")) io.close() |
C | #include char buf[1024]; void shift(char* window, int len) { int i; for (i = 1; i < len; ++i) { window[i-1] = window[i]; } window[len-1] = 0; } void boardrev(char* dest) { FILE* f; int n = 0; int i; char window[5]; int wi = 0; if (f= fopen("/proc/cmdline", "r")) { n = fread(buf, 1, 1023, f); fclose(f); } for (i = 0; i < n; ++i) { char c = buf[i]; if (strcmp(window, "rev=") == 0) { while (buf[i] != ' ' && buf[i] != 0) { *dest++ = buf[i++]; } *dest++ = 0; return; } if (wi < 4) { window[wi++] = c; window[wi] = 0; } else { shift(window, 4); window[3] = c; } } } void main() { char rev[10]; boardrev(rev); printf("%s\n", rev); } |
If your program is running on the "bare metal" of the Raspberry Pi without an operating system to do this stuff for you, please see my previous article about reading Raspberry Pi revision numbers