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

Banana Pi BPI-CM5: Módulo de cómputo SoC Amlogic A311D2 compatible con Raspberry Pi CM4 · Archivo : bpi-cm5-cpu-thermal-throttling-monitor-7.ino · Lenguaje : python · Uso : Surveiller la température des cœurs CPU (Cortex-A73/A53) et détecter le throttling thermique.

Script Python que lee los sensores térmicos del SoC Amlogic A311D2 y alerta en caso de sobrecalentamiento.

Usa el módulo 'psutil' y acceso directo a archivos sysfs térmicos. La BPI-CM5 requiere buen enfriamiento pasivo o activo. Este script verifica la frecuencia de la CPU para detectar el throttling. Ejecutar con sudo para acceso completo a los sensores.

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)

← Volver a la ficha