PWM0 and PWM1 is not working simentensoly

Hi Vicharak Team,
I am trying to use Both PWM ports of AXON board simentensoly with two different frequencies. Sometimes it starts works, in between it give garbage frequency value. From it stops works. I am attacking logs of both pwm below in the chat:

########################################
PWM0 = 17000 Hz
PWM1 = 22000 Hz

----- Testing PWM0 -----

========================================
PWM Path : /sys/class/pwm/pwmchip0/pwm0
Frequency: 17000 Hz
Period : 58823 ns
Duty : 29411 ns
Step 1 : Disable
WRITE: /sys/class/pwm/pwmchip0/pwm0/enable ← 0
Step 2 : Write period
WRITE: /sys/class/pwm/pwmchip0/pwm0/period ← 58823

ERROR configuring /sys/class/pwm/pwmchip0/pwm0
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/vicharak/dual_freq1.py”, line 62, in set_pwm
write(f"{path}/period", period)
File “/home/vicharak/dual_freq1.py”, line 19, in write
with open(path, “w”) as f:
OSError: [Errno 22] Invalid argument

----- Testing PWM1 -----

========================================
PWM Path : /sys/class/pwm/pwmchip1/pwm0
Frequency: 22000 Hz
Period : 45454 ns
Duty : 22727 ns
Step 1 : Disable
WRITE: /sys/class/pwm/pwmchip1/pwm0/enable ← 0
Step 2 : Write period
WRITE: /sys/class/pwm/pwmchip1/pwm0/period ← 45454
Step 3 : Write duty
WRITE: /sys/class/pwm/pwmchip1/pwm0/duty_cycle ← 22727
Step 4 : Enable
WRITE: /sys/class/pwm/pwmchip1/pwm0/enable ← 1
SUCCESS
Period = 45454
Duty = 22727
Enable = 1

Waiting 2 seconds…

########################################
PWM0 = 19000 Hz
PWM1 = 24000 Hz

----- Testing PWM0 -----

========================================
PWM Path : /sys/class/pwm/pwmchip0/pwm0
Frequency: 19000 Hz
Period : 52631 ns
Duty : 26315 ns
Step 1 : Disable
WRITE: /sys/class/pwm/pwmchip0/pwm0/enable ← 0
Step 2 : Write period
WRITE: /sys/class/pwm/pwmchip0/pwm0/period ← 52631

ERROR configuring /sys/class/pwm/pwmchip0/pwm0
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/vicharak/dual_freq1.py”, line 62, in set_pwm
write(f"{path}/period", period)
File “/home/vicharak/dual_freq1.py”, line 19, in write
with open(path, “w”) as f:
OSError: [Errno 22] Invalid argument

----- Testing PWM1 -----

========================================
PWM Path : /sys/class/pwm/pwmchip1/pwm0
Frequency: 24000 Hz
Period : 41666 ns
Duty : 20833 ns
Step 1 : Disable
WRITE: /sys/class/pwm/pwmchip1/pwm0/enable ← 0
Step 2 : Write period
WRITE: /sys/class/pwm/pwmchip1/pwm0/period ← 41666
Step 3 : Write duty
WRITE: /sys/class/pwm/pwmchip1/pwm0/duty_cycle ← 20833
Step 4 : Enable
WRITE: /sys/class/pwm/pwmchip1/pwm0/enable ← 1
SUCCESS
Period = 41666
Duty = 20833
Enable = 1

Waiting 2 seconds…

Disabling PWM outputs…
WRITE: /sys/class/pwm/pwmchip0/pwm0/enable ← 0
WRITE: /sys/class/pwm/pwmchip1/pwm0/enable ← 0
Done.

i have tried every single step to debug it. Kindly assist me or update me asap.

What are the overlays you have enabled to use PWM !?


I have attached screen shot of overlays.

Don’t turn overlays named as PWM1_M0 and PWM1_M1 simultaneously.

For your case, Due to Muxing mechanism of PWM0_M0 and PMW1_M0 OR PWM1_M1.

You can only run total two PWM simultaneously.

Could you send your script/program that you run on PWM !?

dual_freq.py (2.6 KB)
two_freq.py (1.1 KB)
two_freq1.py (1.3 KB)
Hi ,
i have attached the files where i am testing pwm for my use case.

Could you also send me the output of below command !?

cat /boot/extlinux/extlinux.conf

Hi,

/boot/extlinux/extlinux.conf

IMPORTANT WARNING

The configuration of this file is generated automatically.

Do not edit this file manually, use: u-boot-update

default l0
menu title U-Boot menu
prompt 0
timeout 10

