Klipper on FreeBSD

Hi,

I have an SBC that I only can install FreeBSD (probably OpenBSD, too), and from searching for some information I understand I just need Python3, and a “bit” of a preparation, and it should work.

Firstly, has anyone ever done it already? I would love to compare notes.

Secondly, at my first attempt, to me it seems the code uses linux headers (maybe just this one).

(klippy-env) [gal@klipper ~]$ /home/gal/klippy-env/bin/python /home/gal/klipper/klippy/klippy.py /home/gal/printer_data/config/printer.cfg -I /home/gal/printer_data/comms/klippy.serial -l /home/gal/printer_data/logs/klippy.log -a /home/gal/printer_data/comms/klippy.sock
/home/gal/klipper/klippy/chelper/pyhelper.c: In function 'get_monotonic':
/home/gal/klipper/klippy/chelper/pyhelper.c:21:29: error: 'CLOCK_MONOTONIC_RAW' undeclared (first use in this function); did you mean 'CLOCK_MONOTONIC_FAST'?
   21 |     int ret = clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
      |                             ^~~~~~~~~~~~~~~~~~~
      |                             CLOCK_MONOTONIC_FAST
/home/gal/klipper/klippy/chelper/pyhelper.c:21:29: note: each undeclared identifier is reported only once for each function it appears in
/home/gal/klipper/klippy/chelper/serialqueue.c:15:10: fatal error: linux/can.h: No such file or directory
   15 | #include <linux/can.h> // // struct can_frame
      |          ^~~~~~~~~~~~~
compilation terminated.
Traceback (most recent call last):
  File "/home/gal/klipper/klippy/klippy.py", line 367, in <module>
    main()
  File "/home/gal/klipper/klippy/klippy.py", line 349, in main
    main_reactor = reactor.Reactor(gc_checking=True)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gal/klipper/klippy/reactor.py", line 311, in __init__
    SelectReactor.__init__(self, gc_checking)
  File "/home/gal/klipper/klippy/reactor.py", line 100, in __init__
    self.monotonic = chelper.get_ffi()[1].get_monotonic
                     ^^^^^^^^^^^^^^^^^
  File "/home/gal/klipper/klippy/chelper/__init__.py", line 295, in get_ffi
    do_build_code(cmd % (destlib, ' '.join(srcfiles)))
  File "/home/gal/klipper/klippy/chelper/__init__.py", line 271, in do_build_code
    raise Exception(msg)
Exception: Unable to build C code module (error=256)
^C

Any help is appreciated!

Welcome galmiklos,

Just out of curiosity, why can you just use FreeBSD? Which SBC are you using? You also could describe your printer.

The SBC is a “Niuguy NIU-one”, intel based “mini” computer, I used it as my firewall, but upgraded the firewall, so it is just collecting dust, why not try to use it? It is still plenty powerful to run linux or freeBSD. The problem, is that there is some weird video hardware in it, and any linux distro just goes black screen at the beginning of the installation, even in text mode. I have been trying to install ubuntu for weeks, but didn’t get anywhere. So, I thought I’ll try to go down another road, installing klipper on freeBSD. But kiauh works only with linux (perhaps even only debian based distros). So, I am now trying to install klipper manually.

I am building a Voron2, and I am going to use a SmartPrintCoreH7x board (or two, since it only has 5 stepper drivers). I already have successfully set up klipper to run on the board, I just didn’t want to buy a RPi just to run clipper, when I have a perfectly good computer. :wink:

1 Like

Never heard of this SBC.

You’ll spend a bunch of money to build the Voron probably 2.4. Why don’t you get a Klipper supported SBC for your Voron 2.4 project.

When you run into problems, you’ll get better and quicker support here!

I would spend the money, even free time spent time “sucks” :smiling_face_with_sunglasses:

Niuguy NIU-one is one of those noname cheap mini PCs one can set up as a firewall (Amazon.com: NiuGuy® 4 Port, Firewall Micro Appliance/Mini PC, VPN, Router, IPC, Intel Pentium N3540 4-core, AES-NI, 4GB RAM, 32GB mSATA SSD(Charm Blue) : Electronics), it’s got 4 NICs, 4 core CPU, 4G RAM, 32G SSD. I think it’s more powerful than a RPi 3B+, and this is what’s in the BOM generated by the VoronDesign configurator: “RaspberryPi 3B+ or better”. I don’t suppose “better” refers to quality… So, I really comply. :rofl:

1 Like

Yeah, that appears to be the syscalls for Linux’s time tracking. Perhaps the Linux ABI support in FreeBSD might be enough?

with more high-level details here:

The supported syscalls do include the ones for time management. :crossed_fingers:

I tried adding linux_enable=“YES” to /etc/rc.conf, but it didn’t help. I have a feeling that would only help if I already had a linux binary (just guessing), but in my case, the c_helper.so module compilation just fails.

I dug out the compile command from klipper/klippy/chelper/init.py, and executed it, and got the same error.

