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

Debugger problem with project configuration added (VSC-1512) #1334

Closed
1 task done
executer-uno opened this issue Nov 1, 2024 · 5 comments
Closed
1 task done

Debugger problem with project configuration added (VSC-1512) #1334

executer-uno opened this issue Nov 1, 2024 · 5 comments
Assignees
Labels
bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue)

Comments

@executer-uno
Copy link

executer-uno commented Nov 1, 2024

OS

Windows

Operating System version

Windows 10 Pro

Visual Studio Code version

1.8.0 (with hotfix from here #1283)

ESP-IDF version

5.1.4

Python version

Python 3.11.2

Doctor command output

DOCTOR_output.txt

Extension

extensionLOG.txt

Description

I have a project for ESP32S3 with Project Configurations added. And as soon as configurations were added - JTAG Debug failed to launch (debug via ESP32S3 built in USB JTAG).
So I made some workaround, based on clear HelloWorld example - there are two projects in attached archive - hello_world and hello_world_no_config. Second one works great, so Im sure thar hardware and environment are Ok and able to debug via ESP32S3 built in USB JTAG, but project with configuration - not managed to start debug session.
IDF_HelloWorld_JTAG.zip

hello_world_no_config - works properly.
compile, download (via UART), monitor - ok. debug - ok, connected and waiting on void app_main(void) entry point. Here is reference OUTPUT log:
proper_OUTPUT.txt

hello_world - no debug session starts.
As soon as project config added (at least one) via ESP-IDF Open Project configuration wizard debug stops working.
Here is esp_idf_project_configuration.json (also in attached projects):

{
  "config_uno": {
    "build": {
      "compileArgs": [],
      "ninjaArgs": [],
      "buildDirectoryPath": "",
      "sdkconfigDefaults": [],
      "sdkconfigFilePath": ""
    },
    "env": {},
    "flashBaudRate": "",
    "idfTarget": "esp32s3",
    "monitorBaudRate": "",
    "openOCD": {
      "debugLevel": 4,
      "configs": [
        "board/esp32s3-builtin.cfg"
      ],
      "args": []
    },
    "tasks": {
      "preBuild": "",
      "preFlash": "",
      "postBuild": "",
      "postFlash": ""
    }
  }
}

So, after compile, download (via UART) and check HelloWorld in Monitoring Device console, calling DEBUG button makes following actions:
Error banner appears
image
Open OCD server launched and I see restarts of the ESP by the HelloWorld firmware:


C:\esp\esp_tools\tools\xtensa-esp-elf-gdb\12.1_20231023\xtensa-esp-elf-gdb\bin\xtensa-esp32s3-elf-gdb.exe


C:\esp\esp_tools\tools\openocd-esp32\v0.12.0-esp32-20230921\openocd-esp32\bin\openocd.exe


[/Flash]
[OpenOCD]
Open On-Chip Debugger v0.12.0-esp32-20230921 (2023-09-21-13:40)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html

debug_level: 2

Info : only
 one transport option; autoselecting 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and P
ID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000

Info : Listening 
on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections

Info : esp_usb_jtag:
 serial (DC:54:75:F1:7D:14)
Info : esp_usb_jtag: Device found. Base spe
ed 40000KHz, div range 1 to 255
Info : clock spee
d 40000 kHz

Info : JTAG tap
: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: e
sp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)

Info : starting gdb server for e
sp32s3.cpu0 on 3333
Info : Listening on port 3333 for gdb conn
ections

Info : [esp32s
3.cpu0] Debug controller was reset.
Info : [esp32s3.cpu0] Core was reset.

Info : [esp32s3
.cpu1] Debug controller was reset.
Info : [esp32s3.cpu1] Core was reset.

Info : [esp32s3.cpu0] Target halted, P
C=0x40378FBA, debug_reason=00000000

Info : [esp32s3
.cpu0] Reset cause (3) - (Software core reset)

Info : [esp32s3.cpu1] Target hal
ted, PC=0x40378FBA, debug_reason=00000000

Info : [esp3
2s3.cpu1] Reset cause (3) - (Software core reset)

Info : [esp32s3.c
pu0] Debug controller was reset.
Info : [esp32s3.cpu0] Core was reset.

Info : [esp32s3.
cpu1] Debug controller was reset.
Info : [esp32s3.cpu1] Core was reset.

Info : [esp32s3.cpu0] 
Target halted, PC=0x4004883B, debug_reason=00000000

Info : [esp32s3.
cpu0] Reset cause (3) - (Software core reset)

Info : [esp32s3.cpu1] 
Target halted, PC=0x40041A76, debug_reason=00000000

Info : [esp32s3
.cpu1] Reset cause (3) - (Software core reset)

Info : [esp32s3.c
pu0] Debug controller was reset.
Info : [esp32s3.cpu0] Core was reset.

Info : [
esp32s3.cpu1] Debug controller was reset.
Info : [esp32s3.cpu1] Core wa
s reset.

Info : [esp32s3.c
pu0] Target halted, PC=0x40048C2B, debug_reason=00000000

Info : [esp32s3.cpu0] Reset cause (12) - (Software CPU0 reset)

Info : [esp32s3.cpu1] T
arget halted, PC=0x40041A76, debug_reason=00000000

Info : [esp32s3.cp
u1] Reset cause (12) - (Software CPU1 reset)

Info : [esp32s3.cpu
0] Debug controller was reset.
Info : [esp32s3.cpu0] Core was reset.

Info : [esp3
2s3.cpu1] Debug controller was reset.
Info : [esp32s3.cpu1] Core wa
s reset.

Info : [esp32s3.cpu0] 
Target halted, PC=0x4004883B, debug_reason=00000000

Info : [e
sp32s3.cpu0] Reset cause (12) - (Software CPU0 reset)

... and so on ...

But no debug session launched in VSC.

Debug Message

See "Description" section

Other Steps to Reproduce

Just for clarification I also made a test with actual varsion of ESP IDF VSC Extension v1.8.1.
Build, Download, Monitor - fine.
Debug - launches OpenOCD and connects Debug session, hurray! Is it really works now!?
Disconnect debug session, select only project configuration exists "config_uno" and make a final try to be sure:
Debug button:

C:\esp\esp_tools\tools\xtensa-esp-elf-gdb\12.1_20231023\xtensa-esp-elf-gdb\bin\xtensa-esp32s3-elf-gdb.exe
C:\esp\esp_tools\tools\openocd-esp32\v0.12.0-esp32-20230921\openocd-esp32\bin\openocd.exe

And stops, no luck 💥

Check if OpenOCD launches at all via ESP menu > Start/Stop OpenOCD Server > Start:

OPENOCD_SCRIPTS environment variable is missing. Please set it in idf.customExtraVars or in your system environment variables.
C:\esp\esp_tools\tools\openocd-esp32\v0.12.0-esp32-20230921\openocd-esp32\bin\openocd.exe

Nope ☹.
What else? Debug Menu and start "Launch" debug configuration (second item in launch.json file. It returns just:

The following Python requirements are not satisfied:
Error while checking requirement 'pywin32>=227; sys_platform == "win32"'. Package was not found and is required by the application: No package metadata was found for pywin32

Error while checking requirement 'esp-debug-backend'. Package was not found and is required by the application: No package metadata was found for esp-debug-backend
To install the missing packages, please run "install.bat"
Diagnostic information:
    IDF_PYTHON_ENV_PATH: C:\esp\esp_tools\python_env\idf5.1_py3.11_env
    Python interpreter used: C:\esp\esp_tools\python_env\idf5.1_py3.11_env\Scripts\python.exe
Command failed: C:\esp\esp_tools\python_env\idf5.1_py3.11_env\Scripts\python.exe c:\esp\v5.1.4\esp-idf\tools\check_python_dependencies.py -r c:\Users\p.bazhenov\.vscode\extensions\espressif.esp-idf-extension-1.8.1\esp_debug_adapter\requirements.txt

As soon Im sure environment is ok (by hello_world_no_config project debug) looks like that project configuraion crushes some references to environment, or some parameters was not set esp_idf_project_configuration.json not takes its default value (PS are there any detailed descrpition of esp_idf_project_configuration.json fields?)

So, Im stuck in that place. The best I have - is to launch OpenOCD server connected to ESP but with no Debug session from VSC side 😥

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@executer-uno executer-uno added the bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue) label Nov 1, 2024
@github-actions github-actions bot changed the title Debugger problem with project configuration added Debugger problem with project configuration added (VSC-1512) Nov 1, 2024
@executer-uno
Copy link
Author

