Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VSC-1552] Resolve folder when using launch config from code-workspace #1397

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

brianignacio5
Copy link
Collaborator

@brianignacio5 brianignacio5 commented Jan 7, 2025

Description

Show a dropdown to pick workspace folder when using workspace launch configuration.

Override env PATH in extension context environment variables collection.

Fixes #1394

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Steps to test this pull request

Create a workspace .code-workspace file like this:

{
	"folders": [
		{
			"path": "."
		}
	],
	"settings": {
		"idf.port": "/dev/ttyACM1",
		"idf.flashType": "UART",
		"idf.openOcdDebugLevel": 2,
		"idf.openOcdLaunchArgs": [
			"-c adapter serial 40:4C:CA:43:1C:AC"
		],
		"idf.openOcdConfigs": [
			"board/esp32c6-builtin.cfg"
		],
	},
	"launch": {
		"version": "0.2.0",
		"configurations": [
			{
			  "type": "gdbtarget",
			  "request": "attach",
			  "name": "Eclipse CDT GDB Adapter"
			},
			{
			  "type": "espidf",
			  "name": "Launch",
			  "request": "launch"
			}
		],
	},
}
  1. In vscode select menu File -> Open workspace from file... and select the previous created file.
  2. In the created workspace select the Eclipse CDT GDB Adapter (workspace) debug configuration and start debug.
  3. A dropdown should be shown to select a workspace folder.
  4. If there is a /usr/bin/openocd in env PATH, the extension should use the one from $IDF_TOOLS_PATH.
  • Expected behaviour:

  • Expected output:

How has this been tested?

Manual test as described above.

Test Configuration:

  • ESP-IDF Version: 5.3.1
  • OS (Windows,Linux and macOS): Linux and MacOS

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

@brianignacio5 brianignacio5 added this to the v1.9.1 milestone Jan 7, 2025
@brianignacio5 brianignacio5 self-assigned this Jan 7, 2025
@i400s
Copy link

i400s commented Jan 7, 2025

Thank you for looking at these issues for me @brianignacio5 . Much appreciated.

I've looked at the commit and was wondering if an alternative to the drop down to select the folder would instead be to use the ESP-IDF: Current project .... directory selector on the tool bar (or CTRL+SHIFT+P ESP-IDF: pick a workspace folder)? Or default the drop down to be the folder selected there while allowing other workspace directories to be selected?

I had assumed it was the Current project folder that would have been used if the launch was defined at the workspace level in the same way the espidf launch configuration does (or at least I thought it did; but I could be wrong as its been a long couple of days).

Thanks again.

@i400s
Copy link

i400s commented Jan 9, 2025

Hi @brianignacio5, I eventually managed to fork and clone this repo and then switch to this branch and finally created a visx.

The changes you made to the workspace launch #1394 worked with it now giving a drop down to select from.

The issue #1395 seemed as if it was not fixed... however...

With more investigation it seemed that /usr/bin was being put in the path at two different points. Nothing I did seemed to fix the error (such as starting vscode on a new terminal, starting vscode after I had called the idf/export.sh, and so on). So I decided to add a new user to my linux installation and reinstall everything from scratch to see if the problem still occurred. It did not. The new user and installation had all the same basic setup as my existing one, including it being a multi profile set up but none of the changed settings. The PATH was correct and it started and stopped the .espressif version of the openocd program with no issues.

I then cleaned out my install of vscode and the espidf (by deleting HOME/.config/Code/, HOME/.vscode, HOME/.espressif/ HOME/.cache/ HOME/esp/esp-idf and anything else I could think of).

Started vscode, reinstalled the esp-idf (and other programming extensions), and then compared the new set up to the original one. There were a couple of changes that the new install doesn't default in to various files in the same way the earlier versions did so I didn't copy those settings across; only the settings I absolutely wanted (such as spell checker, font sizes and so on). The new version now seems to work with no issues.

The only real differences I could see were "idf.pythonInstallPath": "/usr/bin/python3", instead of "/home/wilsonj/.espressif/python_env/idf5.5_py3.12_env/bin/python", and "idf.customExtraVars": { "OPENOCD_SCRIPTS": "/home/wilsonj/.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts", "ESP_ROM_ELF_DIR": "/home/wilsonj/.espressif/tools/esp-rom-elfs/20240305/" which didn't exist in the new version.

I'm guessing that with multiple upgrades and changes and experimentation and version upgrades that possibly some holdover setting, or cache was bad. Especially as a lot of the original esp-idf-extension was stored in settings files where as now its all stored within the extension itself unless its a value that specifically gets changed.

But the end result is it now seems to work ok.

I shall look forward to the next version upgrade.

@brianignacio5
Copy link
Collaborator Author

Hi @i400s Sorry for late reply. I will update the PR to use the ESP-IDF Current Project instead of the dropdown. It will require a few changes to persist the current workspace folder but I think is worth it in the long run.

Regarding the second issue, I noticed it is because you had installed the default openocd in /usr/bin/openocd which will conflict to find the one from ESP-IDF Tools directory. In the new setup, it is very likely that the issue doesn't happen because it is not included /usr/bin/openocd in env variable PATH.

@i400s
Copy link

i400s commented Jan 13, 2025

Hi @brianignacio5, no worries. I know what its like when you're trying to juggle 101 different updates and changes and fixes.

Yeah, something got added at some point to the PATH but a good clear out of an app and its config and data never goes amiss :-)

I shall look forward to the next release.

Thanks for the great work you do.

@brianignacio5 brianignacio5 changed the title update env var collection resolve undefined folder Resolve folder when using launch config from code-workspace Jan 16, 2025
Copy link

Download the artifacts for this pull request:
You can test these changes by installing this VSIX by click menu View -> Command Palette..., type Install from VSIX and then select downloaded esp-idf-extension.vsix file to install the extension.

Copy link
Collaborator

@radurentea radurentea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@i400s
Copy link

i400s commented Jan 17, 2025

Installed vsix. Can confirm that resolves the issue for a .code-workspace level launcher and that it uses the selected "ESP-IDF: Current project" directory for both the espidf and gdbtarget. Makes it a lot easier to work with as only one launcher needs to exist at the workspace level instead of multiple launch.json files as I tend to flip between coding examples and tests the components I'm working on.

@Fabricio-ESP Fabricio-ESP changed the title Resolve folder when using launch config from code-workspace [VSC-1552] Resolve folder when using launch config from code-workspace Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Launch gdbtarget fails at the workspace level (VSC-1552)
3 participants