Marco Cettina Posted April 3 Posted April 3 (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 April 4 by Marco Cettina 0 Quote
Werner Posted April 4 Posted April 4 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 0 Quote
Marco Cettina Posted April 4 Author Posted April 4 Whoops forgot to add that, there are no pwm related overlays on armbian install. 0 Quote
Werner Posted April 4 Posted April 4 Sometimes armbian-config is unreliable when adding overlays, therefore I suggested to check manually as well. 0 Quote
Marco Cettina Posted April 4 Author Posted April 4 (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 April 4 by Marco Cettina 0 Quote
going Posted April 5 Posted April 5 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? 0 Quote
Marco Cettina Posted April 5 Author Posted April 5 (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 April 5 by Marco Cettina 0 Quote
going Posted April 5 Posted April 5 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? 0 Quote
Marco Cettina Posted April 5 Author Posted April 5 uname -r: 6.6.75-current-sunxi64 I am wired to PH3 right now, that's what i have been testing with and was functional in hardware mode on the factory supplied Debian image. 0 Quote
going Posted April 6 Posted April 6 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. 0 Quote
Marco Cettina Posted April 6 Author Posted April 6 Ill do that and get back to you! Thank you! 0 Quote
Marco Cettina Posted April 6 Author Posted April 6 Alright im updated to 6.13.7-edge-sunxi64. 0 Quote
Marco Cettina Posted April 7 Author Posted April 7 So do you need to push an update to the EDGE build to allow PWM? 0 Quote
going Posted April 7 Posted April 7 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? 0 Quote
Marco Cettina Posted April 11 Author Posted April 11 Hey any update on this? No rush, just checking in. Not sure what has to be done on your end. 0 Quote
going Posted April 14 Posted April 14 06.04.2025 в 00:33, Marco Cettina сказал: I am wired to PH3 right now, https://github.com/The-going/PKG_test/tree/master/sunxi64-6.13 You can install these pre-assembled kernel packages and check their functionality. /boot/armbianEnv.txt ... overlay_prefix=sun50i-h616 overlays=pwm1-ph3 ... 0 Quote
going Posted April 14 Posted April 14 (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 April 14 by going 0 Quote
Marco Cettina Posted Wednesday at 02:10 AM Author Posted Wednesday at 02:10 AM Awesome, going to give it a shot right now. 0 Quote
Marco Cettina Posted Wednesday at 02:57 AM Author Posted Wednesday at 02:57 AM 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. 0 Quote
Werner Posted Wednesday at 10:36 AM Posted Wednesday at 10:36 AM 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. 0 Quote
going Posted Wednesday at 01:46 PM Posted Wednesday at 01:46 PM 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. 0 Quote
Solution Marco Cettina Posted Thursday at 11:12 PM Author Solution Posted Thursday at 11:12 PM (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. Edited Thursday at 11:48 PM by Marco Cettina 1 Quote
Recommended Posts
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.