Skip to content

Commit

Permalink
[adaptive debug option] stlink and cmsis-dap
Browse files Browse the repository at this point in the history
  • Loading branch information
jia-xie committed Apr 5, 2024
1 parent aa3b2b6 commit 660bcd2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
22 changes: 11 additions & 11 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
}
}
},
{
"label": "flash (Darwin)",
"type": "shell",
"command": "mingw32-make -j24 V=1; mingw32-make download",
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "build (Windows)",
"type": "shell",
Expand Down Expand Up @@ -54,18 +63,9 @@
"problemMatcher": []
},
{
"label": "download dap (Windows)",
"type": "shell",
"command": "mingw32-make -j24 V=1; mingw32-make download_dap",
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "download stlink (Windows)",
"label": "flash (Windows)",
"type": "shell",
"command": "mingw32-make -j24 V=1; mingw32-make download_stlink",
"command": "mingw32-make -j24 V=1; mingw32-make download_powershell",
"group": {
"kind": "build",
"isDefault": false
Expand Down
34 changes: 30 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,35 @@ clean:
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)

download_dap:
openocd -f config/openocd_cmsis_dap.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).bin 0x08000000" -c reset -c shutdown
#######################################
# download task
#######################################

# Windows (Powershell)
ECHO_WARNING_POWERSHELL=powershell Write-Host -ForegroundColor Yellow [Message from Jason]:
ECHO_SUCCESS_POWERSHELL=powershell Write-Host -ForegroundColor Green [Success]

download_powershell:
@echo "Attempting to use CMSIS-DAP..."
@openocd -f config/openocd_cmsis_dap.cfg -c init -c halt -c "program $(BUILD_DIR)/$(TARGET).bin 0x08000000 verify reset" -c "reset run" -c shutdown && \
($(ECHO_SUCCESS_POWERSHELL) "Successfully programmed the device using CMSIS-DAP.") || \
($(ECHO_WARNING_POWERSHELL) "Failed to connect using CMSIS-DAP. Attempting to use STLink..." && \
openocd -f config/openocd_stlink.cfg -c init -c halt -c "program $(BUILD_DIR)/$(TARGET).bin 0x08000000 verify reset" -c "reset run" -c shutdown && \
($(ECHO_SUCCESS_POWERSHELL) "Successfully programmed the device using STLink.") || \
($(ECHO_WARNING_POWERSHELL) "Failed to connect using both CMSIS-DAP and STLink. Please check your connections and try again."))


# Unix-Like (Linux, MacOS)
ECHO_WARNING=@echo -e "\033[33m[Warning]\033[0m"
ECHO_SUCCESS=@echo -e "\033[32m[Success]\033[0m"

download:
@echo "Attempting to use CMSIS-DAP..."
@openocd -d2 -f config/openocd_cmsis_dap.cfg -c init -c halt -c "program $(BUILD_DIR)/$(TARGET).bin 0x08000000 verify reset" -c "reset run" -c shutdown && \
($(ECHO_SUCCESS) "Successfully programmed the device using CMSIS-DAP.") || \
($(ECHO_WARNING) "Failed to connect using CMSIS-DAP. Attempting to use STLink..." && \
openocd -d2 -f config/openocd_stlink.cfg -c init -c halt -c "program $(BUILD_DIR)/$(TARGET).bin 0x08000000 verify reset" -c "reset run" -c shutdown && \
($(ECHO_SUCCESS) "Successfully programmed the device using STLink.") || \
($(ECHO_WARNING) "Failed to connect using both CMSIS-DAP and STLink. Please check your connections and try again."))

download_stlink:
openocd -f config/openocd_stlink.cfg -c init -c halt -c "flash write_image erase $(BUILD_DIR)/$(TARGET).bin 0x08000000" -c reset -c shutdown
# *** EOF ***
4 changes: 2 additions & 2 deletions src/app/src/debug_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ extern Daemon_Instance_t *g_daemon_instances[3];
void Debug_Task_Loop(void)
{
static uint32_t counter = 0;
// DEBUG_PRINTF(&huart6, "time=%.1f,a=%d,b=%d,c=%f,d=%d\r\n", (float) counter / 1000.0f * DEBUG_PERIOD,
// g_daemon_instances[1]->counter, g_daemon_instances[0]->counter, g_imu.deg.roll, counter);
DEBUG_PRINTF(&huart6, "time=%.1f,a=%d,b=%d,c=%f,d=%d\r\n", (float) counter / 1000.0f * DEBUG_PERIOD,
2, 12, g_imu.deg.roll, counter);
counter++;
if (counter > 0xFFFFFFFF) {
counter = 0;
Expand Down

0 comments on commit 660bcd2

Please sign in to comment.