mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
add make.mk and rules.mk to help new makefile example
This commit is contained in:
parent
4d29decafc
commit
0f3da42db8
@ -1,185 +1,15 @@
|
||||
include ../../../tools/top.mk
|
||||
include ../../make.mk
|
||||
|
||||
# Select the board to build for.
|
||||
ifeq ($(BOARD),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD=')
|
||||
$(info Possible values are:)
|
||||
$(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.)))))
|
||||
$(error BOARD not defined)
|
||||
else
|
||||
ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
|
||||
$(error Invalid BOARD specified)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
|
||||
ifeq ("$(V)","2")
|
||||
QUIET =
|
||||
else
|
||||
QUIET = @
|
||||
endif
|
||||
|
||||
# If the build directory is not given, make it reflect the board name.
|
||||
BUILD ?= build-$(BOARD)
|
||||
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
||||
include $(TOP)/hw/bsp/$(BOARD)/board.mk
|
||||
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
MKDIR = mkdir
|
||||
SED = sed
|
||||
CP = cp
|
||||
RM = rm
|
||||
|
||||
INC += -Isrc \
|
||||
-I$(TOP)/hw \
|
||||
-I$(TOP)/src
|
||||
|
||||
CFLAGS += \
|
||||
-fsingle-precision-constant \
|
||||
-fno-strict-aliasing \
|
||||
-Wdouble-promotion \
|
||||
-Wno-endif-labels \
|
||||
-Wstrict-prototypes \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wnested-externs \
|
||||
-Wunreachable-code \
|
||||
-Wno-error=lto-type-mismatch \
|
||||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
# This causes lots of warning with nrf5x build due to nrfx code
|
||||
# CFLAGS += -Wcast-align
|
||||
|
||||
#Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -ggdb
|
||||
else
|
||||
CFLAGS += -flto -Os
|
||||
endif
|
||||
|
||||
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
||||
LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nosys.specs -specs=nano.specs
|
||||
|
||||
ifeq ("$(V)","1")
|
||||
$(info CFLAGS $(CFLAGS))
|
||||
$(info )
|
||||
$(info LDFLAGS $(LDFLAGS))
|
||||
$(info )
|
||||
$(info ASFLAGS $(ASFLAGS))
|
||||
$(info )
|
||||
endif
|
||||
|
||||
LIBS = -lgcc -lc -lm -lnosys
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
LIB_SOURCE += \
|
||||
hw/bsp/$(BOARD)/board_$(BOARD).c \
|
||||
src/common/tusb_fifo.c \
|
||||
src/device/usbd.c \
|
||||
src/device/usbd_control.c \
|
||||
src/class/msc/msc_device.c \
|
||||
src/class/cdc/cdc_device.c \
|
||||
src/class/hid/hid_device.c \
|
||||
src/tusb.c \
|
||||
src/portable/$(VENDOR)/$(CHIP_FAMILY)/dcd_$(CHIP_FAMILY).c
|
||||
# Board source
|
||||
SRC_C += hw/bsp/$(BOARD)/board_$(BOARD).c
|
||||
|
||||
SRC_C += $(LIB_SOURCE)
|
||||
|
||||
# Assembly files can be name with upper case .S, convert it to .s
|
||||
SRC_S := $(SRC_S:.S=.s)
|
||||
|
||||
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
|
||||
# assembly file should be placed first in linking order
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=.o))
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o))
|
||||
|
||||
# Set all as default goal
|
||||
.DEFAULT_GOAL := all
|
||||
all: $(BUILD)/$(BOARD)-firmware.bin size
|
||||
|
||||
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
||||
$(OBJ): | $(OBJ_DIRS)
|
||||
$(OBJ_DIRS):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.elf: $(OBJ)
|
||||
@echo LINK $@
|
||||
$(QUIET)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O ihex $^ $@
|
||||
|
||||
# We set vpath to point to the top of the tree so that the source files
|
||||
# can be located. By following this scheme, it allows a single build rule
|
||||
# to be used to compile all .c files.
|
||||
vpath %.c . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.c
|
||||
@echo CC $(notdir $@)
|
||||
$(QUIET)$(CC) $(CFLAGS) -c -MD -o $@ $<
|
||||
@# The following fixes the dependency file.
|
||||
@# See http://make.paulandlesley.org/autodep.html for details.
|
||||
@# Regex adjusted from the above to play better with Windows paths, etc.
|
||||
@$(CP) $(@:.o=.d) $(@:.o=.P); \
|
||||
$(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \
|
||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
|
||||
$(RM) $(@:.o=.d)
|
||||
|
||||
# ASM sources lower case .s
|
||||
vpath %.s . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.s
|
||||
@echo AS $(notdir $@)
|
||||
$(QUIET)$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources upper case .S
|
||||
vpath %.S . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.S
|
||||
@echo AS $(notdir $@)
|
||||
$(QUIET)$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# Flash binary using Jlink, should be added into system path
|
||||
ifeq ($(OS),Windows_NT)
|
||||
JLINKEXE = JLink.exe
|
||||
else
|
||||
JLINKEXE = JLinkExe
|
||||
endif
|
||||
|
||||
# default jlink interface is swd
|
||||
ifeq ($(JLINK_IF),)
|
||||
JLINK_IF = swd
|
||||
endif
|
||||
|
||||
# Flash using jlink
|
||||
flash-jlink: $(BUILD)/$(BOARD)-firmware.hex
|
||||
@echo halt > $(BUILD)/$(BOARD).jlink
|
||||
@echo loadfile $^ >> $(BUILD)/$(BOARD).jlink
|
||||
@echo r >> $(BUILD)/$(BOARD).jlink
|
||||
@echo go >> $(BUILD)/$(BOARD).jlink
|
||||
@echo exit >> $(BUILD)/$(BOARD).jlink
|
||||
$(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -speed auto -CommandFile $(BUILD)/$(BOARD).jlink
|
||||
|
||||
size: $(BUILD)/$(BOARD)-firmware.elf
|
||||
-@echo ''
|
||||
@$(SIZE) $<
|
||||
-@echo ''
|
||||
|
||||
clean:
|
||||
rm -rf build-$(BOARD)
|
||||
include ../../rules.mk
|
||||
|
@ -1,186 +1,15 @@
|
||||
include ../../../tools/top.mk
|
||||
include ../../make.mk
|
||||
|
||||
# Select the board to build for.
|
||||
ifeq ($(BOARD),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD=')
|
||||
$(info Possible values are:)
|
||||
$(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.)))))
|
||||
$(error BOARD not defined)
|
||||
else
|
||||
ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
|
||||
$(error Invalid BOARD specified)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
|
||||
ifeq ("$(V)","2")
|
||||
QUIET =
|
||||
else
|
||||
QUIET = @
|
||||
endif
|
||||
|
||||
# If the build directory is not given, make it reflect the board name.
|
||||
BUILD ?= build-$(BOARD)
|
||||
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
||||
include $(TOP)/hw/bsp/$(BOARD)/board.mk
|
||||
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
MKDIR = mkdir
|
||||
SED = sed
|
||||
CP = cp
|
||||
RM = rm
|
||||
|
||||
INC += -Isrc \
|
||||
-I$(TOP)/hw \
|
||||
-I$(TOP)/src
|
||||
|
||||
CFLAGS += \
|
||||
-fsingle-precision-constant \
|
||||
-fno-strict-aliasing \
|
||||
-Wdouble-promotion \
|
||||
-Wno-endif-labels \
|
||||
-Wstrict-prototypes \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wnested-externs \
|
||||
-Wunreachable-code \
|
||||
-Wno-error=lto-type-mismatch \
|
||||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
# This causes lots of warning with nrf5x build due to nrfx code
|
||||
# CFLAGS += -Wcast-align
|
||||
|
||||
#Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -ggdb
|
||||
else
|
||||
CFLAGS += -flto -Os
|
||||
endif
|
||||
|
||||
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -DBOARD_$(shell echo $(BOARD) | tr '[:lower:]' '[:upper:]')
|
||||
LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nosys.specs -specs=nano.specs
|
||||
|
||||
ifeq ("$(V)","1")
|
||||
$(info CFLAGS $(CFLAGS))
|
||||
$(info )
|
||||
$(info LDFLAGS $(LDFLAGS))
|
||||
$(info )
|
||||
$(info ASFLAGS $(ASFLAGS))
|
||||
$(info )
|
||||
endif
|
||||
|
||||
LIBS = -lgcc -lc -lm -lnosys
|
||||
INC += \
|
||||
src \
|
||||
$(TOP)/hw \
|
||||
|
||||
# Example source
|
||||
EXAMPLE_SOURCE += $(wildcard src/*.c)
|
||||
|
||||
SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
|
||||
|
||||
LIB_SOURCE += \
|
||||
hw/bsp/$(BOARD)/board_$(BOARD).c \
|
||||
src/common/tusb_fifo.c \
|
||||
src/device/usbd.c \
|
||||
src/device/usbd_control.c \
|
||||
src/class/msc/msc_device.c \
|
||||
src/class/cdc/cdc_device.c \
|
||||
src/class/hid/hid_device.c \
|
||||
src/tusb.c \
|
||||
src/portable/$(VENDOR)/$(CHIP_FAMILY)/dcd_$(CHIP_FAMILY).c
|
||||
# Board source
|
||||
SRC_C += hw/bsp/$(BOARD)/board_$(BOARD).c
|
||||
|
||||
SRC_C += $(LIB_SOURCE)
|
||||
|
||||
# Assembly files can be name with upper case .S, convert it to .s
|
||||
SRC_S := $(SRC_S:.S=.s)
|
||||
|
||||
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
|
||||
# assembly file should be placed first in linking order
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=.o))
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o))
|
||||
|
||||
# Set all as default goal
|
||||
.DEFAULT_GOAL := all
|
||||
all: $(BUILD)/$(BOARD)-firmware.bin size
|
||||
|
||||
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
||||
$(OBJ): | $(OBJ_DIRS)
|
||||
$(OBJ_DIRS):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.elf: $(OBJ)
|
||||
@echo LINK $@
|
||||
$(QUIET)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O ihex $^ $@
|
||||
|
||||
# We set vpath to point to the top of the tree so that the source files
|
||||
# can be located. By following this scheme, it allows a single build rule
|
||||
# to be used to compile all .c files.
|
||||
vpath %.c . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.c
|
||||
@echo CC $(notdir $@)
|
||||
$(QUIET)$(CC) $(CFLAGS) -c -MD -o $@ $<
|
||||
@# The following fixes the dependency file.
|
||||
@# See http://make.paulandlesley.org/autodep.html for details.
|
||||
@# Regex adjusted from the above to play better with Windows paths, etc.
|
||||
@$(CP) $(@:.o=.d) $(@:.o=.P); \
|
||||
$(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \
|
||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
|
||||
$(RM) $(@:.o=.d)
|
||||
|
||||
# ASM sources lower case .s
|
||||
vpath %.s . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.s
|
||||
@echo AS $(notdir $@)
|
||||
$(QUIET)$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources upper case .S
|
||||
vpath %.S . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.S
|
||||
@echo AS $(notdir $@)
|
||||
$(QUIET)$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# Flash binary using Jlink, should be added into system path
|
||||
ifeq ($(OS),Windows_NT)
|
||||
JLINKEXE = JLink.exe
|
||||
else
|
||||
JLINKEXE = JLinkExe
|
||||
endif
|
||||
|
||||
# default jlink interface is swd
|
||||
ifeq ($(JLINK_IF),)
|
||||
JLINK_IF = swd
|
||||
endif
|
||||
|
||||
# Flash using jlink
|
||||
flash-jlink: $(BUILD)/$(BOARD)-firmware.hex
|
||||
@echo halt > $(BUILD)/$(BOARD).jlink
|
||||
@echo loadfile $^ >> $(BUILD)/$(BOARD).jlink
|
||||
@echo r >> $(BUILD)/$(BOARD).jlink
|
||||
@echo go >> $(BUILD)/$(BOARD).jlink
|
||||
@echo exit >> $(BUILD)/$(BOARD).jlink
|
||||
$(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -speed auto -CommandFile $(BUILD)/$(BOARD).jlink
|
||||
|
||||
size: $(BUILD)/$(BOARD)-firmware.elf
|
||||
-@echo ''
|
||||
@$(SIZE) $<
|
||||
-@echo ''
|
||||
|
||||
clean:
|
||||
rm -rf build-$(BOARD)
|
||||
include ../../rules.mk
|
||||
|
65
examples/make.mk
Normal file
65
examples/make.mk
Normal file
@ -0,0 +1,65 @@
|
||||
#
|
||||
# Common make definition for all examples
|
||||
#
|
||||
|
||||
# Compiler
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
MKDIR = mkdir
|
||||
SED = sed
|
||||
CP = cp
|
||||
RM = rm
|
||||
|
||||
# Select the board to build for.
|
||||
ifeq ($(BOARD),)
|
||||
$(info You must provide a BOARD parameter with 'BOARD=')
|
||||
$(info Possible values are:)
|
||||
$(info $(sort $(subst /.,,$(subst $(TOP)/hw/bsp/,,$(wildcard $(TOP)/hw/bsp/*/.)))))
|
||||
$(error BOARD not defined)
|
||||
else
|
||||
ifeq ($(wildcard $(TOP)/hw/bsp/$(BOARD)/.),)
|
||||
$(error Invalid BOARD specified)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Build directory
|
||||
BUILD = build-$(BOARD)
|
||||
|
||||
# Board specific
|
||||
include $(TOP)/hw/bsp/$(BOARD)/board.mk
|
||||
|
||||
# Compiler Flags
|
||||
CFLAGS += \
|
||||
-fsingle-precision-constant \
|
||||
-fno-strict-aliasing \
|
||||
-Wdouble-promotion \
|
||||
-Wno-endif-labels \
|
||||
-Wstrict-prototypes \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wfloat-equal \
|
||||
-Wundef \
|
||||
-Wshadow \
|
||||
-Wwrite-strings \
|
||||
-Wsign-compare \
|
||||
-Wmissing-format-attribute \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wnested-externs \
|
||||
-Wunreachable-code \
|
||||
-Wno-error=lto-type-mismatch \
|
||||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
# This causes lots of warning with nrf5x build due to nrfx code
|
||||
# CFLAGS += -Wcast-align
|
||||
|
||||
# Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -ggdb
|
||||
else
|
||||
CFLAGS += -flto -Os
|
||||
endif
|
111
examples/rules.mk
Normal file
111
examples/rules.mk
Normal file
@ -0,0 +1,111 @@
|
||||
#
|
||||
# Common make definition for all examples
|
||||
#
|
||||
|
||||
# libc
|
||||
LIBS = -lgcc -lc -lm -lnosys
|
||||
|
||||
# TinyUSB Stack source
|
||||
SRC_C += \
|
||||
src/common/tusb_fifo.c \
|
||||
src/device/usbd.c \
|
||||
src/device/usbd_control.c \
|
||||
src/class/msc/msc_device.c \
|
||||
src/class/cdc/cdc_device.c \
|
||||
src/class/hid/hid_device.c \
|
||||
src/tusb.c \
|
||||
src/portable/$(VENDOR)/$(CHIP_FAMILY)/dcd_$(CHIP_FAMILY).c
|
||||
|
||||
# TinyUSB stack include
|
||||
INC += $(TOP)/src
|
||||
|
||||
#
|
||||
CFLAGS += $(addprefix -I,$(INC))
|
||||
LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nosys.specs -specs=nano.specs
|
||||
|
||||
# Assembly files can be name with upper case .S, convert it to .s
|
||||
SRC_S := $(SRC_S:.S=.s)
|
||||
|
||||
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
|
||||
# assembly file should be placed first in linking order
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=.o))
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o))
|
||||
|
||||
# Verbose mode
|
||||
ifeq ("$(V)","1")
|
||||
$(info CFLAGS $(CFLAGS) ) $(info )
|
||||
$(info LDFLAGS $(LDFLAGS)) $(info )
|
||||
$(info ASFLAGS $(ASFLAGS)) $(info )
|
||||
endif
|
||||
|
||||
# Set all as default goal
|
||||
.DEFAULT_GOAL := all
|
||||
all: $(BUILD)/$(BOARD)-firmware.bin size
|
||||
|
||||
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
||||
$(OBJ): | $(OBJ_DIRS)
|
||||
$(OBJ_DIRS):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.elf: $(OBJ)
|
||||
@echo LINK $@
|
||||
@$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.bin: $(BUILD)/$(BOARD)-firmware.elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.hex: $(BUILD)/$(BOARD)-firmware.elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O ihex $^ $@
|
||||
|
||||
# We set vpath to point to the top of the tree so that the source files
|
||||
# can be located. By following this scheme, it allows a single build rule
|
||||
# to be used to compile all .c files.
|
||||
vpath %.c . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.c
|
||||
@echo CC $(notdir $@)
|
||||
@$(CC) $(CFLAGS) -c -MD -o $@ $<
|
||||
@# The following fixes the dependency file.
|
||||
@# See http://make.paulandlesley.org/autodep.html for details.
|
||||
@# Regex adjusted from the above to play better with Windows paths, etc.
|
||||
@$(CP) $(@:.o=.d) $(@:.o=.P); \
|
||||
$(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \
|
||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
|
||||
$(RM) $(@:.o=.d)
|
||||
|
||||
# ASM sources lower case .s
|
||||
vpath %.s . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.s
|
||||
@echo AS $(notdir $@)
|
||||
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources upper case .S
|
||||
vpath %.S . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.S
|
||||
@echo AS $(notdir $@)
|
||||
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
size: $(BUILD)/$(BOARD)-firmware.elf
|
||||
-@echo ''
|
||||
@$(SIZE) $<
|
||||
-@echo ''
|
||||
|
||||
clean:
|
||||
rm -rf build-$(BOARD)
|
||||
|
||||
# Flash binary using Jlink
|
||||
ifeq ($(OS),Windows_NT)
|
||||
JLINKEXE = JLink.exe
|
||||
else
|
||||
JLINKEXE = JLinkExe
|
||||
endif
|
||||
|
||||
# Flash using jlink
|
||||
flash-jlink: $(BUILD)/$(BOARD)-firmware.hex
|
||||
@echo halt > $(BUILD)/$(BOARD).jlink
|
||||
@echo loadfile $^ >> $(BUILD)/$(BOARD).jlink
|
||||
@echo r >> $(BUILD)/$(BOARD).jlink
|
||||
@echo go >> $(BUILD)/$(BOARD).jlink
|
||||
@echo exit >> $(BUILD)/$(BOARD).jlink
|
||||
$(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -speed auto -CommandFile $(BUILD)/$(BOARD).jlink
|
@ -23,20 +23,26 @@ SRC_C += \
|
||||
hw/mcu/microchip/samd/asf4/samd21/hal/src/hal_atomic.c
|
||||
|
||||
INC += \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd21/ \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd21/config \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd21/include \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd21/hal/include \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd21/hal/utils/include \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hpl/pm/ \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd21/hpl/port \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd21/hri \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd21/CMSIS/Include
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd21/ \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd21/config \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd21/include \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd21/hal/include \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd21/hal/utils/include \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hpl/pm/ \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd21/hpl/port \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd21/hri \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd21/CMSIS/Include
|
||||
|
||||
# For TinyUSB port source
|
||||
VENDOR = microchip
|
||||
CHIP_FAMILY = samd21
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORT = ARM_CM0
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = ATSAMD21G18
|
||||
JLINK_IF = swd
|
||||
|
||||
# flash using jlink
|
||||
flash: flash-jlink
|
||||
|
@ -25,19 +25,25 @@ SRC_C += \
|
||||
hw/mcu/microchip/samd/asf4/samd51/hal/src/hal_atomic.c
|
||||
|
||||
INC += \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/ \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/config \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/include \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hal/include \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hal/utils/include \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hpl/port \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hri \
|
||||
-I$(TOP)/hw/mcu/microchip/samd/asf4/samd51/CMSIS/Include
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/ \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/config \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/include \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hal/include \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hal/utils/include \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hpl/port \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/hri \
|
||||
$(TOP)/hw/mcu/microchip/samd/asf4/samd51/CMSIS/Include
|
||||
|
||||
# For TinyUSB port source
|
||||
VENDOR = microchip
|
||||
CHIP_FAMILY = samd51
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORT = ARM_CM4F
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = ATSAMD51J19
|
||||
JLINK_IF = swd
|
||||
|
||||
# flash using jlink
|
||||
flash: flash-jlink
|
||||
|
@ -1,11 +1,12 @@
|
||||
CFLAGS += \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_NRF5X \
|
||||
-DNRF52840_XXAA \
|
||||
-mthumb \
|
||||
-mabi=aapcs \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_NRF5X \
|
||||
-DNRF52840_XXAA \
|
||||
-DCONFIG_GPIO_AS_PINRESET
|
||||
|
||||
# nrfx issue undef _ARMCC_VERSION usage https://github.com/NordicSemiconductor/nrfx/issues/49
|
||||
CFLAGS += -Wno-error=undef
|
||||
@ -23,27 +24,31 @@ SRC_C += \
|
||||
SRC_C += src/portable/$(VENDOR)/$(CHIP_FAMILY)/hal_$(CHIP_FAMILY).c
|
||||
|
||||
INC += \
|
||||
-I$(TOP)/hw/cmsis/Include \
|
||||
-I$(TOP)/hw/mcu/nordic \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx/mdk \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx/hal \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx/drivers/include \
|
||||
-I$(TOP)/hw/mcu/nordic/nrfx/drivers/src \
|
||||
$(TOP)/hw/cmsis/Include \
|
||||
$(TOP)/hw/mcu/nordic \
|
||||
$(TOP)/hw/mcu/nordic/nrfx \
|
||||
$(TOP)/hw/mcu/nordic/nrfx/mdk \
|
||||
$(TOP)/hw/mcu/nordic/nrfx/hal \
|
||||
$(TOP)/hw/mcu/nordic/nrfx/drivers/include \
|
||||
$(TOP)/hw/mcu/nordic/nrfx/drivers/src \
|
||||
|
||||
SRC_S += hw/mcu/nordic/nrfx/mdk/gcc_startup_nrf52840.S
|
||||
|
||||
ASFLAGS += -D__HEAP_SIZE=0
|
||||
ASFLAGS += -DCONFIG_GPIO_AS_PINRESET
|
||||
ASFLAGS += -DBLE_STACK_SUPPORT_REQD
|
||||
ASFLAGS += -DSWI_DISABLE0
|
||||
ASFLAGS += -DFLOAT_ABI_HARD
|
||||
ASFLAGS += -DNRF52840_XXAA
|
||||
|
||||
# For TinyUSB port source
|
||||
VENDOR = nordic
|
||||
CHIP_FAMILY = nrf5x
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORT = ARM_CM4F
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = nRF52840_xxAA
|
||||
JLINK_IF = swd
|
||||
|
||||
# flash using jlink
|
||||
flash: flash-jlink
|
||||
|
@ -25,15 +25,21 @@ SRC_S += \
|
||||
hw/mcu/st/startup/stm32f3/startup_stm32f303xc.s
|
||||
|
||||
INC += \
|
||||
-I$(TOP)/hw/bsp/stm32f303disc \
|
||||
-I$(TOP)/hw/mcu/st/cmsis \
|
||||
-I$(TOP)/hw/mcu/st/stm32lib/CMSIS/STM32F3xx/Include \
|
||||
-I$(TOP)/hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Inc
|
||||
$(TOP)/hw/bsp/stm32f303disc \
|
||||
$(TOP)/hw/mcu/st/cmsis \
|
||||
$(TOP)/hw/mcu/st/stm32lib/CMSIS/STM32F3xx/Include \
|
||||
$(TOP)/hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Inc
|
||||
|
||||
# For TinyUSB port source
|
||||
VENDOR = st
|
||||
CHIP_FAMILY = stm32f3
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORT = ARM_CM4F
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = stm32f303vc
|
||||
JLINK_IF = swd
|
||||
|
||||
# Path to STM32 Cube Programmer CLI, should be added into system path
|
||||
STM32Prog = STM32_Programmer_CLI
|
||||
|
@ -21,13 +21,19 @@ SRC_S += \
|
||||
hw/mcu/st/startup/stm32f4/startup_stm32f407xx.s
|
||||
|
||||
INC += \
|
||||
-I$(TOP)/hw/mcu/st/stm32lib/CMSIS/STM32F4xx/Include \
|
||||
-I$(TOP)/hw/mcu/st/cmsis
|
||||
$(TOP)/hw/mcu/st/stm32lib/CMSIS/STM32F4xx/Include \
|
||||
$(TOP)/hw/mcu/st/cmsis
|
||||
|
||||
# For TinyUSB port source
|
||||
VENDOR = st
|
||||
CHIP_FAMILY = stm32f4
|
||||
|
||||
# For freeRTOS port source
|
||||
FREERTOS_PORT = ARM_CM4F
|
||||
|
||||
# For flash-jlink target
|
||||
JLINK_DEVICE = stm32f407vg
|
||||
JLINK_IF = swd
|
||||
|
||||
# Path to STM32 Cube Programmer CLI, should be added into system path
|
||||
STM32Prog = STM32_Programmer_CLI
|
||||
|
Loading…
x
Reference in New Issue
Block a user