How to set up a Zephyr Project App in VSC? - visual-studio-code

I am trying to use VSC to develop and debug embedded C applications with Zephyr OS. Is this possible? Are there instructions to set this up? Is there a zephyr setup extension? The Zephyr documentation discusses how to debug apps on eclipse, and there is an eclipse/zephyr plug-in, but I'd prefer to use VSC if possible.
Since Zephyr utilizes CMake, I thought I follow the VSC CMake project tutorial. When it asks to select a kit, there was nothing appropriate for zephyr, so I left it with no active kit selected. With this setting, I am actually able to get a successful build for the blinky example but cannot debug the project. The error I get is:
ERROR: Unable to start debugging. Unexpected GDB output from command
"-exec-run". Don't know how to run. Try "help target". The program
'/home/mustafa/Code/Sycamore/hello_world/build/zephyr/zephyr.elf' has
exited with code 42 (0x0000002a).
If anyone has any input on how to address this error or instructions on setting up a zephyr project in VSC, that would be great. Thx!

Only few steps enough:
Add necessary folders to workspace like:
"folders": [
{
"path": ".",
"name": "app"
},
{
"path": "..\\zephyr",
"name": "zephyr"
},
{
"path": "..\\mcuboot"
},
{
"path": "..\\modules\\hal\\stm32"
}
]
Install Cortex-Debug extension
Setup debug session in file .vscode/launch.json:
"configurations": [
{
"name": "App",
"cwd": "${workspaceRoot}",
"executable": "./app/build/zephyr/zephyr.elf",
"request": "attach",
"type": "cortex-debug",
"serverpath": "C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe",
"servertype": "jlink",
"device": "stm32f412RE",
"interface": "swd",
"svdFile": "./STM32F412.svd"
},
{
"name": "Bootloader",
"cwd": "${workspaceRoot}",
"executable": "./boot/build/zephyr/boot.elf",
"request": "launch",
"type": "cortex-debug",
"serverpath": "C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe",
"servertype": "jlink",
"device": "stm32f412RE",
"interface": "swd",
"runToMain": true,
"svdFile": "./STM32F412.svd"
}

Related

Launching and debugging Blazor server and webasm on VS Code

I have tried run visual studio code, to build, launch and debug (using omnisharp and dotnet...) the blazor server and webasm project but It seems to only launch one project at a time even tho task.json has both of the projects? is there a way to launch both project at the same time? or to keep one executing while the other is launched in case this wasnt possible?
here is my launch.json
{
"version": "0.2.0",
"configurations":
[
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/BlazorApp/bin/Debug/net5.0/BlazorApp.dll",
"args": [],
"cwd": "${workspaceFolder}/BlazorApp",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5010"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
},
{
"type": "blazorwasm",
"name": "Launch and Debug Blazor WebAssembly Application",
"request": "launch"
}
]
}
the answer is using compounds parameters in the launch.json
How to run multiple tasks in VS Code on build?
as for debugging I have yet to see how to get the js debugger to work on Chrome

Run and Debug problems in Visual Studio Code using haxe

I'm currently coding in Haxe with Heaps using Visual Studio Code. The latter has recently updated to version 1.56 which is now giving my a strange problem I can't manage to fix. Before the update, I was able to click Run and Debug using Hashlink in order to open the window of my game. After the update, when I Run and Debug it no longer opens the window, despite the compile.hxml and launch.json being exactly the same as before:
compile.hxml:
-cp src
-lib heaps
-lib hlsdl
-hl main.hl
-main Main
.json
"version": "0.2.0",
"configurations": [
{
"name": "HashLink (launch)",
"request": "launch",
"type": "hl",
"cwd": "${workspaceFolder}",
"preLaunchTask": {
"type": "haxe",
"args": "active configuration"
}
},
{
"name": "HashLink (attach)",
"request": "attach",
"port": 6112,
"type": "hl",
"cwd": "${workspaceFolder}",
"preLaunchTask": {
"type": "haxe",
"args": "active configuration"
}
}
]
Is anyone experiencing a similar problem?
Update: hashlink-debugger 1.1.2 was released, which should fix the problem.
It's a known issue:
HL debugger no longer works in latest vscode #97
You can downgrade to the previous VSCode release or subscribe to the issue and wait for the hashlink-debugger update.

Setting working directory in VSCode 14.6.x when using CMake Tools to something else then build directory

Since the update of CMake Tools 1.4.2 (Incorrect run folder #1395) the working directory of the launched binary isn't the workspace directory anymore, but the build directory (due to that files loaded with relative paths are not found anymore).
I tried to figure out in the release notes and the settings if there were some changes that cause that behavior, but I'm not able to find a reason or a solution for that.
The setup is:
Linux
VSCode 1.14.1
CMake Tools 1.4.2
I tried to set the cwd using launch.json, but I'm not able to get it to work.
My launch.json currently looks that way:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Does anyone know how the working directory can be changed?
For debugging it can be changed with:
"cmake.debugConfig": {
"cwd": "${workspaceFolder}"
},
For a regular run/launch it is currently not possible without changing the source of the extension.

vscode debugging - how to correctly Blackbox?

I'm trying to debug a react-native application, and need the debugger to skip anything that isn't my code, so node_modules directory. I added "skipFiles" option to the config, but that doesn't help.
This is the latest config that I have:
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react",
"skipFiles": [
"${workspaceRoot}\\node_modules\\**\\*.js",
"${workspaceRoot}/node_modules/**/*.js",
"<node_internals>/**/*.js"
]
},
I tried using "/node_modules/*" and "${workspaceRoot}/node_modules/" but nothing helps. I keeps stepping into node_modules code.

Debugging Perl with Visual Studio Code

I have just started with Perl today and installed ActivePerl 5.24.1 and everything went well. I was able to create my test program testPerl.pl with simple a print command and run it through console.
Now I wanted to use Visual Studio Code to run my Perl script, and so I opened the project folder [testPerl.pl location] with Visual Studio Code and tried to debug the code. I have installed the Perl-Debug extension in the editor and when I hit F5, Visual Studio Code asked me to Select Environment and I chose the Perl Debug option, which actually created the launch.json file for me with the below contents.
{
"version": "0.0.2",
"configurations": [
{
"type": "perl",
"request": "launch",
"exec": "perl",
"name": "Perl-Debug",
"root": "${workspaceRoot}/",
"program": "${workspaceRoot}/${command.AskForProgramName}",
"inc": [],
"stopOnEntry": true
}
]
}
I have kept default values as it, and when I hit F5 again, it asked me for a command with default value test.pl. It is because of ${command.AskForProgramName}, I assume. I entered my file name testPerl.pl in the command, but then nothing happens. It starts and ends without any print in console.
How can I actually configure this launch.json file or is there another way I need to do this?
I tried with a newer version of the plugin: Perl Debug version 0.2.0.
This works out of the box. The proposed configuration looks as follows:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug local",
"program": "${workspaceFolder}/${relativeFile}",
"exec": "perl",
"execArgs": [],
"root": "${workspaceRoot}/",
"inc": [],
"args": [],
"env": {},
"stopOnEntry": true
},
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug remote",
"program": "${workspaceFolder}/${relativeFile}",
"root": "${workspaceRoot}/",
"stopOnEntry": true,
"port": 5000
}
]
}
Do note I tried this out on a Mac, with Visual Studio Code version 1.24.0.
I ran Visual Studio Code on a Mac and changed
"program": "${workspaceRoot}/${command.AskForProgramName}"
to
"program": "${file}"
to get the current file to debug.