Monday, December 3
platform detection with linux on single-board computers
I’m extracting some Python code for detecting the current hardware from Adafruit_Blinka and Adafruit_Python_GPIO. This is a quick and dirty linkdump on ways to figure out what board you’re running on.
This string contains a platform identifier that can be used to append platform-specific components to sys.path, for instance.
platform - yields
some architecture / OS / processor / Python interpreter data.
If it exists,
/proc/device-tree/model may give you a human-readable string
(no trailing newline):
pi@raspberrypi:~ $ cat /proc/device-tree/model Raspberry Pi 3 Model B Plus Rev 1.3
/proc/cpuinfo will have various useful things. On the Pi, it’ll include lines
like so, which are useful:
Hardware : BCM2835 Revision : a020d3 Serial : 000000007cd89b23
The Pi foundation has a list of the revision codes.
An issue on Ev3dev, “an operating system that runs on the LEGO MINDSTORMS EV3 and other platforms with compatible motor/sensor hardware.”: Relying on /proc/cpuinfo and /proc/device-tree/model is not good enough.