Dr-Noob / cpufetch

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

Rockchip RK35xx detection flaws #209

Closed ThomasKaiser closed 5 months ago

ThomasKaiser commented 7 months ago

Hi there,

starting from at least RK35xx Rockchip seems to have reverted the relevant SoC bits (confirmed with at least RK3528, RK3566, RK3568 and RK3588/RK3588s):

RK3568 in NanoPi R5S:

root@nanopi-r5s:/home/tk# /usr/local/src/cpufetch/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
[ERROR]: RK SoC was found but it does not match any known SoCs: 0x3568
[VERSION]: cpufetch v1.04-30-g2fee (Linux ARM build)

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            Microarchitecture:   Cortex-A55
                                                            Max Frequency:       1.992 GHz
                                                            Cores:               4 cores
                                                            Features:            NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    63.74 GFLOP/s

root@nanopi-r5s:/home/tk# /usr/local/src/cpufetch/cpufetch -d
[ERROR]: RK SoC was found but it does not match any known SoCs: 0x3568
[VERSION]: cpufetch v1.04-30-g2fee (Linux ARM build)
cpufetch v1.04-30-g2fee (Linux ARM build)
[Core 0] 0x412FD050 1992 MHz
[Core 1] 0x412FD050 1992 MHz
[Core 2] 0x412FD050 1992 MHz
[Core 3] 0x412FD050 1992 MHz

root@nanopi-r5s:/home/tk# hexdump -C </sys/bus/nvmem/devices/rockchip-otp0/nvmem
00000000  52 4b 35 68 02 00 fe 42  10 01 54 47 31 43 31 38  |RK5h...B..TG1C18|
00000010  00 00 00 00 00 00 00 04  17 10 26 3f 05 0a 00 00  |..........&?....|
00000020  00 00 00 00 00 00 00 00  00 00 1f 22 00 00 00 00  |..........."....|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000080

root@nanopi-r5s:/home/tk# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:    12
Codename:   bookworm

And the RK3588 in my Rock-5B is wrongly reported as RK3588s:

root@rock-5b:/home/tk# /usr/local/src/cpufetch/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

                                                          SoC:                 Rockchip RK3588S
                                                          Technology:          8nm
                                                          CPU 1:
                                              ##            Microarchitecture: Cortex-A55
   ######                ##            ##                   Max Frequency:     1.800 GHz
  ##.  ### ##### #####  ## .## #####  ######. ##   #####    Cores:             4 cores
 #######. ##. # #.     #####  ##.    ###  ###  #     .##    Features:          NEON,SHA1,SHA2,AES,CRC32
##.  ###.  ####. #### ###  .## #### ###  ###   #.#####    CPU 2:
                                                ##          Microarchitecture: Cortex-A76
                                                            Max Frequency:     2.400 GHz
                                                            Cores:             4 cores
                                                            Features:          NEON,SHA1,SHA2,AES,CRC32
                                                          Peak Performance:    211.20 GFLOP/s

root@rock-5b:/home/tk# /usr/local/src/cpufetch/cpufetch -d
cpufetch v1.04-30-g2fee (Linux ARM build)
[Core 0] 0x412FD050 1800 MHz
[Core 1] 0x412FD050 1800 MHz
[Core 2] 0x412FD050 1800 MHz
[Core 3] 0x412FD050 1800 MHz
[Core 4] 0x414FD0B0 2400 MHz
[Core 5] 0x414FD0B0 2400 MHz
[Core 6] 0x414FD0B0 2400 MHz
[Core 7] 0x414FD0B0 2400 MHz

root@rock-5b:/home/tk# hexdump -C </sys/bus/nvmem/devices/rockchip-otp0/nvmem
00000000  52 4b 35 88 91 fe 21 41  5a 43 34 31 00 00 00 00  |RK5...!AZC41....|
00000010  00 00 00 00 02 0c 09 12  12 15 3e 1c 00 00 00 00  |..........>.....|
00000020  00 00 00 00 00 00 00 00  0e 1a 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400

root@rock-5b:/home/tk# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:    20.04
Codename:   focal
Dr-Noob commented 5 months ago

Thanks for the information! Indeed, it seems like they changed the order at some point. I've pushed a commit that should fix it, can you confirm if it works in your machines?

ThomasKaiser commented 5 months ago

RK3588 gets now 'detected' as that:

root@rock-5b:/home/tk# /usr/local/src/cpufetch/cpufetch 

                                                          SoC:                 Rockchip RK3588
                                                          Technology:          8nm
                                                          CPU 1:
                                              ##            Microarchitecture: Cortex-A55
   ######                ##            ##                   Max Frequency:     1.800 GHz
  ##.  ### ##### #####  ## .## #####  ######. ##   #####    Cores:             4 cores
 #######. ##. # #.     #####  ##.    ###  ###  #     .##    Features:          NEON,SHA1,SHA2,AES,CRC32
##.  ###.  ####. #### ###  .## #### ###  ###   #.#####    CPU 2:
                                                ##          Microarchitecture: Cortex-A76
                                                            Max Frequency:     2.400 GHz
                                                            Cores:             4 cores
                                                            Features:          NEON,SHA1,SHA2,AES,CRC32
                                                          Peak Performance:    211.20 GFLOP/s

My own try to distinguish between RK3588 and RK3588S is here:

Few NVMEM samples collected (in brackets the SoC revision according to dmesg output)

RK3588s:
NanoPi R6C (35880000)        52 4b 35 88 91 fe 33 41  5a 43 39 36 00 00 00 00  |RK5...3AZC96....|
NanoPi R6C (35881000)        52 4b 35 88 12 fe 33 41  32 47 50 4b 00 00 00 00  |RK5...3A2GPK....|
Orange Pi 5 (35880000)       52 4b 35 88 12 fe 33 41  32 38 4b 47 00 00 00 00  |RK5...3A28KG....|
ROCK 5A (35881000)           52 4b 35 88 12 fe 33 41  32 4e 55 57 00 00 00 00  |RK5...3A2NUW....|
                                               ^^
RK3588:
Orange Pi 5 Plus (35880000)  52 4b 35 88 12 fe 21 41  32 42 44 4e 00 00 00 00  |RK5...!A2BDN....|
Orange Pi 5 Plus (35881000)  52 4b 35 88 12 fe 21 41  32 4e 48 46 00 00 00 00  |RK5...!A2NHF....|
ROCK 5B (35880000)           52 4b 35 88 12 fe 21 41  32 34 39 57 00 00 00 00  |RK5...!A249W....|
ROCK 5B (35880000)           52 4b 35 88 12 fe 21 41  32 38 43 35 00 00 00 00  |RK5...!A28C5....|
ROCK 5B (35880000)           52 4b 35 88 12 fe 21 41  32 38 46 55 00 00 00 00  |RK5...!A28FU....|
ROCK 5B (35880000)           52 4b 35 88 12 fe 21 41  32 38 52 34 00 00 00 00  |RK5...!A28R4....|
ROCK 5B (35880000)           52 4b 35 88 12 fe 21 41  32 47 50 48 00 00 00 00  |RK5...!A2GPH....|
ROCK 5B (35880000)           52 4b 35 88 91 fe 21 41  5a 43 34 31 00 00 00 00  |RK5...!AZC41....|
                                               ^^

But same situation as before with RK3568 (since a typo slipped in):

root@nanopi-r5s:/home/tk# /usr/local/src/cpufetch/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
[ERROR]: RK SoC was found but it does not match any known SoCs: 0x3568
[VERSION]: cpufetch v1.04-35-g5e00 (Linux ARM build)

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            Microarchitecture:   Cortex-A55
                                                            Max Frequency:       1.992 GHz
                                                            Cores:               4 cores
                                                            Features:            NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    63.74 GFLOP/s

After manually fixing the typo it works as expected:

root@nanopi-r5s:/usr/local/src/cpufetch# ./cpufetch 

                                                          SoC:                 Rockchip RK3568
                                              ##          Technology:          22nm
   ######                ##            ##                 Microarchitecture:   Cortex-A55
  ##.  ### ##### #####  ## .## #####  ######. ##   #####  Max Frequency:       1.992 GHz
 #######. ##. # #.     #####  ##.    ###  ###  #     .##  Cores:               4 cores
##.  ###.  ####. #### ###  .## #### ###  ###   #.#####    Features:            NEON,SHA1,SHA2,AES,CRC32
                                                ##        Peak Performance:    63.74 GFLOP/s
Dr-Noob commented 5 months ago

Thanks again for your feedback, I've fixed the typo. Regarding RK3588/S, checking dmesg is not something that I will do for now, maybe in the future we find more straightforward ways. For now I'm closing this issue, but I'll keep an eye on future updates on this :+1:

ThomasKaiser commented 5 months ago

Regarding RK3588/S, checking dmesg is not something that I will do for now

Sorry for the misunderstanding. 'My' differentiation is solely based on nvmem contents (byte 7: 33 vs. 21), the only thing derived from parsing dmesg is the 'SoC revision' as I call it to check whether this difference is consistent.