Skip to content

Add thermal zone configuration for CPU monitoring#88

Merged
Atomique13 merged 10 commits intomainfrom
atom/thermal
Apr 5, 2026
Merged

Add thermal zone configuration for CPU monitoring#88
Atomique13 merged 10 commits intomainfrom
atom/thermal

Conversation

@Atomique13
Copy link
Copy Markdown
Member

@Atomique13 Atomique13 commented Apr 5, 2026

Summary

Adds full CPU thermal monitoring for the Elegoo Centauri Carbon 1 (R528/T113-S3 SoC) using the on-chip Thermal Hardware Sensor (THS) block.

Changes

Device Tree (elegoo-centauri-carbon1.dts)

  • Adds ths thermal sensor node at 0x02009400 with compatible allwinner,sun20i-d1-ths
  • Adds cpu-thermal thermal zone bound to the THS sensor, with two trip points:
    • 85°C passive — thermal alert threshold (monitoring only; no cooling device bound — see rationale below)
    • 100°C critical — emergency shutdown

Kernel Backport Patch (0003-thermal-sun8i-add-sun20i-d1-ths-support.patch)

Backports sun20i-d1-ths support to the sun8i_thermal driver in Linux 6.6.85. The R528/T113-S3 uses the same THS IP block as the Allwinner D1/T113 line (sun20i-d1-ths), which is natively supported upstream in later kernels. The patch adds:

  • sun20i_d1_ths chip description struct (1 sensor, sun50i_h6-compatible calibration/init/irq)
  • OF match entry for allwinner,sun20i-d1-ths

Kernel Config (fragment.cfg)

Adds explicit thermal framework configuration alongside the existing CONFIG_SUN8I_THERMAL=y driver config:

Config Purpose
CONFIG_THERMAL=y Base thermal framework
CONFIG_THERMAL_OF=y Device-tree thermal zone parsing (required for DTS nodes to work)
CONFIG_THERMAL_GOV_STEP_WISE=y Step-wise governor (required for type = "passive" trip points)
CONFIG_THERMAL_HWMON=y Exposes temperature readings via /sys/class/hwmon for monitoring tools
CONFIG_SUN8I_THERMAL=y Allwinner sun8i/sun20i THS driver

These are explicitly set even though multi_v7_defconfig enables them by default, to document the dependency and protect against future size-reduction changes inadvertently disabling them.

Why No CPU Throttling

CONFIG_CPU_THERMAL (CPU frequency cooling) is intentionally not enabled. The DTS thermal zone has no cooling-maps, so no cooling device is bound to the 85°C passive trip — it fires as a monitoring event only. Enabling CPU frequency throttling would risk breaking Klipper's real-time stepper motor timing under sustained thermal load. Critical shutdown at 100°C is the safety backstop.

Testing

After this PR, CPU temperature is readable via:

cat /sys/class/thermal/thermal_zone0/temp
# e.g. 42000 = 42.0°C

cat /sys/class/hwmon/hwmon0/temp1_input

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

✅ Build Artifacts

Branch: atom/thermal
Build: aeb819d (merge into main)

Artifact Size
CC1 Firmware 89.85 MB

View workflow run

Atomique13 and others added 6 commits April 5, 2026 15:28
Enable the full thermal monitoring stack for the R528/T113-S3 SoC alongside
the existing CONFIG_SUN8I_THERMAL=y driver config:

  CONFIG_THERMAL=y              — base thermal framework
  CONFIG_THERMAL_OF=y           — device-tree thermal zone parsing
  CONFIG_THERMAL_GOV_STEP_WISE=y — step-wise governor for passive trips
  CONFIG_THERMAL_HWMON=y        — expose sensor readings via /sys/class/hwmon

These are explicitly set even though multi_v7_defconfig enables them by
default, to document the dependency and protect against future size-reduction
changes inadvertently disabling them.

CONFIG_CPU_THERMAL is deliberately NOT enabled. The DTS thermal zone has no
cooling-maps, so the 85°C passive trip is monitoring-only — no cooling device
is bound. Enabling CPU throttling (cpufreq cooling) risks breaking Klipper's
real-time stepper motor timing under sustained load.

Trip point summary:
  85°C  passive  — thermal alert (monitoring only, no throttling)
  100°C critical — emergency shutdown

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

✅ Build Artifacts

Branch: atom/thermal
Build: 159318a (merge into main)

Artifact Size
CC1 Firmware 89.86 MB

View workflow run

Two fixes for thermal monitoring on R528/T113-S3:

