Banana pi BPI-R3 can not control pwm fan

I built and deployed the openwrt firmware for it, I found it not support fan control.

root> cd /sys/class/pwm/pwmchip0
root> echo 0 > export
root> ls
device  export  npwm  power subsystem  uevent  unexport

no dev file or dir.

some dmesg info (13.0 KB) mt7986a-bananapi-bpi-r3.dts|default file in default source code (16.0 KB)

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

Your pwm controller is not setup right, 517 should be deferred probe (try later because depencies missing),but i do not see a later attempt…there are also pcie errors…

Have you same errors on official openwrt or only on the lede-fork?

Maybe you miss clock driver?

pwm0 on r3 is mapped to fan-socket (aquired pwm-fan) via dts, pwm1 is exposed on gpio-header

same errors on official openwrt and lede-fork

root@OpenWrt:/# dmesg |grep "pwm"
[    0.111354] mt7986a-pinctrl 1001f000.pinctrl: found group selector 10 for pwm0
[    0.111365] mt7986a-pinctrl 1001f000.pinctrl: found group selector 11 for pwm1_0
[    0.111375] mt7986a-pinctrl 1001f000.pinctrl: request pin 21 (PWM0) for 10048000.pwm
[    0.111385] mt7986a-pinctrl 1001f000.pinctrl: enable function pwm group pwm0
[    0.111400] mt7986a-pinctrl 1001f000.pinctrl: request pin 22 (PWM1) for 10048000.pwm
[    0.111408] mt7986a-pinctrl 1001f000.pinctrl: enable function pwm group pwm1_0
[    0.111468] pwm-mediatek 10048000.pwm: clock: top fail: -517
[    2.784365] mt7986a-pinctrl 1001f000.pinctrl: found group selector 10 for pwm0
[    2.795916] mt7986a-pinctrl 1001f000.pinctrl: found group selector 11 for pwm1_0
[    2.803309] mt7986a-pinctrl 1001f000.pinctrl: request pin 21 (PWM0) for 10048000.pwm
[    2.811034] mt7986a-pinctrl 1001f000.pinctrl: enable function pwm group pwm0
[    2.824490] mt7986a-pinctrl 1001f000.pinctrl: request pin 22 (PWM1) for 10048000.pwm
[    2.838445] mt7986a-pinctrl 1001f000.pinctrl: enable function pwm group pwm1_0
root@OpenWrt:/#

Could you try to change the first clock in dtsi?

image

same error ocurred in firmware built with official source code.

WHICH file and which line should I modify? there are so many clocks in different line and diffrent file. Search for infracfg CLK_INFRA_PWM_HCK and nothing returns.

Mt7986a.dtsi clocks-line in pwm node.

https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/mediatek/patches-6.1/012-v6.5-arm64-dts-mt7986-add-PWM.patch;h=e8c47945d6394e5b499cbc60285151e32ece4399;hb=813ef01a27#l28

I saw it in openwrt/target/linux/mediatek/files-5.15/arch/arm64/boot/dts/mediatek/mt7986a.dtsi. But the firmware I used is being built with this patch. image

But the error kept here.

By the way, the kernel of firmware is 5.15.125.

Try to change first clock to

&infracfg CLK_INFRA_PWM_HCK

Modify it in line 250?

More 249,replace the top_pwm_sel

Ok,now it works.I replace top_pwm_sta.

[ 0.047861] pwm-mediatek 10048000.pwm: clock: top fail: -517 This still keeps.

What works if you still get the error? Maybe pwm is probed too early (517 should be eprobedefer) and second attempt works

Maybe you can try 6.1? In my tests (more recent versions) the openwrt clocks did not work for me. Do not know the cause

Kernel 6.x is bad, it has a lot of terrible bugs in kernel code, plenty of APIs, such as net, has been modifid. It means there are so many broken drivers as they can not build successfully with this kind of kernel.

By the way, may u help me solve this ?

[    2.182146] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[    7.514294] block ubiblock0_1: created from ubi0:1(rootfs)
[   16.570333] block: overlay filesystem in /dev/mmcblk0p66 has not been formatted yet
[   16.587361] block: attempting to load /etc/config/fstab
[   16.596501] block: unable to load configuration (fstab: Entry not found)
[   16.603244] block: no usable configuration
[   57.645098] /dev/ubiblock0_1: Can't open blockdev

AS u see, any modification of configuration would be lost after reboot. How to fix?

Maybe just create a valid filesystem in /dev/mmcblk0p66 based on your rootfs (below the overlay).

Ok,maybe 6.1 is not yet supported by openwrt. In theory it should be possible to boot openwrt with external kernel (to use my kernel) but it will be more work to get some special things like overlayfs working. Some time ago i used openwrt rootfs as initrd.