Skip to content

Commit f582a36

Browse files
committed
Initial commit of source code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
1 parent 37a91e9 commit f582a36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+9950
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
out
2+
*.so
3+
*.pyc
4+
.config
5+
.config.old

COPYING

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Klipper build system
2+
#
3+
# Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
4+
#
5+
# This file may be distributed under the terms of the GNU GPLv3 license.
6+
7+
# Output directory
8+
OUT=out/
9+
10+
# Kconfig includes
11+
export HOSTCC := $(CC)
12+
export CONFIG_SHELL := sh
13+
export KCONFIG_AUTOHEADER := autoconf.h
14+
export KCONFIG_CONFIG := $(CURDIR)/.config
15+
-include $(KCONFIG_CONFIG)
16+
17+
# Common command definitions
18+
CC=$(CROSS_PREFIX)gcc
19+
AS=$(CROSS_PREFIX)as
20+
LD=$(CROSS_PREFIX)ld
21+
OBJCOPY=$(CROSS_PREFIX)objcopy
22+
OBJDUMP=$(CROSS_PREFIX)objdump
23+
STRIP=$(CROSS_PREFIX)strip
24+
CPP=cpp
25+
PYTHON=python
26+
27+
# Source files
28+
src-y=sched.c command.c stepper.c basecmd.c gpiocmds.c spicmds.c endstop.c
29+
DIRS=src src/avr src/simulator
30+
31+
# Default compiler flags
32+
cc-option=$(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`" \
33+
; then echo "$(2)"; else echo "$(3)"; fi ;)
34+
35+
CFLAGS-y := -I$(OUT) -Isrc -Os -MD -g \
36+
-Wall -Wold-style-definition $(call cc-option,$(CC),-Wtype-limits,) \
37+
-ffunction-sections -fdata-sections
38+
CFLAGS-y += -flto -fwhole-program
39+
40+
LDFLAGS-y := -Wl,--gc-sections
41+
42+
CPPFLAGS = -P -MD -MT $@
43+
44+
CFLAGS = $(CFLAGS-y)
45+
LDFLAGS = $(LDFLAGS-y)
46+
47+
# Default targets
48+
target-y := $(OUT)klipper.elf
49+
50+
all:
51+
52+
# Run with "make V=1" to see the actual compile commands
53+
ifdef V
54+
Q=
55+
else
56+
Q=@
57+
MAKEFLAGS += --no-print-directory
58+
endif
59+
60+
# Include board specific makefile
61+
-include src/$(patsubst "%",%,$(CONFIG_BOARD_DIRECTORY))/Makefile
62+
63+
################ Common build rules
64+
65+
$(OUT)%.o: %.c $(OUT)autoconf.h $(OUT)board-link
66+
@echo " Compiling $@"
67+
$(Q)$(CC) $(CFLAGS) -c $< -o $@
68+
69+
################ Main build rules
70+
71+
$(OUT)board-link: $(KCONFIG_CONFIG)
72+
@echo " Creating symbolic link $(OUT)board"
73+
$(Q)touch $@
74+
$(Q)ln -Tsf $(PWD)/src/$(CONFIG_BOARD_DIRECTORY) $(OUT)board
75+
76+
$(OUT)declfunc.lds: src/declfunc.lds.S
77+
@echo " Precompiling $@"
78+
$(Q)$(CPP) $(CPPFLAGS) -D__ASSEMBLY__ $< -o $@
79+
80+
$(OUT)klipper.o: $(patsubst %.c, $(OUT)src/%.o,$(src-y)) $(OUT)declfunc.lds
81+
@echo " Linking $@"
82+
$(Q)$(CC) $(CFLAGS) -Wl,-r -Wl,-T,$(OUT)declfunc.lds -nostdlib $(patsubst %.c, $(OUT)src/%.o,$(src-y)) -o $@
83+
84+
$(OUT)compile_time_request.o: $(OUT)klipper.o ./scripts/buildcommands.py
85+
@echo " Building $@"
86+
$(Q)$(OBJCOPY) -j '.compile_time_request' -O binary $< $(OUT)klipper.o.compile_time_request
87+
$(Q)$(PYTHON) ./scripts/buildcommands.py $(OUT)klipper.o.compile_time_request $(OUT)autoconf.h $(OUT)compile_time_request.c
88+
$(Q)$(CC) $(CFLAGS) -c $(OUT)compile_time_request.c -o $@
89+
90+
$(OUT)klipper.elf: $(OUT)klipper.o $(OUT)compile_time_request.o
91+
@echo " Linking $@"
92+
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
93+
94+
################ Kconfig rules
95+
96+
define do-kconfig
97+
$(Q)mkdir -p $(OUT)/scripts/kconfig/lxdialog
98+
$(Q)mkdir -p $(OUT)/include/config
99+
$(Q)mkdir -p $(addprefix $(OUT), $(DIRS))
100+
$(Q)$(MAKE) -C $(OUT) -f $(CURDIR)/scripts/kconfig/Makefile srctree=$(CURDIR) src=scripts/kconfig obj=scripts/kconfig Q=$(Q) Kconfig=$(CURDIR)/src/Kconfig $1
101+
endef
102+
103+
$(OUT)autoconf.h : $(KCONFIG_CONFIG) ; $(call do-kconfig, silentoldconfig)
104+
$(KCONFIG_CONFIG): src/Kconfig ; $(call do-kconfig, olddefconfig)
105+
%onfig: ; $(call do-kconfig, $@)
106+
help: ; $(call do-kconfig, $@)
107+
108+
109+
################ Generic rules
110+
111+
# Make definitions
112+
.PHONY : all clean distclean FORCE
113+
.DELETE_ON_ERROR:
114+
115+
all: $(target-y)
116+
117+
clean:
118+
$(Q)rm -rf $(OUT)
119+
120+
distclean: clean
121+
$(Q)rm -f .config .config.old
122+
123+
-include $(patsubst %,$(OUT)%/*.d,$(DIRS))

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Welcome to the Klipper project!
2+
3+
This project implements a 3d-printer firmware. There are two parts to
4+
this firmware - code that runs on a micro-controller and code that
5+
runs on a host machine. The host software does the work to build a
6+
schedule of events, while the micro-controller software does the work
7+
to execute the provided schedule at the specified times.
8+
9+
Please see the [documentation](docs/Overview.md) for more information
10+
on running and working with Klipper.
11+
12+
License
13+
=======
14+
15+
Klipper is free software: you can redistribute it and/or modify
16+
it under the terms of the GNU General Public License as published by
17+
the Free Software Foundation, either version 3 of the License, or
18+
(at your option) any later version.
19+
20+
Klipper is distributed in the hope that it will be useful,
21+
but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+
GNU General Public License for more details.
24+
25+
You should have received a copy of the GNU General Public License
26+
along with Klipper. If not, see <http://www.gnu.org/licenses/>.

config/avrsim.cfg

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Support for internal testing with the "simulavr" program. To use
2+
# this config, compile the firmware for an AVR atmega644p, disable the
3+
# AVR watchdog timer, set the MCU frequency to 20000000, and set the
4+
# serial baud rate to 115200.
5+
6+
[stepper_x]
7+
# Pins: PA5, PA4, PA1
8+
step_pin: ar29
9+
dir_pin: ar28
10+
enable_pin: ar25
11+
step_distance: .0225
12+
max_velocity: 500
13+
max_accel: 3000
14+
endstop_pin: ^!ar0
15+
position_min: -0.25
16+
position_endstop: 0
17+
position_max: 200
18+
19+
[stepper_y]
20+
# Pins: PA3, PA2
21+
step_pin: ar27
22+
dir_pin: ar26
23+
enable_pin: ar25
24+
step_distance: .0225
25+
max_velocity: 500
26+
max_accel: 3000
27+
endstop_pin: ^!ar1
28+
position_min: -0.25
29+
position_endstop: 0
30+
position_max: 200
31+
32+
[stepper_z]
33+
# Pins: PC7, PC6
34+
step_pin: ar23
35+
dir_pin: ar22
36+
enable_pin: ar25
37+
step_distance: .005
38+
max_velocity: 250
39+
max_accel: 30
40+
endstop_pin: ^!ar2
41+
position_min: 0.1
42+
position_endstop: 0.5
43+
position_max: 200
44+
45+
[stepper_e]
46+
# Pins: PC3, PC2
47+
step_pin: ar19
48+
dir_pin: ar18
49+
enable_pin: ar25
50+
step_distance: .004242
51+
max_velocity: 200000
52+
max_accel: 3000
53+
54+
[heater_nozzle]
55+
heater_pin: ar4
56+
thermistor_pin: analog1
57+
thermistor_type: EPCOS 100K B57560G104F
58+
control: pid
59+
pid_Kp: 22.2
60+
pid_Ki: 1.08
61+
pid_Kd: 114
62+
min_temp: 0
63+
max_temp: 210
64+
65+
[heater_bed]
66+
heater_pin: ar3
67+
thermistor_pin: analog0
68+
thermistor_type: EPCOS 100K B57560G104F
69+
control: watermark
70+
min_temp: 0
71+
max_temp: 110
72+
73+
[fan]
74+
pin: ar14
75+
hard_pwm: 1
76+
77+
[mcu]
78+
serial: /tmp/pseudoserial
79+
baud: 115200
80+
pin_map: arduino
81+
82+
[printer]
83+
kinematics: cartesian

0 commit comments

Comments
 (0)