Skip to content

Commit

Permalink
Merge pull request #30 from Tritol-travis/master
Browse files Browse the repository at this point in the history
Rewritten CW1 firmware
  • Loading branch information
tritol authored Jul 20, 2020
2 parents 82a3718 + e914a59 commit d609c2d
Show file tree
Hide file tree
Showing 128 changed files with 5,771 additions and 9,654 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_size = 4
indent_style = tab
charset = utf-8
trim_trailing_whitespace = true
max_line_length = null
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
build-env
build
doc
tags
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
dist: trusty
before_install:
- sudo apt-get install -y ninja-build
os: linux
dist: xenial
language: cpp
script:
- git fetch --unshallow || if [ $? -eq 128 ]; then true; else false; fi
- git rev-list --count HEAD
- bash -x build.sh
deploy:
provider: releases
api_key: $ACCESS_TOKEN
token: $ACCESS_TOKEN
file_glob: true
file:
- ../Prusa-CW-Firmware-build/Prusa-CW-Firmware.hex
- build/Prusa-CW1-Firmware-*.hex
skip_cleanup: true
draft: true
prerelease: true
on:
tags: true
134 changes: 0 additions & 134 deletions CMakeLists.txt

This file was deleted.

8 changes: 4 additions & 4 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "Prusa CW Firmware"
PROJECT_NAME = "Prusa CW1 Firmware"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand All @@ -44,7 +44,7 @@ PROJECT_NUMBER =
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF = Original Prusa Curing and Washing machine firmware
PROJECT_BRIEF = "Original Prusa Curing and Washing machine firmware"

# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Expand All @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = Doc
OUTPUT_DIRECTORY = doc

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -873,7 +873,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE =
EXCLUDE = build

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down
122 changes: 122 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
PROJECT = Prusa-CW1-Firmware
DIRS = lib src
I18N = i18n
LANG = en
BUILD_DIR = build

CC = avr-gcc
CPP = avr-g++
OBJCOPY = avr-objcopy

CSTANDARD = -std=gnu11
CPPSTANDARD = -std=gnu++17

WARN = -Wall -Wextra
CPPTUNING = -fno-exceptions -fno-threadsafe-statics
OPT = -g -Os -ffunction-sections -fdata-sections -flto -fno-fat-lto-objects -funsigned-char -funsigned-bitfields -fshort-enums -fno-inline-small-functions -mcall-prologues -fno-split-wide-types
MCU = -mmcu=atmega32u4

DEFS = -DF_CPU=16000000 -DARDUINO=10805 -DUSB_VID=0x2c99 -DUSB_PID=0x0008 -DUSB_MANUFACTURER='"Prusa Research prusa3d.com"' -DUSB_PRODUCT='"Original Prusa CW1"'
INCLUDE = $(foreach dir, ${DIRS}, -I${dir}) -I${BUILD_DIR}

CFLAGS = ${OPT} ${WARN} ${CSTANDARD} ${MCU} ${INCLUDE} ${DEFS}
CPPFLAGS = ${OPT} ${WARN} ${CPPSTANDARD} ${CPPTUNING} ${MCU} ${INCLUDE} ${DEFS}
LINKFLAGS = -fuse-linker-plugin -Wl,--relax,--gc-sections,--defsym=__TEXT_REGION_LENGTH__=28k

