Dr-Noob / cpufetch

Simple yet fancy CPU architecture fetching tool
GNU General Public License v2.0
1.83k stars 100 forks source link

Raspberry Pi 3 not detected properly (no Revision field in cpuinfo) #182

Closed rkujawa closed 9 months ago

rkujawa commented 1 year ago

When running on Fedora 38, cpufetch fails to detect the CPU:

$ cpufetch 

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            Microarchitecture:   Cortex-A53
                                                            Max Frequency:       1.400 GHz
                                                            Cores:               4 cores
                                                            Features:            NEON,CRC32
                                                            Peak Performance:    22.40 GFLOP/s

The errors in debug mode suggest this is somehow related to parsing of /proc/cpuinfo:

$ cpufetch -vd
[WARNING]: [RPi] Couldn't find revision field in cpuinfo
[WARNING]: SoC detection failed using revision code
[WARNING]: SoC detection failed using /proc/cpuinfo: No string found
[WARNING]: read_file: /sys/bus/nvmem/devices/rockchip-efuse0/nvmem: No such file or directory
cpufetch v1.04 (Linux ARM build)
[Core 0] 0x410FD034 1400 MHz
[Core 1] 0x410FD034 1400 MHz
[Core 2] 0x410FD034 1400 MHz
[Core 3] 0x410FD034 1400 MHz
$ uname -srm
Linux 6.2.15-300.fc38.aarch64 aarch64
$ rpm -q cpufetch
cpufetch-1.04-1.fc38.aarch64
$ cat /sys/firmware/devicetree/base/model
Raspberry Pi 3 Model B Plus Rev 1.3
$ cat /proc/cpuinfo 
processor       : 0
BogoMIPS        : 38.40
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
BogoMIPS        : 38.40
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 2
BogoMIPS        : 38.40
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 3
BogoMIPS        : 38.40
Features        : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4
Dr-Noob commented 1 year ago

This is a weird one...

