#author("2022-06-07T13:35:16+08:00","default:Admin","Admin")
#author("2022-10-14T10:57:36+08:00","default:Admin","Admin")
[[ESP32]]

&color(red){※This article is based on esp-idf 4.0};
#contents

* 开发文档 [#qdece1a4]

 https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/index.html

* 编译环境的下载 [#qbaac25b]

** ESP-IDF 5.0之前 [#tf825eb8]

 https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/get-started/windows-setup.html

也可以使用ESP8266的[[+ESP8266+开发环境]]

** ESP-IDF 5.0以后 [#lcc6cb6e]

 https://github.com/espressif/idf-installer

从上面的网址下载在线/离线安装包,Eclipse的开发环境


** Matter [#t99e3ce9]

 git clone --recursive https://github.com/espressif/esp-matter.git

ESP32、ESP32-S系列、ESP32-C系列、ESP32-H系列均支持Matter协议
* 配置编译环境 [#oa1c1aa4]

** MingW32 [#j4539659]

#codeprettify{{
export PATH="$PATH:/opt/xtensa-esp32-elf/bin"
export IDF_PATH="D:/Tools/msys32/home/Administrator/esp/esp-idf"
}}

** Windows [#t0e2d900]

*** Install [#g1cabc4c]

运行 install.bat batch文件

或者

 python -m pip install --user -r $IDF_PATH/requirements.core.txt

需要注意看 requirements.core.txt是否在 IDF_PATH 当中

使用bat安装后的环境也可以使用powershell来编译,运行之前,需要执行 expoer.ps1
*** 设置环境变量 [#y0c1e288]

运行 export.bat batch文件

&color(red){※注意};

如果修改了 IDF_TOOLS_PATH 变量,请确保该变量在每次执行安装脚本 (install.bat、install.ps1 或 install.sh) 和导出脚本 (export.bat、export.ps1 或 export.sh) 均保持一致。
***编译 [#de4ea2c8]

每次启动命令行后执行一下 export.bat batch文件


去example 文件夹里面,运行下面的命令

 ..\..\..\tools\idf.py set-target esp32s2 
 ..\..\..\tools\idf.py menuconfig
 ..\..\..\tools\idf.py build

命令执行后,会自动下载安装确实的依赖包

&ref(esp-idf_cmdbuild2.png);

#codeprettify{{
Project build complete. To flash, run this command:
C:\Users\Administrator\.espressif\python_env\idf5.0_py3.7_env\Scripts\python.exe ..\..\..\components\esptool_py\esptool\esptool.py
 -p (PORT) -b 460800 --before default_reset --after hard_reset --chip esp32  write_flash --flash_mode dio --flash_size detect --flash_freq 40m
 0x1000 build\bootloader\bootloader.bin 0x8000 build\partition_table\partition-table.bin
 0x10000 build\hello_world.bin
or run 'idf.py -p (PORT) flash'
}}
** VS Code [#g8ab3004]

&color(red){ESP-IDF 5.0 版本以后的编译,暂时无法使用MingW32来做,};官方推荐VSCode或者Eclipse,或者使用上面的cmd或者powershell

VSCode 插件仓库搜索“ESP-IDF” Espressif IDF 现在最新版本是 v1.3.0

正常输入命令 ESP-IDF: Configure ESP-IDF extension 后会出现下面的配置画面

&ref(esp-idf_configure.png);


***安装问题 [#t2b0c392]

在配置ESP_IDF时 v1.3.0版本有下面的bug,请安装低版本的1.2

 restart Visual Studio Code and run this wizard again. 

网上有个解决的办法是下载下面的 vsix 插件,使用这个安装,有人说好用,但是本人测试没有效果

 https://nightly.link/espressif/vscode-esp-idf-extension/actions/artifacts/137655771.zip

&ref(esp-idf_vsixinstall.png);
* 烧录 [#z7055eaa]
||模式|GPIO0|
|UART|下载模式|低|
|Flash|运行模式|高|

* monitor [#m9803cf8]

串口监视命令

使用第二个串口)
#codeprettify{{
//Linux
make monitor ESPPORT=/dev/cu.wchusbserial14140

//Windows
make monitor ESPPORT=ESPPORT=COMx
}}

* 查看错误信息 [#y69220a0]

#codeprettify{{
//dump文件
xtensa-lx106-elf-objdump -S build/GW32.elf > a.S

//查看错误所在
xtensa-esp32-elf-addr2line -pfiaC -e build/GW32.elf 0x40087d83:0x3ffb9cd0 
}}

&ref(ZigBee_体系结构.png);

#hr();
コメント:
#comment_kcaptcha

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS