narf52/build_system/platform/nrf52/Makefile

108 lines
3.3 KiB
Makefile
Raw Normal View History

CPU = cortex-m4
CROSS_COMPILE ?= arm-none-eabi-
2020-03-30 09:45:29 +00:00
NRF_PATH := nrf5sdk/
2020-04-10 09:02:00 +00:00
INCLUDES += src/platform/nrf52/sdk
INCLUDES += src/platform/cm4/cmsis/include
2020-03-30 09:45:29 +00:00
2020-04-10 09:02:00 +00:00
NRF_C_SRCS += src/platform/nrf52/sdk/system_nrf52.c
NRF_C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.c.o,$(NRF_C_SRCS)))
2020-03-10 05:56:43 +00:00
2020-04-10 09:02:00 +00:00
NRF_A_SRCS = src/platform/nrf52/sdk/gcc_startup_nrf52.S
NRF_A_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)/%,$(patsubst %.S,%.o,$(NRF_A_SRCS)))
2020-03-10 05:56:43 +00:00
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
2020-03-10 05:56:43 +00:00
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
2020-03-29 13:48:12 +00:00
CXX_FLAGS += -DBOARD_PCA10040
CXX_FLAGS += -DBSP_DEFINES_ONLY
CXX_FLAGS += -DCONFIG_GPIO_AS_PINRESET
CXX_FLAGS += -DFLOAT_ABI_HARD
CXX_FLAGS += -DNRF52
CXX_FLAGS += -DNRF52832_XXAA
CXX_FLAGS += -DNRF52_PAN_74
# CXX_FLAGS += -DNRF_SD_BLE_API_VERSION=7
# CXX_FLAGS += -DS132
# CXX_FLAGS += -DSOFTDEVICE_PRESENT
2020-03-29 13:48:12 +00:00
CXX_FLAGS += -mcpu=$(CPU)
CXX_FLAGS += -mthumb -mabi=aapcs
CXX_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
CXX_FLAGS += -fno-builtin -fshort-enums
CXX_FLAGS += -D__HEAP_SIZE=8192
CXX_FLAGS += -D__HEAP_SIZE=8192
2020-03-10 05:56:43 +00:00
# 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
2020-03-30 09:45:29 +00:00
# A_FLAGS += -DSOFTDEVICE_PRESENT
2020-03-10 05:56:43 +00:00
A_FLAGS += -D__HEAP_SIZE=8192
A_FLAGS += -D__HEAP_SIZE=8192
2020-04-10 09:02:00 +00:00
LINKER_SCRIPT = without_sd.ld
2020-03-12 14:30:53 +00:00
2020-03-10 05:56:43 +00:00
# Linker flags
LD_FLAGS += -O$(OPT) -g$(OPT)
2020-04-10 09:02:00 +00:00
LD_FLAGS += -mthumb -mabi=aapcs -Lbuild_system/platform/$(PLATFORM) -T$(LINKER_SCRIPT)
2020-03-10 05:56:43 +00:00
LD_FLAGS += -mcpu=$(CPU)
LD_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
LD_FLAGS += -Wl,--gc-sections
LD_FLAGS += --specs=nano.specs
2020-03-30 09:45:29 +00:00
LIBS += c nosys m
2020-03-10 05:56:43 +00:00
.PHONY: package flash flash_softdevice erase
2020-03-12 14:30:53 +00:00
package: $(TARGET_HEX)
2020-03-10 05:56:43 +00:00
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)
2020-03-12 14:30:53 +00:00
flash: $(TARGET_HEX)
2020-03-10 05:56:43 +00:00
@echo Flashing: $(TARGET_HEX)
nrfjprog -f nrf52 --program $(TARGET_HEX) --sectorerase
nrfjprog -f nrf52 --reset
2020-03-12 14:30:53 +00:00
flash_softdevice: $(THIS_MAKEFILE)
2020-03-10 05:56:43 +00:00
@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
2020-04-10 09:02:00 +00:00
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.S $(THIS_MAKEFILE)
2020-03-10 05:56:43 +00:00
@mkdir -p $(dir $@)
2020-04-10 09:02:00 +00:00
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(C_FLAGS) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.d,$(SRC_DIR)/%.S,$@)
2020-03-10 05:56:43 +00:00
2020-04-10 09:02:00 +00:00
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(THIS_MAKEFILE)
2020-03-10 05:56:43 +00:00
@mkdir -p $(dir $@)
$(CC) -std=c99 -MP -MD -c -o $@ $< $(C_FLAGS) $(CPP_FLAGS)
2020-04-10 09:02:00 +00:00
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.S $(THIS_MAKEFILE)
2020-03-10 05:56:43 +00:00
@mkdir -p $(dir $@)
$(CC) -c $(ASMFLAGS) $< -o $@