From f46a4174de7d300a1b95e029385a9de05aa796df 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 | 56 +++++++++++++++++++++++++++++++++++++--------- sbs | 19 +++++++++++++--- 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 86491abb4..580e8f8c3 100755 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -13,7 +13,7 @@ "label": "CLEAN", "type": "shell", "windows": { - "command": "sh sbs -c" + "command": "./sbs -c" }, "linux": { "command": "./sbs -c" @@ -32,13 +32,24 @@ "problemMatcher": "$gcc" }, { - "label": "BUILD current-entrypoint", + "label": "BUILD current-entrypoint DEBUG", "type": "shell", "windows": { - "command": "sh sbs -v -n -b ${fileBasenameNoExtension}" + "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" }, @@ -46,7 +57,7 @@ "label": "RUN current-entrypoint", "type": "shell", "windows": { - "command": "ST-LINK_CLI.exe -P bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.bin 0x8000000 -V -Rst" + "command": "ST-LINK_CLI.exe -P build/${fileBasenameNoExtension}.bin 0x8000000 -V -Rst" }, "linux": { "command": "st-flash write bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.bin 0x8000000" @@ -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 bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.bin 0x8000000 -V -Rst" + "command": "./sbs -d -f ${fileBasenameNoExtension}" }, "linux": { - "command": "sleep 1;st-flash write bin/${fileBasenameNoExtension}/${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 @@ -106,6 +129,17 @@ "options": { "cwd": "/opt/arm-miosix-eabi/bin" } + }, + { + "label": "Open PuTTY 'skyward' session", + "type": "shell", + "windows": { + "command": "putty.exe -load skyward &" + }, + "linux": { + "command": "putty.exe -load skyward &" + }, + "problemMatcher": [] } ] } \ No newline at end of file diff --git a/sbs b/sbs index d23bb8720..ba00248e5 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() { @@ -104,7 +106,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 @@ -181,6 +192,8 @@ config_ccache=false config_debug=false config_verbose=false config_ninja=false +config_stflash=false +config_stlink=false build_jobs= find_deps -- GitLab