PROJ_DIR := . COMPONENT_DIR := $(PROJ_DIR)/components SRC_DIR := $(PROJ_DIR)/main SDK_ROOT := $(PROJ_DIR)/nrf_sdk_zigbee SDK_VERSION := $(shell sed -n '1p' $(SDK_ROOT)/documentation/release_notes.txt | egrep -o "([0-9]+\.[0-9]+\.[0-9]+)") PROJECT_NAME := $(shell basename "$(realpath $(PROJ_DIR))") OUTPUT_DIRECTORY := _build DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d") TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1) TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true) COMMIT := $(shell git rev-parse --short HEAD) VERSION := $(TAG:v%=%) ifeq ($(VERSION),) VERSION := $(COMMIT) else ifneq ($(COMMIT), $(TAG_COMMIT)) VERSION := $(VERSION)-next-$(COMMIT) endif endif ifneq ($(shell git status --porcelain --ignore-submodules),) VERSION := $(VERSION)-dirty endif NRF_IC := nrf52833 IC_NUM := $(shell echo ${NRF_IC} | egrep -o "([0-9]+)") TARGETS := nrf52833_xxaa TARGET_RELEASE := $(TARGETS)_release TARGET_DEBUG := $(TARGETS)_debug # Print some helpful info about what the user is compiling for space := space += $(info BUILD OPTIONS:) $(info $(space) Project name $(PROJECT_NAME)) $(info $(space) SDK version $(SDK_VERSION)) $(info $(space) App version $(VERSION)) $(info $(space) Chip $(NRF_IC)) $(info $(space) Date $(DATE)) $(info $(space) Make Type $(MAKECMDGOALS)) $(info $(space)) $(OUTPUT_DIRECTORY)/$(TARGET_RELEASE).out: \ LINKER_SCRIPT := smarthome_gcc_nrf52833.ld $(OUTPUT_DIRECTORY)/$(TARGET_DEBUG).out: \ LINKER_SCRIPT := smarthome_gcc_nrf52833_noboot.ld # Source files common to all targets SRC_FILES += \ $(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_$(NRF_IC).S \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_rtt.c \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_serial.c \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_backend_uart.c \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_default_backends.c \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \ $(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \ $(SDK_ROOT)/external/zboss/src/commissioning/bdb/bdb_finding_binding.c \ $(SDK_ROOT)/external/zboss/osif/zb_nrf52_common.c \ $(SDK_ROOT)/external/zboss/osif/zb_nrf52_nrf_logger.c \ $(SDK_ROOT)/external/zboss/osif/zb_nrf52_logger.c \ $(SDK_ROOT)/external/zboss/osif/zb_nrf52_nvram.c \ $(SDK_ROOT)/external/zboss/osif/zb_nrf52_timer.c \ $(SDK_ROOT)/external/zboss/osif/zb_nrf52_transceiver.c \ $(SDK_ROOT)/components/libraries/button/app_button.c \ $(SDK_ROOT)/components/libraries/util/app_error.c \ $(SDK_ROOT)/components/libraries/util/app_error_handler_gcc.c \ $(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c \ $(SDK_ROOT)/components/libraries/util/app_error_weak.c \ $(SDK_ROOT)/components/libraries/timer/app_timer2.c \ $(SDK_ROOT)/components/libraries/util/app_util_platform.c \ $(SDK_ROOT)/components/libraries/assert/assert.c \ $(SDK_ROOT)/components/libraries/util/nrf_assert.c \ $(SDK_ROOT)/components/libraries/timer/drv_rtc.c \ $(SDK_ROOT)/components/libraries/atomic_fifo/nrf_atfifo.c \ $(SDK_ROOT)/components/libraries/atomic/nrf_atomic.c \ $(SDK_ROOT)/components/libraries/balloc/nrf_balloc.c \ $(SDK_ROOT)/external/fprintf/nrf_fprintf.c \ $(SDK_ROOT)/external/fprintf/nrf_fprintf_format.c \ $(SDK_ROOT)/external/zboss/src/zcl/ha_sas.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_alarms_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_attr_value.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_basic_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_binary_input.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_c_daily_schedule.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_c_drlc.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_c_messaging.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_c_metering.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_c_price.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_c_wwah.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_color_control_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_common.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_continuous_value_change_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_control4_networking.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_dehumid_control.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_diagnostics_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_door_lock.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_el_measurement.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_en50523_appliance_events_and_alerts.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_fan_control.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_general_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_groups.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_ias_ace_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_ias_wd_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_ias_zone_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_identify_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_illuminance_measurement.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_level_control_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_main.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_meter_identification.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_nvram.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_occupancy_sensing_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_on_off_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_on_off_switch_config.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_ota_upgrade_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_ota_upgrade_common.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_ota_upgrade_minimal.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_ota_upgrade_srv_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_poll_control_client.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_poll_control_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_power_config_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_pressure_measurement.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_rel_humidity.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_reporting.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_s_daily_schedule.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_s_drlc.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_s_messaging.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_s_metering.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_s_price.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_s_wwah.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_scenes.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_shade_config_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_temp_measurement.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_thermostat_commands.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_thermostat_ui_config.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_time.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_window_covering.c \ $(SDK_ROOT)/external/zboss/src/zcl/zcl_wwah_common.c \ $(SDK_ROOT)/external/zboss/src/commissioning/bdb/zdo_commissioning_bdb.c \ $(SDK_ROOT)/external/zboss/src/commissioning/bdb/zdo_commissioning_bdb_formation.c \ $(SDK_ROOT)/external/zboss/src/commissioning/legacy/zdo_commissioning_classic.c \ $(SDK_ROOT)/components/libraries/experimental_section_vars/nrf_section_iter.c \ $(SDK_ROOT)/external/zboss/src/zb_error/zb_error_to_string.c \ $(SDK_ROOT)/components/libraries/fstorage/nrf_fstorage.c \ $(SDK_ROOT)/components/libraries/fstorage/nrf_fstorage_nvmc.c \ $(SDK_ROOT)/components/libraries/memobj/nrf_memobj.c \ $(SDK_ROOT)/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c \ $(SDK_ROOT)/components/libraries/queue/nrf_queue.c \ $(SDK_ROOT)/components/libraries/ringbuf/nrf_ringbuf.c \ $(SDK_ROOT)/components/libraries/serial/nrf_serial.c \ $(SDK_ROOT)/components/libraries/sortlist/nrf_sortlist.c \ $(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \ $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_twi.c \ $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_clock.c \ $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_power.c \ $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_rng.c \ $(SDK_ROOT)/integration/nrfx/legacy/nrf_drv_uart.c \ $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c \ $(SDK_ROOT)/modules/nrfx/hal/nrf_nvmc.c \ $(SDK_ROOT)/modules/nrfx/hal/nrf_ecb.c \ $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c \ $(SDK_ROOT)/modules/nrfx/soc/nrfx_atomic.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_gpiote.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_power.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_rng.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_twi.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_twim.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_systick.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_timer.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_wdt.c \ $(SDK_ROOT)/components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c \ $(SDK_ROOT)/components/libraries/hardfault/hardfault_implementation.c \ $(SRC_DIR)/main.c \ $(SRC_DIR)/config.c \ $(SRC_DIR)/periph_monitor.c \ $(SRC_DIR)/zigbee_touch_switch.c \ $(SRC_DIR)/zigbee_ss_led_driver_cluster.c \ $(SRC_DIR)/zigbee_led_driver.c \ $(SRC_DIR)/zigbee_custom_cluster_touch.c\ $(SRC_DIR)/zb_gateway_error_handler.c\ $(SRC_DIR)/zigbee_curtain_cluster.c\ $(SRC_DIR)/periph_curtain.c \ $(SRC_DIR)/zb_zcl_analog_output.c \ $(SDK_ROOT)/components/libraries/fds/fds.c \ $(SDK_ROOT)/components/libraries/crc16/crc16.c \ $(COMPONENT_DIR)/nrf_peripherals/nrf_fds_storage.c \ $(COMPONENT_DIR)/nrf_peripherals/periph_touch/periph_touch.c \ $(COMPONENT_DIR)/nrf_peripherals/periph_touch/touch_lib/sx9500/sx9500.c \ $(COMPONENT_DIR)/nrf_peripherals/periph_touch/touch_lib/sx8636/sx8636.c \ $(COMPONENT_DIR)/nrf_peripherals/periph_pwm/periph_pwm.c \ $(COMPONENT_DIR)/nrf_peripherals/periph_adc/periph_adc.c \ $(COMPONENT_DIR)/nrf_peripherals/periph_button/periph_button.c \ $(COMPONENT_DIR)/zigbee_mesh/zigbee_mesh.c \ $(COMPONENT_DIR)/zigbee_mesh/zigbee_helper.c \ $(COMPONENT_DIR)/zigbee_mesh/zigbee_attr_report.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_pwm.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_ppi.c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_saadc.c \ $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \ $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \ $(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \ $(SDK_ROOT)/modules/nrfx/mdk/system_$(NRF_IC).c \ $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_qdec.c \ # Include folders common to all targets INC_FOLDERS += \ $(SDK_ROOT)/external/zboss/osif \ $(SDK_ROOT)/integration/nrfx \ $(SDK_ROOT)/components/libraries/low_power_pwm \ $(SRC_DIR) \ $(SRC_DIR)/include \ $(SDK_ROOT)/components/libraries/fds \ $(SDK_ROOT)/components/libraries/crc16 \ $(SDK_ROOT)/external/nRF-IEEE-802.15.4-radio-driver/src \ $(SDK_ROOT)/components/libraries/scheduler \ $(SDK_ROOT)/components/libraries/experimental_section_vars \ $(SDK_ROOT)/components/libraries/atomic_fifo \ $(SDK_ROOT)/modules/nrfx/mdk \ $(SDK_ROOT)/components/libraries/queue \ $(SDK_ROOT)/components/libraries/strerror \ $(SDK_ROOT)/components/libraries/serial \ $(SDK_ROOT)/components/zigbee/common \ $(SDK_ROOT)/external/nRF-IEEE-802.15.4-radio-driver/src/fem \ $(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \ $(SDK_ROOT)/integration/nrfx/legacy \ $(SDK_ROOT)/components/libraries/button \ $(SDK_ROOT)/components/libraries/log \ $(SDK_ROOT)/modules/nrfx/hal \ $(SDK_ROOT)/components/libraries/log/src \ $(SDK_ROOT)/components/libraries/sortlist \ $(SDK_ROOT)/modules/nrfx/drivers/include \ $(SDK_ROOT)/external/zboss/include \ $(SDK_ROOT)/external/zboss/include/zcl \ $(SDK_ROOT)/components/libraries/ringbuf \ $(PROJ_DIR)/config \ $(SDK_ROOT)/external/fprintf \ $(SDK_ROOT)/components/libraries/balloc \ $(SDK_ROOT)/components/libraries/util \ $(SDK_ROOT)/modules/nrfx \ $(SDK_ROOT)/components \ $(SDK_ROOT)/external/segger_rtt \ $(SDK_ROOT)/components/libraries/memobj \ $(SDK_ROOT)/external/zboss/src/zb_error \ $(SDK_ROOT)/external/nRF-IEEE-802.15.4-radio-driver/src/fem/three_pin_gpio \ $(SDK_ROOT)/components/libraries/atomic \ $(SDK_ROOT)/external/zboss/include/ha \ $(SDK_ROOT)/external/zboss/src/zb_error \ $(SDK_ROOT)/external/zboss/src/include \ $(SDK_ROOT)/external/zboss/include/osif \ $(SDK_ROOT)/components/libraries/delay \ $(SDK_ROOT)/components/toolchain/cmsis/include \ $(SDK_ROOT)/external/zboss/include/addons \ $(SDK_ROOT)/components/libraries/mutex \ $(SDK_ROOT)/components/libraries/pwr_mgmt \ $(SDK_ROOT)/components/libraries/fstorage \ $(SDK_ROOT)/components/libraries/timer \ $(COMPONENT_DIR)/nrf_peripherals/include \ $(COMPONENT_DIR)/nrf_peripherals/periph_touch/include \ $(COMPONENT_DIR)/nrf_peripherals/periph_touch/touch_lib/sx8636 \ $(COMPONENT_DIR)/nrf_peripherals/periph_touch/touch_lib/sx9500 \ $(COMPONENT_DIR)/nrf_peripherals/periph_pwm/include \ $(COMPONENT_DIR)/nrf_peripherals/periph_button/include \ $(COMPONENT_DIR)/nrf_peripherals/periph_adc/include \ $(COMPONENT_DIR)/zigbee_mesh/include \ $(SDK_ROOT)/components/libraries/hardfault/nrf52 \ $(SDK_ROOT)/components/libraries/hardfault \ # Libraries common to all targets LIB_FILES += \ $(SDK_ROOT)/external/zboss/lib/gcc/libzboss.a \ $(SDK_ROOT)/external/zboss/lib/gcc/$(NRF_IC)/nrf_radio_driver.a \ $(SDK_ROOT)/external/zboss/lib/gcc/libgppb.a \ # Optimization flags OPT = -O0 -ggdb3 # Uncomment the line below to enable link time optimization #OPT += -flto # To make SEGGER RTT retarget to printf correctly, you need to get around # the silly ANSI C compatibility stuff that breaks our GCC builds PARAMS_DEFINE = -D_PARAMS\(paramlist\)=paramlist # C flags common to all targets CFLAGS += $(OPT) CFLAGS += $(PARAMS_DEFINE) CFLAGS += -DPROJECT_NAME=\"$(PROJECT_NAME)\" CFLAGS += -DPROJECT_VERSION=\"$(VERSION)\" CFLAGS += -DUSE_APP_CONFIG CFLAGS += -DAPP_TIMER_V2 CFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED CFLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS CFLAGS += -DCONFIG_ZIGBEE_ERROR_TO_STRING_ENABLED CFLAGS += -DFLOAT_ABI_HARD CFLAGS += -DLIBZBOSS_CONFIG_FILE=\"libzboss_config.h\" CFLAGS += -DNRF$(IC_NUM)_XXAA CFLAGS += -DZBOSS_BUILD CFLAGS += -DZB_NRF_INTERNAL #CFLAGS += -DZB_ROUTER_NO_ED CFLAGS += -DZB_NVRAM_FLASH_AUTO_ADDRESS CFLAGS += -DZB_ZCL_SCENES_OPTIONAL_COMMANDS_DISABLED CFLAGS += -DZB_ZCL_USE_ZCL7_AS_DEFAULT_REVISION #CFLAGS += -DZB_TRACE_LEVEL=0 #CFLAGS += -DZB_TRACE_MASK=0 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 -Wno-packed-bitfield-compat CFLAGS += -Wno-error=unused-variable CFLAGS += -Wno-error=unused-function # C++ flags common to all targets CXXFLAGS += $(OPT) # Assembler flags common to all targets ASMFLAGS += -ggdb3 ASMFLAGS += -mcpu=cortex-m4 ASMFLAGS += -mthumb -mabi=aapcs ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 ASMFLAGS += -DAPP_TIMER_V2 #ASMFLAGS += -DZB_ROUTER_NO_ED ASMFLAGS += -DAPP_TIMER_V2_RTC1_ENABLED ASMFLAGS += -DFLOAT_ABI_HARD ASMFLAGS += -DLIBZBOSS_CONFIG_FILE=\"libzboss_config.h\" ASMFLAGS += -DNRF$(IC_NUM)_XXAA # 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 $(TARGET_RELEASE): CFLAGS += -D__HEAP_SIZE=8192 $(TARGET_RELEASE): CFLAGS += -D__STACK_SIZE=8192 $(TARGET_RELEASE): ASMFLAGS += -D__HEAP_SIZE=8192 $(TARGET_RELEASE): ASMFLAGS += -D__STACK_SIZE=8192 $(TARGET_DEBUG): CFLAGS += -DDEBUG $(TARGET_DEBUG): CFLAGS += -DDEBUG_NRF $(TARGET_DEBUG): CFLAGS += -D__HEAP_SIZE=8192 $(TARGET_DEBUG): CFLAGS += -D__STACK_SIZE=8192 $(TARGET_DEBUG): ASMFLAGS += -DDEBUG $(TARGET_DEBUG): ASMFLAGS += -DDEBUG_NRF $(TARGET_DEBUG): ASMFLAGS += -D__HEAP_SIZE=8192 $(TARGET_DEBUG): 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 -lstdc++ .PHONY: all release debug help # all targets all: release # release target release: $(TARGET_RELEASE) # debug target debug: $(TARGET_DEBUG) # Print all targets that can be built help: @echo "following targets are available:" @echo " all (default) - build all targets: release and debug" @echo " release - build $(TARGET_RELEASE)" @echo " debug - build $(TARGET_DEBUG)" @echo " clean - clean all targets" @echo " sdk_config - starting external tool for editing sdk_config.h" @echo " flash - flashing release binary" @echo " flash_debug - flashing debug binary" @echo "" TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc include $(TEMPLATE_PATH)/Makefile.common $(foreach target_release, $(TARGET_RELEASE), $(call define_target, $(target_release))) $(foreach target_debug, $(TARGET_DEBUG), $(call define_target, $(target_debug))) .PHONY: flash flash_debug erase # Flash the program flash_softdevice: nrfjprog -f nrf52 --program $(SDK_ROOT)/components/softdevice/s113/hex/s113_nrf52_7.0.1_softdevice.hex --sectorerase flash: release nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/$(TARGET_RELEASE).hex --sectorerase nrfjprog -f nrf52 --reset @make monitor # Flash the program flash_debug: debug @echo Flashing: $(OUTPUT_DIRECTORY)/$(TARGET_DEBUG).hex nrfjprog -f nrf52 --program $(OUTPUT_DIRECTORY)/$(TARGET_DEBUG).hex --sectorerase nrfjprog -f nrf52 --reset erase: nrfjprog -f nrf52 --eraseall reset: nrfjprog -f nrf52 --reset log: JLinkRTTViewer monitor: @echo "monitor" $(shell JLinkRTTViewerExe --device NRF52833_XXAA --interface swd --speed 4000 --connection usb --autoconnect) 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)