manjaro / mdd

Manjaro Data Donor - WIP
MIT License
12 stars 3 forks source link

Add support for aarch64 architecture in get_cpu_info #2

Closed fhdk closed 2 weeks ago

fhdk commented 2 weeks ago

This PR updates the get_cpu_info function to handle the aarch64 architecture by checking for the appropriate CPU model identifier. It sets the default CPU model to "unknown" and adds error handling for missing model information. This ensures accurate data retrieval across different CPU architectures.

It also updates the get_system_info function to use values from /proc/device-tree/compatible

fhdk commented 2 weeks ago

Raspberry Pi 4

Dry run on Raspberry Pi 4

[fh@rpi41 mdd]$ python mdd.py --dry-run
Welcome to MDD - The Manjaro Data Donor
Preparing data submission...
cat: /sys/devices/virtual/dmi/id/product_name: No such file or directory
cat: /sys/devices/virtual/dmi/id/product_family: No such file or directory
cat: /sys/devices/virtual/dmi/id/sys_vendor: No such file or directory
cat: /sys/devices/virtual/dmi/id/board_name: No such file or directory

------------------------------------------
 Would send the following data (dry run)
------------------------------------------
{
    "meta": {
        "version": 1,
        "timestamp": "2024-11-02T15:34:13.434315+00:00",
        "device_id": "21900356-2ac7-5aca-8258-148fa1186048",
        "distro_id": "manjaro-arm",
        "release": "24.04",
        "inxi": true
    },
    "system": {
        "kernel": "6.6.58-1-MANJARO-RPI4",
        "form_factor": "",
        "install_date": "2024-07-01T06:59:58+00:00",
        "product_name": null,
        "product_family": null,
        "sys_vendor": null,
        "board_name": null
    },
    "boot": {
        "uefi": false,
        "uptime_seconds": 110677
    },
    "cpu": {
        "arch": "aarch64",
        "model": "cortex-a72",
        "cores": 4,
        "threads": 4
    },
    "memory": {
        "ram_gb": 7.624652862548828,
        "swap_gb": 11.43697738647461
    },
    "graphics": {
        "comp": "unknown",
        "dri": null,
        "gpus": [
            {
                "vendor": null,
                "model": "bcm2711-hdmi0",
                "driver": "vc4_hdmi"
            },
            {
                "vendor": null,
                "model": "bcm2711-hdmi1",
                "driver": "vc4_hdmi"
            },
            {
                "vendor": null,
                "model": "bcm2711-vc5",
                "driver": "vc4_drm"
            }
        ],
        "outputs": []
    },
    "audio": {
        "servers": []
    },
    "disk": {
        "disks": [
            {
                "size_gb": 14.7265625,
                "root": {
                    "size_gb": 14.249724864959717,
                    "fstype": "ext4",
                    "crypt": false
                },
                "home": null
            }
        ],
        "windows": false
    },
    "locale": {
        "region": "en_DK.UTF-8",
        "language": "en",
        "timezone": "Europe/Copenhagen"
    },
    "package": {
        "last_update": "2024-11-02T16:03:11+01:00",
        "branch": "arm-unstable",
        "pkgs": 368,
        "foreign_pkgs": 2,
        "pkgs_update_pending": 0,
        "flatpaks": 0,
        "pacman_mirrors": {
            "total": 1,
            "ok": 1,
            "country_config": "Austria"
        }
    },
    "desktop": {
        "cli": "/bin/bash"
    }
}
------------------------------------------

Note: Skipping data submission because of dry run.
romangg commented 2 weeks ago

Output looks good. Would it make sense to make cpus an array like with gpus to query all cpu chips an ARM chip might have?

philmmanjaro commented 2 weeks ago

We also should only cat those /sys/devices/virtual/dmi endpoints when they are available. So adding a check for that might remove those cat errors displayed.

fhdk commented 2 weeks ago

Added check for aarch to return usable info instead of dmi calls

Raspberry Pi 4

dry run on rpi4

[fh@rpi41 mdd]$ python mdd.py --dry-run
Welcome to MDD - The Manjaro Data Donor
Preparing data submission...

------------------------------------------
 Would send the following data (dry run)
