Klipper Homing Timeout Issues
Problem Description
A communication timeout error occurs during the homing process:
Error during homing z: Communication timeout during homing
This issue is common in Z-axis homing scenarios with multiple MCUs. If the host has a high load during homing, or if multi-MCU communication responses are unstable, a timeout may be triggered.
- Verify that Klipper is installed correctly and can be started.
- Verify that the current user is the Klipper installation user.
- Ensure the paths in the commands below match your actual system.
- It is recommended to back up relevant files before modifying Klipper source code or adding scripts.
- Adjust Timeout
- Manage KlipperScreen
Method 1: Adjust Timeout
This method directly modifies the Klipper source file mcu.py and is only recommended for confirming homing timeout issues. This modification may be overwritten when updating Klipper; it is recommended to restore the default value after troubleshooting or verification.
First, back up the original file:
cp ~/klipper/klippy/mcu.py ~/klipper/klippy/mcu.py.bak
Modify TRSYNC_TIMEOUT in Klipper:
sed -i 's/TRSYNC_TIMEOUT = [0-9.]*$/TRSYNC_TIMEOUT = 0.05/' ~/klipper/klippy/mcu.py
Restart the Klipper service:
sudo systemctl restart klipper
View the current setting:
grep "TRSYNC_TIMEOUT =" ~/klipper/klippy/mcu.py
To restore the default value:
sed -i 's/TRSYNC_TIMEOUT = [0-9.]*$/TRSYNC_TIMEOUT = 0.025/' ~/klipper/klippy/mcu.py
sudo systemctl restart klipper
To restore from the backup file:
cp ~/klipper/klippy/mcu.py.bak ~/klipper/klippy/mcu.py
sudo systemctl restart klipper
Method 2: Manage KlipperScreen
Temporarily disable KlipperScreen to free system resources, reducing the likelihood of triggering a communication timeout during homing.
This method will add gcode_shell_command.py, a script directory, and macro configurations. Please confirm that your system allows shell commands, and ensure the script path matches your actual installation path.
Download Required Files
Standard System:
git clone https://cnb.cool/3dmellow/public/klipper-klipperscreen-manager
curl -# -L --retry 3 --retry-delay 2 -o ~/klipper/klippy/extras/gcode_shell_command.py https://raw.githubusercontent.com/dw-0/kiauh/master/kiauh/extensions/gcode_shell_cmd/assets/gcode_shell_command.py
FlyOS-FAST System:
cd /data
git clone https://cnb.cool/3dmellow/public/klipper-klipperscreen-manager
curl -# -L --retry 3 --retry-delay 2 -o /data/klipper/klippy/extras/gcode_shell_command.py https://raw.githubusercontent.com/dw-0/kiauh/master/kiauh/extensions/gcode_shell_cmd/assets/gcode_shell_command.py
Set Script Permissions
Standard System:
cd ~/klipper-klipperscreen-manager
chmod +x ~/klipper-klipperscreen-manager/scripts/*.sh
FlyOS-FAST System:
cd /data/klipper-klipperscreen-manager
chmod +x /data/klipper-klipperscreen-manager/scripts/*.sh
Create Configuration File
- Create a
klipper_macros.cfgfile in the Klipper configuration directory. - Add the following at the top of the
printer.cfgfile:
[include klipper_macros.cfg]
Configure Macro Commands
Add the following content to klipper_macros.cfg. Replace /data/klipper-klipperscreen-manager/scripts/ with your actual script path.
[gcode_shell_command disable_klipperscreen]
command: sh /data/klipper-klipperscreen-manager/scripts/disable_klipperscreen.sh
timeout: 5.0
verbose: True
[gcode_shell_command enable_klipperscreen]
command: sh /data/klipper-klipperscreen-manager/scripts/enable_klipperscreen.sh
timeout: 5.0
verbose: True
[gcode_macro RESTART_KlipperScreen]
variable_time: 60
gcode:
{% set wait_time = params.TIME|default(printer["gcode_macro RESTART_KlipperScreen"].time)|int %}
{action_respond_info("Wait time: %s seconds" % wait_time)}
RUN_SHELL_COMMAND CMD=disable_klipperscreen PARAMS={wait_time}
[gcode_macro ENABLE_KlipperScreen]
gcode:
{action_respond_info("Starting KlipperScreen immediately")}
RUN_SHELL_COMMAND CMD=enable_klipperscreen
Usage
Temporarily disable KlipperScreen:
RESTART_KlipperScreen
Specify a disable duration, e.g., 120 seconds:
RESTART_KlipperScreen TIME=120
Manually start KlipperScreen immediately:
ENABLE_KlipperScreen
This method temporarily disables the KlipperScreen interface to free system resources and reduce CPU load, thereby decreasing the chance of communication timeouts during homing.
Restoration Method
To no longer use this method, restore in order:
- Delete or comment out
[include klipper_macros.cfg]fromprinter.cfg. - Delete the configurations related to
disable_klipperscreen,enable_klipperscreen,RESTART_KlipperScreen, andENABLE_KlipperScreenfromklipper_macros.cfg. - Delete the downloaded script directory.
Standard System:
rm -rf ~/klipper-klipperscreen-manager
FlyOS-FAST System:
rm -rf /data/klipper-klipperscreen-manager
If no other feature in the system depends on gcode_shell_command.py, you can also delete that file. Before deleting, ensure no other macros are using RUN_SHELL_COMMAND.