Changing fan trigger, device tree modification has no effect

Which Khadas SBC do you use?

Vim3

Which system do you use? Android, Ubuntu, OOWOW or others?

Ubuntu 22

Official vim3-ubuntu-22.04-gnome-linux-6.1-fenix-1.4-221229.img.xz

Please describe your issue below:

Once again I want to change the fan curve on the board. I revisited my old post Customize fan activation temperature on ubuntu. The post worked for kernel 4.9 but now with kernel 6.1 the thermal management code changed a lot.

What I’ve tried

diff --git a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
index 18e82d7498ce..e9b8b292ff5d 100644
--- a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
@@ -323,7 +323,7 @@ &cecb_AO {
 &cpu_thermal {
        trips {
                cpu_active: cpu-active {
-                       temperature = <50000>; /* millicelsius */
+                       temperature = <60000>; /* millicelsius */
                        hysteresis = <2000>; /* millicelsius */
                        type = "active";
                };
  • Recompiled with make kernel && make kernel deb under Fenix
  • Installed the linux-dtb-amlogic-mainline_1.4.2_arm64 on the board

This doesn’t work as the trigger temperature is still 50

cat /sys/class/thermal/thermal_zone0/trip_point_3_temp
50000

My second attempt was to modify the device tree directly on the fly with

sudo fdtput -t i  /boot/dtb/amlogic/meson-g12b-a311d-khadas-vim3.dtb /thermal-zones/cpu-thermal/trips/cpu-active temperature 60000

But this also doesn’t work.

I’m a total noob to these kernel stuff and I’ve exhausted my ideas, any help is welcomed. Thanks!

Hello~@Eurus
You can try to modify the file below.

fenix/build/linux/drivers/misc/khadas-mcu.c

Hi Ivan,

Is this solution for the mainline kernel? I’m on the 6.1.y branch but I can’t find that file.

The above method only works for the 4.9 kernel,The mainline kernel is missing many patches and is not maintained by the khadas team.

The patch I linked above was created by Nick Xie nick@khadas.com, is that not the part producing the current behavior?

@Eurus

  • Execute the following command
khadas@Khadas:~$ sudo systemctl disable fan.service 
Removed /etc/systemd/system/sysinit.target.wants/fan.service.
khadas@Khadas:~$ sudo reboot
khadas@Khadas:~$ cat /sys/class/thermal/thermal_zone0/trip_point_3_temp
60000
  • My modification
diff --git a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
index 18e82d7498ce..e9b8b292ff5d 100644
--- a/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-khadas-vim3.dtsi
@@ -323,7 +323,7 @@ &cecb_AO {
 &cpu_thermal {
        trips {
                cpu_active: cpu-active {
-                       temperature = <50000>; /* millicelsius */
+                       temperature = <60000>; /* millicelsius */
                        hysteresis = <2000>; /* millicelsius */
                        type = "active";
                };

Or

$vim /usr/local/bin/fan.sh

Modify the values in this script. It affects the device tree.

Oh I see, my patch did modify the DT but /usr/local/bin/fan.sh overwrote the trigger value. Thanks!

Now that I can just change the fan.sh, how do I revert my modification to the device tree?

@Eurus

1.What you want to know is how to change the fan trigger only by changing the device tree?
2.Avoid the impact of fan.sh on the device tree, which will be arranged in the future work. It won’t be solved quickly because it’s not the focus of the job. Sorry! :slightly_frowning_face:

I don’t think fan.sh has any impact to the device tree, what it does is echo 50000 > /sys/class/thermal/thermal_zone0/trip_point_3_temp. This overwrites whatever value the dtsi has set. So with fan.service disabled in systemd, my modification to the device tree (via dtsi) can work as intended.

My question is how do I revert the patch to the device tree (I build and installed a deb to the official ubuntu mainline image), since I can just rely on modifying fan.sh to achieve the same result?

Or to put it another way, which way is better? Modify the device tree or the fan.sh? Considering compatibility to future os update.

Modifying only fan.sh has minimal impact on the system :slightly_smiling_face:

Got it, so how do I revert my device tree?

@Eurus
You can refer to the two documents below.
https://docs.khadas.com/products/sbc/common/development/build-ubuntu?s[]=make&s[]=uboot

https://docs.khadas.com/products/sbc/vim3/configurations/upgrade-linux-kernel

  • matters need attention
    After getting Fenix, Set the correct make information.

    ~/fenix$ source env/setenv.sh
    

    Run the following command to switch to the corresponding branch automatically.

    ~/fenix$ make
    

Then modify the device tree to the original state, compile the deb package and install it on VIM3 (refer to the above document).

$ make kernel-deb

deb storage path
~/fenix/build/images/debs/1.4.2/VIM3

Ah okay I understand, I just need to rebuild the kernel with the default settings and install that deb. Thanks.