This tutorial shows how to develop projects for the Espressif ESP32 chip using Visual Studio, VisualGDB and the new ESP-IDF framework.
Warning: The MSBuild-based ESP32 projects are deprecated since VisualGDB 5.4. Please use the Advanced ESP-IDF Project Subsystem instead. The rest of the steps shown in this tutorial will still work.
Watch the video tutorial here and follow the step that should be done in Visual Studio 2017 Community Edition. Skip the steps that describing uploading the nanoCLR into the STM32 Nucleo board. Debugging nanoCLR. If you want to debug the nanoCLR code on the ESP32 chip you'll need an JTAG debugging adapter. ESP32 WROVER KIT already includes one. Browse other questions tagged visual-studio-code arduino wifi esp32 platformio or ask your own question. The Overflow Blog Podcast 323: A director of engineering explains scaling from dozens of Level Up: creative coding with p5.js – part 2.
Visual Studio Code Esp32 Arduino
3 hours ago The Sailor Hat is based around a standard ESP32-WROOM-32 module. Interfaces include a CAN bus transceiver. ESPHome and Visual Studio Code. Getting started with ESP32-C3 on Visual Code, ESP-IDF Plugin. This walks through the process of setting up the VSCode platform for the new Espressif ESP32-C3 using the ESP-IDF Plugin for VSCode. Nhra pro stock drag racing. The ESP32 has two powerful Xtensa cores, allowing for a great deal of variety of program architectures. The FreeRTOS OS that comes with ESP-IDF is capable of multi-core preemptive multithreading, allowing for an intuitive way of writing software.
We will show how to build, program and debug a basic ESP32 program over JTAG on the Sparkfun ESP32 Thing board. In order to use JTAG with ESP32 you will need to connect the following pins to your JTAG programmer:
Pin name on ESP32 chip | Signal on ESP32 Thing board | Pin on the ESP32 board | JTAG signal | Pin on JTAG20 cable |
+3.3V | +3.3V | 5 on J1 | +3.3V | 1 |
Reset | CHIP_PU | 6 on J1 | SRST | 3 |
GND | GND | 1 on J1 | GND | 4 |
MTDI | 12 | 8 on J1 | TDI | 5 |
MTMS | 14 | 9 on J1 | TMS | 7 |
MTCK | 13 | 7 on J1 | TCK | 9 |
MTDO | 15 | 11 on J2 | TDO | 13 |
If you are using a different ESP32 board, consult your board schematics to find the pin numbers corresponding to the signals listed above.
The assembled JTAG debugging setup for the ESP32 Thing board looks as follows:
Before you begin, install VisualGDB 5.2 or later.
Note: VisualGDB 5.4 supports the new advanced ESP-IDF project subsystem that delivers better development experience than MSBuild-projects shown in this tutorial. Once you get basic debugging to work, follow this tutorial to get started with the new advanced ESP-IDF project subsystem.
- Start Visual Studio and open the VisualGDB Embedded Project Wizard:
- On the first page proceed with the default MSBuild subsystem and click “next”:
- On the next page select the ESP32 toolchain. If it is not installed, VisualGDB will download and install it automatically. If it is not shown in the wizard, install it via Tools->VisualGDB Package Manager. Then select the regular ESP32 device:
- On the Sample Selection page pick the LEDBlink sample and enter the pin number where your LED is connected. On the Sparkfun ESP32 Thing board used in this tutorial the LED is connected to pin #5:
- On the debug settings page select your JTAG programmer. For Olimex ARM-USB-OCD-H and other FT2232-based ones, enable the “explicit speed” checkbox:
- You can test the OpenOCD settings and check for common driver problems by pressing the “Test settings” button:
- Press “Finish” to generate your project. Due to a bug in the ESP-IDF framework, the projects built with no optimization (which is the default option for the debug configuration) will not work properly. To fix this, open Visual Studio Project Properties and change the optimization for the project to “Optimize for GDB (-Og)”. If you are using an older version of VisualGDB that does not show this option, simply enter -Og in the “Optimization” field:
- Build your project via Ctrl-Shift-B:
- Try building the project again and ensure it is shown as “up to date”:If you have installed the latest Cygwin-based toolchain and are using VisualGDB 5.2 or earlier, VisualGDB will not handle the project dependencies correctly and will try building all of the source files again. If this happens, open VisualGDB Project Properties, go to the Path Mapping page and set GDB Path Style to Cygwin and the Windows directory for absolute paths to your toolchain directory:
- Press F5 to start debugging. VisualGDB will automatically program the FLASH memory on the device:
- After programming the program may produce a stop event in a random location inside the ESP32 libraries. You can safely ignore it by pressing “Continue”:
WARNING! If you are using ESP-IDF 2.0, the bootloader may randomly hang after a software reset. If this happens, remove all breakpoints, press the Reset button on the board, resume the program and set your breakpoints again. - Once the programming is complete, the onboard LED should start blinking:
- Set a breakpoint somewhere in the blink_task() function and wait for it to trigger:
- Note how the 2 ESP32 cores got mapped to 2 threads in the VisualGDB threads window:
- Because we have enabled minimum optimizations, the unused variables will not be shown and stepping through code will sometimes look strange. You can fix this by disabling optimization for specific files that you want to debug. This will not break the ESP-IDF framework and will provide better debugging experience:
- Another limitation of the ESP32 debugger is the inability to read local variables for the top-level functions. If you encounter this problem, while debugging your thread functions, simply wrap it with another function:We have implemented some utilities commands that can be used in tasks.json and launch.json likeas shown in the debugging documentation.
espIdf.getExtensionPath
: Get the installed location absolute path.espIdf.getOpenOcdScriptValue
: Return the value of OPENOCD_SCRIPTS fromidf.customExtraVars
or from system OPENOCD_SCRIPTS environment variable.espIdf.getOpenOcdConfig
: Return the openOCD configuration files as string. Example'-f interface/ftdi/esp32_devkitj_v1.cfg' -f board/esp32-wrover.cfg
.espIdf.getProjectName
: Return the project name from current workspace folderbuild/project_description.json
.espIdf.getXtensaGcc
: Return the absolute path of the xtensa toolchain gcc for the ESP-IDF target given byidf.adapterTargetName
configuration setting andidf.customExtraPaths
.espIdf.getXtensaGdb
: Return the absolute path of the xtensa toolchain gdb for the ESP-IDF target given byidf.adapterTargetName
configuration setting andidf.customExtraPaths
.
Available Tasks in tasks.json
There is also some tasks defined in Tasks.json, which can be executed by running F1 and writingTasks: Run task
and selecting one ofthe following:Build
- Build ProjectSet Target to esp32
Set Target to esp32s2
Clean
- Clean the projectFlash
- Flash the deviceMonitor
- Start a monitor terminalOpenOCD
- Start the openOCD serverBuildFlash
- Execute a build followed by a flash command.
Note that for OpenOCD tasks you need to define OPENOCD_SCRIPTS in your system environment variables with openocd scripts folder path.Code of Conduct
This project and everyone participating in it is governed by the Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].Programming Esp32 With Visual Studio
License
Visual Studio Esp32 Mac
This extension is licensed under the Apache License 2.0. Please see the LICENSE file for additional copyright notices and terms.