------------------------------------------
{
    "meta": {
        "version": 1,
        "timestamp": "2024-11-03T06:34:16.890118+00:00",
        "device_id": "21900356-2ac7-5aca-8258-148fa1186048",
        "distro_id": "manjaro-arm",
        "release": "24.04",
        "inxi": true
    },
    "system": {
        "kernel": "6.6.59-1-MANJARO-RPI4",
        "form_factor": "single board computer",
        "install_date": "2024-07-01T06:59:58+00:00",
        "product_name": "Raspberry Pi 4 Model B Rev 1.5",
        "product_family": "bcm2711",
        "sys_vendor": "raspberrypi",
        "board_name": "4-model-b brcm"
    },
    "boot": {
        "uefi": false,
        "uptime_seconds": 53353
    },
    "cpu": {
        "arch": "aarch64",
        "model": "cortex-a72",
        "cores": 4,
        "threads": 4
    },
    "memory": {
        "ram_gb": 7.624652862548828,
        "swap_gb": 11.43697738647461
    },
    "graphics": {
        "comp": null,
        "dri": null,
        "gpus": [
            {
                "vendor": null,
                "model": "bcm2711-hdmi0",
                "driver": "vc4_hdmi"
            },
            {
                "vendor": null,
                "model": "bcm2711-hdmi1",
                "driver": "vc4_hdmi"
            },
            {
                "vendor": null,
                "model": "bcm2711-vc5",
                "driver": "vc4_drm"
            }
        ],
        "outputs": []
    },
    "audio": {
        "servers": []
    },
    "disk": {
        "disks": [
            {
                "size_gb": 14.7265625,
                "root": {
                    "size_gb": 14.249724864959717,
                    "fstype": "ext4",
                    "crypt": false
                },
                "home": null
            }
        ],
        "windows": false
    },
    "locale": {
        "region": "en_DK.UTF-8",
        "language": "en",
        "timezone": "Europe/Copenhagen"
    },
    "package": {
        "last_update": "2024-11-02T16:03:11+01:00",
        "branch": "arm-unstable",
        "pkgs": 370,
        "foreign_pkgs": 2,
        "pkgs_update_pending": 0,
        "flatpaks": 0,
        "pacman_mirrors": {
            "total": 1,
            "ok": 1,
            "country_config": "Austria"
        }
    },
    "desktop": {
        "cli": "/bin/bash",
        "display": "unspecified",
        "display_with": null
    }
}
------------------------------------------

Note: Skipping data submission because of dry run.
romangg commented 2 weeks ago

Do you have an ARM chip with multiple CPU chips? What chip does it pick?

fhdk commented 2 weeks ago

I have a pinebook, pinephone pro, rpi4, rpi5 and in a box somewhere, a beaglebone black - Texas instruments if I recall correct.

Does any of them fit your description - because I don't know :)

romangg commented 2 weeks ago

On an ARM system with two CPUs when you run inxi -Cxxx it should print out a variant-1 and variant-2 field.

romangg commented 2 weeks ago

Pinephone Pro has two CPUs: https://pine64.org/devices/pinephone_pro/

fhdk commented 2 weeks ago

Then I don't have it - I will boot up the pinephone

fhdk commented 2 weeks ago

I need to find a working image - it is not functional right now.

fhdk commented 2 weeks ago

pinephone-pro

[kde@manjaro-arm ~]$ inxi -Cxxx
CPU:
  Info: quad core (2-mt/2-st) model: N/A variant-1: cortex-a72 variant-2: cortex-a53 bits: 64
    type: MST AMCP smt: <unsupported> arch: ARMv8 rev: 4
  Speed (MHz): avg: 472 high: 600 min/max: 408/1008:1500 cores: 1: 408 2: 408 3: 408 4: 408
    5: 600 6: 600 bogomips: N/A
  Features: Use -f option to see features

dry run of mdd.py

[kde@manjaro-arm mdd]$ python mdd.py --dry-run
Welcome to MDD - The Manjaro Data Donor
Preparing data submission...
/usr/lib/python3.11/site-packages/tzlocal/unix.py:193: UserWarning: Can not find any timezone configuration, defaulting to UTC.
  warnings.warn("Can not find any timezone configuration, defaulting to UTC.")
[2024-11-03T12:52:55] ERROR getting update time: 'String does not contain a date: '
[2024-11-03T12:52:55] ERROR input was: ''
error: While opening repository /var/lib/flatpak/repo: opening repo: opendir(/var/lib/flatpak/repo): No such file or directory

------------------------------------------
 Would send the following data (dry run)
