summaryrefslogtreecommitdiff
path: root/hosts
diff options
context:
space:
mode:
authorTim Keller <tjk@tjkeller.xyz>2026-05-30 21:39:56 -0500
committerTim Keller <tjk@tjkeller.xyz>2026-05-30 21:39:56 -0500
commit71a5db2f26d1ac01c8e897d9362a09956c02bbc3 (patch)
treef11e4375f2d59dcc3a3570e682bb674147eccc0b /hosts
parent527bc8f288eb916cab4e14d00c4b44b9d69344e4 (diff)
downloadnixos-71a5db2f26d1ac01c8e897d9362a09956c02bbc3.tar.xz
nixos-71a5db2f26d1ac01c8e897d9362a09956c02bbc3.zip
klipper config on gnuslashprinter for ender 3 neoHEADmaster
Diffstat (limited to 'hosts')
-rw-r--r--hosts/gnuslashprinter/configuration.nix2
-rw-r--r--hosts/gnuslashprinter/klipper.nix72
-rw-r--r--hosts/gnuslashprinter/resources/klipper/mcu/config109
-rw-r--r--hosts/gnuslashprinter/resources/klipper/printer.cfg180
4 files changed, 363 insertions, 0 deletions
diff --git a/hosts/gnuslashprinter/configuration.nix b/hosts/gnuslashprinter/configuration.nix
index b05a587..6af701a 100644
--- a/hosts/gnuslashprinter/configuration.nix
+++ b/hosts/gnuslashprinter/configuration.nix
@@ -1,4 +1,6 @@
{
+ imports = [ ./klipper.nix ];
+
boot._loader.enable = true;
_archetypes = {
diff --git a/hosts/gnuslashprinter/klipper.nix b/hosts/gnuslashprinter/klipper.nix
new file mode 100644
index 0000000..a19261c
--- /dev/null
+++ b/hosts/gnuslashprinter/klipper.nix
@@ -0,0 +1,72 @@
+{
+ # Klipper firmware
+ services.klipper = {
+ enable = true;
+ firmwares = {
+ mcu = {
+ enable = true;
+ # Serial port connected to the microcontroller
+ serial = "/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0";
+ # Klipper flash must be enabled in order to build mcu firmware
+ # The resulting `klipper-flash-mcu` command will show the location of the firmware bin in the nix store
+ enableKlipperFlash = true;
+ # Run klipper-genconf to generate this
+ configFile = ./resources/klipper/mcu/config;
+ };
+ };
+ configFile = ./resources/klipper/printer.cfg;
+ logFile = "/var/lib/klipper/klipper.log";
+ };
+ # Mutable config
+ services.klipper.mutableConfig = true;
+ #configDir = "/var/lib/moonraker/config"; # Accessible by moonraker # TODO
+
+ # Moonraker web-api
+ services.moonraker = {
+ user = "root";
+ enable = true;
+ address = "0.0.0.0";
+ settings = {
+ #authorization = {
+ # force_logins = true;
+ # cors_domains = [
+ # "*.local"
+ # "*.lan"
+ # "*://app.fluidd.xyz"
+ # "*://my.mainsail.xyz"
+ # ];
+ # trusted_clients = [
+ # "10.0.0.0/8"
+ # "127.0.0.0/8"
+ # "169.254.0.0/16"
+ # "172.16.0.0/12"
+ # "192.168.0.0/16"
+ # "FE80::/10"
+ # "::1/128"
+ # ];
+ #};
+ #file_manager.check_klipper_config_path = false; # Disable warning when klipper config is not accessible by moonraker
+ # mainsail.cfg
+ #"update_manager mainsail-config" = {
+ # type = "git_repo";
+ # primary_branch = "master";
+ # path = "~/mainsail-config";
+ # origin = "https://github.com/mainsail-crew/mainsail-config.git";
+ # managed_services = "klipper";
+ #};
+ };
+ };
+
+ # Mainsail web-interface
+ services.mainsail = {
+ enable = true;
+ hostName = "0.0.0.0";
+ nginx.listenAddresses = [ "0.0.0.0" ];
+ };
+ services.nginx.clientMaxBodySize = "1000m"; # Allow large gcodes, etc.
+ networking.firewall.allowedTCPPorts = [ 80 ]; # Port for mainsail via nginx
+
+ # Webcam support in mainsail
+ services.ustreamer.enable = true;
+ services.mainsail.nginx.locations."/webcam/".proxyPass = "http://localhost:8080/stream"; # Default location for ustreamer stream
+}
diff --git a/hosts/gnuslashprinter/resources/klipper/mcu/config b/hosts/gnuslashprinter/resources/klipper/mcu/config
new file mode 100644
index 0000000..3e192a3
--- /dev/null
+++ b/hosts/gnuslashprinter/resources/klipper/mcu/config
@@ -0,0 +1,109 @@
+# 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=y
+# CONFIG_MACH_HC32F460 is not set
+# CONFIG_MACH_RPXXXX is not set
+# CONFIG_MACH_PRU is not set
+# CONFIG_MACH_AR100 is not set
+# CONFIG_MACH_LINUX is not set
+# CONFIG_MACH_SIMU is not set
+CONFIG_BOARD_DIRECTORY="stm32"
+CONFIG_MCU="stm32f103xe"
+CONFIG_CLOCK_FREQ=72000000
+CONFIG_SERIAL=y
+CONFIG_FLASH_SIZE=0x10000
+CONFIG_FLASH_BOOT_ADDRESS=0x8000000
+CONFIG_RAM_START=0x20000000
+CONFIG_RAM_SIZE=0x5000
+CONFIG_STACK_SIZE=512
+CONFIG_FLASH_APPLICATION_ADDRESS=0x8007000
+CONFIG_STM32_SELECT=y
+CONFIG_MACH_STM32F103=y
+# CONFIG_MACH_STM32F207 is not set
+# CONFIG_MACH_STM32F401 is not set
+# CONFIG_MACH_STM32F405 is not set
+# CONFIG_MACH_STM32F407 is not set
+# CONFIG_MACH_STM32F429 is not set
+# CONFIG_MACH_STM32F446 is not set
+# CONFIG_MACH_STM32F765 is not set
+# CONFIG_MACH_STM32F031 is not set
+# CONFIG_MACH_STM32F042 is not set
+# CONFIG_MACH_STM32F070 is not set
+# CONFIG_MACH_STM32F072 is not set
+# CONFIG_MACH_STM32G070 is not set
+# CONFIG_MACH_STM32G071 is not set
+# CONFIG_MACH_STM32G0B0 is not set
+# CONFIG_MACH_STM32G0B1 is not set
+# CONFIG_MACH_STM32G431 is not set
+# CONFIG_MACH_STM32G474 is not set
+# CONFIG_MACH_STM32H723 is not set
+# CONFIG_MACH_STM32H743 is not set
+# CONFIG_MACH_STM32H750 is not set
+# CONFIG_MACH_STM32L412 is not set
+# CONFIG_MACH_N32G452 is not set
+# CONFIG_MACH_N32G455 is not set
+CONFIG_MACH_STM32F1=y
+CONFIG_HAVE_STM32_USBFS=y
+CONFIG_STM32_USB_DOUBLE_BUFFER_TX=y
+CONFIG_HAVE_STM32_CANBUS=y
+CONFIG_STM32_DFU_ROM_ADDRESS=0
+# CONFIG_STM32_FLASH_START_2000 is not set
+# CONFIG_STM32_FLASH_START_5000 is not set
+CONFIG_STM32_FLASH_START_7000=y
+# CONFIG_STM32_FLASH_START_8000 is not set
+# CONFIG_STM32_FLASH_START_8800 is not set
+# CONFIG_STM32_FLASH_START_9000 is not set
+# CONFIG_STM32_FLASH_START_10000 is not set
+# CONFIG_STM32_FLASH_START_800 is not set
+# CONFIG_STM32_FLASH_START_1000 is not set
+# CONFIG_STM32_FLASH_START_4000 is not set
+# CONFIG_STM32_FLASH_START_0000 is not set
+CONFIG_CLOCK_REF_FREQ=8000000
+CONFIG_STM32F0_TRIM=16
+# CONFIG_STM32_USB_PA11_PA12 is not set
+CONFIG_STM32_SERIAL_USART1=y
+# CONFIG_STM32_CANBUS_PA11_PA12 is not set
+# CONFIG_STM32_CANBUS_PA11_PB9 is not set
+CONFIG_SERIAL_BAUD=250000
+CONFIG_USB_VENDOR_ID=0x1d50
+CONFIG_USB_DEVICE_ID=0x614e
+CONFIG_USB_SERIAL_NUMBER="12345"
+CONFIG_WANT_ADC=y
+CONFIG_WANT_SPI=y
+CONFIG_WANT_SOFTWARE_SPI=y
+CONFIG_WANT_I2C=y
+CONFIG_WANT_SOFTWARE_I2C=y
+CONFIG_WANT_HARD_PWM=y
+CONFIG_WANT_BUTTONS=y
+CONFIG_WANT_TMCUART=y
+CONFIG_WANT_NEOPIXEL=y
+CONFIG_WANT_PULSE_COUNTER=y
+CONFIG_WANT_ST7920=y
+CONFIG_WANT_HD44780=y
+CONFIG_WANT_ADXL345=y
+CONFIG_WANT_LIS2DW=y
+CONFIG_WANT_MPU9250=y
+CONFIG_WANT_ICM20948=y
+CONFIG_WANT_THERMOCOUPLE=y
+CONFIG_WANT_HX71X=y
+CONFIG_WANT_ADS1220=y
+CONFIG_WANT_LDC1612=y
+CONFIG_WANT_SENSOR_ANGLE=y
+CONFIG_NEED_SENSOR_BULK=y
+CONFIG_WANT_LOAD_CELL_PROBE=y
+CONFIG_NEED_SOS_FILTER=y
+CONFIG_CANBUS_FREQUENCY=1000000
+CONFIG_INLINE_STEPPER_HACK=y
+CONFIG_HAVE_STEPPER_OPTIMIZED_BOTH_EDGE=y
+CONFIG_WANT_STEPPER_OPTIMIZED_BOTH_EDGE=y
+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_STRICT_TIMING=y
+CONFIG_HAVE_CHIPID=y
+CONFIG_HAVE_BOOTLOADER_REQUEST=y
diff --git a/hosts/gnuslashprinter/resources/klipper/printer.cfg b/hosts/gnuslashprinter/resources/klipper/printer.cfg
new file mode 100644
index 0000000..1e39048
--- /dev/null
+++ b/hosts/gnuslashprinter/resources/klipper/printer.cfg
@@ -0,0 +1,180 @@
+# This file contains pin mappings for the stock 2020 Creality Ender 3
+# V2. To use this config, during "make menuconfig" select the
+# STM32F103 with a "28KiB bootloader" and serial (on USART1 PA10/PA9)
+# communication.
+
+# If you prefer a direct serial connection, in "make menuconfig"
+# select "Enable extra low-level configuration options" and select
+# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC
+# cable used for the LCD module as follows:
+# 3: Tx, 4: Rx, 9: GND, 10: VCC
+
+# Flash this firmware by copying "out/klipper.bin" to a SD card and
+# turning on the printer with the card inserted. The firmware
+# filename must end in ".bin" and must not match the last filename
+# that was flashed.
+
+# See docs/Config_Reference.md for a description of parameters.
+
+[include mainsail.cfg]
+
+# Default V2 config
+[stepper_x]
+step_pin: PC2
+dir_pin: PB9
+enable_pin: !PC3
+microsteps: 16
+rotation_distance: 40
+endstop_pin: ^PA5
+position_endstop: -20
+position_min: -20
+position_max: 235
+homing_speed: 50
+
+[stepper_y]
+step_pin: PB8
+dir_pin: PB7
+enable_pin: !PC3
+microsteps: 16
+rotation_distance: 40
+endstop_pin: ^PA6
+position_endstop: -8
+position_min: -8
+position_max: 235
+homing_speed: 50
+
+[stepper_z]
+step_pin: PB6
+dir_pin: !PB5
+enable_pin: !PC3
+microsteps: 16
+rotation_distance: 8
+endstop_pin: probe:z_virtual_endstop
+#position_endstop: 0.0
+position_min: -5
+position_max: 250
+
+[extruder]
+max_extrude_only_distance: 100.0
+step_pin: PB4
+dir_pin: PB3
+enable_pin: !PC3
+microsteps: 16
+rotation_distance: 34.406
+nozzle_diameter: 0.400
+filament_diameter: 1.750
+heater_pin: PA1
+sensor_type: EPCOS 100K B57560G104F
+sensor_pin: PC5
+control: pid
+# tuned for stock hardware with 200 degree Celsius target
+pid_Kp: 21.527
+pid_Ki: 1.063
+pid_Kd: 108.982
+min_temp: 0
+max_temp: 250
+
+[heater_bed]
+heater_pin: PA2
+sensor_type: EPCOS 100K B57560G104F
+sensor_pin: PC4
+control: pid
+# tuned for stock hardware with 50 degree Celsius target
+pid_Kp: 54.027
+pid_Ki: 0.770
+pid_Kd: 948.182
+min_temp: 0
+max_temp: 130
+
+[fan]
+pin: PA0
+
+[mcu]
+serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
+restart_method: command
+
+[printer]
+kinematics: cartesian
+max_velocity: 300
+max_accel: 3000
+max_z_velocity: 5
+max_z_accel: 100
+
+######################################################################
+# 128x64 Full Graphic Creality CR10 / ENDER 3 stockdisplay
+######################################################################
+
+# This section is used for a Creality "12864" display with a single
+# ribbon cable between the display's EXP3 plug and the
+# micro-controller board's EXP1 connector.
+
+[display]
+lcd_type: st7920
+cs_pin: EXP1_7
+sclk_pin: EXP1_6
+sid_pin: EXP1_8
+encoder_pins: ^EXP1_5, ^EXP1_3
+click_pin: ^!EXP1_2
+
+[output_pin beeper]
+pin: EXP1_1
+
+[board_pins]
+aliases:
+ EXP1_1=PC6,EXP1_3=PB10,EXP1_5=PB14,EXP1_7=PB12,EXP1_9=<GND>,
+ EXP1_2=PB2,EXP1_4=PB11,EXP1_6=PB13,EXP1_8=PB15,EXP1_10=<5V>,
+ PROBE_IN=PB1,PROBE_OUT=PB0,FIL_RUNOUT=PA6
+
+[display_status]
+
+######
+# Bed leveling
+
+[bltouch]
+sensor_pin: ^PROBE_IN
+control_pin: PROBE_OUT
+x_offset: -40
+y_offset: -12
+#z_offset: 1.1
+probe_with_touch_mode: true
+stow_on_each_sample: false
+
+[bed_mesh]
+speed: 120
+mesh_min: 10, 10
+mesh_max: 195, 220
+probe_count: 5,5
+algorithm: bicubic
+
+[safe_z_home]
+home_xy_position: 157.5, 129.5
+speed: 75
+z_hop: 10
+z_hop_speed: 5
+move_to_previous: true
+
+
+#*# <---------------------- SAVE_CONFIG ---------------------->
+#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
+#*#
+#*# [bed_mesh default]
+#*# version = 1
+#*# points =
+#*# -0.017500, 0.025000, 0.050000, 0.122500, 0.155000
+#*# -0.045000, -0.040000, 0.037500, 0.102500, 0.145000
+#*# -0.007500, -0.032500, 0.005000, 0.092500, 0.132500
+#*# -0.060000, -0.045000, -0.007500, 0.087500, 0.127500
+#*# 0.075000, 0.042500, 0.015000, 0.105000, 0.175000
+#*# x_count = 5
+#*# y_count = 5
+#*# mesh_x_pps = 2
+#*# mesh_y_pps = 2
+#*# algo = bicubic
+#*# tension = 0.2
+#*# min_x = 10.0
+#*# max_x = 195.0
+#*# min_y = 10.0
+#*# max_y = 220.0
+#*#
+#*# [bltouch]
+#*# z_offset = 1.342