PWM Issues BeagleBoard.org Debian Image 2018-01-28

110 views
Skip to first unread message

Co M

unread,
Feb 16, 2018, 12:07:35 PM2/16/18
to BeagleBoard
Hi, (2018 Feb 16)
I went to many posts, but they look outdated from 1025 and beyond.
I am trying to enable the PWM on pin 14 and 16,  EHRPWM1A P9.14 and EHRPWM1B P9.16
My system details are:
    BeagleBoard.org Debian Image 2018-01-28
    Linux beaglebone 4.9.78-ti-r94 #1 SMP PREEMPT Fri Jan 26 21:26:24 UTC 2018 armv7l GNU/Li

The 2 dts's were compiled after they were generated using: http://www.kilobaser.com/blog/2014-07-28-beaglebone-black-devicetreeoverlay-generator

Here are my slots:

bbg@beaglebone:~/dtoverlay$ cat /sys/devices/platform/bone_capemgr/slots
 
0: PF----  -1
 
1: PF----  -1
 
2: PF----  -1
 
3: PF----  -1
 
4: P-O-L-   0 Override Board Name,00A0,Override Manuf,am33xx_pwm
 
5: P-O-L-   1 Override Board Name,00A0,Override Manuf,bsana_AIN0_39
 
6: P-O-L-   2 Override Board Name,00A0,Override Manuf,bspwm_P9_14_6
 
7: P-O-L-   3 Override Board Name,00A0,Override Manuf,bspwm_P9_16_6


Here are my sys files

./devices/platform/ocp/ocp:bs_pwm_test_P9_14
./devices/platform/ocp/48300000.epwmss
./devices/platform/ocp/48304000.epwmss
./devices/platform/ocp/48302000.epwmss
./devices/platform/ocp/ocp:bs_pwm_test_P9_16
./firmware/devicetree/base/__symbols__/epwmss2
./firmware/devicetree/base/__symbols__/epwmss0
./firmware/devicetree/base/__symbols__/bs_pwm_P9_16_0x6
./firmware/devicetree/base/__symbols__/epwmss1
./firmware/devicetree/base/__symbols__/bs_pwm_P9_14_0x6
./firmware/devicetree/base/ocp/epwmss@48304000
./firmware/devicetree/base/ocp/bs_pwm_test_P9_16
./firmware/devicetree/base/ocp/epwmss@48300000
./firmware/devicetree/base/ocp/bs_pwm_test_P9_14
./firmware/devicetree/base/ocp/epwmss@48302000
./firmware/devicetree/base/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_bs_pwm_P9_14_0x6
./firmware/devicetree/base/ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_bs_pwm_P9_16_0x6
./bus/platform/devices/ocp:bs_pwm_test_P9_14
./bus/platform/devices/48300000.epwmss
./bus/platform/devices/48304000.epwmss
./bus/platform/devices/48302000.epwmss
./bus/platform/devices/ocp:bs_pwm_test_P9_16
./bus/platform/drivers/pwmss/48300000.epwmss
./bus/platform/drivers/pwmss/48304000.epwmss
./bus/platform/drivers/pwmss/48302000.epwmss




But

root@beaglebone:/sys/devices/platform/ocp/ocp:bs_pwm_test_P9_14/of_node# echo 500000 > duty
bash
: duty: Permission denied



And

root@beaglebone:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3# ls
device    
export    npwm  power  subsystem    uevent    unexport

root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3# echo 1 > export
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3# echo 0 > export

# creates pwm0 and pwm1
power
/ pwm0/  pwm1/  
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3# cd pwm0/
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm0# ls
capture  duty_cycle  enable  period  polarity  power  uevent
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm0# echo 1 > period
bash
: echo: write error: Invalid argument
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm0# echo 10 > period
bash
: echo: write error: Invalid argument
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm0# echo 100 > period
bash
: echo: write error: Invalid argument
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm0# echo 10000 > period
bash
: echo: write error: Invalid argument
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm0# echo 100000 > period
bash
: echo: write error: Invalid argument
root@beaglebone
:/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm0# echo 1000000 > period




Thank you.




Robert Nelson

unread,
Feb 16, 2018, 12:17:47 PM2/16/18
to Beagle Board, marri...@gmail.com
On Fri, Feb 16, 2018 at 11:07 AM, Co M <marri...@gmail.com> wrote:
> Hi, (2018 Feb 16)
> I went to many posts, but they look outdated from 1025 and beyond.
> I am trying to enable the PWM on pin 14 and 16, EHRPWM1A P9.14 and EHRPWM1B
> P9.16
> My system details are:
>
> BeagleBoard.org Debian Image 2018-01-28
> Linux beaglebone 4.9.78-ti-r94 #1 SMP PREEMPT Fri Jan 26 21:26:24 UTC 2018
> armv7l GNU/Li
>
> The 2 dts's were compiled after they were generated using:
> http://www.kilobaser.com/blog/2014-07-28-beaglebone-black-devicetreeoverlay-generator

Well, "2018-01-28" support pwm's out of the box, so you don't have to
do all that extra work:

Just pick your pin and run the correct option:

config-pin P8_13 pwm
config-pin P8_19 pwm
config-pin P8_34 pwm
config-pin P8_36 pwm
config-pin P8_45 pwm
config-pin P8_46 pwm
config-pin P9_14 pwm
config-pin P9_16 pwm
config-pin P9_21 pwm
config-pin P9_22 pwm
config-pin P9_28 pwm
config-pin P9_29 pwm
config-pin P9_31 pwm
config-pin P9_42 pwm

Then go under /syc/class/pwm/ and enable/etc..

If they don't work, just run:

sudo /opt/scripts/tools/version.sh

and share it's output with us to help you fix what's broken..

Regards,

--
Robert Nelson
https://rcn-ee.com/

evilwulfie

unread,
Feb 16, 2018, 12:21:34 PM2/16/18
to beagl...@googlegroups.com
4.9 kernels do not use slots everything's loaded in uboot via uEnv.txt with a dtbo file
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/aab3e397-6918-4171-ad3c-326169404314%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Co M

unread,
Feb 16, 2018, 2:39:30 PM2/16/18
to BeagleBoard
FIXED.
PWM, Beagle Bone

Meanwhile I got an answer at: github.com cdsteinkuehler  beaglebone-universal-io
Though, I used the SDcard, the u-boot @ 2016 from eMMC took over.  I dd-it and wipe it.

 
For: EHRPWM1A   P9_14 
the sys file is: /sys/class/pwm/pwmchip3
echo
0 > export



EHRPWM1B    P9_16
the sys file is: /sys/class/pwm/pwmchip3
echo
1 > export



     cd /sys/class/pwm/pwmchip3
     echo
0 > export
     echo
1 > export
        echo
20000 > pwm0/period
        echo
10000 > pwm0/duty_cycle #  P9_14
        echo
1 > pwm0/enable

        echo
20000 > pwm1/period
        echo
10000 > pwm1/duty_cycle #  P9_16
        echo
1 > pwm1/enable



Robert Nelson

unread,
Feb 16, 2018, 2:55:17 PM2/16/18
to Beagle Board, Co M
Be careful, "pwmchip3" is not set in stone, and can move between
reboots/kernel/etc...

For P9_14/P9_16 go thru:

/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip*/

When you look at:

/sys/class/pwm/pwmchip3/ you see it symlinks back to above..

Co M

unread,
Feb 16, 2018, 4:03:58 PM2/16/18
to BeagleBoard
Thank you. Just ran into. :)

Co M

unread,
Feb 16, 2018, 4:41:38 PM2/16/18
to BeagleBoard
Hi,
Thank you. Just ran into, That's I am back to forum., though I hack it's initialization.


pwm1=$(config-pin -l P9.16 | grep pwm)
pwm2
=$(config-pin -l P9.14 | grep pwm)
[[ ! -z $pwm1 ]] && config-pin  P9.14 pwm
[[ ! -z $pwm2 ]] && config-pin  P9.16 pwm

pushd
/sys/class/pwm
right
=$(ls -l | grep 48302200 | awk '{print $9}')
echo
"found right chip $right"
if [[ ! -z $right ]];then
        pwmsys
=$right
        pushd $pwmsys
        echo
0 > export
        echo
1 > export
        pushd pwm0
                echo
10000 > period
                echo
5000 > duty_cycle
                echo normal
> polarity
                echo
1 > enable
        popd
        pushd pwm1
                echo
10000 > period
                echo
5000 > duty_cycle
                echo normal
> polarity
                echo
1 > enable
        popd
        popd
fi
popd





J
Reply all
Reply to author
Forward
0 new messages