------------------------------------------
{
    "meta": {
        "version": 1,
        "timestamp": "2024-11-03T12:52:53.677992+00:00",
        "device_id": "4a45f6e0-bc56-5bd9-aa9c-6fd2e67265ba",
        "distro_id": "manjaro-arm",
        "release": "24.03",
        "inxi": true
    },
    "system": {
        "kernel": "6.7.5-1-MANJARO-ARM",
        "form_factor": "handset",
        "install_date": "2024-03-23T04:05:04+00:00",
        "product_name": "Pine64 PinePhonePro",
        "product_family": "rk3399",
        "sys_vendor": "pine64",
        "board_name": "pinephone-pro rockchip"
    },
    "boot": {
        "uefi": false,
        "uptime_seconds": 1544
    },
    "cpu": {
        "arch": "aarch64",
        "model": "unknown",
        "cores": 6,
        "threads": 6
    },
    "memory": {
        "ram_gb": 3.775074005126953,
        "swap_gb": 5.662609100341797
    },
    "graphics": {
        "comp": "kwin",
        "dri": null,
        "gpus": [
            {
                "vendor": null,
                "model": "display-subsystem",
                "driver": "rockchip_drm"
            },
            {
                "vendor": null,
                "model": "rk3399-mali",
                "driver": "panfrost"
            }
        ],
        "outputs": [
            {
                "model": null,
                "res": null,
                "refresh": 0,
                "dpi": 0,
                "size": null
            }
        ]
    },
    "audio": {
        "servers": [
            {
                "name": "PipeWire",
                "active": true
            },
            {
                "name": "PulseAudio",
                "active": false
            }
        ]
    },
    "disk": {
        "disks": [
            {
                "size_gb": 115.234375,
                "root": {
                    "size_gb": 114.7575216293335,
                    "fstype": "ext4",
                    "crypt": false
                },
                "home": null
            }
        ],
        "windows": false
    },
    "locale": {
        "region": "en_US.UTF-8",
        "language": "en",
        "timezone": "UTC"
    },
    "package": {
        "last_update": "unknown",
        "branch": "arm-stable",
        "pkgs": 790,
        "foreign_pkgs": 0,
        "pkgs_update_pending": 2,
        "flatpaks": 0,
        "pacman_mirrors": {
            "total": 94,
            "ok": 86,
            "country_config": ""
        }
    },
    "desktop": {
        "cli": "/bin/bash"
    }
}
------------------------------------------

Note: Skipping data submission because of dry run.
romangg commented 2 weeks ago

I would simply combine the two variants if they exist into one like cortex-a72/cortex-a53 and set model to that then.

fhdk commented 2 weeks ago

Raspberry Pi 5

[nix@nix ~]$ inxi -Cxxx
CPU:
  Info: quad core model: N/A variant: cortex-a76 bits: 64 type: MCP arch: ARMv8 rev: 1 cache:
    L1: 512 KiB L2: 2 MiB L3: 2 MiB
  Speed (MHz): avg: 1500 min/max: 1500/2400 cores: 1: 1500 2: 1500 3: 1500 4: 1500 bogomips: 432
  Features: Use -f option to see features
[nix@nix mdd]$ python mdd.py --dry-run
Welcome to MDD - The Manjaro Data Donor
Preparing data submission...

------------------------------------------
 Would send the following data (dry run)
------------------------------------------
{
    "meta": {
        "version": 1,
        "timestamp": "2024-11-03T16:12:01.794582+00:00",
        "device_id": "c52dd2d9-4f35-5c33-b2ae-c172abee033b",
        "distro_id": "manjaro-arm",
        "release": "24.04",
        "inxi": true
    },
    "system": {
        "kernel": "6.6.42-1-MANJARO-RPI5",
        "form_factor": "single board computer",
        "install_date": "2024-07-24T07:50:09+00:00",
        "product_name": "Raspberry Pi 5 Model B Rev 1.0",
        "product_family": "bcm2712",
        "sys_vendor": "raspberrypi",
        "board_name": "5-model-b brcm"
    },
    "boot": {
        "uefi": false,
        "uptime_seconds": 2413
    },
    "cpu": {
        "arch": "aarch64",
        "model": "cortex-a76",
        "cores": 4,
        "threads": 4
    },
    "memory": {
        "ram_gb": 7.86151123046875,
        "swap_gb": 11.792251586914062
    },
    "graphics": {
        "comp": "unknown",
        "dri": null,
        "gpus": [
            {
                "vendor": null,
                "model": "bcm2712-hdmi0",
                "driver": "vc4_hdmi"
            },
            {
                "vendor": null,
                "model": "bcm2712-hdmi1",
                "driver": "vc4_hdmi"
            }
        ],
        "outputs": []
    },
    "audio": {
        "servers": []
    },
    "disk": {
        "disks": [
            {
                "size_gb": 14.83740234375,
                "root": {
                    "size_gb": 14.360564708709717,
                    "fstype": "ext4",
                    "crypt": false
                },
                "home": null
            }
        ],
        "windows": false
    },
    "locale": {
        "region": "en_DK.UTF-8",
        "language": "en",
        "timezone": "Europe/Copenhagen"
    },
    "package": {
        "last_update": "2024-11-03T17:02:22+01:00",
        "branch": "arm-unstable",
        "pkgs": 231,
        "foreign_pkgs": 0,
        "pkgs_update_pending": 0,
        "flatpaks": 0,
        "pacman_mirrors": {
            "total": 1,
            "ok": 1,
            "country_config": "Austria"
        }
    },
    "desktop": {
        "cli": "/bin/bash"
    }
}
------------------------------------------