CSRCS = $(foreach dir, ${DIRS}, $(wildcard ${dir}/*.c))
CPPSRCS = $(foreach dir, ${DIRS}, $(wildcard ${dir}/*.cpp))
OBJS = $(addprefix $(BUILD_DIR)/, $(patsubst %.c, %.o, $(CSRCS))) $(addprefix $(BUILD_DIR)/, $(patsubst %.cpp, %.o, $(CPPSRCS)))
DEPS = $(addprefix $(BUILD_DIR)/, $(patsubst %.c, %.d, $(CSRCS))) $(addprefix $(BUILD_DIR)/, $(patsubst %.cpp, %.dd, $(CPPSRCS)))
VERSION = $(shell git describe --abbrev=0 --tags)
VERSION_FILE = ${BUILD_DIR}/version.h
LANG_TEMPLATE = ${I18N}/${PROJECT}-${VERSION}.pot

default: DEFS += -DSERIAL_COM_DEBUG
default: $(addprefix $(BUILD_DIR)/, ${PROJECT}-${LANG}-devel.hex)

dist: $(addprefix $(BUILD_DIR)/, ${PROJECT}-${LANG}-${VERSION}.hex)

.PHONY: clean distclean lang_extract default dist ${VERSION_FILE}.tmp doc

.SECONDARY:

.SECONDEXPANSION:

$(BUILD_DIR)/.:
@mkdir -p $@

$(BUILD_DIR)%/.:
@mkdir -p $@

$(BUILD_DIR)/%.hex: ${BUILD_DIR}/%.elf
${OBJCOPY} -O ihex -R .eeprom $< $@.tmp
@echo "; device = cw1" > $@
@echo >> $@
cat $@.tmp >> $@
rm $@.tmp

$(BUILD_DIR)/%.elf: ${OBJS}
@echo "LINK $@"
@${CPP} ${CPPFLAGS} ${LINKFLAGS},-Map=${@:%.elf=%.map} $^ -o $@

$(BUILD_DIR)/%.o: %.c | $${@D}/.
@echo "CC $<"
@${CC} ${CFLAGS} -c $< -o $@

$(BUILD_DIR)/%.o: %.cpp | $${@D}/.
@echo "CPP $<"
@${CPP} ${CPPFLAGS} -c $< -o $@

$(VERSION_FILE): ${VERSION_FILE}.tmp
@if ! cmp -s $< $@; then cp $< $@; fi

$(VERSION_FILE).tmp: ${BUILD_DIR}/${LANG}.h | $${@D}/.
@echo "#pragma once" > $@
@echo -n "#define FW_LOCAL_CHANGES " >> $@
@git diff-index --quiet HEAD -- && echo 0 >> $@ || echo 1 >> $@
@echo -n "#define FW_BUILDNR " >> $@
@echo "\"`git rev-list --count HEAD`\"" >> $@
@echo -n "#define FW_HASH " >> $@
@echo "\"`git rev-parse --short=18 HEAD`\"" >> $@
@echo -n "#define FW_VERSION " >> $@
@echo "\"${VERSION}\"" >> $@
@echo -n "#include " >> $@
@echo "\"${LANG}.h\"" >> $@

clean:
rm -f $(foreach dir, ${DIRS}, $(wildcard ${BUILD_DIR}/${dir}/*.o)) $(foreach dir, ${DIRS}, $(wildcard ${BUILD_DIR}/${dir}/*.d*)) ${BUILD_DIR}/*.h $(VERSION_FILE).tmp ${BUILD_DIR}/*.sed

distclean: clean
rm -rf ${BUILD_DIR}/*.hex ${BUILD_DIR}/*.elf ${BUILD_DIR}/*.map ${I18N}/*.pot tags doc

lang_extract: ${LANG_TEMPLATE}

$(LANG_TEMPLATE): ${I18N}/en.h
touch $@
xgettext --join-existing --sort-output --keyword=_ --output=$@ $?

$(BUILD_DIR)/%.sed: ${I18N}/%.po
msgconv --stringtable-output $< |grep -E '".+" ='|sed 's/"\(.*\)" = "\(.*\)";/s~"\1"~"\2"~/'|sed 's~\[~\\\[~g;s~\]~\\\]~g' > $@

$(BUILD_DIR)/en.h: ${I18N}/en.h
cp $< $@

$(BUILD_DIR)/%.h: ${BUILD_DIR}/%.sed
sed -f $< ${I18N}/en.h > $@

tags: ${CSRCS} ${CPPSRCS} $(wildcard ${I18N}/*.h)
arduino-ctags $^

doc:
doxygen


$(BUILD_DIR)/%.d: %.c ${VERSION_FILE} Makefile | $${@D}/.
@echo "deps $<"
@${CC} ${CFLAGS} $< -MM -MT ${@:.d=.o} >$@

$(BUILD_DIR)/%.dd: %.cpp ${VERSION_FILE} Makefile | $${@D}/.
@echo "deps $<"
@${CPP} ${CPPFLAGS} $< -MM -MT ${@:.dd=.o} >$@

-include ${DEPS}
2 changes: 0 additions & 2 deletions Prusa-CW-Firmware.hex.in

This file was deleted.

Loading

0 comments on commit d609c2d

Please sign in to comment.