Add regin to replace Pi3 with FluiddPi, which is unmaintained

This commit is contained in:
Erwin Boskma 2023-02-28 13:31:47 +01:00
parent d39c1fdb49
commit 99f79aaaea
Signed by: erwin
SSH key fingerprint: SHA256:CyeNoWXd3kjX2Nwu6pDxxdS7OqmPVOy0NavA/KU/ntU
4 changed files with 405 additions and 0 deletions

View file

@ -51,6 +51,10 @@ inputs: {
substituteOnTarget = true; substituteOnTarget = true;
}; };
}; };
regin = {
system = "aarch64-linux";
config = import ./regin/configuration.nix inputs;
};
vm1 = { vm1 = {
config = import ./vm1/configuration.nix inputs; config = import ./vm1/configuration.nix inputs;
}; };

View file

@ -0,0 +1,221 @@
{ nixpkgs, nixos-hardware, ... }:
{ config, pkgs, ... }:
{
imports = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
nixos-hardware.nixosModules.raspberry-pi-4
../../users/root
../../users/erwin
];
eboskma = {
users.erwin.enable = true;
base.kernel = pkgs.linuxPackages_rpi4;
networking.enable = true;
nix-common.enable = true;
systemd.enable = true;
};
hardware = {
enableRedistributableFirmware = true;
raspberry-pi."4" = {
fkms-3d.enable = true;
audio.enable = true;
};
};
networking = {
hostName = "regin";
useDHCP = false;
useNetworkd = true;
};
systemd.network = {
enable = true;
networks = {
"40-eth0" = {
DHCP = "yes";
};
};
};
services.openssh.enable = true;
### 3D printer config
# TODO: split to modules
### Klipper
services.klipper = {
enable = true;
firmwares = {
mcu = {
enable = true;
configFile = ./firmware-config;
serial = "/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A600KWST-if00-port0";
};
};
settings = {
stepper_x = {
step_pin = "PA3";
dir_pin = "!PA1";
enabe_pin = "!PA5";
rotation_distance = 40;
microsteps = 16;
endstop_pin = "^PA0";
position_min = -10;
position_endstop = -10;
position_max = 195;
homing_speed = 50;
homing_retract_dist = 5;
};
stepper_y = {
step_pin = "PC6";
dir_pin = "!PC4";
enabe_pin = "!PA7";
rotation_distance = 40;
microsteps = 16;
endstop_pin = "^PA4";
position_min = 0;
position_endstop = 0;
position_max = 200;
homing_speed = 50;
homing_retract_dist = 5;
};
stepper_z = {
step_pin = "PC0";
dir_pin = "PG2";
enabe_pin = "!PC2";
rotation_distance = 2;
microsteps = 16;
endstop_pin = "^PC7";
position_min = 0;
position_endstop = 0;
position_max = 180;
homing_speed = 5;
homing_retract_dist = 5;
};
extruder = {
step_pin = "PL6";
dir_pin = "!PL4";
enable_pin = "!PG0";
rotation_distance = 34.043;
microsteps = 16;
nozzle_diameter = 0.400;
filament_diameter = 1.75;
max_extrude_only_distance = 150;
heater_pin = "PE4";
sensor_type = "EPCOS 100K B57560G104F";
sensor_pin = "PK0";
control = "pid";
pid_Kp = 12.33;
pid_Ki = 0.51;
pid_Kd = 74.50;
min_temp = 0;
max_temp = 250;
max_extrude_cross_section = 5;
};
heater_bed = {
heater_pin = "PG5";
sensor_type = "ATC Semitec 104GT-2";
sensor_pin = "PK2";
control = "pid";
pid_Kp = 234.88;
pid_Ki = 42.79;
pid_Kd = 322.28;
min_temp = 0;
max_temp = 120;
};
bed_screws = {
screw1 = "20,7";
screw2 = "190,7";
screw3 = "190,180";
screw4 = "20,180";
};
fan.pin = "PH4";
mcu.serial = config.services.klipper.firmwares.mcu.serial;
printer = {
kinematics = "cartesian";
max_velocity = 400;
max_accel = 5000;
max_z_velocity = 5;
max_z_accel = 75;
};
display = {
lcd_type = "hd44780";
rs_pin = "PD1";
e_pin = "PH0";
d4_pin = "PH1";
d5_pin = "PD0";
d6_pin = "PE3";
d7_pin = "PH3";
encoder_pins = "PL7,PG1";
click_pin = "^!PD2";
};
# These are necessary for Fluidd
virtual_sdcard = {
path = "/var/lib/klipper/gcode_files";
};
display_status = { };
pause_resume = { };
} // (import ./klipper-macros.nix);
};
services.moonraker = {
enable = true;
allowSystemControl = true;
settings = {
authorization = {
cors_domains = [
"*.local"
"*://app.fluidd.xyz"
];
trusted_clients = [
"10.0.0.0/24"
"10.1.0.0/24"
"127.0.0.0/8"
"fe80::/10"
"::1/128"
];
};
history = { };
octoprint_compat = {
enable_ufp = false;
};
zeroconf = { };
};
};
services.fluidd = {
enable = true;
hostName = config.networking.hostName;
};
### END 3D printer config
security = {
polkit.enable = true;
};
environment.systemPackages = with pkgs; [
raspberrypi-eeprom
];
system.stateVersion = "23.05";
}