Note: Skipping data submission because of dry run.
fhdk commented 2 weeks ago

PineBook Pro

dry run

[fh@pbp mdd]$ python mdd.py --dry-run
Welcome to MDD - The Manjaro Data Donor
Preparing data submission...
[2024-11-03T16:52:53] ERROR getting update time: 'String does not contain a date: '
[2024-11-03T16:52:53] ERROR input was: ''

------------------------------------------                                                         
 Would send the following data (dry run)                                                           
------------------------------------------                                                         
{                                                                                                  
    "meta": {                                                                                      
        "version": 1,                                                                              
        "timestamp": "2024-11-03T15:52:52.019491+00:00",                                           
        "device_id": "4d6d4e6a-b515-50a4-92bf-d993bf2dc280",                                       
        "distro_id": "manjaro-arm",                                                                
        "release": "24.03",                                                                        
        "inxi": true                                                                               
    },                                                                                             
    "system": {                                                                                    
        "kernel": "6.7.9-1-MANJARO-ARM",                                                           
        "form_factor": "laptop",                                                                   
        "install_date": "2024-11-03T15:35:46+00:00",
        "product_name": "Pine64 Pinebook Pro",
        "product_family": "rk3399",
        "sys_vendor": "pine64",
        "board_name": "pinebook-pro rockchip"
    },
    "boot": {
        "uefi": false,
        "uptime_seconds": 262
    },
    "cpu": {
        "arch": "aarch64",
        "model": "unknown",
        "cores": 6,
        "threads": 6
    },
    "memory": {
        "ram_gb": 3.772380828857422,
        "swap_gb": 5.6585693359375
    },
    "graphics": {
        "comp": null,
        "dri": "rockchip",
        "gpus": [
            {
                "vendor": null,
                "model": "display-subsystem",
                "driver": "rockchip_drm"
            },
            {
                "vendor": null,
                "model": "rk3399-mali",
                "driver": "panfrost"
            }
        ],
        "outputs": [
            {
                "model": null,
                "res": null,
                "refresh": 0,
                "dpi": 0,
                "size": null
            }
        ]
    },
    "audio": {
        "servers": [
            {
                "name": "PipeWire",
                "active": true
            },
            {
                "name": "PulseAudio",
                "active": false
            }
        ]
    },
    "disk": {
        "disks": [
            {
                "size_gb": 29.72314453125,
                "root": {
                    "size_gb": 29.246291160583496,
                    "fstype": "ext4",
                    "crypt": false
                },
                "home": null
            }
        ],
        "windows": false
    },
    "locale": {
        "region": "en_DK.UTF-8",
        "language": "en",
        "timezone": "Europe/Copenhagen"
    },
    "package": {
        "last_update": "unknown",
        "branch": "arm-stable",
        "pkgs": 643,
        "foreign_pkgs": 0,
        "pkgs_update_pending": 0,
        "flatpaks": 0,
        "pacman_mirrors": {
            "total": 1,
            "ok": 1,
            "country_config": "Austria"
        }
    },
    "desktop": {
        "cli": "/bin/bash",
        "gui": "LXQt",
        "dm": "LightDM",
        "wm": "Openbox",
        "display": "x11",
        "display_with": null
    }
}
------------------------------------------
romangg commented 2 weeks ago

Is this with different code or the current code?

fhdk commented 2 weeks ago

This is your xrandr and my cpu/sysinfo code combined

romangg commented 2 weeks ago

It doesn't pick up both variants of the Pinebook Pro and the Pinebook Pro. Do you plan on fixing that, or should I take a look?

fhdk commented 2 weeks ago

Do you plan on fixing that, or should I take a look?

I cannot see through all that data - so please :smile:

You have a more clear idea of what data and where to find them.

I can provide output for

I look over the options in /proc/ - that is where I found device-tree/model - I also found compatibility which I split to fill in the device info.

But you more about what data you expect ....

I am fairly certain though that arm devices needs a parser depending on vendor and board type

romangg commented 2 weeks ago

Ok, I checked out your PR and will rebase it. Please don't use Git merges. I'm trying to rebase the branch now but the merge makes it difficult.

fhdk commented 2 weeks ago

hmm - I probably have bad habits - the code in the PR is only for sysinfo and cpu info.

Please extract those two functions - for your own code - this way you get a clear cut.

I don't mind - you don't have to accept the PR - just do what is best for your flow.

romangg commented 2 weeks ago

Hey, no worries. I actually went with nuking the branch completely with a git reset <old-rev> and then copy-pasting your changes over, afterwards doing git add -pu to create a new commit for cpu first and then system info. I copied over some of the commit messages of yours. Take a look if it's ok this way.

Afterwards a git rebase master was possible.