How to run "espcoredump.py" from pio?

Hi,

I want to use the ESP32 core dump feature for the flash. Is there a possible solution to run the espcoredump.py command from PlattformIO? I got the following error when I try to run the script manually:

C:\.platformio\packages\framework-espidf> python components/espcoredump/espcoredump.py
Esptool is not found! Set proper $IDF_PATH in environment.

I could get it to run once I execute export.bat in framework-espidf (ignore the “compiler not found” messages, just setting IDF_PATH is important) and installing some missing Python dependencies

export.bat
python -m pip install construct
python -m pip install pygdbmi
C:\Users\Max\.platformio\packages\framework-espidf>python components/espcoredump/espcoredump.py --help
usage: espcoredump.py [-h] [--port PORT] [--baud BAUD] [--gdb-timeout-sec GDB_TIMEOUT_SEC]
                      {dbg_corefile,info_corefile} ...

espcoredump.py v0.4-dev - ESP32 Core Dump Utility

positional arguments:
  {dbg_corefile,info_corefile}
    dbg_corefile        Starts GDB debugging session with specified corefile
    info_corefile       Print core dump info from file

optional arguments:
  -h, --help            show this help message and exit
  --port PORT, -p PORT  Serial port device
  --baud BAUD, -b BAUD  Serial port baud rate used when flashing/reading
  --gdb-timeout-sec GDB_TIMEOUT_SEC
                        Overwrite the default internal delay for gdb responses

Hi,

sorry for the late response. I didn´t find the time to test it. Please take a look at my terminal output:

PS C:\.platformio\packages\framework-espidf> ./export.bat
Setting IDF_PATH: C:\.platformio\packages\framework-espidf

Adding ESP-IDF tools to PATH...
ERROR: tool xtensa-esp32-elf has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool esp32ulp-elf has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool cmake has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool openocd-esp32 has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool mconf has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool ninja has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool idf-exe has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool ccache has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
PS C:\.platformio\packages\framework-espidf> python -m pip install construct
Collecting construct
  Downloading construct-2.10.67.tar.gz (57 kB)
     |████████████████████████████████| 57 kB 1.1 MB/s
Building wheels for collected packages: construct
  Building wheel for construct (setup.py) ... done
  Created wheel for construct: filename=construct-2.10.67-py3-none-any.whl size=59037 sha256=f1ad9b9c18a676430ffa00d7a8cd28593a92d6459c8ad8eb4f3f5ef315b171d9
  Stored in directory: c:\users\...\appdata\local\pip\cache\wheels\e7\f8\22\2bfb6d0b41af703485d9c323cfbcf1bb99992e3b9a8650c2db
Successfully built construct
Installing collected packages: construct
Successfully installed construct-2.10.67
WARNING: You are using pip version 21.1.2; however, version 21.1.3 is available.
You should consider upgrading via the 'C:\.platformio\penv\Scripts\python.exe -m pip install --upgrade pip' command.
PS C:\.platformio\packages\framework-espidf> python -m pip install pygdbmi
Collecting pygdbmi
  Downloading pygdbmi-0.10.0.1-py3-none-any.whl (16 kB)
Installing collected packages: pygdbmi
Successfully installed pygdbmi-0.10.0.1
WARNING: You are using pip version 21.1.2; however, version 21.1.3 is available.
You should consider upgrading via the 'C:\.platformio\penv\Scripts\python.exe -m pip install --upgrade pip' command.
PS C:\.platformio\packages\framework-espidf> python .\components\espcoredump\espcoredump.py --help
Esptool is not found! Set proper $IDF_PATH in environment.

Edit: It looks like an issue with PowerShell. It works when I follow your steps by using a git terminal (which uses bash). But it also doesn´t work from a PIO shell in VS code:

PS C:\.platformio\packages\framework-espidf> ./export.bat                                                        
Setting IDF_PATH: C:\.platformio\packages\framework-espidf

Adding ESP-IDF tools to PATH...
ERROR: tool xtensa-esp32-elf has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool esp32ulp-elf has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it. 
ERROR: tool cmake has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.        
ERROR: tool openocd-esp32 has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
ERROR: tool mconf has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.        
ERROR: tool ninja has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.        
ERROR: tool idf-exe has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.      
ERROR: tool ccache has no installed versions. Please run 'C:\.platformio\packages\framework-espidf\install.bat' to install it.
PS C:\.platformio\packages\framework-espidf> python -m pip install construct                                     
Requirement already satisfied: construct in c:\.platformio\python3\lib\site-packages (2.10.67)
ERROR: Error while checking for conflicts. Please file an issue on pip's issue tracker: https://github.com/pypa/pip/issues/new
Traceback (most recent call last):
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3021, in _dep_map
    return self.__dep_map
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3012, in _parsed_pkg_info
    return self._pkg_info
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _pkg_info

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\.platformio\python3\lib\site-packages\pip\_internal\commands\install.py", line 514, in _determine_conflicts
    return check_install_conflicts(to_install)
  File "C:\.platformio\python3\lib\site-packages\pip\_internal\operations\check.py", line 105, in check_install_conflicts
    package_set, _ = create_package_set_from_installed()
  File "C:\.platformio\python3\lib\site-packages\pip\_internal\operations\check.py", line 47, in create_package_set_from_installed
    package_set[name] = PackageDetails(dist.version, dist.requires())
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2736, in requires
    dm = self._dep_map
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3023, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3032, in _compute_dependencies
    for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3014, in _parsed_pkg_info
    metadata = self.get_metadata(self.PKG_INFO)
  File "C:\.platformio\python3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1895, in get_metadata
    raise KeyError("No metadata except PKG-INFO is available")
KeyError: 'No metadata except PKG-INFO is available'
WARNING: You are using pip version 21.0.1; however, version 21.1.3 is available.
You should consider upgrading via the 'C:\.platformio\python3\python.exe -m pip install --upgrade pip' command.
PS C:\.platformio\packages\framework-espidf>