嵌入式ESP32初学踩坑记录

发布时间:2026/10/2 2:33:05

嵌入式ESP32初学踩坑记录 我第一次做嵌入式开发然后把学习过程记录一下。ESP32开发板这里我选了一个我同事给我推荐的板子叫ESP32。具体型号为ESP32-S3开发板N16R8焊接。我在淘宝上买的20多块钱。开发环境搭建上来我用最常见的Windows做开发环境后续我会尝试一下用Linux做开发。官方文档地址如下https://docs.espressif.com/projects/esp-idf/zh_CN/stable/esp32/get-started/windows-setup.html我的实战操作如下下载安装包https://dl.espressif.com/dl/eim/https://dl.espressif.com/github_assets/espressif/idf-im-ui/releases/download/v0.19.0/eim-gui-windows-x64.exe打开开始安装第1次玩不折腾了直接简易安装。直接点开始安装然后就开始下载安装包了估计要下载10几分钟吧可惜我这里自动安装失败了。说什么找不到python的什么环境吧。我忘记截图了然后点了个重试说安装路径已经存在。然后又点了专家模式。这个版本选择这里我很怂的选择上个版本的稳定版本v5.5.5。然后点击继续安装。这里因为我不懂所以我全选 第1 次尝试我全选安装后来安装失败了。原因是磁盘空间不足原来C盘就只有不足。后来我换了安装在D盘。安装后C盘有一个Espressif目录高达17GB我感觉这个目录可能是下载的缓存吧理论上应该可以删除吧。我暂时不敢删除D盘的安装目录是为什么会这么巨大啊我猜测可能是因为是集成开发环境吧。把一堆依赖项目都自动安装了吧。创建项目为了简单点我选择使用命令行版本的参考https://docs.espressif.com/projects/esp-idf/zh_CN/stable/esp32/get-started/windows-start-project.htmlESP-IDF 安装完成后EIM 会在桌面上创建 快捷方式用于启动已激活 ESP-IDF 环境的终端。例如点击 IDF_v5.4.2_Powershell 快捷方式打开已设置好环境的 PowerShell 终端。至此您已成功在终端中激活 ESP-IDF 环境。后续所有 ESP-IDF 相关命令都需在已激活的终端中运行。开始创建项目现在可以准备开发 ESP32 应用程序了。可以从 ESP-IDF 中 examples 目录下的 get-started/hello_world 项目开始。重要ESP-IDF 编译系统不支持 ESP-IDF 路径或其项目路径中带有空格。将 get-started/hello_world 项目复制至本地的 ~/esp 目录下D:\esp\v5.5.5\esp-idf\examples\get-started\我复制到了D:\workspace\esp\hello_world获取串口信息可以拔掉设备后在插上看端口这里的设备变化因为我这里只有一台设备所以知道这里是COM3cdD:\workspace\esp\hello_world idf.py set-target esp32 idf.py menuconfig打开一个新项目后应首先使用 idf.py set-target esp32 设置“目标”芯片。注意此操作将清除并初始化项目之前的编译和配置如有。也可以直接将“目标”配置为环境变量此时可跳过该步骤。更多信息请见 选择目标芯片set-target。正确操作上述步骤后系统将显示以下菜单可以通过此菜单设置项目的具体变量包括 Wi-Fi 网络名称、密码和处理器速度等。hello_world 示例项目会以默认配置运行因此在这一项目中可以跳过使用 menuconfig 进行项目配置这一步骤。编译项目请使用以下命令编译烧录项目idf.py build运行以上命令可以编译应用程序和所有 ESP-IDF 组件接着生成引导加载程序、分区表和应用程序二进制文件。如果一切正常编译完成后将生成 .bin 文件。烧录到设备请运行以下命令将刚刚生成的二进制文件烧录至 ESP32 开发板idf.py-pPORT flash那么我这里就是上面查到的COM3idf.py-pCOM3 flash我这里并没有成功任务失败明天在试吧。然后问AI说尝试按住Boot键然后点一下RST这时会听到电脑一个设备连接的咚一声在设备管理中发现串口COM3变成COM4了。这时执行烧写日志发生变化了。idf.py flash(venv)PS D:\workspace\esp\hello_worldidf.py flash Executing action: flash Serial port COM4 Connecting... Detecting chip type... ESP32-S3 Running ninjaindirectory D:\workspace\esp\hello_world\build Executingninja flash...[0/1]Re-running CMake... -- Component directory D:/esp/v5.5.5/esp-idf/components/esp_blockdev does not contain a CMakeLists.txt file. No component will be added -- Minimal build - ON -- ccache will be usedforfaster recompilation --gitrev-parse returnedfatal: not a git repository (or any of the parent directories): .git-- Could not usegit describeto determine PROJECT_VER. -- Building ESP-IDF componentsfortarget esp32 -- ESP-TEE is currently supported only on the esp32c6;esp32h2;esp32c5 SoCs -- Project sdkconfigfileD:/workspace/esp/hello_world/sdkconfig -- Compiler supported targets: xtensa-esp-elf -- Detecting C compiler ABI info -- Detecting C compiler ABI info -done-- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info -done-- Detecting C compiler ABI info -- Detecting C compiler ABI info -done-- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info -done-- USING O3 -- Apphello_worldversion:1-- Adding linker script D:/workspace/esp/hello_world/build/esp-idf/esp_system/ld/memory.ld -- Adding linker script D:/workspace/esp/hello_world/build/esp-idf/esp_system/ld/sections.ld.in -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libc-funcs.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-reent-funcs.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/soc/esp32/ld/esp32.peripherals.ld -- Components: app_update bootloader bootloader_support cxx efuse esp_app_format esp_bootloader_format esp_common esp_driver_gpio esp_hw_support esp_mm esp_partition esp_pm esp_rom esp_security esp_system esp_timer esptool_py freertos hal heap log main mbedtls newlib partition_table pthread soc spi_flash xtensa -- Component paths: D:/esp/v5.5.5/esp-idf/components/app_update D:/esp/v5.5.5/esp-idf/components/bootloader D:/esp/v5.5.5/esp-idf/components/bootloader_support D:/esp/v5.5.5/esp-idf/components/cxx D:/esp/v5.5.5/esp-idf/components/efuse D:/esp/v5.5.5/esp-idf/components/esp_app_format D:/esp/v5.5.5/esp-idf/components/esp_bootloader_format D:/esp/v5.5.5/esp-idf/components/esp_common D:/esp/v5.5.5/esp-idf/components/esp_driver_gpio D:/esp/v5.5.5/esp-idf/components/esp_hw_support D:/esp/v5.5.5/esp-idf/components/esp_mm D:/esp/v5.5.5/esp-idf/components/esp_partition D:/esp/v5.5.5/esp-idf/components/esp_pm D:/esp/v5.5.5/esp-idf/components/esp_rom D:/esp/v5.5.5/esp-idf/components/esp_security D:/esp/v5.5.5/esp-idf/components/esp_system D:/esp/v5.5.5/esp-idf/components/esp_timer D:/esp/v5.5.5/esp-idf/components/esptool_py D:/esp/v5.5.5/esp-idf/components/freertos D:/esp/v5.5.5/esp-idf/components/hal D:/esp/v5.5.5/esp-idf/components/heap D:/esp/v5.5.5/esp-idf/components/log D:/workspace/esp/hello_world/main D:/esp/v5.5.5/esp-idf/components/mbedtls D:/esp/v5.5.5/esp-idf/components/newlib D:/esp/v5.5.5/esp-idf/components/partition_table D:/esp/v5.5.5/esp-idf/components/pthread D:/esp/v5.5.5/esp-idf/components/soc D:/esp/v5.5.5/esp-idf/components/spi_flash D:/esp/v5.5.5/esp-idf/components/xtensa -- Configuringdone(19.4s)-- Generatingdone(0.9s)-- Build files have been written to: D:/workspace/esp/hello_world/build[3/9]Generating binary image from built executable esptool.py v4.12.0 Creating esp32 image... Merged2ELF sections Successfully created esp32 image. Generated D:/workspace/esp/hello_world/build/hello_world.bin[4/9]C:\Windows\system32\cmd.exe /Ccd /D D:\workspace\esp\hello_world\build\esp-idf\esptool_py C:...llo_world/build/partition_table/partition-table.bin D:/workspace/esp/hello_world/build/hello_world.bin hello_world.bin binary size 0x21660 bytes. Smallest app partition is 0x100000 bytes. 0xde9a0 bytes (87%) free. [0/1] Re-running CMake... -- Component directory D:/esp/v5.5.5/esp-idf/components/esp_blockdev does not contain a CMakeLists.txt file. No component will be added -- Minimal build - OFF -- Building ESP-IDF components for target esp32 -- ESP-TEE is currently supported only on the esp32c6;esp32h2;esp32c5 SoCs -- Project sdkconfig file D:/workspace/esp/hello_world/sdkconfig -- Compiler supported targets: xtensa-esp-elf -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Adding linker script D:/esp/v5.5.5/esp-idf/components/soc/esp32/ld/esp32.peripherals.ld -- Bootloader project name: bootloader version: 1 -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libc-funcs.ld -- Adding linker script D:/esp/v5.5.5/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.rom.ld -- Components: bootloader bootloader_support efuse esp_app_format esp_bootloader_format esp_common esp_hw_support esp_rom esp_security esp_system esptool_py freertos hal log main micro-ecc newlib partition_table soc spi_flash xtensa -- Component paths: D:/esp/v5.5.5/esp-idf/components/bootloader D:/esp/v5.5.5/esp-idf/components/bootloader_support D:/esp/v5.5.5/esp-idf/components/efuse D:/esp/v5.5.5/esp-idf/components/esp_app_format D:/esp/v5.5.5/esp-idf/components/esp_bootloader_format D:/esp/v5.5.5/esp-idf/components/esp_common D:/esp/v5.5.5/esp-idf/components/esp_hw_support D:/esp/v5.5.5/esp-idf/components/esp_rom D:/esp/v5.5.5/esp-idf/components/esp_security D:/esp/v5.5.5/esp-idf/components/esp_system D:/esp/v5.5.5/esp-idf/components/esptool_py D:/esp/v5.5.5/esp-idf/components/freertos D:/esp/v5.5.5/esp-idf/components/hal D:/esp/v5.5.5/esp-idf/components/log D:/esp/v5.5.5/esp-idf/components/bootloader/subproject/main D:/esp/v5.5.5/esp-idf/components/bootloader/subproject/components/micro-ecc D:/esp/v5.5.5/esp-idf/components/newlib D:/esp/v5.5.5/esp-idf/components/partition_table D:/esp/v5.5.5/esp-idf/components/soc D:/esp/v5.5.5/esp-idf/components/spi_flash D:/esp/v5.5.5/esp-idf/components/xtensa -- Adding linker script D:/esp/v5.5.5/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.ld -- Configuring done (9.8s) -- Generating done (0.4s) -- Build files have been written to: D:/workspace/esp/hello_world/build/bootloader [1/2] C:\Windows\system32\cmd.exe /C cd/D D:\workspace\esp\hello_world\build\bootloader\esp-idf\espto...izes.py--offset0x8000 bootloader 0x1000 D:/workspace/esp/hello_world/build/bootloader/bootloader.bin Bootloader binary size 0x6610 bytes. 0x9f0 bytes(9%)free.[7/9]C:\Windows\system32\cmd.exe /Ccd /D D:\esp\v5.5.5\esp-idf\components\esptool_py C:\Espressif...:/workspace/esp/hello_world/build -P D:/esp/v5.5.5/esp-idf/components/esptool_py/run_serial_tool.cmake esptool.py --chip esp32 -p COM4 -b 460800 --beforedefault_reset --afterhard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x1000 bootloader/bootloader.bin 0x10000 hello_world.bin 0x8000 partition_table/partition-table.bin esptool.py v4.12.0 Serial port COM4 Connecting... A fatal error occurred: This chip is ESP32-S3, not ESP32. Wrong --chip argument? CMake Error at run_serial_tool.cmake:67 (message): C:/Espressif/tools/python/v5.5.5/venv/Scripts/python.exe;;D:/esp/v5.5.5/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32 failed. FAILED: CMakeFiles/flash D:/workspace/esp/hello_world/build/CMakeFiles/flash C:\Windows\system32\cmd.exe /C cd/D D:\esp\v5.5.5\esp-idf\components\esptool_pyC:\Espressif\tools\cmake\3.30.2\bin\cmake.exe-DIDF_PATHD:/esp/v5.5.5/esp-idf-DSERIAL_TOOLC:/Espressif/tools/python/v5.5.5/venv/Scripts/python.exe;;D:/esp/v5.5.5/esp-idf/components/esptool_py/esptool/esptool.py;--chip;esp32-DSERIAL_TOOL_ARGS--beforedefault_reset;--afterhard_reset;write_flash;flash_args-DWORKING_DIRECTORYD:/workspace/esp/hello_world/build-PD:/esp/v5.5.5/esp-idf/components/esptool_py/run_serial_tool.cmake ninja: build stopped: subcommand failed. ninja failed withexitcode1, output of thecommandisinthe D:\workspace\esp\hello_world\build\log\idf_py_stderr_output_5308 and D:\workspace\esp\hello_world\build\log\idf_py_stdout_output_5308(venv)PS D:\workspace\esp\hello_world在日志中看到A fatal error occurred: This chip is ESP32-S3, not ESP32. Wrong --chip argument?CMake Error at run_serial_tool.cmake:67 (message):对这次日志已经把问题定位得非常清楚了。你的开发板实际上是 ESP32-S3而你的项目目前按照普通 ESP32 在烧录。最关键的一行A fatal error occurred: This chip is ESP32-S3, not ESP32. Wrong --chip argument?也就是说现在的情况是你的开发板ESP32-S3 ↓ 当前项目配置ESP32 ↓ esptool--chip esp32 ↓ 发现芯片其实是 ESP32-S3 ↓ 烧录失败解决方法你需要把项目的 Target 从esp32改成esp32s3。在当前项目cd D:\workspace\esp\hello_world执行idf.pyset-targetesp32s3正常应该会看到类似Set Target to: esp32s3, new sdkconfig will be created.然后重新编译idf.py build最后烧录idf.py-p COM4 flash这次就烧录成功了。监视输出可以使用 idf.py -p PORT monitor 命令监视 “hello_world” 项目的运行情况。注意不要忘记将 PORT 替换为自己的串口名称。运行该命令后IDF 监视器 应用程序将启动。我这里显示的内容如下(venv)PS D:\workspace\esp\hello_worldidf.py monitor Executing action: monitor Serial port COM4 Connecting... Detecting chip type... ESP32-S3 Running idf_monitorindirectory D:\workspace\esp\hello_world ExecutingC:\Espressif\tools\python\v5.5.5\venv\Scripts\python.exe D:\esp\v5.5.5\esp-idf\tools/idf_monitor.py -p COM4 -b 115200 --toolchain-prefix xtensa-esp32s3-elf- --target esp32s3 --revision 0 D:\workspace\esp\hello_world\build\hello_world.elf D:\workspace\esp\hello_world\build\bootloader\bootloader.elf --force-color -m C:\Espressif\tools\python\v5.5.5\venv\Scripts\python.exe D:\esp\v5.5.5\esp-idf\tools\idf.py... --- WARNING: GDB cannotopenserial ports accessed as COMx --- NOTE: Using\\.\COM4 instead... --- esp-idf-monitor1.10.0 on\\.\COM4115200--- Quit: Ctrl]|Menu: CtrlT|Help: CtrlT followed by CtrlH ESP-ROM:esp32s3-20210327 Build:Mar272021rst:0x15(USB_UART_CHIP_RESET),boot:0x0(DOWNLOAD(USB/UART0))Saved PC:0x40048d14 --- 0x40048d14: uart_rx_one_charinROM waitingfordownload并没有我想要的hello world的输出。对烧录已经成功了。现在的问题也很明确boot:0x0 (DOWNLOAD(USB/UART0)) waiting for download说明你的 ESP32-S3现在还停留在下载模式没有启动刚才写进去的hello_world程序。现在这样做先退出当前 monitorCtrl ]然后不要按 BOOT直接按一下开发板上的RST / RESET / EN然后重新idf.py monitor或者更简单idf.py-p COM4 monitor正常情况下应该看到类似Hello world! This is ESP32-S3 chip with 2 CPU cores Chip revision: v0.2 ... Restarting in 10 seconds...如果你的hello_world是 ESP-IDF 自带的经典示例它会不断输出类似I (251) main_task: Calling app_main() Hello world! This is esp32s3 chip with 2 CPU core(s), WiFi/BLE, silicon revision v0.2, 2MB external flash Minimum free heap size: 391992 bytes Restarting in 10 seconds... Restarting in 9 seconds... Restarting in 8 seconds...
延伸阅读

