Sublime Text 可通过配置胜任 ESP32/Arduino 固件开发:需安装 ESP-IDF 或 Arduino CLI 工具链,配置对应 Build System,搭配 EasyClangComplete 等插件提升效率,并规范项目结构与头文件路径。

Sublime Text 本身不是 IDE,但通过合理配置,完全可以胜任 ESP32 或 Arduino 的 C/C++ 固件开发——轻量、快速、高度可定制,特别适合熟悉命令行和构建流程的嵌入式开发者。
Sublime 不自带编译功能,需先在系统层面配好底层工具:
install.sh 并执行 export.sh 配置环境变量;确保 idf.py 可全局调用arduino-cli config init,再用 arduino-cli core install esp32:esp32 安装 ESP32 支持包make、cmake、python3、gcc-arm-none-eabi(ESP-IDF 必需)已就位让 Sublime 调用真实工具链编译烧录,关键在 Tools → Build System → New Build System:
ESP-IDF.sublime-build
{
"shell_cmd": "idf.py -p $project_path/ports/serialport build flash monitor",
"working_dir": "$project_path",
"variants": [
{
"name": "Build Only",
"shell_cmd": "idf.py build"
},
{
"name": "Flash Only",
"shell_cmd": "idf.py -p /dev/ttyUSB0 flash"
}
]
}Arduino-CLI.sublime-build
{
"shell_cmd": "arduino-cli compile -b esp32:esp32:devkitv1 --fqbn esp32:esp32:devkitv1 -u -p /dev/ttyUSB0 $file_path",
"working_dir": "$file_path",
"selector": "source.cpp"
}⚠️ 注意替换 /dev/ttyUSB0 为你实际串口(macOS 是 /dev/cu.usbserial-,Windows 是 COM3 等)
立即学习“C++免费学习笔记(深入)”;
纯文本编辑器缺啥补啥,这几个插件能大幅提效:
compile_commands.json,ESP-IDF 项目可用 idf.py build -t compile_commands 生成)idf.py monitor 或 arduino-cli monitor 查看串口日志避免“找不到 header”报错,关键是路径对齐:
components/xxx/ 下,其 CMakeLists.txt 中用 target_include_directories(${COMPONENT_TARGET} PRIVATE include)
libraries/MyDriver/,并在 platformio.ini(若用 PlatformIO)或 arduino-cli.yaml 中声明路径Ctrl+Shift+P → “Index Files” 强制刷新符号索引,确保跳转和补全准确基本上就这些。不用重装 IDE,不卡顿不占内存,写固件也能保持 Sublime 的干净和速度。
以上就是Sublime进行IoT设备固件开发_使用C/C++适配ESP32或Arduino的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号