Jump to content

Orange pi zero 3 enable pwm?


Go to solution Solved by Marco Cettina,

Recommended Posts

Posted (edited)

Hello! PWM seems to work without any configuration on the factory images with the gpio command, but I cant seem to get it to work on armbian.

There doesn't seem to be any dtbs related to pwm, and /sys/class/pwm is empty on armbian. Anyone got this to work?

 

EDIT: Forgot to add, doesnt seem to be any pwm overlays present on armbian install

Edited by Marco Cettina
Posted

Check if there are pwm overlays available in /boot/dtb/allwinner/overlay. If so try enable via armbian-config or manually with overlays= in /boot/armbianEnv.txt

Posted

Sometimes armbian-config is unreliable when adding overlays, therefore I suggested to check manually as well.

Posted (edited)

The only two dtbs that mention PWM have a different prefix so i assume thats why they dont work when i try to enable them?

sun50i-h5-pwn.dtbo and sun50i-h6-pwn.dtbo

Edited by Marco Cettina
Posted
03.04.2025 в 23:58, Marco Cettina сказал:

doesnt seem to be any pwm overlays present

Which pin requires an overlay?
Which core are you using?

Posted (edited)

So Im not entirely sure if I need to figure out the overlays or something else. On the factory debian image there are two overlays pwm12 and pwm34, i didnt enable them and it seems to work just fine with the gpio command.
 

I should have been more specific, on armbian there are two pwm overlays but they have the prefix of sun50i-h5 and sun50i-h6, i tried enabling them anyway but didnt make a difference and still no pwmchip showing up in /sys/class/pwm.

It also is giving me "val pwmWrite 0 <= X <= 1024, Or you can set new range by yourself by pwmSetRange(range)" when i set the pwm value even though I already did set a range and ram the same commands that worked perfectly on the factory image.

Im not sure exactly what you mean by core.

Edited by Marco Cettina
Posted
51 минуту назад, Marco Cettina сказал:

Im not sure exactly what you mean by core.

uname -r command.

 

Two types of PWM can be available. Software and hardware.

The hardware for h616-h618 processors is only available for these pins:

PG19 - pwm1
PH0  - pwm3
PH1  - pwm4
PH2  - pwm2
PH3  - pwm1
PI11 - pwm1
PI12 - pwm2
PI13 - pwm3
PI14 - pwm4

 

Which pin do you want to use PWM for?

Posted
19 часов назад, Marco Cettina сказал:

uname -r: 6.6.75-current-sunxi64

This is an outdated core and will no longer be supported after this pull request.

Try switching to the EDGE core (6.13).

 

I will add the ability to apply overlays for PWM to the EDGE core.
And we will check it together.

 

Posted
16 часов назад, Marco Cettina сказал:

So do you need to push an update to the EDGE build to allow PWM?

The pwm driver is present there.
It is necessary to add the overlay correctly.

 

Is your device an orange-pi-zero-3?

Posted (edited)

@Marco Cettina When you apply the overlay, the PWM driver will loaded and export some files to /sys.
I haven't figured out what to do with it next or how to use it yet.
I hope you can clarify this for all of us.

 

PR: pull/8086

Edited by going
Posted

Success!!

New kernel installed and overlays enabled, pwm works exactly how it should with the gpio command.

The pwm chip shows up in /sys/class/pwm instead of /sys/pwm but it works!!

Thank you for all the help!

If you want more details on what commands i ran to use pwm i can send them.

Posted
7 hours ago, Marco Cettina said:

i can send them.

Feel free to share them here. So anyone else who might run into this issue can find the solution.

Posted
10 часов назад, Marco Cettina сказал:

If you want more details on what commands i ran to use pwm i can send them.

Yes, please post it here.
There may be several suggestions (explanations) as a short instruction for use.

  • Solution
Posted (edited)

This is going to be a rough tutorial on how to get PWM working on a OrangePi Zero 3 running armbian. Just got this working thanks to (https://forum.armbian.com/profile/9748-going/). I am no expert when it comes to PWM and kernel overlays but this should get you something that works. Enjoy!


Install all 4 of the deb's from this link (https://github.com/The-going/PKG_test/tree/master/sunxi64-6.13) after rebooting you should be on 6.13.11. You can check with "uname -r"

Edit the file at /boot/armbianEnv.txt and add "pwm1-ph3", "pwm1-pi11", "pwm4-ph1" or "pwm4-pi14" depending on which pwm pin you want to use. Use the included pinout.png for reference.

After enabling the overlay I used the gpio command which should be preinstalled on armbian, if not this wiki page tells you how to install. (http://www.orangepi.org/orangepiwiki/index.php/Orange_Pi_Zero_3#How_to_install_wiringOP)

 

"gpio readall" this will print out an ascii diagram of the physical pins on the board as shown in ascii.png. In this case I am using physical pin 10, which corresponds to wPi pin 4 which is what we need for the next commands. (The pin names/number here are going to be different than the ones used previously, it is best to just use the ascii diagram and find what pin you are using instead of basing off of previous pin names)

"gpio mode 4 pwm" replace 4 with whatever wPi pin you are using, do this for all following commands. This will set the pin mode in the software to pwm

The following information I just learned from doing some googling so it may NOT be 100% correct but it was enough to get it working in my case.

"gpio pwmc 4 25" this sets the clock frequency of the PWM pin. The clock frequency is equal to 19200000 divided by the last number specified in the command. So in this case the clock frequency is 768000=19200000/25.

"gpio pwmr 4 50" this sets the pwm range and output frequency. range is essentially the resolution of pwm adjustment, higher range means finer control. your final pwm frequency is equal to 19200000/clockvalue/rangevalue. So in this case my pwm frequency is 15360=19200000/25/50.

"gpio pwm 4 25" this sets your pwm duty cycle, this is the value you will most likely be changing to control whatever device you have connected to your pwm pin. this number cant be more than your set pwm range, so in this case i have 51 steps because I have any number from and including 0 to 50 to work with.

Again I am far from an expert in PWM so I cant guarantee this is all correct but at the very least this shows how to set the needed values with the gpio commands and get PWM working on this board.

pinout.png

ascii.png

Edited by Marco Cettina

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines