bpi-cm5-cpu-thermal-throttling-monitor-7.ino

Banana Pi BPI-CM5 : Module Compute SoC Amlogic A311D2 compatible Raspberry Pi CM4 · Fichier : bpi-cm5-cpu-thermal-throttling-monitor-7.ino · Langage : python · Usage : Surveiller la température des cœurs CPU (Cortex-A73/A53) et détecter le throttling thermique.

Script Python lisant les capteurs thermiques du SoC Amlogic A311D2 et alertant en cas de surchauffe.

Utilisez le module 'psutil' et l'accès direct aux fichiers sysfs thermiques. La BPI-CM5 nécessite un bon refroidissement passif ou actif. Ce script vérifie la fréquence CPU pour détecter le throttling. Exécutez avec sudo pour un accès complet aux capteurs.

bpi-cm5-cpu-thermal-throttling-monitor-7.ino

#!/usr/bin/env python3
import os
import time
import subprocess

# Path to thermal zones for Amlogic A311D2 (adjust if needed based on kernel version)
# Usually /sys/class/thermal/thermal_zone*/temp
TEMP_PATH = "/sys/class/thermal/thermal_zone0/temp"

def get_cpu_temp():
    try:
        with open(TEMP_PATH, 'r') as f:
            return int(f.read().strip()) / 1000.0
    except Exception:
        return -1

def get_cpu_freq():
    try:
        result = subprocess.run(["grep", "cpu MHz", "/proc/cpuinfo"], capture_output=True, text=True)
        lines = result.stdout.split('\n')
        freqs = [float(line.split(':')[1].strip()) for line in lines if 'cpu MHz' in line]
        return max(freqs) if freqs else 0
    except Exception:
        return 0

print("Monitoring BPI-CM5 A311D2 Thermal Status...")
while True:
    temp = get_cpu_temp()
    freq = get_cpu_freq()
    status = "NORMAL"
    if temp > 80.0:
        status = "CRITICAL - THROTTLING LIKELY"
    elif temp > 70.0:
        status = "WARNING"
    
    print(f"Temp: {temp:.1f} C | Max Freq: {freq:.0f} MHz | Status: {status}")
    time.sleep(5)

← Retour à la fiche