Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Better detection of Pi platform #53

Merged
merged 15 commits into from
Jul 16, 2018

Conversation

wimrijnders
Copy link
Contributor

@wimrijnders wimrijnders commented Jul 13, 2018

The attempted implementation for detecting if you're running on Pi does not work on early Pi versions (or distributions). This PR adds a fallback which should work on any version.

  • Added platform check using /proc/cpuinfo to both C++ and shell versions of detectPlatform
  • No attempt is made to determine the exact Pi model. The fallback just gives the message 'This is a Pi platform`.
  • Added a unit test for the correct working of the platform detection scripts.

@mn416
Copy link
Owner

mn416 commented Jul 15, 2018

Hi @wimrijnders,

Here is my /proc/cpuinfo:

processor	: 0
model name	: ARMv6-compatible processor rev 7 (v6l)
Features	: swp half thumb fastmult vfp edsp java tls 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xb76
CPU revision	: 7

Hardware	: BCM2708
Revision	: 000d
Serial		: 00000000791b4652

@wimrijnders
Copy link
Contributor Author

Hardware : BCM2708

Well crap. The good news is that the cpuinfo solution will work. The bad news is that this is another BCM number than I'm expecting, so this needs to be detected also.

@wimrijnders
Copy link
Contributor Author

Turns out that BCM2807 and BCM2835 come down to the same thing. It does make it a bit bothersome though. BCM2807 is the 'family' name and the other numbers are its members.

I think the safest thing here is to test all possible BCM numbers. From the wiki:

  • BCM2807
  • BCM2835
  • BCM2836
  • BCM2837
  • BCM2837B0

If you have a better idea, please let me know.


The thing is, the combination of fields Hardware and Revision is pretty much unique already. Testing the values of the fields is meant as an extra check. You could do a same check with Revision, which can have the following values:

0002 0003 0004 0005 0006 0007 0008 0009 000d 000e 000f 0011
0014 0012 0015 a01041 a21041 a22042 900092 900093 9000C1 a02082
a22082 a020d3

See what I mean? I thought checking the Hardware field would be easier. Not that it's not doable, of course. And a computer program doesn't much care how much it needs to test.

@wimrijnders
Copy link
Contributor Author

Strange though; my Pi 1 has revision 000e but it's also a Model B Rev 2 like yours. Still, it gives BCM2835 in the Hardware-field.

@wimrijnders
Copy link
Contributor Author

@mn416 Adjusted detectPlatform scripts to test multiple model numbers, in particular the model of your Pi.

Please test both the bash and C++ version on you platform and tell me if it works for you.

@mn416
Copy link
Owner

mn416 commented Jul 16, 2018

Hi @wimrijnders,

To make it future proof, how about just detecting Hardware: BCM? This will catch the common case of someone running with QPU=1 on a PC or Mac.

@wimrijnders
Copy link
Contributor Author

OK, then. But:

  • I will check on prefix BCM28, because this is the valid family prefix for Pi's
  • Will put the insights about the model numbers in the header comment

PR forthcoming.

@wimrijnders
Copy link
Contributor Author

wimrijnders commented Jul 16, 2018

@mn416 Detection of prefix only added. See if this works for you.

@mn416
Copy link
Owner

mn416 commented Jul 16, 2018

@wimrijnders My Pi shows BCM2708, so how about BCM2 as the prefix or BCM2(7|8)?

@wimrijnders
Copy link
Contributor Author

BCM27x: heh, you're right. Good catch.

wimrijnders pushed a commit to wimrijnders/QPULib that referenced this pull request Jul 16, 2018
Now that DMA is enabled, it's interesting to know what the actual size is of the VPM.
This adds it to the output of `detectPlatform`.

Example output:

```
> sudo obj-qpu/bin/detectPlatform
Detected platform: Raspberry Pi 2 Model B Rev 1.1
Hardware revision: a01041
Number of slices: 3
Number of QPU's per slice: 4
Size of VPM: 12KB                    # <-- This is new

```

**NOTE:* This will probably not work on your machine until mn416#52 and mn416#53 have been merged.
@mn416
Copy link
Owner

mn416 commented Jul 16, 2018

Hi @wimrijnders,

Now getting much further, it's correctly detecting my Pi as a Pi.

But I still get stuck on RegisterMap.cpp:

Compiling Lib/VideoCore/RegisterMap.cpp
In file included from /opt/vc/include/interface/vcos/vcos_assert.h:149:0,
                 from /opt/vc/include/interface/vcos/vcos.h:114,
                 from /opt/vc/include/interface/vmcs_host/vc_dispmanx.h:33,
                 from /opt/vc/include/bcm_host.h:46,
                 from Lib/VideoCore/RegisterMap.cpp:8:
/opt/vc/include/interface/vcos/vcos_types.h:38:33: fatal error: vcos_platform_types.h: No such file or directory
compilation terminated.
make: *** [obj-qpu/VideoCore/RegisterMap.o] Error 1

@mn416 mn416 merged commit 11f2163 into mn416:development Jul 16, 2018
@wimrijnders
Copy link
Contributor Author

But I still get stuck on RegisterMap.cpp:

That's what the last update in #52 is trying to solve. Can you see if that works now?

@wimrijnders wimrijnders deleted the fix-detect-platform branch July 16, 2018 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants