Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

OllieK
Posts: 58
Joined: Mon Jan 18, 2016 8:08 am
Location: USA, PA
Contact:

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby OllieK » Sun Jan 17, 2021 5:22 am

Some additional observations:
1. FT2232HL/IDF 4.1 continues to work, but is quite fragile
2. I have not been able to install IDF 4.2
3. I have not been able to get FT232H/IDF 4.1 to work

espdorian
Posts: 33
Joined: Sat Dec 26, 2020 10:57 am

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby espdorian » Sun Jan 17, 2021 2:48 pm

hmm it mena everyhing is still a bit fragile for some reason. I have tried IDF4.1 with extenseion v0.6 and VS code on a completely different computer. Not able to finish the installation as described.

OllieK
Posts: 58
Joined: Mon Jan 18, 2016 8:08 am
Location: USA, PA
Contact:

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby OllieK » Sun Jan 17, 2021 9:00 pm

Espdorian,

I will do an installation of all steps on a Win 10 computer without any ESP or VS code for IDF 4.1 with FT2232HL. I will record all the steps to confirm that everything works as intended. I will do this because it is bothering me that things have not been as repeatable as they should.

Compared to the STM32 world, I am missing the robustness in ESP IDF. For example, in debugging a loop with a single breakpoint and a vTaskDelay the breakpoint works twice, but not on the third time. If I add a second breakpoint, then it works as it should.

OllieK
Posts: 58
Joined: Mon Jan 18, 2016 8:08 am
Location: USA, PA
Contact:

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby OllieK » Mon Jan 18, 2021 1:56 am

I was surprised, how smooth the installation into a vanilla system was. The only snafu was related to the serial monitor problem introduced in Espressif IDF 0.6.0. My original workaround works in older Windows 10 environment, but today I got the latest Windows 10 upgrade and the CMD was replaced with powershell and a new workaround is required.

The bottom line is, there are no software setups required for the debugger. Once it is connected, it just works.

My setup has the following components
- Windows 10 Pro, version 20H2
- VSC 1.52.1
- Espressif IDF 0.6.0
- ESP-IDF 4.1
- FT2232HL (ESP-Prog used to work too)
- ESP32 Pico D4

In half an hour, you can start the debugging with the following steps

1. Debugger Interface Driver
- If Device Manager shows two Dual RS232-HS as Other devices, the FT2232HL driver has to be replaced
- Download the latest Zadig version from https://zadig.akeo.ie/
- Start Zadig, in Options menu, select List All Devices, select Dual RS232-HS (interface 0)
- Select Install Driver to replace the FTDI driver with WinUSB driver

2. Python
- Install latest Python version from https://www.python.org/downloads/
- Disable path length limit because ESP IDF VSCE will use a lot of PATH items

3. Git
- Download latest Git from https://gitforwindows.org/
- Install Git with the default settings, optionally change the default editor

4. Visual Studio Code
- Install VSC from https://code.visualstudio.com/
- Start VSC, in Extensions (Ctrl-Shift-X), enter "esp" in search field
- Select Espressif IDF, select Install
- In Extensions (Ctrl-Shift-X), select ESP-IDF Explorer, select EXPRESS option
- There should be no need to change any of these options
- Select Install
- If you are repeating this, use F1 or Ctrl-Shift-P to select command ESP-IDF: Configure ESP-IDF extension

5. Pip Update
- If the ESP EDF Extension configuration complaints about pip version it can be updated
- On Command terminal (CMD), enter "python -m pip install --upgrade pip"

6. Select a Template
- Open Command Palette (F1 or Ctrl-Shift-P), select ESP-IDF: Show Examples Projects
- In get-started, select hello_world, select Create project using example hello_world
- Save the project folder in your place, such as Documents\ESP32\Projects\Hello_World

7. Target System
- Open Command Palette, select ESP-IDF: Select port to use

8. Compile and Flash
- Use the ESP-IDF Build project icon on bottom of the VSC window to start compilation
- Use the ESP-IDF Flash device icon on bottom of the VSC window to start flashing
- On first time it asks to select the flash method, select UART

9. Monitor device
- Use the ESP-IDF Monitor device icon on bottom of the VSC window to start serial monitoring
- With Espressif IDF 0.6.0, this is not working
- In the workaround, select Terminal Menu, select New Terminal to start CMD
- In the terminal, enter C:\Users\name\esp\esp-idf\export && idf.py -p comX monitor
- Where name = user name, comX = com port number
- Note: The latest update of Windows 10 uses powershell instead of CMD.
There the multicommand separator is semicolon instead of double ampersand

10. Start debugger
- In the Run menu, select Start Debugging (F5)

Just wondering, why Espressif is not publishing these simplified steps :ugeek:

jas39_
Posts: 21
Joined: Mon Aug 29, 2016 8:26 pm

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby jas39_ » Thu Jan 21, 2021 9:16 pm

Thats a great step-by-step! Could you please also add what your launch.jso looks like? I think I've messed mine up.

OllieK
Posts: 58
Joined: Mon Jan 18, 2016 8:08 am
Location: USA, PA
Contact:

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby OllieK » Thu Jan 21, 2021 9:42 pm

I have not touched lounch,json

Code: Select all

{
    // 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": "espidf",
            "name": "Launch",
            "request": "launch",
        }
    ]
}

espdorian
Posts: 33
Joined: Sat Dec 26, 2020 10:57 am

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby espdorian » Sat Jan 23, 2021 7:24 pm

@OllieK
Thanks for your clear steps. It is also something I am missing. It is hard to believe for me that all Windows versions are that much different.
I tried from scratch on a 'Vanilla' PC and still it did not match tne instructions I have seen.

But I was wondering your explanation, it seems to me, you are debugging with a monitor application on the target, not with JTAG.
A monitor is usually intrusive. Is your setup using monitor for debugging or JTAG ?
Last edited by espdorian on Sun Jan 24, 2021 7:32 am, edited 1 time in total.

OllieK
Posts: 58
Joined: Mon Jan 18, 2016 8:08 am
Location: USA, PA
Contact:

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby OllieK » Sun Jan 24, 2021 2:09 am

@espdorian,

I do confirm that I am running the JTAG debugger within VSC both with and without the serial monitor. I did start the testing using ESP-Prog. In that configuration, I had the serial monitor connected either through the target system USB connector or through the ESP-Prog serial interface. In the first case there are two USB cables required. In the second case there is only one USB cable.

I have been too lazy to check the same functionality with FT2232HL. I have prepared the serial wiring there, but never tested it - it should be OK.

The only caveat I am observing at the moment is that some debugging related S/W stays active even after ending the debugging session. Next time, when starting the flashing, it fails with an error message. The remedy for that is to disconnect the FT2232HL USB cable. It can be reconnected either before or after the serial monitor is started. The next debugging session starts by simply pushing F5. Be patient, the debugger takes some time to start.

espdorian
Posts: 33
Joined: Sat Dec 26, 2020 10:57 am

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby espdorian » Sun Jan 24, 2021 7:31 am

@OllieK
One of the biggest caveats which caused me troubles, is that you really have to do the step "create project from template"
It is intuitive to open one of the 'examples' folders, build it and press F5 for debugging.
This does not work and you end up with an incorrect launch.json

So no I am getting a bit further, after pressing F5 openOCD is started, detects the chip (already flashed it using serial)
Then these are the last messages I see:

Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset.
Info : esp32: Core 0 was reset.
Info : Listening on port 3333 for gdb connections

And nothing happens. Looks like GDB does not connect to open OCD (which looks the same I experienced some weeks ago when trying from the command line)

The toolbar at the left side shows 1 active debug session, but I could not find a way to terminate this session, other than to restart VScode. When starting debug session I get the debug toolbar at the top of the screen, sometimes when pressing restart it disappear and I can not get it back again.

Note:
Just noticed the following message after starting VScode:
Unable to resolve configuration with compilerPath "H:\.espressif\tools\xtensa-esp32-elf\esp-2020r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gdb.exe". Using "C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\gcc.exe" instead.

Which might be related. The question is why, the path is correct. (have to say that my last install attempt uses ESP-IDF extension 0.6.1)


Newly added:
No idea why, but a next attempt after VScode restart did more, there now seems to be a connection to openOCD:
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Error: No symbols for FreeRTOS
Info : Target halted. CPU0: PC=0x4009F624 (active)
Info : Target halted. CPU1: PC=0x00000000
Info : cpu0: Target halted, PC=0x400916EA, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 21 KB
Info : Flash mapping 1: 0x20020 -> 0x400d0020, 75 KB
Info : cpu0: Target halted, PC=0x400916EA, debug_reason=00000001
Info : Auto-detected flash bank 'esp32.flash' size 4096 KB
Info : Using flash bank 'esp32.flash' size 4096 KB

But still unable to debug/run. 2 breakpoints, nothing happens.

Behavior is also unpredictable, each next attempt is different. Often it just stops after: "Info : Listening on port 3333 for gdb connections" Which means the gdb does not connect with openOCD.

For now I give up. Did in total approx 8 times an installation of VScode, IDF IDS extension on 2 different PC's, I use the official Espressif debugger, I tried both from VScode as well as command line openOCD+GDB. Never got a single working debug session. :cry:
Last edited by espdorian on Mon Jan 25, 2021 7:46 am, edited 1 time in total.

OllieK
Posts: 58
Joined: Mon Jan 18, 2016 8:08 am
Location: USA, PA
Contact:

Re: Anyone managed to get debugging working with IDF 4.1 / VS Code / Windows

Postby OllieK » Sun Jan 24, 2021 9:24 pm

It's sad that the ESP IDF tools are not robust. Sorry to hear all the extra effort you have spent with this problem.

It is possible that I have seen some similar messages during my experimentation, but not anymore with my normal development steps. When starting the debugger, the ESP-IDF Debug Adapter OUTPUT shows

DEBUG_ADAPTER_STARTED
2021-01-24 16:13:31,129 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_STARTED
DEBUG_ADAPTER_READY2CONNECT
2021-01-24 16:13:31,134 - Debug Adapter (main) - CRITICAL - Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT

DEBUG CONSOLE shows

Debug adapter -> Extension: DEBUG_ADAPTER_STARTED
Debug adapter -> Extension: DEBUG_ADAPTER_READY2CONNECT
Debug Adapter initialized
Debug Adapter is running

If I try to start the Serial Monitor when the debugger is waiting, the ESP-IDF Monitor TERMINAL shows a continuous stream of messages

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun 8 2016 00:22:57

To me, the main challenge is that I have not been able to install IDF V4.2 to support ESP32s2 development. I can observe that many other developers have been able to use ESP32s2. Perhaps, I need to wait for the V4.2 to be in the main stream :x

Who is online

Users browsing this forum: No registered users and 20 guests