Klipper Shutdown When Moving Manual Stepper Simultaneously

Basic Information:

Printer Model: Voron Trident
MCU / Printerboard: BTT-SKR 1.4 & MELLOW Fly D8
Host / SBC: Orange Pi Zero 3
klippy.log

Fill out above information and in all cases attach your klippy.log file (use zip to compress it, if too big). Pasting your printer.cfg is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there

So i tried to make pico mmu (Pico MMU · lhndo/LH-Stinger Wiki · GitHub ) but when i comfigure my [manual_stepper] there is something wrong with it. when i move my stepper this message show up.

strange thing is, this message is only appear when i execute the macro/gcode command when stepper is moving. but when is stop and execute it. it works fine the stepper is moving correctly

klippy.log (5).zip (6.4 MB)

1 Like

Hi @zapprint ,

It looks like you’re getting an internal error on stepcompress, which is one of the more obscure errors. :thinking:

Have you seen Happy Hare MMU software? It has Pico MMU support and is much more robust than simple macros.

Git version: 'v0.13.0-212-g78462cff4-dirty'
Untracked files: klippy/extras/led_effect.py, klippy/extras/z_calibration.py
Branch: master
Remote: origin
....
b'stepcompress o=2 i=0 c=4 a=0: Invalid sequence'
Internal error on command:"MANUAL_STEPPER"
Traceback (most recent call last):
  File "/home/zopi/klipper/klippy/gcode.py", line 212, in _process_commands
    handler(gcmd)
  File "/home/zopi/klipper/klippy/gcode.py", line 140, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zopi/klipper/klippy/gcode.py", line 150, in <lambda>
    handler = lambda gcmd: self._cmd_mux(cmd, gcmd)
                           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zopi/klipper/klippy/gcode.py", line 315, in _cmd_mux
    values[key_param](gcmd)
  File "/home/zopi/klipper/klippy/extras/manual_stepper.py", line 120, in cmd_MANUAL_STEPPER
    self.do_move(movepos, speed, accel, sync)
  File "/home/zopi/klipper/klippy/extras/manual_stepper.py", line 81, in do_move
    self.sync_print_time()
  File "/home/zopi/klipper/klippy/extras/manual_stepper.py", line 47, in sync_print_time
    toolhead.dwell(self.next_cmd_time - print_time)
  File "/home/zopi/klipper/klippy/toolhead.py", line 463, in dwell
    self._advance_move_time(next_print_time)
  File "/home/zopi/klipper/klippy/toolhead.py", line 291, in _advance_move_time
    self._advance_flush_time(flush_time)
  File "/home/zopi/klipper/klippy/toolhead.py", line 278, in _advance_flush_time
    self.motion_queuing.flush_motion_queues(flush_time, sg_flush_time)
  File "/home/zopi/klipper/klippy/extras/motion_queuing.py", line 65, in flush_motion_queues
    raise mcu.error("Internal error in MCU '%s' stepcompress"
mcu.error: Internal error in MCU 'btt-skr' stepcompress
Transition to shutdown state: Internal error on command:"MANUAL_STEPPER"
...

Hmmm…

@zapprint, can you maybe show the minimal G-code sequence to reproduce that?

It can be related to recent refactoring, so you can also try switching to an older Klipper:

git checkout 3ef760c18
sudo systemctl restart klipper

So, if you can reproduce on the recent release and can’t with the older one, something has been broken recently.

Thanks.


@3dcoded, jfyi, generally, there is an assumption that you should not be able to crash vanilla Klipper, even by the macros.

This is not so obscure, in a sense. This means that, for some reason, itersolve generates steps with a 0 interval (infinite speed), or the stepcompress code does something strange and outputs that sequence.

1 Like

yeah i found out this is a problem with the klipper. i tried to roll back and it works

cd ~/klipper

sudo systemctl stop klipper

git reset --hard 17ce45d2

sudo systemctl start klipper

2 Likes

@koconnor JFYI,
I will try to make a fix, but it will take some time.

gcode, rp2040 printer.cfg, rp2040 kconfig just in case
Archive.zip (2.0 KB)

python3 klippy/klippy.py rp2040_printer.cfg -a /tmp/klippy_uds -i /tmp/bug.gcode -d out/klipper.dict -o test.serial
INFO:root:Starting Klippy...
INFO:root:Start printer at Wed Aug 20 20:12:39 2025 (1755713559.9 9055.3)
INFO:root:Extruder max_extrude_ratio=2.494510
INFO:root:Loaded MCU 'mcu' 134 commands (v0.13.0-237-gc4ac6e04c / gcc: (Arch Repository) 14.2.0 binutils: (GNU Binutils) 2.43)
MCU 'mcu' config: ADC_MAX=4095 BUS_PINS_i2c0a=gpio0,gpio1 BUS_PINS_i2c0b=gpio4,gpio5 BUS_PINS_i2c0c=gpio8,gpio9 BUS_PINS_i2c0d=gpio12,gpio13 ... BUS_PINS_spi1a=gpio8,gpio11,gpio10 BUS_PINS_spi1b=gpio12,gpio15,gpio14 BUS_PINS_spi1c=gpio24,gpio27,gpio26 CLOCK_FREQ=12000000 MCU=rp2040 PWM_MAX=255 STATS_SUMSQ_BASE=256 STEPPER_OPTIMIZED_EDGE=2 STEPPER_STEP_BOTH_EDGE=1
INFO:root:Sending MCU 'mcu' printer configuration...
INFO:root:Configured MCU 'mcu' (500 moves)
ERROR:root:b'stepcompress o=2 i=0 c=17 a=0: Invalid sequence'
ERROR:root:Internal error on command:"MANUAL_STEPPER"
Traceback (most recent call last):
  File "/home/nefelim4ag/Coding/klipper/klippy/gcode.py", line 212, in _process_commands
    handler(gcmd)
    ~~~~~~~^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/gcode.py", line 140, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
                          ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/gcode.py", line 150, in <lambda>
    handler = lambda gcmd: self._cmd_mux(cmd, gcmd)
                           ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/gcode.py", line 315, in _cmd_mux
    values[key_param](gcmd)
    ~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/extras/manual_stepper.py", line 120, in cmd_MANUAL_STEPPER
    self.do_move(movepos, speed, accel, sync)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/extras/manual_stepper.py", line 81, in do_move
    self.sync_print_time()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/nefelim4ag/Coding/klipper/klippy/extras/manual_stepper.py", line 47, in sync_print_time
    toolhead.dwell(self.next_cmd_time - print_time)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/toolhead.py", line 462, in dwell
    self._advance_move_time(next_print_time)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/toolhead.py", line 290, in _advance_move_time
    self._advance_flush_time(flush_time)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/toolhead.py", line 279, in _advance_flush_time
    self.motion_queuing.flush_motion_queues(flush_time, sg_flush_time,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                            trapq_free_time)
                                            ^^^^^^^^^^^^^^^^
  File "/home/nefelim4ag/Coding/klipper/klippy/extras/motion_queuing.py", line 67, in flush_motion_queues
    raise mcu.error("Internal error in MCU '%s' stepcompress"
                    % (mcu.get_name(),))
mcu.error: Internal error in MCU 'mcu' stepcompress
ERROR:root:Transition to shutdown state: Internal error on command:"MANUAL_STEPPER"
INFO:root:Dumping gcode input 1 blocks
Read 9055.314311: 'MANUAL_STEPPER STEPPER=sp_motor MOVE=300 SPEED=10 ACCEL=2000\nMANUAL_STEPPER STEPPER=sp_motor MOVE=100 SPEED=10 ACCEL=2000\n'
INFO:root:gcode state: absolute_coord=True absolute_extrude=True base_position=[0.0, 0.0, 0.0, 0.0] last_position=[0.0, 0.0, 0.0, 0.0] homing_position=[0.0, 0.0, 0.0, 0.0] speed_factor=0.016666666666666666 extrude_factor=1.0 speed=25.0
INFO:root:Reactor garbage collection: (0.0, 0.0, 0.0)
ERROR:root:Internal error on command:"MANUAL_STEPPER"
Once the underlying issue is corrected, use the
"FIRMWARE_RESTART" command to reset the firmware, reload the
config, and restart the host software.
Printer is shutdown

WARNING:root:Internal error on command:"MANUAL_STEPPER"
1 Like

JFYI,
I will try to make a fix, but it will take some time.

Thanks for the ping and the well designed test case. It’s this change in commit 5cbe7d83e that introduces the regression:

@@ -76,8 +75,6 @@ class ManualStepper:
         self.sync_print_time()
         self.next_cmd_time = self._submit_move(self.next_cmd_time, movepos,
                                                speed, accel)
-        self.trapq_finalize_moves(self.trapq, self.next_cmd_time + 99999.9,
-                                  self.next_cmd_time + 99999.9)
         toolhead = self.printer.lookup_object('toolhead')
         toolhead.note_mcu_movequeue_activity(self.next_cmd_time)
         if sync:

It’s not immediately clear to me why that change breaks the code - I’ll continue to look at it.

-Kevin

1 Like

I was able to track this down. The issue was actually introduced in commit 9399e738. I have created a PR at Fix flushing bug in manual_stepper by KevinOConnor · Pull Request #7019 · Klipper3d/klipper · GitHub that will hopefully fix the issue.

-Kevin

2 Likes