executer-uno commented Nov 1, 2024

Extra notices: Start/Stop OpenOCD Server command from ESP-IDF menu returns:

OPENOCD_SCRIPTS environment variable is missing. Please set it in idf.customExtraVars or in your system environment variables.
C:\esp\esp_tools\tools\openocd-esp32\v0.12.0-esp32-20230921\openocd-esp32\bin\openocd.exe

Ignoring the fact that OPENOCD_SCRIPTS alredy defined in Settings>Extensions>ESP-IDF>Custom extra vars to proper path
C:\esp\esp_tools\tools\openocd-esp32\v0.12.0-esp32-20230921\openocd-esp32\share\openocd\scripts

UPD: this issue may be fixed with adding parameter in env list in project configurations, but originally I suppose VSC project configurations json parameters as additionals but not instead of predefined
"env": {"OPENOCD_SCRIPTS": "C:/esp/esp_tools/tools/openocd-esp32/v0.12.0-esp32-20230921/openocd-esp32/share/openocd/scripts"},

🥳 with env list defined Im not managed to reproduce error any more, debug session starts each time.
So , with following esp_idf_project_configuration.json HelloWorld project from zip should works fine now
esp_idf_project_configuration.json

But, the root issue is esp_idf_project_configuration.json env entry overrides some environment variables and makes OPENOCD_SCRIPTS undefined.

What also helps - is to remove env entry from esp_idf_project_configuration.json at all - then it not overrides environment and works as well. So looks like it is just UX issue - default esp_idf_project_configuration.json must contains some reference to global variables and overrides them either contains empty env and not ovverides but append env entry values.

@executer-uno
Copy link
Author

executer-uno commented Nov 1, 2024

Previous post help for HelloWorld project. But now I can not completly tansfer the solution to my master project. I have following inconsistence:
In HelloWorld project both "Eclipse CDT GDB Adapter" and "Launch" debug profile starts and connects but in my master project only green play button ▶ works on "Launch" and from debug command bar:
image
image
But all other debugging buttons leads to error message:
image
image
image
image
Error:
image

So I feels standing on unstable floor

@brianignacio5
Copy link
Collaborator

brianignacio5 commented Nov 4, 2024

Thank you for your issue. Will take a look at it!

Is your environment using the network port 43476 ? This is the default network portused by debug adapter server and if it used it will not work.

You can try updating launch.json like this:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "gdbtarget",
      "request": "attach",
      "name": "Eclipse CDT GDB Adapter",
      "debugPort": ###
    }
  ]
} 

and replace ### for a different server port.

I'll test the project configuration example you mentioned. Your settings shouldn't affect the debug experience but I'll take a look see if we missed something.

@brianignacio5
Copy link
Collaborator

Hi @executer-uno

Could you please try with the current master vsix installer link here ?

I've tried using esp32s3 devkitc-1 with the same project configuration you use in a blink ESP-IDF v5.4 example. I didn't observe the issue you posted (cannot read properties of null). We've might have fixed it in master already.

@brianignacio5 brianignacio5 self-assigned this Nov 5, 2024
@executer-uno
Copy link
Author

You are right. VSIX from master works brilliant.
Thank you for quick support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue)
Projects
None yet
Development

No branches or pull requests

2 participants