Skip to content

Commit

Permalink
Initial commit of source code.
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed May 25, 2016
1 parent 37a91e9 commit f582a36
Show file tree
Hide file tree
Showing 71 changed files with 9,950 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
out
*.so
*.pyc
.config
.config.old
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Klipper build system
#
# Copyright (C) 2016 Kevin O'Connor <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.

# Output directory
OUT=out/

# Kconfig includes
export HOSTCC := $(CC)
export CONFIG_SHELL := sh
export KCONFIG_AUTOHEADER := autoconf.h
export KCONFIG_CONFIG := $(CURDIR)/.config
-include $(KCONFIG_CONFIG)

# Common command definitions
CC=$(CROSS_PREFIX)gcc
AS=$(CROSS_PREFIX)as
LD=$(CROSS_PREFIX)ld
OBJCOPY=$(CROSS_PREFIX)objcopy
OBJDUMP=$(CROSS_PREFIX)objdump
STRIP=$(CROSS_PREFIX)strip
CPP=cpp
PYTHON=python

# Source files
src-y=sched.c command.c stepper.c basecmd.c gpiocmds.c spicmds.c endstop.c
DIRS=src src/avr src/simulator

# Default compiler flags
cc-option=$(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`" \
; then echo "$(2)"; else echo "$(3)"; fi ;)

CFLAGS-y := -I$(OUT) -Isrc -Os -MD -g \
-Wall -Wold-style-definition $(call cc-option,$(CC),-Wtype-limits,) \
-ffunction-sections -fdata-sections
CFLAGS-y += -flto -fwhole-program

LDFLAGS-y := -Wl,--gc-sections

CPPFLAGS = -P -MD -MT $@

CFLAGS = $(CFLAGS-y)
LDFLAGS = $(LDFLAGS-y)

# Default targets
target-y := $(OUT)klipper.elf

all:

# Run with "make V=1" to see the actual compile commands
ifdef V
Q=
else
Q=@
MAKEFLAGS += --no-print-directory
endif

# Include board specific makefile
-include src/$(patsubst "%",%,$(CONFIG_BOARD_DIRECTORY))/Makefile

################ Common build rules

$(OUT)%.o: %.c $(OUT)autoconf.h $(OUT)board-link
@echo " Compiling $@"
$(Q)$(CC) $(CFLAGS) -c $< -o $@

################ Main build rules

$(OUT)board-link: $(KCONFIG_CONFIG)
@echo " Creating symbolic link $(OUT)board"
$(Q)touch $@
$(Q)ln -Tsf $(PWD)/src/$(CONFIG_BOARD_DIRECTORY) $(OUT)board

$(OUT)declfunc.lds: src/declfunc.lds.S
@echo " Precompiling $@"
$(Q)$(CPP) $(CPPFLAGS) -D__ASSEMBLY__ $< -o $@

$(OUT)klipper.o: $(patsubst %.c, $(OUT)src/%.o,$(src-y)) $(OUT)declfunc.lds
@echo " Linking $@"
$(Q)$(CC) $(CFLAGS) -Wl,-r -Wl,-T,$(OUT)declfunc.lds -nostdlib $(patsubst %.c, $(OUT)src/%.o,$(src-y)) -o $@

$(OUT)compile_time_request.o: $(OUT)klipper.o ./scripts/buildcommands.py
@echo " Building $@"
$(Q)$(OBJCOPY) -j '.compile_time_request' -O binary $< $(OUT)klipper.o.compile_time_request
$(Q)$(PYTHON) ./scripts/buildcommands.py $(OUT)klipper.o.compile_time_request $(OUT)autoconf.h $(OUT)compile_time_request.c
$(Q)$(CC) $(CFLAGS) -c $(OUT)compile_time_request.c -o $@

$(OUT)klipper.elf: $(OUT)klipper.o $(OUT)compile_time_request.o
@echo " Linking $@"
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@

################ Kconfig rules

define do-kconfig
$(Q)mkdir -p $(OUT)/scripts/kconfig/lxdialog
$(Q)mkdir -p $(OUT)/include/config
$(Q)mkdir -p $(addprefix $(OUT), $(DIRS))
$(Q)$(MAKE) -C $(OUT) -f $(CURDIR)/scripts/kconfig/Makefile srctree=$(CURDIR) src=scripts/kconfig obj=scripts/kconfig Q=$(Q) Kconfig=$(CURDIR)/src/Kconfig $1
endef

$(OUT)autoconf.h : $(KCONFIG_CONFIG) ; $(call do-kconfig, silentoldconfig)
$(KCONFIG_CONFIG): src/Kconfig ; $(call do-kconfig, olddefconfig)
%onfig: ; $(call do-kconfig, $@)
help: ; $(call do-kconfig, $@)


################ Generic rules

# Make definitions
.PHONY : all clean distclean FORCE
.DELETE_ON_ERROR:

all: $(target-y)

clean:
$(Q)rm -rf $(OUT)

distclean: clean
$(Q)rm -f .config .config.old

-include $(patsubst %,$(OUT)%/*.d,$(DIRS))
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Welcome to the Klipper project!

This project implements a 3d-printer firmware. There are two parts to
this firmware - code that runs on a micro-controller and code that
runs on a host machine. The host software does the work to build a
schedule of events, while the micro-controller software does the work
to execute the provided schedule at the specified times.

Please see the [documentation](docs/Overview.md) for more information
on running and working with Klipper.

License
=======

Klipper 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.

Klipper 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 Klipper. If not, see <http://www.gnu.org/licenses/>.
83 changes: 83 additions & 0 deletions config/avrsim.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Support for internal testing with the "simulavr" program. To use
# this config, compile the firmware for an AVR atmega644p, disable the
# AVR watchdog timer, set the MCU frequency to 20000000, and set the
# serial baud rate to 115200.

[stepper_x]
# Pins: PA5, PA4, PA1
step_pin: ar29
dir_pin: ar28
enable_pin: ar25
step_distance: .0225
max_velocity: 500
max_accel: 3000
endstop_pin: ^!ar0
position_min: -0.25
position_endstop: 0
position_max: 200

[stepper_y]
# Pins: PA3, PA2
step_pin: ar27
dir_pin: ar26
enable_pin: ar25
step_distance: .0225
max_velocity: 500
max_accel: 3000
endstop_pin: ^!ar1
position_min: -0.25
position_endstop: 0
position_max: 200

[stepper_z]
# Pins: PC7, PC6
step_pin: ar23
dir_pin: ar22
enable_pin: ar25
step_distance: .005
max_velocity: 250
max_accel: 30
endstop_pin: ^!ar2
position_min: 0.1
position_endstop: 0.5
position_max: 200

[stepper_e]
# Pins: PC3, PC2
step_pin: ar19
dir_pin: ar18
enable_pin: ar25
step_distance: .004242
max_velocity: 200000
max_accel: 3000

[heater_nozzle]
heater_pin: ar4
thermistor_pin: analog1
thermistor_type: EPCOS 100K B57560G104F
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 210

[heater_bed]
heater_pin: ar3
thermistor_pin: analog0
thermistor_type: EPCOS 100K B57560G104F
control: watermark
min_temp: 0
max_temp: 110

[fan]
pin: ar14
hard_pwm: 1

[mcu]
serial: /tmp/pseudoserial
baud: 115200
pin_map: arduino

[printer]
kinematics: cartesian
Loading

0 comments on commit f582a36

Please sign in to comment.