用Trae的sole模式来模拟文心快码comate的Spec Mode模式来做一个esp32操作系统的项目

solo已经很好用了,Comate竟然又出来Spec Mode模式,导致Trae的solo都不香了。不过我们可以让solo模式来模拟Spec模式

先创建任务

第一步prompt

基于rtems内核,辅助以busybox,尝试为esp32c3 等硬件平台实现类似freeBSD系统那样的效果。

基本思路就是实现esp32硬件平台的自控制:可以远程登录到esp32,可以通过网络下载源码或已编译好的二进制代码,而不需要使用烧录设备来装应用软件。

请先写好项目需求文档,再梳理实现任务。

这个任务的特点

告诉AI写文档,实现任务,而不是直接下任务。

需求文档结果

AI 进行了技术策略调整 :

  • 用FreeRTOS替代RTEMS(技术风险更低,ESP32生态支持更好)

  • 基于ESP-IDF驱动进行适配

  • 分阶段实施,确保项目可控

RTEMS+BusyBox的组合在嵌入式实时场景下可模拟FreeBSD的部分功能(如命令行环境、基础网络、文件系统),但受限于内核架构、资源约束和生态差异,无法完全替代FreeBSD的完整特性。若需在ESP32 RISC-V上实现类FreeBSD体验,建议优先评估实时性需求、资源预算及功能优先级,必要时可探索RTEMS与FreeBSD的混合架构(如RTEMS内核+FreeBSD用户空间),或采用裁剪版FreeBSD(如NetBSD/RTEMS的嵌入式分支)以平衡功能与性能。

第二步prompt

使用推荐的FreeRTOS方案快速实现,根据需求文档和任务清单,一步步来

因为网络的原因,esp-idf没有下载成,是事后自己手工下载的。

手工安装开发环境

先设置加速镜像

windows下使用set

复制代码
set IDF_GITHUB_ASSETS=dl.espressif.com/github_assets

然后进行安装:

复制代码
G:\traework\RtemeBSD\tools\esp-idf>install.bat

安装完成:

复制代码
All done! You can now run:
   export.bat

执行export.bat

复制代码
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

  idf.py build

这时候就可以到项目的目录,进行build了。

第三步prompt编译烧录和功能测试

编译和烧录 :

  • 打开ESP-IDF命令提示符

  • 导航到项目目录

  • 使用 idf.py build 编译项目

  • 使用 idf.py flash 烧录固件到ESP32C3开发板

  • 使用 idf.py monitor 查看串口输出

功能测试 :

  • 测试LED闪烁功能

  • 测试串口通信

  • 测试WiFi连接

  • 测试网络功能

等等,AI说它把活干完了?

AI说把活干完了

现在我将总结我们完成的工作,并说明如何使用ESP-IDF命令来编译和烧录项目。已成功将ESP32C3基于FreeRTOS的类FreeBSD系统项目转换为ESP-IDF兼容格式,具体包括:

  1. 项目结构转换 :
  • 创建了ESP-IDF兼容的目录结构,包括main目录和components目录

  • 将驱动代码移动到components/drivers目录

  • 将网络代码移动到components/network目录

  • 将主应用程序移动到main目录

  1. 构建系统配置 :
  • 修改了CMakeLists.txt,使用ESP-IDF的构建系统

  • 为每个组件创建了CMakeLists.txt文件

  1. 配置文件创建 :
  • 创建了sdkconfig.defaults配置文件,设置了FreeRTOS、WiFi、网络、UART和Flash等默认配置

  • 创建了partitions.csv分区表文件,定义了Flash分区结构

编译和烧录步骤 :

  1. 打开ESP-IDF命令提示符 :
  • 从开始菜单找到"ESP-IDF Command Prompt"并打开

  • 或者使用VS Code的ESP-IDF扩展

  1. 导航到项目目录 :

```

cd g:\traework\RtemeBSD

```

  1. 配置项目 :

