Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support to choose between JLINK and BMP as programmers #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ PROJECT_NAME := ble_app_beacon_pca10040_s132
TARGETS := nrf52832_xxaa
OUTPUT_DIRECTORY := _build

#Either JLINK or BMP
DEBUGGER := BMP

ifeq ($(DEBUGGER),JLINK)
### JLink related stuff ###
NRFJPROG := nrfjprog
endif

ifeq ($(DEBUGGER),BMP)
### BMP related stuff ###
# Use relevant port like COM5 in Windows environment
BMP_PORT := /dev/ttyBmpGdb
#Install ARM GCC compiler
#https://launchpad.net/gcc-arm-embedded/+download
GDB := arm-none-eabi-gdb
endif

SDK_ROOT := ../../../../../../..
PROJ_DIR := ../../..

Expand Down Expand Up @@ -236,15 +253,34 @@ $(foreach target, $(TARGETS), $(call define_target, $(target)))

# Flash the program
flash: $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex
@echo Flashing: $<
nrfjprog --program $< -f nrf52 --sectorerase
nrfjprog --reset -f nrf52
@echo Flashing: $<; \
if [ "$(DEBUGGER)" = "JLINK" ]; then \
$(NRFJPROG) --program $< -f nrf52 --sectorerase; \
$(NRFJPROG) --reset -f nrf52; \
elif [ "$(DEBUGGER)" = "BMP" ]; then \
$(GDB) -q -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'compare-sections' -ex 'detach' -ex 'quit' $<; \
else\
echo "Use the DEBUGGER variable to specify the debugger to be used for uploading"; \
fi

# Flash softdevice
flash_softdevice:
@echo Flashing: s132_nrf52_3.0.0_softdevice.hex
nrfjprog --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_3.0.0_softdevice.hex -f nrf52 --sectorerase
nrfjprog --reset -f nrf52
@echo Flashing: s132_nrf52_3.0.0_softdevice.hex; \
if [ "$(DEBUGGER)" = "JLINK" ]; then\
$(NRFJPROG) --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_3.0.0_softdevice.hex -f nrf52 --sectorerase; \
$(NRFJPROG) --reset -f nrf52; \
elif [ "$(DEBUGGER)" = "BMP" ]; then \
$(GDB) -q -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'compare-sections' -ex 'detach' -ex 'quit' $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_3.0.0_softdevice.hex; \
else \
echo "Use the DEBUGGER variable to specify the debugger to be used for uploading"; \
fi

erase:
nrfjprog --eraseall -f nrf52
@if [ "$(DEBUGGER)" = "JLINK" ]; then\
$(NRFJPROG) --eraseall -f nrf52; \
elif [ "$(DEBUGGER)" = "BMP" ]; then \
$(GDB) -q -ex 'target extended-remote $(BMP_PORT)' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'mon erase_mass' -ex 'detach' -ex 'quit'; \
else\
echo "Use the DEBUGGER variable to specify the debugger to be used for the erase all operation"; \
fi