From 00c0e221b77e658b0360dc18f15efbbc8085a6ec Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 28 May 2015 19:12:06 +0200 Subject: o Lots of improvements, almost a rewrite. --- Makefile.common | 787 ++++++++++++++++++++++++++++++++---------------------- Makefile.posix | 8 +- Makefile.template | 238 ++++++++--------- Makefile.windows | 20 +- 4 files changed, 608 insertions(+), 445 deletions(-) diff --git a/Makefile.common b/Makefile.common index 42782f3..66f3b4e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1,218 +1,376 @@ -DEVICE := NRF51 -DEVICESERIES := nrf51 - -SDK_INCLUDE_PATH = $(SDK_PATH)/Include -SDK_SOURCE_PATH = $(SDK_PATH)/Source -# TEMPLATE_PATH += $(SDK_SOURCE_PATH)/templates/gcc -OUTPUT_BINARY_DIRECTORY := build - -ifeq ($(OS),Windows_NT) -include $(TEMPLATE_PATH)/Makefile.windows -else -include $(TEMPLATE_PATH)/Makefile.posix -endif - -ifeq ($(LINKER_SCRIPT),) - ifeq ($(USE_SOFTDEVICE), S110-v6) - LINKER_SCRIPT = gcc_$(DEVICESERIES)_s110-v6_$(DEVICE_VARIANT).ld - OUTPUT_FILENAME := $(OUTPUT_FILENAME)_s110-v6_$(DEVICE_VARIANT) - STARTADDRESS = 0x14000 - else - ifeq ($(USE_SOFTDEVICE), S110) - LINKER_SCRIPT = gcc_$(DEVICESERIES)_s110_$(DEVICE_VARIANT).ld - OUTPUT_FILENAME := $(OUTPUT_FILENAME)_s110_$(DEVICE_VARIANT) - STARTADDRESS = 0x16000 - else - ifeq ($(USE_SOFTDEVICE), S120) - LINKER_SCRIPT = gcc_$(DEVICESERIES)_s120_$(DEVICE_VARIANT).ld - OUTPUT_FILENAME := $(OUTPUT_FILENAME)_s120_$(DEVICE_VARIANT) - STARTADDRESS = 0x18000 - else - LINKER_SCRIPT = gcc_$(DEVICESERIES)_blank_$(DEVICE_VARIANT).ld - OUTPUT_FILENAME := $(OUTPUT_FILENAME)_$(DEVICE_VARIANT) - STARTADDRESS = 0x0 - endif - endif - endif -else -# Use externally defined settings -endif - -CPU := cortex-m0 +DEVICE := NRF51 +DEVICESERIES := nrf51 + +# TODO: check that DEVICE_VARIANT, TARGET_CHIP and is set + +ifeq ($(PROJECT_NAME),) +$(error PROJECT_NAME has to be set) +endif + +ifeq ($(BOARD),) +$(error BOARD has to be set) +endif + +ifeq ($(DEVICE_VARIANT),) +$(error DEVICE_VARIANT has to be set) +endif + +ifeq ($(TARGET_CHIP),) +$(error TARGET_CHIP has to be set) +endif + +USE_SOFTDEVICE ?= NO + +SDK_INCLUDE_PATH = $(SDK_PATH)/Include +SDK_SOURCE_PATH ?= $(SDK_PATH)/Source +# TEMPLATE_PATH += $(SDK_SOURCE_PATH)/templates/gcc +OUTPUT_BINARY_DIRECTORY := build + +ifeq ($(OS),Windows_NT) +include $(TEMPLATE_PATH)/Makefile.windows +else +include $(TEMPLATE_PATH)/Makefile.posix + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + STAT_SIZE=stat --format %s + endif + ifeq ($(UNAME_S),Darwin) + STAT_SIZE=stat -f %z + endif +endif + +# TODO: it should be possible to read the start address from the ld script, they're very structured. +ifeq ($(LINKER_SCRIPT),) + CFLAGS += -DSOFTDEVICE_PRESENT + ifeq ($(USE_SOFTDEVICE), S110-v6) + LINKER_SCRIPT = $(SDK_PATH)/components/toolchain/gcc/gcc_$(DEVICESERIES)_s110_$(DEVICE_VARIANT).ld + OUTPUT_FILENAME := $(PROJECT_NAME)_s110-v6_$(DEVICE_VARIANT)_$(BOARD) + STARTADDRESS = 0x14000 + else ifeq ($(USE_SOFTDEVICE), S1xx_iot) + LINKER_SCRIPT = $(SDK_PATH)/components/toolchain/gcc/gcc_$(DEVICESERIES)_s1xx_iot_$(DEVICE_VARIANT).ld + OUTPUT_FILENAME := $(PROJECT_NAME)_s1xx_iot_$(DEVICE_VARIANT)_$(BOARD) + STARTADDRESS = 0x18000 + else ifeq ($(USE_SOFTDEVICE), S110) + LINKER_SCRIPT = $(SDK_PATH)/components/toolchain/gcc/gcc_$(DEVICESERIES)_s110_$(DEVICE_VARIANT).ld + OUTPUT_FILENAME := $(PROJECT_NAME)_s110_$(DEVICE_VARIANT)_$(BOARD) + STARTADDRESS = 0x16000 + else ifeq ($(USE_SOFTDEVICE), S120) + LINKER_SCRIPT = $(SDK_PATH)/components/toolchain/gcc/gcc_$(DEVICESERIES)_s120_$(DEVICE_VARIANT).ld + OUTPUT_FILENAME := $(PROJECT_NAME)_s120_$(DEVICE_VARIANT)_$(BOARD) + STARTADDRESS = 0x18000 + else ifeq ($(USE_SOFTDEVICE), NO) + LINKER_SCRIPT = $(SDK_PATH)/components/toolchain/gcc/gcc_$(DEVICESERIES)_blank_$(DEVICE_VARIANT).ld + OUTPUT_FILENAME := $(PROJECT_NAME)_$(DEVICE_VARIANT)_$(BOARD) + STARTADDRESS = 0x0 + else +$(error Unknown softdevice: $(USE_SOFTDEVICE)) + endif +else +# Use externally defined settings +# TODO: verify that STARTADDRESS is set +endif + +CPU := cortex-m0 #Flasher selection -#FLASHER := JLink -FLASHER := OpenOCD +FLASHER := JLink +#FLASHER := OpenOCD -# Toolchain commands -JLINK := JLinkExe -Device nrf51822 -speed 100 -if swd +# Toolchain commands +#JLINK := JLinkExe -Device nrf51822 -speed 100 -if swd +JLINK := JLinkExe -speed 100 -if swd +#JLINK := JLinkExe -IP localhost #You need to change openOCD clause depending your dongle. I have stlink-v2 and it's working. Jlink will work if you fetch latest trunk from git. OPENOCD := /usr/local/bin/openocd -f interface/stlink-v2.cfg -c"transport select hla_swd" -f target/nrf51.cfg -#OPENOCD := /usr/local/bin/openocd -f interface/jlink.cfg -c"transport select swd ; adapter_khz 1000 ; adapter_nsrst_delay 10" -f /home/death/de/nrf51.cfg -CC := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gcc" -AS := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-as" -AR := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ar" -r -LD := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ld" -NM := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-nm" -OBJDUMP := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objdump" -OBJCOPY := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objcopy" +#OPENOCD := /usr/local/bin/openocd -f interface/jlink.cfg -c"transport select swd ; adapter_khz 1000 ; adapter_nsrst_delay 10" -f /home/death/de/nrf51.cfg +CC := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gcc" +AS := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-as" +AR := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ar" -r +LD := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ld" +NM := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-nm" +OBJDUMP := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objdump" +OBJCOPY := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objcopy" GDB := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gdb" - -MK := mkdir -RM := rm -rf - -OBJECT_DIRECTORY := build -LISTING_DIRECTORY := build - -C_SOURCE_FILES += system_$(DEVICESERIES).c -ASSEMBLER_SOURCE_FILES += gcc_startup_$(DEVICESERIES).s - -# Linker flags -#LDFLAGS += -L"$(GNU_INSTALL_ROOT)/arm-none-eabi/lib/armv6-m" -#LDFLAGS += -L"$(GNU_INSTALL_ROOT)/lib/gcc/arm-none-eabi/$(GNU_VERSION)/armv6-m" -LDFLAGS += -Xlinker -Map=$(LISTING_DIRECTORY)/$(OUTPUT_FILENAME).map -LDFLAGS += -mcpu=$(CPU) -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT) - -# Compiler flags -CFLAGS += -mcpu=$(CPU) -mthumb -mabi=aapcs -D$(DEVICE) -D$(BOARD) -D$(TARGET_CHIP) --std=gnu99 -CFLAGS += -Wall -CFLAGS += -mfloat-abi=soft - -# Assembler flags -ASMFLAGS += -x assembler-with-cpp - -INCLUDEPATHS += -I./src -INCLUDEPATHS += -I"$(SDK_PATH)/Include" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/gcc" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/console" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/nrf_assert" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/sdk" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/app_common" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/sd_common" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/ble" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/ble/ble_services" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/ble/device_manager" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/ble/device_manager/experimental" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/ext_sensors" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization/common" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization/common/transport" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization/common/struct_ser" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization/connectivity" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization/connectivity/codecs" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization/application/transport" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization/application/codecs/common" -INCLUDEPATHS += -I"$(SDK_PATH)/Include/serialization/application/codecs/s110/serializers" - -ifeq ($(USE_SOFTDEVICE), S110-v6) - INCLUDEPATHS += -I"$(SDK_PATH)/Include/s110" -else - ifeq ($(USE_SOFTDEVICE), S110) - INCLUDEPATHS += -I"$(SDK_PATH)/Include/s110" - else - ifeq ($(USE_SOFTDEVICE), S120) - INCLUDEPATHS += -I"$(SDK_PATH)/Include/s120" - else - INCLUDEPATHS += -I"$(SDK_PATH)/Include/sdk_soc" - endif - endif -endif - -# Sorting removes duplicates -BUILD_DIRECTORIES := $(sort $(OBJECT_DIRECTORY) $(OUTPUT_BINARY_DIRECTORY) $(LISTING_DIRECTORY) ) - -#################################################################### -# Rules # -#################################################################### - -C_SOURCE_FILENAMES = $(notdir $(C_SOURCE_FILES) ) -ASSEMBLER_SOURCE_FILENAMES = $(notdir $(ASSEMBLER_SOURCE_FILES) ) - -# Make a list of source paths -C_SOURCE_PATHS += $(SDK_SOURCE_PATH) $(TEMPLATE_PATH) $(wildcard $(SDK_SOURCE_PATH)/*/) $(wildcard $(SDK_SOURCE_PATH)/ext_sensors/*/) $(wildcard $(SDK_SOURCE_PATH)/ble/*/) $(BUILD_SCRIPTS_PATH) src -ASSEMBLER_SOURCE_PATHS = $(SDK_SOURCE_PATH) $(TEMPLATE_PATH) $(wildcard $(SDK_SOURCE_PATH)/*/) $(BUILD_SCRIPTS_PATH) - -C_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILENAMES:.c=.o) ) -ASSEMBLER_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(ASSEMBLER_SOURCE_FILENAMES:.s=.o) ) - -# Set source lookup paths -vpath %.c $(C_SOURCE_PATHS) -vpath %.s $(ASSEMBLER_SOURCE_PATHS) - -# Include automatically previously generated dependencies --include $(addprefix $(OBJECT_DIRECTORY)/, $(COBJS:.o=.d)) - -### Targets -# debug: OUTPUT_FILENAME:=$(OUTPUT_FILENAME)-debug -debug: CFLAGS += -DDEBUG -g3 -O0 -debug: ASMFLAGS += -DDEBUG -g3 -O0 -debug: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex - -.PHONY: release -# release: OUTPUT_FILENAME:=$(OUTPUT_FILENAME)-release -release: CFLAGS += -DNDEBUG -O3 -release: ASMFLAGS += -DNDEBUG -O3 -release: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex - -echostuff: - @echo C_OBJECTS: [$(C_OBJECTS)] - @echo C_SOURCE_FILES: [$(C_SOURCE_FILES)] - @echo C_SOURCE_PATHS: [$(C_SOURCE_PATHS)] - -## Create build directories -$(BUILD_DIRECTORIES): - $(MK) $@ - -## Create objects from C source files -$(OBJECT_DIRECTORY)/%.o: %.c -# Build header dependencies - $(CC) $(CFLAGS) $(INCLUDEPATHS) -M $< -MF "$(@:.o=.d)" -MT $@ -# Do the actual compilation - $(CC) $(CFLAGS) $(INCLUDEPATHS) -g -c -o $@ $< - -## Assemble .s files -$(OBJECT_DIRECTORY)/%.o: %.s - $(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $< - -## Link C and assembler objects to an .out file -$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out: $(BUILD_DIRECTORIES) $(C_OBJECTS) $(ASSEMBLER_OBJECTS) $(LIBRARIES) - $(CC) $(LDFLAGS) $(C_OBJECTS) $(ASSEMBLER_OBJECTS) $(LIBRARIES) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out - -## Create binary .bin file from the .out file -$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out - $(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin - -## Create binary .hex file from the .out file -$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out - $(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex - -## Default build target -.PHONY: all -all: clean debug - -clean: - $(RM) $(OUTPUT_BINARY_DIRECTORY) + +MK := mkdir +RM := rm -rf + +OBJECT_DIRECTORY := build +LISTING_DIRECTORY := build + +C_SOURCE_FILES += system_$(DEVICESERIES).c +ASSEMBLER_SOURCE_FILES += gcc_startup_$(DEVICESERIES).s + +# Linker flags +#LDFLAGS += -L"$(GNU_INSTALL_ROOT)/arm-none-eabi/lib/armv6-m" +#LDFLAGS += -L"$(GNU_INSTALL_ROOT)/lib/gcc/arm-none-eabi/$(GNU_VERSION)/armv6-m" +LDFLAGS += -Xlinker -Map=$(LISTING_DIRECTORY)/$(OUTPUT_FILENAME).map +LDFLAGS += -mcpu=$(CPU) -mthumb -mabi=aapcs -L$(SDK_PATH)/components/toolchain/gcc -T$(LINKER_SCRIPT) + +# Compiler flags +CFLAGS += -mcpu=$(CPU) -mthumb -mabi=aapcs -D$(DEVICE) -D$(BOARD) -D$(TARGET_CHIP) --std=gnu99 +CFLAGS += -Wall +CFLAGS += -mfloat-abi=soft + +# Assembler flags +ASMFLAGS += -x assembler-with-cpp + +# TODO: should probably be called SDK_INCLUDES as they are all relative to the SDK +INCLUDES += components/ble/ble_db_discovery +INCLUDES += components/ble/ble_debug_assert_handler +INCLUDES += components/ble/ble_dtm +INCLUDES += components/ble/ble_error_log +INCLUDES += components/ble/ble_racp +INCLUDES += components/ble/ble_radio_notification +INCLUDES += components/ble/ble_services/ble_ans_c +INCLUDES += components/ble/ble_services/ble_bas +INCLUDES += components/ble/ble_services/ble_bas_c +INCLUDES += components/ble/ble_services/ble_bps +INCLUDES += components/ble/ble_services/ble_cgm +INCLUDES += components/ble/ble_services/ble_cscs +INCLUDES += components/ble/ble_services/ble_dfu +INCLUDES += components/ble/ble_services/ble_dis +INCLUDES += components/ble/ble_services/ble_gls +INCLUDES += components/ble/ble_services/ble_hids +INCLUDES += components/ble/ble_services/ble_hrs +INCLUDES += components/ble/ble_services/ble_hrs_c +INCLUDES += components/ble/ble_services/ble_hts +INCLUDES += components/ble/ble_services/ble_ias +INCLUDES += components/ble/ble_services/ble_ias_c +INCLUDES += components/ble/ble_services/ble_lls +INCLUDES += components/ble/ble_services/ble_rscs +INCLUDES += components/ble/ble_services/ble_sps +INCLUDES += components/ble/ble_services/ble_tps +INCLUDES += components/ble/common +INCLUDES += components/ble/device_manager +INCLUDES += components/ble/device_manager/config +INCLUDES += components/drivers_ext/adns2080 +INCLUDES += components/drivers_ext/cherry8x16 +INCLUDES += components/drivers_ext/ds1624 +INCLUDES += components/drivers_ext/mpu6050 +INCLUDES += components/drivers_ext/nrf6350 +INCLUDES += components/drivers_ext/synaptics_touchpad +INCLUDES += components/drivers_nrf/ble_flash +INCLUDES += components/drivers_nrf/hal +INCLUDES += components/drivers_nrf/pstorage +INCLUDES += components/drivers_nrf/pstorage/config +INCLUDES += components/drivers_nrf/radio_config +INCLUDES += components/drivers_nrf/sdio +INCLUDES += components/drivers_nrf/sdio/config +INCLUDES += components/drivers_nrf/simple_uart +INCLUDES += components/drivers_nrf/spi_master +INCLUDES += components/drivers_nrf/spi_slave +INCLUDES += components/drivers_nrf/twi_master +INCLUDES += components/drivers_nrf/twi_master/config +INCLUDES += components/drivers_nrf/uart +INCLUDES += components/libraries/ant_fs +INCLUDES += components/libraries/bootloader_dfu +INCLUDES += components/libraries/bootloader_dfu +INCLUDES += components/libraries/bootloader_dfu +INCLUDES += components/libraries/bootloader_dfu/ble_transport +INCLUDES += components/libraries/bootloader_dfu/experimental +INCLUDES += components/libraries/bootloader_dfu/hci_transport +INCLUDES += components/libraries/button +INCLUDES += components/libraries/console +INCLUDES += components/libraries/crc16 +INCLUDES += components/libraries/fifo +INCLUDES += components/libraries/gpiote +INCLUDES += components/libraries/hci +INCLUDES += components/libraries/hci/config +INCLUDES += components/libraries/scheduler +INCLUDES += components/libraries/sensorsim +INCLUDES += components/libraries/timer +INCLUDES += components/libraries/trace +INCLUDES += components/libraries/util +INCLUDES += components/properitary_rf/esb +INCLUDES += components/properitary_rf/gzll +INCLUDES += components/properitary_rf/gzll/config +INCLUDES += components/toolchain +INCLUDES += components/toolchain/arm +INCLUDES += components/toolchain/gcc +INCLUDES += components/serialization/application/codecs/common +INCLUDES += components/serialization/application/hal +INCLUDES += components/serialization/application/transport +INCLUDES += components/serialization/common +INCLUDES += components/serialization/common/transport +INCLUDES += components/serialization/common/transport/debug +INCLUDES += components/serialization/common/transport +INCLUDES += components/serialization/common/transport/ser_phy/config +INCLUDES += components/serialization/common/transport/ser_phy +INCLUDES += components/serialization/common +INCLUDES += components/serialization/connectivity +INCLUDES += components/serialization/connectivity/codecs/common +INCLUDES += components/serialization/connectivity/hal +INCLUDES += components/serialization/connectivity +INCLUDES += components/softdevice/common/softdevice_handler + +# Softdevice-specific includes +ifeq ($(USE_SOFTDEVICE), S110) +INCLUDES += components/serialization/application/codecs/s110/serializers +INCLUDES += components/serialization/common/struct_ser/s110 +INCLUDES += components/serialization/connectivity/codecs/s110/middleware +INCLUDES += components/serialization/connectivity/codecs/s110/serializers +INCLUDES += components/softdevice/s110/headers +else ifeq ($(USE_SOFTDEVICE),S110-v6) +INCLUDES += components/softdevice/s110/headers +else ifeq ($(USE_SOFTDEVICE), S120) +INCLUDES += components/serialization/application/codecs/s120/serializers +INCLUDES += components/serialization/common/struct_ser/s120 +INCLUDES += components/serialization/connectivity/codecs/s120/middleware +INCLUDES += components/serialization/connectivity/codecs/s120/serializers +INCLUDES += components/softdevice/s120/headers +else ifeq ($(USE_SOFTDEVICE),S130) +INCLUDES += components/softdevice/s130/headers +else ifeq ($(USE_SOFTDEVICE),S310) +INCLUDES += components/softdevice/s310/headers +else ifeq ($(USE_SOFTDEVICE),S1xx_iot) +INCLUDES += components/ble/ble_6lowpan +INCLUDES += components/ble/ble_services/ble_ipsp +INCLUDES += components/iot/coap +INCLUDES += components/iot/context_manager +INCLUDES += components/iot/include +INCLUDES += components/iot/ipv6_stack/icmp6 +INCLUDES += components/iot/ipv6_stack/include +INCLUDES += components/iot/ipv6_stack/ipv6 +INCLUDES += components/iot/ipv6_stack/pbuffer +INCLUDES += components/iot/ipv6_stack/udp +INCLUDES += components/iot/ipv6_stack/utils +INCLUDES += components/libraries/mem_manager +INCLUDES += components/softdevice/s1xx_iot/headers +else ifeq ($(USE_SOFTDEVICE),NO) +INCLUDES += components/drivers_nrf/nrf_soc_nosd +endif + +INCLUDES += examples/bsp + +#INCLUDEPATHS += -I./src +#INCLUDEPATHS += "-I$(SDK_PATH)" +INCLUDEPATHS += $(addprefix -I$(SDK_PATH)/,$(INCLUDES)) + +# Sorting removes duplicates +BUILD_DIRECTORIES := $(sort $(OBJECT_DIRECTORY) $(OUTPUT_BINARY_DIRECTORY) $(LISTING_DIRECTORY) ) + +#################################################################### +# Rules # +#################################################################### + +C_SOURCE_FILENAMES = $(notdir $(C_SOURCE_FILES) ) +ASSEMBLER_SOURCE_FILENAMES = $(notdir $(ASSEMBLER_SOURCE_FILES) ) + +# Make a list of source paths +C_SOURCE_PATHS += $(SDK_SOURCE_PATH) +C_SOURCE_PATHS += $(TEMPLATE_PATH) +C_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/*/) +C_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/ext_sensors/*/) +C_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/ble/*/) +C_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/ble/ble_services/*/) +C_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/drivers_nrf/*/) +C_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/libraries/*/) +C_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/iot/*) +C_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/iot/ipv6_stack/*) +C_SOURCE_PATHS += $(SDK_PATH)/examples/bsp +C_SOURCE_PATHS += $(SDK_PATH)/components/softdevice/common/softdevice_handler +C_SOURCE_PATHS += $(BUILD_SCRIPTS_PATH) +C_SOURCE_PATHS += src + +ASSEMBLER_SOURCE_PATHS += $(SDK_SOURCE_PATH) +ASSEMBLER_SOURCE_PATHS += $(TEMPLATE_PATH) +ASSEMBLER_SOURCE_PATHS += $(wildcard $(SDK_SOURCE_PATH)/*/) +ASSEMBLER_SOURCE_PATHS += $(BUILD_SCRIPTS_PATH) + +C_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILENAMES:.c=.o) ) +ASSEMBLER_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(ASSEMBLER_SOURCE_FILENAMES:.s=.o) ) + +# Set source lookup paths +vpath %.c $(C_SOURCE_PATHS) +vpath %.s $(ASSEMBLER_SOURCE_PATHS) + +# Include automatically previously generated dependencies +-include $(C_OBJECTS:.o=.d) + +### Targets +# debug: OUTPUT_FILENAME:=$(OUTPUT_FILENAME)-debug +debug: CFLAGS += -DDEBUG -g3 -O0 +debug: ASMFLAGS += -DDEBUG -g3 -O0 +debug: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex + +.PHONY: release +# release: OUTPUT_FILENAME:=$(OUTPUT_FILENAME)-release +release: CFLAGS += -DNDEBUG -O3 +release: ASMFLAGS += -DNDEBUG -O3 +release: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex + +echostuff: + @echo CPU: $(CPU) + @echo DEVICE: $(DEVICE) + @echo BOARD: $(BOARD) + @echo TARGET_CHIP: $(TARGET_CHIP) + @echo C_OBJECTS: [$(C_OBJECTS)] + @echo CFLAGS: $(CFLAGS) + @echo C_SOURCE_FILES: + @echo $(C_SOURCE_FILES) | tr ' ' '\n' + @echo C_SOURCE_PATHS: + @echo $(C_SOURCE_PATHS) | tr ' ' '\n' + @echo INCLUDEPATHS: + @echo $(INCLUDEPATHS) | tr ' ' '\n' + +## Create build directories +$(BUILD_DIRECTORIES): + $(MK) $@ + +## Create objects from C source files +$(OBJECT_DIRECTORY)/%.o: %.c | $(BUILD_DIRECTORIES) +# Build header dependencies + @$(CC) $(CFLAGS) $(INCLUDEPATHS) -M $< -MF "$(@:.o=.d)" -MT $@ +# Do the actual compilation + @echo CC $@ + @$(CC) $(CFLAGS) $(INCLUDEPATHS) -g -c -o $@ $< + +## Assemble .s files +$(OBJECT_DIRECTORY)/%.o: %.s + @echo AS $@ + @$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $< + +## Link C and assembler objects to an .out file +$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out: $(C_OBJECTS) $(ASSEMBLER_OBJECTS) $(LIBRARIES) | $(BUILD_DIRECTORIES) + @echo LD $@ + @$(CC) $(LDFLAGS) -o $@ $^ + +## Create binary .bin file from the .out file +$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out + $(OBJCOPY) -O binary $< $@ + +## Create binary .hex file from the .out file +$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out + $(OBJCOPY) -O ihex $< $@ + +## Default build target +.PHONY: all +all: debug + +clean: + $(RM) $(OUTPUT_BINARY_DIRECTORY) # Create binary file from the softdevice 7 hex file -$(OUTPUT_BINARY_DIRECTORY)/softdevice.bin: $(BUILD_DIRECTORIES) - $(OBJCOPY) -I ihex -O binary $(SOFTDEVICE_HEX_PATH) $(OUTPUT_BINARY_DIRECTORY)/softdevice.bin +$(OUTPUT_BINARY_DIRECTORY)/softdevice.bin: $(BUILD_DIRECTORIES) + $(OBJCOPY) -I ihex -O binary $(SOFTDEVICE_HEX_PATH) $(OUTPUT_BINARY_DIRECTORY)/softdevice.bin # Create IUCR binary file from the softdevice 6 UICR hex file -$(OUTPUT_BINARY_DIRECTORY)/softdevice_uicr.bin: $(SOFTDEVICE_HEX_PATH) $(BUILD_DIRECTORIES) - $(OBJCOPY) -Iihex -Obinary --only-section .sec3 $< $@ +$(OUTPUT_BINARY_DIRECTORY)/softdevice_uicr.bin: $(SOFTDEVICE_HEX_PATH) $(BUILD_DIRECTORIES) + $(OBJCOPY) -Iihex -Obinary --only-section .sec3 $< $@ -# Create binary file from the softdevice 6 hex file -$(OUTPUT_BINARY_DIRECTORY)/softdevice_main.bin: $(SOFTDEVICE_HEX_PATH) $(BUILD_DIRECTORIES) - $(OBJCOPY) -Iihex -Obinary --remove-section .sec3 $< $@ +# Create binary file from the softdevice 6 hex file +$(OUTPUT_BINARY_DIRECTORY)/softdevice_main.bin: $(SOFTDEVICE_HEX_PATH) $(BUILD_DIRECTORIES) + $(OBJCOPY) -Iihex -Obinary --remove-section .sec3 $< $@ #OpenOCD Flasher Scripts ifeq ($(FLASHER), OpenOCD) -flash: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin - $(OPENOCD) -c "program $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin $(STARTADDRESS) verify" +flash: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin + $(OPENOCD) -c "program $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin $(STARTADDRESS) verify" ifeq ($(USE_SOFTDEVICE), S110-v6) -flash_softdevice: $(OUTPUT_BINARY_DIRECTORY)/softdevice_main.bin $(OUTPUT_BINARY_DIRECTORY)/softdevice_uicr.bin - $(OPENOCD) -c "init ; reset halt ; nrf51 mass_erase ; sleep 500 ; flash write_image $(OUTPUT_BINARY_DIRECTORY)/softdevice_uicr.bin 0x10001000 ; verify_image $(OUTPUT_BINARY_DIRECTORY)/softdevice_uicr.bin 0x10001000 ; flash write_image $(OUTPUT_BINARY_DIRECTORY)/softdevice_main.bin 0x0 ; verify_image $(OUTPUT_BINARY_DIRECTORY)/softdevice_main.bin 0; shutdown" +flash_softdevice: $(OUTPUT_BINARY_DIRECTORY)/softdevice_main.bin $(OUTPUT_BINARY_DIRECTORY)/softdevice_uicr.bin + $(OPENOCD) -c "init ; reset halt ; nrf51 mass_erase ; sleep 500 ; flash write_image $(OUTPUT_BINARY_DIRECTORY)/softdevice_uicr.bin 0x10001000 ; verify_image $(OUTPUT_BINARY_DIRECTORY)/softdevice_uicr.bin 0x10001000 ; flash write_image $(OUTPUT_BINARY_DIRECTORY)/softdevice_main.bin 0x0 ; verify_image $(OUTPUT_BINARY_DIRECTORY)/softdevice_main.bin 0; shutdown" else flash_softdevice: $(OUTPUT_BINARY_DIRECTORY)/softdevice.bin $(OPENOCD) -c "init ; reset halt ; nrf51 mass_erase ; sleep 500 ; flash write_image $(OUTPUT_BINARY_DIRECTORY)/softdevice.bin 0x0 ; verify_image $(OUTPUT_BINARY_DIRECTORY)/softdevice.bin 0x0 ; mww 0x4001e504 1 ; mww 0x10001000 $(STARTADDRESS) ; mww 0x4001e504 0 ; shutdown" @@ -224,131 +382,136 @@ erase_all: pinreset: $(OPENOCD) -c "init ; reset halt ; mww 0x4001e504 2 ; mww 0x40000544 1 ; reset ; shutdown" -gdbserver: +gdbserver: $(OPENOCD) GDB_COMMAND_SCRIPT=$(OUTPUT_BINARY_DIRECTORY)/gdbinit -$(GDB_COMMAND_SCRIPT): debug - echo -e -n "target remote localhost:3333 \n\ +$(GDB_COMMAND_SCRIPT): debug + echo -e -n "target remote localhost:3333 \n\ monitor reset halt \n\ - file $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out \n\ - load \n\ - b main \n\ - b app_error_handler \n\ - monitor reset \n\ + file $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out \n\ + load \n\ + b main \n\ + b app_error_handler \n\ + monitor reset \n\ continue" > $(GDB_COMMAND_SCRIPT) - + #JLink Flasher Scripts -else -$(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink : $(BUILD_DIRECTORIES) - echo " -r \n\ -h \n\ -w4 0x4001e504,2 # enable erase all \n\ -w4 0x4001e50c,1 # start erasing \n\ -sleep 1000 \n\ -w4 0x4001e514,1 # start erasing UICR \n\ -sleep 500 \n\ -r \n\ -q \n\ - " \ - > $(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink - -erase_all: $(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink - $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink; [ "$$?" -eq 1 ] - -$(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink: $(BUILD_DIRECTORIES) - echo " \n\ -r \n\ -h \n\ -w4 0x4001e504,2 # enable erase \n\ -w4 0x4001e50c,1 # start erasing all \n\ -sleep 1000 \n\ -w4 0x4001e514,1 # start erasing UICR \n\ -sleep 500 \n\ -w4 0x10001000, $(STARTADDRESS) # write code region size \n\ -sleep 1000 \n\ -w4 0x4001e504,1 \n\ -sleep 1000 \n\ -loadbin \"$(OUTPUT_BINARY_DIRECTORY)/softdevice.bin\", 0x0 \n\ -verifybin \"$(OUTPUT_BINARY_DIRECTORY)/softdevice.bin\", 0x0 \n\ -r \n\ -qc \n\ -" > $(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink - -flash_softdevice: $(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink $(OUTPUT_BINARY_DIRECTORY)/softdevice.bin - $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink; [ "$$?" -eq 1 ] - -$(OUTPUT_BINARY_DIRECTORY)/flash.jlink: $(BUILD_DIRECTORIES) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin - echo " \n\ -r \n\ -h \n\ -w4 0x4001e504,2 # enable erase \n\ -" > $(OUTPUT_BINARY_DIRECTORY)/flash.jlink - binsize=`stat -f %z $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin`; \ - starthexaddr=$(STARTADDRESS); \ - startaddr=`printf "%d" $$starthexaddr`; \ - page=0; \ - while [ $$binsize -gt 0 ]; \ - do \ - echo "w4 0x4001e508, $$starthexaddr # start erasing code region 1 page $$page\n" >> $(OUTPUT_BINARY_DIRECTORY)/flash.jlink ; \ - binsize=`expr $$binsize - 1024`; \ - page=`expr $$page + 1`; \ - startaddr=`expr $$startaddr + 1024`; \ - starthexaddr=`printf "0x%x" $$startaddr`; \ - done - echo "sleep 1000 \n\ -r \n\ -w4 0x4001e504,1 # enable write \n\ -loadbin \"$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin\", $(STARTADDRESS)\n\ -verifybin \"$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin\", $(STARTADDRESS)\n\ -r \n\ -g \n\ -qc \n\ -" >> $(OUTPUT_BINARY_DIRECTORY)/flash.jlink - -flash: $(OUTPUT_BINARY_DIRECTORY)/flash.jlink - $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/flash.jlink; [ "$$?" -eq 1 ] - -$(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink: $(BUILD_DIRECTORIES) - echo "\n\ - r \n\ - h \n\ - w4 4001e504 2 \n\ - w4 40000544 1 \n\ - r \n\ - qc \n\ - " > $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink - -pin-reset: $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink - $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink; [ "$$?" -eq 1 ] - -START_GDB_SERVER_SCRIPT=$(OUTPUT_BINARY_DIRECTORY)/start_gdbserver.sh -$(START_GDB_SERVER_SCRIPT): $(BUILD_DIRECTORIES) +else +$(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink : $(BUILD_DIRECTORIES) + @echo "\ +r \n\ +h \n\ +w4 0x4001e504,2 # enable erase all \n\ +w4 0x4001e50c,1 # start erasing \n\ +sleep 1000 \n\ +w4 0x4001e514,1 # start erasing UICR \n\ +sleep 500 \n\ +r \n\ +q \n\ + " \ + > $@ + +erase_all: $(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink + $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink; [ "$$?" -eq 1 ] + +$(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink: $(BUILD_DIRECTORIES) + @echo " \n\ +r \n\ +h \n\ +w4 0x4001e504,2 # enable erase \n\ +w4 0x4001e50c,1 # start erasing all \n\ +sleep 1000 \n\ +w4 0x4001e514,1 # start erasing UICR \n\ +sleep 500 \n\ +w4 0x10001000, $(STARTADDRESS) # write code region size \n\ +sleep 1000 \n\ +w4 0x4001e504,1 \n\ +sleep 1000 \n\ +loadbin \"$(OUTPUT_BINARY_DIRECTORY)/softdevice.bin\", 0x0 \n\ +verifybin \"$(OUTPUT_BINARY_DIRECTORY)/softdevice.bin\", 0x0 \n\ +r \n\ +qc \n\ +" > $(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink + +flash_softdevice: $(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink $(OUTPUT_BINARY_DIRECTORY)/softdevice.bin + $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink; [ "$$?" -eq 1 ] + +$(OUTPUT_BINARY_DIRECTORY)/flash.jlink: $(BUILD_DIRECTORIES) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin + @echo " \n\ +r \n\ +h \n\ +w4 0x4001e504,2 # enable erase \n\ +" > $@ + set -e; \ + binsize=`$(STAT_SIZE) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin`; \ + starthexaddr=$(STARTADDRESS); \ + startaddr=`printf "%d" $$starthexaddr`; \ + page=0; \ + while [ $$binsize -gt 0 ]; \ + do \ + echo "w4 0x4001e508, $$starthexaddr # start erasing code region 1 page $$page\n" >> $@ ; \ + binsize=`expr $$binsize - 1024`; \ + page=`expr $$page + 1`; \ + startaddr=`expr $$startaddr + 1024`; \ + starthexaddr=`printf "0x%x" $$startaddr`; \ + done + echo "sleep 1000 \n\ +r \n\ +w4 0x4001e504,1 # enable write \n\ +loadbin \"$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin\", $(STARTADDRESS)\n\ +verifybin \"$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin\", $(STARTADDRESS)\n\ +r \n\ +g \n\ +qc \n\ +" >> $@ + +flash: $(OUTPUT_BINARY_DIRECTORY)/flash.jlink + $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/flash.jlink; [ "$$?" -eq 1 ] + +$(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink: $(BUILD_DIRECTORIES) + @echo "\n\ + r \n\ + h \n\ + w4 4001e504 2 \n\ + w4 40000544 1 \n\ + r \n\ + qc \n\ + " > $@ + +pin-reset: $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink + $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink; [ "$$?" -eq 1 ] + +START_GDB_SERVER_SCRIPT=$(OUTPUT_BINARY_DIRECTORY)/start_gdbserver.sh +$(START_GDB_SERVER_SCRIPT): $(BUILD_DIRECTORIES) echo "JLinkGDBServer -if swd -device nrf51822 -LocalHostOnly" > $(START_GDB_SERVER_SCRIPT) -gdbserver: $(START_GDB_SERVER_SCRIPT) +gdbserver: $(START_GDB_SERVER_SCRIPT) /bin/sh $(START_GDB_SERVER_SCRIPT) GDB_COMMAND_SCRIPT=$(OUTPUT_BINARY_DIRECTORY)/gdbinit -$(GDB_COMMAND_SCRIPT): debug - echo " \n\ - target remote localhost:2331 \n\ - mon flash breakpoints = 1 \n\ - monitor reset \n\ - file $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out \n\ - load \n\ - b main \n\ - b app_error_handler \n\ - monitor reset \n\ - continue" > $(GDB_COMMAND_SCRIPT) - -#end of FLASHER selection +$(GDB_COMMAND_SCRIPT): debug + @echo " \n\ + target remote localhost:2331 \n\ + mon flash breakpoints = 1 \n\ + monitor reset \n\ + file $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out \n\ + load \n\ + b main \n\ + b app_error_handler \n\ + monitor reset \n\ + continue" > $@ + +.PHONY: jlink +jlink: + $(JLINK) + +#end of FLASHER selection endif - -gdb: $(GDB_COMMAND_SCRIPT) debug - $(GDB) -x $(GDB_COMMAND_SCRIPT) - + +gdb: $(GDB_COMMAND_SCRIPT) debug + $(GDB) -x $(GDB_COMMAND_SCRIPT) + serial: screen /dev/ttyUSB1cu.usbmodem1411 38400 diff --git a/Makefile.posix b/Makefile.posix index b9e0b44..5439214 100644 --- a/Makefile.posix +++ b/Makefile.posix @@ -1,4 +1,4 @@ -GNU_INSTALL_ROOT := /opt/gcc-arm-none-eabi-4_8-2014q2 -GNU_VERSION := 4.8.4 -GNU_PREFIX := arm-none-eabi - +GNU_INSTALL_ROOT ?= /opt/gcc-arm-none-eabi-4_8-2014q2 +GNU_VERSION := 4.8.4 +GNU_PREFIX := arm-none-eabi + diff --git a/Makefile.template b/Makefile.template index 134dd16..a4d40d5 100644 --- a/Makefile.template +++ b/Makefile.template @@ -1,119 +1,119 @@ -TARGET_CHIP := NRF51822_QFAA_CA -BOARD := BOARD_PCA10001 - -#Uncomment correct line if you have s110 programmed on the chip. -DEVICE_VARIANT := xxaa -#DEVICE_VARIANT := xxab - -USE_SOFTDEVICE := S110 -#USE_SOFTDEVICE := S110-v6 -#USE_SOFTDEVICE := S120 - -HOME = ~ - -#Not that SDK 5.1.0 does NOT work with SoftDevice 7 -#SDK_PATH = $(HOME)/nRF_SDK_v5.1.0.36092/Nordic/nrf51822 -SDK_PATH = $(HOME)/nRF51_SDK_v6.0.0.43681/Nordic/nrf51822 -BUILD_SCRIPTS_PATH = $(HOME)/nrf51822-posix-build-scripts -TEMPLATE_PATH = $(BUILD_SCRIPTS_PATH) -ifeq ($(USE_SOFTDEVICE), S110-v6) - SOFTDEVICE_HEX_PATH = /run/media/death/F2FS/s110_nrf51822_6_0_0/s110_nrf51822_6.0.0_softdevice.hex -else - SOFTDEVICE_HEX_PATH = /run/media/death/F2FS/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_softdevice.hex -endif - -# CFLAGS += -DBLE_STACK_SUPPORT_REQD -# debug: CFLAGS+=-DENABLE_DEBUG_LOG_SUPPORT - -C_SOURCE_FILES += main.c -ifeq ($(MAKECMDGOALS),debug) # template for conditional rules -# C_SOURCE_FILES += uart.c -endif - -# C_SOURCE_FILES += softdevice_handler.c # need custome defined assert_nrf_callback() - -# nrf_delay -# C_SOURCE_FILES += nrf_delay.c - -# nrf_assert -# C_SOURCE_FILES += nrf_assert.c - -# nrf_ecb -# C_SOURCE_FILES += nrf_ecb.c - -# nrf_nvmc -# C_SOURCE_FILES += nrf_nvmc.c - -# nrf_soc -# C_SOURCE_FILES += nrf_soc.c - -# spi_master -# C_SOURCE_FILES += spi_master.c - -# spi_slave -# C_SOURCE_FILES += spi_slave.c - -# twi_master -# C_SOURCE_FILES += twi_hw_master.c -# C_SOURCE_FILES += twi_sw_master.c - -# simple_uart -# C_SOURCE_FILES += simple_uart.c - -# sd_common -# C_SOURCE_FILES += softdevice_handler.c - -# app_common -# C_SOURCE_FILES += app_button.c -# C_SOURCE_FILES += app_fifo.c -# C_SOURCE_FILES += app_gpiote.c -# C_SOURCE_FILES += app_scheduler.c -# C_SOURCE_FILES += app_timer.c -# C_SOURCE_FILES += app_trace.c -# C_SOURCE_FILES += app_uart.c -# C_SOURCE_FILES += app_uart_fifo.c -# C_SOURCE_FILES += crc16.c -# C_SOURCE_FILES += hci_mem_pool.c -# C_SOURCE_FILES += hci_slip.c -# C_SOURCE_FILES += hci_transport.c -# C_SOURCE_FILES += pstorage.c # need pstorage_platform.h - -# ble -# C_SOURCE_FILES += ble_advdata.c -# C_SOURCE_FILES += ble_advdata_parser.c -# C_SOURCE_FILES += ble_conn_params.c -# C_SOURCE_FILES += ble_debug_assert_handler.c -# C_SOURCE_FILES += ble_dtm.c -# C_SOURCE_FILES += ble_error_log.c -# C_SOURCE_FILES += ble_flash.c -# C_SOURCE_FILES += ble_racp.c -# C_SOURCE_FILES += ble_radio_notification.c -# C_SOURCE_FILES += ble_sensorsim.c - -# ble/ble_services -# C_SOURCE_FILES += ble_ans_c.c -# C_SOURCE_FILES += ble_bas.c -# C_SOURCE_FILES += ble_bps.c -# C_SOURCE_FILES += ble_cscs.c -# C_SOURCE_FILES += ble_dfu.c -# C_SOURCE_FILES += ble_dis.c -# C_SOURCE_FILES += ble_gls.c -# C_SOURCE_FILES += ble_gls_db.c -# C_SOURCE_FILES += ble_hids.c -# C_SOURCE_FILES += ble_hrs.c -# C_SOURCE_FILES += ble_hts.c -# C_SOURCE_FILES += ble_ias.c -# C_SOURCE_FILES += ble_ias_c.c -# C_SOURCE_FILES += ble_lls.c -# C_SOURCE_FILES += ble_rscs.c -# C_SOURCE_FILES += ble_sc_ctrlpt.c -# C_SOURCE_FILES += ble_srv_common.c -# C_SOURCE_FILES += ble_tps.c - -# ble/device_manager/experimental -# C_SOURCE_FILES += device_manager_central.c - -OUTPUT_FILENAME := main - -include $(TEMPLATE_PATH)/Makefile.common - +TARGET_CHIP := NRF51822_QFAA_CA +BOARD := BOARD_PCA10001 + +#Uncomment correct line if you have s110 programmed on the chip. +DEVICE_VARIANT := xxaa +#DEVICE_VARIANT := xxab + +USE_SOFTDEVICE := S110 +#USE_SOFTDEVICE := S110-v6 +#USE_SOFTDEVICE := S120 + +HOME = ~ + +#Not that SDK 5.1.0 does NOT work with SoftDevice 7 +#SDK_PATH = $(HOME)/nRF_SDK_v5.1.0.36092/Nordic/nrf51822 +SDK_PATH = $(HOME)/nRF51_SDK_v6.0.0.43681/Nordic/nrf51822 +BUILD_SCRIPTS_PATH = $(HOME)/nrf51822-posix-build-scripts +TEMPLATE_PATH = $(BUILD_SCRIPTS_PATH) +ifeq ($(USE_SOFTDEVICE), S110-v6) + SOFTDEVICE_HEX_PATH = /run/media/death/F2FS/s110_nrf51822_6_0_0/s110_nrf51822_6.0.0_softdevice.hex +else + SOFTDEVICE_HEX_PATH = /run/media/death/F2FS/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_softdevice.hex +endif + +# CFLAGS += -DBLE_STACK_SUPPORT_REQD +# debug: CFLAGS+=-DENABLE_DEBUG_LOG_SUPPORT + +C_SOURCE_FILES += main.c +ifeq ($(MAKECMDGOALS),debug) # template for conditional rules +# C_SOURCE_FILES += uart.c +endif + +# C_SOURCE_FILES += softdevice_handler.c # need custome defined assert_nrf_callback() + +# nrf_delay +# C_SOURCE_FILES += nrf_delay.c + +# nrf_assert +# C_SOURCE_FILES += nrf_assert.c + +# nrf_ecb +# C_SOURCE_FILES += nrf_ecb.c + +# nrf_nvmc +# C_SOURCE_FILES += nrf_nvmc.c + +# nrf_soc +# C_SOURCE_FILES += nrf_soc.c + +# spi_master +# C_SOURCE_FILES += spi_master.c + +# spi_slave +# C_SOURCE_FILES += spi_slave.c + +# twi_master +# C_SOURCE_FILES += twi_hw_master.c +# C_SOURCE_FILES += twi_sw_master.c + +# simple_uart +# C_SOURCE_FILES += simple_uart.c + +# sd_common +# C_SOURCE_FILES += softdevice_handler.c + +# app_common +# C_SOURCE_FILES += app_button.c +# C_SOURCE_FILES += app_fifo.c +# C_SOURCE_FILES += app_gpiote.c +# C_SOURCE_FILES += app_scheduler.c +# C_SOURCE_FILES += app_timer.c +# C_SOURCE_FILES += app_trace.c +# C_SOURCE_FILES += app_uart.c +# C_SOURCE_FILES += app_uart_fifo.c +# C_SOURCE_FILES += crc16.c +# C_SOURCE_FILES += hci_mem_pool.c +# C_SOURCE_FILES += hci_slip.c +# C_SOURCE_FILES += hci_transport.c +# C_SOURCE_FILES += pstorage.c # need pstorage_platform.h + +# ble +# C_SOURCE_FILES += ble_advdata.c +# C_SOURCE_FILES += ble_advdata_parser.c +# C_SOURCE_FILES += ble_conn_params.c +# C_SOURCE_FILES += ble_debug_assert_handler.c +# C_SOURCE_FILES += ble_dtm.c +# C_SOURCE_FILES += ble_error_log.c +# C_SOURCE_FILES += ble_flash.c +# C_SOURCE_FILES += ble_racp.c +# C_SOURCE_FILES += ble_radio_notification.c +# C_SOURCE_FILES += ble_sensorsim.c + +# ble/ble_services +# C_SOURCE_FILES += ble_ans_c.c +# C_SOURCE_FILES += ble_bas.c +# C_SOURCE_FILES += ble_bps.c +# C_SOURCE_FILES += ble_cscs.c +# C_SOURCE_FILES += ble_dfu.c +# C_SOURCE_FILES += ble_dis.c +# C_SOURCE_FILES += ble_gls.c +# C_SOURCE_FILES += ble_gls_db.c +# C_SOURCE_FILES += ble_hids.c +# C_SOURCE_FILES += ble_hrs.c +# C_SOURCE_FILES += ble_hts.c +# C_SOURCE_FILES += ble_ias.c +# C_SOURCE_FILES += ble_ias_c.c +# C_SOURCE_FILES += ble_lls.c +# C_SOURCE_FILES += ble_rscs.c +# C_SOURCE_FILES += ble_sc_ctrlpt.c +# C_SOURCE_FILES += ble_srv_common.c +# C_SOURCE_FILES += ble_tps.c + +# ble/device_manager/experimental +# C_SOURCE_FILES += device_manager_central.c + +OUTPUT_FILENAME := main + +include $(TEMPLATE_PATH)/Makefile.common + diff --git a/Makefile.windows b/Makefile.windows index ed8d0c4..533cbb6 100644 --- a/Makefile.windows +++ b/Makefile.windows @@ -1,10 +1,10 @@ -ifeq ($(findstring 86, $(ProgramFiles)), ) - PROGFILES := C:/Program Files -else - PROGFILES := C:/Program Files (x86) -endif - -GNU_INSTALL_ROOT := $(PROGFILES)/GNU Tools ARM Embedded/4.7 2013q1 -GNU_VERSION := 4.7.3 -GNU_PREFIX := arm-none-eabi - +ifeq ($(findstring 86, $(ProgramFiles)), ) + PROGFILES := C:/Program Files +else + PROGFILES := C:/Program Files (x86) +endif + +GNU_INSTALL_ROOT := $(PROGFILES)/GNU Tools ARM Embedded/4.7 2013q1 +GNU_VERSION := 4.7.3 +GNU_PREFIX := arm-none-eabi + -- cgit v1.2.3