From 9996a06796d5e422bce30ba94c0fb7b548a0c212 Mon Sep 17 00:00:00 2001 From: Emilio Corigliano <emilio.corigliano@skywarder.eu> Date: Wed, 1 Dec 2021 23:33:14 +0100 Subject: [PATCH] [SBS] fixed flashing for windows - detecting what flashing software exists and uses it to flash the binary - added to the tasks different building modes (debug or no debug) --- .vscode/tasks.json | 39 +++++++++++++++++++++++++++++++-------- sbs | 19 ++++++++++++++++--- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 8de106b4d..580e8f8c3 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -32,13 +32,24 @@ "problemMatcher": "$gcc" }, { - "label": "BUILD current-entrypoint", + "label": "BUILD current-entrypoint DEBUG", "type": "shell", "windows": { "command": "./sbs -d -b ${fileBasenameNoExtension}" }, "linux": { - "command": "./sbs -v -b ${fileBasenameNoExtension}" + "command": "./sbs -d -b ${fileBasenameNoExtension}" + }, + "problemMatcher": "$gcc" + }, + { + "label": "BUILD current-entrypoint NO DEBUG", + "type": "shell", + "windows": { + "command": "./sbs -b ${fileBasenameNoExtension}" + }, + "linux": { + "command": "./sbs -b ${fileBasenameNoExtension}" }, "problemMatcher": "$gcc" }, @@ -54,18 +65,30 @@ "problemMatcher": [] }, { - "label": "BUILD+RUN current-entrypoint", + "label": "BUILD+RUN current-entrypoint DEBUG", "type": "shell", "windows": { - "command": "ST-LINK_CLI.exe -P build/${fileBasenameNoExtension}.bin 0x8000000 -V -Rst" + "command": "./sbs -d -f ${fileBasenameNoExtension}" }, "linux": { - "command": "sleep 1;st-flash write build/${fileBasenameNoExtension}.bin 0x8000000" + "command": "./sbs -d -f ${fileBasenameNoExtension}" + }, + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "BUILD+RUN current-entrypoint NO DEBUG", + "type": "shell", + "windows": { + "command": "./sbs -f ${fileBasenameNoExtension}" + }, + "linux": { + "command": "./sbs -f ${fileBasenameNoExtension}" }, "problemMatcher": [], - "dependsOn": [ - "BUILD current-entrypoint" - ], "group": { "kind": "build", "isDefault": true diff --git a/sbs b/sbs index dee9fd248..4d1dd0e9f 100755 --- a/sbs +++ b/sbs @@ -40,8 +40,10 @@ EOF } find_deps() { - command -v ccache &> /dev/null && config_ccache=true - command -v ninja &> /dev/null && config_ninja=true + command -v ccache &> /dev/null && config_ccache=true + command -v ninja &> /dev/null && config_ninja=true + command -v st-flash &> /dev/null && config_stflash=true + command -v ST-LINK_CLI.exe &> /dev/null && config_stlink=true } print_found_deps() { @@ -103,7 +105,16 @@ flash() { if build "$1"; then echo if [ -f "$build_dir/$1.bin" ]; then - st-flash --reset write "$build_dir/$1.bin" 0x08000000 + printf "Flashing software: "; + [ "$config_stflash" = true ] && echo "st-flash" || ([ "$config_stlink" = true ] && echo "st-link" || "no") + + if [ "$config_stflash" = true ]; then + st-flash --reset write "$build_dir/$1.bin" 0x08000000 + elif [ "$config_stlink" = true ]; then + ST-LINK_CLI.exe -P "$build_dir/$1.bin" 0x8000000 -V -Rst + else + echo "Error: No flashing software found!" + fi else echo "Error: target '$1' is not flashable" fi @@ -180,6 +191,8 @@ config_ccache=false config_debug=false config_verbose=false config_ninja=false +config_stflash=false +config_stlink=false build_jobs= find_deps -- GitLab