Jump to content

Disappearing printer.cfg?


Recommended Posts

This is the third time this has happened now; fire up the Pi and the printer, and immediately get an error message about the serial connection.  Which would be issue number one (of a great many) since the printer.cfg file is there, but it's completely blank, just a "1" line number and nothing else.  Thankfully, after the first time it happened I got over the losing my mind thing and just rename the most recent backup as the current config file, but it's becoming annoying to have to do this repeatedly.  I smartened up this time and created a new directory holding the current *.cfg files for quick restore.  Has anybody else had to deal with vanishing printer.cfg files?

Link to comment
Share on other sites

The first thing I'd do is run an fsck on the filesystem.  Also check to see if the uptime is consistent with what you expect it to be.  I'm assuming that you'd notice if your rpi was crashing out all the time, but an unstable system cold cause weird filesystem issues (or vice versa!).

Beyond that ... is the "1" consistent?  It's a "1" every time?  In that case, I'd maybe go looking for whether I have any backup scripts or something installed, or any sort of script to do processing on the config.  "1" might not be a line number, it might be an exit code being left by some poorly-written wrapper script.  You could also look for cron jobs ("crontab -l" and/or "sudo crontab -l", though there could be some in /etc/cron*).  You might browser through /var/log/syslog to see if there are any suggestive errors.

You could do something like "sudo chattr +i printer.cfg".  That will set the immutable flag.  If you do this, you should log it somewhere so that you remember, because basically everything will bounce off of that file, including anything you are trying to do.  It's not a good solution, but it might cause whatever script is messing with the file to start failing, and those failures might help you figure out the root cause.