Seems like /proc/cpuinfo is using spaces instead of tabs as delimiters. This is the first time I see such a thing. Looks like this also happened in WSL (Microsoft/WSL#732). Can you confirm this by pasting the output of something like hexdump -C /proc/cpuinfo?

Edit: Do you use any VM or container? That might explain why it is tampering the /proc/cpuinfo.

rkujawa commented 1 year ago

No, this is neither VM nor container. cpufetch is installed from RPM package on the host OS.

$ hexdump -C /proc/cpuinfo 
00000000  70 72 6f 63 65 73 73 6f  72 09 3a 20 30 0a 42 6f  |processor.: 0.Bo|
00000010  67 6f 4d 49 50 53 09 3a  20 33 38 2e 34 30 0a 46  |goMIPS.: 38.40.F|
00000020  65 61 74 75 72 65 73 09  3a 20 66 70 20 61 73 69  |eatures.: fp asi|
00000030  6d 64 20 65 76 74 73 74  72 6d 20 63 72 63 33 32  |md evtstrm crc32|
00000040  20 63 70 75 69 64 0a 43  50 55 20 69 6d 70 6c 65  | cpuid.CPU imple|
00000050  6d 65 6e 74 65 72 09 3a  20 30 78 34 31 0a 43 50  |menter.: 0x41.CP|
00000060  55 20 61 72 63 68 69 74  65 63 74 75 72 65 3a 20  |U architecture: |
00000070  38 0a 43 50 55 20 76 61  72 69 61 6e 74 09 3a 20  |8.CPU variant.: |
00000080  30 78 30 0a 43 50 55 20  70 61 72 74 09 3a 20 30  |0x0.CPU part.: 0|
00000090  78 64 30 33 0a 43 50 55  20 72 65 76 69 73 69 6f  |xd03.CPU revisio|
000000a0  6e 09 3a 20 34 0a 0a 70  72 6f 63 65 73 73 6f 72  |n.: 4..processor|
000000b0  09 3a 20 31 0a 42 6f 67  6f 4d 49 50 53 09 3a 20  |.: 1.BogoMIPS.: |
000000c0  33 38 2e 34 30 0a 46 65  61 74 75 72 65 73 09 3a  |38.40.Features.:|
000000d0  20 66 70 20 61 73 69 6d  64 20 65 76 74 73 74 72  | fp asimd evtstr|
000000e0  6d 20 63 72 63 33 32 20  63 70 75 69 64 0a 43 50  |m crc32 cpuid.CP|
000000f0  55 20 69 6d 70 6c 65 6d  65 6e 74 65 72 09 3a 20  |U implementer.: |
00000100  30 78 34 31 0a 43 50 55  20 61 72 63 68 69 74 65  |0x41.CPU archite|
00000110  63 74 75 72 65 3a 20 38  0a 43 50 55 20 76 61 72  |cture: 8.CPU var|
00000120  69 61 6e 74 09 3a 20 30  78 30 0a 43 50 55 20 70  |iant.: 0x0.CPU p|
00000130  61 72 74 09 3a 20 30 78  64 30 33 0a 43 50 55 20  |art.: 0xd03.CPU |
00000140  72 65 76 69 73 69 6f 6e  09 3a 20 34 0a 0a 70 72  |revision.: 4..pr|
00000150  6f 63 65 73 73 6f 72 09  3a 20 32 0a 42 6f 67 6f  |ocessor.: 2.Bogo|
00000160  4d 49 50 53 09 3a 20 33  38 2e 34 30 0a 46 65 61  |MIPS.: 38.40.Fea|
00000170  74 75 72 65 73 09 3a 20  66 70 20 61 73 69 6d 64  |tures.: fp asimd|
00000180  20 65 76 74 73 74 72 6d  20 63 72 63 33 32 20 63  | evtstrm crc32 c|
00000190  70 75 69 64 0a 43 50 55  20 69 6d 70 6c 65 6d 65  |puid.CPU impleme|
000001a0  6e 74 65 72 09 3a 20 30  78 34 31 0a 43 50 55 20  |nter.: 0x41.CPU |
000001b0  61 72 63 68 69 74 65 63  74 75 72 65 3a 20 38 0a  |architecture: 8.|
000001c0  43 50 55 20 76 61 72 69  61 6e 74 09 3a 20 30 78  |CPU variant.: 0x|
000001d0  30 0a 43 50 55 20 70 61  72 74 09 3a 20 30 78 64  |0.CPU part.: 0xd|
000001e0  30 33 0a 43 50 55 20 72  65 76 69 73 69 6f 6e 09  |03.CPU revision.|
000001f0  3a 20 34 0a 0a 70 72 6f  63 65 73 73 6f 72 09 3a  |: 4..processor.:|
00000200  20 33 0a 42 6f 67 6f 4d  49 50 53 09 3a 20 33 38  | 3.BogoMIPS.: 38|
00000210  2e 34 30 0a 46 65 61 74  75 72 65 73 09 3a 20 66  |.40.Features.: f|
00000220  70 20 61 73 69 6d 64 20  65 76 74 73 74 72 6d 20  |p asimd evtstrm |
00000230  63 72 63 33 32 20 63 70  75 69 64 0a 43 50 55 20  |crc32 cpuid.CPU |
00000240  69 6d 70 6c 65 6d 65 6e  74 65 72 09 3a 20 30 78  |implementer.: 0x|
00000250  34 31 0a 43 50 55 20 61  72 63 68 69 74 65 63 74  |41.CPU architect|
00000260  75 72 65 3a 20 38 0a 43  50 55 20 76 61 72 69 61  |ure: 8.CPU varia|
00000270  6e 74 09 3a 20 30 78 30  0a 43 50 55 20 70 61 72  |nt.: 0x0.CPU par|
00000280  74 09 3a 20 30 78 64 30  33 0a 43 50 55 20 72 65  |t.: 0xd03.CPU re|
00000290  76 69 73 69 6f 6e 09 3a  20 34 0a 0a              |vision.: 4..|
0000029c
Dr-Noob commented 9 months ago

Okay, so the issue is not that the /proc/cpuinfo file is using spaces. The problem is that your /proc/cpuinfo does not contain the Revision field that is mandatory for SoC identification (more info here. Also related to #91).

I think this is supposed to be mandatory field in /proc/cpuinfo in all Raspberry Pis, but maybe because you are not running the official OS then it does not show. So cpufetch cannot do more that what it is currently doing: report the error. Without that field there's no way to detect the SoC according to the official Raspberry Pi webpage.