PROJECT_NAME := ares_nrf52_s132 TARGETS := $(PROJECT_NAME) OUTPUT_DIRECTORY := $(PROJ_DIR)/obj/$(VARIANT) SDK_ROOT := $(PROJ_DIR)/NordicSDK15 $(OUTPUT_DIRECTORY)/ares_nrf52_s132.out: \ LINKER_SCRIPT := $(PROJ_DIR)/ares_gcc_nrf52.ld # Source files common to all targets SRC_FILES += \ $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52.S \ $(SDK_ROOT)/components/boards/boards.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_pwm.c \ # Include folders common to all targets INC_FOLDERS += \ $(SDK_ROOT)/components \ $(SDK_ROOT)/components/libraries/experimental_memobj \ $(PROJ_DIR)/hal/inc \ # Libraries common to all targets LIB_FILES += \ # Optimization flags OPT = -O3 -g3 # Uncomment the line below to enable link time optimization OPT += -flto # C flags common to all targets CFLAGS += $(OPT) CFLAGS += -DBOARD_PCA10040 CFLAGS += -DBSP_DEFINES_ONLY CFLAGS += -DCONFIG_GPIO_AS_PINRESET CFLAGS += -DFLOAT_ABI_HARD CFLAGS += -DNRF52 CFLAGS += -DNRF52832_XXAA CFLAGS += -DNRF52_PAN_74 CFLAGS += -DNRF_SD_BLE_API_VERSION=6 CFLAGS += -DS132 CFLAGS += -DSOFTDEVICE_PRESENT CFLAGS += -mcpu=cortex-m4 CFLAGS += -mthumb -mabi=aapcs CFLAGS += -Wall -Werror CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 # keep every function in a separate section, this allows linker to discard unused ones CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing CFLAGS += -fno-builtin -fshort-enums CFLAGS += -std=gnu99 # C++ flags common to all targets CXXFLAGS += $(OPT) # Assembler flags common to all targets ASMFLAGS += -g3 ASMFLAGS += -mcpu=cortex-m4 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 ASMFLAGS += -DBOARD_PCA10040 ASMFLAGS += -DBSP_DEFINES_ONLY ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET ASMFLAGS += -DFLOAT_ABI_HARD ASMFLAGS += -DNRF52 ASMFLAGS += -DNRF52832_XXAA ASMFLAGS += -DNRF52_PAN_74 ASMFLAGS += -DNRF_SD_BLE_API_VERSION=6 ASMFLAGS += -DS132 ASMFLAGS += -DSOFTDEVICE_PRESENT # Linker flags LDFLAGS += $(OPT) LDFLAGS += -mthumb -mabi=aapcs -L$(SDK_ROOT)/modules/nrfx/mdk -T$(LINKER_SCRIPT) LDFLAGS += -mcpu=cortex-m4 LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 # let linker dump unused sections LDFLAGS += -Wl,--gc-sections # use newlib in nano version LDFLAGS += --specs=nano.specs LDFLAGS += -L$(ROOT_DIR)/scale2/obj/ps2/ LDFLAGS += -L$(ROOT_DIR)/scale2/src/ LDFLAGS += -lscale2 ares_nrf52_s132: CFLAGS += -D__HEAP_SIZE=8192 ares_nrf52_s132: CFLAGS += -D__STACK_SIZE=8192 ares_nrf52_s132: ASMFLAGS += -D__HEAP_SIZE=8192 ares_nrf52_s132: ASMFLAGS += -D__STACK_SIZE=8192 # Add standard libraries at the very end of the linker input, after all objects # that may need symbols provided by these libraries. LIB_FILES += -lc -lnosys -lm .PHONY: default help # Default target - first one defined default: ares_nrf52_s132 # Print all targets that can be built help: @echo following targets are available: @echo ares_nrf52_s132 @echo flash_softdevice @echo sdk_config - starting external tool for editing sdk_config.h @echo flash - flashing binary TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc include $(TEMPLATE_PATH)/Makefile.common $(foreach target, $(TARGETS), $(call define_target, $(target))) .PHONY: flash flash_softdevice erase # Flash the program flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex @echo Flashing: $< nrfjprog -f nrf52 --program $< --sectorerase nrfjprog -f nrf52 --reset # Flash softdevice flash_softdevice: @echo Flashing: s132_nrf52_6.0.0_softdevice.hex nrfjprog -f nrf52 --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_6.0.0_softdevice.hex --sectorerase nrfjprog -f nrf52 --reset erase: nrfjprog -f nrf52 --eraseall SDK_CONFIG_FILE := ../config/sdk_config.h CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar sdk_config: java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)