1. Fix corrupt patch (0003-thermal-sun8i-add-sun20i-d1-ths-support.patch)
   The patch was generated against a different kernel version and had
   wrong hunk line numbers:
     Hunk 1: -671,6 +671,17  ->  -606,6 +606,18  (line 671 vs actual 606;
                                                    +17 vs actual +18 lines)
     Hunk 2: -681,6 +692,7   ->  -614,6 +626,7
   Also corrected the stat (12 -> 13 insertions) and removed the stale
   index blob hash line. Verified with 'git apply --check' against the
   extracted linux-6.6.85 source.

2. Add CONFIG_NVMEM_SUNXI_SID=y to fragment.cfg
   The sun8i_thermal driver requires the Allwinner SID (eFuse) NVMEM
   driver to read factory calibration data at probe time. Without it,
   the driver fails silently and /sys/class/thermal + /sys/class/hwmon
   remain empty. Despite multi_v7_defconfig enabling it, the final
   .config showed it disabled — making it explicit here fixes the gap.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

✅ Build Artifacts

Branch: atom/thermal
Build: 9d4584c (merge into main)

Artifact Size
CC1 Firmware 89.86 MB

View workflow run

Copy link
Copy Markdown
Collaborator

@jamesturton jamesturton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Atomique13 Atomique13 temporarily deployed to approval-needed April 5, 2026 22:44 — with GitHub Actions Inactive
@Atomique13 Atomique13 merged commit 32572aa into main Apr 5, 2026
1 check was waiting
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

✅ Build Artifacts

Branch: atom/thermal
Build: c556282 (merge into main)

Artifact Size
CC1 Firmware 89.86 MB

View workflow run

pdscomp added a commit that referenced this pull request Apr 6, 2026
* Add thermal zone configuration for CPU monitoring

* Add thermal sensor configuration

* Add support for sun20i-d1 thermal block in the kernel

* fix: normalize patch file line endings to LF

* fix: recreate patch file with clean encoding

* kernel: add explicit thermal framework configs for R528 THS monitoring

Enable the full thermal monitoring stack for the R528/T113-S3 SoC alongside
the existing CONFIG_SUN8I_THERMAL=y driver config:

  CONFIG_THERMAL=y              — base thermal framework
  CONFIG_THERMAL_OF=y           — device-tree thermal zone parsing
  CONFIG_THERMAL_GOV_STEP_WISE=y — step-wise governor for passive trips
  CONFIG_THERMAL_HWMON=y        — expose sensor readings via /sys/class/hwmon

These are explicitly set even though multi_v7_defconfig enables them by
default, to document the dependency and protect against future size-reduction
changes inadvertently disabling them.

CONFIG_CPU_THERMAL is deliberately NOT enabled. The DTS thermal zone has no
cooling-maps, so the 85°C passive trip is monitoring-only — no cooling device
is bound. Enabling CPU throttling (cpufreq cooling) risks breaking Klipper's
real-time stepper motor timing under sustained load.

Trip point summary:
  85°C  passive  — thermal alert (monitoring only, no throttling)
  100°C critical — emergency shutdown

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* kernel: fix thermal patch line numbers and add NVMEM_SUNXI_SID

Two fixes for thermal monitoring on R528/T113-S3:

1. Fix corrupt patch (0003-thermal-sun8i-add-sun20i-d1-ths-support.patch)
   The patch was generated against a different kernel version and had
   wrong hunk line numbers:
     Hunk 1: -671,6 +671,17  ->  -606,6 +606,18  (line 671 vs actual 606;
                                                    +17 vs actual +18 lines)
     Hunk 2: -681,6 +692,7   ->  -614,6 +626,7
   Also corrected the stat (12 -> 13 insertions) and removed the stale
   index blob hash line. Verified with 'git apply --check' against the
   extracted linux-6.6.85 source.

2. Add CONFIG_NVMEM_SUNXI_SID=y to fragment.cfg
   The sun8i_thermal driver requires the Allwinner SID (eFuse) NVMEM
   driver to read factory calibration data at probe time. Without it,
   the driver fails silently and /sys/class/thermal + /sys/class/hwmon
   remain empty. Despite multi_v7_defconfig enabling it, the final
   .config showed it disabled — making it explicit here fixes the gap.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* klipper: add host/toolboard temperature monitoring

* klipper: normalize temperature sensor section names

* gitignore: add Yocto build artifacts to ignore list

---------

Co-authored-by: Paul Swenson <pdscomp@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Ubuntu <ubuntu@ubuntu-2204.linuxvmimages.local>
Co-authored-by: Atomique13 <contact@zatom.cc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants