# BBB: Bullseye 22-07-01: pwm does not work

**URL:** <https://forum.digikey.com/t/bbb-bullseye-22-07-01-pwm-does-not-work/24223>\
**Category:** Linux Discussions\
**Created:** [July 28, 2022, 9:10am UTC](https://forum.digikey.com/t/bbb-bullseye-22-07-01-pwm-does-not-work/24223 "2022-07-28T09:10:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yrrah53](https://avatars.discourse-cdn.com/v4/letter/y/8797f3/32.png) [@yrrah53](https://forum.digikey.com/u/yrrah53)\
**Post date:** [July 28, 2022, 9:10am UTC](https://forum.digikey.com/t/bbb-bullseye-22-07-01-pwm-does-not-work/24223/1 "2022-07-28T09:10:56Z")

</div>

Hello,

I have recently updated my BBB to Debian Bullseye XFCE Image 2022-07-01. Serial I/O works but my application nicely running on older images gives errors when addressing pwm pins. My test script:  
import Adafruit\_BBIO.PWM as pwm  
pwm.start(“P8\_13”,50)  
pwm.start(“P8\_19”,60)  
pwm.stop(“P8\_13”)  
pwm.stop(“P8\_19”)

Gives the famous: RuntimeError: Unknown error. for line 2  
I can run config-pin commands without problem.  
Running the Python testscript in sudo or not does not make a difference.  
Please advise,  
Best regards,  
Harke

---

<div class="post-metadata">

**Author:** ![RobertCNelson](https://sea2.discourse-cdn.com/digikey/user_avatar/forum.digikey.com/robertcnelson/32/12_2.png) [@RobertCNelson](https://forum.digikey.com/u/RobertCNelson)\
**Post date:** [July 28, 2022, 1:11pm UTC](https://forum.digikey.com/t/bbb-bullseye-22-07-01-pwm-does-not-work/24223/2 "2022-07-28T13:11:20Z")

</div>

> [@yrrah53](#):
>
> import Adafruit\_BBIO.PWM as pwm  
> pwm.start(“P8\_13”,50)  
> pwm.start(“P8\_19”,60)  
> pwm.stop(“P8\_13”)  
> pwm.stop(“P8\_19”)

Adafruit\_BBIO has not been ported to v5.10.x-ti…

As long as you load the pwm overlay, you can echo those values into /dev/bone/pwm/\*

Regards,

---

<div class="post-metadata">

**Author:** ![yrrah53](https://avatars.discourse-cdn.com/v4/letter/y/8797f3/32.png) [@yrrah53](https://forum.digikey.com/u/yrrah53)\
**Post date:** [July 28, 2022, 2:33pm UTC](https://forum.digikey.com/t/bbb-bullseye-22-07-01-pwm-does-not-work/24223/3 "2022-07-28T14:33:54Z")

</div>

Hello Robert, thanks. I am afraid I am not sure what it means…  
Regards,  
Harke

---

<div class="post-metadata">

**Author:** ![RobertCNelson](https://sea2.discourse-cdn.com/digikey/user_avatar/forum.digikey.com/robertcnelson/32/12_2.png) [@RobertCNelson](https://forum.digikey.com/u/RobertCNelson)\
**Post date:** [July 28, 2022, 3:02pm UTC](https://forum.digikey.com/t/bbb-bullseye-22-07-01-pwm-does-not-work/24223/4 "2022-07-28T15:02:08Z")

</div>

Hi @yrrah53 first, there’s one package in 2022-07-01 that needs an update and it’ll be available in next week’s image with 2022-08-01…

Default: 2022-07-01

```auto
debian@BeagleBone:~$ tree /dev/bone/
/dev/bone/
├── i2c
│ ├── 0 -> ../../i2c-0
│ ├── 1 -> ../../i2c-1
│ └── 2 -> ../../i2c-2
├── spi
│ ├── 0.0 -> ../../spidev0.0
│ ├── 0.1 -> ../../spidev0.1
│ ├── 1.0 -> ../../spidev1.0
│ └── 1.1 -> ../../spidev1.1
└── uart
    ├── 0 -> ../../ttyS0
    ├── 1 -> ../../ttyS1
    ├── 2 -> ../../ttyS2
    ├── 3 -> ../../ttyS3
    ├── 4 -> ../../ttyS4
    └── 5 -> ../../ttyS5

3 directories, 13 files

```

First update bb-customizations package and enable it’s service file:

```auto
sudo apt update
sudo apt install --only-upgrade bb-customizations
sudo systemctl enable bb-symlinks.service

```

Then reboot…

```auto
sudo reboot

```

Now you will see the pwm symlinks…

```auto
debian@BeagleBone:~$ tree /dev/bone/
/dev/bone/
├── am335x
│ └── ecap
│ ├── 0 -> /sys/class/pwm/pwmchip0/pwm0
│ ├── 1 -> /sys/class/pwm/pwmchip1/pwm0
│ └── 2 -> /sys/class/pwm/pwmchip2/pwm0
├── counter
│ ├── counter0 -> /sys/bus/counter/devices/counter0
│ ├── counter1 -> /sys/bus/counter/devices/counter1
│ └── counter2 -> /sys/bus/counter/devices/counter2
├── i2c
│ ├── 0 -> ../../i2c-0
│ ├── 1 -> ../../i2c-1
│ └── 2 -> ../../i2c-2
├── pwm
│ ├── 0
│ │ ├── a -> /sys/class/pwm/pwmchip3/pwm0/
│ │ └── b -> /sys/class/pwm/pwmchip3/pwm1/
│ ├── 1
│ │ ├── a -> /sys/class/pwm/pwmchip5/pwm0/
│ │ └── b -> /sys/class/pwm/pwmchip5/pwm1/
│ └── 2
│ ├── a -> /sys/class/pwm/pwmchip7/pwm0/
│ └── b -> /sys/class/pwm/pwmchip7/pwm1/
├── spi
│ ├── 0.0 -> ../../spidev0.0
│ ├── 0.1 -> ../../spidev0.1
│ ├── 1.0 -> ../../spidev1.0
│ └── 1.1 -> ../../spidev1.1
└── uart
    ├── 0 -> ../../ttyS0
    ├── 1 -> ../../ttyS1
    ├── 2 -> ../../ttyS2
    ├── 3 -> ../../ttyS3
    ├── 4 -> ../../ttyS4
    └── 5 -> ../../ttyS5

22 directories, 13 files

```

Next, from: [Beagleboard:BeagleBone cape interface spec - eLinux.org](https://elinux.org/Beagleboard:BeagleBone_cape_interface_spec#PWM) we see:

```auto
P8_13 -> /dev/bone/pwm/2/b
P8_19 -> /dev/bone/pwm/2/a

```

Now let’s configure, P8\_13 & P8\_19 for pwm output:

```auto
debian@BeagleBone:~$ config-pin -l P8_13

Available modes for P8_13 are: default gpio gpio_pu gpio_pd gpio_input pwm

debian@BeagleBone:~$ config-pin -l P8_19

Available modes for P8_19 are: default gpio gpio_pu gpio_pd gpio_input pwm

```

```auto
debian@BeagleBone:~$ config-pin P8_13 pwm

Current mode for P8_13 is: pwm

debian@BeagleBone:~$ config-pin P8_19 pwm

Current mode for P8_19 is: pwm

```

Then go under /dev/bone/pwm/2/b and /dev/bone/pwm/2/a and configure your pwm device!

```auto
debian@BeagleBone:/dev/bone/pwm/2/b$ tree
.
├── capture
├── duty_cycle
├── enable
├── period
├── polarity
├── power
│ ├── async
│ ├── autosuspend_delay_ms
│ ├── control
│ ├── runtime_active_kids
│ ├── runtime_active_time
│ ├── runtime_enabled
│ ├── runtime_status
│ ├── runtime_suspended_time
│ └── runtime_usage
└── uevent

1 directory, 15 files

```

at a minimal, you need duty\_cycle, period, and enable…

Regards,

---

<div class="post-metadata">

**Author:** ![yrrah53](https://avatars.discourse-cdn.com/v4/letter/y/8797f3/32.png) [@yrrah53](https://forum.digikey.com/u/yrrah53)\
**Post date:** [July 28, 2022, 7:17pm UTC](https://forum.digikey.com/t/bbb-bullseye-22-07-01-pwm-does-not-work/24223/5 "2022-07-28T19:17:06Z")

</div>

Thank you Robert, can’t wait to download the next version… It all works like you wrote. But how can I change the value of enable, duty\_cycle and period? I am not a programmer, I am a ham using a Beaglebone to control my EME antenna.  
my best,  
Harke

---

<div class="post-metadata">

**Author:** ![RobertCNelson](https://sea2.discourse-cdn.com/digikey/user_avatar/forum.digikey.com/robertcnelson/32/12_2.png) [@RobertCNelson](https://forum.digikey.com/u/RobertCNelson)\
**Post date:** [July 28, 2022, 7:33pm UTC](https://forum.digikey.com/t/bbb-bullseye-22-07-01-pwm-does-not-work/24223/6 "2022-07-28T19:33:33Z")

</div>

> [@yrrah53](#):
>
> It all works like you wrote. But how can I change the value of enable, duty\_cycle and period? I am not a programmer, I am a ham using a Beaglebone to control my EME antenna.

[https://docs.kernel.org/driver-api/pwm.html#using-pwms-with-the-sysfs-interface](https://docs.kernel.org/driver-api/pwm.html#using-pwms-with-the-sysfs-interface)

> When a PWM channel is exported a pwmX directory will be created in the pwmchipN directory it is associated with, where X is the number of the channel that was exported. The following properties will then be available:
> 
> period  
> The total period of the PWM signal (read/write). Value is in nanoseconds and is the sum of the active and inactive time of the PWM.
> 
> duty\_cycle  
> The active time of the PWM signal (read/write). Value is in nanoseconds and must be less than the period.
> 
> polarity  
> Changes the polarity of the PWM signal (read/write). Writes to this property only work if the PWM chip supports changing the polarity. The polarity can only be changed if the PWM is not enabled. Value is the string “normal” or “inversed”.
> 
> enable  
> Enable/disable the PWM signal (read/write).
> 
> 0 - disabled
> 
> 1 - enabled

On the board, just run:

```auto
debian@BeagleBone:/dev/bone/pwm/2/b$ echo 1000 > period 
debian@BeagleBone:/dev/bone/pwm/2/b$ echo 500 > duty_cycle 
debian@BeagleBone:/dev/bone/pwm/2/b$ echo 1 > enable 

```

as one example…

Regards,
