Identifying which Pi
John Sandgrounder (1650) 574 posts |
I am looking for the way to check at boot which Raspberry Pi model my software is running on. Is there a SWI I can use? As a secondary question, is there a SWI which will identify which particular Pi is active (giving the ethernet address, perhaps?) My search has failed to find the answers :( |
Krzysztof Klis (2832) 36 posts |
What exactly do you need it for? In case you want to know whether your software will run on the current hardware, perhaps it might be better to recognize the CPU architecture (v6, v7, v8) than the RPi model itself? AFAIK you can recognize the ARM type using assembly language and checking which instructions are supported. |
Doug Webb (190) 1180 posts |
Chris Hall’s Screen Help software not only displays information about RISC OS to Monitor matching but also the model of the sytstem it is running on and also the vewrsion of RISC OS running as well. |
David Pitt (3386) 1248 posts |
OS_ReadSysInfo 9 with reason code 7. This should be for all platforms but it did not fully identify an RPi1, it reported Raspberry Pi Unknown.
This is very comprehensive but needs to catchup with the RPi3B+ Line 204 :- See https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md |
John Sandgrounder (1650) 574 posts |
OK, Thank You. OS_ReadSysInfo looks good.
One issue is to load the correct version of Aemulor for EasySockets and SocketFS. |
Chris Hall (132) 3554 posts |
Chris Hall’s Screen Help software – This is very comprehensive but needs to catchup with the RPi3B+ Now caught up with Pi Zero W, CM3 and model 3B+ (version 1.40 uploaded today to !Store). |
David Pitt (3386) 1248 posts |
Many thanks. (Just a minor thing, it reports itself as 1.20, as set at the top of the BASIC.) |
Chris Hall (132) 3554 posts |
Now corrected. |
John Sandgrounder (1650) 574 posts |
Back to my basic problem.
This correctly identifies a Raspberry Pi 2. But, the problem is, there are two different versions of the Raspberry Pi 2, each with a different processor. On start-up the system identifies the processor. |
Jeffrey Lee (213) 6048 posts |
The kernel doesn’t expose the CPU type, but you can work it out for yourself by reading the CP15 ID register: DIM code% 16 P%=code% [ OPT 0 SWI "OS_EnterOS" MRC CP15,0,R0,C0,C0,0 SWI "OS_LeaveOS" MOV PC,R14 ] PRINT USR code% And then decode it to determine the CPU type (check the relevant manuals, or the tables in the kernel sources) If you’re after more fine-grained information (e.g. “is SWP supported?”) then OS_PlatformFeatures 34 is able to return a whole bunch of info, since checking for specific machine/CPU types is likely to failure as soon as a new machine comes along. |
David Pitt (3386) 1248 posts |
OS_ReadSysInfo 9 with reason code 7. Processor type can be found from the Raspberry Pi revision codes Chris Hall’s |
John Sandgrounder (1650) 574 posts |
except on the screen at boot time! (so I can read it, but my software can’t) I have not yet got anything useful out of your CP15 example code. I can read all of the documentation and I can run Chris Hall’s !ScrHelp, but none of that helps me write a simple bit of Basic which tells my software what type of processor is running, so I can load the correct version of Aemulor. |
John Sandgrounder (1650) 574 posts |
But, could it? As it has worked it out and put on the screen. Perhaps, set a system variable (say, Processor$Type). It would save other software having to repeat the exercise. There are lots of other variables set before the boot sequence is run. EDIT: I now have your code running at boot time setting Processor$Type for the Raspberry Pi boards which I have. Thank you. |
Jeffrey Lee (213) 6048 posts |
Try this: DIM code% 16 P%=code% [ OPT 0 SWI "OS_EnterOS" MRC CP15,0,R0,C0,C0,0 SWI "OS_LeaveOS" MOV PC,R14 ] ID%=USR code% CASE ID% AND &FFF0 OF WHEN &B760: PRINT "ARM11" WHEN &C070: PRINT "A7" WHEN &D030: PRINT "A53" OTHERWISE: PRINT "Other" ENDCASE The kernel doesn’t expose the CPU type Yes, it could. However ROOL aren’t fans of identifying things using enums, since there’s often no “correct” way for a program to cope with enum values that it doesn’t recognise. Instead they prefer APIs where specific features can be checked for (like OS_PlatformFeatures 34, although that does take things to the extreme a bit). See this thread (look for the bits about OS_ReadSysInfo 8), and this thread, amongst others. So there’s the danger that exposing the CPU type directly could lead programmers into continuing that bad behaviour. |
John Sandgrounder (1650) 574 posts |
OK, Many thanks for your help. I now have code which identifies the Processor Type and sets a system variable. I now also have the correct version of Aemulor starting at boot time. |
Rick Murray (539) 13840 posts |
More info here: https://www.riscosopen.org/forum/forums/11/topics/4015 |