0

I wrote years ago a short c program for a Raspberry Pi (RPi3) using the pigpio library to send an infrared signal to a heating system. Still in use. The carrier frequency is 450 kHz, i.e., pretty fast for a RPi. Thus, I use hardware PWM and only need to switch PWM off and on (i.e., duty cycle 0% and 50%, respectively).

Since the latest RPiOS ("Raspbian") update, this no longer works; likely because the pigpio library uses the obsolete sysfs interface. I can confirm on the commandline that sysfs is no longer supported (while the same command works on another, not yet upgraded RPi):

~# uname --kernel-name --kernel-release --kernel-version
Linux 6.6.31+rpt-rpi-v7 #1 SMP Raspbian 1:6.6.31-1+rpt1 (2024-05-29)
~# echo 23 > /sys/class/gpio/export
-bash: echo: write error: Invalid argument

To my question: is there a library that supports hardware PWM and uses the character device interface? pigpio and RPi.GPIO (for Python) seem to use sysfs. libgpiod and wiringPi use the character device interface but I found no support for hardware PWM. Library bcm2835 only supports RPi1 and RPi2.

2
  • Hardware PWM is supported by the respective kernel driver. Not sure what you are trying to achieve with GPIO. Are you sure you understand the concept of hardware PWM? In the kernel it uses sysfs which never was switched to any other ABI so far. Commented Jul 7, 2024 at 20:11
  • Thanks. What I want to achieve (and did achieve in the past): GPIO connected to Darlington amplifier, connected to IR LED. Then sending IR signals to start and stop a bathroom heater. My PWM knowledge is certainly limited. Albeit sufficient to get it to work in the past. I also forked some years ago a lirc kernel module and modified it to support hardware PWM and not only software PWM. Commented Jul 9, 2024 at 6:21

1 Answer 1

0

Short answer - No.

The GPIO character device interface is strictly that - GPIO. PWM is a different kernel subsystem and has a totally separate interface.

While the GPIO sysfs interface has been deprecated in favour of the character device interface, for PWM you still use the PWM sysfs interface.

There is talk of adding a PWM character device/ioctl interface, but that has not even hit the mainline kernel yet (as of Linux 6.10), much less the Raspberry Pi branch, so you wont find a PWM character device/ioctl interface in current kernels.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. I was not aware that PWM and GPIO are so separate. Using directly the PWM sysfs interface should solve my issue.
There is a driver in review to add SW PWM on GPIO, using HR timer. It might be that driver makes v6.11.
FWIW the PWM GPIO driver is pending for the n ext cycle.
@0andriy I didn't mention pwm-gpio in my answer as this question is about interfaces, and the pwm-gpio module doesn't add a new PWM interface - it allows any GPIO to be driven as a SW PWM using the PWM interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.