Search code examples
linux-kernelbeagleboarddevice-tree

Cannot Figure Out PWM Overlay for BeagleBone Green Wireless


I am new to BeagleBone Green Wireless (BBGW). I just read Derek Molloy's Exploring BeagleBone. Very good read, however, BBGW has Linux 4.4.9-ti-r25 and everything is quite different. Linux 4.4.9 no longer has the device tree source. Just has the device tree overlays (.dto). I am trying to experiment with the PWM's. I loaded am33xx_pwm-00A0.dtbo and BB-PWM1-00A0.dtbo overlays found in /lib/firmware. I presume these are default overlays for PWM1 but not sure.

export SLOTS=/sys/devices/platform/bone_capemgr/slots
export PINS=/sys/kernel/debug/pinctrl/44e10800.pinmux/pins

sudo sh -c "echo am33xx_pwm > $SLOTS"
sudo sh -c "echo BB-PWM1 > $SLOTS"

They appear to be loaded correctly,

root@beaglebone:/lib/firmware# cat $SLOTS
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 5: P-O-L-   0 Override Board Name,00A0,Override Manuf,am33xx_pwm
 7: P-O-L-   1 Override Board Name,00A0,Override Manuf,BB-PWM1

However, I cannot find where to access PWM1's properties. Malloy says that they are in, /sys/devices/ocp.3/pwm_test_p9_22.15. I could not find that directory and the closest I could find was /sys/devices/platform/ocp/. There are several devices but nothing about PWM1. Where can I find the location of PWM1's properties? I want to change them using the echo command using this example,

sudo su
echo 5000 > duty
echo 10000 > period
echo 1 > run

If someone knows of a good document that would be helpful as well.


Solution

  • I know you said you are close to solving it but I got it to work..

    Kernel: 4.4.30-ti-r64

    Distro: Debian 8.6 Jessie

    Now to load the PWM overlay...

    1. My distro is from RCN and comes with the overlays pre-populated in my /lib/firmware/ folder. If you have the overlays there continue to step 4, if not step 2.

    2. apt-get update

    3. sudo apt install bb-cape-overlays

    4. Load the overlay into the cape manager:

      echo BB-PWM1 > /sys/devices/platform/bone_capemgr/slots

    5. Ensure the overlay is loaded correctly by doing two things:

    First make sure it is in the capemanager:

    cat /sys/devices/platform/bone_capemgr/slots

    output:

    0: PF---- -1

    1: PF---- -1

    2: PF---- -1

    3: PF---- -1

    4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-PWM1

    The second is to make sure the pin is correctly muxed to do this:

    cd /sys/kernel/debug/pinctrl/44e10800.pinmux

    more pins | grep 848

    the output should be similar to this :

    pin 18 (44e10848.0) 00000006 pinctrl-single

    You can look into the overlay to get a deeper understanding of what is going on but it is a little outside the scope of this question.

    if you don't see the 00000006 output. Dont proceed. Reboot the BB and try again. This happened to me and a reboot solved the problem

    So, the BB is now ready for PWM.

    1. cd /sys/class/pwm
    2. cd pwmchip0
    3. echo 0 > export
    4. cd pwm0
    5. echo 1000000000 > period
    6. echo 800000000 > duty_cycle
    7. echo 1 > enable

    Ta-da. it should work. Sorry for the lengthy response. I wanted to be thorough.

    I followed the tutorial: http://www.teachmemicro.com/beaglebone-black-pwm-ubuntu-device-tree/

    Edit: This is for setting the PWM for P9_14