```

idf.py menuconfig

```

  • 可以根据需要调整配置,如WiFi设置、串口配置等
  1. 编译项目 :

```

idf.py build

```

  • 编译成功后,会生成固件文件build/esp32c3-freertos.bin
  1. 烧录固件 :

```

idf.py flash

```

  • 确保ESP32C3开发板已连接到电脑

  • 系统会自动检测串口并烧录固件

  1. 查看串口输出 :

```

idf.py monitor

```

  • 可以查看系统启动信息和调试输出

  • 按Ctrl+]退出监控

功能测试 :

  1. LED闪烁测试 :观察ESP32C3开发板上的LED是否按1秒间隔闪烁

  2. 串口通信测试 :通过串口监视器查看系统输出

  3. WiFi连接测试 :检查系统是否能连接到指定的WiFi AP

  4. 网络功能测试 :验证TCP/IP协议栈是否正常工作

该项目已经转换为ESP-IDF兼容格式,可以使用ESP-IDF的标准命令进行编译和烧录,便于后续开发和测试。

第四步prompt 这步略

  • 实现文件系统

  • 集成Busybox

  • 开发远程管理功能

  • 实现网络启动和代码分发

第五步prompt:给我创建一个riscv5 esp32c3的虚拟机环境,以便测试验证项目

搞定

测试环境使用说明 :

  1. 安装RISC-V交叉编译工具链和QEMU

  2. 进入tools/riscv_test目录

  3. 运行make编译测试程序

  4. 运行make run在QEMU中运行测试程序

该测试环境可以用于测试ESP32C3项目的核心功能,包括FreeRTOS内核、驱动和网络栈等组件。

后续步骤 :

  1. 按照README.md中的说明安装RISC-V交叉编译工具链和QEMU

  2. 编译和运行测试程序,验证测试环境是否正常工作

  3. 修改测试程序,添加FreeRTOS和其他组件的测试代码

  4. 测试ESP32C3项目的核心功能

  5. 根据测试结果优化和完善项目代码

但是现在还是没有qemu环境。

make之后有报错,AI解决说:

此测试环境演示了ESP32C3项目所需的核心功能,包括FreeRTOS任务管理、GPIO控制和串行通信。您可以轻松地扩展它来测试WiFi、网络功能和闪存等其他组件。

该项目使用ESP-IDF构建系统,这是ESP32C3的官方开发框架,确保了兼容性和易用性。这种方法避免了对RISC-V交叉编译器和QEMU等额外工具的需要,使开始测试项目变得更加简单。

手工安装qemu环境

参考这个页面:https://skywalk.blog.csdn.net/article/details/144499393

在idf根目录,直接运行

复制代码
python tools\idf_tools.py install qemu-xtensa qemu-riscv32

完成:

复制代码
Destination: G:\Espressif\dist\qemu-riscv32-softmmu-esp_develop_9.0.0_20240606-x86_64-w64-mingw32.tar.xz.tmp
Done
Extracting G:\Espressif\dist\qemu-riscv32-softmmu-esp_develop_9.0.0_20240606-x86_64-w64-mingw32.tar.xz to G:\Espressif\tools\qemu-riscv32\esp_develop_9.0.0_20240606

如果要使用qemu执行

复制代码
idf.py qemu monitor

手工编译

复制代码
PS G:\traework\RtemeBSD\tools> cd .\esp32c3_test\
PS G:\traework\RtemeBSD\tools\esp32c3_test> idf.py build

编译成的文件在这里

