113 lines
3.9 KiB
Makefile
113 lines
3.9 KiB
Makefile
CPU = cortex-m4
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
|
|
|
NRF_PATH := nrf5sdk/
|
|
INCLUDES += $(NRF_PATH)components/
|
|
INCLUDES += $(NRF_PATH)modules/nrfx/mdk/
|
|
INCLUDES += $(NRF_PATH)components/libraries/strerror/
|
|
INCLUDES += $(NRF_PATH)components/softdevice/s132/headers/nrf52/
|
|
INCLUDES += $(NRF_PATH)components/toolchain/cmsis/include/
|
|
INCLUDES += $(NRF_PATH)components/libraries/util/
|
|
INCLUDES += $(NRF_PATH)components/libraries/balloc/
|
|
INCLUDES += $(NRF_PATH)components/libraries/ringbuf/
|
|
INCLUDES += $(NRF_PATH)modules/nrfx/hal/
|
|
INCLUDES += $(NRF_PATH)components/libraries/bsp/
|
|
INCLUDES += $(NRF_PATH)components/libraries/log/
|
|
INCLUDES += $(NRF_PATH)modules/nrfx/
|
|
INCLUDES += $(NRF_PATH)modules/nrfx/drivers/include/
|
|
INCLUDES += $(NRF_PATH)components/libraries/experimental_section_vars/
|
|
INCLUDES += $(NRF_PATH)components/softdevice/s132/headers/
|
|
INCLUDES += $(NRF_PATH)components/libraries/delay/
|
|
INCLUDES += $(NRF_PATH)integration/nrfx/
|
|
INCLUDES += $(NRF_PATH)integration/nrfx/legacy/
|
|
INCLUDES += $(NRF_PATH)components/libraries/atomic/
|
|
INCLUDES += $(NRF_PATH)components/boards/
|
|
INCLUDES += $(NRF_PATH)components/libraries/memobj/
|
|
INCLUDES += $(NRF_PATH)components/softdevice/common/
|
|
INCLUDES += $(NRF_PATH)external/fprintf/
|
|
INCLUDES += $(NRF_PATH)components/libraries/log/src/
|
|
|
|
NRF_C_SRCS += $(NRF_PATH)components/boards/boards.c
|
|
NRF_C_SRCS += $(NRF_PATH)modules/nrfx/mdk/system_nrf52.c
|
|
|
|
NRF_C_OBJS = $(patsubst $(NRF_PATH)%,$(OBJ_DIR)/%,$(patsubst %.c,%.o,$(NRF_C_SRCS)))
|
|
|
|
NRF_A_SRCS = $(NRF_PATH)modules/nrfx/mdk/gcc_startup_nrf52.S
|
|
NRF_A_OBJS = $(patsubst $(NRF_PATH)%,$(OBJ_DIR)/%,$(patsubst %.S,%.o,$(NRF_A_SRCS)))
|
|
|
|
C_FLAGS += -DBOARD_PCA10040
|
|
C_FLAGS += -DBSP_DEFINES_ONLY
|
|
C_FLAGS += -DCONFIG_GPIO_AS_PINRESET
|
|
C_FLAGS += -DFLOAT_ABI_HARD
|
|
C_FLAGS += -DNRF52
|
|
C_FLAGS += -DNRF52832_XXAA
|
|
C_FLAGS += -DNRF52_PAN_74
|
|
C_FLAGS += -DNRF_SD_BLE_API_VERSION=7
|
|
C_FLAGS += -DS132
|
|
C_FLAGS += -DSOFTDEVICE_PRESENT
|
|
C_FLAGS += -mcpu=$(CPU)
|
|
C_FLAGS += -mthumb -mabi=aapcs
|
|
C_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
C_FLAGS += -fno-builtin -fshort-enums
|
|
C_FLAGS += -D__HEAP_SIZE=8192
|
|
C_FLAGS += -D__HEAP_SIZE=8192
|
|
|
|
# Assembler flags common to all targets
|
|
A_FLAGS += -g$(OPT)
|
|
A_FLAGS += -mcpu=$(CPU)
|
|
A_FLAGS += -mthumb -mabi=aapcs
|
|
A_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
A_FLAGS += -DBOARD_PCA10040
|
|
A_FLAGS += -DBSP_DEFINES_ONLY
|
|
A_FLAGS += -DCONFIG_GPIO_AS_PINRESET
|
|
A_FLAGS += -DFLOAT_ABI_HARD
|
|
A_FLAGS += -DNRF52
|
|
A_FLAGS += -DNRF52832_XXAA
|
|
A_FLAGS += -DNRF52_PAN_74
|
|
A_FLAGS += -DNRF_SD_BLE_API_VERSION=7
|
|
A_FLAGS += -DS132
|
|
A_FLAGS += -DSOFTDEVICE_PRESENT
|
|
A_FLAGS += -D__HEAP_SIZE=8192
|
|
A_FLAGS += -D__HEAP_SIZE=8192
|
|
|
|
LINKER_SCRIPT = config/build/$(PLATFORM)/$(APPLICATION)/linker.ld
|
|
|
|
# Linker flags
|
|
LD_FLAGS += -O$(OPT) -g$(OPT)
|
|
LD_FLAGS += -mthumb -mabi=aapcs -L$(NRF_PATH)modules/nrfx/mdk -T$(LINKER_SCRIPT)
|
|
LD_FLAGS += -mcpu=$(CPU)
|
|
LD_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
|
LD_FLAGS += -Wl,--gc-sections
|
|
LD_FLAGS += --specs=nano.specs
|
|
|
|
.PHONY: package flash flash_softdevice erase
|
|
|
|
package: $(TARGET_HEX)
|
|
nrfutil pkg generate --hw-version 52 --application-version 1 --application $(TARGET_HEX) --sd-req 0xCB --sd-id 0xCB --key-file keys/private.key $(TARGET_PACKAGE)
|
|
|
|
flash: $(TARGET_HEX)
|
|
@echo Flashing: $(TARGET_HEX)
|
|
nrfjprog -f nrf52 --program $(TARGET_HEX) --sectorerase
|
|
nrfjprog -f nrf52 --reset
|
|
|
|
flash_softdevice: $(THIS_MAKEFILE)
|
|
@echo Flashing: $(NRF_PATH)/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex
|
|
nrfjprog -f nrf52 --program $(NRF_PATH)/components/softdevice/s132/hex/s132_nrf52_7.0.1_softdevice.hex --sectorerase
|
|
nrfjprog -f nrf52 --reset
|
|
|
|
erase:
|
|
nrfjprog -f nrf52 --eraseall
|
|
|
|
$(OBJ_DIR)/%.d: $(NRF_PATH)/%.S $(THIS_MAKEFILE)
|
|
@mkdir -p $(dir $@)
|
|
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(C_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.d,$(NRF_PATH)/%.S,$@)
|
|
|
|
$(OBJ_DIR)/%.o: $(NRF_PATH)/%.c $(THIS_MAKEFILE)
|
|
@mkdir -p $(dir $@)
|
|
$(CC) -std=c99 -MP -MD -c -o $@ $< $(C_FLAGS) $(CPP_FLAGS)
|
|
|
|
$(OBJ_DIR)/%.o: $(NRF_PATH)/%.S $(THIS_MAKEFILE)
|
|
@mkdir -p $(dir $@)
|
|
$(CC) -c $(ASMFLAGS) $< -o $@
|
|
|