label l0
menu label Vicharak Linux Kernel 6.1.75-axon
linux /Image-6.1.75-axon
initrd /initrd.img-6.1.75-axon
fdt /rk3588-axon-linux-6.1.75-axon.dtb
fdtoverlays /overlays-6.1.75-axon/rk3588-axon_v0.3-pwm0.dtbo /overlays-6.1.75-axon/rk3588-axon_v0.3-pwm1-m0.dtbo /overlays-6.1.75-axon/rk3588-axon_v0.3-pwm1-m1.dtbo
append audit=0 earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 irqchip.gicv3_pseudo_nmi=0 loglevel=4 earlyprintk plymouth.ignore-serial-consoles quiet root=PARTUUID=5a74e5d3-bbbe-4251-9c8c-a15db7b8f4b3 rootwait rw splash coherent_pool=1m systemd.gpt_auto=0 cgroup_enable=memory swapaccount=1

Let me again repeat kindly turn off one overlays out of two PWM1.


Done

Reboot the Axon and run your script/code.

i had reboot the AXON and run the code but still facing same issue. Can some from your technical team connect with me over meet to fix it. its highly appreciable .

Hi Team,
Any update on above chat ?

could you send the dmesg log captured while running your python script?

Hi Team,

here is demesg log
sudo dmesg -wH
[Jul 9 10:43] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000020] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.939078] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000231] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.938972] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000249] IPv6: MLD: clamping QRV from 1 to 2!
[ +2.113600] rockchip-pinctrl pinctrl: pin gpio0-15 already requested by 1-0022; cannot claim for fd8b0000.pwm
[ +0.000040] rockchip-pinctrl pinctrl: pin-15 (fd8b0000.pwm) status -22
[ +0.000018] rockchip-pinctrl pinctrl: could not request pin 15 (gpio0-15) from group pwm0m0-pins on device rockchip-pinctrl
[ +0.000018] rockchip-pwm fd8b0000.pwm: Error applying setting, reverse things back
[ +0.000071] rockchip-pinctrl pinctrl: pin gpio0-15 already requested by 1-0022; cannot claim for fd8b0000.pwm
[ +0.000015] rockchip-pinctrl pinctrl: pin-15 (fd8b0000.pwm) status -22
[ +0.000013] rockchip-pinctrl pinctrl: could not request pin 15 (gpio0-15) from group pwm0m0-pins on device rockchip-pinctrl
[ +0.000014] rockchip-pwm fd8b0000.pwm: Error applying setting, reverse things back
[ +3.824882] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000180] IPv6: MLD: clamping QRV from 1 to 2!
[ +6.144104] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000033] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.940011] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.204597] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.938523] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.938694] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000223] IPv6: MLD: clamping QRV from 1 to 2!
[Jul 9 10:44] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000077] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.939672] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000054] IPv6: MLD: clamping QRV from 1 to 2!
[ +6.143783] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.204760] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.734572] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000038] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.938351] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000201] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.939011] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000167] IPv6: MLD: clamping QRV from 1 to 2!
[ +6.144292] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000053] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.938657] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000418] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.939048] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000041] IPv6: MLD: clamping QRV from 1 to 2!
[ +6.144188] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000032] IPv6: MLD: clamping QRV from 1 to 2!
[Jul 9 10:45] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000137] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.939231] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000039] IPv6: MLD: clamping QRV from 1 to 2!
[ +6.143383] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000252] IPv6: MLD: clamping QRV from 1 to 2!
[ +5.938755] IPv6: MLD: clamping QRV from 1 to 2!
[ +0.000220] IPv6: MLD: clamping QRV from 1 to 2!
[ +2.947726] rockchip-pinctrl pinctrl: pin gpio0-15 already requested by 1-0022; cannot claim for fd8b0000.pwm
[ +0.000030] rockchip-pinctrl pinctrl: pin-15 (fd8b0000.pwm) status -22
[ +0.000013] rockchip-pinctrl pinctrl: could not request pin 15 (gpio0-15) from group pwm0m0-pins on device rockchip-pinctrl
[ +0.000013] rockchip-pwm fd8b0000.pwm: Error applying setting, reverse things back
[ +0.000057] rockchip-pinctrl pinctrl: pin gpio0-15 already requested by 1-0022; cannot claim for fd8b0000.pwm
[ +0.000011] rockchip-pinctrl pinctrl: pin-15 (fd8b0000.pwm) status -22
[ +0.000008] rockchip-pinctrl pinctrl: could not request pin 15 (gpio0-15) from group pwm0m0-pins on device rockchip-pinctrl
[ +0.000010] rockchip-pwm fd8b0000.pwm: Error applying setting, reverse things back

Could you please share your Overlays Configuration menu, similar to the screenshot below? I’d like to verify that no other overlays are enabled.

Based on the dmesg log you shared, it appears that GPIO0–GPIO15 are already being used by other peripherals. I want to confirm that no additional overlays are causing those GPIOs to be reserved.

Hi team,
here is screen shot i have attached

@vatsal @Avi_Shihora Hi team,
Is there any way you can connect my AXON board remotely and check the things and issue. So it can esaily resolved asap.

Mail over support@vicharak.in

could you please update the kernel? If any changes haven’t been applied or updated properly, they could be causing this issue.

run this command : sudo apt update && sudo apt upgrade

@vatsal i had run these commands still not get results. I have sent mail over support for remote technical assistance.