复制代码
Generated G:/traework/RtemeBSD/tools/esp32c3_test/build/bootloader/bootloader.bin
[110/110] C:\Windows\system32\cmd.exe /C "cd /D G:\traewor...emeBSD/tools/esp32c3_test/build/bootloader/bootloader.bin"
Bootloader binary size 0x5210 bytes. 0x2df0 bytes (36%) free.
[988/989] Generating binary image from built executable
esptool.py v4.10.0
Creating esp32c3 image...
Merged 1 ELF section
Successfully created esp32c3 image.
Generated G:/traework/RtemeBSD/tools/esp32c3_test/build/esp32c3-test.bin
[989/989] C:\Windows\system32\cmd.exe /C "cd /D G:\traewor...aework/RtemeBSD/tools/esp32c3_test/build/esp32c3-test.bin"
esp32c3-test.bin binary size 0x2ced0 bytes. Smallest app partition is 0x100000 bytes. 0xd3130 bytes (82%) free.

也就是在这里:

build/esp32c3-test.bin

让qemu调用这个bin文件

复制代码
idf.py qemu --flash-filebuild/esp32c3-test.bin monitor

但是这里报错了....有点糊涂了...

让人烧脑筋的时刻,下一步该怎么办

现在用这条命令,可以monitor成功

复制代码
idf.py qemu --graphics monitor

也就是在一个项目下执行

复制代码
# 编译
idf.py build
# 用monitor启动
idf.py qemu --graphics monitor

先不用qemu,先解决build的问题。

第六步 让AI可以调试代码

因为idf-需要进入环境,所以所有的cmd都需要先执行

复制代码
C:\Windows\system32\cmd.exe /k ""G:\Espressif\idf_cmd_init.bat" esp-idf-10fae2432b9d28444f9976c887386775"  

将这件事告诉AI,让它每次启动cmd都先执行这句。

然后让AI尝试调试根目录的build报错

用idf menuconfig 设置了4M

运行的时候看到提示:-- IDF_TARGET is not set, guessed 'esp32' from sdkconfig 'G:/traework/RtemeBSD/sdkconfig'

看来target没有设置好啊,怪不得会有报错说2M的事。明白了,是这句话闹的。

编译完成

烧录一下

复制代码
esptool.py --chip esp32c3 --port com3 --baud 460800 write_flash -z 0x0  build/esp32c3-freertos.bin

# 另一个
esptool.py --chip esp32c3 --port com3 --baud 460800 write_flash -z 0x0  tools\esp32c3_test\build\esp32c3-test.bin

最简单的烧录方法是

