R38.2 How to add a PWM-controlled fan and incorporate it into the temperature control strategy?

hi:

We have added a new set of PWM and combined it with the original PWM to form two groups of fans. The system’s built-in one is quite useful. I want to add a new control to adjust the fan speed based on a temperature strategy.

This gpio36 is used in the schematic diagram

two pin one is gpio36,one is gpio45, How does the code use these two pins

Hi mingming,

Are you using the devkit or custom board for Thor?

Please refer to the pwm-fan node in device tree which has configured PWM4(pwm@c6a0000) for FAN by default.
In your case, it is PWM3(pwm@810c5f0000) and you can configure the same.

hi:KevinFFF

we use custom board for thor.

now i configure the pwm3,one problem is that the fan speed is a fixed value and will not change.

I see that the fan in the original pwm4 channel has changed.

hi:

any update?

Do you mean there’s the PWM output from pwm3 now?
and the current issue is about the PWM output is fixed for pwm3 but not for pwm4?
If so, have you also tried to configure the pwm through sysfs directly?

Do you have the AGX Thor devkit to reproduce the similar issue?

hi:

this have two pwm,pwm3 the duty cycle of pwm is now fixed and does not change with temperature variations

Will the pwm3 get changed if you control it through sysfs node manually?

hi:

i will try it

hi:

Verification is acceptable.

Now, how can it be added to the temperature control strategy, just like pwm4, where the rotational speed is automatically adjusted instead of rotating at a fixed value all the time

I found that we are not using this gpio of pwm tach now. Could it be related to this

Do you want to add another FAN to be controlled according to the temperature?
If so, you have to add it into nvfancontrol_p3834_0008_p4071_0000.conf for nvfancontrol.service.

FAN tach is used to measure the FAN speed.(i.e. rpm)

hi:

是这个意思,我们加了这个风扇也作为降温的一个策略,

我参考这个写了一份,加了一个fan 2,是这样使用吗

POLLING_INTERVAL 2

<FAN 1>
	TMARGIN ENABLED
	FAN_GOVERNOR pid {
		STEP_SIZE 10
	}
	FAN_GOVERNOR cont {
		STEP_SIZE 10
	}
	FAN_CONTROL close_loop {
		RPM_TOLERANCE 100
	}
	FAN_PROFILE cool {
		#TEMP 	HYST	PWM	RPM
		0	0	255	5371
		15	0	255	5371
		24	0	192	4170
		29	0	140	2900
		35	0	102	2300
		45	0	77	1750
		115	0	77	1750
	}
	THERMAL_GROUP 0 {
		GROUP_MAX_TEMP 115
		#Thermal-Zone Coeffs Max-Temp
		cpu-thermal 25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
		gpu-thermal 25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
		soc012-thermal 25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
		soc345-thermal 25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
	}
	FAN_DEFAULT_CONTROL close_loop
	FAN_DEFAULT_PROFILE cool
	FAN_DEFAULT_GOVERNOR cont
	KICKSTART_PWM 51
	
<FAN 2>
	TMARGIN ENABLED
	FAN_GOVERNOR pid {
		STEP_SIZE 10
	}
	FAN_GOVERNOR cont {
		STEP_SIZE 10
	}
	FAN_CONTROL close_loop {
		RPM_TOLERANCE 100
	}
	FAN_PROFILE cool {
		#TEMP 	HYST	PWM	RPM
		0	0	255	5371
		15	0	255	5371
		24	0	192	4170
		29	0	140	2900
		35	0	102	2300
		45	0	77	1750
		115	0	77	1750
	}
	THERMAL_GROUP 0 {
		GROUP_MAX_TEMP 115
		#Thermal-Zone Coeffs Max-Temp
		cpu-thermal 25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
		gpu-thermal 25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
		soc012-thermal 25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
		soc345-thermal 25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0
	}
	FAN_DEFAULT_CONTROL close_loop
	FAN_DEFAULT_PROFILE cool
	FAN_DEFAULT_GOVERNOR cont
	KICKSTART_PWM 51

yes, please check if it could be controlled by nvfancontrol service.

Please also provide the result of the following command on your board.

$ ls -l /sys/class/hwmon/
$ sudo find /sys -name "name" -exec grep -l "pwmfan" {} \; | xargs dirname

hi:

agi@tegra-ubuntu:~$ ls -l /sys/class/hwmon/ 
total 0
lrwxrwxrwx 1 root root 0 Feb 22  2025 hwmon0 -> ../../devices/platform/bus@0/a808440000.pcie/pci0003:00/0003:00:00.0/0003:01:00.0/nvme/nvme0/hwmon0
lrwxrwxrwx 1 root root 0 Feb 22  2025 hwmon1 -> ../../devices/platform/pwm-fan/hwmon/hwmon1
lrwxrwxrwx 1 root root 0 Feb 22  2025 hwmon2 -> ../../devices/platform/pwm-fan1/hwmon/hwmon2
lrwxrwxrwx 1 root root 0 Jan  1  1970 hwmon3 -> ../../devices/platform/bus@0/810c5c0000.tachometer/hwmon/hwmon3
lrwxrwxrwx 1 root root 0 Feb 22  2025 hwmon4 -> ../../devices/platform/bpmp/bpmp:i2c/i2c-5/5-004c/hwmon/hwmon4
lrwxrwxrwx 1 root root 0 Jan  1  1970 hwmon5 -> ../../devices/platform/nvtherm-oc-event/hwmon/hwmon5
agi@tegra-ubuntu:~$ 
agi@tegra-ubuntu:~$ sudo find /sys -name "name" -exec grep -l "pwmfan" {} \; | xargs dirname
/sys/devices/platform/pwm-fan1/hwmon/hwmon2
/sys/devices/platform/pwm-fan/hwmon/hwmon1
agi@tegra-ubuntu:~$ sudo find /sys -name rpm
/sys/kernel/tracing/events/rpm
/sys/kernel/debug/tracing/events/rpm
/sys/devices/platform/bus@0/810c5c0000.tachometer/hwmon/hwmon3/rpm
agi@tegra-ubuntu:~$

It seems both pwm-fan have been configured and enabled correctly in your case.

What do you mean about “定值”?

Please share the result when you run sudo nvfancontrol to start the daemon.

hi:

What do you mean about “定值”? —-》By reading the entire pwm node, I found that the values were the same,this value reflects the rotational speed of the fan

Please share the result when you run sudo nvfancontrol to start the daemon.

agi@tegra-ubuntu:~$ sudo nvfancontrol
[sudo] password for agi: 
NVPOWER INFO (find_knobs:1206): Cannot find all of power monitor knobs during initialization
NVPOWER INFO (init_libjetsonpower:638): Cannot find some knobs successfully, the corresponding APIs may not work as expected!
NVPOWER INFO (init_libjetsonpower:646): Cannot initialize average power successfully, the corresponding APIs may not work as expected!
NVFAN WARN: Switched to open loop control due to failed rpm read!
NVFAN ERROR: Failed to get FAN2 PWM! (ret = -22)
NVFAN ERROR: Prerequisites are not satisfied!
agi@tegra-ubuntu:~$ sudo su

It might be the issue as R38.2 JP7.0 How to read the rotational speed of a fan - Jetson & Embedded Systems / Jetson Thor - NVIDIA Developer Forums that we are working on configuring it in the next JP7.1 release.

hi:

thanks