[gal@klipper ~/klipper/klippy/chelper]$ gcc -mfpmath=sse -msse2 -Wall -g -O2 -shared -fPIC -flto -fwhole-program -fno-use-linker-plugin -o /home/gal/klipper/klippy/chelper/c_helper.so /home/gal/klipper/klippy/chelper/pyhelper.c /home/gal/klipper/klippy/chelper/serialqueue.c /home/gal/klipper/klippy/chelper/stepcompress.c /home/gal/klipper/klippy/chelper/itersolve.c /home/gal/klipper/klippy/chelper/trapq.c /home/gal/klipper/klippy/chelper/pollreactor.c /home/gal/klipper/klippy/chelper/msgblock.c /home/gal/klipper/klippy/chelper/trdispatch.c /home/gal/klipper/klippy/chelper/kin_cartesian.c /home/gal/klipper/klippy/chelper/kin_corexy.c /home/gal/klipper/klippy/chelper/kin_corexz.c /home/gal/klipper/klippy/chelper/kin_delta.c /home/gal/klipper/klippy/chelper/kin_deltesian.c /home/gal/klipper/klippy/chelper/kin_polar.c /home/gal/klipper/klippy/chelper/kin_rotary_delta.c /home/gal/klipper/klippy/chelper/kin_winch.c /home/gal/klipper/klippy/chelper/kin_extruder.c /home/gal/klipper/klippy/chelper/kin_shaper.c /home/gal/klipper/klippy/chelper/kin_idex.c /home/gal/klipper/klippy/chelper/kin_generic.c
/home/gal/klipper/klippy/chelper/pyhelper.c: In function 'get_monotonic':
/home/gal/klipper/klippy/chelper/pyhelper.c:21:29: error: 'CLOCK_MONOTONIC_RAW' undeclared (first use in this function); did you mean 'CLOCK_MONOTONIC_FAST'?
   21 |     int ret = clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
      |                             ^~~~~~~~~~~~~~~~~~~
      |                             CLOCK_MONOTONIC_FAST
/home/gal/klipper/klippy/chelper/pyhelper.c:21:29: note: each undeclared identifier is reported only once for each function it appears in
/home/gal/klipper/klippy/chelper/serialqueue.c:15:10: fatal error: linux/can.h: No such file or directory
   15 | #include <linux/can.h> // // struct can_frame
      |          ^~~~~~~~~~~~~
compilation terminated.
[gal@klipper ~/klipper/klippy/chelper]$ 

Could chelper be changed, so that it wouldn’t contain any linux system call?

Is this the right place to raise an “issue”, as the issue tracker is closed on github?

Yes, but what issue? There is no issue!
Klipper supports Debian based Linux distributions.

FreeBSD has its own kernel. You may have a look here Debian_GNU/kFreeBSD - Debian Wiki

You found the problem. This means the Linux kernel (at least the version you tried) doesn’t support this hardware native.

Three things you could try.
First, find out the VID (vendor ID) and PID (product ID) of this “weird video hardware” with you running FreeBSD (don’t know how, I never used FreeBSD). When you have the VID and PID you could try a WWW search for a Linux driver. If you find a driver, install it by hand and try to get Linux running.

Second try to install a Debian distribution which supports the latest kernel.

Third, install Windows. Find out the VID (vendor ID) and PID (product ID) of this “weird video hardware” (I could help you here).

You need to get running a Debian based Linux distro on your “Niuguy NIU-one” to run Klipper!

  • As indicated, Klipper focuses on Debian-like distributions.
  • FreeBSD and Linux are quite different in many aspects.
  • It seems strange that some video hardware is supported by FreeBSD but not by a recent Linux kernel. Usually, support for this type of hardware is much better in Linux, while FreeBSD clearly excels in pure server/networking topics.
  • An interested developer would likely need to dedicate their time to figuring out the relevant differences and solving them. Since this is probably considered a “niche OS” for Klipper with low user impact, the chances might be rather slim.
  • The Klipper core developers are actively monitoring this place, making it the right spot to raise such a request. If there is interest, they will surely return to it.

I just read it in another post I could try to run Klipper in a virtual python environment on pretty much any operating system, as long as I have python, but I understand the official standpoint is that Klipper is only supported on debian based linux distributions. It is totally understandable, and sorry for sounding like I am demaning something, it was not my intention.

As per the weird hardware, I don’t think it’s the kernel that works or fails, but the bootloader, and it could be the BIOS, not really the video hardware. I tried installing Windows, but it behaves the exact same way as linux. Only freebSD and OpenBSD “goes through”.

Thank you for taking the time reading my posts and responding!

Where?

According to

There is no kernel failing, I never intended to state that. I was talking about hardware drivers.
How do you run Klipper in a virtual python environment without a working SBC/Niu-one?

According to

For your Niu-one
Windows only is the supported OS.

If you don’t get Windows running you have some other serious problems. Did you change some settings in the BIOS?

1 Like

That is true for OctoPrint - but IDK if it true for Klipper.

While this might be largely true, there are places in Klipper that rely on low-level kernel and operating system interfaces. How many there are and how complex it would be to resolve them, I cannot tell.

A quick search for your build error reveals, for example: Use CLOCK_MONOTONIC_RAW instead of CLOCK_MONOTONIC for Instant · Issue #77807 · rust-lang/rust · GitHub

@galmiklos

Do you know how a common PC boots up?

  • Power On
  • then the BIOS (Basic Input/Output System) or nowadays UEFI (Unified Extensible Firmware Interface) comes up (this runs from an IC on your motherboard and is a “very simple operating system”). If CSM (Compatibility Support Module) is available you can go back from UEFI to BIOS/Legacy mode (can be helpful).
    BIOS/UEFI one of those is the first (very simple) “operating system” on your PC. But! If you mess up the settings here, no OS like Windows, Linux, FreeBSD, or macOS will be able to install.

The bootloader Bootloader - Wikipedia is not your problem.

You may be able to reset your current BIOS/UEFI settings to the factory settings. I don’t know how to do that on your “Niuguy NIU-one”.

Well, yeah, as I am getting older, I more and more realize the more I learn, the less I know. I mean, there’s just so much knowledge, one cannot fathom to know everything. I’m trying… :wink: Will do better next time, sorry again.

If you really want to get your “Niuguy NIU-one” working, keep going! But!

Good luck with your Voron, hcet14

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