Klipper Host MCU fails to initialize hardware PWM on Raspberry Pi GPIO

Basic Information:

Printer Model: Voron Switchwire
MCU / Printerboard: BTT SKR 1.4 Turbo
Host / SBC Raspberry Pi 4
klippy.log

klippy (2).zip (89.9 KB)

Klipper Host MCU: hardware_pwm: true Fails on Raspberry Pi GPIO

What Im attempting to do. Use hardware_pwm to make a passive buzzer play silly music when the print is done, an error has been cause, or filament runs out. In this case… RD2D sounds.
My other printer Im doing Zelda songs and sound effects. Cause Im a nerd.
I’ve never reported a Klipper error before, so please forgive me if I’m missing any important details. I’ve done my best to include everything requested and to provide as much detail as possible. I’m still a Klipper newbie, and I’ve never really dug this deep into any programming or software language before, so this has been half a learning experience and half a deep dive down a rabbit hole of problem-solving. Hopefully, I’ve got everything you need here, and if not, I’ll do my best to answer any questions that come up!

PROBLEM SUMMARY:
Klipper running on a Raspberry Pi fails to initialize any GPIO pin configured with hardware_pwm: true, even when the /sys/class/pwm/pwmchip0/ interface is correctly exposed by the OS and other userspace tools confirm PWM is available. This affects multiple RPi models and fresh installs of MainsailOS or Klipper on Raspberry Pi OS.


:test_tube: What I’ve Tested

I tested this across multiple printers, using:

  • Raspberry Pi 4 (with and without touchscreen)

  • MainsailOS

  • Latest versions of:

    • Klipper (as of July 28, 2025) (although the klipper.log file is on an older version

    • Moonraker\

    • Mainsail OS

Minimal working config:

[mcu rpi]
serial: /tmp/klipper_host_mcu

[output_pin r2_buzzer]
pin: rpi:gpio18
pwm: true
hardware_pwm: false #THIS WORKS
scale: 1000

When I enable hardware PWM:

[output_pin r2_buzzer]
pin: rpi:gpio18
pwm: true
hardware_pwm: true
scale: 1000

:firecracker: Klipper throws this error:

MCU 'rpi' shutdown: Unable to config pwm device


:white_check_mark: Confirmed Working Outside Klipper

With this /boot/config.txt:

dtoverlay=pwm-2chan
dtparam=audio=off
enable_uart=1
dtoverlay=disable-bt

Ive confirmed:

  • /sys/class/pwm/pwmchip0/pwm0 exists

  • raspi-gpio get 18 returns func=PWM0_0

  • dmesg | grep pwm shows device present

  • Manually writing to /sys/class/pwm/pwmchip0/... works fine (tone heard on passive buzzer)


:repeat_button: GPIOs Tested

I tried the following pins with identical results:

  • GPIO18 (PWM0)

  • GPIO19 (PWM1)

  • GPIO13 (PWM1 alternative)

All fail inside Klipper when hardware_pwm: true is set.


:puzzle_piece: Additional Notes

  • No other output_pin or hardware_pwm: true config exists in the Klipper setup.

  • Touchscreen and HDMI do not conflict — I tested with vc4-kms-v3d both on and off.

  • lsmod confirms no vc4 module conflict.

  • /sys/class/pwm/pwmchip0/ is always present at boot, even before Klipper launches.

  • Permissions and group ownership on /sys/class/pwm are standard and consistent.


:red_question_mark:Request

Can someone from the Klipper team or smarter than myself help determine:

  • Why Klipper Host MCU cannot initialize PWM hardware devices even when everything else confirms they are available?

  • Is this an ordering issue, privilege issue, or sysfs path expectation mismatch?

I’m happy to provide full logs, system info, or retest specific changes.

Thanks for the awesome project and for your time.

Did you follow Optional: Hardware PWM?

2 Likes

I could have sworn I had followed that to the T. It kept failing.

Course I just retried it because I had a doubt if in all my testing, I did fully follow it.

It now works. Current config should anyone be curious.

[mcu host]
serial: /tmp/klipper_host_mcu

[output_pin r2_buzzer]
pin: host:pwmchip0/pwm0
pwm: true
hardware_pwm: true
scale: 100
cycle_time: 0.0025

Thank you for you help, and redirecting me to what I should have already seen!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.