If none of the above makes any sense (and maybe even if it does), I am also a firm believer in simply reinstalling rather than debugging obscure issues.  SD cards are cheap, you can just pull the current card for reference when making your new build.  Your next build should be MUCH easier because you don't have to go down as many dead-end experiments.  Take notes as you build, so that over time you have a database of changes, and also so that each rebuild becomes easier.  When building out a new local service, I always try to circle back and do a rebuild after things have been stable for a few months, because I won't end up with a ton of extraneous packages and hacky scripts (alt: it's a good time to rewrite the hacky scripts to not be so hacky).  Worst case, you can always put the original SD card back in.

Link to comment
Share on other sites

One of my friends had almost this exact same issue. They were using a high quality SD card and had nothing wrong with their raspberry pi. The problem ended up being from them hard shutting down the raspberry pi by just flipping the power switch on the printer whenever they wanted to turn the printer off. Once they started properly shutting down the raspberry pi before flipping the power switch the problem went away. That was the first time I had actually seen a raspberry pi have file corruption from hard shutdown even though I knew it was possible. The reason I was able to determine that this was the most likely cause was that several of the log files had a corrupted line in them right at the time the printer was last turned off. I used Visual Studio Code to look at the log files, it shows corrupted lines with a red bar that says "NULL" over and over.

  • Like 1
Link to comment
Share on other sites

Hey dshess - - yes, each time this happened, the file is just empty.  The "1" is a line number, not a 1 entered on line 1, just the line number with no content in the line... like it's 'waiting for input.'  Definitely no backup scripts in use (at least nothing implemented by me), don't think there even are any on board.  I'm with you on the periodic re-install for sure.  I do the same thing to my PCs every year or so (Windows and Linux both, though usually Windows needs it far more than Linux does!), when it starts to show signs of slowing down sometimes or any glitchy behavior.  Seems reasonable to do the same with the Pi too.  Makes coming back from any kind of disaster much easier since a complete re-install and setup is something you've done frequently.

Thanks Gunner - - I feel stupid for asking, but what's the *proper* way to shut down?  I've been doing exactly that, just hitting the power button for the Pi, then the printer.  Not following *any* kind of orderly shutdown procedure, which in hindsight is pretty stupid, since that's not how I shut down my PC!

Link to comment
Share on other sites

Posted (edited)
1 hour ago, kharrisma said:

Thanks Gunner - - I feel stupid for asking, but what's the *proper* way to shut down?  I've been doing exactly that, just hitting the power button for the Pi, then the printer.  Not following *any* kind of orderly shutdown procedure, which in hindsight is pretty stupid, since that's not how I shut down my PC!

Go to your printer's interface, Mainsail, Fluid, KlipperScreen etc. and select the "Shutdown" button. BUT WAIT for at least 30 seconds or more for the OS (debian) to shut down all processes and close any opened files before power is removed. Then you can power off the printer.

Actually, Pi has a "Drive" (SD) LED which you can see very active during power up, reboots and shut down. Unfortunately, the Pi in the printers is not visible so, just give it a minute to fully shut down before removing the power.

Finally, if you have a Klipperscreen panel, during shut down you can see the OS shutting down processes etc. and then stops sending text to the screen. I will recommend waiting for an additional 30 seconds as the OS is still active, but the display is not any more before powering off.2025-06-08_21h16_09.thumb.jpg.b4aada30b922cfb0b07b47fff44afb7f.jpg

Edited by NikosSprocket
Link to comment
Share on other sites

My "pro tip" for shutting down rpi computers is ... I just don't bother.  My Voron machine already shuts down all the fans and stuff, so I don't care.  The hacked bedslingers I will shut down the "printer" part, but the rpi sitting next to it I just leave on all the time.  It probably costs me an extra $3/year/rpi or something, but recovering a messed up filesystem once is worse than that.

Link to comment
Share on other sites

That's something I've long wondered about, regarding electronic stuff, particularly computers: is it better for the hardware to shut down and turn on repeatedly, or just leave it running?  The constant thermal cycling of the components from repeatedly turning them on and off can't be doing them any good (and over time can trash an iffy solder point), can't find anything like a definitive answer as to whether it's benign, malignant or makes-no-difference.  There's this incandescent light bulb in a firestation in California that's been in nearly continuous service since 1901 - - culled this from an online authority:  "Several reasons have been cited for the bulb's extensive lifespan. Its continuous operation has largely eliminated the stresses associated with turning a light bulb on and off, the act of which causes the temperature of the bulb to increase and decrease."  I know PC's and lightbulbs aren't the same thing, but the same principal is in effect.  Either way, I'll be adopting the 'proper' shutdown procedure.  Input very much appreciated!  I like the idea of having two setups on two SD cards so there's a quick restore should things go sideways in a big way, but I'm also toying with the idea of hooking the Pi up to a higher-capacity SSD instead of using an SD card, which I've read can be problematic.  Can't say I can see a whole lot of difference between an SSD and an SD card - - they're both solid-state memory.

Link to comment
Share on other sites

12 hours ago, dshess said:

My "pro tip" for shutting down rpi computers is ... I just don't bother.  My Voron machine already shuts down all the fans and stuff, so I don't care.  The hacked bedslingers I will shut down the "printer" part, but the rpi sitting next to it I just leave on all the time.  It probably costs me an extra $3/year/rpi or something, but recovering a messed up filesystem once is worse than that.

This is exactly what I do. I leave both my printers on 24/7 so it's easy to start prints any time I want. The only time I turn off a printer is if I'm opening it up for a repair/mod, or if I'm traveling and there's no point in leaving a fire hazard on and unattended.

Link to comment
Share on other sites

7 hours ago, kharrisma said:

That's something I've long wondered about, regarding electronic stuff, particularly computers: is it better for the hardware to shut down and turn on repeatedly, or just leave it running?  The constant thermal cycling of the components from repeatedly turning them on and off can't be doing them any good (and over time can trash an iffy solder point), can't find anything like a definitive answer as to whether it's benign, malignant or makes-no-difference.  There's this incandescent light bulb in a firestation in California that's been in nearly continuous service since 1901 - - culled this from an online authority:  "Several reasons have been cited for the bulb's extensive lifespan. Its continuous operation has largely eliminated the stresses associated with turning a light bulb on and off, the act of which causes the temperature of the bulb to increase and decrease."  I know PC's and lightbulbs aren't the same thing, but the same principal is in effect.  Either way, I'll be adopting the 'proper' shutdown procedure.  Input very much appreciated!  I like the idea of having two setups on two SD cards so there's a quick restore should things go sideways in a big way, but I'm also toying with the idea of hooking the Pi up to a higher-capacity SSD instead of using an SD card, which I've read can be problematic.  Can't say I can see a whole lot of difference between an SSD and an SD card - - they're both solid-state memory.

All these are very good points @kharrisma. Personally, after I have run all the jobs for the day, I shut down and power-off the printers. Even when the motors are disengaged, part and extruder fans are not running etc. all your MCUs are running including the MCU fans! Other components running with power-on are all your PSUs (power supplies) and don't forget the KlipperScreen TFT.

Do you leave your audio amplifier and TVs running 24/7? If you do, then do the same for your printers.

Finally, because the power provided by the grid is ... not great, I personally utilize UPSs to power my printers. If you go this route, you need to use high KVA UPS as the bed heater can pull from 500 to 1,000 Watts depending on the size and some bargain UPSs cannot handle the bed heaters. I use APC UPS 1500VA Sine Wave Battery Backup. Also, I do not lose the print job when there is a brown-out! This UPS handles both my 300 and 350 Voron 2.4r2s but, I never "warm-up" both at the same time as that will exceed the UPSs capacity and damage it. If I use both printers at the same time, I warm up the 350s bed first and after the bed is fully heated then I turn on the 300, so I never pull more than 850–900 Watts for prolonged time.

I hope this gives you enough information for your printers.

Link to comment
Share on other sites

Yeah that pretty much confirms my own feelings on it, Nikos.  Actually, though, when I turn off my TV... it's not really OFF, as in unplugged from wall off.  It's in a standby state, so it's still energized.  Got a few other devices around here that are the same way; it amounts to a continual 'parasitic draw' on the house current.  Negligible in terms of absolute amount, but with these things, off isn't really OFF.  😉   With something like a printer, I'd prefer it be OFF when I'm done, as it's a potential fire hazard - - I wouldn't leave my countertop toaster-oven on unattended either.  It just *feels* safer, even if it does introduce more 'wear and tear' on the electronic components.  They're cheap enough.

Yah, *anything* that  makes heat draws a ferocious amount of current.  I haven't gone with UPSs, as if you want to run electronics you really need a true sine-wave UPS, not chopped DC, and true sine are a lot spendier than their 'chopper' cousins!  Power around here's pretty reliable, Winter and big storms with high winds being what usually takes it out.

  • Like 1
Link to comment
Share on other sites

If you look around, there are mods out there that let you add a GPIO-triggered safe shutdown.  People put something like one of those momentary push-button switches on their front panel (say for a Voron mod), using, oh, "uxcell Momentary Metal Push Button Switch 12mm 3-6v led" on Amazon.  The LED ones can double as a power indicator, but there are also simpler no-LED ones.

The basic idea is that you push the button and it causes the rpi to start shutting things down safely.  Presumably you could have the script do "everything", such as cancelling the current print and letting the tool head cool down first.  If your system has separate power for the printer and rpi, it might make more sense to put them off a smart plug of some sort which the rpi can trigger on the way down.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...