diff --git a/Makefile b/Makefile index 71008ed..ea0c492 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,6 @@ firmware-build: firmware/*.mk firmware/**/*.c firmware/**/*.h firmware/**/**/*.r cd firmware && $(MAKE) -f ansible.mk firmware-clean: - rm -rfv firmware/build rm -fv res/firmware/*.dll rm -fv res/firmware/*.dylib rm -fv res/firmware/*.so diff --git a/firmware/common.mk b/firmware/common.mk index bc22d1b..60a9536 100644 --- a/firmware/common.mk +++ b/firmware/common.mk @@ -2,6 +2,7 @@ SHELL := /bin/bash -O extglob RACK_DIR ?= ../../.. TARGET_DIR := ../res/firmware/ +BUILD_DIR := ../build/firmware/$(TARGET_NAME) FLAGS += \ -DDEBUG \ @@ -33,7 +34,7 @@ ifeq ($(ARCH_WIN), 1) TARGET = $(TARGET_DIR)$(TARGET_NAME).dll endif -include $(RACK_DIR)/compile.mk +include compile.mk all: $(TARGET) diff --git a/firmware/compile.mk b/firmware/compile.mk new file mode 100644 index 0000000..3b19f4f --- /dev/null +++ b/firmware/compile.mk @@ -0,0 +1,114 @@ +# Rack SDK compile.mk modified to support configurable build products folder + +ifndef RACK_DIR +$(error RACK_DIR is not defined) +endif + +include $(RACK_DIR)/arch.mk + +BUILD_DIR ?= build +OBJCOPY ?= objcopy +STRIP ?= strip +INSTALL_NAME_TOOL ?= install_name_tool +OTOOL ?= otool + +# Generate dependency files alongside the object files +FLAGS += -MMD -MP +# Debugger symbols. These are removed with `strip`. +FLAGS += -g +# Optimization +FLAGS += -O3 -funsafe-math-optimizations -fno-omit-frame-pointer +# Warnings +FLAGS += -Wall -Wextra -Wno-unused-parameter +# C++ standard +CXXFLAGS += -std=c++11 + +# Define compiler/linker target if cross-compiling +ifdef CROSS_COMPILE + FLAGS += --target=$(MACHINE) + LDFLAGS += --target=$(MACHINE) +endif + +# Architecture-independent flags +ifdef ARCH_X64 + FLAGS += -DARCH_X64 + FLAGS += -march=nehalem +endif +ifdef ARCH_ARM64 + FLAGS += -DARCH_ARM64 + FLAGS += -march=armv8-a+fp+simd +endif + +ifdef ARCH_LIN + FLAGS += -DARCH_LIN + CXXFLAGS += -Wsuggest-override +endif +ifdef ARCH_MAC + FLAGS += -DARCH_MAC + CXXFLAGS += -stdlib=libc++ + LDFLAGS += -stdlib=libc++ + MAC_SDK_FLAGS := -mmacosx-version-min=10.9 + FLAGS += $(MAC_SDK_FLAGS) + LDFLAGS += $(MAC_SDK_FLAGS) +endif +ifdef ARCH_WIN + FLAGS += -DARCH_WIN + FLAGS += -D_USE_MATH_DEFINES + FLAGS += -municode + CXXFLAGS += -Wsuggest-override +endif + +# Allow *appending* rather than prepending to common flags. +# This is useful to force-redefine compiler settings instead of merely setting defaults that may be overwritten. +FLAGS += $(EXTRA_FLAGS) +CFLAGS += $(EXTRA_CFLAGS) +CXXFLAGS += $(EXTRA_CXXFLAGS) +LDFLAGS += $(EXTRA_LDFLAGS) + +# Apply FLAGS to language-specific flags +CFLAGS += $(FLAGS) +CXXFLAGS += $(FLAGS) + +# Derive object files from sources and place them before user-defined objects +OBJECTS := $(patsubst %, $(BUILD_DIR)/%.o, $(SOURCES)) $(OBJECTS) +OBJECTS += $(patsubst %, $(BUILD_DIR)/%.bin.o, $(BINARIES)) +DEPENDENCIES := $(patsubst %, $(BUILD_DIR)/%.d, $(SOURCES)) + +# Final targets + +$(TARGET): $(OBJECTS) + $(CXX) -o $@ $^ $(LDFLAGS) + +-include $(DEPENDENCIES) + +$(BUILD_DIR)/%.c.o: %.c + @mkdir -p $(@D) + $(CC) $(CFLAGS) -c -o $@ $< + +$(BUILD_DIR)/%.cpp.o: %.cpp + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) -c -o $@ $< + +$(BUILD_DIR)/%.cc.o: %.cc + @mkdir -p $(@D) + $(CXX) $(CXXFLAGS) -c -o $@ $< + +$(BUILD_DIR)/%.m.o: %.m + @mkdir -p $(@D) + $(CC) $(CFLAGS) -c -o $@ $< + +$(BUILD_DIR)/%.bin.o: % + @mkdir -p $(@D) +ifdef ARCH_LIN + $(OBJCOPY) -I binary -O elf64-x86-64 -B i386:x86-64 --rename-section .data=.rodata,alloc,load,readonly,data,contents $< $@ +endif +ifdef ARCH_WIN + $(OBJCOPY) -I binary -O pe-x86-64 -B i386:x86-64 --rename-section .data=.rodata,alloc,load,readonly,data,contents $< $@ +endif +ifdef ARCH_MAC + @# Apple makes this needlessly complicated, so just generate a C file with an array. + xxd -i $< | $(CC) $(MAC_SDK_FLAGS) -c -o $@ -xc - +endif + +$(BUILD_DIR)/%.html: %.md + markdown $< > $@ diff --git a/firmware/mock_hardware/modules/teletype/adapter_teletype.c b/firmware/mock_hardware/modules/teletype/adapter_teletype.c index f06a80e..a8bc4b8 100644 --- a/firmware/mock_hardware/modules/teletype/adapter_teletype.c +++ b/firmware/mock_hardware/modules/teletype/adapter_teletype.c @@ -8,7 +8,7 @@ #include "module/globals.h" #include "module/live_mode.h" #include "module/preset_w_mode.h" -#include "src/serialize.h" +#include "src/scene_serialization.h" #include "src/teletype_io.h" #include "types.h" @@ -62,8 +62,16 @@ void fake_flash_read(scene_state_t* src_scene, scene_state_t* dest_scene, uint8_t init_i2c_op_address) { memcpy(ss_scripts_ptr(dest_scene), ss_scripts_ptr(src_scene), + +// handle difference in macros between TT 5 and 4 +#ifdef EDITABLE_SCRIPT_COUNT + ss_scripts_size(EDITABLE_SCRIPT_COUNT) +#else // Exclude size of TEMP script as above - ss_scripts_size() - sizeof(scene_script_t)); + ss_scripts_size() - sizeof(scene_script_t) +#endif + + ); if (init_pattern) { @@ -77,7 +85,13 @@ void fake_flash_read(scene_state_t* src_scene, scene_state_t* dest_scene, memcpy(dest_text, src_text, SCENE_TEXT_LINES * SCENE_TEXT_CHARS); // need to reset timestamps uint32_t ticks = tele_get_ticks(); + +// handle difference in macros between TT 5 and 4 +#ifdef TOTAL_SCRIPT_COUNT + for (size_t i = 0; i < TOTAL_SCRIPT_COUNT; i++) +#else for (size_t i = 0; i < TEMP_SCRIPT; i++) +#endif dest_scene->scripts[i].last_time = ticks; dest_scene->variables.time = 0; diff --git a/firmware/teletype4 b/firmware/teletype4 index 407c6e7..a34da87 160000 --- a/firmware/teletype4 +++ b/firmware/teletype4 @@ -1 +1 @@ -Subproject commit 407c6e720ad2b080917f266c98996014e1671d36 +Subproject commit a34da87afb779b993cd0a6bce4e6102cd35c4a95