Am 26.06.2019 um 16:28 schrieb aTc atc@k-n-p.org:
Is there a more official method of detecting if a pyra is a 2 or 4gb model from linux, other than just looking at /proc/meminfo MemTotal ?
Yes, that is the official way. It is robust and independent of specific hardware. Like on x86 systems where you can insert new memory modules and the new memory is magically found.
But which problem do you want to solve by this detection from user-space? The only area where it seems to make sense is for system information which reports available and used memory size or for Installers.
There is also a nice command line tool "free" which even hides that /proc/meminfo exists and would be more general and robust against changes to /proc entries.
Looking at /proc/device-tree/model only seems to give the board revision.
It may also be reasonable to look at /proc/device-tree/compatible. But this also does not tell 2GB or 4GB differences. And (currently) does not even tell the board revision.
The task of U-Boot and the kernel is to abstract from specific hardware.
So if you are looking into /proc/device-tree/model to distinguish devices, there is probably something wrong elsewhere.
Yes, there are cases where it must be done that way. LetuxOS for example uses it to find out how to correctly setup the xorg.conf for different devices because Xorg seems not yet to be able to find out everything using the omapdrm kernel API. For example LCD screen size in mm is not yet available elsewhere. At least for older Debian versions and kernels. AFAIK developers are working on that and somewhen it will work and LetuxOS can get rid of checking /proc/device-tree/model.
In summary, it should be avoided to check for a specific device model. Rather, the kernel should be asked for the presence of certain features. E.g. to distinguish between the LTE-EU and LTE-US variants the modem should be turned on and asked for "AT I".