更多相关文章

2026/10/2 2:33:05

DeepSeek LeetCode 138.随机链表的复制 Kotlin实现

下面是 LeetCode 138「随机链表的复制」的 Kotlin 实现。提供两种常见解法:哈希表法(简单直观)和原地复制法(O(1) 额外空间)。节点类定义 class Node(var val: Int) {var next: Node? nullvar random: Node? null …

2026/10/2 2:33:05

乘法器和除法器

引言本篇文章主要是关于《计算机组成原理》的乘法和除法运算的底层进行细节展开,相比于考研的内容,底层的实现可能会更加全面一些。乘法器两个数相乘我们在小学的时候就利用竖式进行计算,所以在我们无符号数的时候,我们的计算方式…

2026/10/2 2:33:05

从“警察抓小偷”到 6502 汇编:一段关于《Lode Runner》的回忆与追寻

一、那个叫“警察抓小偷”的游戏 上世纪八十年代,一台 Apple II 电脑前,一个初中生正对着屏幕上的像素小人发愁。他操控的小人在砖块迷宫里跑来跑去,身后有几个红色的小人紧追不舍。他需要收集完所有的金块,然后爬到顶部逃出去。但他总是失败,总是被抓到,然后从第一关重…

2026/10/2 3:08:07

网络欺诈检测NLP实战:从TF-IDF到BERT微调的完整指南

简介:网络欺诈检测数据集提供8,564个中英双语欺诈案例,覆盖钓鱼、虚假招聘、冒充等类型,面向自然语言处理与网络安全研究者,用于训练和评估多类别欺诈文本识别模型,可帮助开发者快速构建和迭代检测方案。资源共4个JSON…

2026/10/2 3:08:07

PyTorch CNN遥感滑坡识别:小样本、多光谱与距离场监督

简介:本资源是一套基于PyTorch实现的遥感图像滑坡识别系统,面向地理信息科学、遥感技术及人工智能交叉领域的高校学生与科研初学者,解决地质灾害智能解译中的关键识别问题。压缩包共15个文件,含7个核心Python脚本(涵盖…

2026/10/2 3:08:07

报文修改实战指南:从Wireshark抓包到Linux重放的完整链路

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/2 3:08:07

Verilog仿真环境搭建:Icarus+GTKwave+VSCode全链路解析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/2 3:03:07

机票数据分析与可视化大作业:从数据清洗到ECharts交互看板

简介:这是一份面向计算机相关专业学生与项目实战学习者的Python数据分析可视化大作业完整源码,聚焦机票价格数据分析与预测,并借助PyQt5实现可视化界面展示,适合正在准备课程设计、期末大作业或需要练手数据分析项目的人群。资源包…

2026/10/1 5:21:14

东莞市品牌网站建设报价常见报错与解决

东莞品牌网站建设报价单背后:一份保姆级建站教程避坑实录 网站做好了没人访问,这大概是很多老板最头疼的事。花了大几万做的品牌站,上线后流量惨淡,比路边摊还冷清。别急着骂外包公司,很多“东莞品牌网站建设报价”里藏着不少猫腻,比如用模板站冒充定制…

2026/10/1 17:09:46

如何划分训练/验证集:Spirula Studio五种eval_mode策略详解

如何划分训练/验证集:Spirula Studio五种eval_mode策略详解 【免费下载链接】spirula-studio Cross-vendor 3D Gaussian Splatting trainer - video to splat to mesh, Vulkan or CUDA. 项目地址: https://gitcode.com/GitHub_Trending/sp/spirula-studio Sp…

2026/10/1 10:48:55

SEO怎么推广速查手册新手避坑实战指南

SEO怎么推广速查手册新手避坑实战指南 模板网站太丑不够用?别急着加滤镜,那是治标不治本。很多老板盯着后台流量掉得眼红,却还在纠结首页Banner的圆角是不是3像素。这就像穿着西装去挖土,姿势不对,努力白费。我整理这份 速查手册…

2026/10/2 0:02:57

PWN入门:从栈溢出原理到ROP链实战

1. 这不是“学PWN”,是重新理解你每天敲的每一行C代码我第一次在CTF赛场上写出能控制程序流的exp时,手抖得连gdb的c命令都输错三次。那道题只有23行C代码,一个gets()调用,一个printf(),一个return——它甚至没开NX&…

2026/10/2 0:02:57

Windows下cudaMallocHost显存占用之谜:WDDM与TCC模式差异及优化方案

1. 一个反直觉的显存占用现象第一次在 Windows 上看到cudaMallocHost把显存吃掉的时候,我的反应是打开任务管理器反复确认了三遍。明明调用的是主机端锁页内存分配,按 CUDA 文档的说法,这块内存应该落在系统 RAM 里,跟 GPU 的显存…

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
☎咨询二维码 ☎ ↑