Hi,
I am replying to my own E-mail. I amanaged to get PWM to work on 3.18.1-bone1. I used the code from:
https://github.com/SaadAhmad/beaglebone-black-cpp-PWM
and the information from:
http://hipstercircuits.com/enable-pwm-on-beaglebone-with-device-tree-overlays/
Both these sites have information for 3.8 kernels and assume you have a working Cape manager. For 3.18.1 there is no cape manager. A a Newbie to this here is what I did to get it to go. May not be a correct way, but I do see in /sys/kernel/debug/pwm
platform/48304200.ehrpwm, 2 PWM devices
pwm-0 ((null) ):
pwm-1 (PWM_P8_13 ): requested enabled
And on an Osilloscope the expected trace of a swuare wave that I can change the Mark-Space ratio on.
There are some newbie things worth nothing here that I did not know until I went through this:
-
3.8 Kernel Device Tree Overlays ==> change these to XXX.dtsi files (device tree include files) for 3.18.1-bone1. You can do this by hacking out the target, fragment etc. stuff. Note (it took be a while to realize this) DTC also does an OVERLAY with dtsi and dts files too, so it is not limited to just Capemgr overlays.
-
You need to get a good control of the DTB generation of the kernel. Robert C . Nelson has this in his build_kernel.sh script.
As shown in this:
https://www.mail-archive.com/beagleboard@googlegroups.com/msg19714.html
you can break that out like this:
cpp -Wp,-MD,src/arm/.am335x-boneblack.dtb.d.pre.tmp -nostdinc -Iinclude -
Isrc/arm -Itestcase-data -undef -D__DTS__ -x assembler-with-cpp -o src/arm/.
am335x-boneblack.dtb.dts.tmp src/arm/am335x-boneblack.dts ;
dtc -O dtb -o src/arm/am335x-boneblack.dtb -b 0 -i src/arm -d src/arm/.
am335x-boneblack.dtb.d.dtc.tmp src/arm/.am335x-boneblack.dtb.dts.tmp ;
cat src/arm/.am335x-boneblack.dtb.d.pre.tmp src/arm/.am335x-boneblack.dtb.d.
dtc.tmp > src/arm/.am335x-boneblack.dtb.d
3) I found I had to edit the include dtsi files: am33xx.dtsi and
am335x-bone-common-pinmux.dtsi to remove conflicts, some of which do not become
apparent before you load the kernel and look a dmesg upon boot.
4) in the &am335x_pinmux bit. You can add pins with any name so long
as you do not have a label that matches something else already there.
5) in the &ocp bit, if you have more than one device driver, e.g. bone-pinmux-helper
that tries to grab a pin as well as your driver, in my case pwm_test, P8_13 then the
kernel module fails to load on boot, and dmesg shows errors. Fix this by commenting out
conflicts in the device tree files. (Not sure if this is the right way, but it worked
for me).
6) You need to know a bit about your silicon. In the TI Sitara AM335x not
all the components are switched on by default, you need to "turn on" in the device
tree. So as well as configuring the pin, you need to turn on the EHRPWM and Clocks.
And make a note of which EHRPWM and which *channel* of the EHRPWM to use for the pin
that you want to use PWM on. For P8_13 that is EHRPWM2 Channel 1, sometimes called Channel B.
A= 0, B = 1.
Internally in the AM335x Ti Sitara, not all bits are connected to all pins, you you need
to know a bit about the silicon so that the right internal components
are (1) Turned on and (2) connected up. (Note the AM335x manual is almost 5,000 pages!).
7) Understanding what is in your device tree is important. I used the reverse dtb to
dts function in the DTC compiler alot. That way you can see if your edits / hacks in
all the dtsi and dts files had the desired effect.
8) Egrep-ing in all the am33*.dts* files also helps a lot to see where all the names
and labels end up.
When I first looked at a full DTS file it looked like someone was randomly
bashing a keyboard with something. I soon realized it was his head ... !!!
Hope this helps someone. Best, Mike.