Enabling pwm2_m1


Is anybody having a problem activating pwm2_m1? I have pwm0_m1 enabled but unable to activate pwm on pin 3 with these overlays enabled


I get the error

Traceback (most recent call last):
  File "/home/rock/test_cp2.py", line 5, in <module>
    cppwm = mraa.Pwm(3)
  File "/usr/local/lib/python3.9/dist-packages/mraa.py", line 483, in __init__
    _mraa.Pwm_swiginit(self, _mraa.new_Pwm(pin, owner, chipid))
ValueError: Error initialising PWM on pin

with the following python code to test

from __future__ import division
import time
import mraa

cppwm = mraa.Pwm(3)




What is

journalctl | grep mraa


Nothing much, just this

Jun 28 13:33:11 radxa-cm3-io libmraa[775]: libmraa version v2.1.0-24-gbd91964 initialised by user 'rock' with EUID 1000
Jun 28 13:33:11 radxa-cm3-io libmraa[775]: gpio: platform doesn't support chardev, falling back to sysfs
Jun 28 13:33:11 radxa-cm3-io libmraa[775]: libmraa initialised for platform 'Radxa CM3 IO' of type 32

At least your board is recognized correctly by libmraa.

Check if you have

/sys/class/pwm/pwmchip2 (that directory should exist if the pwm2_m1 overlay is loaded and controls pin 3) and /sysclass/pwmchip0 (controlling pin 11)

I have the following, not sure why pwmchip1 is listed and not 2?

rock@radxa-cm3-io:/sys/class/pwm$ ls
pwmchip0  pwmchip1

But the following listed in extlinux.conf

rock@radxa-cm3-io:/sys/class/pwm$ cat /boot/extlinux/extlinux.conf 
#timeout 10
#menu title select kernel

label kernel-4.19.193-58-rockchip-gbac1feba87f0
    kernel /vmlinuz-4.19.193-58-rockchip-gbac1feba87f0
    initrd /initrd.img-4.19.193-58-rockchip-gbac1feba87f0
    devicetreedir /dtbs/4.19.193-58-rockchip-gbac1feba87f0
    fdtoverlays  /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-fiq-debugger-uart2m0.dtbo /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-disable-npu.dtbo /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-pwm0-m1.dtbo /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-i2c2-m0.dtbo /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-spi3-m0-cs0-spidev.dtbo /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-pwm2-m1.dtbo
    append   root=UUID=c7587256-cdaa-4c3f-a313-d1da45d126a2 earlyprintk console=ttyFIQ0,1500000n8 console=tty1 consoleblank=0 loglevel=7 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 switolb=1 coherent_pool=1m

I format your fdtoverlay line so it is easier to read:


You load i2c2-m0 AND pwm2-m1. This will not work, because BOTH require pin 3 (SDA for i2c2).

remove i2c2-m0.

BTW: You seem to use the Ubuntu image. While it might be “user friendly”, the Radxa Debian image might be more suited for initial HW setup. The rsetup utility for instance should detect such double assignments…

1 Like

Doh! That would make sense, I need 2 x PWM, 1 x I2C and 1 SPI. Which looks to be a struggle as there is not a complete set of overlays for all and I see now we have/had duplicates.

rock@radxa-cm3-io:/sys/class/pwm/pwmchip1$ cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION="11 (bullseye)"

Can’t see rsetup is installed by default but will take a look. Thanks

I think if we can get dtoverlays for I2C2_M1 then we are good, is there a repo with additional dtoverlays anywhere?

EDIT: Found them!

Thanks for your help!

I now only have the following enabled


But still not able to use pwm on mraa pin 5?

Not able to get rsetup to install to check for duplicates so not quite sure what I am doing wrong

Assuming you use this image https://github.com/radxa-build/radxa-cm3-io/releases/download/20221101-0118/radxa-cm3-io-debian-bullseye-xfce4-arm64-20221101-0302-gpt.img.xz, then yes, no rsetup. I thought all Radxa Debian images have it :frowning:

Anyway, what does this 3 lines mean?

/dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-fiq-debugger-uart2m0.dtbo /dtbs/4.19.193-58-rockchip-gbac1feba87f0/rockchip/overlay/rk3568-disable-npu.dtbo 

Inside your /boot/extlinux/extlinux.conf all overlays must be in ONE line (after fdtoverlays) if I understand the syntax correctly, no line breaks allowed.

I copied out the overlays and separated onto thier own lines to make it easier to read. In extlinux.conf they are all on one line

In /sys/class/pwm, I have pwmchip0 and pwmchip1 showing but don’t seem to be able to use use pwmchip1 in ether mraa or the export and use directly in sysfs.