aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-05-31 18:49:50 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-05-31 18:49:50 +0200
commit67bf9dbc5262619128bb28c5e7726282e1f26aa0 (patch)
tree2ceb4e773966f06263f5bf9a27640a6a1555f894
parent00c0e221b77e658b0360dc18f15efbbc8085a6ec (diff)
downloadnrf51822-posix-build-scripts-master.tar.gz
nrf51822-posix-build-scripts-master.tar.bz2
nrf51822-posix-build-scripts-master.tar.xz
nrf51822-posix-build-scripts-master.zip
o Better flashing technique.HEADmaster
-rw-r--r--Makefile.common56
1 files changed, 38 insertions, 18 deletions
diff --git a/Makefile.common b/Makefile.common
index 66f3b4e..3a10fc2 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -26,6 +26,9 @@ SDK_SOURCE_PATH ?= $(SDK_PATH)/Source
# TEMPLATE_PATH += $(SDK_SOURCE_PATH)/templates/gcc
OUTPUT_BINARY_DIRECTORY := build
+# Modern (> 4.98?) exits with 0 on success
+JLINK_OUTPUT ?= 0
+
ifeq ($(OS),Windows_NT)
include $(TEMPLATE_PATH)/Makefile.windows
else
@@ -78,7 +81,7 @@ FLASHER := JLink
# Toolchain commands
#JLINK := JLinkExe -Device nrf51822 -speed 100 -if swd
-JLINK := JLinkExe -speed 100 -if swd
+JLINK := JLinkExe -device nrf51822 -speed 1000 -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
@@ -301,18 +304,23 @@ 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 "CPU: $(CPU)"
+ @echo "DEVICE: $(DEVICE)"
+ @echo "BOARD: $(BOARD)"
+ @echo "TARGET_CHIP: $(TARGET_CHIP)"
+ @echo "STARTADDRESS: $(STARTADDRESS)"
+ @echo CFLAGS:
+ @$(foreach X,$(CFLAGS), echo " $(X)";)
+ @echo LDFLAGS:
+ @$(foreach X,$(LDFLAGS), echo " $(X)";)
+ @echo C_OBJECTS:
+ @$(foreach X,$(C_OBJECTS), echo " $(X)";)
@echo C_SOURCE_FILES:
- @echo $(C_SOURCE_FILES) | tr ' ' '\n'
+ @$(foreach X,$(C_SOURCE_FILES), echo " $(X)";)
@echo C_SOURCE_PATHS:
- @echo $(C_SOURCE_PATHS) | tr ' ' '\n'
+ @$(foreach X,$(C_SOURCE_PATHS), echo " $(X)";)
@echo INCLUDEPATHS:
- @echo $(INCLUDEPATHS) | tr ' ' '\n'
+ @$(foreach X,$(INCLUDEPATHS), echo " $(X)";)
## Create build directories
$(BUILD_DIRECTORIES):
@@ -334,7 +342,7 @@ $(OBJECT_DIRECTORY)/%.o: %.s
## 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 $@ $^
+ $(CC) $(LDFLAGS) -o $@ $^
## Create binary .bin file from the .out file
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
@@ -346,11 +354,14 @@ $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$(
## Default build target
.PHONY: all
-all: debug
+all: debug $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).dump
clean:
$(RM) $(OUTPUT_BINARY_DIRECTORY)
+%.dump: %.out
+ $(OBJDUMP) -d $< > $@
+
# 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
@@ -413,7 +424,7 @@ q \n\
> $@
erase_all: $(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink
- $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink; [ "$$?" -eq 1 ]
+ $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/erase_all.jlink; [ "$$?" -eq $(JLINK_OUTPUT) ]
$(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink: $(BUILD_DIRECTORIES)
@echo " \n\
@@ -435,9 +446,9 @@ 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 ]
+ $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/flash_softdevice.jlink; [ "$$?" -eq $(JLINK_OUTPUT) ]
-$(OUTPUT_BINARY_DIRECTORY)/flash.jlink: $(BUILD_DIRECTORIES) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
+$(OUTPUT_BINARY_DIRECTORY)/flash2.jlink: $(BUILD_DIRECTORIES) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
@echo " \n\
r \n\
h \n\
@@ -450,7 +461,7 @@ w4 0x4001e504,2 # enable erase \n\
page=0; \
while [ $$binsize -gt 0 ]; \
do \
- echo "w4 0x4001e508, $$starthexaddr # start erasing code region 1 page $$page\n" >> $@ ; \
+ echo "w4 0x4001e508, $$starthexaddr # start erasing code region 1 page $$page" >> $@ ; \
binsize=`expr $$binsize - 1024`; \
page=`expr $$page + 1`; \
startaddr=`expr $$startaddr + 1024`; \
@@ -466,8 +477,17 @@ g \n\
qc \n\
" >> $@
+$(OUTPUT_BINARY_DIRECTORY)/flash.jlink: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin | $(BUILD_DIRECTORIES)
+ echo "w4 0x4001e504,1 # enable write \n\
+loadbin \"$<\", $(STARTADDRESS)\n\
+verifybin \"$<\", $(STARTADDRESS)\n\
+r \n\
+g \n\
+qc \n\
+" >> $@
+
flash: $(OUTPUT_BINARY_DIRECTORY)/flash.jlink
- $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/flash.jlink; [ "$$?" -eq 1 ]
+ $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/flash.jlink; [ "$$?" -eq $(JLINK_OUTPUT) ]
$(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink: $(BUILD_DIRECTORIES)
@echo "\n\
@@ -480,7 +500,7 @@ $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink: $(BUILD_DIRECTORIES)
" > $@
pin-reset: $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink
- $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink; [ "$$?" -eq 1 ]
+ $(JLINK) -CommanderScript $(OUTPUT_BINARY_DIRECTORY)/pinreset.jlink; [ "$$?" -eq $(JLINK_OUTPUT) ]
START_GDB_SERVER_SCRIPT=$(OUTPUT_BINARY_DIRECTORY)/start_gdbserver.sh
$(START_GDB_SERVER_SCRIPT): $(BUILD_DIRECTORIES)