Klipper Firmware integration

Hi everyone,
I wanted to ask you if it was possible to insert the possibility to perform Klipper firmware updates directly from the repetier server web interface as other systems such as https://github.com/cadriel/fluidd or MainsailOS do now.
it would also be very useful to modify the firmware parameters in the printer.cfg file directly from repetier server.
I hope you can add these things in the next versions of repetier server to keep it up to date with the new firmware. Thanks so much.

Have a good day
Lorenzo

Comments

  • edited January 2021
    I agree!
    Furthermore there is no possibility to edit the printer.cfg inside Repetier Server, a request already made by me for some time, thing possible with MainsailOS and Octoprint (open source, so free frontend).
  • This requires the possibility to modify files in the os with enlarged privileges to succeed (config is normally not owned by repetier). For a general solution you must be able to define the files but a hacker could also set it to any other file - lets say passwords - and modify it. So to allow this I have to make the installation very insecure or I have to limit it to something that can only be configured in the os like with extcommands.xml - so no one from outside can use it to hack the computer. But it needs to be assigned to a printer which is a xml config file you can down and upload.

    For updating you could make a script called by extcommands.xml that executes the update. Just for editing I'm not sure how to solve. Maybe making some extra xml to edit some scripts and run commands on safe. Then also other files could be edited. But that still leaves the permission problem open.
  • I agree that this could create a danger to the files inside the device, but it is only about permissions on a single file that is in the user's folder, not to the entire file system.
    The problem remains that only Repetier Server cannot do it, and it is the only paid product of those mentioned above.
    This should make him more powerful than the others.
    My two cents...
  • I'm currently thinking about a script that can list/read/write ascii/utf-8 files for server config. Then it could be outsourced to that script that would execute what ever needed on write. That way also other config files could be made available if users add it to that script. But in the end the server is responsible for printer communication and handling print tasks. It is no os replacement that runs and configures all other existing software. But I think that would be a good intermediate solution allowing it to extend. With that we can  make also things like webcams or networks more configurable if someone wishes to do so.
  • any update on a better Klipper integration ?
  • No editor to edit files we have no permission for if you mean that.
  • edited December 2021
    In version 1.2.1 there is the integration for Klipper, excellent news, too bad there is no documentation of how to activate it.
    Nothing appears here in the "Klipper Configuration" drop-down menu, it is empty.
    Roland, if you need a beta tester for the next versions I can help you, at least with Klipper that I have always used.
    After running the update command this came out:

    Failed to open /dev/tty: No such device or address

    But anyway my printers with Klipper still work anyway.
  • I've also updated but when I open the clipper menu, an empty drop-down menu appears. I await your suggestions, thank you very much!
  • What do you mean with empty? If I call it I get something like this:

    https://cln.sh/9vIqma

    When you add a new printer with wizard and select Klipper as firmware it offers to install klipper for that installation. Afterwards it appears in your printer with empty config. You add it and save and save and restart klipper. Only thing you need to do manually is upload the firmware stub to your printer.

    Documentation about klipper install and what to do is in manual in chapter "Printer Configuration" at the end.

    Can you make a screenshot of what you consider "empty" or describe compared to my image. WIth old existing klipper install it of course does not contain any configurations. You must install with server or we have permission issues and don't know how to handle it. Only installations configured our way are editable and restartable in server.
  • edited December 2021
    Repetier said:
    What do you mean with empty? If I call it I get something like this:

    https://cln.sh/9vIqma

    When you add a new printer with wizard and select Klipper as firmware it offers to install klipper for that installation. Afterwards it appears in your printer with empty config. You add it and save and save and restart klipper. Only thing you need to do manually is upload the firmware stub to your printer.

    Documentation about klipper install and what to do is in manual in chapter "Printer Configuration" at the end.

    Can you make a screenshot of what you consider "empty" or describe compared to my image. WIth old existing klipper install it of course does not contain any configurations. You must install with server or we have permission issues and don't know how to handle it. Only installations configured our way are editable and restartable in server.

    https://postimg.cc/75pKKGYF

    If I already use many printers with Klipper I don't understand why I should delete their configuration and recreate them, as well as being full of groups and gcodes.



  • edited December 2021
    Klipper is installed in the classic path, for example the priter.cfg is in /home/pi/printer.cfg, and the file printer and klippy.log are in the tmp.
    I also tried to recreate the klipper.service service but it doesn't change anything.
    If it is a question of permissions tell me how to act to resolve.
  • I see the problem. Since you did not install one there is no config there preventing the page to work. From ssh run
    sudo -u repetierserver touch /var/lib/Repetier-Server/database/klipper/slug.cfg

    with slug.cfg replaced by slug name of the printer.

    Then go to klipper config scree again and you should see it. Now copy your klipper configuration into this, stop or uninstall old version and hit install button. Then you get same config with new klipper installation but manageable within repetier-server. This all only works when installs are in well defined folders. We also add a service that starts automatically on bootup.

    Here the part from docs about where what gets stored with whom as owner:

    Klipper

    Klipper is a printer firmware with a special twist. The firmware is split into two parts. A small part resides inside the printer and the bigger part is a daemon running on the same pc as the server. So to use any printer with Klipper, you need to install the Klipper daemon and configure it so it is accessible from server.

    Repetier-Server greatly minifies the required work. Already during installation with the printer wizard, you get offered to install the klipper daemon. You should always do this, even if you do not have a configuration yet. The instance must have the same name as the printer slug, so we can detect it correctly and can offer configuration with the server.

    When you installed the daemon successfully, you get the following files and directories, where we assume that the printer slug name was MyKlipper:

    • /var/lib/klipper/sockets/MyKlipper - Socket file for serial communication
    • /var/lib/Repetier-Server/database/klipper/MyKlipper.cfg - Printer configuration file
    • /opt/klipper/MyKlipper - Klipper git files. Here you can install the printer firmware part.

    In case your printer has no klipper stub matching the current version you need to create and upload that first. Please follow our instructions, which are adjusted to our installation method. First login to the pc via ssh.

    When you do the installation you need to become root first and cd to our installation path. Then you configure the printer board and compile the binary.

    sudo -i
    cd /opt/klipper/MyKlipper
    make menuconfig
    make

    The last command creates the required binary that needs to be installed on the printer board. For some you can just flash it to the connected printer, others require that you copy the file to a sd card on the printer and then reset the printer.

    For the direct upload you need to know the serial port. This is not the one you entered in Repetier-Server! In Repetier-Server you set the virtual port that connects to the klipper daemon, while here you need the serial port of the printer. Enter ls -l /dev/serial/by-id/* to get a list of currently connected serial devices. If you are unsure which one is the correct one, disconnect the other devices. Once you know the path, run the following commands (remember we again use the MyKlipper placeholder for your printer slug):

    service klipper_MyKlipper stop
    make flash FLASH_DEVICE=PathToSerialFromAbove
    service klipper_MyKlipper start

    Now the printer stub is on your printer and Klipper can connect, but nothing will happen. The configuration file is empty. Switch to the Repetier-Server gui and select inside the printer menu Klipper Configuration. Here you see by default the configuration associated with the printer, but in the dropdown you can switch between them. For the active printer configuration you will also see options to install/uninstall/restart Klipper. And everytime you save the configuration, it will restart printer with new settings. So now you can edit your configuration according to the Klipper documentation and activate it directly. The editor uses highlighting to better show which parts are comments, sections, options and associated gcodes. For sections and options it has a autocomplete function to help you to write the right syntax.

    In the installation directory in the config subdirectory you will find a lot of sample configurations. A easy way to copy it is to run cat config/filename.cfg and copy the shown configuration with copy and paste into the editor.

    Multiple Klipper Installations

    Our solution is not limited to one installation, so there is no difference in installing one or two or three instances. Only the CPU power and RAM are the limit.

  • edited December 2021
    Ok, now it's clear how the integration works, thanks.
    It would have been better if he leaned on standard path, i mean for klipper installation (the default is /home/pi/klipper and not /opt/klipper) and the various cfg, however better this way than nothing.
  • The standard path is not working by standard:-) Actually we use the standard path just with different folders since it is not running as user pi.
  • Repetier said:
    The standard path is not working by standard:-) Actually we use the standard path just with different folders since it is not running as user pi.

    And to update Klipper? I only see Install and Uninstall.
  • Uninstall followed by install is an update. This will not delete the config file so nothing gets lost.
  • edited December 2021
    Repetier said:
    Uninstall followed by install is an update. This will not delete the config file so nothing gets lost.

    Klipper you know it can work with multiple files in the configuration, did you expect that? That is, the cfg master can rely on other cfg ([include]), many for example keep all the macros in another file that must be recalled from the cfg master. From the server interface I understand that only the main cfg can be edited.
  • No did not expect that, but you can add files in same directory and edit them as well. Just use save as or touch file like first. Guess we should also add a new button for this. Need to play with that for more details.
  • edited December 2021
    Repetier said:
    Now copy your klipper configuration into this, stop or uninstall old version and hit install button. Then you get same config with new klipper installation but manageable within repetier-server.

    Once that operation is done, that is, I see the cfg I copied and pasted, I can't find INSTALL or UNINSTALL button anywhere, and before i removed Klipper from the system.
    I only see "Cancel, Save As and Save configuration".
  • You only see install button when the config file has same name as your printer slug - see e.g. url in browser for it. Uninstall only appears for that config if an active installation was found (with our system).

    For testing just stop your old klipper service - no need to delete it for that. Just note that on reboot prbably both will start so connection will fail as both use same serial. 
  • edited December 2021
    Repetier said:
    You only see install button when the config file has same name as your printer slug - see e.g. url in browser for it. Uninstall only appears for that config if an active installation was found (with our system).

    For testing just stop your old klipper service - no need to delete it for that. Just note that on reboot prbably both will start so connection will fail as both use same serial. 

    OK, from the url I see that printer is called Sapphire_Plus and I had omitted the underscore in the slug.
    Another interesting thing for Klipper would be to have a menu to invoke the macros included in the cfg, it would be very useful.
  • edited December 2021
    It would also be useful to be able to invoke a custom script to be able to flash the board.
    For example I use this by invoking it from Octoprint with one of the various plugins available, and it flashes the board without any problem.
    You know well that installing Klipper without flashing the board is useless, so it takes something to be able to do it without going to the shell, even if the make menuconfig is mandatory at least once, and obviously you can't do it from Repetier Server.

    #!/bin/bash
    sudo service klipper stop
    cd /home/pi/klipper
    git fetch --prune origin
    git reset --hard origin/master
    git clean -f -d
    make clean
    make
    ./scripts/flash-sdcard.sh /dev/ttyACM0 btt-skr-pro-v1.2
    sudo service klipper start
  • edited December 2021
    Where is the Klipper log saved with this integration? I only see the socket to connect Repetier Server on the correct port, but there is no log trace.
    Ok, found now, it is still in /tmp but with the name of the printer, good!
    The only thing I don't like is the constant accesses to the virtual port file during any print, the life of the MicroSd in this way falls brutally.
    Before being in /tmp I had ramdisk on for that folder, and it's not a good thing that it's now in /var/lib/klipper/sockets for that reason.
    It would therefore be useful if the printer log and virtual port were in the same folder.


  • > The only thing I don't like is the constant accesses to the virtual port file during any print, the life of the MicroSd in this way falls brutally.
    That is a os socket - why do you think it does write anything to disk? unix sockets and TCP/IP sockets also don't do that. And actually klipper puts only the link there - the real file is always in /dev/pts which is not even a physical filesystem - just mapped from linux. So all that happens is that klipper adds a link at connection, or do I miss something.

    Flashing the printer is a bit of a problem. There are several solutions and some include copying a compiled bin file to sd card and reinsert it. Will think about that - at least creating the bin file and offer a download might be an option, but you still have to login to configure klipper for the correct board and some extra options before you can compile. And that might change between klipper version so might make any server side solution invalid.
  • edited December 2021
    Yes, it's true.
    But not all boards flash by copying the bin to the SD.
    SKR Pro for example through a very clever script creates a virtual socket on the board MicroSD, copies the bin and performs a reset, Klipper flashed.
    Boards based on ArduinoDue also flash directly.

  • edited December 2021
    Now the Klipper native script to flash the board in which way it doesn't work, not good, so I believe that everything must therefore be thought differently:

    root@Raspberry3:/opt/klipper/Sapphire_Plus# ./scripts/flash-sdcard.sh /dev/ttyACM0 btt-skr-pro-v1.2
    Flashing /opt/klipper/Sapphire_Plus/out/klipper.bin to /dev/ttyACM0
    ./scripts/flash-sdcard.sh: line 85: /root/klippy-env/bin/python: No such file or directory

    So I go back to non-integration, at the most convenient at the moment imho.
    Editing the printer.cfg with WinSCP is not dramatic.
    Fluidd and Mainsail, but also Octoprint do not have these limitations as they work inside the user folder, so anything is possible.
    The idea of having a Klipper folder for each printer is not bad, but it would have to stay inside the user folder to skip all the limits of having to use root.




Sign In or Register to comment.