Dr-Noob / cpufetch

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

Allwinner ARM SoCs #130

Closed Popolon closed 2 years ago

Popolon commented 3 years ago

I wrote this but I'm not sure about the syntax, with: Name, Series, ENUM, soc, "technology"/"process" I only put SoC where the technology is known from the page in link. This is a wiki of people working on open source driver for AllWinner SoCs, mainly by reverse engineering.

// https://linux-sunxi.org/Allwinner_SoC_Family
bool match_allwinner(char* soc_name, struct system_on_chip* soc) {
  char* tmp;

  if((tmp = strstr(soc_name, "sunxi")) == NULL)
    return false;

  SOC_START
  // A series 32 bits
  SOC_EQ(tmp, "A10",   "sun4i",       SOC_ALLWINNER_A10,   soc, 55)
  SOC_EQ(tmp, "A13",   "sun5i",       SOC_ALLWINNER_A13,   soc, 55)
  SOC_EQ(tmp, "A10s",  "sun5i",       SOC_ALLWINNER_A10S,  soc, 55)
  SOC_EQ(tmp, "A20",   "sun7i",       SOC_ALLWINNER_A20,   soc, 40)
  SOC_EQ(tmp, "A23",   "sun8i",       SOC_ALLWINNER_A23,   soc, 40)
  SOC_EQ(tmp, "A31",   "sun6i",       SOC_ALLWINNER_A31,   soc, 40)
  SOC_EQ(tmp, "A31s",  "sun6i",       SOC_ALLWINNER_A31S,  soc, 40)
  SOC_EQ(tmp, "A33",   "sun8i",       SOC_ALLWINNER_A33,   soc, 40)
  SOC_EQ(tmp, "A40",   "sun8i",       SOC_ALLWINNER_A40,   soc, 40)
  SOC_EQ(tmp, "A50",   "sun8i",       SOC_ALLWINNER_A50,   soc, 28)
  SOC_EQ(tmp, "A80",   "sun9i",       SOC_ALLWINNER_A80,   soc, 28)
  SOC_EQ(tmp, "A83T",  "sun8i",       SOC_ALLWINNER_A83T,  soc, 28)

  // H series 32 bits
  SOC_EQ(tmp, "H2+",   "sun8i",       SOC_ALLWINNER_HZP,   soc, 40)
  SOC_EQ(tmp, "H3",    "sun8i",       SOC_ALLWINNER_H3,    soc, 40)
  SOC_EQ(tmp, "H8",    "sun8i",       SOC_ALLWINNER_H8,    soc, 28)

  // H series 64 bits
  SOC_EQ(tmp, "H5",    "sun50i",      SOC_ALLWINNER_H5,    soc, 40)
  SOC_EQ(tmp, "H6",    "sun50i",      SOC_ALLWINNER_H6,    soc, 28)
  SOC_EQ(tmp, "H616",  "sun50i",      SOC_ALLWINNER_H616,  soc, 28)

  // R series 32 bits
  SOC_EQ(tmp, "R8",    "sun5i",       SOC_ALLWINNER_R8,    soc, 55)
  SOC_EQ(tmp, "R16",   "sun8i",       SOC_ALLWINNER_R16,   soc, 40)
  SOC_EQ(tmp, "R40",   "sun8i",       SOC_ALLWINNER_R40,   soc, 40)
  SOC_EQ(tmp, "R58",   "sun8i",       SOC_ALLWINNER_R58,   soc, 28)

  // R series  64 bits
  SOC_EQ(tmp, "R329",  "sun50i",      SOC_ALLWINNER_R328,  soc, 28)

  SOC_END
}
Dr-Noob commented 3 years ago

Thanks for the idea and the webpage.

Looks good but there is an issue with this. The most important part of the code is to detect the SoC. Filling the name, technology, etc is easy, but the hard thing is to actually detect the SoC. To do so, cpufetch will look at /proc/cpuinfo and read the Hardware line, and will try to match it against the string that you use in match_xxx.

For example, let's look at the Pinephone, which has Allwinner A64 (see this link). The reported hardware in this case is sun50iw1p1 which could be shortened to sun50i. Following the URL that you posted we can build a function like yours and actually match the CPU against the sun50i string. But here is the thing. There are a lot of SoCs that can be matched with sun50i. In the webpage (see this table), if we use sun50iw1p1, it can be either A64, H64, or R18...

So it seems that it is impossible to unequivocally detect a Allwiner SoC by its name in /proc/cpuinfo

Popolon commented 3 years ago

Thanks for your answer. If /proc/cpuinfo is used, so here is the full answer for my Allwinner A20 as reference (I masked the serial number). The Hardware field contains : "Allwinner $family ($model) Family"

Hardware : Allwinner sun7i (A20) Family

processor   : 0
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 50.52
Features    : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xc07
CPU revision    : 4

processor   : 1
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 50.52
Features    : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xc07
CPU revision    : 4

Hardware    : Allwinner sun7i (A20) Family
Revision    : 0000
Serial      : xxxxxxxxxxxxxxxxx
Dr-Noob commented 2 years ago

Alright, I have just pushed a commit to feat2 branch to include Allwinner SoCs. Can you test the new commit in your machine/s and report your results here? Remember to do git checkout feat2 after downloading the code to test the latest commit.

I'm worried about this since there may be SoCs that may not be detected using this code (because the naming scheme change). But at least this should work for some SoCs. Let's see.

Popolon commented 2 years ago

I made a :

git pull
git checkout feat2
make
./cpufetch

works well, but still doesn't display the "Technology":

 SoC:                 Allwinner sun7i (A20) Family
 Technology:          Unknown
 Microarchitecture:   Cortex-A7
 Max Frequency:       960 MHz
 Cores:               2 cores
 Features:            NEON
 Peak Performance:    7.68 GFLOP/s
Popolon commented 2 years ago

Also among features, this one has edsp as returned by cat /proc/cpuinfo: Features : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm

https://developer.arm.com/architectures/instruction-sets/dsp-extensions

Dr-Noob commented 2 years ago

That's really strange. Can you run the program with -v? (run cpufetch -v)

Popolon commented 2 years ago
./cpufetch -v
[WARNING]: SoC detection failed using /proc/cpuinfo: Found 'Allwinner sun7i (A20) Family' string

Looks like something went wrong during the previous checkout. when I type git branch, I'm on master;

So I removed my copy of the repository, created a new one, made a new checkout feat2 and now git branch display I'm in feat2 branch.

And that's now OK :). Thank you very much.



                #################              
          .########             #####    ####  
       ######                        #######   
    #####.    ##             ..##     ####.    SoC:                 Allwinner A20
  .####      ####          #####     ####      Technology:          40nm
 ####       ## ###          ###.   #####  .    Microarchitecture:   Cortex-A7
####       ##   ## ####   .###### ####*   .    Max Frequency:       960 MHz
###       ##  ##.###  ## #### .######          Cores:               2 cores
###      #.##     ###  #####   #####    .      Features:            NEON
###     ###        ### .###     ###    .       Peak Performance:    7.68 GFLOP/s
 #### ###          ####             #.         
   ####                          #*            
      #####                 ##.                
            ###########.                       
Dr-Noob commented 2 years ago

Nice! I'll merge the changes into the master branch.

Thanks for the feedback. For now I'm closing the issue. I will consider which reported ARM features should cpufetch display for future enhancements.