under an intel I know I can look at the outcome of uname -m to know if my OS is 32 or 64 bit, but under ARM this gives:
armv7l
I deduced from
file /usr/bin/ls
that I’m on a 32-bit OS, but how can I know this in an easier way?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
There are several gradations, since you can run a 32-bit or mixed operating system on a 64-bit-capable CPU. See 64-bit kernel, but all 32-bit ELF executable running processes, how is this? for a detailed discussion (written for x86, but most of it applies to arm as well).
You can find the processor model in /proc/cpuinfo. For example:
$ cat /proc/cpuinfo Processor : ARMv7 Processor rev 10 (v7l)
ARMv7 (and below) is 32-bit. ARMv8 introduces the 64-bit instruction set.
If you want to see whether your system supports 64-bit binaries, check the kernel architecture:
$ uname -m armv7l
On a 64-bit processor, you’d see a string starting with armv8 (or above) if the uname process itself is a 32-bit process, or aarch64 if it’s a 64-bit process. (See also https://stackoverflow.com/questions/45125516/possible-values-for-uname-m)
Method 2
As richard points out, armv7 variants are all 32-bit, so there is no redundant label armv7-32, etc.
On a linux system, you can easily, although not truly definitively, check by examining a common executable:
> which bash /bin/bash > file /bin/bash /bin/bash: ELF 32-bit LSB executable, ARM, version 1 (SYSV) ...
I say “not definitively” because it is possible to run 32-bit executables on a 64-bit system.
There does not appear to be anything foolproof in /proc or /sys; the output from /proc/cpuinfo may provide some significant clues. If for some reason you need an automated check, creating a table mapped to the “model name” field seems like one potentially sound method (other fields, including “model”, “cpu family”, etc. look optional — they don’t appear at all for me on a Broadcom 2708 ARMv6 processor).
Method 3
Install the ‘lshw’ package.
# lshw
...
description: Computer
product: Raspberry Pi 3 Model B Rev 1.2
width: 32 bits
...
Method 4
Seems like most ways to see bit count is to somehow know that arm7=32 bit and while that may be true but what about
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e2928ba290928bdb">[email protected]</a>:~ $ getconf LONG_BIT 32
And if you want to look for the cpu model I normally use arch
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73011c1c073301031a47">[email protected]</a>:~# tr '' 'n' </proc/device-tree/model;arch Raspberry Pi Model B Rev 2 armv6l <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="56263f1624263f6f">[email protected]</a>:~ $ tr '' 'n' </proc/device-tree/model;arch Raspberry Pi 3 Model B Rev 1.2 armv7l
Method 5
Try the following.
// -*- compile-command: "gcc -Wall -o sizeof sizeof.c && ./sizeof" -*-
#include <stdio.h>
#include <limits.h>
#define size(t) { t x; printf("%s:t%3lu bitn", #t, CHAR_BIT * sizeof x); }
int main (int argc, char *argv[])
{
size(char);
size(short);
size(int);
size(long);
size(void*);
return 0;
}
The address size is void*.
Method 6
Nope it’s a 64-bit computer. It’s an Allwinner H8, witch is a double ARM-7. 8 cores, 64 bits, powervr, sgx 544, at double speed (700mhz).
So no, it’s capable of being 64 bit. Just the OS might be 32.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0