Compare commits

...

6 Commits

Author SHA1 Message Date
838652e723 ODROID-C5: change adc max value and adc file path
Change-Id: I32aada4e66e6034823bf66c41fccf178d6ff50d0
2025-06-04 09:38:29 +09:00
67f8acc7d8 add can systemd network
Change-Id: Ic1c30541e4507c4a92eecea3358e1116b556bf9f
2025-06-04 09:38:29 +09:00
e1eb7b3d7b ODROID-C5: change baudrate
Change-Id: I89c18fa05c3bb10f540c4ab9eec66094e36b8e9d
2025-06-04 09:38:29 +09:00
acb13c0034 ODROID: debian: Add Debian package scripts
- Update klipper to v0.13.0

Signed-off-by: YoungSoo Shin <shinys000114@gmail.com>
Change-Id: I8847a248fb622a8944e07a1fd858949b93629b86
2025-06-04 09:38:29 +09:00
Dongjin Kim
b05df8ccdf ODROID: debian: Add Debian package scripts
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
Change-Id: If859a008e42cf8c0f670de40886e525916ae98ce
2025-06-04 09:38:29 +09:00
11fdec8c51 ODROID: add example for m1s/c5
- Do not use this! not tested

Change-Id: I3e32957156348a7cdeccc7049a96ece7ca429668
2025-06-04 09:38:29 +09:00
17 changed files with 675 additions and 3 deletions

4
.gitignore vendored
View File

@@ -4,3 +4,7 @@ out
.config .config
.config.old .config.old
klippy/.version klippy/.version
.pybuild/
dist
firmware

5
80-can.network Normal file
View File

@@ -0,0 +1,5 @@
[Match]
Name=can0
[CAN]
BitRate=250000

2
can.conf Normal file
View File

@@ -0,0 +1,2 @@
can-raw
can-dev

243
config/example-odroidc5.cfg Normal file
View File

@@ -0,0 +1,243 @@
# Copyright (C) 2025 Hardkernel Co., Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# This file contains common pin mappings for the m1s with board_stepper
# To use this config, the firmware should be compiled for the
# Linux process.
[mcu]
serial: /tmp/klipper_host_mcu
[mcu EBBCan] # based on EBB36 CAN V1.1
canbus_uuid: e8a11afa199b
[printer]
kinematics: cartesian
max_velocity: 500
max_accel: 5000
#max_accel: 7000
#max_accel_to_decel: 3500
max_z_velocity: 25
max_z_accel: 100
[stepper_x]
step_pin: gpiochip0/gpio31
dir_pin: gpiochip0/gpio30
enable_pin: !gpiochip0/gpio50
endstop_pin: gpiochip0/gpio51
homing_retract_dist: 2
microsteps: 16
rotation_distance: 40
position_endstop: 0
position_max: 200
homing_speed: 50
[stepper_y]
step_pin: gpiochip0/gpio28
dir_pin: gpiochip0/gpio41
enable_pin: !gpiochip0/gpio66
endstop_pin: gpiochip0/gpio49
homing_retract_dist: 2
microsteps: 16
rotation_distance: 40
position_endstop: 0
position_max: 230
homing_speed: 50
[stepper_z]
step_pin: gpiochip0/gpio55
dir_pin: !gpiochip0/gpio62
enable_pin: !gpiochip0/gpio26
microsteps: 16
rotation_distance: 8
endstop_pin: probe: z_virtual_endstop
position_min: -4.0
position_max: 300
[stepper_z1]
step_pin: gpiochip0/gpio54
dir_pin: !gpiochip0/gpio40
enable_pin: !gpiochip0/gpio27
microsteps: 16
rotation_distance: 8
[extruder]
step_pin: EBBCan: PD0
dir_pin: EBBCan: PD1
enable_pin: !EBBCan: PD2
microsteps: 16
rotation_distance: 7.703694208
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: EBBCan:PB13
sensor_type: EPCOS 100K B57560G104F
sensor_pin: EBBCan:PA3
control: pid
pid_Kp: 21.527
pid_Ki: 1.063
pid_Kd: 108.982
min_temp: 0
max_temp: 240
min_extrude_temp: 0
[heater_fan nozzle_fan]
pin: EBBCan:PA2
heater: extruder
heater_temp: 50.0
[heater_bed]
heater_pin: gpiochip0/gpio65
sensor_type: ATC Semitec 104GT-2
sensor_pin: analog0
control = pid
pid_kp = 76.549
pid_ki = 0.974
pid_kd = 1504.195
min_temp: 0
max_temp: 85
[z_tilt]
z_positions:
260, 130# -55,-7
-30, 130# -55,320
points:
20,130
180,130
retries: 5
retry_tolerance: 0.002
[fan]
pin: EBBCan:PA1
[verify_heater extruder]
max_error: 200
check_gain_time: 60
heating_gain: 1
[tmc2209 stepper_x]
uart_pin: gpiochip0/gpio61
tx_pin: gpiochip0/gpio60
uart_address: 1
run_current: 0.800
hold_current: 0.500
stealthchop_threshold: 250
[tmc2209 stepper_y]
uart_pin: gpiochip0/gpio61
tx_pin: gpiochip0/gpio60
uart_address: 2
run_current: 0.800
hold_current: 0.500
stealthchop_threshold: 250
[tmc2209 stepper_z]
uart_pin: gpiochip0/gpio61
tx_pin: gpiochip0/gpio60
uart_address: 3
run_current: 1.000
hold_current: 0.500
stealthchop_threshold: 30
[tmc2209 stepper_z1]
uart_pin: gpiochip0/gpio61
tx_pin: gpiochip0/gpio60
uart_address: 0
run_current: 1.000
hold_current: 0.500
stealthchop_threshold: 30
[tmc2209 extruder]
uart_pin: EBBCan:PA15
run_current: 0.800
hold_current: 0.500
stealthchop_threshold: 250
[probe]
pin: !EBBCan:PB8
x_offset: -42.0
y_offset: -4.0
speed: 5.0
[bed_mesh]
speed: 80
mesh_min: 0,0
mesh_max: 180,270
probe_count: 3,3
[bed_screws]
screw1: 30,25
screw2: 270,25
screw3: 270,265
screw4: 30, 265
[input_shaper]
shaper_freq_x: 39.4
shaper_type_x: mzv
shaper_freq_y: 25.0
shaper_type_y: mzv
[virtual_sdcard]
path: /var/printer_data/gcodes
[pause_resume]
[display_status]
[homing_override]
set_position_z: 0
axes: z
gcode:
G1 Z10 F600
G28 X Y
G1 X142 Y150 F3000 # (100 + 42, 150 + 4)
G28 Z
[gcode_macro START_PRINT]
gcode:
G28
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
gcode:
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-{E} F2100
G1 Z{Z}
G90
G1 X{X} Y{Y} F6000
[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
G91
G1 E{E} F2100
G90
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
BASE_CANCEL_PRINT
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [probe]
#*# z_offset = 0.34

View File

@@ -0,0 +1,296 @@
# Copyright (C) 2023 Hardkernel Co., Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# This file contains common pin mappings for the m1s with board_stepper
# To use this config, the firmware should be compiled for the
# Linux process.
[mcu]
serial: /tmp/klipper_host_mcu
[mcu EBBCan] # based on EBB42 CAN V1.0
# python3 ~/klipper/lib/canboot/flash_can.py -i can0 -q
canbus_uuid: 1e8ea3b32c8a
[printer]
kinematics: cartesian
max_velocity: 500
max_accel: 5000
#max_accel: 7000
#max_accel_to_decel: 3500
max_z_velocity: 25
max_z_accel: 100
[stepper_x]
step_pin: gpiochip2/gpio15
dir_pin: gpiochip2/gpio16
enable_pin: !gpiochip0/gpio12
endstop_pin: gpiochip2/gpio6
homing_retract_dist: 2
microsteps: 16
rotation_distance: 40
position_endstop: 0
position_max: 240
homing_speed: 50
[stepper_y]
step_pin: gpiochip0/gpio13
dir_pin: gpiochip0/gpio14
enable_pin: !gpiochip3/gpio13
endstop_pin: gpiochip3/gpio14
homing_retract_dist: 2
microsteps: 16
rotation_distance: 40
position_endstop: 0
position_max: 290
homing_speed: 50
[stepper_z]
step_pin: gpiochip2/gpio7
dir_pin: !gpiochip2/gpio13
enable_pin: !gpiochip2/gpio14
microsteps: 16
rotation_distance: 8
endstop_pin: probe: z_virtual_endstop
#position_endstop: 0.0
position_min: -4.0
position_max: 330
[stepper_z1]
step_pin: gpiochip2/gpio9
dir_pin: !gpiochip0/gpio18
enable_pin: !gpiochip3/gpio11
microsteps: 16
rotation_distance: 8
# #endstop_pin: probe: z_virtual_endstop
# position_endstop: 0.0
#
# [stepper_z2]
# step_pin: gpiochip0/gpio11
# dir_pin: !gpiochip2/gpio5
# enable_pin: !gpiochip3/gpio20
# microsteps: 16
# rotation_distance: 8
# endstop_pin: probe: z_virtual_endstop
#position_endstop: 0.0
# position_min: -4.0
# position_max: 330
#
# [stepper_z3]
# step_pin: gpiochip3/gpio21
# dir_pin: !gpiochip3/gpio12
# enable_pin: !gpiochip3/gpio20
# microsteps: 16
# rotation_distance: 8
# endstop_pin: probe: z_virtual_endstop
# #position_endstop: 0.0
# position_min: -4.0
# position_max: 330
[extruder]
step_pin: EBBCan: PA9
dir_pin: EBBCan: PA8
enable_pin: !EBBCan: PA10
microsteps: 16
rotation_distance: 7.703694208
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: EBBCan:PB1
sensor_type: EPCOS 100K B57560G104F
sensor_pin: EBBCan:PA0
control: pid
pid_Kp: 21.527
pid_Ki: 1.063
pid_Kd: 108.982
min_temp: 0
max_temp: 240
min_extrude_temp: 100
[heater_fan nozzle_fan]
pin: EBBCan:PA2
heater: extruder
heater_temp: 50.0
[heater_bed]
heater_pin: gpiochip2/gpio10
sensor_type: ATC Semitec 104GT-2
sensor_pin: analog3
control = pid
pid_kp = 76.549
pid_ki = 0.974
pid_kd = 1504.195
min_temp: 0
max_temp: 85
[z_tilt]
z_positions:
260, 130# -55,-7
-30, 130# -55,320
points:
20,130
210,130
retries: 5
retry_tolerance: 0.002
[fan]
pin: EBBCan:PA1
[verify_heater extruder]
max_error: 200
check_gain_time: 60
heating_gain: 1
[tmc2209 stepper_x]
uart_pin: gpiochip0/gpio16
tx_pin: gpiochip0/gpio17
uart_address: 0
run_current: 0.800
hold_current: 0.500
stealthchop_threshold: 250
[tmc2209 stepper_y]
uart_pin: gpiochip0/gpio16
tx_pin: gpiochip0/gpio17
uart_address: 2
run_current: 0.800
hold_current: 0.500
stealthchop_threshold: 250
[tmc2209 stepper_z]
uart_pin: gpiochip0/gpio16
tx_pin: gpiochip0/gpio17
uart_address: 1
run_current: 1.000
hold_current: 0.500
stealthchop_threshold: 30
[tmc2209 stepper_z1]
uart_pin: gpiochip0/gpio16
tx_pin: gpiochip0/gpio17
uart_address: 3
run_current: 1.000
hold_current: 0.500
stealthchop_threshold: 30
#
# [tmc2209 stepper_z2]
# uart_pin: gpiochip2/gpio3
# tx_pin: gpiochip2/gpio4
# uart_address: 0
# run_current: 1.000
# hold_current: 0.500
# stealthchop_threshold: 30
#
# [tmc2209 stepper_z3]
# uart_pin: gpiochip2/gpio3
# tx_pin: gpiochip2/gpio4
# uart_address: 2
# run_current: 1.000
# hold_current: 0.500
# stealthchop_threshold: 30
[tmc2209 extruder]
uart_pin: EBBCan:PA13
run_current: 0.800
hold_current: 0.500
stealthchop_threshold: 250
[probe]
pin: !EBBCan:PA5
x_offset: -42.0
y_offset: -4.0
speed: 5.0
#samples: 3
#sample_retract_dist: 1.0
[bed_mesh]
speed: 80
#horizontal_move_z: 3
mesh_min: 0,0
mesh_max: 180,270
probe_count: 3,3
#probe_count: 10,10
#fade_start: 1.0
#fade_end: 10.0
[bed_screws]
screw1: 30,25
screw2: 270,25
screw3: 270,265
screw4: 30, 265
[input_shaper]
shaper_freq_x: 39.4
shaper_type_x: mzv
shaper_freq_y: 25.0
shaper_type_y: mzv
[virtual_sdcard]
path: ~/printer_data/gcodes
[pause_resume]
[display_status]
[homing_override]
set_position_z: 0
axes: z
gcode:
G1 Z10 F600
G28 X Y
G1 X142 Y150 F3000 # (100 + 42, 150 + 4)
G28 Z
[gcode_macro START_PRINT]
gcode:
G28
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
#default_parameter_X: 230 #edit to your park position
#default_parameter_Y: 230 #edit to your park position
#default_parameter_Z: 10 #edit to your park position
#default_parameter_E: 1 #edit to your retract length
gcode:
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-{E} F2100
G1 Z{Z}
G90
G1 X{X} Y{Y} F6000
[gcode_macro RESUME]
rename_existing: BASE_RESUME
#default_parameter_E: 1 #edit to your retract length
gcode:
G91
G1 E{E} F2100
G90
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
BASE_CANCEL_PRINT
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [probe]
#*# z_offset = 0.34

5
debian/changelog vendored Normal file
View File

@@ -0,0 +1,5 @@
klipper (0.1) stable; urgency=medium
* Initial release.
-- Dongjin Kim <tobetter@gmail.com> Mon, 11 Jan 2021 17:30:47 -0500

1
debian/compat vendored Normal file
View File

@@ -0,0 +1 @@
10

34
debian/control vendored Normal file
View File

@@ -0,0 +1,34 @@
Source: klipper
Maintainer: Kevin O'Connor <kevin@koconnor.net>
Uploaders: Dongjin Kim <tobetter@gmail.com>
Section: utils
Priority: optional
Build-Depends: debhelper (>=9),
build-essential,
libc6-dev,
dh-virtualenv (>= 1.0),
python3,
python3-dev,
python3-pip,
libffi-dev,
Standards-Version: 3.9.5
Package: klipper
Architecture: any
Depends: ${misc:Depends},
python3,
python3-dev,
virtualenv,
libffi-dev,
build-essential,
libusb-dev,
libusb-1.0-0,
usbutils,
Description: Klipper Host software
...
Package: klipper-mcu
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Klipper MCU firmware
...

1
debian/klipper-mcu.install vendored Normal file
View File

@@ -0,0 +1 @@
firmware/* /usr/share/klipper/firmware/

21
debian/klipper-mcu.service vendored Normal file
View File

@@ -0,0 +1,21 @@
#Systemd klipper linux mcu Service
[Unit]
Description=Starts the MCU Linux firmware for klipper on startup
Documentation=https://www.klipper3d.org/RPi_microcontroller.html
Before=klipper.service
ConditionFileIsExecutable=/usr/share/klipper/firmware/LINUX/klipper_mcu
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
Environment=KLIPPER_HOST_MCU_SERIAL=/tmp/klipper_host_mcu
RemainAfterExit=yes
ExecStart=/usr/share/klipper/firmware/LINUX/klipper_mcu -r -I ${KLIPPER_HOST_MCU_SERIAL}
ExecStop=sh -c 'echo "FORCE_SHUTDOWN" > ${KLIPPER_HOST_MCU_SERIAL}'
ExecStop=sleep 1
TimeoutStopSec=2
Restart=always
RestartSec=5

4
debian/klipper.install vendored Normal file
View File

@@ -0,0 +1,4 @@
config/* /var/printer_data/config/
klippy/* /usr/share/klippy
can.conf /lib/modules-load.d/
80-can.network /lib/systemd/network/

6
debian/klipper.postinst vendored Normal file
View File

@@ -0,0 +1,6 @@
#!/bin/sh
mkdir -p "/var/printer_data/logs"
ln -s example-odroidc5.cfg /var/printer_data/config/printer.cfg
#DEBHELPER#

16
debian/klipper.service vendored Normal file
View File

@@ -0,0 +1,16 @@
#Systemd service file for klipper
[Unit]
Description=Starts klipper on startup
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/opt/venvs/klipper/bin/python3 \
usr/share/klippy/klippy.py \
/var/printer_data/config/printer.cfg \
-l /var/printer_data/logs/klippy.log \
-a /tmp/klipper.sock

31
debian/rules vendored Executable file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/make -f
define firmware
make distclean
echo CONFIG_MACH_LINUX=y | tr -d '[[:space:]]' \
> $(shell pwd)/.config && make olddefconfig
TOPDIR=$(shell pwd) make
mkdir -p $(shell pwd)/firmware/LINUX
cp out/klipper.elf $(shell pwd)/firmware/LINUX/klipper_mcu
endef
%:
dh $@ --with python-virtualenv --with systemd
override_dh_auto_configure:
$(call firmware,LINUX,klipper.elf,klipper_mcu)
dh_auto_configure
override_dh_virtualenv:
dh_virtualenv --requirements scripts/klippy-requirements.txt --no-package klipper-mcu --skip-install
override_dh_strip:
dh_strip --exclude=/site-packages/
override_dh_shlibdeps:
dh_shlibdeps --exclude=/site-packages/
override_dh_auto_install:
dh_auto_install
dh_systemd_enable || false
dh_systemd_start || false

1
debian/source/format vendored Normal file
View File

@@ -0,0 +1 @@
3.0 (quilt)

View File

@@ -70,7 +70,7 @@ def lookup_tmc_uart_mutex(mcu):
pmutexes.mcu_to_mutex[mcu] = mutex pmutexes.mcu_to_mutex[mcu] = mutex
return mutex return mutex
TMC_BAUD_RATE = 40000 TMC_BAUD_RATE = 9600
TMC_BAUD_RATE_AVR = 9000 TMC_BAUD_RATE_AVR = 9000
# Code for sending messages on a TMC uart # Code for sending messages on a TMC uart

View File

@@ -13,13 +13,15 @@
#include "internal.h" // report_errno #include "internal.h" // report_errno
#include "sched.h" // sched_shutdown #include "sched.h" // sched_shutdown
DECL_CONSTANT("ADC_MAX", 4095); // Assume 12bit adc // ODROID-C5
DECL_CONSTANT("ADC_MAX", 1800); // Assume 12bit adc
#define ANALOG_START (1<<12) #define ANALOG_START (1<<12)
DECL_ENUMERATION_RANGE("pin", "analog0", ANALOG_START, 8); DECL_ENUMERATION_RANGE("pin", "analog0", ANALOG_START, 8);
#define IIO_PATH "/sys/bus/iio/devices/iio:device0/in_voltage%d_raw" // ODROID-C5
#define IIO_PATH "/sys/bus/iio/devices/iio:device0/in_voltage%d_input"
struct gpio_adc struct gpio_adc
gpio_adc_setup(uint32_t pin) gpio_adc_setup(uint32_t pin)