mirror of
https://github.com/mkuf/prind.git
synced 2025-10-26 00:36:17 +02:00
Add hostmcu Workflow (#79)
* klipper: rename the mcu target to tools * klipper: add hostmcu target * klipper: add klipper user to tty group * klipper: add build config for klipper_mcu * docs: add new targets to klipper image readme * docs: add hostmcu profile to additional profiles * add hostmcu profile
This commit is contained in:
34
README.md
34
README.md
@@ -61,7 +61,7 @@ All Runtime Configs are stored within ``config`` of this Repo.
|
||||
* Make sure to update ``cors_domains`` and ``trusted_clients`` within ``moonraker.cfg`` to secure your moonraker api from unwanted access. See [Moonraker Docs](https://moonraker.readthedocs.io/en/latest/configuration/) for Reference
|
||||
|
||||
### Starting the stack
|
||||
Currently, there are 3 Profiles to choose from, depending on the Web Frontend you'd like to use.
|
||||
There are currently 3 frontend Profiles to choose from, depending on the Web Frontend you'd like to use.
|
||||
* fluidd
|
||||
* mainsail
|
||||
* octoprint
|
||||
@@ -84,6 +84,38 @@ docker compose --profile mainsail up -d
|
||||
```
|
||||
|
||||
### Additional Profiles
|
||||
Docker compose allows for multiple profiles to be started at once.
|
||||
You may combine any of the above frontend profiles with any number of the following additional profiles.
|
||||
|
||||
Be sure to always use the same set of profiles when updating the stack, otherwise services may be orphaned or the stack is behaving in an unpredictable way.
|
||||
|
||||
#### hostmcu
|
||||
The `hostmcu` profile enables you to use your host as secondary mcu for klipper.
|
||||
See the [Klipper Docs](https://www.klipper3d.org/RPi_microcontroller.html) for more information on this Topic.
|
||||
|
||||
Uncomment the following lines in `printer.cfg`
|
||||
```
|
||||
[mcu host]
|
||||
serial: /opt/printer_data/run/klipper_host_mcu.tty
|
||||
```
|
||||
then start the stack with
|
||||
|
||||
```
|
||||
docker compose --profile mainsail --profile hostmcu up -d
|
||||
```
|
||||
|
||||
After the hostmcu container is started, you may check for available gpio chips with
|
||||
|
||||
```
|
||||
docker compose exec -it hostmcu gpiodetect
|
||||
```
|
||||
|
||||
and check the pin number and pin availability with
|
||||
|
||||
```
|
||||
docker compose exec -it hostmcu gpioinfo
|
||||
```
|
||||
|
||||
#### KlipperScreen
|
||||
[KlipperScreen by jordanruthe](https://github.com/jordanruthe/KlipperScreen) can be enabled via the `klipperscreen` Profile.
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
[mcu]
|
||||
serial: /dev/serial/by-id/<klipper-device>
|
||||
|
||||
## Use the host as mcu to control its gpio pins
|
||||
## Uncomment the lines below if you use the hostmcu profile, see main Readme for more info
|
||||
# [mcu host]
|
||||
# serial: /opt/printer_data/run/klipper_host_mcu.tty
|
||||
|
||||
[printer]
|
||||
kinematics: cartesian
|
||||
max_velocity: 500
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
services:
|
||||
calibrate_shaper:
|
||||
image: mkuf/klipper:${TAG:-latest}-mcu
|
||||
image: mkuf/klipper:${TAG:-latest}-tools
|
||||
entrypoint: python3 /opt/klipper/scripts/calibrate_shaper.py
|
||||
working_dir: /opt/resonances
|
||||
volumes:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
services:
|
||||
make:
|
||||
image: mkuf/klipper:${TAG:-latest}-mcu
|
||||
image: mkuf/klipper:${TAG:-latest}-tools
|
||||
tty: true
|
||||
privileged: true
|
||||
entrypoint: make
|
||||
|
||||
@@ -146,6 +146,18 @@ services:
|
||||
labels:
|
||||
org.prind.service: mobileraker_companion
|
||||
|
||||
hostmcu:
|
||||
image: mkuf/klipper:latest-hostmcu
|
||||
restart: unless-stopped
|
||||
privileged: true
|
||||
volumes:
|
||||
- /dev:/dev
|
||||
- run:/opt/printer_data/run
|
||||
profiles:
|
||||
- hostmcu
|
||||
labels:
|
||||
org.prind.service: hostmcu
|
||||
|
||||
## Accompanying Services/Infra
|
||||
##
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
## Get Code and Build venv
|
||||
## Get Klipper Source and Build venv
|
||||
##
|
||||
FROM python:2 as build
|
||||
|
||||
ARG REPO=https://github.com/Klipper3d/klipper
|
||||
@@ -16,14 +17,18 @@ RUN virtualenv -p python2 venv \
|
||||
&& venv/bin/pip install numpy \
|
||||
&& venv/bin/python -m compileall klipper/klippy \
|
||||
&& venv/bin/python klipper/klippy/chelper/__init__.py
|
||||
###
|
||||
|
||||
## Runtime Image
|
||||
|
||||
## Klippy Runtime Image
|
||||
##
|
||||
FROM python:2-slim as run
|
||||
|
||||
WORKDIR /opt
|
||||
RUN groupadd klipper --gid 1000 \
|
||||
&& useradd klipper --uid 1000 --gid klipper \
|
||||
&& usermod klipper --append --groups dialout
|
||||
&& usermod klipper --append --groups dialout \
|
||||
&& usermod klipper --append --groups tty
|
||||
RUN mkdir -p printer_data/run printer_data/gcodes printer_data/logs printer_data/config \
|
||||
&& chown -R klipper:klipper /opt/*
|
||||
|
||||
@@ -34,9 +39,12 @@ USER klipper
|
||||
VOLUME ["/opt/printer_data/run", "/opt/printer_data/gcodes", "/opt/printer_data/logs", "/opt/printer_data/config"]
|
||||
ENTRYPOINT ["/opt/venv/bin/python", "klipper/klippy/klippy.py"]
|
||||
CMD ["-I", "printer_data/run/klipper.tty", "-a", "printer_data/run/klipper.sock", "printer_data/config/printer.cfg"]
|
||||
###
|
||||
|
||||
## For building MCU Code
|
||||
FROM debian:bullseye as mcu
|
||||
|
||||
## Image for building MCU code including other tooling
|
||||
##
|
||||
FROM debian:bullseye as tools
|
||||
|
||||
WORKDIR /opt
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
@@ -53,9 +61,40 @@ RUN apt update \
|
||||
|
||||
COPY --from=build /opt/klipper ./klipper
|
||||
COPY --from=build /opt/venv ./venv
|
||||
###
|
||||
|
||||
## Build klipper.elf for Simulavr and Simulavr itself
|
||||
FROM mcu as build-simulavr
|
||||
|
||||
## Build the klipper_mcu binary
|
||||
##
|
||||
FROM tools as build-hostmcu
|
||||
|
||||
WORKDIR /opt
|
||||
|
||||
COPY config.hostmcu klipper/.config
|
||||
RUN cd klipper \
|
||||
&& make flash
|
||||
###
|
||||
|
||||
|
||||
## Runtime image for the klipper_mcu binary
|
||||
##
|
||||
FROM debian:bullseye-slim as hostmcu
|
||||
|
||||
RUN apt update \
|
||||
&& apt install -y gpiod \
|
||||
&& apt clean
|
||||
|
||||
COPY --from=build-hostmcu /usr/local/bin/klipper_mcu /usr/local/bin/klipper_mcu
|
||||
|
||||
VOLUME ["/opt/printer_data/run"]
|
||||
ENTRYPOINT ["/usr/local/bin/klipper_mcu"]
|
||||
CMD ["-I", "/opt/printer_data/run/klipper_host_mcu.tty"]
|
||||
###
|
||||
|
||||
|
||||
## Build Simulavr and klipper.elf
|
||||
## For manual builds, not uploaded to the docker registry
|
||||
FROM tools as build-simulavr
|
||||
|
||||
RUN apt update \
|
||||
&& apt install -y \
|
||||
|
||||
@@ -103,14 +103,17 @@ none
|
||||
## Tags
|
||||
|Tag|Description|Static|
|
||||
|---|---|---|
|
||||
|`latest`/`nightly`|Refers to the most recent runtime Image.|May point to a new build within 24h, depending on code changes in the upstream repository.|
|
||||
|`latest`/`nightly`|Refers to the most recent runtime Image for klippy.|May point to a new build within 24h, depending on code changes in the upstream repository.|
|
||||
|`<7-digit-sha>` <br>eg: `d75154d`|Refers to a specific commit SHA in the upstream repository. eg: [Klipper3d/klipper:d75154d](https://github.com/Klipper3d/klipper/commit/d75154d695efb1338cbfff061d226c4f384d127b)|Yes|
|
||||
|`*-mcu`|Refers to a full blown Ubuntu Image containing all Tools necessary to Build the Microcontroller code for Klipper|Yes|
|
||||
|`*-tools`|Refers to Debian Image containing all Tools necessary to Build the Microcontroller code for Klipper|Yes|
|
||||
|`*-hostmcu`|Refers to the runtime Image for klipper_mcu.|Yes|
|
||||
|
||||
## Targets
|
||||
|Target|Description|Pushed|
|
||||
|---|---|---|
|
||||
|`build`|Pull Upstream Codebase and build python venv|No|
|
||||
|`build-simulavr`|Based on `mcu`: Pull and Build simulavr for klipper. Used for testing without Hardware.|No|
|
||||
|`run`|Default runtime Image|Yes|
|
||||
|`mcu`|Build Tools for MCU code compilation|Yes|
|
||||
|`build-hostmcu`|Based on `mcu`: Build the klipper_mcu binary|No|
|
||||
|`run`|Default runtime Image for klippy|Yes|
|
||||
|`tools`|Build Tools for MCU code compilation|Yes|
|
||||
|`hostmcu`|Runtime Image for the klipper_mcu binary|Yes|
|
||||
|
||||
26
docker/klipper/config.hostmcu
Normal file
26
docker/klipper/config.hostmcu
Normal file
@@ -0,0 +1,26 @@
|
||||
# CONFIG_LOW_LEVEL_OPTIONS is not set
|
||||
# CONFIG_MACH_AVR is not set
|
||||
# CONFIG_MACH_ATSAM is not set
|
||||
# CONFIG_MACH_ATSAMD is not set
|
||||
# CONFIG_MACH_LPC176X is not set
|
||||
# CONFIG_MACH_STM32 is not set
|
||||
# CONFIG_MACH_HC32F460 is not set
|
||||
# CONFIG_MACH_RP2040 is not set
|
||||
# CONFIG_MACH_PRU is not set
|
||||
# CONFIG_MACH_AR100 is not set
|
||||
CONFIG_MACH_LINUX=y
|
||||
# CONFIG_MACH_SIMU is not set
|
||||
CONFIG_BOARD_DIRECTORY="linux"
|
||||
CONFIG_CLOCK_FREQ=50000000
|
||||
CONFIG_LINUX_SELECT=y
|
||||
CONFIG_USB_VENDOR_ID=0x1d50
|
||||
CONFIG_USB_DEVICE_ID=0x614e
|
||||
CONFIG_USB_SERIAL_NUMBER="12345"
|
||||
CONFIG_CANBUS_FREQUENCY=500000
|
||||
CONFIG_HAVE_GPIO=y
|
||||
CONFIG_HAVE_GPIO_ADC=y
|
||||
CONFIG_HAVE_GPIO_SPI=y
|
||||
CONFIG_HAVE_GPIO_I2C=y
|
||||
CONFIG_HAVE_GPIO_HARD_PWM=y
|
||||
CONFIG_HAVE_GPIO_BITBANGING=y
|
||||
CONFIG_INLINE_STEPPER_HACK=y
|
||||
Reference in New Issue
Block a user