Marlin 2 Printer paused instead of canceling print from SD card

What is the problem?

When I start a print from SD card everything works fine, untill I hit the cancel print button in octoprint. Instead of canceling the print, it changes it's status to "Print Pauses" on the LCD display and moves to parking position. The nozzle cooles down and I can restart the print via octoprint by klicking on reheat and continue in some message windows. Then the Printer wants to continue, by moving to the right place, but stops for a short time, homes again and turns off the nozzle and bed (I think because of the "after cancel print GCODE script" in octoprint). After that the print starts again without heated nozzel and bed.

When i print a file stored on the rasPi everything works fine. But i have some artifacts on the print caused by a slow data transfer. This issue can be solved with a workaround but thats another topic. I want to print directly from the SD card.

The problem occured after i updated my Ender 3 Max on Marlin
I used the Configuration.h and Configuration_adv.h provided by Marlin for the Ender 3 Max to
compile the Firmware.
I had to disable Z_SAFE_HOMING, otherwise the printer didn't home correctly
I disabled S_CURE_ACCELERATION in config and LIN_ADVANCE in the config_adv
I enabled CLASSIC_JERK in cofig (to disable junction deviation)


What did you already try to solve it?

I tried to analized the problem and may traced down the reason in the serial_log

serial (29).log (64.4 KB)

after i canceld the print (Timestemp: 2021-12-17 12:48:17,451)
there is the command M25 witch means according to "pause sd print"
the right command should be M524 (Abort SD print), or is there another problem I missed?
My idear is to change the M25 to M524 when i kick on the print cancel button, but i don't know how to do that. But maybe there is an other option I don't get.

I hope you can help me solving this problem.

Have you tried running in safe mode?


Did running in safe mode solve the problem?

Not tried

Systeminfo Bundle

You can download this in OctoPrint's System Information dialog ... no bundle, no support!) (49.8 KB)

Additional information about your setup

OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ... as much data as possible

Octoprint v1.7.2, OctoPi v0.18, Firmware Marlin, Browser Chrome, Win10

M524 was added to Marlin 2 so it isn't implemented in a lot of 3D printers. I can't speak to changing the core OctoPrint (see below) but I believe there are enough events and hooks available to write a plugin which could could capture M25 and convert it to M524 in the appropriate circumstances.

In OctoPrint\src\octoprint\util\ changing line 1746 from M25 to M524 should work in your case.

A plugin would hook the octoprint.comm.protocol.gcode.sending to intercept the M25 and the EventHandlerPlugin to capture the cancelling event.

1 Like

In OctoPrint\src\octoprint\util\ changing line 1746 from M25 to M524 should work in your case.

That sounds like the perfect solution. I downloaded the files on GitHub and changed the line 1746 in accordingly.
Now i can't figure out how i can set up an image for my rasPi with the changed I know, its a trivial question but i find no installation guide for the raw files. Just the pip install or the installation with rasPi imager, where you select the OctoPi image.

Unfortunately, my knowledge of OctoPrint doesn't extend beyond reading the sources. I have written a plugin or two but that's it. I'd suggest you go to the OctoPrint Discord and ask in one of the support or development channels. If I have some time, I'll try and put a plugin together but there are folks that hang out on Discord that can probably do it faster than I can.

Okay, i'll try to contact someone via discord. Thank you for the fast and very good help.
I will update this topic for sb who ran into the same issue.

I solved the Problem

Optional step:
Install Octopi via the Rasberry Pi Imager on the SD Card of the Pi (to have the vanilla version, without plugins, of octoprint on your Pi)

  1. Download Octoprint from GitHub and extract it.

  2. In the extracted files go to OctoPrint\src\octoprint\util\ and open with an text editor (I did it with Visual Studio, but the normal Editor from windows should also work).

  3. just Change M25 to M524 (dont delete spaces, because it's a python script and spaces are part of the syntax!!!). save the file.

  4. zip the octoprint-master folder (it contains all files you downloaded from GitHub)

  5. Connect to OctoPrint via your browser. Open the Plugin Manager (Settings -> Plugin manager) Click on the "get more" icon. Select the modified zip folder you just created in the "from an uploaded file" section and click install (When you click install, i think you will loose your plugins and settings, but im not sure about that). Octoprint asked me to make an update, i ignored the message. Else it may be overwrite the again.

  6. Restart Octoprint and start a print from SD card, it should send the M524 instead of the M25 command when pressing the "cancel" button, but stay close to the printer if sth go wrong. you can verify it in the terminal view or enable the serial_log.

Notes: If you press the "about Octoprint" button in settings, the version is "0+unknown", thats a downside I noticed

In case you want to leave the core OctoPrint files alone, here is a zip file with a single file plugin that should accomplish the same thing. (708 Bytes)

The .py file should be placed in /home/pi/.octoprint/plugins


This should be a more convenient way for doing the task. especially if you want to update Octoprint later on. Thanks for your help.

Are you still able to use pause when you have this Python script installed as a plug-in?

I doubt it since the M25 command is the one for pausing, and it's always being replaced with cancel.

The plugin only converts M25 commands that occur when cancelling a print from SD card. Pause is a different event so it should still work. If it doesn't, let me know and I'll see if I can fix it.

Ah it's smarter than I thought it was - good job there, I wouldn't have thought of that. There could be cases where it misses the events (since they are fired async) but as long as there are no other blocking event handlers it shouldn't get behind.

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