esp32开发-vs2019/2022环境搭建

效果图

安装 esp-idf与tools

https://dl.espressif.com/dl/esp-idf-tools-setup-2.3.exe
这个安装程序会自动下载github与esp32官网(国内)的文件,最好先设置全局代理,下载国内时可能出错,再取消代理可继续下载,如弹出错误导致安装程序退出可重新运行继续下载安装.

本文相关文件位置

esp-idf: D:\iot_dev\toolchain\esp-idf\v4.4.1

esp tools: D:\iot_dev\toolchain\esp-idf\.espressif

python3:  C:\Program Files\python3.10

git: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd

CMakeSettings.json - (项目根目录)

				
					{
  "configurations": [
    {
      "name": "ESP-IDF_4_1-Debug",
      "generator": "Ninja",
      "configurationType": "Debug",
      "inheritEnvironments": [ "linux_x64" ],
      "buildRoot": "${projectDir}\\build",
      "installRoot": "${projectDir}\\install",
      "cmakeCommandArgs": "--warn-uninitialized",
      "buildCommandArgs": "",
      "ctestCommandArgs": "",
      "environments": [
        {
          "IDF_GIT_DIR": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\Git\\cmd",
          "IDF_PATH": "D:\\iot_dev\\toolchain\\esp-idf\\v4.4.1",
          "IDF_TOOLS_PATH": "D:\\iot_dev\\toolchain\\esp-idf\\.espressif",
          "IDF_PYTHON_DIR": "C:\\Program Files\\python3.10",
          "IDF_PYTHON_ENV_PATH": "${env.IDF_TOOLS_PATH}\\python_env\\idf4.4_py3.8_env",
          "OPENOCD_SCRIPTS": "${env.IDF_TOOLS_PATH}\\tools\\openocd-esp32\\v0.10.0-esp32-20191114\\openocd-esp32\\share\\openocd\\scripts",
          "PATH": "${env.IDF_TOOLS_PATH}\\tools\\xtensa-esp32-elf\\esp-2021r2-patch3-8.4.0\\xtensa-esp32-elf\\bin;${env.IDF_TOOLS_PATH}\\tools\\xtensa-esp32s2-elf\\esp-2021r2-patch3-8.4.0\\xtensa-esp32s2-elf\\bin;${env.IDF_TOOLS_PATH}\\tools\\esp32ulp-elf\\2.28.51-esp-20191205\\esp32ulp-elf-binutils\\bin;${env.IDF_TOOLS_PATH}\\tools\\esp32s2ulp-elf\\2.28.51-esp-20191205\\esp32s2ulp-elf-binutils\\bin;${env.IDF_TOOLS_PATH}\\tools\\ninja\\1.10.2\\;${env.IDF_TOOLS_PATH}\\tools\\idf-exe\\1.0.3\\;${env.IDF_TOOLS_PATH}\\tools\\ccache\\4.3\\;${env.IDF_TOOLS_PATH}\\python_env\\idf4.4_py3.8_env\\Scripts;${env.IDF_PATH}\\tools;${env.IDF_PATH};${env.PATH};",
          "INCLUDE": "${env.IDF_TOOLS_PATH}\\tools\\xtensa-esp32-elf\\esp-2021r2-patch3-8.4.0\\xtensa-esp32-elf\\xtensa-esp32-elf\\include;${env.IDF_TOOLS_PATH}\\tools\\xtensa-esp32s2-elf\\esp-2021r2-patch3-8.4.0\\xtensa-esp32s2-elf\\xtensa-esp32s2-elf\\include;${env.IDF_PATH}\\components;${env.INCLUDE};E:\\easy_cpp\\esp32",
          "FLASH_COM_PORT": "COM5",
          "FLASH_BAUD": "921600",
          "environment": "linux_x64"
        }
      ],
      "intelliSenseMode": "windows-clang-x64",
      "variables": [
        {
          "name": "IDF_TARGET",
          "value": "esp32",
          "type": "STRING"
        },
        {
          "name": "CMAKE_MAKE_PROGRAM",
          "value": "${env.IDF_TOOLS_PATH}\\tools\\ninja\\1.10.2\\ninja.exe",
          "type": "FILEPATH"
        },
        {
          "name": "CCACHE_ENABLE",
          "value": "1",
          "type": "STRING"
        },
        {
          "name": "ESP_PLATFORM",
          "value": "1",
          "type": "STRING"
        }
      ]
    }
  ]
}
				
			

tasks.vs.json - (项目根目录)vs中文件列表右键菜单

				
					{
  "version": "0.2.1",
  "tasks": [
    {
      "taskLabel": "[ESP32 SDK Config]",
      "appliesTo": "*",
      "type": "launch",
      "inheritEnvironments": [
        "linux_x64"
      ],
      "command": "cmd",
      "args": [
        "/Q /K start idf.py menuconfig"
      ]
    },
    {
      "taskLabel": "[写入芯片]",
      "appliesTo": "*",
      "type": "launch",
      "inheritEnvironments": [
        "linux_x64"
      ],
      "command": "idf.py",
      "args": [
        "-p ${env.FLASH_COM_PORT} -b 921600 flash"
      ]
    },
    {
      "taskLabel": "[写入芯片后显示监控]",
      "appliesTo": "*",
      "type": "launch",
      "inheritEnvironments": [
        "linux_x64"
      ],
      "command": "cmd",
      "args": [
        "/Q /K idf.py -p ${env.FLASH_COM_PORT} -b 921600 flash & start idf.py monitor"
      ]
    },
    {
      "taskLabel": "[监控串口窗口]",
      "appliesTo": "*",
      "type": "launch",
      "inheritEnvironments": [
        "linux_x64"
      ],
      "command": "cmd",
      "args": [
        "/Q /K start idf.py monitor"
      ]
    },
    {
      "taskLabel": "[编译]",
      "contextType":"custom",
      "appliesTo": "*",
      "type": "launch",
      "inheritEnvironments": [
        "linux_x64"
      ],
      "command": "idf.py",
      "args": [
        "build"
      ]
    }
  ]
}
				
			

发表评论

您的电子邮箱地址不会被公开。