I am so frustrated that my vscode debugger does not work on the remote servers suddenly today.
Here is the situation.
When I use the starred interpreter by vscode (the recommended one), it works smoothly. However, when I want to use other interpreters, the ones stored in personal folder on the server, the debugger doesn't launch a debug console and dose not enter the file.
Vscode can find and recognize the interpreters and I can use those interpreters to run scripts but can NOT DEBUG.(on the remote server) However, it works fine on my local machine with multiple python interpreter.
Can anyone give me some help? I have tried uninstall vscode completely on my end but still not work. Thank you so much!!
The Python extension debugger in VSCode requires a minimum Python version to run properly. However, this is not documented at all in the changelog at https://github.com/microsoft/vscode-python/releases, but you have to find out for yourself. For example, at the time of writing, version 2022.12.0 doesn't harmonize with Python 3.6.8.
As a workaround you have 2 options
Upgrade your interpreter to a newer version
Downgrade the Python extension to an older version
For the latter, go to the extensions page and under the Uninstall button you will find Install another version.... This makes it easy to try out what works best for you.
Just in case stumbles upon this question and the accepted answer doesn't work for you:
Try downgrading the Python extension version in VSCode. That fixed the issue for me. I picked a random version from ~2 months ago (when I wasn't having the issue). You might need to try a few versions though.
This workaround might work for you: use the interpreter that works for you but in the launch.json configuration file add a
"python": "/path/to/the/python/you/want",
I share the same experience. It seems that vscode fails to start the remote debugger with the interpreter I want but succeeds with the system interpreter.
For example:
"configurations": [
{
"name": "config_name",
"type": "python",
"python": "/path/to/desired/python",
"request": "launch",
"program": "/path/to/python/script.py",
"console": "integratedTerminal",
},
]
Related
I've installed Quartus and NIOS II IDE on my Linux machine. Originally I tried importing an existing NIOS II Project into Eclipse, but it just sits there spinning away and eventually tells me it can't import the project because it already exists.
I tried installing everything on a Win10 machine and the project imported OK. I did notice that some of the paths in the orignal project have backslashes. So, for example:
#include "..\subfolder\include_file.h"
Kind of thing. I wonder whether maybe it was that was causing issues.
So, I then tried creating an hello world NIOS Processor in Quartus and making a NIOS II project from scratch. Every step along the way with Eclipse was grindingly slow, but eventually worked up until the point I was able to hit Finish at which point it's just hanging with the little circle with red and blue arrows spinning round and round.
I also have a pop up window with a long list of:
Remote System Explorer Opertion
lines, and at the top it says:
The user operation is waiting for background work to complete
It seems like everything is installed correctly, I can open the NIOS II Eclipse IDE from Quartus for example. Quartus itself works nicely.
I used these instructions to installed Eclipse:
Is anyone able to give me any pointers as to why this is so incredibly slow please? My Linux machine is pretty high spec and flies. Nothing else whatsoever even vaguely struggles on it.
If there's anything I can try to give diagnostic info, am more than happy to supply. Thanks!
I found a solution here
https://askubuntu.com/questions/761604/eclipse-not-working-in-16-04
To test if this fix works, try opening a terminal, and doing
$export SWT_GTK3=0
then run eclipse-nios2. That is, do something like
$ ~/intelFPGA_lite/20.1/nios2eds/bin/eclipse-nios2
If that fixes the problem then to make the fix permanent edit eclipse.ini which for me is in intelFPGA_lite/20.1/nios2eds/bin/eclipse_nios2
In that file, between the lines openFile and --launcher.appendVmargs
insert
--launcher.GTK_version
2
So it reads:
openFile
--launcher.GTK_version
2
--launcher.appendVmargs
and save.
Worked for me!
Try using Visual Studio Code instead. It can do (almost) everything that Eclipse can do, with the added benefit that you can debug remote. E.g. in my setup, I develop exclusively using macOS. I have Quartus installed in a Ubuntu 20.04 VM and VSCODE allows me to develop and debug as if I'm running Quartus natively in macOS.
I'll provide a rough 'how-to' below.
I strongly suggest using a Ubuntu environment for Quartus (other linux environments should work too: I've tested Arch and Manjaro). The Windows install is a royal pain to get working, regardless of IDE choice. I haven't tried the Windows version since 20.1 but nothing worked out of the box and it took many hours or messing with config files to fix it. Also, the Windows version isn't native anyway - it's actually running in Ubuntu via WSL.
Make sure you have installed your required version of Quartus - this should work for Pro, Standard and Lite editions. You can skip the manual installation of NiosII Build Tools for Eclipse if you'd like but I would actually recommend installing it. It can still be useful, if only for creating a new project, BSP etc.
Install VSCODE along with the C/C++ Extension provided by Microsoft (and the Visual Studio Code Remote - SSH extension if you intend to use that feature)
Create a new project using Eclipse (or skip, if you already have a project)
Open VSCODE, select open and navigate to the software directory of your project.
VSCODE will open your project and you should see your application directory and BSP directory.
From here, you can work on your code with full linting, auto completion etc.
If you need to regenerate your BSP, you can either do that using Eclipse or just run the command-line tool instead.
Compiling
If you allowed Eclipse to create your project for you, it will have produced a makefile in your application directory. Compiling is as simple as running 'make' from the application directory. I like to keep a terminal window open within VSCODE so I can run various tools as I work so this is usually how I can compile code. If, instead, you'd like to integrate this into VSCODE, you can define a task (https://code.visualstudio.com/docs/editor/tasks).
Eclipse automatically adds new sources that you create to the makefile. VSCODE won't do this - however, I personally don't think this is a bad thing. I don't like IDEs messing with my makefiles, I want fully control over them myself. So when you create a new source file, just remember to add it to the makefile. There is probably a way to get VSCODE to add sources files automatically (you can run commands on save etc) - but I have no motivation to try to figure this out.
Debugging
It is also possible to debug Nios2 software live on the target via the USB-Blaster using VSCODE. To do this, open the launch.json file in the .vscode folder of your project. If this file does not exist, just create it. The path should be:
<project root dir>/.vscode/launch.json
Copy the following into the launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "app",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/app/app.elf",
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerServerAddress": "localhost:2334",
"miDebuggerPath": "/PATH/TO/intelFPGA/20.1/nios2eds/bin/gnu/H-x86_64-pc-linux-gnu/bin/nios2-elf-gdb",
"debugServerPath": "/PATH/TO/intelFPGA/20.1/quartus/bin/nios2-gdb-server",
"debugServerArgs": "--tcpport 2334 --reset-target --tcppersist",
}
]
}
This file is a list of debug targets and settings. You can add any number of configurations here, but easiest to just start with one for now. The configuration above is called 'app', you can change this to suit your own project if you wish.
Update the "program" entry with the path to your applications elf
file
Update the "miDebuggerPath" path with the path the nios2-elf-gdb on
your system. This is the gdb client for Nios2
Update the "debugServerPath" path with the path the nios2-gdb-server.
This is the gdb server for Nios2
Save the file and now click on the "run and debug" button on the left
side control panel in VSCODE
You'll see play button at the top of the screen next to the configuration you just defined in launch.json. Hit the play button - this will start an instance of the gdb server, followed by the gdb client and connect the two. If all goes well, your target will run and stop in main.
VSCODE will provide you with a set of debug tools for stepping, watching variables, call stack - all that good stuff. On the right hand side, you can view the debug console which will allow you to enter commands directly into the gdb console. Note, you have to prepend your commands with -exec. E.g. to print the value of a variable x, you would type:
-exec print x
Caveat
There is a problem with this debugging method: nios2-gdb-server doesn't always exit cleanly and as a result the port doesn't close. If you try to start another debug session, the server won't start because the port is in use. Eclipse solves this problem by randomizing the port everytime it launches the gdb. I have not found a way to do that VSCODE yet.
I find easiest way around this is to run the gdb server manually when I need it. Comment out the two 'debugServer' lines above. Open a second terminal in VSCODE and run:
nios2-gdb-server --tcpport 2334 --reset-target --tcppersist
This will keep the server running even when you stop debugging. If you start another debug session, it will reconnect to the same server instance.
Update: rioV8 provided a helpful solution to this problem which involves using a vscode extension to generate a random environment variable which can used be used in place of the port numbers. The solution is here.
Every time I build or run a program in VSCode a new python debug console is loaded. Before I know it I have 20+ and need to start deleting them. After 32 open consoles I get the error "The terminal process terminated with exit code: 256". I changed the terminal from the default console to git bash recently. How can I stop this?
A way around this issue is to stop VS Code from redundantly printing to the TERMINAL during debugging in the first place. Since it prints to the DEBUG CONSOLE as well, you can use that instead.
Change console to "none" "internalConsole" in each configuration in your project's launch.json file:
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole"
}
]
May 2019 Update: the "none" option was replaced by "internalConsole" so I edited my answer to reflect that. Here's the relevant GitHub Issue.
Adding "args": ["&&", "exit"], to launch.json remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.
This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently.
I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals.
Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a VS Code/Python Extension defect about this. The initial response is that Git Bash is not officially supported currently.
There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window.
There is some additional background info and hacks to fix this from the past in this answer.
Hopefully fixed in the Insiders Build and should be in v1.54. See Debug opens a new integrated terminal for each Python session
. Test it in the Insiders Build if you can and report at the issue if it fixed/did not fix.
Actually you can delete all the instances of the terminal just by clicking on the trash can icon 🗑. If it does not work for the first time, restart the VS Code and try again.
I am new to the realm of STM32 programming and have been trying to find a suitable IDE for quite a while now. I know of all the other IDE's like Keil and IAR but the cost of buying them just to learn is far to steep for me at this point in time.
I have started using VS Code for a growing amount of my development work and I though it would be a good IDE to use for STM32 development. I have found many examples online over the past few days on how to configure the IDE to build STM32 projects but they all seem to be missing important information that I need to properly get the project to compile. It is rather frustrating,
I was wondering if there is anyone that can point me to a complete setup guide on how to set up VS code to work with cubeMX and the arm tool-chain, or if you are feeling really kind, send me a sample project that I can use as a base learn from.
Just some background information, I know how to use cubeMX to generate the base project as well as the associated makefile, I also have the latest GNU-Tools-Arm-Embedded installed.
Thank you in advance for your help
Install GNU Arm Embedded toolchain and add its bin folder to your PATH environment variable.
You will also need a make to execute your makefiles so download Make for Windows. Easiest way is to download the binaries and extract it somewhere on your system. Add it (C:\make-3.81-bin\bin) to your PATH as well.
Create an STM32CubeMX project and select Makefile as Toolchain/IDE.
At this point you will be able to build the generated project by simply using make in the project's root folder.
If you open the project in VS Code you can build using its terminal or you can create a VS Code task to execute the make command. You can bind your task to a hotkey as well to spare some time.
To debug, the easiest way is to install Cortex-Debug VS Code extension. Follow the instructions to configure your debug sessions.
A while ago I had the same question, but did not find anything that I really liked. So I created STM32 for VSCode, it is an extension for VSCode which works with STM32CubeMX generated files and sets up building and debugging for you.
There is a library of python scripts that does just this, it has been released recently with excellent documentation and after testing I can say it works as advertised.
VSCode STM32 IDE
The process is quite straight forward:
Export the files using STM32CubeMX
Cpen the VSCode folder and save it as workspace
Copy the scripts "ideScripts" directory to your project folder
Run update.py
Here is a video on how it works:
VSCode STM32 IDE - Getting Started
There is already very good answer by #Bence Kaulics, based on it add my recent findings.
make command somehow did not work for me in VS Code Terminal. To solve this I installed "Makefile Tools" extension from Microsoft.
instruction link does not work, therefore I add steps how to configure debugging for J-Link.
-> Install Cortex-Debug Extention. -> Download and install J-Link Software from Segger. -> Get SVD file if you want to see peripheral registers. -> Edit launch.json file (see code below). -> Set your executable, paths and device.
{
"version": "0.2.0",
"configurations": [
{
"cwd": "${workspaceRoot}",
"executable": "./build/STM32F103RBT6_Test1.elf",
"name": "Debug Microcontroller",
"request": "launch",
"type": "cortex-debug",
"servertype": "jlink",
"serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL.exe",
"armToolchainPath": "C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin",
"device": "STM32F103RB",
"interface": "swd",
//"serialNumber": "", // if Multiple Debuggers attached
"runToMain": true,
"svdFile": "${workspaceRoot}/device/STM32F103xx.svd",
}
]
}
I have installed VSCode and Python 3.6.4, and I was hoping to set up the Python extension for VSCode to enable linting, debugging, etc. Unfortunately, I'm not able to set up the extension correctly. The extension comes with a set of pre-loaded commands for the command palette. These include "Python: Create Terminal
", "Python: Select Interpreter", "Python: Enable Linting", among many others.
For some reason, whenever I try to run any of these commands, I receive a command not found error. For example, when I try running "Python: Create Terminal", I receive:
ERROR command 'python.createTerminal' not found
I have triple checked that the Python extension is installed and activated. I have not edited the User settings file with respect to the python extension at all. And I have already tried uninstalling the extension and reinstalling it.
To ensure that it's not a general problem with all of my extensions, I tried running a few ESLint commands and they all work fine. I've also ensured Python is on my path.
Any guidance for what else to try would be greatly appreciated!
I have been trying to configure the debugger on vscode for debugging python code. Below is the launch.json config and following are the settings.json and externalTerminal (launch.json) config, respectively.
I have read through the documentation but I am afraid I am not able to understand it. From what I read on there, I need to set up my external terminal configuration as the integrated terminal isn't capable of accepting inputs(yet).
I am using virtualenvs for my project and I have them in the path: usr/Projects/VirtualEnvs. All my venvs reside in there. I tried to set "python.pythonPath": "/usr/Projects/VirtualEnvs/myVenv/bin/python3.6" which doesn't seem to work. Could anyone help me out or at least point me in the right direction (would be a good learning experience)? Please let me know if my question isn't clear enough.
I figured it out!
My mistake: The python interpreter was not set for the script I was debugging, and since I was using a venv with different Python version, I was thinking that maybe I'd have to somehow set it to that version of the Python interpreter!
How I came to the solution?: Today, while studying and getting stuck with a problem, I noticed that near my shebang was line that said 'Set as interpreter'. I clicked that and VSCode told me that it was now using Python 3.6.1 as the interpreter, that kind of got me excited. Just to be sure I did a google search and found this video. That, very quickly, helped me understand my problem that firstly the interpreter wasn't set and secondly, I was running the debugger from the wrong file!
"program": "${file}",
"cwd": "${workspaceFolder}"
This setting takes care of which folder and what file for you!
For the External Terminal configuration, a new terminal window pops up and you can supply args to your input statement and watch as the debugger goes step by step!