GithubHelp home page GithubHelp logo

neggles / cm4io-fan Goto Github PK

View Code? Open in Web Editor NEW
76.0 8.0 14.0 57 KB

CM4 IO board PWM fan controller driver

License: GNU General Public License v2.0

Makefile 8.44% C 76.73% Shell 14.83%
raspberry-pi compute-module-4 cm4io emc2301 fan hwmon

cm4io-fan's Introduction

cm4io-fan

kernel module and device tree overlay to add support for the EMC2301 fan controller on the Raspberry Pi Compute Module 4 IO Board.

Works with 5.10+ 64-bit kernels only.

Uses Traverse Technologies' EMC2301 hwmon driver for their ten64 board, which you should definitely check out because it's awesome.

Usage

  1. Install dkms if you haven't already:
sudo apt install dkms
  1. Download the latest source .tar.gz from the releases page
  2. Untar it to /usr/src/cm4io-fan-<version> and run the dkms install:
tar -xzvf 0.2.0.tar.gz -C /usr/src/
sudo dkms install cm4io-fan/0.2.0
  1. Add these lines to your /boot/config.txt (adjust the rpm values for your specific fan, defaults are 3500 / 5500) and reboot. See below for more config options.
# Enable I2C bus 1 on VideoCore (/dev/i2c-10 in Raspberry Pi OS)
dtparam=i2c_vc=on
# Enable CM4 IO Board fan controller
dtoverlay=cm4io-fan,minrpm=1000,maxrpm=5000
  1. Some distributions may not automatically load the kernel module despite the devicetree entry; Raspberry Pi OS does, Ubuntu 21.10 does not, etc. To make the module load, edit /etc/modules (or make a new file called /etc/modules-load.d/cm4io-fan.conf), adding this line:
emc2301

Install from git

  1. Install dkms if you haven't already:
sudo apt install dkms
  1. Clone the repo
mkdir -p ~/src
cd ~/src
git clone https://github.com/neg2led/cm4io-fan.git
cd cm4io-fan
  1. Run install.sh, feel free to inspect it yourself first. It will archive the current HEAD to /usr/src with an appropriate version, and run DKMS.

Config options

The device tree overlay has a few options, here's the equivalent of a /boot/overlays/README info section:

Name:   cm4io-fan
Info:   Raspberry Pi Compute Module 4 IO Board fan controller
Load:   dtoverlay=cm4io-fan,<param>[=<val>]
Params: minrpm              RPM target for the fan when the SoC is below 
                            mintemp (default 3500)
        maxrpm              RPM target for the fan when the SoC is above
                            maxtemp (default 5500)
        midtemp             Temperature (in millicelcius) at which the fan
                            begins to speed up (default 50000)
        midtemp_hyst        Temperature delta (in millicelcius) below mintemp
                            at which the fan will drop to minrpm (default 2000)
        maxtemp             Temperature (in millicelcius) at which the fan 
                            will be held at maxrpm (default 70000)
        maxtemp_hyst        Temperature delta (in millicelcius) below maxtemp
                            at which the fan begins to slow down (default 2000)

many thanks to:

cm4io-fan's People

Contributors

mcbridematt avatar nbuchwitz avatar neggles avatar sdwilsh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cm4io-fan's Issues

fan sets to full speed after cooling down

I've built this (sudo dkms install cm4io-fan/0.1.0-2) on 32bit raspi and it seems to work well except for 1 issue. After it has been cooling and ramping down to slower and slower speeds, it kicks back on at full speed. Until the temp starts to rise again, then the driver appears to "kick on" and the fan speed slows down and then speeds up a bit until the pi is cooled off, and then this cycle repeats. I would expect the fan to completely shut off, or to remain at a low speed.

My setup:
CM4 with wifi + 4GB ram Lite With IO Board
pi@raspi-nas1:~ $ uname -r
5.10.49-v7l_charlie1+

my confit.txt:
dtoverlay=cm4io-fan,minrpm=300,maxrpm=1700,midtemp=50000,maxtemp=55000

