Klipper crashes when running resonance measurements

Basic Information:

Printer Model: Voron Switchwire
MCU / Printerboard: SKR Mini E3 V3, Odroid C2
klippy.log (108.1 KB)
printer.cfg (13.4 KB)
Klipper

Describe your issue:

Hi all, I’ve got an issue with running any resonance measurements on my setup: Voron Switchwire (Ender conversion), Odroid C2, ADXL345

I can get readings from ADXL sensor, but when I try to run resonance test, klipper crashes without any error in the klippy.log

Can someone help me here, what should be the steps for debugging this crash?

I tried to to dig around in the code for input shaping and it seems it crashes on importing numpy as a module.

I don’t understand why, numpy is correctly installed in the klippy-env virtual environment, but it crashes on import without catching the Import exception.

I’ve reinstalled whole virtualenv with kiauh scripts, modified ~/klipper/scripts/klippy-requirements.txt to install latest numpy when updating klipper and it still crashes when running TEST_RESONANCES AXIS=X OUTPUT=resonances

Running TEST_RESONANCES AXIS=X OUTPUT=raw_data works just fine.

I’ve also upgraded from Python 3.8.10 to Python 3.11.7, reinstalled klipper + packages, moonraker and reflashed MCU host, but the issue still persist…

Package    Version
---------- -------
aenum      3.1.15
cffi       1.14.6
greenlet   2.0.2
Jinja2     2.11.3
MarkupSafe 1.1.1
numpy      1.26.3
pip        23.3.2
pycparser  2.21
pyserial   3.4
python-can 3.3.4
setuptools 65.5.0
wrapt      1.16.0```

Have you tried an older numpy version, e.g.

~/klippy-env/bin/pip uninstall -y numpy
~/klippy-env/bin/pip install -v 'numpy==1.23.5' --force-reinstall #or even down to 1.18.5

Yes, I’ve tried older versions (I think those were 1.24.4 and 1.15.something), but I can try other versions as well today.

Does this command fails? ~/klippy-env/bin/python -c "import numpy" (It shouldn’t print anything)
If there is an error, does this fixes it? : OPENBLAS_CORETYPE=ARMV8 ~/klippy-env/bin/python -c "import numpy"

Yes, there’s an error when importing numpy:
Illegal instruction

Unfortunatelly, OPENBLAS_CORETYPE=ARMV8 does nothing :confused:

odroid@enderwire:~$ OPENBLAS_CORETYPE=ARMV8 ~/klippy-env/bin/python -c "import numpy"
Illegal instruction

How did you install the numpy versions? Via pip or as wheel?
You have libopenblas-base in your system?

Yes, I’ve libopenblas-base installed on my Odroid.

I’ve installed multiple version via pip either directly with python3.8 -m pip install numpy==1.19.4

odroid@enderwire:~$ python3.8 -m pip install -U numpy==1.19.4 --no-cache-dir
Collecting numpy==1.19.4
  Downloading numpy-1.19.4-cp38-cp38-manylinux2014_aarch64.whl (12.2 MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12.2 MB 5.0 MB/s
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.19.5
    Uninstalling numpy-1.19.5:
      Successfully uninstalled numpy-1.19.5
Successfully installed numpy-1.19.4
odroid@enderwire:~$ python3.8 -c "import numpy"
Illegal instruction

and building it locally with python3 -m pip install -U numpy==1.19.4 --no-cache-dir --no-binary numpy

Example from trying outside venv with python3.8:

odroid@enderwire:~$ printenv OPENBLAS_CORETYPE
ARMV8
odroid@enderwire:~$ python3.8 -m pip install -U numpy==1.19.4 --no-cache-dir --no-binary numpy
Collecting numpy==1.19.4
  Downloading numpy-1.19.4.zip (7.3 MB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7.3 MB 2.2 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: numpy
  Building wheel for numpy (PEP 517) ... done
  Created wheel for numpy: filename=numpy-1.19.4-cp38-cp38-linux_aarch64.whl size=13437221 sha256=d80fb07d4d51fbb7f34aacf52b1ad9176c373494f210ee59797b97dc7db08c9b
  Stored in directory: /tmp/pip-ephem-wheel-cache-vz03yemu/wheels/6d/16/41/249ad7da789b267243d1798090f061495fadbfb3113a6d94e2
Successfully built numpy
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.24.4
    Uninstalling numpy-1.24.4:
      Successfully uninstalled numpy-1.24.4
Successfully installed numpy-1.19.4
odroid@enderwire:~$ python3.8 -c "import numpy"
Illegal instruction

numpy has a bunch of dependencies and it sounds like one of them isn’t loading. Try python3.8 -v -c "import numpy" to get more info on what’s actually throwing the illegal instruction.

Here’s the output of python3.8 -v -c "import numpy"
numpy.log (12.6 KB)

Also installed GDB and tried to run test.py with just import numpy

(gdb) run test.py
Starting program: /usr/bin/python test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fb65c61e0 (LWP 15825)]
[New Thread 0x7fb5dc51e0 (LWP 15826)]
[New Thread 0x7fb35c41e0 (LWP 15827)]

Thread 2 "python" received signal SIGILL, Illegal instruction.
[Switching to Thread 0x7fb65c61e0 (LWP 15825)]
0x0000007fb698450c in ?? () from /usr/lib/aarch64-linux-gnu/openblas-pthread/libopenblas.so.0

Finally managed to get resonance measurements running, but with a big workaround (issues described in this post were when I was running latest official minimal Ubuntu 20.04 from hardkernel because I got SPI working there).

  • reflashed eMMC of my Odroid C2 with latest DietPi again (used it previously, but could not get SPI to work, so I switched back to that minimal Ubuntu)
  • reinstlalled everything (WiFi, Klipper, Moonraker, Mainsail, all the plugins, bells and whistles)
  • modified dietpiEnv.txt, modprobe and device tree to activate SPI interface and finally got it working

With this setup, Klipper runs just fine, I am able to get data from ADXL345 on /dev/spidev0.1 and finally TEST_RESONANCES now works properly.
I was able to do resonance measurements on both X and Y successfully.

Don’t know why I got problems with Illegal instruction when importing numpy on that minimal Ubuntu 20.04 previously (even when I’ve build numpy 1.18.5 locally it was throwing the same error)
But I am now up and running again (and hopefully this was my last obstacle :crossed_fingers:).

1 Like

X axis

Y axis

if anyone is still having issues,
klipper says to install libopenblas-base
the fix for me was to install libopenblas-dev
so:

sudo apt install python3-numpy python3-matplotlib libatlas-base-dev libopenblas-base libopenblas-dev

im a mega noob by the way. hope this helps.

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