I am currently using the latest beaglebone black debian image, and I am trying to get pwm to work on the board using the instructions in Molloy’s Exploring the Beaglebone. Unfortunately, shall we say, it doesn’t seem to be working. I am unable to see the bone_capemgr.9 directory to setup the SLOTS export. I suspect this may be due to changes between Debian releases. With that being the case, is there some location that has the current instructions for setting up the PWM module with the current image?
If I were you Walter, I’d just learn how to adapt DR Molloy’s instructions to 4.1.x. These newer kernels I’ve found to be noticeably more responsive . . .
Thanks. That helps quite a bit. I’ve still not quite got everything working, but I’m making headway. Now to find the magic decoder ring of pwm chips to pins and ports.
I could probably walk through how to setup an use PWM on Debian with a 4.1.x kernel. Problem is that I would have no real way of testing that what I’m doing is actually outputting what I’d expect.
OK, so here is where I am at: #1 I wrote the following script, and, well it worked great… Until I had to reboot my machine:
#!/bin/bash # SE3910 Real Time Systems # PWM Bash shell script. # Author: W. Schilling # This script will enable PWM on the beaglebone connected to ECAPPWM0. # It will set the duty cycle to the value passed in, which is a value between 1 and 10000.
# Setup the pin as a PWM pin. config-pin P9.42 pwm
# Export the control for the device, creating the directory structure that we w$ echo 0 > /sys/class/pwm/pwmchip0/export
# Setup the period for PWM to be 10000 to make things nice and easy to work wit$ echo 10000 > /sys/class/pwm/pwmchip0/pwm0/period
# Setup the duty cycle to the value passed in as $1 echo $1 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
However, when I rebooted my machine, the pin failed to toggle. I believe I inadvertently did something with capes that wasn’t enabled when I first tried it. I then tried this script on my home beaglebone, running Robert Nelson’s image bone-debian-8.3-lxqt-4gb-armhf-2016-02-21-4gb.img. This one, however, fails with the following:
root@beaglebone:~# ./pwm2.sh 1000
P9_42 pinmux file not found!
cape-universala overlay not found
run “config-pin overlay cape-universala” to load the cape
./pwm2.sh: line 12: echo: write error: Device or resource busy
./pwm2.sh: line 15: /sys/class/pwm/pwmchip0/pwm0/period: No such file or directory
./pwm2.sh: line 18: /sys/class/pwm/pwmchip0/pwm0/duty_cycle: No such file or directory
./pwm2.sh: line 21: /sys/class/pwm/pwmchip0/pwm0/enable: No such file or directory
root@beaglebone:~#
I’ve tried the following, which results in different errors but still errors:
root@beaglebone:~# config-pin overlay cape-universaln
Loading cape-universaln overlay
bash: line 0: echo: write error: File exists
Error loading device tree overlay file: cape-universaln
root@beaglebone:~# ./pwm2.sh 1000
P9_42 pinmux file not found!
cape-universala overlay not found
run “config-pin overlay cape-universala” to load the cape
./pwm2.sh: line 12: echo: write error: Device or resource busy
./pwm2.sh: line 15: /sys/class/pwm/pwmchip0/pwm0/period: No such file or directory
./pwm2.sh: line 18: /sys/class/pwm/pwmchip0/pwm0/duty_cycle: No such file or directory
./pwm2.sh: line 21: /sys/class/pwm/pwmchip0/pwm0/enable: No such file or directory
root@beaglebone:~#
Have you solved the problem that you were having? I am unsure why you are getting the error:
P9_42 pinmux file not found!
cape-universala overlay not found
I am currently trying to figure out how the PWM pins work in the 4.1+ Kernel and it appears that after each reboot the pwmchip* links in the /sys/class/pwm/ directory link to different directories in the ocp directory. For P9.42, look for the pwmchip link that links to the /sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip? directory and then your code works for me.