My Fan:
Noctua NF-P12 redux-1700 PWM
(https://www.amazon.com/gp/product/B07CG2PGY6/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&psc=1)
Noctua NA-FC1, 4-Pin PWM Fan Controller
(https://www.amazon.com/gp/product/B072M2HKSN/ref=ppx_yo_dt_b_asin_title_o08_s00?ie=UTF8&psc=1)

I have tried connecting the fan directly to the pwm pins on the IO boards, and have tried with the noctua fan controller with attached sata power. I see the same behavior either way.

I notice that if I don't load the driver and just use these 2 commands to directly control the fan, it works as I would expect:
Turn fan on full speed: sudo i2cset -y 10 0x2f 0x30 0xff
Turn fan off: sudo i2cset -y 10 0x2f 0x30 0x00

So perhaps in your driver there should be some setting that after the fan has ramped down to just set the 0x30 register to 0 so the fan stays off?

fuse: mount failed: Permission denied #179

我想问一下,fuse: mount failed: Permission denied #179
这个问题你是怎么解决的,SSHFS挂载问题,我看你取消了,应当是解决了吧,我已经好几天了,在搞这个问题

ubuntu 20.04 support

Hi,

i couldnt figure out yet how to get it working on ubuntu 20.04

the latest kernel there is 5.4.0-1042-raspi
the module compiles fine but it requires changing the regex in dkms.conf

the bigger challange is getting the dtb to compile. right now it just doesnt... and i dont understand how its supposed to work

root@ubuntu:/usr/src/cm4io-fan-0.1.1# dkms install cm4io-fan/0.1.1

emc2301.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.4.0-1042-raspi/updates/dkms/

Running the post_install script:
cm4io-fan.dtbo:
 - Installation
   - Installing to /boot/firmware/overlays/
cp: cannot stat '/var/lib/dkms/cm4io-fan/0.1.1/5.4.0-1042-raspi/aarch64/module/cm4io-fan.dtbo': No such file or directory

depmod....

DKMS: install completed.


none of the makefiles contain any call to dtc, so i'm not sure how this works in the first place

calling dtc directly wont work either, since the dts is not valid syntax.

root@ubuntu:/usr/src/cm4io-fan-0.1.1/overlays# dtc  -O dtb -o /boot/firmware/overlays/emc2301.dtbo cm4io-fan-overlay.dts 
Error: cm4io-fan-overlay.dts:4.1-2 syntax error
FATAL ERROR: Unable to parse input tree

Support for Oracle Linux UEK7 kernels (5.15.0)

This module works for Oracle Linux, but need some installation tweaks...

  1. There seem to be a rule in the Makefiles for building .dtbo files from -overlay.dts which doesn't exists in the OL kernels (No rule to make target errors), but it knows how to make .dtbo from .dts files.
    Creating a symlink solved the issue: ln -s cm4io-fan-overlay.dts cm4io-fan.dts
  2. The overlays are in /boot/efi/overlays instead of /boot/overlays. Either symlink the overlays directory or replace /boot by /boot/efi in the following files: dkms.post_install, dkms.post_remove and overlays/Makefile

Grafana Screechot

dkms install problem

Hi, can you tell me why the install fails with:

Copying source to /usr/src/cm4io-fan-0.2.0...Done
Running DKMS install...
Error! Your kernel headers for kernel 5.15.76-v8+ cannot be found.
Please install the linux-headers-5.15.76-v8+ package,
or use the --kernelsourcedir option to tell DKMS where it's located

I2C needs to be enabled - maybe add to README?

I wanted to note that on a fresh Raspberry Pi OS install, I also had to go in and enable I2C for the driver to work:

# Enable I2C bus 1.
dtparam=i2c_vc=on

Should this be documented in the README? Or is it actually not necessary? I didn't see the driver load in dmesg if I didn't have this setting enabled in /boot/config.txt.

3007 Cooling Fan dont spin on PoE Board using PWM

Hi, after connect CM4-fan-3007 to FAN pins (all 4) I can't force it to spin using I2C and cm4io-fan.
Before instaling cm4io-fan when I run i2cdetect -y 10 I get correct value on 2f and I can change it (but fan dont spin).
After install cm4io-fan i2cdetect return UU on 2f place, and when I try to set it manually i got Error Device or resource busy.
In config.txt i have:

dtparam=i2c_arm=on
dtparam=i2c_vc=on
dtoverlay=i2c-fan,emc2301,i2c_csi_dsi
dtoverlay=cm4io-fan,minrpm=1000,maxrpm=3000

Other options are default, I'm trying to do it on clean rpi OS 64 Lite (september 22) with Compute Module 4 IO Board With PoE Feature.

Only when I disconnect last PIN then fan start working (regardless of the settings).

Kernel 5.10.46 problem

I can't load module for 5.10.46 kernel, i get : modprobe: ERROR: could not insert 'emc2301': Exec format error
It works on 5.10.17

driver won't load on latest kernel

driver is not loading for me on latest 32-bit kernel:

dmesg | grep emc
[   10.584880] emc2301: disagrees about version of symbol module_layout

just installed a fresh copy of raspberry pi os
then ran sudo apt update/sudo apt full-upgrade
then pulled kernel source and built with few custom needed configs
then pulled this repo and built it
added an entry to my config.txt

sudo dkms install cm4io-fan/0.1.1

uname -r
5.10.60-v7l_charlie1+

this driver worked great for me under kernel 5.10.17, so not sure what the problem is? I've tried googling around, but haven't found anything helpful.

Any thoughts?

support for Linux raspberrypi 6.1.x kernels

Upon running sudo ./install.sh

this is the output :

> Copying source to /usr/src/cm4io-fan-0.2.0...Done
> Running DKMS install...
> Error!  The /var/lib/dkms/cm4io-fan/0.2.0/6.1.21-v8+/aarch64/dkms.conf for module cm4io-fan includes a BUILD_EXCLUSIVE directive which
> does not match this kernel/arch.  This indicates that it should not be built.
> 

Iam running :

pi@raspberrypi:~/src/cm4io-fan $ uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

What do I need to update in order for the installation to succeed?

headers for kernel 5.15.32-v8+ cannot be found

sudo dkms install cm4io-fan-0.2.0

Creating symlink /var/lib/dkms/cm4io-fan/0.2.0/source ->
/usr/src/cm4io-fan-0.2.0

DKMS: add completed.
Error! Your kernel headers for kernel 5.15.32-v8+ cannot be found.
Please install the linux-headers-5.15.32-v8+ package,
or use the --kernelsourcedir option to tell DKMS where it's located

Don't know if this really is a problem.
Kernel 5.15.32-v8+ came via apt upgrade, but kernel headers obviously haven't been updated too;

apt show -a linux-headers-arm64
Package: linux-headers-arm64
Version: 5.10.113-1
Built-Using: linux (= 5.10.113-1)
Priority: optional
Section: kernel
Source: linux-signed-arm64 (5.10.113+1)
Maintainer: Debian Kernel Team [email protected]
Installed-Size: 10,2 kB
Provides: linux-headers-generic
Depends: linux-headers-5.10.0-14-arm64 (= 5.10.113-1)
Homepage: https://www.kernel.org/
Download-Size: 1.180 B
APT-Manual-Installed: no
APT-Sources: http://deb.debian.org/debian-security bullseye-security/updates/main arm64 Packages
Description: Header files for Linux arm64 configuration (meta-package)
This package depends on the architecture-specific header files for the
latest Linux kernel arm64 configuration.

Package: linux-headers-arm64
Version: 5.10.106-1
Built-Using: linux (= 5.10.106-1)
Priority: optional
Section: kernel
Source: linux-signed-arm64 (5.10.106+1)
Maintainer: Debian Kernel Team [email protected]
Installed-Size: 10,2 kB
Provides: linux-headers-generic
Depends: linux-headers-5.10.0-13-arm64 (= 5.10.106-1)
Homepage: https://www.kernel.org/
Download-Size: 1.180 B
APT-Sources: http://deb.debian.org/debian bullseye/main arm64 Packages
Description: Header files for Linux arm64 configuration (meta-package)
This package depends on the architecture-specific header files for the
latest Linux kernel arm64 configuration.

wrong speed?

Hi, may be you can help:
I've installed your cm4io-fan - basically it works, but somehow the fan speed seems to be wrong.

In my /boot/config.txt I have the following line:
dtoverlay=cm4io-fan,minrpm=500,maxrpm=2000
There are no other configuration settings.
With these settings I had expected the fan to be at about 500 rpm if the CPU is < 50°
The CPU is at 37° ... but the fan is at about 900rpm ( cat /sys/class/hwmon/hwmon2/fan1_input ---> 897). And this seems to be the lower limit, too.
If I program the fan manually I can reach the 500 rpm ...

Am I doing something wrong?

Further question: Is it possible to have the fan stopped?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.