DellFanManagement & DellFanKeepAlive – Tools for managing the fan speed in Dell laptops

Discussion in 'Dell' started by Aaron44126, Jun 18, 2020.

  1. Aaron44126

    Aaron44126 Notebook Prophet

    Reputations:
    779
    Messages:
    4,542
    Likes Received:
    1,397
    Trophy Points:
    231
    Introducing DellFanManagement, a suite of tools for manipulating the fans in Dell laptops.

    There are a few different tools in the package:

    DellFanLib, a library (DellFanLib.dll) which facilitates passing fan commands to the embedded controller (EC). It uses bzh_dell_smm_io_x64.sys, and all of the other tools depend on this.
    DellFanLibInterop, a .NET library (DellFanLibInterop.dll) which makes it easy to make calls to DellFanLib from a .NET environment. Other .NET developers could use this to build their own Dell fan control apps. Maybe someone can think of a different strategy that works better for certain situations.
    DellFanCmd, which behaves the same as the old version of the app with the same name. A new test feature has been added which can quickly determine if it will work with your laptop model and what the available fan speeds are.
    DellFanKeepAlive, a new tool which allows for locking the fans at a specific speed during certain conditions and allowing the EC to manage them during others.
    DellSmmIoLib, a library which allows sending commands to the Dell SMM BIOS (without using bzh_dell_smm_io_x64.sys).
    DellSetThermalSetting, a simple tool that allows adjusting the system thermal setting (optimized/cool/quiet/performance) from the command line.

    The source code for the entire package is available at https://github.com/AaronKelley/DellFanManagement.
    Binaries can be downloaded from https://github.com/AaronKelley/DellFanManagement/releases.


    History (working backwards)

    I previously released the command-line app DellFanCmd, which allows for disabling the EC fan control. DellFanCmd can also set the fan to a certain speed. Other apps like SpeedFan can also manage the fan once EC fan control is disabled. HWiNFO64 has since been updated to use the same mechanism for fan control, so it can manage the fans in the same manner without DellFanCmd or bzh_dell_smm_io_x64.sys.
    Source code
    NotebookReview forum thread

    DellFanCmd is derived from an app called "Dell fan utility", by 424778940z. It uses the same driver, bzh_dell_smm_io_x64.sys, which is by the same author.
    Dell fan utility source code
    bzh_dell_smm_io_x64.sys source code
    NotebookReview forum thread

    bzh_dell_smm_io_x64.sys is derived from the "i8k" driver on Linux and these projects which enable the same level of fan manipulation in Dell laptops on Linux:
    https://github.com/clopez/dellfan
    https://github.com/TomFreudenberg/dell-bios-fan-control
    ...and also from I8kfanGUI and its associated driver by Christian Diefer.
    https://www.diefer.de/i8kfan/index.html


    System requirements
    • 64-bit Windows support only.
    • All of the tools require loading a driver, so you must be running them elevated / "as administrator".
    • All of the tools require the Visual C++ 2019 redistributable. You will get some sort of DLL load error if it is not installed. https://aka.ms/vs/16/release/vc_redist.x64.exe
    • All of the tools aside from DellFanLib are .NET binaries and require Microsoft .NET Framework 4.8.
    • bzh_dell_smm_io_x64.sys is signed with a valid code-signing certificate, but it is not an EV certificate. You must make a registry change, and then reboot, in order for it to be allowed to load. More details on this can be found here. You will get a driver load error if this is not done.
    Code:
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CI\Policy]
    "UpgradedSystem"=dword:00000000
    • See list of supported systems in the post below; there are most likely other supported systems that are not on the list, almost all models released since 2011 (Intel 2nd-gen Sandy Bridge or newer) work.


    Possibilities and limitations

    Basically, people have discovered a few commands that can be passed to the EC that have to do with fan management.

    You can disable EC fan control or enable EC fan control. EC fan control is enabled by default, whenever you boot the system. If EC fan control is disabled, the fans will no longer respond to changes in temperature or system load. EC fan control will remain disabled until it is specifically enabled again, or you do a full shutdown of the system. The system will always start from a cold boot with EC fan control enabled, but it will not be enabled after a reboot.

    You can set the fan level for each fan to level 0 (off), level 1, or level 2. The actual speed (RPM) for level 1 and level 2 varies from system to system. I've found that level 1 is a little bit below the lowest level that the EC normally chooses to use, and level 2 is a bit below the highest level that the EC normally chooses to use. For example, in my Precision 7530, level 1 is 2100 RPM and level 2 is 4400 RPM. However, if the EC is in charge of the fans, it won't run them any lower than 2300 RPM (unless they are off) and it can push them up as high as 4800 RPM.

    Basically, this means that any setup that uses these EC commands is limited to just three fan speeds: "off", "medium", and "high". if the EC is left in charge of the fans, it has five (?) different fan speeds that it will use in addition to the "off" speed, so more granular fan speed modulation is possible but you have no direct control over it.

    The last thing that you can do is query the fan speed for either fan. This works whether EC fan control is enabled or not.


    DellFanCmd

    This is a simple command-line tool that allows for passing commands to the EC.

    Code:
    Usage: DellFanCmd [command]
    Available commands:
      ec-disable              Turn EC fan control off (fan goes to manual control)
      ec-disable-nofanchg     Turn EC fan control off and don't change the fan speed
      ec-enable               Turn EC fan control on (fan goes to automatic control)
      test                    Try turning EC fan control off,
                              and record the fan RPM at different levels.
      fan1-rpm                Report RPM for fan 1
      fan2-rpm                Report RPM for fan 2
                              (RPMs are reported via status/error code)
    
    After EC fan control is off, you may use:
      fan1-level0             Set fan 1 to level 0 (0%)
      fan1-level1             Set fan 1 to level 1 (50%)
      fan1-level2             Set fan 1 to level 2 (100%)
      fan2-level0             Set fan 2 to level 0 (0%)
      fan2-level1             Set fan 2 to level 1 (50%)
      fan2-level2             Set fan 2 to level 2 (100%)
    
    Append "-alt" to EC disable or enable commands to attempt alternate method.
    (Example: ec-disable-alt)
    You can read more about how this works and how to use it in the DellFanCmd thread. One thing that has been added is the test function. Running "DellFanCmd test" will run through a test sequence; the program will disable EC fan control, try the fans at each of the different levels and record the RPMs, and then enable EC fan control again.


    DellSetThermalSetting

    This is a simple command-line app that allows you to adjust the system's thermal setting / thermal mode from the command line. (This is the same setting that you can adjust from Dell Power Manager, or from the BIOS on systems with 10th gen CPUs and up.)

    This program must be run elevated / as administrator. It should work on any system that Dell Power Manager works on (systems with 4th gen CPUs and up). Unlike the other tools, it does not require the Visual C++ redistributable and it does not require that you make the registry change to allow non-EV-signed drivers to be loaded.

    Code:
    Usage is simple:
      DellSetThermalSetting.exe Optimized          Set system to optimized mode
      DellSetThermalSetting.exe Cool               Set system to cool mode
      DellSetThermalSetting.exe Quiet              Set system to quiet mode
      DellSetThermalSetting.exe UltraPerformance   Set system to ultra performance mode

    DellFanKeepAlive

    Background

    I basically set all of this up so that I could build this program, which is borne out of long-term frustrations that I have with the fan control in my Precision M6700 in particular.

    I purchased my Precision M6700 at launch in 2012, but before that my primary system was an Inspiron 1720. This was a nice, solidly built high-spec machine (for its time)... They don't make Inspirons like that anymore. One thing that I loved about it was that it was quiet even under high load. Eventually, I needed more horsepower so I replaced it with the M6700, which was Dell's top offering for a high-spec laptop at the time. I was generally pleased with it but noticed right away that the fans were louder. Even more obnoxious was the noise that they make when starting up from the off state. Instead of gradually revving up to the lowest running speed (≈2400 RPM), they whir up to a higher speed before settling down which causes a very noticeable "fans are turning on" sound. (My sensorimotor OCD really hates this, it's quite distracting.) And the system likes to alternate between fans on and fans off on a ≈10 minute cycle if there isn't a whole lot going on.

    The Precision wasn't designed to be a quiet system. It wasn't even really designed to be a personal home system, it seems like they are more for specific high-performance use cases. But it's a shame because they are an excellent choice for a home system for power-user types who just want a nice, solid laptop that is serviceable, upgradeable, and that can offer high performance when desired. It's not bulky like some high-end consumer systems that lean more towards the gaming space, with crazy LED lights and huge rear exhaust radiators (but the Precision is still totally usable for gaming). If Dell spent a little bit of time working on the thermal management (...and the keyboard layout, but that's another story) then they'd have something that I really couldn't complain about.

    So anyway, my goal is basically to have two modes of operation that I can easily switch between. There is "regular mode", where I am just using the system lightly, browsing the web, writing, watching videos, doing light dev work, etc. In this case the CPU is not being pushed very hard. The system should totally be able to run with the fans at a consistent, low level for an extended period of time. Then, there is "performance mode" which I will switch over to if I need extra CPU or GPU power. In this case, the fans will be allowed to ramp up. Switching between modes should be deliberate but super easy.

    What is DellFanKeepAlive?

    My original idea for this was, I just wanted to let the EC manage the fans normally but prevent them from ever turning off, which is where the name came from. This would at least stop the on-again off-again fan behavior, plus the annoying startup sound in my M6700, for a nice and consistent and still quiet noise coming out of the fans. This is done by continuously watching the fan speed and system temperatures. When the fan speed hits the lowest normal EC fan speed, and the temperatures are pretty low, EC fan control will be shut off and the fans will be locked at their lowest normal speed. If the system comes under load and things start heating up, EC fan control will be re-enabled so that the fans can ramp up.

    Setup

    Technically, you don't need to set up two modes of operation to use this app ("regular"/"performance" as described above), so this section can be skipped. However, I have found that if you do not take some measure to limit the CPU speed, a light load can cause the temperatures to spike up quickly which will create more fan speed variation than desired or necessary. So, here is an easy way to set up two different performance modes that can be easily toggled between, on more recent versions of Windows 10.

    1. Use the Balanced power plan. (This is the default and you sort of have to go out of your way to change it.)
    [​IMG]
    2. In advanced power settings, set the maximum processor state to 99%.
    [​IMG]
    3. Set the power slider one step from the right. (You will have to make this change separately on AC power and battery power, as the system "remembers" the slider position separately for each.) This, combined with the previous step, will prevent the CPU from entering "turbo boost" speeds and you'll be capped in the mid 2 GHz range — which is completely fine for more light desktop work.
    [​IMG]
    4. If you want to uncap the CPU speed for higher performance, all you need to do is move the slider over to the right.
    [​IMG]

    Alternate method.
    (This is actually what I am using.)
    You can leave the power slider one notch from the right and, instead, switch between the "Balanced" power profile and the "High performance" power profile, either programmatically or with a script. "Balanced" should have the maximum processor state set to 99%, and "High performance" should have the maximum power state set to 100%, so switching to "High performance" will uncap the CPU.

    Benefits to this method:
    • You can have other differences between "regular mode" and "performance mode" aside from the CPU speed cap.
    • For example, the Precision M6700 supports the "Dell Feature Enhancement Pack" application which adds some extra thermal management options to advanced power settings. I'm using the "Quiet" thermal mode in the "balanced" profile, and "Standard" in "high performance".
    [​IMG]
    • I don't know of a way to use a script to change the power slider, but you can use a script to change the power profile. Here are commands to switch to "balanced" and "high performance", respectively.
    Code:
    powercfg -s 381b4222-f694-41f0-9685-ff5bb260df2e
    powercfg -s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
    (I'm using another tool to automatically change profiles when certain programs are open, so I rarely have to manually flip power modes at all.)

    Using DellFanKeepAlive

    The program takes three command-line parameters.
    1. Lower temperature threshold (°C)
    2. Upper temperature threshold (°C)
    3. Fan speed threshold (RPM)

    When you run the program, it will stay active and monitor the temperature (all CPU cores, and the discrete GPU as well if you have one) and the fan speeds. It will wait until all of the temperatures are below the lower temperature threshold and all of the fan speeds are below the fan speed threshold (but above zero), and at that point, it will shut off the EC fan control, locking the fan speed.

    If any of the temperatures rise above the upper temperature threshold, EC fan control will be enabled and the EC can cool the system according to however it normally works.

    The goal here is...
    • The fans will never totally spin down because the program will lock the fan speed before the EC gets around to shutting them off.
    • The fan speed will remain constant under moderate CPU load; only if one of the CPU core temperatures rises above the upper threshold will they be allowed to ramp up.

    If you set the lower temperature threshold too low, the system might decide to shut off the fans before the temperature gets low enough.
    If you set the upper temperature threshold too high, then it might take a while for the upper threshold to be reached and the fans to activate (and they will roar to life when they do).
    If you set the two temperatures too close together, then you might end up with flip-flop behavior as the temperature waffles above and below the thresholds.

    It takes some trial and error to find a good setup and it depends for each system. But really... You just want to set the upper threshold to the temperature at which you want the fans to kick up and the lower threshold comfortably below that.

    For my Precision M6700, I am using:
    lower threshold 70 (idle temperatures can actually drop into the 50's)
    upper threshold 80
    fan threshold 2800

    My Precision 7530 runs considerably cooler; I am using:
    lower threshold 54 (idle temperatures can actually drop into the 30's)
    upper threshold 64
    fan threshold 2400

    Here's what it looks like running my Precision M6700.

    [​IMG]

    You can see the current temperature and RPM values, and also the range of temperatures that have been observed since the program started. (Temperatures are provided by Open Hardware Monitor.) In addition to text stating that the fan speed is locked, you can tell that this is the case because of the blue background.

    Here is what things look like after some light gaming... The CPU temperature was pushed above 80, so the fan speed was unlocked (EC takes control), and the background turns red to make it obvious that this happened.
    [​IMG]

    On my Precision 7530, there are more cores to show (and lower temperatures).
    [​IMG]

    This happens sometimes immediately after starting the program... The EC has turned the fans off, so we have to wait for it to decide to turn them back on before the fan speed will be locked.
    [​IMG]

    I think that the EC might use CPU load in addition to temperature to decide what speed to run the fans at. Here, the temperature rose so the fan speed was unlocked, but the temperature is now stable at around 50. I don't think that there is any reason for the fans to be running at 4000 RPM... But I'm going to let the EC do its thing. We have to wait for the EC to the speed before it will be locked again.
    [​IMG]

    This one is on an Inspiron 15R 5520. The program correctly detects that this system only has one fan.
    [​IMG]

    Startup

    There are any number of ways to start the program at boot. I'm using Task Scheduler with an "At log on" trigger that just fires up the program. In this case you have to make sure that the task has "Run with highest privileges" selected, again, the program must be run elevated so that it can load the EC I/O driver. The thresholds can be specified in the "Add arguments" field.
    [​IMG]

    (I fully intend to make a GUI version of this app that can hide in the system tray. I'm waiting to see how things shake out with WinUI before deciding which direction to go with it.)

    One more note... If you run DellFanCmd while DellFanKeepAlive is running, it will probably cause DellFanKeepAlive to crash. Don't run the tools at the same time.


    DellFanLib and DellFanLibInterop

    These can be used to build your own fan control solutions. They have similar interfaces; DellFanLibInterop exists just to make it easy to call DellFanLib from a .NET environment without having to set up the interop calls yourself. Check DellFanLib.h and DellFanLib.cs to see the interface, or look at the DellFanCmd source code which is a pretty straight-forward command-line implementation.


    DellSmmIoLib

    This is a .NET library that allows sending commands to the Dell SMM BIOS using the ACPI/WMI interface. This is the same method that Dell Power Manager uses to talk to the BIOS. I think that it should be possible to build this out and replace bzh_dell_smm_io_x64.sys, so that a separate driver won't be needed to send fan control commands, but I haven't figured out how to replicate the commands used in DellFanLib yet.


    Always interested in ideas for improvement, or if anyone has ideas for other strategies (within the constraints of what is possible with the limited EC control) that might work better.
     
    Last edited: Jul 2, 2020
  2. Aaron44126

    Aaron44126 Notebook Prophet

    Reputations:
    779
    Messages:
    4,542
    Likes Received:
    1,397
    Trophy Points:
    231
    Supported systems:
    We have confirmation that this method works with these systems. (Add yours in a comment below and I will add it to this list.) I think that it is highly likely to work with any system closely related to these (basically any system with a 2nd-generation Sandy Bridge CPU, or later).

    Precision M4600 / Precision M6600
    Precision M4700 / Precision M6700
    Precision 7530 / Precision 7730
    Precision 7550 / Precision 7750

    Precision 5520

    Latitude E6540
    Latitude E7440

    Inspiron 5379
    Inspiron 5577
    Inspiron 15R 5520
    Inspiron 15R 5521

    Inspiron 7559
    Inspiron 7567
    Inspiron 7577

    Inspiron 7779 ("2-in-1")

    G5 5587
    G7 7588

    XPS 9360
    XPS 9550
    XPS 9560 (Seems to be broken with later BIOS versions)
    XPS 9570 (BIOS 1.6.0 or lower?)
    Note: Some XPS systems seem to lose the ability to control the screen brightness from the keyboard after disabling EC fan control

    How to check to see if your system supports this fan control mechanism.

    1. Make sure that Visual C++ 2019 redistributable and .NET Framework 4.8 are installed.
    https://aka.ms/vs/16/release/vc_redist.x64.exe
    https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net48-web-installer

    2. Apply the registry change to allow non-EV-signed drivers to be loaded.
    Code:
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CI\Policy]
    "UpgradedSystem"=dword:00000000
    Reboot.
    (You can remove this after the test to restore things to how they used to be.)

    3. Download DellFanCmd and unzip.
    https://github.com/AaronKelley/DellFanManagement/releases

    4. Open a command prompt "as administrator" in the location where you unzipped the files.

    5. Run the command:
    Code:
    DellFanCmd test
    6. The system should cycle through some different fan speeds and come back with the RPM values... Post back with the results.
     
    Last edited: Sep 16, 2020 at 9:27 AM
  3. alittleteapot

    alittleteapot Notebook Guru

    Reputations:
    17
    Messages:
    66
    Likes Received:
    31
    Trophy Points:
    26
    Hi Aaron!

    I thought I would post the results here. Ambient temperature is around 77 F, and this is my Precision 7730 under idle load:

    Fan 1 initial speed: 3389
    Fan 2 initial speed: 3584

    Fan 1 level 0 speed: 0
    Fan 1 level 1 speed: 2018
    Fan 1 level 2 speed: 4192

    Fan 2 level 0 speed: 0
    Fan 2 level 1 speed: 2005
    Fan 2 level 2 speed: 4201
     
    Aaron44126 likes this.
  4. Aaron44126

    Aaron44126 Notebook Prophet

    Reputations:
    779
    Messages:
    4,542
    Likes Received:
    1,397
    Trophy Points:
    231
    Thanks. That's about the same as I see on the Precision 7530. I haven't had confirmation that any newer systems are supported (Precision 7X40, 7X50)... hoping that nothing has changed.
     
  5. minimalmayhem

    minimalmayhem Notebook Enthusiast

    Reputations:
    5
    Messages:
    11
    Likes Received:
    5
    Trophy Points:
    6
    On my 7550:
    Loading SMM I/O driver...
    ...Success.
    Disabling EC fan control...
    Measuring: Fan 1, level 0...
    Measuring: Fan 1, level 1...
    Measuring: Fan 1, level 2...
    Measuring: Fan 2, level 0...
    Measuring: Fan 2, level 1...
    Measuring: Fan 2, level 2...
    Enabling EC fan control...
    Test procedure is finished.
    Fan 1 initial speed: 2780
    Fan 2 initial speed: 2767
    Fan 1 level 0 speed: 0
    Fan 1 level 1 speed: 2225
    Fan 1 level 2 speed: 4830
    Fan 2 level 0 speed: 0
    Fan 2 level 1 speed: 2226
    Fan 2 level 2 speed: 4848
    Unloading SMM I/O driver...
    ...Done.
     
  6. Aaron44126

    Aaron44126 Notebook Prophet

    Reputations:
    779
    Messages:
    4,542
    Likes Received:
    1,397
    Trophy Points:
    231
    Excellent, thank you...
     
  7. Aaron44126

    Aaron44126 Notebook Prophet

    Reputations:
    779
    Messages:
    4,542
    Likes Received:
    1,397
    Trophy Points:
    231
    I have a new goal for a feature add. I want to add the capability to switch the Dell "thermal mode" (Optimized/Cool/Quiet/Performance) either programmatically or from a command-line tool. Right now, I only know of these ways to switch it.
    * Systems with 3rd gen CPUs and lower — It's attached to the Windows power profile (so you can switch it from the command line by issuing a command to switch power profiles)
    * Systems with 4th gen CPUs and higher — can only be switched from the Dell Power Manager GUI app, open it up and select from the list of radio buttons
    * Systems with 10th gen CPUs and higher — you can use Dell Power Manager, or you can also use a new menu that has been added in the BIOS setup

    I've been poking around in the DLLs that are shipped with Dell Power Manager this morning to see how the app does it. I've made some interesting discoveries.

    * Dell Power Manager talks to the BIOS via WMI — it is not necessary to actually load a driver. It might be possible to use this instead of the bzh_dell_smm_io_x64.sys driver with the above tools.
    * The methods in the DLL library that interface with the BIOS have a security check in front of them, so you can't just write an app and hook up to the DPM DLLs and do whatever you want. They check to make sure that the calling executable is signed by Dell before allowing access to most things. I will be able to work around this because the check happens entirely in the DLL userspace; the interface to the BIOS itself doesn't seem to have any checks in front of it.
    * I am able to read the model number and system service tag pretty easily. I was also able to successfully query the BIOS and detect the current thermal mode and also the list of available thermal modes (highlighted at the bottom here), which requires bypassing the signature security check, so proof of concept is sort of done.

    [​IMG]

    I still have to unravel some more before I can actually change the thermal mode, but I am proceeding...
     
    custom90gt and minimalmayhem like this.
  8. Aaron44126

    Aaron44126 Notebook Prophet

    Reputations:
    779
    Messages:
    4,542
    Likes Received:
    1,397
    Trophy Points:
    231
    Did some reverse engineering against SmbLib.dll and came up with a simple interface to send commands to the BIOS. It hits the Microsoft ACPI/WMI interface so a separate driver is not needed.

    I am able to read the thermal mode and also change it.
    [​IMG]

    Will investigate tomorrow if this interface can be used for stuff that I am currently using bzh_dell_smm_io_x64.sys for (enable/disable fan control, change fan speed, query RPM).
     
  9. Aaron44126

    Aaron44126 Notebook Prophet

    Reputations:
    779
    Messages:
    4,542
    Likes Received:
    1,397
    Trophy Points:
    231
    New release, version 2.1. I've made some tweaks to the other tools but the main one is a new DellSetThermalSetting which simply allows setting the thermal setting (optimized/cool/quiet/performance) from the command line. I'm updating the documentation up top.

    I tried using the ACPI/WMI interface to issue other commands but was unable to get it to work. I still think that it is possible, just a matter of figuring out how to package up the commands to be sent to the SMM BIOS. Possibly something simple that I didn't try. If anyone else wants to take a stab at it, be my guest...
     
  10. minimalmayhem

    minimalmayhem Notebook Enthusiast

    Reputations:
    5
    Messages:
    11
    Likes Received:
    5
    Trophy Points:
    6
    This is great, thanks. the actual dell thermal app takes ages (well, a few seconds) to load, so having this (quick!) utility is really nice.
     

Share This Page