diff --git a/Tools/ide/vscode/setup.py b/Tools/ide/vscode/setup.py
index b16bb28d91..618846aca6 100644
--- a/Tools/ide/vscode/setup.py
+++ b/Tools/ide/vscode/setup.py
@@ -3,7 +3,7 @@
# Sming hardware configuration tool
#
-import os, sys, copy, shutil
+import os, sys, copy
appPath = os.path.dirname(os.path.realpath(__file__))
libPath = appPath + '/../common/'
@@ -58,36 +58,46 @@ def update_launch():
filename = '.vscode/launch.json'
launch = load_json(filename, False)
template = load_template('launch.json', appPath)
+ if env.get('ENABLE_WOKWI'):
+ wokwi_template = load_template('wokwi/launch.json', appPath)
+ template["configurations"].extend(wokwi_template["configurations"])
if launch is None:
launch = template.copy()
configurations = get_property(launch, 'configurations', [])
- config_name = "%s GDB" % env['SMING_ARCH']
- config = find_object(configurations, config_name)
- template_config = find_object(template['configurations'], config_name)
- if template_config is None:
- print("Warning: Template launch configuration '%s' not found" % config_name)
- elif not config is None:
- configurations.remove(config)
- config = template_config.copy()
- configurations.append(config)
-
- if config is None:
- return
- config['miDebuggerPath'] = find_tool(env['GDB'])
- dbgargs = "-x ${env:SMING_HOME}/Arch/%s/Components/gdbstub/gdbcmds" % env['SMING_ARCH']
- if env['SMING_ARCH'] == 'Host':
- args = []
- args += env['CLI_TARGET_OPTIONS'].split()
- args += ["--"]
- args += env['HOST_PARAMETERS'].split()
- config['args'] = args
- else:
- if not env.isWsl():
- dbgargs += " -b %s" % env.resolve('${COM_SPEED_GDB}')
- config['miDebuggerServerAddress'] = env.resolve('${COM_PORT_GDB}')
- config['miDebuggerArgs'] = dbgargs
- config['program'] = "${workspaceFolder}/" + env.resolve('${TARGET_OUT_0}')
+ wokwi_config_name = "Wokwi GDB"
+ config_names = ["%s GDB" % env['SMING_ARCH']]
+ if env.get('ENABLE_WOKWI'):
+ config_names.append(wokwi_config_name)
+ for config_name in config_names:
+ config = find_object(configurations, config_name)
+ template_config = find_object(template['configurations'], config_name)
+ if template_config is None:
+ print("Warning: Template launch configuration '%s' not found" % config_name)
+ elif not config is None:
+ configurations.remove(config)
+ config = template_config.copy()
+ configurations.append(config)
+
+ if config is None:
+ return
+
+ config['miDebuggerPath'] = find_tool(env['GDB'])
+ dbgargs = "-x ${env:SMING_HOME}/Arch/%s/Components/gdbstub/gdbcmds" % env['SMING_ARCH']
+ if env['SMING_ARCH'] == 'Host':
+ args = []
+ args += env['CLI_TARGET_OPTIONS'].split()
+ args += ["--"]
+ args += env['HOST_PARAMETERS'].split()
+ config['args'] = args
+ else:
+ if not env.isWsl():
+ dbgargs += " -b %s" % env.resolve('${COM_SPEED_GDB}')
+ if config_name != wokwi_config_name:
+ config['miDebuggerServerAddress'] = env.resolve('${COM_PORT_GDB}')
+ if config_name != wokwi_config_name:
+ config['miDebuggerArgs'] = dbgargs
+ config['program'] = "${workspaceFolder}/" + env.resolve('${TARGET_OUT_0}')
save_json(launch, filename)
@@ -111,7 +121,6 @@ def update_wokwi():
extensions = template.copy()
save_json(extensions, filename)
return
-
extensions["recommendations"] = extensions["recommendations"] + list(set(template["recommendations"]) - set(extensions["recommendations"]))
save_json(extensions, filename)
diff --git a/Tools/ide/vscode/template/wokwi/launch.json b/Tools/ide/vscode/template/wokwi/launch.json
new file mode 100644
index 0000000000..81bb464108
--- /dev/null
+++ b/Tools/ide/vscode/template/wokwi/launch.json
@@ -0,0 +1,18 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Wokwi GDB",
+ "type": "cppdbg",
+ "request": "launch",
+ "program": "",
+ "args": [],
+ "stopAtEntry": true,
+ "cwd": "${workspaceFolder}",
+ "environment": [],
+ "externalConsole": true,
+ "MIMode": "gdb",
+ "miDebuggerServerAddress": "localhost:3333"
+ }
+ ]
+}
diff --git a/Tools/ide/vscode/template/wokwi/wokwi.toml b/Tools/ide/vscode/template/wokwi/wokwi.toml
index a3ce4bf54f..f54dca4f23 100644
--- a/Tools/ide/vscode/template/wokwi/wokwi.toml
+++ b/Tools/ide/vscode/template/wokwi/wokwi.toml
@@ -2,3 +2,4 @@
version=1
firmware='${FW_BASE}/app-merged.bin'
elf='${TARGET_OUT_0}'
+gdbServerPort=3333
diff --git a/docs/source/experimental/wokwi-debug.jpg b/docs/source/experimental/wokwi-debug.jpg
new file mode 100644
index 0000000000..11c2380b04
Binary files /dev/null and b/docs/source/experimental/wokwi-debug.jpg differ
diff --git a/docs/source/experimental/wokwi.rst b/docs/source/experimental/wokwi.rst
index 296a1f97d1..cabbc5bd25 100644
--- a/docs/source/experimental/wokwi.rst
+++ b/docs/source/experimental/wokwi.rst
@@ -27,8 +27,8 @@ From the root directory of your application, run the following command to consol
make mergeflash SMING_ARCH=Esp32
-Example Usage
-=============
+Usage
+=====
Basic_Blink
-----------
@@ -43,7 +43,19 @@ Follow the commands below to get started::
Once the compilation is complete, open the folder in VS Code, install the recommended extensions, and either open the ``diagram.json`` file or press F1 and type ``Wokwi``.
From the options, choose to start the Wokwi simulator.
+Debugging
+=========
+
+Running the Basic_Blink sample in the simulator enables you to debug it directly in VS Code.
+Set a breakpoint in the ``init`` function in the Basic_Blink ``app/application.cpp`` file.
+Press F1 and select "Start Simulator and Wait for Debugger." In the Launch configurations, choose "Wokwi GDB" and click the play button.
+This initiates a new debugging session, allowing you to debug the code running in the simulator.
+
+.. image:: wokwi-debug.jpg
+ :height: 192px
+
Diagram Editor
==============
-The ``diagram.json`` file, which includes elements and their connections, can be edited on the Wokwi official website __.
-You can add new elements such as extra LEDs or servos. Ensure to copy the modified contents of the diagram.json from the website to your local environment.
\ No newline at end of file
+
+The ``diagram.json`` file, which includes elements and their connections, can be edited on the `Wokwi official website `__.
+You can add new elements such as extra LEDs or servos. Ensure to copy the modified contents of the diagram.json from the website to your local environment.