小智AI烧录/ESP32切换目标板报错的处理 Failed to set target esp32s3:non zero exit code 2
小智AI烧录/ESP32切换目标板报错的处理 Failed to set target esp32s3:non zero exit code 2

这一篇解决这个报错,这是在烧录esp32s3等系列芯片常发生的问题,具体表现是报以上的错,或者删除build后成功切换到esp32s3了,但是此时又打不开齿轮的config界面了。
配置

原码版本是1.8.3,不建议用最新的原码,然后ESP-IDF的版本是5.5.1,串口选UART,自行选择端口COMX,初始时目标板是型号是esp32,上图是解决后的截图。
下载ESP-IDF5.5.1(完成可跳过)
先打开ESP-IDF,如果在左侧栏没找到就点击三个点。

然后点开“Advanced”,点击配置扩展

等待一会,出现这个页面选择ADVANCED

在version项选择5.5.1

然后选择安装路径(大约1.8G),点击configureTools即可,要等待很久,然后会有一个下载tools的界面,正常下载即可。
注意,在下载期间不要切换网络,断了就白下了,需要删除文件夹重新下。
解决
# 1. 打开 ESP-IDF PowerShell(不是普通PowerShell!)
ctrl+shift+P,输入ESP-IDF:Open ESP-IDF Terminal打开终端

conda deactivate 直到完全退出虚拟环境(PS前面不带括号为止,每个人的初始配置可能不一样)
(mindspore_env) PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> conda deactivate
(base) PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> conda deactivate
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3>
echo $env:IDF_TARGET 会输出esp32,此时不是s3
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> echo $env:IDF_TARGET
esp32
$env:IDF_TARGET = "esp32s3" 切换为s3
echo $env:IDF_TARGET 检查环境变量是否切换成功
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> $env:IDF_TARGET = "esp32s3"
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> echo $env:IDF_TARGET
esp32s3
'c:\Users\HP\.vscode\extensions\espressif.esp-idf-extension-1.10.2\export.ps1'
(在下一步前一定要删除 build sdkconfig sdkconfig.old components/ 文件)
idf.py fullclean
这是没删除时的报错:
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> idf.py fullclean
Executing action: fullclean
Directory 'E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3\build' doesn't seem to be a CMake build directory. Refusing to automatically delete files in this directory. Delete the directory manually to 'clean' it.
删除后输出如下:
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> idf.py fullclean
Executing action: fullclean
Build directory 'E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3\build' not found. Nothing to clean.
Executing action: remove_managed_components
Done
idf.py set-target esp32s3
等待执行完毕即可,此时切换到配置页面也正常了
结束。
后续操作
后续就可以更改配置文件,选择flash、psram等配置,然后点击扳手或小火苗进行编译和构建和监视了。
如图成功。

临时记录(不用看了)
(mindspore_env) PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> conda deactivate
(base) PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> conda deactivate
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> echo $env:IDF_TARGET
esp32
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> $env:IDF_TARGET = "esp32s3"
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> echo $env:IDF_TARGET
esp32s3
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> 'c:\Users\HP\.vscode\extensions\espressif.esp-idf-extension-1.10.2\export.ps1'
c:\Users\HP\.vscode\extensions\espressif.esp-idf-extension-1.10.2\export.ps1
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> idf.py fullclean
Executing action: fullclean
Directory 'E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3\build' doesn't seem to be a CMake build directory. Refusing to automatically delete files in this directory. Delete the directory manually to 'clean' it.
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> idf.py fullclean
Executing action: fullclean
Build directory 'E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3\build' not found. Nothing to clean.
Executing action: remove_managed_components
Done
PS E:\Passport\xiaozhi-esp32-1.8.3\xiaozhi-esp32-1.8.3> idf.py set-target esp32s3
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
加载个人及系统配置文件用了 5244 毫秒。
(base) PS E:\xiaozhi-esp32> & 'c:\Users\HP\.vscode\extensions\espressif.esp-idf-extension-1.10.2\export.ps1'
(base) PS E:\xiaozhi-esp32> C:/Users/HP/miniconda3/Scripts/activate
(base) PS E:\xiaozhi-esp32> conda activate mindspore_env
(mindspore_env) PS E:\xiaozhi-esp32> idf.py fullclean
No module named 'esp_idf_monitor'
This usually means that "idf.py" was not spawned within an ESP-IDF shell environment or the python virtual environment used by "idf.py" is corrupted.
Please use idf.py only in an ESP-IDF shell environment. If problem persists, please try to install ESP-IDF tools again as described in the Get Started guide.
(mindspore_env) PS E:\xiaozhi-esp32> conda deactivate
(base) PS E:\xiaozhi-esp32> conda deactivate
PS E:\xiaozhi-esp32> & 'c:\Users\HP\.vscode\extensions\espressif.esp-idf-extension-1.10.2\export.ps1'
PS E:\xiaozhi-esp32> idf.py fullclean
Executing action: fullclean
Build directory 'E:\xiaozhi-esp32\build' not found. Nothing to clean.
Executing action: remove_managed_components
Aborted!
PS E:\xiaozhi-esp32> idf.py set-target esp32s3
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Build directory 'E:\xiaozhi-esp32\build' not found. Nothing to clean.
Executing action: set-target
Set Target to: esp32s3, new sdkconfig will be created.
Target 'esp32s3' specified on command line is not consistent with target 'esp32' in the environment.
PS E:\xiaozhi-esp32> idf.py set-target esp32s3
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Build directory 'E:\xiaozhi-esp32\build' not found. Nothing to clean.
Executing action: set-target
Set Target to: esp32s3, new sdkconfig will be created.
Target 'esp32s3' specified on command line is not consistent with target 'esp32' in the environment.
PS E:\xiaozhi-esp32> echo $env:IDF_TARGET
esp32
PS E:\xiaozhi-esp32> $env:IDF_TARGET = "esp32s3"
PS E:\xiaozhi-esp32> echo $env:IDF_TARGET
esp32s3
PS E:\xiaozhi-esp32> idf.py set-target esp32s3
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Build directory 'E:\xiaozhi-esp32\build' is empty. Nothing to clean.
Executing action: set-target
Set Target to: esp32s3, new sdkconfig will be created.
Running cmake in directory E:\xiaozhi-esp32\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DPYTHON=E:\Passport\esp32\.espressif\python_env\idf5.4_py3.11_env\Scripts\python.exe -DESP_PLATFORM=1 -DIDF_TARGET=esp32s3 -DCCACHE_ENABLE=1 E:\xiaozhi-esp32"...
更多推荐



所有评论(0)