andrea9nta
Posts: 2
Joined: Mon Apr 05, 2021 3:35 pm

Compute Module 4 IO Board Fan

Mon Apr 05, 2021 4:16 pm

Hi all!
I want to regulate the speed of a fan connected to the fan header of my compute module 4 io board. From the datasheet I've read that it's connected to a EMC2301 chip but I cannot figure out how to control it. I am using the raspbian lite OS with rebuilt kernel (64bit and sata support).

Thanks in advance to all

aBUGSworstnightmare
Posts: 2910
Joined: Tue Jun 30, 2015 1:35 pm

Re: Compute Module 4 IO Board Fan

Tue Apr 06, 2021 5:51 am

It's controlled via PWM. The EMC2301 (https://www.microchip.com/wwwproducts/en/EMC2301 ) sits on the I2C bus .
It has two addresses: 0x0c is the alert response address of SMBBus (0001_100xb); device address is 0x2f (0101_111(r/w)b)

With 'dtparam=i2c_vc=on' added to config.txt I get below from the CM4IO

Code: Select all

pi@raspberrypi:~ $ sudo i2cdetect -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- 0c -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 2f 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --     
the data sheet has the details on the device. Sorry, but don't know if there is a kernel driver for the PWM controller.

Icarus_Radio
Posts: 10
Joined: Sat Apr 03, 2021 6:02 am

Re: Compute Module 4 IO Board Fan

Wed Apr 07, 2021 3:12 am

aBUGSworstnightmare wrote:
Tue Apr 06, 2021 5:51 am
It's controlled via PWM. The EMC2301 (https://www.microchip.com/wwwproducts/en/EMC2301 ) sits on the I2C bus .
It has two addresses: 0x0c is the alert response address of SMBBus (0001_100xb); device address is 0x2f (0101_111(r/w)b)

With 'dtparam=i2c_vc=on' added to config.txt I get below from the CM4IO

Code: Select all

pi@raspberrypi:~ $ sudo i2cdetect -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- 0c -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 2f 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --     
the data sheet has the details on the device. Sorry, but don't know if there is a kernel driver for the PWM controller.
It seems that Linux has a PWM interface (https://www.kernel.org/doc/html/latest/ ... i/pwm.html). I am wondering how to control the fan as well. Any help is appreciated.

aBUGSworstnightmare
Posts: 2910
Joined: Tue Jun 30, 2015 1:35 pm

Re: Compute Module 4 IO Board Fan

Wed Apr 07, 2021 6:40 am

Icarus_Radio wrote:
Wed Apr 07, 2021 3:12 am
aBUGSworstnightmare wrote:
Tue Apr 06, 2021 5:51 am
It's controlled via PWM. The EMC2301 (https://www.microchip.com/wwwproducts/en/EMC2301 ) sits on the I2C bus .
It has two addresses: 0x0c is the alert response address of SMBBus (0001_100xb); device address is 0x2f (0101_111(r/w)b)

With 'dtparam=i2c_vc=on' added to config.txt I get below from the CM4IO

Code: Select all

pi@raspberrypi:~ $ sudo i2cdetect -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- 0c -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 2f 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --     
the data sheet has the details on the device. Sorry, but don't know if there is a kernel driver for the PWM controller.
It seems that Linux has a PWM interface (https://www.kernel.org/doc/html/latest/ ... i/pwm.html). I am wondering how to control the fan as well. Any help is appreciated.
if you simply want to have it temperature controled simply enable that feature. 'Controlling' it has a different understanding to me.

andrea9nta
Posts: 2
Joined: Mon Apr 05, 2021 3:35 pm

Re: Compute Module 4 IO Board Fan

Wed Apr 07, 2021 2:27 pm

By 'Controlling' I mean adjust automatically the speed of the fan in relation of temperature. If this is not possible it would be fine to only adjust it to a speed lower than 100%.


aBUGSworstnightmare
Posts: 2910
Joined: Tue Jun 30, 2015 1:35 pm

Re: Compute Module 4 IO Board Fan

Thu Apr 08, 2021 5:44 am

Temperature control is avaialble from the OS; open Raspi Config and enable it. The default GPIO setting should not be changed for the CM4IO, so you only need to set the temp level when the fan kicks in.

If you want your own profile use the kernel driver.

User avatar
geerlingguy
Posts: 215
Joined: Sun Feb 15, 2015 3:43 am
Location: St. Louis, MO, USA
Contact: Website Twitter YouTube

Re: Compute Module 4 IO Board Fan

Tue Apr 27, 2021 7:55 pm

aBUGSworstnightmare wrote:
Thu Apr 08, 2021 5:44 am
Temperature control is avaialble from the OS; open Raspi Config and enable it. The default GPIO setting should not be changed for the CM4IO, so you only need to set the temp level when the fan kicks in.

If you want your own profile use the kernel driver.
This is not true regarding the built in EMC2301 chip on the CM4 IO Board. It is controlled over I2C and the 'Fan' option inside raspi-config has no bearing on whether the I2C bus-connected 4-pin fan is running or not.
The question is not whether something should be done on a Raspberry Pi, it is whether it can be done on a Raspberry Pi.

User avatar
boyinhell
Posts: 8
Joined: Sat Mar 25, 2017 2:26 am
Location: Singapore
Contact: Website

Re: Compute Module 4 IO Board Fan

Fri May 07, 2021 8:53 am

There is a patch change request but not yet merged.

Check out here on patchwork.kernel.org: https://patchwork.kernel.org/project/li ... s.nxp.com/
Building memories...

User avatar
boyinhell
Posts: 8
Joined: Sat Mar 25, 2017 2:26 am
Location: Singapore
Contact: Website

Re: Compute Module 4 IO Board Fan

Fri May 07, 2021 8:54 am

geerlingguy wrote:
Tue Apr 27, 2021 7:55 pm
aBUGSworstnightmare wrote:
Thu Apr 08, 2021 5:44 am
Temperature control is avaialble from the OS; open Raspi Config and enable it. The default GPIO setting should not be changed for the CM4IO, so you only need to set the temp level when the fan kicks in.

If you want your own profile use the kernel driver.
This is not true regarding the built in EMC2301 chip on the CM4 IO Board. It is controlled over I2C and the 'Fan' option inside raspi-config has no bearing on whether the I2C bus-connected 4-pin fan is running or not.
Hi Jeff! Love your CM4 Videos.
Building memories...

User avatar
neggles
Posts: 6
Joined: Tue Jun 26, 2012 2:52 pm
Location: Melbourne, Australia
Contact: Website Twitter

Re: Compute Module 4 IO Board Fan

Sat May 08, 2021 2:16 pm

so I have this working using hwmon :)

I borrowed Traverse Technologies' emc2301 driver for their Ten64 board, and built a device tree overlay that links it all together. it's rough as heck, but you can find it here: https://github.com/neg2led/cm4io-fan

device tree overlay is based on the rpi-poe and i2c-rtc overlays, kind of. it's fairly simple - EMC2301 gives you 8 fan speed steps, so you set your midtemp/maxtemp/minrpm/maxrpm and off you go. Uses DKMS to build the module and dtbo.

Code: Select all

[    4.488756] emc2301 10-002f: EMC2301 detected
[    4.488786] emc2301 10-002f: Have 1 fans configured in DT
[    4.488812] emc2301 10-002f: Fan 0 Cooling step is 187 RPM, minimum 1000, max 2500 RPM
[    4.497208] emc2301 10-002f: registering a cooling device
It works great on the latest 64-bit raspi OS build; I don't think the driver builds on 32-bit, but if anyone tries it please let me know if it works!
Last edited by neggles on Sun May 09, 2021 3:11 pm, edited 1 time in total.

Icarus_Radio
Posts: 10
Joined: Sat Apr 03, 2021 6:02 am

Re: Compute Module 4 IO Board Fan

Sun May 09, 2021 7:52 am

neggles wrote:
Sat May 08, 2021 2:16 pm
so I have this working using hwmon :)

