diff --git a/scripts/gen_target.sh b/scripts/gen_target.sh index 93c154857..dd9924cbe 100755 --- a/scripts/gen_target.sh +++ b/scripts/gen_target.sh @@ -5,7 +5,7 @@ GEN_DIR=$2 YAML_PARSER="dasel -n -p yaml --plain -f" TARGET_NAME=$(basename "$YAML_FILE" .yml) OUT_HEADER="$GEN_DIR"/Target.h -OUT_MAKEFILE="$GEN_DIR"/Defines.mk +OUT_MAKEFILE="$GEN_DIR"/Makefile #generated header contains cpp code #generate USB names in dedicated header since this one is included in .c files diff --git a/src/Defines.mk b/src/Defines.mk index 4eaf99757..e8962df0b 100644 --- a/src/Defines.mk +++ b/src/Defines.mk @@ -1,3 +1,7 @@ +SW_VERSION_MAJOR := $(shell git describe --tags --abbrev=0 | cut -c 2- | cut -d. -f1) +SW_VERSION_MINOR := $(shell git describe --tags --abbrev=0 | cut -c 2- | cut -d. -f2) +SW_VERSION_REVISION := $(shell git describe --tags --abbrev=0 | cut -c 2- | cut -d. -f3) + GEN_DIR_BASE := board/gen GEN_DIR_TARGET_BASE := $(GEN_DIR_BASE)/target GEN_DIR_MCU_BASE := $(GEN_DIR_BASE)/mcu @@ -5,6 +9,16 @@ GEN_DIR_VENDOR_BASE := $(GEN_DIR_BASE)/vendor GEN_DIR_ARCH_BASE := $(GEN_DIR_BASE)/arch GEN_DIR_TARGET := $(GEN_DIR_TARGET_BASE)/$(TARGET) GEN_DIR_TSCREEN_BASE := application/io/touchscreen/gen + +-include $(MAKEFILE_INCLUDE_PREFIX)$(GEN_DIR_TARGET)/Makefile + +#these makefiles are specific only to firmware, which is why they don't have MAKEFILE_INCLUDE_PREFIX +#the prefix is used to specify the directory of main, target makefile +#needed for tests since they are outside of src/ +-include board/arch/$(ARCH)/$(VENDOR)/Makefile +-include board/arch/$(ARCH)/$(VENDOR)/variants/$(MCU_FAMILY)/$(MCU)/Makefile +-include board/arch/$(ARCH)/Makefile + COMMAND_FW_UPDATE_START := 0x4F70456E6E45704F COMMAND_FW_UPDATE_END := 0x4465436B SYSEX_MANUFACTURER_ID_0 := 0x00 @@ -14,13 +28,14 @@ FW_METADATA_SIZE := 4 UART_BAUDRATE_MIDI_STD := 31250 UART_BAUDRATE_USB := 38400 UART_BAUDRATE_TOUCHSCREEN := 38400 -USB_OVER_SERIAL_BUFFER_SIZE := 16 -I2C_TX_BUFFER_SIZE := 64 ESTA_ID := 0x6555 -SW_VERSION_MAJOR := $(shell git describe --tags --abbrev=0 | cut -c 2- | cut -d. -f1) -SW_VERSION_MINOR := $(shell git describe --tags --abbrev=0 | cut -c 2- | cut -d. -f2) -SW_VERSION_REVISION := $(shell git describe --tags --abbrev=0 | cut -c 2- | cut -d. -f3) +#these can be overriden by target/vendor/arch/mcu etc. +USB_OVER_SERIAL_BUFFER_SIZE ?= 16 +I2C_TX_BUFFER_SIZE ?= 64 +UART_TX_BUFFER_SIZE ?= 128 +UART_RX_BUFFER_SIZE ?= 128 +MIDI_SYSEX_ARRAY_SIZE ?= 100 DEFINES += \ UART_BAUDRATE_MIDI_STD=$(UART_BAUDRATE_MIDI_STD) \ @@ -29,6 +44,7 @@ UART_BAUDRATE_TOUCHSCREEN=$(UART_BAUDRATE_TOUCHSCREEN) \ USB_OVER_SERIAL_BUFFER_SIZE=$(USB_OVER_SERIAL_BUFFER_SIZE) \ TSCREEN_CDC_PASSTHROUGH_BUFFER_SIZE=$(USB_OVER_SERIAL_BUFFER_SIZE) \ I2C_TX_BUFFER_SIZE=$(I2C_TX_BUFFER_SIZE) \ +MIDI_SYSEX_ARRAY_SIZE=$(MIDI_SYSEX_ARRAY_SIZE) \ FIXED_NUM_CONFIGURATIONS=1 \ SYSEX_MANUFACTURER_ID_0=$(SYSEX_MANUFACTURER_ID_0) \ SYSEX_MANUFACTURER_ID_1=$(SYSEX_MANUFACTURER_ID_1) \ @@ -44,30 +60,8 @@ ifeq ($(DEBUG), 1) DEFINES += DEBUG endif --include $(MAKEFILE_INCLUDE_PREFIX)$(GEN_DIR_TARGET)/Defines.mk - -ifneq (,$(findstring USB_LINK_MCU,$(DEFINES))) - ifeq ($(MCU), atmega16u2) - ifeq ($(TYPE),boot) - #save flash - this feature doesn't fit into 4k - DEFINES := $(filter-out LED_INDICATORS_CTL,$(DEFINES)) - DEFINES += UART_TX_BUFFER_SIZE=32 - DEFINES += UART_RX_BUFFER_SIZE=32 - else ifeq ($(TYPE),app) - DEFINES += UART_TX_BUFFER_SIZE=64 - DEFINES += UART_RX_BUFFER_SIZE=64 - endif - endif -else - DEFINES += UART_TX_BUFFER_SIZE=128 - DEFINES += UART_RX_BUFFER_SIZE=128 - DEFINES += MIDI_SYSEX_ARRAY_SIZE=100 -endif - -ifeq ($(CPU),cortex-m4) - DEFINES += \ - CORE_ARM_M4 -endif +DEFINES += UART_TX_BUFFER_SIZE=$(UART_TX_BUFFER_SIZE) +DEFINES += UART_RX_BUFFER_SIZE=$(UART_RX_BUFFER_SIZE) ifeq ($(TYPE),boot) DEFINES += FW_BOOT diff --git a/src/Sources.mk b/src/Sources.mk index 75ea956fa..35d1012c5 100644 --- a/src/Sources.mk +++ b/src/Sources.mk @@ -2,34 +2,17 @@ vpath modules/%.cpp ../ vpath modules/%.c ../ #common include dirs -INCLUDE_DIRS := \ +INCLUDE_DIRS += \ -I"../modules/" \ -I"$(GEN_DIR_MCU_BASE)/$(MCU)" \ -I"$(GEN_DIR_TARGET)/" \ -I"application/" \ +-I"bootloader/" \ -I"board/arch/$(ARCH)/$(VENDOR)/variants/$(MCU_FAMILY)" \ -I"board/arch/$(ARCH)/$(VENDOR)" \ -I"board/common" \ -I"./" -ifeq (,$(findstring gen,$(TYPE))) - ifeq ($(VENDOR), atmel) - INCLUDE_DIRS += \ - -I"../modules/lufa/" \ - -I"../modules/avr-libstdcpp/include" - else ifeq ($(VENDOR),st) - INCLUDE_DIRS += \ - $(addprefix -I,$(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/common -type d -not -path "*Src*")) \ - $(addprefix -I,$(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/$(MCU_FAMILY)/common -type d -not -path "*Src*")) \ - $(addprefix -I,$(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/$(MCU_FAMILY)/$(MCU_BASE)/Drivers -type d -not -path "*Src*")) - endif - - ifeq ($(TYPE),boot) - INCLUDE_DIRS += \ - -I"bootloader/" - endif -endif - LINKER_FILE := $(MCU_DIR)/$(MCU).ld TARGET_GEN_HEADER := $(GEN_DIR_TARGET)/Target.h @@ -40,52 +23,6 @@ endif ifeq (,$(findstring gen,$(TYPE))) SOURCES += $(TSCREEN_GEN_SOURCE) - #arch specific - ifeq ($(ARCH),avr) - ifneq (,$(findstring USB_SUPPORTED,$(DEFINES))) - #common for bootloader and application - SOURCES += \ - modules/lufa/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c \ - modules/lufa/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c \ - modules/lufa/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c \ - modules/lufa/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c \ - modules/lufa/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c \ - modules/lufa/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c \ - modules/lufa/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c \ - modules/lufa/LUFA/Drivers/USB/Core/ConfigDescriptors.c \ - modules/lufa/LUFA/Drivers/USB/Core/DeviceStandardReq.c \ - modules/lufa/LUFA/Drivers/USB/Core/Events.c \ - modules/lufa/LUFA/Drivers/USB/Core/USBTask.c \ - modules/lufa/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c \ - modules/lufa/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c \ - modules/lufa/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c - endif - else ifeq ($(ARCH),arm) - SOURCES += modules/EmuEEPROM/src/EmuEEPROM.cpp - - #clang-specific defines - ifneq (,$(findstring clang,$(CC_ARM))) - TOOLCHAIN_DIR := $(shell dirname $(shell which arm-none-eabi-gcc) | rev | cut -c5- | rev) - CPP_VER := $(shell $(FIND) $(TOOLCHAIN_DIR)/arm-none-eabi/include/c++ -mindepth 1 -maxdepth 1 | rev | cut -d/ -f 1 | rev) - - INCLUDE_DIRS += \ - -isystem"$(TOOLCHAIN_DIR)/lib/gcc/arm-none-eabi/$(CPP_VER)/include" \ - -isystem"$(TOOLCHAIN_DIR)/lib/gcc/arm-none-eabi/$(CPP_VER)/include-fixed" \ - -isystem"$(TOOLCHAIN_DIR)/arm-none-eabi/include/c++/$(CPP_VER)" \ - -isystem"$(TOOLCHAIN_DIR)/arm-none-eabi/include/c++/$(CPP_VER)/arm-none-eabi" \ - -isystem"$(TOOLCHAIN_DIR)/arm-none-eabi/include/c++/$(CPP_VER)/backward" \ - -isystem"$(TOOLCHAIN_DIR)/arm-none-eabi/include" - endif - endif - - #vendor specific - ifeq ($(VENDOR),st) - SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/common -regex '.*\.\(s\|c\)') - SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/$(MCU_FAMILY)/common -regex '.*\.\(s\|c\)') - SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/$(MCU_FAMILY)/$(MCU_BASE) -regex '.*\.\(s\|c\)') - SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/variants/$(MCU_FAMILY) -maxdepth 1 -name "*.cpp") - endif - SOURCES += $(shell $(FIND) ./board/common -maxdepth 1 -type f -name "*.cpp") SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/common/ -type f -name "*.cpp") SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/common/ -type f -name "*.cpp") diff --git a/src/board/arch/arm/Makefile b/src/board/arch/arm/Makefile new file mode 100644 index 000000000..865eacad5 --- /dev/null +++ b/src/board/arch/arm/Makefile @@ -0,0 +1,22 @@ +ifeq (,$(findstring gen,$(TYPE))) + SOURCES += modules/EmuEEPROM/src/EmuEEPROM.cpp + + #clang-specific defines + ifneq (,$(findstring clang,$(CC_ARM))) + TOOLCHAIN_DIR := $(shell dirname $(shell which arm-none-eabi-gcc) | rev | cut -c5- | rev) + CPP_VER := $(shell $(FIND) $(TOOLCHAIN_DIR)/arm-none-eabi/include/c++ -mindepth 1 -maxdepth 1 | rev | cut -d/ -f 1 | rev) + + INCLUDE_DIRS += \ + -isystem"$(TOOLCHAIN_DIR)/lib/gcc/arm-none-eabi/$(CPP_VER)/include" \ + -isystem"$(TOOLCHAIN_DIR)/lib/gcc/arm-none-eabi/$(CPP_VER)/include-fixed" \ + -isystem"$(TOOLCHAIN_DIR)/arm-none-eabi/include/c++/$(CPP_VER)" \ + -isystem"$(TOOLCHAIN_DIR)/arm-none-eabi/include/c++/$(CPP_VER)/arm-none-eabi" \ + -isystem"$(TOOLCHAIN_DIR)/arm-none-eabi/include/c++/$(CPP_VER)/backward" \ + -isystem"$(TOOLCHAIN_DIR)/arm-none-eabi/include" + endif +endif + +ifeq ($(CPU),cortex-m4) + DEFINES += \ + CORE_ARM_M4 +endif \ No newline at end of file diff --git a/src/board/arch/arm/st/Makefile b/src/board/arch/arm/st/Makefile new file mode 100644 index 000000000..30a9d030f --- /dev/null +++ b/src/board/arch/arm/st/Makefile @@ -0,0 +1,11 @@ +ifeq (,$(findstring gen,$(TYPE))) + INCLUDE_DIRS += \ + $(addprefix -I,$(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/common -type d -not -path "*Src*")) \ + $(addprefix -I,$(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/$(MCU_FAMILY)/common -type d -not -path "*Src*")) \ + $(addprefix -I,$(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/$(MCU_FAMILY)/$(MCU_BASE)/Drivers -type d -not -path "*Src*")) + + SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/common -regex '.*\.\(s\|c\)') + SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/$(MCU_FAMILY)/common -regex '.*\.\(s\|c\)') + SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/gen/$(MCU_FAMILY)/$(MCU_BASE) -regex '.*\.\(s\|c\)') + SOURCES += $(shell $(FIND) ./board/arch/$(ARCH)/$(VENDOR)/variants/$(MCU_FAMILY) -maxdepth 1 -name "*.cpp") +endif \ No newline at end of file diff --git a/src/board/arch/avr/Makefile b/src/board/arch/avr/Makefile new file mode 100644 index 000000000..c63aab04a --- /dev/null +++ b/src/board/arch/avr/Makefile @@ -0,0 +1,24 @@ +ifeq (,$(findstring gen,$(TYPE))) + INCLUDE_DIRS += \ + -I"../modules/lufa/" \ + -I"../modules/avr-libstdcpp/include" + + ifneq (,$(findstring USB_SUPPORTED,$(DEFINES))) + #common for bootloader and application + SOURCES += \ + modules/lufa/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c \ + modules/lufa/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c \ + modules/lufa/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c \ + modules/lufa/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c \ + modules/lufa/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c \ + modules/lufa/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c \ + modules/lufa/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c \ + modules/lufa/LUFA/Drivers/USB/Core/ConfigDescriptors.c \ + modules/lufa/LUFA/Drivers/USB/Core/DeviceStandardReq.c \ + modules/lufa/LUFA/Drivers/USB/Core/Events.c \ + modules/lufa/LUFA/Drivers/USB/Core/USBTask.c \ + modules/lufa/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c \ + modules/lufa/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c \ + modules/lufa/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c + endif +endif \ No newline at end of file diff --git a/src/board/arch/avr/atmel/variants/avr8/atmega16u2/Makefile b/src/board/arch/avr/atmel/variants/avr8/atmega16u2/Makefile new file mode 100644 index 000000000..4cff6c9e1 --- /dev/null +++ b/src/board/arch/avr/atmel/variants/avr8/atmega16u2/Makefile @@ -0,0 +1,9 @@ +ifeq ($(TYPE),boot) + #save flash - this feature doesn't fit into 4k + DEFINES := $(filter-out LED_INDICATORS_CTL,$(DEFINES)) + UART_TX_BUFFER_SIZE := 32 + UART_RX_BUFFER_SIZE := 32 +else ifeq ($(TYPE),app) + UART_TX_BUFFER_SIZE := 64 + UART_RX_BUFFER_SIZE := 64 +endif \ No newline at end of file