usul27
Posts: 23
Joined: Mon Nov 26, 2012 9:54 am

Checking board revision

Mon Jul 21, 2014 4:45 pm

As some alternative pins have changed from model B to B+, I need to update the kernel driver. I would like to distinguish between "old" and new B+ revision. How can I do this in a kernel driver?

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6259
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Checking board revision

Mon Jul 21, 2014 5:42 pm


usul27
Posts: 23
Joined: Mon Nov 26, 2012 9:54 am

Re: Checking board revision

Tue Jul 22, 2014 7:34 pm

Ok, is there already a kernel routine to do this or do I have to implement it by myself? Couldn't see something yet. I just don't want to duplicate code that exists already.

MrEngman
Posts: 4077
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Checking board revision

Tue Jul 22, 2014 8:18 pm

What about cat /proc/cpuinfo

Shows for my Pis.

Code: Select all

B+       - Revision        : 0010
B2 512MB - Revision        : 000e
A        - Revision        : 0008
B2 256MB - Revision        : 0004
B1       - Revision        : 0002
Plus various other stuff.


MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

User avatar
DougieLawson
Posts: 40241
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Checking board revision

Tue Jul 22, 2014 8:20 pm

MrEngman wrote:What about cat /proc/cpuinfo
That needs Linux running. This is the "bare metal" forum so that may not be the case.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

usul27
Posts: 23
Joined: Mon Nov 26, 2012 9:54 am

Re: Checking board revision

Tue Jul 22, 2014 8:21 pm

I can't use this from a kernel module, but I now know all revisions, which also helps.

Thanks
Daniel

usul27
Posts: 23
Joined: Mon Nov 26, 2012 9:54 am

Re: Checking board revision

Tue Jul 22, 2014 8:39 pm

I need it on Linux, but in a kernel module. However the solution was much easier than expected:

extern int system_rev;

does the job :-)

usul27
Posts: 23
Joined: Mon Nov 26, 2012 9:54 am

Re: Checking board revision

Tue Jul 22, 2014 9:03 pm

Is there any documentation how revisions will be handled in the future? Checking for revision>=0x10 works for now to distinguish between model B+ and "older" Raspberry Pis. But is there a risk that there will be new A or B versions with revisions>0x10?

User avatar
DougieLawson
Posts: 40241
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Checking board revision

Tue Jul 22, 2014 9:17 pm

I think you'll need to build a look-up table.
http://elinux.org/RPi_HardwareHistory

Also beware that you'll get a different revision value for a CM.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6259
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Checking board revision

Wed Jul 23, 2014 7:05 am

To avoid confusion, I've moved the topic out of the bare metal sub-forum. The way you would do things in Linux kernel and user space is very different to how you would do it your own bare metal kernel, so you didn't get a helpful answer straight away.

Future revisions are not documented, since they're assigned as they're needed. You'll need to keep an eye out for new revisions as they pop up. Perhaps adding a message asking the user to email you when the revision is not recognised may help.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Checking board revision

Thu Jul 24, 2014 4:57 pm

Just for the sake of completeness, here's another method https://github.com/raspberrypi/noobs/bl ... il.cpp#L99

Return to “C/C++”