I borrowed Traverse Technologies' emc2301 driver for their Ten64 board, and built a (kind of rough?) device tree overlay that links it all together. it's rough as heck, but you can find it here: https://github.com/neg2led/cm4io-fan

device tree overlay is based on the rpi-poe and i2c-rtc overlays, kind of. it's fairly simple - EMC2301 gives you 8 fan speed steps, so you set your midtemp/maxtemp/minrpm/maxrpm and off you go. Uses DKMS to build the module and dtbo.

Code: Select all

[    4.488756] emc2301 10-002f: EMC2301 detected
[    4.488786] emc2301 10-002f: Have 1 fans configured in DT
[    4.488812] emc2301 10-002f: Fan 0 Cooling step is 187 RPM, minimum 1000, max 2500 RPM
[    4.497208] emc2301 10-002f: registering a cooling device
It works great on the latest 64-bit raspi OS build; I don't think the driver builds on 32-bit, but if anyone tries it please let me know if it works!
Great job! Wonder when they will release some official tools. Maybe a GUI or a component in raspi-config.

User avatar
neggles
Posts: 6
Joined: Tue Jun 26, 2012 2:52 pm
Location: Melbourne, Australia
Contact: Website Twitter

Re: Compute Module 4 IO Board Fan

Wed May 12, 2021 10:21 am

The Traverse driver is really nice, it works very well with all the fans I've tried so far (a half dozen different ones) - can't see why it wouldn't, really, the closed-loop RPM control is all in the chip. Would definitely be nice to see official support, maybe I should email Mathew @ Traverse and ask if he'd like to submit the module/dts to raspberrypi/linux?

Also, when I made that last post the dkms config and setup scripts in the repo were a bit, well, broken - late night repo pushes are never a great idea... It's all fixed up now, should actually install through DKMS properly.

Only one minor known issue, at the moment you have to remove an old version of the dkms package before installing the new one, or when you run dkms remove it'll delete /boot/overlays/cm4io-fan.dbto :? not a huge issue, since I doubt I'll be updating it very much except maybe to add i2c bus/address parameters so it's easier to use on custom boards.

If anyone who knows their way around Debian packaging can tell me what i'm missing when it comes to building a .deb out of this, that'd be extremely helpful as well... why is that so heinously difficult?!

Return to “Compute Module”