dmzdmz666666 发表于 2021-6-30 12:17

【ESP32-C3-DevKitM-1】+ESP32系列通用Windows环境搭建

本帖最后由 dmzdmz666666 于 2021-7-1 10:08 编辑

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">开发一款芯片</font>,<font face="宋体">需要搭建一个开发环境</font><font face="Calibri">,</font><font face="宋体">像开发</font><font face="Calibri">STM32</font><font face="宋体">或者</font><font face="Calibri">51</font><font face="宋体">单片机需要用到</font><font face="Calibri">KEIL</font><font face="宋体">或者</font><font face="Calibri">IAR</font><font face="宋体">这类的</font><font face="Calibri">IDE,</font><font face="宋体">极大的方便开发者开发。</font></span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">众所周知</font>,<font face="宋体">乐鑫的一个比较大的问题就是没有专门的开发环境</font><font face="Calibri">,</font><font face="宋体">都是散装的组件进行拼接,对一部分的开发者来说,搭建环境直接从入门到放弃。</font></span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">经过不断尝试,终于勉勉强强搭建好了环境,我用的是</font>Eclipse IDE<font face="宋体">,官方有提供</font><font face="Calibri">VS code</font><font face="宋体">和</font><font face="Calibri">Eclipse</font><font face="宋体">这两款</font><font face="Calibri">IDE</font><font face="宋体">的安装方法,大家选其一就行了。</font></span></span></span></span></p>

<p><span style="font-size:14pt"><span style="125%"><span style="font-family:Arial"><span style="font-size:14.0000pt"><span style="font-family:黑体"><font face="黑体">1、安装</font>ESP-IDF<font face="黑体">及对应组件</font></span></span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">首先是要下载</font>ESP-IDF,<font face="宋体">这个我就不用多说了</font><font face="Calibri">,</font><font face="宋体">上</font><font face="Calibri">github</font><font face="宋体">下载,下载好以后,记得</font></span></span><i><span style="font-size:10.5000pt"><span style="font-family:宋体"><span style="font-style:italic">git submodule update --init -f --recursive</span></span></span></i><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">一下,这样可以将相关的子组件全部下载好,免得编译报错。</font></span></span></span></span><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">然后在下面这个链接中下载</font>ESP-IDF <font face="宋体">工具安装器,这个安装器会安装</font><font face="Calibri">Python</font><font face="宋体">、</font><font face="Calibri">Git</font><font face="宋体">、交叉编译器、</font><font face="Calibri">CMake </font><font face="宋体">和 </font><font face="Calibri">Ninja </font><font face="宋体">等工具,我建议是下载在线安装版。</font></span></span></span></span><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">在下载前最好检查一下,如下图</font></span></span></span></span></p>

