Skip to content

Commit

Permalink
vscode: added STLink and JLink debug setups
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Jul 22, 2024
1 parent 0c64799 commit 9c8e4a9
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 336 deletions.
37 changes: 32 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,46 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// STLink configuration
{
"name": "AM32 STLink",
"cwd": "${workspaceFolder}",
"executable": "${workspaceFolder}/obj/debug.elf",
"liveWatch": {
"enabled": true,
"samplesPerSecond": 4,
},
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"configFiles": [
"${workspaceFolder}/tools/openocd-at32f421.cfg",
],
"showDevDebugOutput": "none",

"serverpath": "${workspaceFolder}${/}tools${/}${config:OS}${/}openocd${/}bin${/}openocd",
"armToolchainPath": "${workspaceRoot}/tools/${config:OS}/xpack-arm-none-eabi-gcc-10.3.1-2.3/bin",
},

// JLink configuration
{
"type": "cortex-debug",
"request": "launch",
"name": "AM32 Build/Debug",
"name": "AM32 JLink",
"cwd": "${workspaceRoot}",
"executable": "${workspaceRoot}/obj/AM32_FOXEER_F421_2.12.elf",
"gdbTarget": ":3333",
"showDevDebugOutput": "none",
"servertype" : "external",
"device" : "-AT32F421K8U7",
"gdbPath": "${workspaceRoot}/tools/${config:OS}/xpack-arm-none-eabi-gcc-10.3.1-2.3/bin/arm-none-eabi-gdb",
"executable": "${workspaceRoot}/obj/debug.elf",
"showDevDebugOutput": "raw",
"servertype" : "jlink",
"swoConfig": {
"enabled": false,
},
"serialNumber": "",
"liveWatch": {
"enabled": true,
"samplesPerSecond": 4
}
}
]
}
24 changes: 12 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"makefile.makePath": "/usr/bin/make",
"makefile.launchConfigurations": [
"OS": "windows",
"makefile.makePath": "tools/windows/make/bin/make.exe",

//"OS": "linux",
//"makefile.makePath": "/usr/bin/make",

"makefile.configurations": [
{
"cwd": "/home/tridge/project/UAV/AM32/AM32",
"name": "Make Clean",
"request": "launch",
"type": "cppdbg",
"program": "${workspaceFolder}/Makefile",
"args": [
"clean"
],
"stopAtEntry": false,
"externalConsole": false
"name": "MakeParallel",
"makeArgs": [
"-j8"
]
}
]
}
}
31 changes: 18 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

QUIET = @

# update version numbers here
Expand Down Expand Up @@ -48,19 +49,18 @@ ROOT := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
# Search source files
SRC_COMMON := $(foreach dir,$(SRC_DIRS_COMMON),$(wildcard $(dir)/*.[cs]))

VERSION_MAJOR := $(shell grep "#define VERSION_MAJOR" $(MAIN_SRC_DIR)/main.c | awk '{print $$3}' )
VERSION_MINOR := $(shell grep "#define VERSION_MINOR" $(MAIN_SRC_DIR)/main.c | awk '{print $$3}' )

FIRMWARE_VERSION := $(VERSION_MAJOR).$(VERSION_MINOR)

TARGET_BASENAME = $(BIN_DIR)/$(IDENTIFIER)_$(TARGET)_$(FIRMWARE_VERSION)
TARGET_FNAME = $(IDENTIFIER)_$(TARGET)_$(FIRMWARE_VERSION)
TARGET_BASENAME = $(BIN_DIR)/$(TARGET_FNAME)

# Build tools, so we all share the same versions
# import macros common to all supported build systems
include $(ROOT)/make/system-id.mk
# include $(ROOT)/make/system-id.mk

# configure some directories that are relative to wherever ROOT_DIR is located
BIN_DIR := $(ROOT)/obj
OBJ := obj
BIN_DIR := $(ROOT)/$(OBJ)

TOOLS_DIR ?= $(ROOT)/tools
DL_DIR := $(ROOT)/downloads
Expand All @@ -74,10 +74,17 @@ e230 : $(TARGETS_E230)
f421 : $(TARGETS_F421)
f415 : $(TARGETS_F415)

$(OBJ):
@$(MKDIR) $(OBJ) > $(NUL)

clean :
rm -rf $(BIN_DIR)/*
@echo "Removing $(OBJ) directory"
@$(RMDIR) $(OBJ)

binary : $(TARGET_BASENAME).bin
# we copy debug.elf to give us a constant debug target for vscode
# this means the debug button will always debug the last target built
@$(COPY) $(OBJ)$(DSEP)$(TARGET_FNAME).elf $(OBJ)$(DSEP)debug.elf > $(NUL)
@$(ECHO) done $(TARGET)

$(TARGETS_F051) :
Expand All @@ -99,13 +106,11 @@ $(TARGETS_F415) :
@$(MAKE) -s MCU_TYPE=F415 TARGET=$@ binary

# Compile target
$(TARGET_BASENAME).elf: SRC := $(SRC_COMMON) $(SRC_$(MCU_TYPE))
$(TARGET_BASENAME).elf: CFLAGS := $(MCU_$(MCU_TYPE)) $(CFLAGS_$(MCU_TYPE)) $(CFLAGS_COMMON)
$(TARGET_BASENAME).elf: LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_$(MCU_TYPE)) -T$(LDSCRIPT_$(MCU_TYPE))
$(TARGET_BASENAME).elf: $(SRC)
$(TARGET_BASENAME).elf: $(SRC_COMMON) $(SRC_$(MCU_TYPE)) $(OBJ)
@$(ECHO) Compiling $(notdir $@)
$(QUIET)mkdir -p $(dir $@)
$(QUIET)$(CC) $(CFLAGS) $(LDFLAGS) -MMD -MP -MF $(@:.elf=.d) -o $(@) $(SRC)
$(QUIET)$(CC) $(CFLAGS) $(LDFLAGS) -MMD -MP -MF $(@:.elf=.d) -o $(@) $(SRC_COMMON) $(SRC_$(MCU_TYPE))

# Generate bin and hex files
$(TARGET_BASENAME).bin: $(TARGET_BASENAME).elf
Expand All @@ -115,10 +120,10 @@ $(TARGET_BASENAME).bin: $(TARGET_BASENAME).elf

# mkdirs
$(DL_DIR):
$(QUIET)mkdir -p $@
$(QUIET)$(MKDIR) $@

$(TOOLS_DIR):
$(QUIET)mkdir -p $@
$(QUIET)$(MKDIR) $@

# include the tools makefile
include $(ROOT)/make/tools.mk
Expand Down
2 changes: 1 addition & 1 deletion Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2263,4 +2263,4 @@ void assert_failed(uint8_t* file, uint32_t line)
line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
#endif /* USE_FULL_ASSERT */
Loading

0 comments on commit 9c8e4a9

Please sign in to comment.