Dr-Noob / cpufetch

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

Add support for Freescale i.MX8MP SoC (ARM) / MNT Pocket Reform #261

Closed andypiper closed 3 months ago

andypiper commented 3 months ago

Noted that new features / platforms should be submitted as issues rather than sending a PR.

Currently, the above SoC shows as Unknown.

It's a Cortex A53 and I'm running Debian unstable (which is what ships on the Pocket Reform)

$ cpufetch --logo-short                                                                                                                                           
                                          SoC:                 Unknown
   #####  ##   # #####  ## ####  ######   Technology:          Unknown
 ###    ####   ###      ####  ###   ###   Microarchitecture:   Cortex-A53
###       ##   ###      ###    ##    ###  Max Frequency:       2.000 GHz
 ###    ####   ###      ###    ##    ###  Cores:               4 cores
  ######  ##   ###      ###    ##    ###  Features:            NEON,SHA1,SHA2,AES,CRC32
                                          Peak Performance:    64.00 GFLOP/s
$ cpufetch -d
cpufetch v1.05-38-gf631 (Linux ARM build)
[Core 0] 0x410FD034 2000 MHz
[Core 1] 0x410FD034 2000 MHz
[Core 2] 0x410FD034 2000 MHz
[Core 3] 0x410FD034 2000 MHz
$ cpufetch -v                                                                                                                                                     
[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
[WARNING]: read_file: /sys/bus/nvmem/devices/rockchip-otp0/nvmem: No such file or directory

[plus standard output]

Here is some additional system information that may be useful:

$ cat /proc/device-tree/compatible                                             
mntre,pocket-reformboundary,imx8mp-nitrogen8mp-somfsl,imx8mp%

$ cat /proc/cpuinfo
processor   : 0
BogoMIPS    : 16.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 1
BogoMIPS    : 16.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 2
BogoMIPS    : 16.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 3
BogoMIPS    : 16.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

$ rg i.MX /sys --no-messages                                                                                                                       

/sys/devices/soc0/family
1:Freescale i.MX

/sys/devices/soc0/soc_id
1:i.MX8MP

/sys/devices/soc0/machine
1:MNT Pocket Reform with i.MX8MP Module

/sys/devices/system/clockevents/broadcast/current_device
1:i.MX system counter timer

/sys/devices/platform/soc@0/3d800000.ddr-pmu/imx8_ddr0/identifier
1:i.MX8MP 

$ lscpu                                                                        
Architecture:             aarch64
  CPU op-mode(s):         32-bit, 64-bit
  Byte Order:             Little Endian
CPU(s):                   4
  On-line CPU(s) list:    0-3
Vendor ID:                ARM
  Model name:             Cortex-A53
    Model:                4
    Thread(s) per core:   1
    Core(s) per cluster:  4
    Socket(s):            -
    Cluster(s):           1
    Stepping:             r0p4
    CPU(s) scaling MHz:   100%
    CPU max MHz:          2000.0000
    CPU min MHz:          1200.0000
    BogoMIPS:             16.00
    Flags:                fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
Caches (sum of all):
  L1d:                    128 KiB (4 instances)
  L1i:                    128 KiB (4 instances)
  L2:                     512 KiB (1 instance)
NUMA:
  NUMA node(s):           1
  NUMA node0 CPU(s):      0-3
Vulnerabilities:
  Gather data sampling:   Not affected
  Itlb multihit:          Not affected
  L1tf:                   Not affected
  Mds:                    Not affected
  Meltdown:               Not affected
  Mmio stale data:        Not affected
  Reg file data sampling: Not affected
  Retbleed:               Not affected
  Spec rstack overflow:   Not affected
  Spec store bypass:      Not affected
  Spectre v1:             Mitigation; __user pointer sanitization
  Spectre v2:             Not affected
  Srbds:                  Not affected
  Tsx async abort:        Not affected

Let me know if I can provide any other diagnostic information that would help here.

Dr-Noob commented 3 months ago

Wow, nice PC! cpufetch does have a lot of ways to infer the SoC, but in this case it seems to be not enough. The only (kind of) portable way I can see here is using /proc/device-tree/compatible as I already do for RISC-V SoC detection. This hasn't been implemented for ARM yet, but now I have a good motivation to do so. I'll schedule some time to work on this :+1:

Dr-Noob commented 3 months ago

The information online is a bit confusing:

Please let me know if my understanding is correct. I have pushed a patch in branch i261. If you are happy with it then I'll create the NXP logo and merge it into master :+1:

PS: Can I have the output of hexdump -C /proc/device-tree/compatible? cat is not showing all the truth here.

andypiper commented 3 months ago

Yes, I've been referring to it in the same way that MNT have done (mostly in IRC chats), so your approach looks right on the naming.

$ hexdump -C /proc/device-tree/compatible                                                                                                                                             
00000000  6d 6e 74 72 65 2c 70 6f  63 6b 65 74 2d 72 65 66  |mntre,pocket-ref|
00000010  6f 72 6d 00 62 6f 75 6e  64 61 72 79 2c 69 6d 78  |orm.boundary,imx|
00000020  38 6d 70 2d 6e 69 74 72  6f 67 65 6e 38 6d 70 2d  |8mp-nitrogen8mp-|
00000030  73 6f 6d 00 66 73 6c 2c  69 6d 78 38 6d 70 00     |som.fsl,imx8mp.|
0000003f
andypiper commented 3 months ago

Branch i261 results

$ ./cpufetch                                                                                                                                                                            

                                                  SoC:                 NXP i.MX 8M Plus
                                                  Technology:          14nm
                                                  Microarchitecture:   Cortex-A53
                                                  Max Frequency:       2.000 GHz
                                                  Cores:               4 cores
                                                  Features:            NEON,SHA1,SHA2,AES,CRC32
                                                  Peak Performance:    64.00 GFLOP/s

Looks good to me, the logo is optional as the generic ARM logo was fine in my opinion! 👍🏻 thanks for the effort here.

The Pocket Reform (and mainline Reform) support alternative CPU modules as well, including the Banana Pi CM4 which is an A311D (which I have access to) and the Rockchip RK3588 (which I have coming in the future), so I'll be happy to see how those show up in cpufetch as well.

Nice work.

Dr-Noob commented 3 months ago

Awesome! I have added the NXP logo (feedback is welcomed) and merged this into master. The ARM logo is a fallback when cpufetch knows it's an ARM CPU but does not know the specific SoC.

Closing this, and looking forward your report for the hardware you mentioned in case it does not work. I expect the Banana Pi CM4 not to work and the RK3588 to work (I have a Rockchip as well so I try to give a good support for RK SoCs). Thanks! :+1:

PS: I'd also be interested in adding support for other NXP SoCs such as i.MX 6/7/8 but cannot find a good source to find the corresponding value in /proc/device-tree/compatible...