🛠 Surveillance thermique et fréquence du RK3568B2
Objectives
Set up continuous monitoring of the RK3568B2 temperature and frequency: read thermal zones and cpufreq policies, trigger script-based alerts, and understand the board's thermal behavior (FriendlyElec has never seen the CPU exceed 50 °C in a passive metal case; operating range 0-70 °C). You will write a systemd daemon that periodically logs and alerts above a threshold, useful before installing the board in a network enclosure without airflow.
Hardware
- NanoPi R5S running Debian/Ubuntu/Armbian, preferably in a metal case (the passive heatsink is part of the case)
- Optional: 5 V fan on the dedicated ZH1.5 connector
- Packages:
apt install lm-sensors(sensors);stress-ngfor test load
Complete Code
#!/bin/bash
# surveille_r5s.sh — journalise température + fréquences, alerte > 65 °C
# (seuil bas car la spec max est 70 °C ambiants 0-70)
LOG=/var/log/r5s-thermal.csv
THRESH=65000 # milli-°C
[ -f "$LOG" ] || echo "date,temp_mC,cpu0_kHz,cpu3_kHz" > "$LOG"
while :; do
T=$(cat /sys/class/thermal/thermal_zone*/temp 2>/dev/null | head -1)
T=${T:-0}
F0=$(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq)
F3=$(cat /sys/devices/system/cpu/cpufreq/policy4/scaling_cur_freq 2>/dev/null || echo 0)
echo "$(date -Is),$T,$F0,$F3" >> "$LOG"
if [ "$T" -gt "$THRESH" ]; then
logger -t r5s-thermal "ALERTE température ${T}m°C (seuil ${THRESH}m°C)"
fi
sleep 30
done
# Test de charge : stress-ng --cpu 4 --timeout 300
# Ordonnanceur/gouverneur : cat /sys/.../policy0/scaling_governor (schedutil)
# Installer en service :
# cp surveille_r5s.sh /usr/local/bin/ puis unit systemd Type=simple
Expected Verification
After running stress-ng --cpu 4 --timeout 300, the CSV shows the temperature rise (staying below ~50-55 °C in a metal case) and frequencies close to 2000 MHz as long as throttling does not kick in. cat /sys/class/thermal/thermal_zone*/type identifies the cpu zone. The systemd service starts at boot (systemctl status r5s-thermal). If the temperature approaches 65 °C, check the case (the metal acts as a heatsink), the confined location, or add the fan on the ZH1.5 connector.
Common Errors
- Getting the units wrong: temp is in milli-°C (42000 = 42 °C), scaling_cur_freq is in kHz.
- Comparing strings with
-gtwithout removing line breaks: use clean$(cat ...)ortr -d. - policy0/policy4: on RK3568, the four A55 cores are generally under a single policy; test the existence of paths before reading them.
- Believing lm-sensors is infallible: on Rockchip, direct reading from /sys/class/thermal is often more reliable than
sensorsdepending on the kernel. - Monitoring without ever testing under load: a poorly ventilated case only reveals itself with stress-ng for 5-10 minutes.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash