<div dir="ltr">I found a project on <a href="https://gist.github.com/alwynallan/1c13096c4cd675f38405702e89e0c536">https://gist.github.com/alwynallan/1c13096c4cd675f38405702e89e0c536</a> for a hardware controlled pwm fan for the RPI4.  This should have low resource usage, as compared to software controlled pwm.  I don&#39;t have a Noctua type pwm fan, but I made a simple circuit with a resistor, a transistor and a flyback diode to drive a brushless DC motor from the GPIO pin.  The circuit, cobbled together on some perf board, works great.<div><br></div><div>This project works, but doesn&#39;t.  By that I mean, if one makes and installs the program along with a systemd service it works.  However, the fan control does not survive a reboot.  More accurately, the service is relaunched after boot - I can see it with # systemctl | grep pi_fan_hwpwm, but the actual pin is not being controlled.  The SW thinks it is controlling the pwm pin output, but there is NO physical control of the pin.  As the core temp gets hotter and hotter the PWM duty factor increases, as designed, but no signal is at the GPIO#18 pin.</div><div><br></div><div>The pi_fan_hwpwm.service is</div><div><font face="monospace">[Unit]<br>Description=Hardware PWM control for Raspberry Pi 4 Case Fan<br>After=syslog.target<br><br>[Service]<br>Type=simple<br>User=root<br>WorkingDirectory=/run<br>PIDFile=/run/pi_fan_hwpwm.pid<br>ExecStart=/usr/local/sbin/pi_fan_hwpwm<br>Restart=on-failure<br><br>[Install]<br>WantedBy=multi-user.target<br></font></div><div><br></div><div>Multi-user.target.wants has pi_fan_hwpwm.service in its directory.  The service does start.  However the actual control of the pin is somehow being prevented.  Even if I stop and start the service, the pin is not controlled.</div><div><br></div><div>I&#39;ve turned off i2c, spi and audio in /boot/config.txt  There&#39;s some &quot;mumbling&quot; about doing things like this, both in the source of pi_fan_hwpwm.c and in the header of bcm2835.h.</div><div><br></div><div>This project includes bcm2835.h to control the pwm.  If I use the example file found in bcm2835-1.68/examples/pwm/pwm.c and compile it, it controls the fan.  If I then stop and start the fan service (after running ./pwm once) the fan pwm service now controls the fan physically.  Comparing the code in pwm.c and pi_fan_hwpwm.c reveals similar structure and initialization.  Have to say, this has been perplexing.  </div><div><br></div><div>Besides giving up, which I have seriously considered, anyone got any suggestions to make this work?  Was hoping to use the HW controlled fan on my RPI4 NAS.  <br></div><div><br></div><div><br></div></div>