diff options
author | sprhawk <hongbo@yang.me> | 2014-09-01 15:10:09 +0800 |
---|---|---|
committer | sprhawk <hongbo@yang.me> | 2014-09-01 15:10:09 +0800 |
commit | 22a63ba4804c0903a6d8a31ec2fa85128659ebb4 (patch) | |
tree | e6196b0eb0c128f66e0232a4d37432c32b4dc5b7 | |
parent | adf5f50774809cb999146e94a4535a86f955bac5 (diff) | |
download | nrf51822-posix-build-scripts-22a63ba4804c0903a6d8a31ec2fa85128659ebb4.tar.gz nrf51822-posix-build-scripts-22a63ba4804c0903a6d8a31ec2fa85128659ebb4.tar.bz2 nrf51822-posix-build-scripts-22a63ba4804c0903a6d8a31ec2fa85128659ebb4.tar.xz nrf51822-posix-build-scripts-22a63ba4804c0903a6d8a31ec2fa85128659ebb4.zip |
add GDB/JLinkGDBServer support
-rw-r--r-- | Makefile.common | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/Makefile.common b/Makefile.common index 0841ff9..447cd45 100644 --- a/Makefile.common +++ b/Makefile.common @@ -124,12 +124,14 @@ vpath %.s $(ASSEMBLER_SOURCE_PATHS) -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: clean
+# release: OUTPUT_FILENAME:=$(OUTPUT_FILENAME)-release +release: clean
release: CFLAGS += -DNDEBUG -O3
release: ASMFLAGS += -DNDEBUG -O3
release: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
@@ -148,7 +150,7 @@ $(OBJECT_DIRECTORY)/%.o: %.c # Build header dependencies
$(CC) $(CFLAGS) $(INCLUDEPATHS) -M $< -MF "$(@:.o=.d)" -MT $@
# Do the actual compilation
- $(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
+ $(CC) $(CFLAGS) $(INCLUDEPATHS) -g -c -o $@ $<
## Assemble .s files
$(OBJECT_DIRECTORY)/%.o: %.s
@@ -168,7 +170,7 @@ $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$( ## Default build target
.PHONY: all
-all: clean release
+all: clean debug
clean:
$(RM) $(OUTPUT_BINARY_DIRECTORY)
@@ -268,9 +270,18 @@ $(START_GDB_SERVER_SCRIPT): $(BUILD_DIRECTORIES) gdbserver: $(START_GDB_SERVER_SCRIPT) /bin/sh $(START_GDB_SERVER_SCRIPT) -START_GDB_SCRIPT=$(OUTPUT_BINARY_DIRECTORY)/gdb.sh -$(START_GDB_SCRIPT): $(BUILD_DIRECTORIES) - echo 'arm-none-eabi-gdb -ex "target remote localhost:2331"' > $(START_GDB_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) -gdb: $(START_GDB_SCRIPT) - /bin/sh $(START_GDB_SCRIPT) +gdb: $(GDB_COMMAND_SCRIPT) debug + arm-none-eabi-gdb -x $(GDB_COMMAND_SCRIPT) |