MCU 'rpi' error during config: Unable to config pwm device - at boot only

Basic Information:

[x ] Printer Model: No model - homemade printer
MCU / Printerboard: BTT SKR v1.4
Host / SBC: Rpi 3B+
klippy.log

I added [mcu: rpi] and pwm corresponding config to control light.
Now the klipper is not starting correctly. Extruder fan is switched on Instead of normal start.
Octoprint is started normally, web interface is accesible.
After the Klipper restart (by click button Restart Firmware) then is restarted correctly - everything is working including lights.

Please help.

klippy.log (74.6 KB)

Explain that again?

Did Klipper stop working after you put in the caselight into your cfg?

Did you setup your Pi to enable PWM as described here under “Optional: Hardware PWM”?

https://www.klipper3d.org/RPi_microcontroller.html

Yes, I have configured Rpi correctly according instructions. The proof is, that after firmware restart everything is working.
Just klipper is not starting correctly at boot.

Is there some klipper dependencies on other processes?
Just I am thinking if everything - what is required - is ready when klipper starts.

Just to be clear:
I have this in /boot/config.txt:

# Enable pwmchip sysfs interface
dtoverlay=pwm,pin=12,func=4

This in /etc/rc.local:

# Enable pwmchip sysfs interface
echo 0 > /sys/class/pwm/pwmchip0/export

I found the problem. Seems Klipper is started earlier than the command in the /etc/rc.local.

I put the same command into klipper init.d start script:

case "$1" in
start)  log_daemon_msg "Starting klipper" $NAME

        echo 0 > /sys/class/pwm/pwmchip0/export

        start-stop-daemon --start --quiet --exec $KLIPPY_EXEC \
                          --background --pidfile $PIDFILE --make-pidfile \
                          --chuid $KLIPPY_USER --user $KLIPPY_USER \
                          -- $KLIPPY_ARGS
        log_end_msg $?
        ;;

and now klipper is starting correctly.

But this solution is not really good - start script can be overwritten during upgrade.
So question is - where to place the command to execute it before the klipper?

Also the question - why is the extruder fan started when pwm is not exported?

This is more a Linux question than Klipper question:

This depends on your device and its configuration. E.g. see https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf#page=102

Thanks for the hint.
I created a simple “service” to export pwm.

pi@octopi:~ $ cat pwm_export.service 
[Unit]
Description=RPi PWM export required by klipper
Before=klipper-mcu.service

[Service]
User=root
Type=oneshot
ExecStart=sh -c '/usr/bin/echo 0 > /sys/class/pwm/pwmchip0/export'

[Install]
RequiredBy=klipper-mcu.service

File copied to the /etc/systemd/system.
Service enabled by systemctl.

systemctl enable pwm_export.service

It works.

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