<p style="text-align:left"></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">如果你下载好</font>ESP-IDF<font face="宋体">(我建议提前下载好,不然用这个</font><font face="Calibri">ESP-IDF </font><font face="宋体">工具安装器下载很慢),直接选择下载好的路径,如下图</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">然后选择组件存放的文件夹,最后选择要安装的组件,可以选择自定义,不勾选</font>Eclipse<font face="宋体">,驱动可以全部勾选,或者选择第三项,因为</font><font face="Calibri">ESP32-C3-DevKitM-1</font><font face="宋体">上有</font><font face="Calibri">CP210X</font><font face="宋体">,如下图,不知为什么最后一项不从</font><font face="Calibri">github</font><font face="宋体">下载无法勾选,很奇怪</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">接下来按提示安装,之后运行</font></span></span><i>&nbsp;</i><i><span style="font-size:9.5000pt"><span style="background:#fcfcfc"><span style="font-family:Arial"><span style="color:#404040"><span style="letter-spacing:0.0000pt"><span style="font-style:italic">ESP-IDF Command Prompt</span></span></span></span></span></span></i><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">或者</font></span></span><i><span style="font-size:9.5000pt"><span style="background:#fcfcfc"><span style="font-family:Arial"><span style="color:#404040"><span style="letter-spacing:0.0000pt"><span style="font-style:italic">ESP-IDF PowerShell Environment</span></span></span></span></span></span></i><i><span style="font-size:9.5000pt"><span style="background:#fcfcfc"><span style="font-family:宋体"><span style="color:#404040"><span style="letter-spacing:0.0000pt"><span style="font-style:italic"><font face="宋体">,</font></span></span></span></span></span></span></i><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">这里我选择</font></span></span><i><span style="font-size:9.5000pt"><span style="background:#fcfcfc"><span style="font-family:Arial"><span style="color:#404040"><span style="letter-spacing:0.0000pt"><span style="font-style:italic">ESP-IDF Command Prompt</span></span></span></span></span></span></i><i><span style="font-size:9.5000pt"><span style="background:#fcfcfc"><span style="font-family:宋体"><span style="color:#404040"><span style="letter-spacing:0.0000pt"><span style="font-style:italic">,</span></span></span></span></span></span></i><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">点击</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">这个提示是将下载好的工具的路径添加到环境变量中</font>,<font face="宋体">如下图</font><font face="Calibri">,IDF_PATH</font><font face="宋体">似乎要手动添加</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">然后先输入</font>cd examples\get-started\hello_world,<font face="宋体">这是你想运行的程序的路径</font><font face="Calibri">,</font><font face="宋体">我这里选择</font><font face="Calibri">hello_world,</font><font face="宋体">然后回车</font><font face="Calibri">,</font><font face="宋体">再输入</font><font face="Calibri">idf.py set-target esp32-c3,</font><font face="宋体">回车</font><font face="Calibri">,</font><font face="宋体">正常情况下</font><font face="Calibri">,</font><font face="宋体">会出现以下图片</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">出现</font></span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体">-- Configuring done</span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体">-- Generating done</span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体">-- Build files have been written to: E:/Desktop/ESP_IDF_V4.2.2/examples/get-started/hello_world/build</span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">就已经设置好编译目标了</font>,<font face="宋体">再输入</font><font face="Calibri">idf.py build,</font><font face="宋体">开始编译</font><font face="Calibri">,</font><font face="宋体">如下图</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">编译好以后输出</font>idf.py -p COM9 flash<font face="宋体">将固件通过</font><font face="Calibri">COM9</font><font face="宋体">烧录到</font><font face="Calibri">ESP32-C3,</font><font face="宋体">串口号根据自身来修改</font><font face="Calibri">,</font><font face="宋体">如下图</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">下载好以后</font>,<font face="宋体">我们输入 </font><font face="Calibri">idf.py -p COM9 monitor</font><font face="宋体">打开监控器来观察串口打印的数据</font><font face="Calibri">,</font><font face="宋体">当然也可以用串口助手来看</font><font face="Calibri">,</font><font face="宋体">如下图</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">一切正常的话会出现下图所示内容</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">至此</font>,<font face="宋体">到这步都一切正常的话说明电脑已经安装好了开发</font><font face="Calibri">ESP-IDF</font><font face="宋体">必须的组件和程序了。</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"><span style="font-size:14pt"><span style="125%"><span style="font-family:Arial"><span style="font-size:14.0000pt"><span style="font-family:黑体"><font face="黑体">2、安装</font>Eclipse<font face="黑体">及对应</font><font face="Arial">IDF</font><font face="黑体">插件</font></span></span></span></span></span></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">平时用</font>IDE<font face="宋体">习惯了,不太习惯用命令行来开发,不太方便美观,所以选择</font><font face="Calibri">Eclipse</font><font face="宋体">来开发,正好官方也提供了对应的插件</font></span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">具体的步骤我是参考以下文章,第一篇很详细,当时没有图文,第二篇有图文,大家可以综合看来搭建,很详细,我就不再讲一次了。这里感谢</font>CSDN<font face="宋体">作者 </font></span></span><a href="https://blog.csdn.net/qq_20515461"><span style="font-size:10.5000pt"><span style="font-family:Calibri"><font face="宋体">清凉简装</font></span></span></a></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><a href="https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md"><u><span class="15" style="font-family:宋体"><span style="color:#0000ff"><span style="text-decoration:underline"><span style="text-underline:single">https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md</span></span></span></span></u></a></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><a href="https://blog.csdn.net/qq_20515461/article/details/108638928"><u><span class="15" style="font-family:'Times New Roman'"><span style="color:#0000ff"><span style="text-decoration:underline"><span style="text-underline:single">https://blog.csdn.net/qq_20515461/article/details/108638928</span></span></span></span></u></a></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">这里我讲一下注意事项吧</font></span></span></span></span></p>

<p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体">1、Eclipse<font face="宋体">需要</font><font face="Calibri">Java</font><font face="宋体">环境,所以要提前下载安装好</font></span></span></span></span>&nbsp; &nbsp; &nbsp;</p>

<p style="text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">2、安装好插件好,要选择安装工具,这里的</font>git<font face="宋体">和</font><font face="Calibri">python</font><font face="宋体">可以选择</font><font face="Calibri">ESP-IDF </font><font face="宋体">工具安装器下载好的路径,见下图</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;3、<span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">要确保</font>Eclipse<font face="宋体">的</font><font face="Calibri">PATH</font><font face="宋体">中包含所有组件,</font><font face="Calibri">Window -&gt; Preferences -&gt; C/C++-&gt; Build -&gt; ENvironment,</font><font face="宋体">如下图</font></span></span></span></span></p>

<ol start="3"><br />
        &nbsp;
</ol>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">把</font>PATH<font face="宋体">展开就是下图所示</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">最后</font>,<font face="宋体">按下图所示参看安装工具情况</font></span></span></span></span></p>

<p>&nbsp;</p>

<p style="text-align:left"></p>

<p style="text-align:left"></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">出现上图所示说明安装好了。</font></span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">其他注意事项上面参考的两篇文章已经提到了,本人就不赘述了。搭建好环境,就可以根据自身任务需求来修改程序。</font></span></span></span></span></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:14.0000pt"><span style="font-family:黑体"><font face="黑体">总结</font></span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">乐鑫的开发环境被不少人吐槽过,官方推荐使用</font>Linux<font face="宋体">来编译,不仅简单而且效率高,奈何很多开发者已经习惯了</font><font face="Calibri">Windows</font><font face="宋体">的开发环境和使用逻辑,虽然官方也编写了在</font><font face="Calibri">Windows</font><font face="宋体">下的开发环境搭建,但对没有一定开发经验的小白不是很友好,好在随着用乐鑫的人越来越多,相关更通俗易懂的教程也越来越多,但在这里我还是希望乐鑫官方推出可以同时支持</font><font face="Calibri">ESP8266</font><font face="宋体">和</font><font face="Calibri">ESP32</font><font face="宋体">所有系列的一站式</font><font face="Calibri">IDE</font><font face="宋体">,这样大大方便开发者。</font></span></span></span></span></p>

<p>&nbsp;</p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:14.0000pt"><span style="font-family:黑体"><font face="黑体">参考资料</font></span></span></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><a href="https://www.bilibili.com/video/BV1rf4y1p75s"><u><span class="15" style="font-family:'Times New Roman'"><span style="color:#0000ff"><span style="text-decoration:underline"><span style="text-underline:single">https://www.bilibili.com/video/BV1rf4y1p75s</span></span></span></span></u></a></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><a href="https://www.bilibili.com/read/cv7780033?spm_id_from=333.788.b_636f6d6d656e74.33"><u><span class="15" style="font-family:'Times New Roman'"><span style="color:#0000ff"><span style="text-decoration:underline"><span style="text-underline:single">https://www.bilibili.com/read/cv7780033?spm_id_from=333.788.b_636f6d6d656e74.33</span></span></span></span></u></a></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><a href="https://www.bilibili.com/video/av796774491"><u><span class="15" style="font-family:'Times New Roman'"><span style="color:#0000ff"><span style="text-decoration:underline"><span style="text-underline:single">https://www.bilibili.com/video/av796774491</span></span></span></span></u></a></span></span></p>

<p><span style="font-size:10.5pt"><span style="font-family:Calibri"><a href="https://docs.espressif.com/projects/esp-idf/zh_CN/v4.3/esp32c3/get-started/index.html"><u><span class="15" style="font-family:'Times New Roman'"><span style="color:#0000ff"><span style="text-decoration:underline"><span style="text-underline:single">https://docs.espressif.com/projects/esp-idf/zh_CN/v4.3/esp32c3/get-started/index.html</span></span></span></span></u></a></span></span></p>

<p>&nbsp;</p>

<p>&nbsp;</p>

dmzdmz666666 发表于 2021-6-30 12:19

<p>大家有什么问题可以互相交流,本人也是勉勉强强搭建好环境,有些情况暂时还没遇到,遇到了也不一定能解决,因为对有些步骤的原理也不是很懂。</p>

minihang 发表于 2021-6-30 15:07

<p>前排支持 观摩学习</p>

Jacktang 发表于 2021-6-30 21:37

<p>ESP32的开发环境搭建本来就很麻烦的</p>

soso 发表于 2021-7-1 09:28

dmzdmz666666 发表于 2021-6-30 12:19
大家有什么问题可以互相交流,本人也是勉勉强强搭建好环境,有些情况暂时还没遇到,遇到了也不一定能解决, ...

<p>开始摸索第一步,赞一个。我们也会将楼主建议反馈。</p>

dmzdmz666666 发表于 2021-7-1 09:52

Jacktang 发表于 2021-6-30 21:37
ESP32的开发环境搭建本来就很麻烦的

<p>确实 希望以后能直接集成吧</p>

damiaa 发表于 2021-8-16 10:49

<p>esp-idf-tools-setup-offline-2.10 好像直接安装完成了。就可以编译了。</p>
页: [1]
查看完整版本: 【ESP32-C3-DevKitM-1】+ESP32系列通用Windows环境搭建