🛠 Premier script Python : état de la carte

ODROID-M1 (Hardkernel) · debutant · Schéma : IMG-odroid-m1-debutant-3-odroidm1-premier-script-python.svg — ODROID-M1 avec son SSD NVMe M.2, un terminal affichant le rapport système généré par le script Python

Objectives

Write your first useful Python script on the ODROID-M1: a status report that displays the RK3568B2 processor (quad Cortex-A55 up to 2 GHz), LPDDR4 RAM (4 or 8 GB), the boot medium, and the M.2 NVMe SSD (PCIe 3.0 x2, approximately 1600 MB/s measured).

Hardware

Complete Code

#!/usr/bin/env python3
"""Rapport d'état de l'ODROID-M1 (aucune dépendance)."""
import shutil, os, re

def cpu:
    txt = open("/proc/cpuinfo").read
    n = len(re.findall(r"^processor", txt, re.M))
    return f"{n} coeur(s) détectés (attendu : 4 Cortex-A55)"

def memo:
    for l in open("/proc/meminfo"):
        if l.startswith("MemTotal"):
            return f"RAM : {int(l.split[1]) // 1048576} Go"

def disque:
    n = shutil.disk_usage("/")
    return f"Racine : {n.used // 2**30} Go utilisés / {n.total // 2**30} Go"

print("== Rapport ODROID-M1 ==")
print(cpu); print(memo); print(disque)
nvme = [p for p in os.listdir("/dev") if p.startswith("nvme")]
print("NVMe M.2 :", nvme if nvme else "aucun SSD installé")

Expected Verification

The script displays 4 cores, the RAM (4 or 8 GB), root disk usage, and the list of nvme0n1 devices if an M.2 SSD is present.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials