Blame
|
1 | # Power Mode and Fan Control |
||||||
| 2 | ||||||||
| 3 | ### Problem |
|||||||
|
4 | No fan and power mode control is available is available for Linux or Windows on Sixunited's AXB35 board. |
||||||
|
5 | |||||||
|
6 | ### Solution for Linux |
||||||
|
7 | There is a [ec-su_axb35-linux kernel module](https://github.com/cmetz/ec-su_axb35-linux) written by Christoph Metz. |
||||||
| 8 | ||||||||
| 9 | It allows you to: |
|||||||
| 10 | - read current fan speeds and modes |
|||||||
| 11 | - switch modes of each of the three available fans |
|||||||
| 12 | - control fan speed in `fixed` mode |
|||||||
| 13 | - control fan speed with custom curves in `curve` mode |
|||||||
| 14 | - read current power mode |
|||||||
| 15 | - change current power mode |
|||||||
| 16 | - read current APU temperature |
|||||||
| 17 | ||||||||
|
18 | #### Generic Installation (no secure boot) |
||||||
|
19 | 1. Install module building dependencies (depends on your distro, on debian/ubuntu install `build-essential` and `linux-headers-$(uname -r)` packages). |
||||||
|
20 | 2. Clone the repo with `git clone https://github.com/cmetz/ec-su_axb35-linux.git`. |
||||||
|
21 | 3. Build and install the module with `cd ec-su_axb35-linux && sudo make install`. |
||||||
|
22 | 4. Try loading the module with `modprobe ec_su_axb35` and check your `dmesg` afterwards. You should see the `Sixunited AXB35-02 EC driver loaded` message. |
||||||
| 23 | 5. Run `scripts/info.sh` and check that all information is there. |
|||||||
| 24 | 6. Run `scripts/test_fan_mode_fixed.sh`, it should test your fans on all 6 fixed levels. |
|||||||
|
25 | 7. If everything is good, you can make the module automatically load on system boot with `sudo echo ec_su_axb35 >> /etc/modules`. If it says "permission denied", drop into root console with `su` or `sudo su -` and try again. |
||||||
|
26 | |||||||
|
27 | The equivalent of the above steps for Fedora is: |
||||||
| 28 | ```shell |
|||||||
| 29 | # Install module building dependencies |
|||||||
| 30 | sudo dnf group install -y development-tools c-development |
|||||||
| 31 | sudo dnf install -y kernel-headers |
|||||||
| 32 | ||||||||
| 33 | # Clone the repo |
|||||||
| 34 | git clone https://github.com/cmetz/ec-su_axb35-linux.git /tmp/ec-su_axb35-linux |
|||||||
| 35 | cd /tmp/ec-su_axb35-linux |
|||||||
| 36 | sudo make install |
|||||||
| 37 | ||||||||
| 38 | sudo modprobe ec_su_axb35 |
|||||||
| 39 | echo 'ec_su_axb35' | sudo tee /etc/modules-load.d/ec_su_axb35.conf >/dev/null |
|||||||
| 40 | ||||||||
| 41 | dmesg | grep 'Sixunited AXB35-02 EC driver loaded' |
|||||||
| 42 | ``` |
|||||||
| 43 | ||||||||
|
44 | #### Installation with secure boot on Fedora |
||||||
| 45 | Check that secure boot is enabled: |
|||||||
| 46 | ``` |
|||||||
| 47 | $ mokutil --sb-state |
|||||||
| 48 | SecureBoot enabled |
|||||||
| 49 | ``` |
|||||||
| 50 | Generate a new self-signed certificate for MOK and request it to be added to your UEFI keys: |
|||||||
| 51 | ``` |
|||||||
| 52 | sudo dnf install dkms openssl sbsigntools |
|||||||
| 53 | sudo dkms generate_mok |
|||||||
| 54 | MOK_PASSWD=test1 |
|||||||
| 55 | sudo mokutil -i /var/lib/dkms/mok.pub << EOI |
|||||||
| 56 | ${MOK_PASSWD} |
|||||||
| 57 | ${MOK_PASSWD} |
|||||||
| 58 | EOI |
|||||||
| 59 | sudo systemctl reboot |
|||||||
| 60 | ``` |
|||||||
| 61 | During reboot the blue Shim UEFI key management screen appears. Press a key. |
|||||||
| 62 | Select “Enroll MOK”, choose “Continue”, select “Yes”, enter the password "test1" from above. Note that the password must be no more than 5 characters long. Your keyboard will probably be in a US keyboard layout at this point. |
|||||||
| 63 | ||||||||
| 64 | Build the ec_su_axb35 kernel module: |
|||||||
| 65 | ``` |
|||||||
| 66 | git clone https://github.com/cmetz/ec-su_axb35-linux.git |
|||||||
| 67 | cd ec-su_axb35-linux |
|||||||
| 68 | make |
|||||||
| 69 | sudo make install |
|||||||
| 70 | ``` |
|||||||
|
71 | Sign the kernel module file you just compiled and then load it (as root): |
||||||
|
72 | ``` |
||||||
| 73 | /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 /var/lib/dkms/mok.key /var/lib/dkms/mok.pub /lib/modules/$(uname -r)/updates/ec_su_axb35.ko |
|||||||
| 74 | modprobe ec_su_axb35 |
|||||||
| 75 | dmesg|tail |
|||||||
| 76 | ``` |
|||||||
| 77 | Hopefully you will see this: |
|||||||
| 78 | ``` |
|||||||
| 79 | [ 123.02] ec_su_axb35: loading out-of-tree module taints kernel. |
|||||||
| 80 | [ 123.03] ec_su_axb35: Sixunited AXB35-02 EC driver loaded |
|||||||
| 81 | ``` |
|||||||
| 82 | ||||||||
|
83 | … and you're done! Note that you will have to redo the steps (compiling and signing) for every new Linux kernel version. |
||||||
| 84 | ||||||||
|
85 | #### Usage |
||||||
| 86 | Reading and writing all of the parameters happens through sysfs with `/sys/class/ec_su_axb35` path. You can find detailed information in [the repo's readme file](https://github.com/cmetz/ec-su_axb35-linux/blob/main/README.md). |
|||||||
| 87 | ||||||||
| 88 | Some examples: |
|||||||
| 89 | - `cat /sys/class/ec_su_axb35/fan2/rpm` to get current rpm of fan2 |
|||||||
| 90 | - `echo fixed > /sys/class/ec_su_axb35/fan3/mode && echo 2 > /sys/class/ec_su_axb35/fan3/level` to switch fan3 to fixed mode and set speed to level 2 |
|||||||
| 91 | - `echo balanced > /sys/class/ec_su_axb35/apu/power_mode` to set power mode to balanced (85W) |
|||||||
| 92 | ||||||||
|
93 | You can also call `su_axb35_monitor` anywhere to monitor all available values in realtime: |
||||||
| 94 |  |
|||||||
|
95 | |||||||
| 96 | To apply specific settings at system startup, place them in your `rc.local` file or utilize any other methods for executing commands during boot, such as creating a systemd unit. In the future, these parameters will also be configurable through module options. |
|||||||
| 97 | ||||||||
| 98 | #### Custom Curves |
|||||||
| 99 | The custom curves define temperature thresholds for fan power levels: |
|||||||
| 100 | - **Ramp-up curve** (`/sys/class/ec_su_axb35/fanX/rampup_curve`): temperature points where fan increases to the next level |
|||||||
|
101 | - **Ramp-down curve** (`/sys/class/ec_su_axb35/fanX/rampdown_curve`): temperature points where fan decreases to the previous level |
||||||
|
102 | |||||||
| 103 | For example, with these settings: |
|||||||
| 104 | - `rampup_curve = 60,70,83,95,97` |
|||||||
| 105 | - `rampdown_curve = 40,50,80,94,96` |
|||||||
| 106 | ||||||||
| 107 | **When CPU is heating up:** |
|||||||
| 108 | - Below 60°: Fan at level 0 (minimum) |
|||||||
| 109 | - At 60°: Increases to level 1 |
|||||||
| 110 | - At 70°: Increases to level 2 |
|||||||
| 111 | - At 83°: Increases to level 3 |
|||||||
| 112 | - At 95°: Increases to level 4 |
|||||||
| 113 | - At 97°: Increases to level 5 (maximum) |
|||||||
| 114 | ||||||||
| 115 | **When CPU is cooling down:** |
|||||||
| 116 | - Above 96°: Fan stays at level 5 |
|||||||
| 117 | - Below 96°: Decreases to level 4 |
|||||||
| 118 | - Below 94°: Decreases to level 3 |
|||||||
| 119 | - Below 80°: Decreases to level 2 |
|||||||
| 120 | - Below 50°: Decreases to level 1 |
|||||||
| 121 | - Below 40°: Decreases to level 0 |
|||||||
| 122 | ||||||||
| 123 | This creates a buffer at each level that prevents the fan from rapidly switching between speeds when temperature fluctuates around threshold values. |
|||||||
| 124 | ||||||||
| 125 | Curves are being applied only when `curve` mode is set on a specific fan, each fan has their own curves. |
|||||||
| 126 | ||||||||
|
127 | |||||||
| 128 | ### Solution for Windows |
|||||||
| 129 | Based on the research made for the Linux module [a Windows implementation has been written as well](https://github.com/deseven/ec-su_axb35-win). The only major limitation is the need to disable Secure Boot, everything else should be pretty simple, just follow the readme in the repo. |
|||||||
| 130 | ||||||||
| 131 | ||||||||
|
132 | ### Fine-tuning Power Limits |
||||||
|
133 | If you want more gradual control over power modes, there's a [RyzenAdj](https://github.com/FlyGoat/RyzenAdj) utility (or [UXTU](https://amdaputuningutility.com) for Windows). |
||||||
|
134 | |||||||
| 135 | Main 3 parameters we are interested in are: |
|||||||
| 136 | - `STAPM LIMIT` (sustained power draw) |
|||||||
| 137 | - `PPT LIMIT FAST` (boost power draw) |
|||||||
| 138 | - `PPT LIMIT SLOW` (average power draw) |
|||||||
| 139 | ||||||||
| 140 | Default values on all 3 selectable power modes (use `ryzenadj --info` to read them): |
|||||||
| 141 | ||||||||
| 142 | | Power Mode | STAPM LIMIT | PPT LIMIT FAST | PPT LIMIT SLOW | |
|||||||
| 143 | | ----------- | ----------- | -------------- | -------------- | |
|||||||
| 144 | | Quiet | 54.0 | 100.0 | 54.0 | |
|||||||
| 145 | | Balanced | 85.0 | 120.0 | 120.0 | |
|||||||
| 146 | | Performance | 120.0 | 140.0 | 120.0 | |
|||||||
| 147 | ||||||||
| 148 | Example on setting the power limit to static 100W with no boost: |
|||||||
| 149 | `ryzenadj --stapm-limit=100000 --fast-limit=100000 --slow-limit=100000` |
|||||||
| 150 | ||||||||
| 151 | **Note that changing the power mode via the EC controller (using `ec-su_axb35-linux` or otherwise) resets these values to their defaults.** |
|||||||
| 152 | ||||||||
|
153 | ### Relevant Pages |
||||||
|
154 | - [[Guides/Hardware_Monitoring]] |
||||||
| 155 | - [[Guides/Power_Modes_and_Performance]] |
|||||||