Banana pi R3 can not control pwm fan

6.1 is supported as test kernel. I’m running openwrt with 6.1 for 2 days now

Does pwm work for you?

I haven’t checked. I’ll do that tomorrow

Have tried it? With original openwrt clock it was not working for me on mainline kernel…

edit: booted again 6.5-rc on my r3 and looked for the top-clock-error…do not have it

root@bpi-r3:~# uname -a
Linux bpi-r3 6.5.0-rc1-bpi-r3 #3 SMP Sat Aug 19 16:00:16 CEST 2023 aarch64 GNU/Linux
root@bpi-r3:~# dmesg | grep pwm
root@bpi-r3:~# cd /sys/class/pwm/pwmchip0
root@bpi-r3:/sys/class/pwm/pwmchip0# echo 1 > export                                                                                               
root@bpi-r3:/sys/class/pwm/pwmchip0# ls -l
total 0
lrwxrwxrwx 1 root root    0 Feb 28 11:17 device -> ../../../10048000.pwm
--w------- 1 root root 4096 Feb 28 11:17 export
-r--r--r-- 1 root root 4096 Feb 28 11:17 npwm
drwxr-xr-x 2 root root    0 Feb 28 11:17 power
drwxr-xr-x 3 root root    0 Feb 28 11:17 pwm1
lrwxrwxrwx 1 root root    0 Feb 28 11:15 subsystem -> ../../../../../../class/pwm
-rw-r--r-- 1 root root 4096 Feb 28 11:15 uevent
--w------- 1 root root 4096 Feb 28 11:17 unexport
root@bpi-r3:/sys/class/pwm/pwmchip0# 

i can se the same problem in 23.05.0 RC3

root@OpenWrt:/# dmesg |grep “pwm”

[ 0.049827] pwm-mediatek 10048000.pwm: clock: top fail: -517

root@OpenWrt:/#

quote and code tags are broken in this forum or what ? all the text is in sequence

Kernel 6.1 or 5.15?

I guess something is different between openwrt and mainline as pwm was not working in mainline for me with openwrt top clock

Kernel 5.15.127

OpenWrt 23.05.0-rc3 r23389-5deed175a5 / LuCI openwrt-23.05 branch git-23.219.80063-bece581

5.15 is known not working

I guess because backported pwm/clock support is different to mainline

The pwm node i upstreamed works for me in mainline kernel without openwrt. So we need someone who can test pwm with openwrt with kernel 6.1 which (hopefully) does not have any openwrt-specific backports for r3

1 Like

Sorry Frank, I had no time but I finally checked with oscilloscope and it works with 6.1. And I don’t have that error on boot. But that error was always there and people always had the PWM interface working for them. I know for a fact that PWM works for some people using openwrt 5.15

5.15 mainline does not support bpi-r3/mt7986

Openwrt recently switched to mainline devicetree and so some settings changed to mainline state (like the missing milliwatt setting for sfp and the pwm top clock). The top clock was different in older openwrt devicetree so it worked till the switch to mainline dts.

Thats why older snapshots worked but with this setting it was not working in mainline code,so i had changed the clock before posting to mainline…seems like something is different in clockdriver in backported patches compared to mainline…so openwrt team could add a patch for changing the topclock of pwm for 5.15 if this is enough…so we need somebody who can change the clock in his 5.15 dts and report that it works after that. If 6.1 works (like i guess because clock driver is not backported - if this is the cause) than no change is needed here and users can switch to 6.1 as alternative

1 Like

Can you try

echo 2 > /sys/class/thermal/cooling_device0/cur_state

Does it turn the fan on?

Yes, during 5s and it stop.

echo 1 > /sys/class/thermal/cooling_device0/cur_state

makes it runing continuously

You can try this tree as daniel added the missing parts

https://git.openwrt.org/openwrt/staging/dangole.git

@dangowrt can you please change the first clock for pwm in openwrt for 5.15 only to

&infracfg CLK_INFRA_PWM_HCK

? 5.15 seems to have problems with the clock i use in higher kernel versions. 6.1 should be ok with the new clock…maybe some backporting issue for clock driver.

  • 5.15 works after clock change confirmed here
  • 6.1 confirmed here

Well, it does not work now, Fan & nvme doesnot work. kernel-boot-log.txt (70.5 KB) Please helo me.Kernel ver: 5.15.136.

And I wonder which the PCIE LINK mode of the m2 works. Is RC? Or EP?

Dears, I am using this arch linux with kernel 6.7 https://www.woudstra.mywire.org/images/

The fan is not working after first boot up. I have configured as mentioned above conversation . It doesn’t work well. Please advice Sirs.

I actually do not have a fan. But perhaps the temperature needs to rise first, before the fan will start.

Update linux-bpir64-git package as temperature was not configured correctly until recently.