Skip to content

CM4 IO Board fan still running after shutdown #4632

Closed

Description

@buismaarten

Is there any way to let the kernel the control the fan using the fan header on the CM4 IO Board? The fan always spins because it's plugged into a power adapter.

Activity

  1. pelwell commented on Oct 16, 2021

    @pelwell
    Contributor

    What does the schematic show the header to be connected to?

  2. buismaarten commented on Oct 16, 2021

    @buismaarten
    Author

    What do you mean? I'm using the fan header on the IO board.

  3. buismaarten commented on Oct 16, 2021

    @buismaarten
    Author

    Is it possible to add support for the EMC2301 chip to handle the fan speed?

    See: https://forums.raspberrypi.com/viewtopic.php?t=308787

  4. 6by9 commented on Oct 16, 2021

    @6by9
    Contributor

    It would be nice if there had been a V2 to https://patchwork.kernel.org/project/linux-hwmon/patch/20200928104326.40386-1-biwen.li@oss.nxp.com/ to merge support into the mainline kernel. It's probably worth cherry-picking it back and seeing what state it is in as the requested changes appear not to be too huge.
    It's a little concerning that the original poster is reporting a nasty looking kernel splat from it.

  5. geerlingguy commented on Nov 21, 2021

    @geerlingguy

    Just posting my support for something standardized, too. Right now it seems this project (https://github.com/neg2led/cm4io-fan) is the most common way people are getting any decent PWM control over the fan, other than writing up hackneyed scripts to control speeds like:

    $ i2cset -y 10 0x2f 0x30 0x80
    

    (to set it to 50%).

    As an aside, and more on point with the thread's original topic of discussion, I noticed that the fan comes on after shutdown, but it seems to pulsate a bit, going faster and slower. Is there any particular reason for that? Or do I just have a ghost somewhere in my IO board or 120mm fan?

  6. icman003 commented on May 2, 2022

    @icman003

    same issue here after system shutdown the fan still on , I saw somewhere said need update bootloader don'y know how

  7. 6by9 commented on May 10, 2022

    @6by9
    Contributor

    EMC230x driver merged with #5026. This is based on the more recent patch set that was sent to linux-hwmon in https://patchwork.kernel.org/project/linux-hwmon/cover/20220430114905.53448-1-michaelsh@nvidia.com/

    dtoverlay=i2c-fan,emc2301,i2c_csi_dsi to load it with the default temps and speeds.
    Add midtemp=55000,maxtemp=65000 or similar to change the default switch temperatures, and minpwm=0,maxpwm=255 with alternative numbers to modify the PWM range used.

    I have looked at what happens on shutdown, and the simple answer is nothing. The fan remains spinning at the speed that was requested previously. I've tried adding a reboot notifier hook via register_reboot_notifier, but it seems to make no difference (possibly I've messed it up, but it's a tricky one to debug).

    The CM4 keeps the 3V3 rail powered up on shutdown, and the 12V is coming directly in from the power supply, so the EMC2301 remains powered and keeps the fan spinning. As noted in https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#POWER_OFF_ON_HALT, you should be able to alter that behaviour via sudo -E rpi-eeprom-config --edit when usbboot'ed (rpi-eeprom-config is disabled for EMMC boot). Kill the power to the EMC2301 and the fan should drop to a default speed, but there are no absolute guarantees over what that is.

  8. 6by9 commented on May 10, 2022

    @6by9
    Contributor

    And just a minor warning should you have a pre-production CM4IO board (dated 13/5/2020) the TACH and PWM lines of the fan connector are reversed, so it won't work. That's unlikely to affect anyone outside Raspberry Pi or some of the alpha testers.

  9. YPyltiai commented on May 24, 2022

    @YPyltiai

    Does anyone know when is the release with this change expected? Thanks!

  10. 6by9 commented on May 24, 2022

    @6by9
    Contributor

    raspberrypi/rpi-firmware@affbf52
    So rpi-update will get it a kernel including it.

  11. wadoli commented on May 25, 2022

    @wadoli

    Or I just wait until a Linux kernel version ≥ 5.15.38 becomes the stable version shipped via apt to Pi OS? (The current stable aarch64-version shipped via apt is 5.15.32-v8+)

  12. YPyltiai commented on May 25, 2022

    @YPyltiai

    Just tested it on latest Kernel - doesn't seem to be working with LoveRPI POE Hat which now has EMC2301 and PWM connector. I can control fan via i2c commands fine but nothing happens automatically.

    Fan is there:

    $ i2cdetect -y 1
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:                         -- -- -- -- 0c -- -- -- 
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 2f 
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    70: -- -- -- -- -- -- -- -- 
    

    And config.txt has:

    dtparam=i2c_arm=on
    dtoverlay=i2c-fan,emc2301,i2c0
    

    What am I doing wrong?

  13. 6by9 commented on May 26, 2022

    @6by9
    Contributor

    What am I doing wrong?

    The default assumes that the fan is on i2c1 - no override needed.
    Adding i2c0 looks on i2c-0 (GPIOs 0&1, and CM4IO CAM0 and DISP0 connectors via jumpers J6), whilst i2c_csi_dsi looks on i2c-10 (CAM1 & DISP1 connectors, and where the fan controller and RTC are connected on a CM4IO).

  14. pelwell commented on May 26, 2022

    @pelwell
    Contributor

    In other words, all you should need is:

    dtoverlay=i2c-fan,emc2301
    

    i2c_arm=on is included as part of the i2c-fan overlay.

  15. YPyltiai commented on May 26, 2022

    @YPyltiai

    Thanks! Now it makes sense - I didn’t try that yesterday.

  16. 3 remaining items

  17. kwinz commented on Aug 23, 2022

    @kwinz

    Thank you that was super helpful! Especially knowing about the additional /sys/ variables in thermal_zone and cooling device directory:

    /sys/class/thermal/thermal_zone0/temp:43816
    /sys/class/thermal/thermal_zone0/trip_point_0_hyst:2000
    /sys/class/thermal/thermal_zone0/trip_point_0_temp:70000
    /sys/class/thermal/thermal_zone0/trip_point_0_type:active
    /sys/class/thermal/thermal_zone0/trip_point_1_hyst:2000
    /sys/class/thermal/thermal_zone0/trip_point_1_temp:60000
    /sys/class/thermal/thermal_zone0/trip_point_1_type:active
    /sys/class/thermal/thermal_zone0/type:cpu-thermal
    /sys/class/thermal/cooling_device0/cur_state:0
    /sys/class/thermal/cooling_device0/max_state:10
    /sys/class/thermal/cooling_device0/type:emc2305_fan
    

    I kept watching it, and as the temp increased the cur_state increased from 0 to 6 or 7. But that didn't seem to influence the fan speed at all. The fan spins, even if the cur_state is 0. And it doesn't seem to go any faster if the cur_state is at 7.

    My PWM fan is a Fan-4010-PWM-12V that came in a Waveshare WS-19195 case bundle.
    Photo: https://www.dropbox.com/s/x2iv9ax1bs5gp3q/IMG_20220823_215237.jpg?dl=0
    Maybe my fan's PWM controller is broken? I don't have another 12V PWM fan at hand right now to test.

  18. Hreimr commented on Dec 27, 2022

    @Hreimr

    Is there any way to get this to work in home assistant os?
    Some people has gotten their fans to work however that's on RPI 4s using the GPIO pins as fan control.
    I don't know how to get status of the fan nor of setting it's rpm in home assistant.

  19. dmeziere commented on Oct 3, 2023

    @dmeziere

    Let me just precise that after 2 long evenings trying different sets of parameters with "cur_state" at zero and the fan always off, a simple rpi-update raised my kernel from 6.1.21-v8+ to 6.1.54-v8+, and the fan started to spin according to temperature.

  20. habibbenkhedher commented on Jul 24, 2024

    @habibbenkhedher

    Hi guys, I just got a CM4 with EMMC and a cm4 io board and I tried everything but still my fan are going full power and even with the changes to config.txt, I notice no changes in the rpms. can somebody provide me with a config.txt file to fix my problem or did anybody encounter this problem ? I'm running on pi os 64 (latest version)
    my "/boot/firmware/config.txt":

    dtparam=i2c_arm=on
    dtparam=i2s=on
    dtparam=spi=on
    dtparam=i2c_vc=on

    dtparam=audio=on

    camera_auto_detect=1

    auto_initramfs=1

    dtoverlay=vc4-kms-v3d
    max_framebuffers=2

    disable_fw_kms_setup=1

    arm_64bit=1

    disable_overscan=1

    arm_boost=1

    [cm4]

    otg_mode=1

    [cm5]
    dtoverlay=dwc2,dr_mode=host

    [all]
    dtoverlay=i2c-fan,emc2301,midtemp=45000,maxtemp=65000,minpwm=0,maxpwm=255

  21. rofehr commented on Jul 24, 2024

    @rofehr

    /boot/firmware/config.txt ??
    but that is not the right directory

  22. habibbenkhedher commented on Jul 24, 2024

    @habibbenkhedher

    Let me just precise that after 2 long evenings trying different sets of parameters with "cur_state" at zero and the fan always off, a simple rpi-update raised my kernel from 6.1.21-v8+ to 6.1.54-v8+, and the fan started to spin according to temperature.

    is your solution still working ? if yes could you please tell me the exact steps that has to be made to get the fan rpm down (best case shutdown if temperature too low)

    /boot/firmware/config.txt ?? but that is not the right directory

    in /boot/config.txt, the following is written :
    "
    DO NOT EDIT THIS FILE

    The file you are looking for has moved to /boot/firmware/config.txt
    "
    so I didn't Bother editing this one.

  23. pelwell commented on Jul 25, 2024

    @pelwell
    Contributor

    Starting with Bookworm, the firmware partition moved from /boot to /boot/firmware. As a result, any references to /boot/config.txt should be read as /boot/firmware/config.txt.

    The early Bookworm releases had symbolic links from /boot/config.txt and /boot/cmdline.txt to the real files in /boot/firmware, but we found that for some people - perhaps because of the editor they use - the symbolic links were being replaced by a copy of the file, which caused their changes to be ignored. Now there are placeholder files directing the user to the new locations.

  24. habibbenkhedher commented on Jul 25, 2024

    @habibbenkhedher

    I managed to control the rpm through i2c-set but then it will mean that I will need a shell script that controls the fan rpms.

    Starting with Bookworm, the firmware partition moved from /boot to /boot/firmware. As a result, any references to /boot/config.txt should be read as /boot/firmware/config.txt.

    The early Bookworm releases had symbolic links from /boot/config.txt and /boot/cmdline.txt to the real files in /boot/firmware, but we found that for some people - perhaps because of the editor they use - the symbolic links were being replaced by a copy of the file, which caused their changes to be ignored. Now there are placeholder files directing the user to the new locations.

    is there a known solution to fix it ?

  25. pelwell commented on Jul 25, 2024

    @pelwell
    Contributor

    To fix what - the fan speed or the file locations?

  26. habibbenkhedher commented on Jul 25, 2024

    @habibbenkhedher

    well the fan speed , I just rebooted and the fans are back at 100%. after excecuting dmesg | grep emc I got this message :
    [ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_headphones=0 snd_bcm2835.enable_hdmi=1 snd_bcm2835.enable_hdmi=0 smsc95xx.macaddr=2C:CF:67:58:7A:31 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 overlayroot=tmpfs console=ttyS0,115200 console=tty1 root=PARTUUID=f0e0fde2-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=DE modprobe.blacklist=emc2305

  27. pelwell commented on Jul 25, 2024

    @pelwell
    Contributor
    ... modprobe.blacklist=emc2305
    

    What's that doing there? It is disabling the fan driver that would be responsible for switching off the fan - no wonder it keeps spinning.

  28. habibbenkhedher commented on Jul 25, 2024

    @habibbenkhedher
    ... modprobe.blacklist=emc2305
    

    What's that doing there? It is disabling the fan driver that would be responsible for switching off the fan - no wonder it keeps spinning.

    thanks I just noticed it but on /etc/modprobe.d/rpi-blacklist.confthere is nothing written there so I'm wondering where it has to be modified.

  29. pelwell commented on Jul 25, 2024

    @pelwell
    Contributor

    /boot/firmware/cmdline.txt?

  30. habibbenkhedher commented on Jul 25, 2024

    @habibbenkhedher

    /boot/firmware/cmdline.txt?

    yes just found it, thank you sir, I rebooted after deleting it but I still have 100% rpm back.
    my /boot/firmware/config.txt looks like this :

    # For more options and information see
    # http://rptl.io/configtxt
    # Some settings may impact device functionality. See link above for details
    
    # Uncomment some or all of these to enable the optional hardware interfaces
    dtparam=i2c_arm=on
    dtparam=i2s=on
    dtparam=spi=on
    dtparam=i2c_vc=on
    
    # Enable audio (loads snd_bcm2835)
    dtparam=audio=on
    
    # Additional overlays and parameters are documented
    # /boot/firmware/overlays/README
    
    # Automatically load overlays for detected cameras
    camera_auto_detect=1
    # Automatically load overlays for detected DSI displays
    display_auto_detect=1
    
    # Automatically load initramfs files, if found
    auto_initramfs=1
    
    # Enable DRM VC4 V3D driver
    dtoverlay=vc4-kms-v3d
    max_framebuffers=2
    
    # Don't have the firmware create an initial video= setting in cmdline.txt.
    # Use the kernel's default instead.
    disable_fw_kms_setup=1
    # Run in 64-bit mode
    arm_64bit=1
    
    # Disable compensation for displays with overscan
    disable_overscan=1
    
    # Run as fast as firmware / board allows
    arm_boost=1
    
    [cm4]
    # Enable host mode on the 2711 built-in XHCI USB controller.
    # This line should be removed if the legacy DWC2 controller is required
    # (e.g. for USB device mode) or if USB support is not required.
    otg_mode=1
    
    [cm5]
    dtoverlay=dwc2,dr_mode=host
    
    [all]
    dtoverlay=i2c-fan,emc2305,midtemp=45000,maxtemp=65000,minpwm=0,maxpwm=100
    enable_uart=1
    

    i will continue searching for a solution but I think I'm getting closer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions