Compare commits

...

19 Commits

Author SHA1 Message Date
65a96db75b ODROID-C5: debian: change build rule
Change-Id: I44b0fcb6a753cab1f8bafbadb21d0f2a5602a30b
2025-07-02 10:45:02 +09:00
d94e8ba0bc ODROID-C5: analog: fix for ODROID-C5
ODROID-C5 has two internal 10bit ADCs. However, the value of in_voltage0_raw outputs a difficult number.

So, klipper read "in_voltage0_input", which outputs the actual voltage value, to read the value of ADC.

The iio device file, The read speed of "in_voltage0_input" is very slow. This will adversely affect the stepper motor operation and result in a "Stepper too far in past" error.

Read the value of Voltage0_raw and calculate the ADC voltage directly in the klipper.

Change-Id: I293cbdf8d1f54efe50ab89729a9908eb598820b6
2025-07-02 10:37:51 +09:00
d5bb4148f2 ODROID-C5: config: add board select config
Change-Id: Ic01d9fabf1d58ef453bd707858e77a5d09e116db
2025-07-02 10:13:18 +09:00
bc0c6a52fa Revert "ODROID-C5: change adc max value and adc file path"
This reverts commit 88ad6d1934.
2025-07-02 10:09:21 +09:00
7c07bdc08c Revert "ODROID-C5: analog: fix for ODROID-C5"
This reverts commit 4a66eefe5d.
2025-07-02 10:09:21 +09:00
a18ccdeea9 ORDOID-C5: config: add macro PRINT_END
Change-Id: I4040be0773ae009e9a123740a46251b29f3bc6ee
2025-06-24 15:33:16 +09:00
ce18ba251f ORDOID-C5: config: change bed screws
Change-Id: I2271cbc4bb74d6f0052bc973b7e40270a63d3dd5
2025-06-24 15:33:16 +09:00
facee8b4dc ORDOID-C5: config: change bed size
Change-Id: Id7a5fa32fd5b49eeed02691426149a3f001b024f
2025-06-24 15:33:16 +09:00
8dee2f31c9 ORDOID-C5: config: change heater bed PID parameter
Change-Id: I849bd7b8e9579bc7c4f63720d3764aaa07f6bba6
2025-06-24 15:33:16 +09:00
0cf3a2d2bd ODROID-C5: stepper: ignore error "Stepper too far in past"
Change-Id: I10975e37f512ae46b8b474435e809df4e219078f
2025-06-24 15:33:16 +09:00
8d087c3f86 ODROID-C5: systemd: change default CAN Bus bitrate
Change-Id: I17f4457d2ec83b88391e42831e19019be83c396b
2025-06-24 15:33:16 +09:00
7757c0bc68 ODROID-C5: change package name klipper-mcu to klipper-mcu-odroidc5
Change-Id: I070d6991e60e71c96757fae66f0b5e821cea3f2e
2025-06-24 15:33:16 +09:00
4a66eefe5d ODROID-C5: analog: fix for ODROID-C5
The iio device file, The read speed of "in_voltage0_input" is very slow. This will adversely affect the stepper motor operation and result in a "Stepper too far in past" error.

Read the value of Voltage0_raw and calculate the ADC voltage directly in the klipper.

Change-Id: Iedb1b5f7fbfedc60d42fc1a28eaa7e49879d6404
2025-06-24 15:33:16 +09:00
88ad6d1934 ODROID-C5: change adc max value and adc file path
ODROID-C5 has two internal 10bit ADCs. However, the value of in_voltage0_raw outputs a difficult number.

So, klipper read "in_voltage0_input", which outputs the actual voltage value, to read the value of ADC.

Change-Id: I32aada4e66e6034823bf66c41fccf178d6ff50d0
2025-06-24 15:33:16 +09:00
5797bd9cb3 ODROID-C5: systemd: add can systemd network
Change-Id: Ic1c30541e4507c4a92eecea3358e1116b556bf9f
2025-06-24 15:33:16 +09:00
2b961e6991 ODROID-C5: change baudrate
Baudrates that are too high will not work with the ODROID-C5.

Change-Id: I89c18fa05c3bb10f540c4ab9eec66094e36b8e9d
2025-06-24 15:33:16 +09:00
c789d93c05 ODROID-C5: debian: Add Debian package scripts
- Update klipper to v0.13.0
- Use Python virtual environment

Signed-off-by: YoungSoo Shin <shinys000114@gmail.com>
Change-Id: I8847a248fb622a8944e07a1fd858949b93629b86
2025-06-24 15:33:15 +09:00
Dongjin Kim
f7d08a02bb ODROID: debian: Add Debian package scripts
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
Change-Id: If859a008e42cf8c0f670de40886e525916ae98ce
2025-06-11 14:51:00 +09:00
c773418da6 ODROID: add example for m1s/c5
- Do not use this! not tested

Change-Id: I3e32957156348a7cdeccc7049a96ece7ca429668
2025-06-11 14:51:00 +09:00
21 changed files with 827 additions and 5 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=1000000

2
can.conf Normal file
View File

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

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

@@ -0,0 +1,261 @@
# 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 EBB42 CAN V1.0
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: 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: 200
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: 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: 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: 21.527
pid_Ki: 1.063
pid_Kd: 108.982
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: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
[bed_mesh]
speed: 80
mesh_min: 0,0
mesh_max: 150,150
probe_count: 5,5
[bed_screws]
screw1: 30,25
screw2: 200,25
screw3: 200,200
screw4: 30, 200
[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 PRINT_END]
gcode:
# Move Z +25
SAVE_GCODE_STATE NAME=_ui_movement
G91
G1 Z+25 F1500
RESTORE_GCODE_STATE NAME=_ui_movement
# Retract filament
SAVE_GCODE_STATE NAME=_ui_extrude
M83
G1 E-5 F300
RESTORE_GCODE_STATE NAME=_ui_extrude
# Move X and Y to 0
G28 X
G28 Y
[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

11
debian/changelog vendored Normal file
View File

@@ -0,0 +1,11 @@
klipper (0.13.0) stable; urgency=medium
* Version up
-- YoungSoo Shin <shinys000114@gmail.com> Wed, 04 Jun 2025 09:47:26 +0900
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-odroidc5
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Klipper MCU firmware
...

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

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

21
debian/klipper-mcu-odroidc5.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

33
debian/rules vendored Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/make -f
define firmware
make distclean
echo CONFIG_MACH_LINUX=y \
> $(shell pwd)/.config
echo CONFIG_MACH_LINUX_ODROIDC5=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-odroidc5 --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

@@ -16,6 +16,22 @@ config BOARD_DIRECTORY
string string
default "linux" default "linux"
######################################################################
# Board selection
######################################################################
choice
prompt "Board model"
config MACH_LINUX_DEFAULT
bool "DEFAULT"
config MACH_LINUX_ODROIDC5
bool "ODROID-C5"
select MACH_LINUX_ODROID_COMMON
endchoice
config MACH_LINUX_ODROID_COMMON
bool
config CLOCK_FREQ config CLOCK_FREQ
int int
default 50000000 default 50000000

View File

@@ -3,10 +3,13 @@
dirs-y += src/linux src/generic dirs-y += src/linux src/generic
src-y += linux/main.c linux/timer.c linux/console.c linux/watchdog.c src-y += linux/main.c linux/timer.c linux/console.c linux/watchdog.c
src-y += linux/pca9685.c linux/spidev.c linux/analog.c linux/hard_pwm.c src-y += linux/pca9685.c linux/spidev.c linux/hard_pwm.c
src-y += linux/i2c.c linux/gpio.c generic/crc16_ccitt.c generic/alloc.c src-y += linux/i2c.c linux/gpio.c generic/crc16_ccitt.c generic/alloc.c
src-y += linux/sensor_ds18b20.c src-y += linux/sensor_ds18b20.c
src-$(CONFIG_MACH_LINUX_DEFAULT) += linux/analog.c
src-$(CONFIG_MACH_LINUX_ODROIDC5) += linux/analog_odroidc5.c
CFLAGS_klipper.elf += -lutil -lrt -lpthread CFLAGS_klipper.elf += -lutil -lrt -lpthread
flash: $(OUT)klipper.elf flash: $(OUT)klipper.elf

102
src/linux/analog_odroidc5.c Normal file
View File

@@ -0,0 +1,102 @@
// Read analog values from Linux IIO device
//
// Copyright (C) 2017 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
#include <fcntl.h> // open
#include <stdio.h> // snprintf
#include <stdlib.h> // atoi
#include <unistd.h> // read
#include "command.h" // shutdown
#include "gpio.h" // gpio_adc_setup
#include "internal.h" // report_errno
#include "sched.h" // sched_shutdown
// ODROID-C5
DECL_CONSTANT("ADC_MAX", 1800);
#define ANALOG_START (1<<12)
DECL_ENUMERATION_RANGE("pin", "analog0", ANALOG_START, 8);
// ODROID-C5
#define IIO_PATH "/sys/bus/iio/devices/iio:device0/in_voltage0_raw"
#define SCALE_PATH "/sys/bus/iio/devices/iio:device0/in_voltage_scale"
#define OFFSET_PATH "/sys/bus/iio/devices/iio:device0/in_voltage_offset"
struct gpio_adc
gpio_adc_setup(uint32_t pin)
{
struct gpio_adc g;
int fd;
char buf[64];
int ret;
fd = open(SCALE_PATH, O_RDONLY);
ret = read(fd, buf, sizeof(buf)-1);
if (ret <= 0) {
goto fail;
}
buf[ret] = '\0';
g.scale = atof(buf) * 1000;
close(fd);
fd = open(OFFSET_PATH, O_RDONLY);
ret = read(fd, buf, sizeof(buf)-1);
if (ret <= 0) {
goto fail;
}
buf[ret] = '\0';
g.offset = atoi(buf);
close(fd);
fd = open(IIO_PATH, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
report_errno("analog open", fd);
goto fail;
}
ret = set_non_blocking(fd);
if (ret < 0)
goto fail;
g.fd = fd;
return g;
fail:
if (fd >= 0)
close(fd);
shutdown("Unable to open adc device");
}
uint32_t
gpio_adc_sample(struct gpio_adc g)
{
return 0;
}
uint16_t
gpio_adc_read(struct gpio_adc g)
{
char buf[64];
int voltage;
int ret = pread(g.fd, buf, sizeof(buf)-1, 0);
if (ret <= 0) {
report_errno("analog read", ret);
try_shutdown("Error on analog read");
return 0;
}
buf[ret] = '\0';
voltage = atoi(buf) + g.offset;
voltage = voltage > 0 ? voltage : 0;
voltage = voltage * g.scale;
voltage = voltage < 1800000 ? voltage : 1800000;
voltage /= 1000;
return voltage;
}
void
gpio_adc_cancel_sample(struct gpio_adc g)
{
}

View File

@@ -1,6 +1,7 @@
#ifndef __LINUX_GPIO_H #ifndef __LINUX_GPIO_H
#define __LINUX_GPIO_H #define __LINUX_GPIO_H
#include "autoconf.h" // CONFIG_MACH_LINUX_*
#include <stdint.h> // uint8_t #include <stdint.h> // uint8_t
struct gpio_out { struct gpio_out {
@@ -20,6 +21,10 @@ void gpio_in_reset(struct gpio_in g, int8_t pull_up);
uint8_t gpio_in_read(struct gpio_in g); uint8_t gpio_in_read(struct gpio_in g);
struct gpio_adc { struct gpio_adc {
#ifdef CONFIG_MACH_LINUX_ODROIDC5
int scale;
int offset;
#endif
int fd; int fd;
}; };
struct gpio_adc gpio_adc_setup(uint32_t pin); struct gpio_adc gpio_adc_setup(uint32_t pin);

View File

@@ -172,9 +172,9 @@ stepper_event_full(struct timer *t)
if (ret == SF_DONE || !timer_is_before(s->time.waketime, min_next_time)) if (ret == SF_DONE || !timer_is_before(s->time.waketime, min_next_time))
return ret; return ret;
// Next step event is too close to the last unstep // Next step event is too close to the last unstep
int32_t diff = s->time.waketime - min_next_time; // int32_t diff = s->time.waketime - min_next_time;
if (diff < (int32_t)-timer_from_us(1000)) // if (diff < (int32_t)-timer_from_us(1000))
shutdown("Stepper too far in past"); // shutdown("Stepper too far in past");
reschedule_min: reschedule_min:
s->time.waketime = min_next_time; s->time.waketime = min_next_time;
return SF_RESCHEDULE; return SF_RESCHEDULE;