rust-sysfs-pwm
rust-sysfs-pwm copied to clipboard
Can't make example to work
Hi! I'm probably missing something very fundamental here, but I can't make the example work. It compiles and runs, however nothing happens to the LED connected to P9.22 on my beaglebone black.
I also couldn't figure out the pin to chip mappings, but shame on me for that. I tried all pwm capable pins with pretty much all number combinations but still none worked.
Could you point me to the right directions on what should I look for?
A couple of things:
- For PWM to work on pins, you'll need to make sure that your device tree is set up to enable PWM on pins. For P9.22, you will need to confirm that the device tree muxes that pin as mode 3, ehrpwm0A.
- Here's what I usually refer back to for mappings now that I have created it for another project: https://github.com/rust-embedded/gpio-utils/blob/master/examples/beaglebone.toml
Thank you, @posborne ! I'll look into 1). I watched this mapping after I read in #1 . It was a bit confusing as P9.23 is named EHRPWM0A. I found this mapping before:
export number pin name pins
0 EHRPWM0A P9.22,P9.31
1 EHRPWM0B P9.21,P9.29
2 ECAPPWM0 P9.42
3 EHRPWM1A P9.14,P8.36
4 EHRPWM1B P9.16,P8.34
5 EHRPWM2A P8.19,P8.45
6 EHRPWM2B P8.13,P8.46
7 ECAPPWM2 P9.28
I'm not sure how it maps to pwmchip# as each chip allows me to export pmwchip#/pwm0 and pwmchip#/pwm1. Could it be associated with 1)?
Sorry for my lame questions, I'm new to embedded linux and rust in general.
Ah, maybe the PWM exports and exports for GPIO are separate (that is likely the case). Where is the table you reference from?
It referenced in multiple pages, at this blog, and here. These export tables worked for me from bash and python.
Tomorrow I'll look into loading the pwm modules from .dtbo and I'll check the pwmchip - pmw mappings again. As I was unable to export any other than pwm0 and pwm1 from any pwmchip so far.
I am struggling with a similar problem. I am not using Rust, rather beaglebone-universal-io. My two pins are P9.29 and P9.42. I have managed to get P9.42 working, following the same instructions @zen3ger did here. P9.29 shows up in the /sys/ directory, but wont output signals. I am starting to think it may be a kernel bug, because I am using a very recent release (kernel 4.9.14 bone). What kernel are you using?
I used to try it on Debian 8, unfortunately I don't know the kernel version. Currently I have Debian 7 with 3.8.13-bone67 kernel having similar issues. As you said, I can export but I get no output on the pin.
I've read it before that PWM tend to not work on 4.x kernels, also there was some change in mappings which needed to be patched. I would point you to it but my laptop died and lost all my saved stuff.
I was told the 4x kernels have many differences from the 3x kernels, "loading overlays, names of drivers, locations of things in /sysfs ... ". One driver in specific "uio_pruss" or " remote-proc" varies among kernels. I find it surprising Beaglebone official images would not support ehrpwm, on the other hand maybe there is work in progress. Its probably more likely I'm missing something simple here....