From 4bdf68489258ff69ae8738f6b8d0202d77a55adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20K=C3=BCffner?= <11882946+mkuf@users.noreply.github.com> Date: Sun, 23 Nov 2025 22:00:50 +0100 Subject: [PATCH] klipper: rework tools image (#244) * klipper: clean up tools stage * remove redundant copy statements * add requirements file for tools stage * set path to use venv by default * remove calibrate-shaper and rename make * add symlink for klippy-env * update docs * docs: update changelog --- CHANGELOG.md | 20 +++++++++ README.md | 43 ++++++++++++------- docker-compose.extra.calibrate-shaper.yaml | 7 --- ...ke.yaml => docker-compose.extra.tools.yaml | 5 ++- docker/klipper/Dockerfile | 8 ++-- docker/klipper/requirements-prind-tools.txt | 2 + 6 files changed, 58 insertions(+), 27 deletions(-) delete mode 100644 docker-compose.extra.calibrate-shaper.yaml rename docker-compose.extra.make.yaml => docker-compose.extra.tools.yaml (74%) create mode 100644 docker/klipper/requirements-prind-tools.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d3875f..c0cbde2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). diff --git a/README.md b/README.md index ab7942f..ad768ea 100644 --- a/README.md +++ b/README.md @@ -37,25 +37,41 @@ Follow the official guides to install and set them up: * [Install Docker Compose v2](https://docs.docker.com/compose/cli-command/#installing-compose-v2) Clone this repository onto your Docker host using Git: -``` +```bash git clone https://github.com/mkuf/prind ``` + +Install the `prind-tools` helper script. +```bash +cd prind + +cat < +```bash +prind-tools "make menuconfig" +prind-tools "make" +prind-tools "make flash FLASH_DEVICE=/dev/serial/by-id/" ``` -If your Board can be flashed via SD-Card, you may want to omit `make flash` and retrieve the `klipper.bin` from the `out` directory that is created by `make`. Follow your boards instructions on how to proceed with flashing via SD-Card. +If your Board can be flashed via SD-Card, you can also use the `flash-sdcard.sh` script provided by klipper + +```bash +prind-tools "scripts/flash-sdcard.sh " +``` + +If no official flash method is available, you can retrieve the `klipper.bin` from the `out` directory that is created by `make` and Follow your boards instructions on how to proceed with flashing. ### Add your Configuration to docker-compose.override.yaml Locate the `webcam` Service within `docker-compose.override.yaml` and update the `device` Section with the Device Name of your Webcam. @@ -279,16 +295,13 @@ docker compose cp klipper:/tmp/resonances_x_20220708_124515.csv ./resonances/ docker compose cp klipper:/tmp/resonances_y_20220708_125150.csv ./resonances/ ``` -`docker-compose.extra.calibrate-shaper.yaml` is set up to run `calibrate_shaper.py`, so any options supported by the script can also be used with the container. -Set an alias to save yourself from typing the the docker compose command multiple times. The generated Images are located besides the csv files in `./resonances` +To analyze the generated files, call `calibrate_shaper.py` via `prind-tools` ``` -alias calibrate_shaper="docker compose -f docker-compose.extra.calibrate-shaper.yaml run --rm calibrate_shaper" - -calibrate_shaper resonances_x_20220708_124515.csv -o cal_x.png +prind-tools "scripts/calibrate_shaper.py resonances/resonances_x_20220708_124515.csv -o resonances/cal_x.png" [...] Recommended shaper is ei @ 90.2 Hz -calibrate_shaper resonances_y_20220708_125150.csv -o cal_y.png +prind-tools "scripts/calibrate_shaper.py resonances/resonances_y_20220708_125150.csv -o resonances/cal_y.png" [...] Recommended shaper is mzv @ 48.2 Hz ``` diff --git a/docker-compose.extra.calibrate-shaper.yaml b/docker-compose.extra.calibrate-shaper.yaml deleted file mode 100644 index 541314b..0000000 --- a/docker-compose.extra.calibrate-shaper.yaml +++ /dev/null @@ -1,7 +0,0 @@ -services: - calibrate_shaper: - image: mkuf/klipper:${TAG:-latest}-tools - entrypoint: python3 /opt/klipper/scripts/calibrate_shaper.py - working_dir: /opt/resonances - volumes: - - ./resonances:/opt/resonances diff --git a/docker-compose.extra.make.yaml b/docker-compose.extra.tools.yaml similarity index 74% rename from docker-compose.extra.make.yaml rename to docker-compose.extra.tools.yaml index 819b34e..c6a4324 100644 --- a/docker-compose.extra.make.yaml +++ b/docker-compose.extra.tools.yaml @@ -1,11 +1,12 @@ services: - make: + tools: image: mkuf/klipper:${TAG:-latest}-tools tty: true privileged: true - entrypoint: make + entrypoint: bash -c working_dir: /opt/klipper volumes: - /dev:/dev - ./config/build.config:/opt/klipper/.config - ./out:/opt/klipper/out + - ./resonances:/opt/klipper/resonances diff --git a/docker/klipper/Dockerfile b/docker/klipper/Dockerfile index 383849b..dd338f3 100644 --- a/docker/klipper/Dockerfile +++ b/docker/klipper/Dockerfile @@ -63,11 +63,13 @@ RUN apt update \ avrdude gcc-avr binutils-avr avr-libc \ stm32flash dfu-util libnewlib-arm-none-eabi \ gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0 libusb-1.0-0-dev \ - python3-numpy python3-matplotlib \ && apt clean -COPY --from=build /opt/klipper ./klipper -COPY --from=build /opt/venv ./venv +COPY requirements-prind-tools.txt . +RUN venv/bin/pip install -r requirements-prind-tools.txt + +RUN ln -s /opt/venv /root/klippy-env +ENV PATH=/opt/venv/bin:$PATH ENTRYPOINT ["/usr/bin/bash"] ### diff --git a/docker/klipper/requirements-prind-tools.txt b/docker/klipper/requirements-prind-tools.txt new file mode 100644 index 0000000..806f221 --- /dev/null +++ b/docker/klipper/requirements-prind-tools.txt @@ -0,0 +1,2 @@ +numpy +matplotlib \ No newline at end of file