From 462e324c7823e38fb8bd71c63db5ea8db48293c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niccol=C3=B2=20Betto?= <niccolo.betto@skywarder.eu>
Date: Thu, 11 Jul 2024 01:23:06 +0200
Subject: [PATCH] [VSCode] Add debug configurations for Main and Payload

---
 .vscode/launch.json | 76 +++++++++++++++++++++++++++++---------
 .vscode/tasks.json  | 89 ++++++++-------------------------------------
 2 files changed, 75 insertions(+), 90 deletions(-)

diff --git a/.vscode/launch.json b/.vscode/launch.json
index 3e9272fde..ead1517cf 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -2,32 +2,74 @@
     "version": "0.2.0",
     "configurations": [
         {
+            "name": "(gdb) Launch Main",
+            "type": "cortex-debug",
+            "request": "launch",
+            "servertype": "stutil",
+            "device": "STM32F767ZI",
+            "executable": "${workspaceFolder}/build/main-entry",
             "cwd": "${workspaceRoot}",
-            "executable": "${workspaceFolder}/bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.elf",
-            "name": "ST-LINK V2 (current entrypoint)",
-            "request": "attach",
+            "armToolchainPath": "/opt/arm-miosix-eabi/bin",
+            "toolchainPrefix": "arm-miosix-eabi",
+            "internalConsoleOptions": "neverOpen",
+            "presentation": {
+                "hidden": false,
+                "group": "Main",
+                "order": 1,
+            },
+            "preLaunchTask": "Build Main (Debug)",
+        },
+        {
+            "name": "(gdb) Attach Main",
             "type": "cortex-debug",
-            "servertype": "openocd",
-            "device": "STM32F429ZI",
+            "request": "attach",
+            "servertype": "stutil",
+            "device": "STM32F767ZI",
+            "executable": "${workspaceFolder}/build/main-entry",
+            "cwd": "${workspaceRoot}",
             "armToolchainPath": "/opt/arm-miosix-eabi/bin",
             "toolchainPrefix": "arm-miosix-eabi",
-            "configFiles": [
-                "${workspaceFolder}/data/gdb/stm32f4-stlinv2.cfg"
-            ]
+            "internalConsoleOptions": "neverOpen",
+            "presentation": {
+                "hidden": false,
+                "group": "Main",
+                "order": 2,
+            },
         },
         {
+            "name": "(gdb) Launch Payload",
+            "type": "cortex-debug",
+            "request": "launch",
+            "servertype": "stutil",
+            "device": "STM32F767ZI",
+            "executable": "${workspaceFolder}/build/payload-entry",
             "cwd": "${workspaceRoot}",
-            "executable": "${workspaceFolder}/bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.elf",
-            "name": "ST-LINK V1 (current entrypoint)",
-            "request": "attach",
+            "armToolchainPath": "/opt/arm-miosix-eabi/bin",
+            "toolchainPrefix": "arm-miosix-eabi",
+            "internalConsoleOptions": "neverOpen",
+            "presentation": {
+                "hidden": false,
+                "group": "Payload",
+                "order": 1,
+            },
+            "preLaunchTask": "Build Payload (Debug)",
+        },
+        {
+            "name": "(gdb) Attach Payload",
             "type": "cortex-debug",
-            "servertype": "openocd",
-            "device": "STM32F429ZI",
+            "request": "attach",
+            "servertype": "stutil",
+            "device": "STM32F767ZI",
+            "executable": "${workspaceFolder}/build/payload-entry",
+            "cwd": "${workspaceRoot}",
             "armToolchainPath": "/opt/arm-miosix-eabi/bin",
             "toolchainPrefix": "arm-miosix-eabi",
-            "configFiles": [
-                "${workspaceFolder}/libs/miosix-kernel/miosix/arch/cortexM4_stm32f4/stm32f429zi_skyward_death_stack/death_stack.cfg"
-            ]
-        }
+            "internalConsoleOptions": "neverOpen",
+            "presentation": {
+                "hidden": false,
+                "group": "Payload",
+                "order": 2,
+            },
+        },
     ]
 }
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 2d33cab32..fafc9671d 100755
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -2,102 +2,45 @@
   "version": "2.0.0",
   "tasks": [
     {
-      "label": "CLEAN",
+      "label": "Clean Build Artifacts",
       "type": "shell",
       "windows": {
-        "command": "sh sbs -c"
+        "command": "sh sbs -c ; sbs -c"
       },
       "linux": {
-        "command": "./sbs -c"
+        "command": "./sbs -c ; ./sbs -c"
       },
       "problemMatcher": "$gcc"
     },
     {
-      "label": "BUILD all",
+      "label": "Build Main (Debug)",
       "type": "shell",
       "windows": {
-        "command": "sh sbs"
+        "command": "sh sbs -d -b main-entry"
       },
       "linux": {
-        "command": "./sbs"
+        "command": "./sbs -d -b main-entry"
       },
-      "problemMatcher": "$gcc"
-    },
-    {
-      "label": "BUILD current-entrypoint",
-      "type": "shell",
-      "windows": {
-        "command": "sh sbs -v -n -b ${fileBasenameNoExtension}"
-      },
-      "linux": {
-        "command": "./sbs -v -b ${fileBasenameNoExtension}"
+      "presentation": {
+        "reveal": "always",
+        "panel": "dedicated"
       },
       "problemMatcher": "$gcc"
     },
     {
-      "label": "RUN current-entrypoint",
+      "label": "Build Payload (Debug)",
       "type": "shell",
       "windows": {
-        "command": "ST-LINK_CLI.exe -P bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.bin 0x8000000 -V -Rst"
+        "command": "sh sbs -d -b payload-entry"
       },
       "linux": {
-        "command": "st-flash write bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.bin 0x8000000"
-      },
-      "problemMatcher": []
-    },
-    {
-      "label": "BUILD+RUN current-entrypoint",
-      "type": "shell",
-      "windows": {
-        "command": "ST-LINK_CLI.exe -P bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.bin 0x8000000 -V -Rst"
-      },
-      "linux": {
-        "command": "sleep 1;st-flash write bin/${fileBasenameNoExtension}/${fileBasenameNoExtension}.bin 0x8000000"
-      },
-      "problemMatcher": [],
-      "dependsOn": [
-        "BUILD current-entrypoint"
-      ],
-      "group": {
-        "kind": "build",
-        "isDefault": true
-      }
-    },
-    {
-      "label": "BUILD tests-catch",
-      "type": "shell",
-      "windows": {
-        "command": "sh sbs -v -n -b tests-catch"
+        "command": "./sbs -d -b payload-entry"
       },
-      "linux": {
-        "command": "./sbs -v -b tests-catch"
+      "presentation": {
+        "reveal": "always",
+        "panel": "dedicated"
       },
       "problemMatcher": "$gcc"
-    },
-    {
-      "label": "RUN tests-catch",
-      "type": "shell",
-      "windows": {
-        "command": "ST-LINK_CLI.exe -P bin/tests-catch/tests-catch.bin 0x8000000 -V"
-      },
-      "linux": {
-        "command": "st-flash write bin/tests-catch/tests-catch.bin 0x8000000"
-      },
-      "problemMatcher": []
-    },
-    {
-      "type": "shell",
-      "label": "arm-miosix-eabi-g++ build active file",
-      "command": "/opt/arm-miosix-eabi/bin/arm-miosix-eabi-g++",
-      "args": [
-        "-g",
-        "${file}",
-        "-o",
-        "${fileDirname}/${fileBasenameNoExtension}"
-      ],
-      "options": {
-        "cwd": "/opt/arm-miosix-eabi/bin"
-      }
     }
   ]
-}
+}
\ No newline at end of file
-- 
GitLab