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?