复制代码
idf.py flash

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (149 compressed) at 0x00008000 in 0.0 seconds (effective 740.6 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 31...
Writing at 0x00310000... (100 %)
Wrote 8192 bytes (31 compressed) at 0x00310000 in 0.0 seconds (effective 1367.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Done

这样就自动烧录上去了。我也不知道它怎么知道是com3口的,也许是上次烧录它记住了?还是只有这么一个com口?

烧录完连接

复制代码
idf.py monitor

经过大约4-5轮的solo调试,Trae写的代码终于跑起来了:

复制代码
G:\traework\RtemeBSD>idf.py monitor
Executing action: monitor
Serial port COM3
Connecting....
Detecting chip type... ESP32-C3
Running idf_monitor in directory G:\traework\RtemeBSD
Executing "G:\Espressif\python_env\idf5.5_py3.11_env\Scripts\python.exe 
G:\Espressif\frameworks\esp-idf-v5.5.1\tools/idf_monitor.py -p COM3 -b 115200 --toolchain-prefix riscv32-esp-elf- --target esp32c3 --revision 3 
--decode-panic backtrace G:\traework\RtemeBSD\build\esp32c3-freertos.elf G:\traework\RtemeBSD\build\bootloader\bootloader.elf --force-color -m 'G:\Espressif\python_env\idf5.5_py3.11_env\Scripts\python.exe' 'G:\Espressif\frameworks\esp-idf-v5.5.1\tools\idf.py'"...
--- Warning: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM3 instead...
--- esp-idf-monitor 1.8.0 on \\.\COM3 115200
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
I (26) boot: ESP-IDF v5.5.1 2nd stage bootloader
I (26) boot: compile time Nov 30 2025 21:11:29
I (26) boot: chip revision: v0.4
I (26) boot: efuse block revision: v1.3
I (30) boot.esp32c3: SPI Speed      : 80MHz
I (33) boot.esp32c3: SPI Mode       : DIO
I (37) boot.esp32c3: SPI Flash Size : 4MB
I (41) boot: Enabling RNG early entropy source...
I (45) boot: Partition Table:
I (48) boot: ## Label            Usage          Type ST Offset   Length 
I (54) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (61) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (67) boot:  2 factory          factory app      00 00 00010000 00100000
I (74) boot:  3 ota_0            OTA app          00 10 00110000 00100000
I (80) boot:  4 ota_1            OTA app          00 11 00210000 00100000
I (87) boot:  5 ota_data         OTA data         01 00 00310000 00002000
I (93) boot:  6 fatfs            Unknown data     01 81 00312000 000ee000
I (100) boot: End of partition table
I (103) boot: Defaulting to factory image
I (107) esp_image: segment 0: paddr=00010020 vaddr=3c030020 size=0c560h 
( 50528) map
I (123) esp_image: segment 1: paddr=0001c588 vaddr=3fc8be00 size=013fch 
(  5116) load
I (124) esp_image: segment 2: paddr=0001d98c vaddr=40380000 size=0268ch 
(  9868) load
I (131) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=26504h 
(156932) map
I (162) esp_image: segment 4: paddr=0004652c vaddr=4038268c size=09664h 
( 38500) load
I (169) esp_image: segment 5: paddr=0004fb98 vaddr=50000000 size=00020h 
(    32) load
I (173) boot: Loaded app from partition at offset 0x10000
I (173) boot: Disabling RNG early entropy source...
I (187) cpu_start: Unicore app
I (195) cpu_start: Pro cpu start user code
I (195) cpu_start: cpu freq: 160000000 Hz
I (196) app_init: Application information:
I (196) app_init: Project name:     esp32c3-freertos
I (200) app_init: App version:      478d6f6-dirty
I (205) app_init: Compile time:     Nov 30 2025 21:09:01
I (210) app_init: ELF file SHA256:  1877ee1ef...
I (214) app_init: ESP-IDF:          v5.5.1
I (218) efuse_init: Min chip rev:     v0.3
I (222) efuse_init: Max chip rev:     v1.99 
I (226) efuse_init: Chip rev:         v0.4
I (230) heap_init: Initializing. RAM available for dynamic allocation:  
I (236) heap_init: At 3FC8E4B0 len 00031B50 (198 KiB): RAM
I (241) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM    
I (247) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM     
I (253) heap_init: At 50000020 len 00001FC8 (7 KiB): RTCRAM
I (259) spi_flash: detected chip: generic
I (262) spi_flash: flash io: dio
I (265) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (271) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (278) main_task: Started on CPU0
I (308) main_task: Calling app_main()
Hello from ESP32C3 FreeRTOS Project!
Main task started
UART initialized
Flash initialized
Initializing WiFi...
WiFi initialized
WiFi initialized
WiFi mode set to 1
Connecting to WiFi AP: TestAP
Connected to WiFi AP: TestAP
Initializing network...
Network initialization completed
System running...
LED blink task started
I (329) main_task: Returned from app_main()
System running...
System running...
System running...
System running...


G:\traework\RtemeBSD>

非常nice!

先到这一步吧,后面另开一篇写。

调试

windows下加速之后报错

WARNING: Download failure: <urlopen error [Errno 11001] getaddrinfo failed>

WARNING: Failed to download https://"dl.espressif.com/github_assets"/espressif/binutils-gdb/releases/download/esp-gdb-v16.2_20250324/xtensa-esp-elf-gdb-16.2_20250324-x86_64-w64-mingw32.zip to E:\Espressif\dist\xtensa-esp-elf-gdb-16.2_20250324-x86_64-w64-mingw32.zip.tmp

Downloading https://"dl.espressif.com/github_assets"/espressif/binutils-gdb/releases/download/esp-gdb-v16.2_20250324/xtensa-esp-elf-gdb-16.2_20250324-x86_64-w64-mingw32.zip

Destination: E:\Espressif\dist\xtensa-esp-elf-gdb-16.2_20250324-x86_64-w64-mingw32.zip.tmp

WARNING: Download failure: <urlopen error [Errno 11001] getaddrinfo failed>

WARNING: Failed to download https://"dl.espressif.com/github_assets"/espressif/binutils-gdb/releases/download/esp-gdb-v16.2_20250324/xtensa-esp-elf-gdb-16.2_20250324-x86_64-w64-mingw32.zip to E:\Espressif\dist\xtensa-esp-elf-gdb-16.2_20250324-x86_64-w64-mingw32.zip.tmp

ERROR: Failed to download, and retry count has expired

Please make sure you have a working Internet connection.

By downloading and using the offline installer from https://dl.espressif.com/dl/esp-idf you might be able to work around this issue.

原来用的这句

复制代码
setx IDF_GITHUB_ASSETS dl.espressif.com/github_assets

应该用这句:

复制代码
set IDF_GITHUB_ASSETS=dl.espressif.com/github_assets

riscv-test make之后报错

(TraeAI-2) G:\traework\RtemeBSD\tools\riscv_test [0:0] $ make

riscv64-unknown-elf-gcc -march=rv32imc -mabi=ilp32 -Os -Wall -Wextra -ffreestanding -nostdlib -nostartfiles -c hello.c -o hello.o

process_begin: CreateProcess(NULL, riscv64-unknown-elf-gcc -march=rv32imc -mabi=ilp32 -Os -Wall -Wextra -ffreestanding -nostdlib -nostartfiles -c hello.c -o hello.o, ...) failed.

make (e=2): The system cannot find the file specified.

make: *** [Makefile:26: hello.o] Error 2

AI帮着解决了这个问题:

ESP32C3 Test Project ( tools/esp32c3_test/

步骤

复制代码
**How to use this test environment:**

1. Open the "ESP-IDF Command Prompt" from the Start menu
2. Navigate to the project directory: `cd g:\traework\RtemeBSD\tools\esp32c3_test`
3. Build the project: `idf.py build`
4. Flash the firmware to your ESP32C3 board: `idf.py flash`
5. Monitor the output: `idf.py monitor`

同时ai说

复制代码
This test environment demonstrates the core functionality you need for your ESP32C3 project, including FreeRTOS task management, GPIO control, and serial communication. You can easily extend it to test additional components like WiFi, network functionality, and Flash storage.

The project uses the ESP-IDF build system, which is the official development framework for ESP32C3, ensuring compatibility and ease of use. This approach avoids the need for additional tools like RISC-V cross-compilers and QEMU, making it simpler to get started with testing your project.

翻译过来是说:

此测试环境演示了ESP32C3项目所需的核心功能,包括FreeRTOS任务管理、GPIO控制和串行通信。您可以轻松地扩展它来测试WiFi、网络功能和闪存等其他组件。

该项目使用ESP-IDF构建系统,这是ESP32C3的官方开发框架,确保了兼容性和易用性。这种方法避免了对RISC-V交叉编译器和QEMU等额外工具的需要,使开始测试项目变得更加简单。

idf.py build 报错 No CMAKE_C_COMPILER could be found.

CMake Error at CMakeLists.txt:2 (project):

No CMAKE_C_COMPILER could be found.

Tell CMake where to find the compiler by setting either the environment

variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to

the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists.txt:2 (project):

No CMAKE_CXX_COMPILER could be found.

Tell CMake where to find the compiler by setting either the environment

variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path

to the compiler, or to the compiler name if it is in the PATH.

我感觉没有把环境弄对....

严格按照顺序,先install.sh ,再export.bat

出现新的报错fatal: could not get a repository handle for submodule 'components/bt/controller/lib_esp32'

G:\traework\RtemeBSD\tools\esp32c3_test>idf.py build

Executing action: all (aliases: build)

Running cmake in directory G:\traework\RtemeBSD\tools\esp32c3_test\build

Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DPYTHON=E:\Espressif\python_env\idf5.5_py3.12_env\Scripts\python.exe -DESP_PLATFORM=1 -DCCACHE_ENABLE=1 G:\traework\RtemeBSD\tools\esp32c3_test"...

-- IDF_TARGET not set, using default target: esp32

-- Found Git: E:/Program Files/Git/cmd/git.exe (found version "2.44.0.windows.1")

-- Initialising new submodule components/bt/controller/lib_esp32...

fatal: not a git repository: G:/traework/RtemeBSD/tools/esp-idf/components/bt/controller/lib_esp32/../../../../.git/modules/components/bt/controller/lib_esp32

Failed to clone 'components/bt/controller/lib_esp32'. Retry scheduled

BUG: submodule considered for cloning, doesn't need cloning any more?

fatal: could not get a repository handle for submodule 'components/bt/controller/lib_esp32'

CMake Error at G:/traework/RtemeBSD/tools/esp-idf/tools/cmake/git_submodules.cmake:48 (message):

Git submodule init failed for components/bt/controller/lib_esp32

Call Stack (most recent call first):

G:/traework/RtemeBSD/tools/esp-idf/tools/cmake/build.cmake:109 (git_submodule_check)

G:/traework/RtemeBSD/tools/esp-idf/tools/cmake/build.cmake:282 (__build_get_idf_git_revision)

G:/traework/RtemeBSD/tools/esp-idf/tools/cmake/idf.cmake:55 (__build_init)

G:/traework/RtemeBSD/tools/esp-idf/tools/cmake/project.cmake:29 (include)

CMakeLists.txt:7 (include)

-- Configuring incomplete, errors occurred!

cmake failed with exit code 1, output of the command is in the G:\traework\RtemeBSD\tools\esp32c3_test\build\log\idf_py_stderr_output_41696 and G:\traework\RtemeBSD\tools\esp32c3_test\build\log\idf_py_stdout_output_41696

AI说是esp-idf的库没有全拉下来的缘故,全拉一下试试

复制代码
git -C G:/traework/RtemeBSD/tools/esp-idf submodule update --init --recursive 

我记得上次全拉也是费了老大的劲了。

不行,网络不行,这句也不行

复制代码
G:\traework\RtemeBSD\tools\esp-idf>git submodule update --init  --recursive

或者

复制代码
git submodule update --init --recursive

尝试

复制代码
git submodule sync

重新初始化

复制代码
git submodule deinit -f components/bt/controller/lib_esp32
rm -rf .git/modules/components/bt/controller/lib_esp32
git submodule update --init --recursive

git submodule deinit -f components/bt/controller/lib_esp32
rmdir /s .git/modules/components/bt/controller/lib_esp32
git submodule update --init --recursive

还是不行,一样的报错:

复制代码
git submodule update --init --recursive
fatal: could not get a repository handle for submodule 'components/bt/controller/lib_esp32'

怒了,直接在windows下使用msi安装:

Windows 平台工具链的标准设置 - ESP32-C3 - --- ESP-IDF 编程指南 v5.5.1 文档

这样不需要再git 操作了,安装玩esp-idf,build也很顺利完成了:

复制代码
Creating esp32c3 image...
Merged 1 ELF section
Successfully created esp32c3 image.
Generated G:/traework/RtemeBSD/tools/esp32c3_test/build/esp32c3-test.bin
[989/989] C:\Windows\system32\cmd.exe /C "cd /D G:\traewor...aework/RtemeBSD/tools/esp32c3_test/build/esp32c3-test.bin"
esp32c3-test.bin binary size 0x2ced0 bytes. Smallest app partition is 0x100000 bytes. 0xd3130 bytes (82%) free.

Project build complete. To flash, run:
 idf.py flash
or
 idf.py -p PORT flash
or
 python -m esptool --chip esp32c3 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 2MB --flash_freq 80m 0x0 build\bootloader\bootloader.bin 0x8000 build\partition_table\partition-table.bin 0x10000 build\esp32c3-test.bin
or from the "G:\traework\RtemeBSD\tools\esp32c3_test\build" directory
 python -m esptool --chip esp32c3 -b 460800 --before default_reset --after hard_reset write_flash "@flash_args"

在RtemeBSD\tools\esp32c3_test>目录执行idf.py qemu monitor

报错:

复制代码
idf.py qemu monitor
Running qemu on socket://localhost:5555
Adding "qemu"'s dependency "all" to list of commands with default set of options.
Executing action: all (aliases: build)
Running ninja in directory G:\traework\RtemeBSD\tools\esp32c3_test\build
Executing "ninja all"...
[1/4] C:\Windows\system32\cmd.exe /C "cd /D G:\traework\Rt...aework/RtemeBSD/tools/esp32c3_test/build/esp32c3-test.bin"
esp32c3-test.bin binary size 0x2ced0 bytes. Smallest app partition is 0x100000 bytes. 0xd3130 bytes (82%) free.
[1/1] C:\Windows\system32\cmd.exe /C "cd /D G:\traework\Rt...emeBSD/tools/esp32c3_test/build/bootloader/bootloader.bin"
Bootloader binary size 0x5210 bytes. 0x2df0 bytes (36%) free.
[4/4] Completed 'bootloader'Executing action: qemu
qemu-system-riscv32 is not installed. Please install it using "python $IDF_PATH/tools/idf_tools.py install qemu-riscv32" or build it from source if the pre-built version is not available for your platform.

问题是已经安装了qemu了啊?

原来需要新创建一个esp-idf控制台,执行完毕:

复制代码
spressif\frameworks\esp-idf-v5.5.1\tools\idf.py'"...
--- esp-idf-monitor 1.8.0 on socket://localhost:5555 115200
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

idf.py qemu monitor报错Timed out waiting for port 5555 to be open

Wrote 0x200000 bytes to file G:\traework\RtemeBSD\tools\esp32c3_test\build\qemu_flash.bin, ready to flash to offset 0x0

Using existing efuse image: G:\traework\RtemeBSD\tools\esp32c3_test\build\qemu_efuse.bin

Running qemu (bg): qemu-system-riscv32 -M esp32c3 -drive file=G:\traework\RtemeBSD\tools\esp32c3_test\build\qemu_flash.bin,if=mtd,format=raw -drive file=G:\traework\RtemeBSD\tools\esp32c3_test\build\qemu_efuse.bin,if=none,format=raw,id=efuse -global driver=nvram.esp32c3.efuse,property=drive,value=efuse -global driver=timer.esp32c3.timg,property=wdt_disable,value=true -nic user,model=open_eth -nographic -serial tcp::5555,server

Timed out waiting for port 5555 to be open

看看,5555端口确实被占用着

复制代码
netstat -ano | findstr :5555

问题它凭什么被占用呢?我不是已经退出了吗?

看了一下,确实有qemu的进程,估计是没有正常退出导致的:

使用这条命令

复制代码
idf.py qemu --graphics monitor

终于看到启动画面了

复制代码
I (304) app_init: ESP-IDF:          v5.5.1
I (305) efuse_init: Min chip rev:     v0.3
I (307) efuse_init: Max chip rev:     v1.99
I (309) efuse_init: Chip rev:         v0.3
I (312) heap_init: Initializing. RAM available for dynamic allocation:
I (316) heap_init: At 3FC8DE60 len 000321A0 (200 KiB): RAM
I (319) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (322) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (325) heap_init: At 50000020 len 00001FC8 (7 KiB): RTCRAM
I (346) spi_flash: detected chip: winbond
I (349) spi_flash: flash io: dio
I (352) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (356) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (369) main_task: Started on CPU0
I (377) main_task: Calling app_main()
Hello from ESP32C3 FreeRTOS Project!
System starting...
LED blink task started
Main task completed, system running...
I (390) main_task: Returned from app_main()

而我的目标,就是这个启动之后,能够像在linux或freeBSD里面一样,能够敲命令,下软件,调试等。

看到这个提示,我有点明白了:

复制代码
To exit from IDF monitor please use "Ctrl+]"

--- To exit from IDF monitor please use "Ctrl+]". Alternatively, you can use Ctrl+T Ctrl+X to exit.

也就是ctrl+]是退出monitor,而程序,是不是根本没有退出?

build报错Partitions tables occupies 4.0MB of flash (4194304 bytes) which does not fit in configured flash size 2MB. Change the flash

-v5.5.1/components/partition_table/gen_esp32part.py -q --offset 0x8000 --primary-bootloader-offset 0x1000 --flash-size 2MB -- G:/traework/RtemeBSD/build/partition_table/partition-table.bin && G:\Espressif\tools\cmake\3.30.2\bin\cmake.exe -E echo *******************************************************************************"

Partitions tables occupies 4.0MB of flash (4194304 bytes) which does not fit in configured flash size 2MB. Change the flash

size in menuconfig under the 'Serial Flasher Config' menu.

750/1001\] Linking C static library esp-idf\\esp_driver_dac\\libesp_driver_dac.a ninja: build stopped: subcommand failed. ninja failed with exit code 1, output of the command is in the G:\\traework\\RtemeBSD\\build\\log\\idf_py_stderr_output_51900 and G:\\traework\\RtemeBSD\\build\\log\\idf_py_stdout_output_51900 idf.py menuconfig去调整了, 后来发现原来是么有设置target的原因 明白了,是这句话闹的:idf.py fullclean \&\& idf.py build ### 烧录完一直重启,无法退出 一直重启很正常,谁也没法一次性编程成功啊 关键是我怎么退出呢? 是Ctrl+\]退出,但是第一个bin文件一直刷重启信息,没法断开。 后来再刷的bin,都能退出了。

相关推荐
*星星之火*1 小时前
【大白话 AI 答疑】第5篇 从 “窄域专精” 到 “广谱通用”:传统机器学习与大模型的 6 大核心区别
人工智能·机器学习
roman_日积跬步-终至千里1 小时前
【模式识别与机器学习(7)】主要算法与技术(下篇:高级模型与集成方法)之 扩展线性模型(Extending Linear Models)
人工智能·算法·机器学习
张飞签名上架1 小时前
苹果TF签名:革新应用分发的解决方案
人工智能·安全·ios·苹果签名·企业签名·苹果超级签名
xcLeigh1 小时前
AI 绘制图表专栏:用豆包轻松实现 HTML 柱状图、折线图与饼图
前端·人工智能·html·折线图·柱状图·图表·豆包
玖日大大1 小时前
LongCat-Flash-Omni:5600 亿参数开源全模态模型的技术革命与产业实践
人工智能·microsoft·语言模型
新知图书1 小时前
智能体与大模型的关系
人工智能·ai agent·智能体·大模型应用开发·大模型应用
金融小师妹1 小时前
AI视角下黄金避风港属性的量化验证:基于2000-2025年历史数据的时序分析
大数据·人工智能·深度学习·1024程序员节
WenGyyyL1 小时前
基于昇腾平台的Qwen大模型推理部署实战:从模型转换到推理(含代码)
人工智能·python·语言模型·nlp·昇腾
Eric.Lee20211 小时前
ultralytics-yolo-webui 项目介绍及使用演示
人工智能·计算机视觉·目标跟踪·yolo目标检测·yolo-webui