Activating PWM on the Device tree overlay

Which system do you use? Android, Ubuntu, OOWOW or others?

Ubuntu

Which version of system do you use? Please provide the version of the system here:

edge2-ubuntu-22.04-gnome-linu-5.10fenixv1.6.5-240301.img

Please describe your issue below:

Please bear with me, I am a bit new to updating the device tree. I am trying to update the device tree overlay for the pin 13 to work as pwm pin,

Edit /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env to add pwm node
to fdt_overlays node if it doesn’t exist.

fdt_overlays=edge2-io-pwm

image.png

After this it should show

pwmchip2 folder inside the following directory,

/sys/class/pwm/pwmchip2/export

But for me when I update the device tree

rk3588s-khadas-edge2.dtb.overlay.env

with two

fdt_overlays=edge2-io-uart.dtbo

fdt_overlays=edge2-io-pwm

I cannot see the pwmchip2 folder inside /sys/class/pwm/, I can see is pwmchip0 and pwmchip1

Am I missing something? Can we use two device tree overlays, it should be because if I want to use the gpio pin for some and some pwm, this feature should be available, no?

Post a console log of your issue below:


No log for now

Hello @Sunita_Pokharel

After editing the /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env, you should also input command like this:

$ sudo vi /boot/dtb/rockchip/rk3588s-khadas-edge2.dtb.overlay.env
$ sync
$ sudo reboot

Before edit the file, I got pwm like this:

khadas@Khadas:~$ ls /sys/class/pwm/pwmchip?
/sys/class/pwm/pwmchip0:
device  export  npwm  power  subsystem  uevent  unexport

/sys/class/pwm/pwmchip1:
device  export  npwm  power  subsystem  uevent  unexport

Then add edge2-io-pwm to the file

fdt_overlays=edge2-io-pwm

After sync and reboot, I got the followings:

khadas@Khadas:~$ ls /sys/class/pwm/pwmchip?
/sys/class/pwm/pwmchip0:
device  export  npwm  power  subsystem  uevent  unexport

/sys/class/pwm/pwmchip1:
device  export  npwm  power  subsystem  uevent  unexport

/sys/class/pwm/pwmchip2:
device  export  npwm  power  subsystem  uevent  unexport

Reference: Edge2 PWM [Khadas Docs]

1 Like

Hi Jacobe,

Thank You for your response. I found my issue was I was trying to activate both uart and pwm that is why I added two of these on my .env files. I figured that my problem was how I added it.
Before I had this on my overlay,
fdt_overlays=edge2-io-uart.dtbo
fdt_overlays=edge2-io-pwm

Updated it to the following and the pwmchip2 is showing.
fdt_overlays=edge2-io-uart.dtbo edge2-io-pwm

Thank You for your input.

Also, do you know how many pwm pins do we have on this board? is it jus the pin number 13 or there is other too? I need 2 pwm pin for my job so I wanted to see if there is anyway I could do it from this board and not add an extra board.

Thank You !

Also, do you know how many pwm pins do we have on this board? is it jus the pin number 13 or there is other too?

There is only on the IO extension board.

I need 2 pwm pin for my job so I wanted to see if there is anyway I could do it from this board and not add an extra board.

Well, I’m not for sure if the software pwm simulation will meet your requirements. You can try it and feel free to ask if have some problems. :wink: