Khadas Edge-V Fan support in Linux 4.4 kernel?

I want to auto enable the fan at low speed(1) when the CPU reaches 50 degrees Celsius, medium speed(2) when reaching 60 degrees and max speed(3) when it reaches 70 degrees.

I found this patch to auto enable the fan for the 4.4 kernel but it doesn’t work in LibreELEC for me, the fan doesn’t turn on even after device reaches 80 degrees Celsius :frowning:
https://github.com/khadas/linux/commit/f1bcb3c08ab452e3fa304e1475040a667f5612df.patch

The Android fan patch also doesn’t work since it’s dependant on menu settings to change the fan, which is not available in Linux or LibreELEC.
'https://github.com/khadas/linux/commit/10fdda281cffce36004db995e429c6cb8b5f1f84

If I use the nanopi4 dts file then the fan turns on at maximum speed but obviously doesn’t boot on the Edge-V.

dts file used
'https://github.com/Joern-P/kernel/blob/develop-4.4/arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtsi

4.4 kernel config used
https://raw.githubusercontent.com/Joern-P/LibreELEC.tv/master/projects/Rockchip/devices/RK3399/linux/rockchip-4.4/linux.aarch64.conf

I don’t want to use scripts since it gets complicated with LibreELEC, only kernel changes to auto enable the fan at certain temperatures.

Maybe the fan, sensors or hwmon settings are missing or not enabled?

If someone can help it would be very appreciated.

Hello @mo123

Have you checked our ubuntu image? The FAN should work.

@numbqq

In the Ubuntu image, is the fan working automatically or also dependant on startup scripts?
I want some solution if possible that only depends on the kernel, so the fan automatically scales up the speed depending on the temperature of the CPU without any scripts since LibreELEC is not easily configurable like Ubuntu to use scripts on startup.

Can you link to the kernel config file and dts file used for the Ubuntu image?
Is this Ubuntu also based on the 4.4 stock kernel with fan working or is it the 5.5rc2(mainline) one?


Maybe I can compare it to mine used for LibreELEC.

Strange thing is if I use nanopi4 dts for 4.4 kernel with LibreELEC, the fan on Khadas Edge-V turns on automatically on highest speed but I get a black screen since the dts is not correct.
'https://github.com/Joern-P/kernel/blob/develop-4.4/arch/arm64/boot/dts/rockchip/rk3399-nanopi4-common.dtsi

So I’m not sure what setting is extra there and missing in the Khadas Edge dts file
'https://github.com/Joern-P/kernel/blob/develop-4.4/arch/arm64/boot/dts/rockchip/rk3399-khadas-edge.dtsi

I also added this patch - 'https://github.com/khadas/linux/commit/f1bcb3c08ab452e3fa304e1475040a667f5612df.patch

Thanks

It doesn’t depend on scripts. Only depend on kernel, you can setup the fan mode in /boot/env.txt

fan_mode=auto

We have modified the default FAN driver to add automode depend on temperature, so you can use other dts.

I see my LibreELEC kernel dts file is missing this ‘i2c2’ entry in Khadas Linux Edge one

This auto-freq-en = <1>; was also ‘0’ in my kernel

and ‘Edge: add MCU control driver’ is also missing in my kernel

2 fan patches I already applied


But my kernel has 2 extra fan commits not in Khadas Edge kernel, so I will revert those 2 commits and only add the 2 ones from Khadas above, maybe that also caused a problem with the fan.
'https://github.com/Joern-P/kernel/commits/develop-4.4/drivers/hwmon/pwm-fan.c

I will try all these changes and let you know if I get it working.

Thanks

Hi

LibreELEC with 4.4 kernel only has this file
extlinux.conf

content:
LABEL LibreELEC
LINUX /KERNEL
FDT /rk3399-khadas-edge.dtb
APPEND boot=UUID=1305-1950 disk=UUID=10cdb2fe-a067-4781-a217-b36da6883be1 quiet console=uart8250,mmio32,0xff1a0000 console=tty0

How can I use the ‘fan_mode=auto’
Is there somehow to enable it to auto in the kernel?

You can use this :

APPEND boot=UUID=1305-1950 disk=UUID=10cdb2fe-a067-4781-a217-b36da6883be1 quiet console=uart8250,mmio32,0xff1a0000 console=tty0 fan=auto