View file

@ -0,0 +1,51 @@
CONFIG_LOW_LEVEL_OPTIONS=y
CONFIG_MACH_AVR=y
# 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_RP2040 is not set
# CONFIG_MACH_PRU is not set
# CONFIG_MACH_LINUX is not set
# CONFIG_MACH_SIMU is not set
CONFIG_AVR_SELECT=y
CONFIG_BOARD_DIRECTORY="avr"
CONFIG_MACH_atmega2560=y
# CONFIG_MACH_atmega1280 is not set
# CONFIG_MACH_at90usb1286 is not set
# CONFIG_MACH_at90usb646 is not set
# CONFIG_MACH_atmega32u4 is not set
# CONFIG_MACH_atmega1284p is not set
# CONFIG_MACH_atmega644p is not set
# CONFIG_MACH_atmega328p is not set
# CONFIG_MACH_atmega328 is not set
# CONFIG_MACH_atmega168 is not set
CONFIG_MCU="atmega2560"
CONFIG_AVRDUDE_PROTOCOL="wiring"
CONFIG_AVR_FREQ_16000000=y
# CONFIG_AVR_FREQ_8000000 is not set
CONFIG_CLOCK_FREQ=16000000
CONFIG_AVR_CLKPR=-1
CONFIG_AVR_STACK_SIZE=256
CONFIG_AVR_WATCHDOG=y
CONFIG_SERIAL=y
CONFIG_AVR_SERIAL_UART0=y
# CONFIG_AVR_SERIAL_UART1 is not set
# CONFIG_AVR_SERIAL_UART2 is not set
# CONFIG_AVR_SERIAL_UART3 is not set
CONFIG_SERIAL_BAUD_U2X=y
CONFIG_SERIAL_PORT=0
CONFIG_SERIAL_BAUD=250000
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER="12345"
CONFIG_CANBUS_FREQUENCY=500000
CONFIG_INITIAL_PINS=""
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_HAVE_STRICT_TIMING=y
CONFIG_INLINE_STEPPER_HACK=y

View file

@ -0,0 +1,129 @@
{
"gcode_macro PAUSE" = {
description = "Pause the running print";
rename_existing = "PAUSE_BASE";
variable_extrude = 1.0;
gcode = ''
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PAUSE_BASE
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
'';
};
"gcode_macro RESUME" = {
description = "Resume a paused print";
rename_existing = "RESUME_BASE";
gcode = ''
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
'';
};
"gcode_macro CANCEL_PRINT" = {
description = "Cancel the running print";
rename_existing = "CANCEL_PRINT_BASE";
gcode = ''
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
CANCEL_PRINT_BASE
END_PRINT
'';
};
"gcode_macro START_PRINT" = {
description = "Start of print base sequence";
variable_bed_temp = 60;
variable_extruder_temp = 200;
gcode = ''
# Start bed heating
M140 S{bed_temp}
# Reset the G-Code Z offset (adjust Z offset if needed)
SET_GCODE_OFFSET Z=0.0
# Home the printer
G28
# Use absolute coordinates
G90
# Reset extruder distance
G92 E0
# Move the nozzle near the bed
#G1 Z5 F3000
# Move the nozzle very close to the bed
#G1 Z0.15 F300
# Wait for bed to reach temperature
M190 S{bed_temp}
# Set and wait for nozzle to reach temperature
M109 S{extruder_temp}
# Prime the nozzle
G1 X-3 F500 # Move out of print volume
# G1 E4 F500 # Build a bit of pressure
# G1 Y60 E9 F500 # start purge line
# G1 Y100 E12.5 F500 # finish purge line
# Prime the nozzle
G1 Y140 E15 F1500
'';
};
"gcode_macro END_PRINT" = {
description = "End-of-print sequence";
gcode = ''
# Turn off bed, extruder, and fan
M140 S0
M104 S0
M107
# Move nozzle away from print while retracting
G91
G1 X-2 Y-2 E-5 F300
# Raise nozzle by 10mm
G1 Z10 F3000
# Home X axis
G28 X
G90
# Move bed forward
G1 Y180
# Disable X, Y and extruder steppers
M84 X Y E
'';
};
}