# UGREEN DXP4800 Pro — Fan Control Run Sheet **Status: working.** Confirmed holding `manual` mode across multiple checks, responding correctly to real CPU load swings (48C→61C→50C tracked pwm 91→165→102), same PID throughout, no reversion. Persistence via TrueNAS Post Init added 2026-08-22 — pending reboot confirmation. --- ## What this does Two independently-driven fans on the it87/IT8613E Super I/O chip: | Fan | Channel | Driven by | Curve | |-----|---------|-----------|-------| | Internal (CPU) | `pwm2` | `coretemp` package temp | 45→30%, 55→50%, 65→75%, 75→100% | | Rear 140mm | `pwm3` | hottest of `drivetemp` (HDD) + NVMe **composite** temp | 32→30%, 40→40%, 45→55%, 50→70%, 55→85%, 62→100% | **NVMe reads composite (`temp1_input`) only** — NAND sensors (`temp2`/`temp3`) run 5-10C hotter than composite and were pinning the drive fan at 100% unnecessarily. This was the key fix that made the drive curve usable. Fan→channel mapping (confirmed empirically by stopping each channel and watching which blade stopped): - `pwm2` → internal CPU fan - `pwm3` → rear 140mm (primary drive cooling) --- ## Files All on the pool at `/mnt/ftank/scripts/` (survives TrueNAS OS updates — nothing is installed to `/etc` or systemd): | File | Purpose | |------|---------| | `ugreen-fancontrol.sh` | the control daemon | | `fanctl` | start/stop/status/temps/diagnose helper | Log: `/var/log/ugreen-fancontrol.log` PID file: `/var/run/ugreen-fancontrol.pid` --- ## Everyday commands ```bash sudo /mnt/ftank/scripts/fanctl start # start the daemon sudo /mnt/ftank/scripts/fanctl stop # stop + force chip auto mode sudo /mnt/ftank/scripts/fanctl restart # after editing curves sudo /mnt/ftank/scripts/fanctl status # running? pwm mode+value? log tail sudo /mnt/ftank/scripts/fanctl temps # one-shot temps + RPM, no daemon needed sudo /mnt/ftank/scripts/fanctl diagnose # module/hwmon/writability checks sudo /mnt/ftank/scripts/fanctl log # follow the log live ``` To change a curve: edit `CPU_CURVE` / `DRIVE_CURVE` near the top of `ugreen-fancontrol.sh`, then `fanctl restart`. --- ## Persistence — Init/Shutdown Script **System Settings → Advanced → Init/Shutdown Scripts → Add** | Field | Value | |---|---| | Description | Fan Control Script - fanctl | | Type | Command | | Command | `/mnt/ftank/scripts/fanctl start` | | When | Post Init | | Enabled | ✅ | | Timeout | 10 | Added 2026-08-22. `fanctl start` backgrounds the daemon and returns in ~1s, well inside the 10s timeout. It's idempotent — safe if it ever runs twice. **After any reboot, verify:** ```bash sudo /mnt/ftank/scripts/fanctl status ``` Want to see `STATUS: running`, both `pwm2`/`pwm3` as `manual` with sane values (not `mode0`/`auto`, not stuck at 255). --- ## How we got here (context for future-you) Two prior sessions burned a lot of time chasing what looked like the same bug but turned out to be **several distinct real bugs**, all now fixed in this version: 1. **Parser bugs** (early daemon used `sensors -u` text parsing with wrong assumptions about blank lines / chip block boundaries) — **fixed** by reading sysfs directly (`temp*_input` files), no text parsing at all. 2. **File-descriptor leak** in an earlier sleep-fallback fifo implementation that eventually exhausted FDs and made `fork()` fail — **fixed** by removing the fifo entirely; plain `sleep` is reliable on this box. 3. **it87 write-order requirement**: the channel must be set to manual (`enable=1`) *before* writing a pwm duty, or the write is rejected — **fixed**, enable is written first. 4. **An intermittent backgrounded-exec fault** (`nohup`'d processes occasionally got `Function not implemented` on ordinary binaries) — never fully root-caused; TrueNAS blocks `dmesg` even under sudo, so kernel-side diagnosis wasn't possible. **Mitigated** by moving the manual-mode/pwm writes to happen *immediately* at daemon startup, before any sensor read is required — so even if a transient exec hiccup delays temp reads, the fans are already under real control at a safe mid-speed rather than depending on that first read succeeding. 5. **NVMe NAND vs composite temp** — the drive curve was being driven by the hotter NAND sensor, pinning the rear fan at 100% even when the drive was fine by its own reported spec temp — **fixed**, composite (`temp1_input`) only. If `fanctl status` ever shows `mode0` or the fans seem stuck at 255 again, suspect #4 recurring — check `sudo /mnt/ftank/scripts/fanctl diagnose` and whether the PID has changed unexpectedly (a crash-restart loop would show in `fanctl log`). --- ## Hardware facts - Chip: ITE IT8613E (`it8613`), driver: mainline `it87` - `pwm2_enable`/`pwm3_enable`: `0`=full speed (uncontrolled), `1`=manual, `2`=chip automatic - The it87's own hardware auto-curve (`pwmN_auto_point*_temp` etc.) exists as a **daemon-free fallback** if this script is ever abandoned — it's driven by the chip's own `temp1` (CPU/PECI) only, so it **cannot** react to drive temperature (no wiring from drives to the it87). That's why a userspace daemon is needed for the drive-fan zone at all. - NIC/module notes, pool layout, LAGG etc. are covered in the separate `truenas-new-instance` notes — not repeated here. --- ## Rebuild-from-scratch checklist 1. Confirm `it87` loads: `sudo /mnt/ftank/scripts/fanctl diagnose` 2. `sudo chmod +x /mnt/ftank/scripts/ugreen-fancontrol.sh /mnt/ftank/scripts/fanctl` 3. `sudo /mnt/ftank/scripts/fanctl start` then `... status` — both pwm should read `manual` within a few seconds. 4. Add the Post Init entry (table above). 5. Reboot, wait ~1 min, `fanctl status` again to confirm it survived. 6. Optional stress check: ```bash yes > /dev/null & sleep 20; sudo /mnt/ftank/scripts/fanctl temps; kill %1 ``` Confirms `pwm2` climbs under real CPU load.