ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

archlinux 搭建ESP32开发环境 从0到Hello world

archlinux 搭建ESP32开发环境 从0到Hello world 我喜欢使用linux作为开发环境我常常跟做嵌入式开发的朋友推荐他总是说他的开发只能在windows之中进行。我就很疑惑 别的芯片我不知道我刚学的ESP32官方文档中写了支持linux。那么我今天就尝试用Linux 搭建一下吧。在linux之中尝试之前我已经在windows搭建过开发环境了相关文章《ESP32 入门 从0到Hello world》https://blog.csdn.net/lxyoucan/article/details/166937693开发板选购我这里选的是ESP32 S3-N16R8,为什么选这个型号呢 我一个会嵌入式的朋友推荐的。20多块买的。安装依赖包通过官方文档得知在arch linux之中需要以下依赖包。Arch Linuxlibusb: Includes both runtime and development files for USB access.libffi: Includes both runtime and development files for Foreign Function Interface.openssl: Includes both runtime and development files for OpenSSL.libgcrypt: Runtime library for cryptographic functions (QEMU dependency).glib: Runtime library for GLib (QEMU dependency).pixman: Runtime library for pixman (QEMU dependency).sdl2: Runtime library for SDL2 (QEMU dependency).libslirp: Runtime library for SLIRP user-mode networking (QEMU dependency).webkit2gtk-4.1: library needed for rendering the Ui for the GUI not needed for CLIsudopacman-S--needed\libusb\libffi\openssl\libgcrypt\glib2\pixman\sdl2\libslirp\webkit2gtk-4.1eim-cli官方文档之中只介绍了Debian 发行版与RPM 发行版的安装方法那么在archlinux之中如何安装呢我找到了这个https://aur.archlinux.org/packages/eim-cliyay-Seim-cli从这个名称上可以看出这是个cli程序但是为什么安装时也看到了下载GUI的包。保存路径/home/itkey/.cache/yay/eim-bin/gui-0.19.0-x64.zip并且解压以后确实可以正常打开图形化界面。看起来跟windows上的图形化安装界面完全相同。虽然现在有图形化界面了但是咱不用。都用linux了是不是用一下cli更符合场景呢向导模式【失败】PS这个模式失败了所以不用看仅做了解。# 向导模式进行安装eim wizard显示如下eim wizard2026-10-0210:06:59 -10-10- INFO - Running IDF Installer Wizard...2026-10-0210:06:59 -10-10- INFO - Found git: /usr/sbin/git2026-10-0210:06:59 -10-10- INFO - All prerequisites are satisfied!2026-10-0210:06:59 -10-10- INFO - Running python sanity check ⠂ Doing something...2026-10-0210:06:59 -10-10- INFO - Found python3 ⢀ Doing something...[PASS]Python Version[PASS]pip[PASS]venv[PASS]Standard Library(json, os, platform)[PASS]ctypes[PASS]SSL/HTTPS2026-10-0210:07:01 -10-10- INFO - Your Python meets the requirements ? Pleaseselectall of the target platforms(ESP chips)› ⬚ all ⬚ esp32 ⬚ esp32c2 ⬚ esp32c3 ⬚ esp32c5 ⬚ esp32c6 ⬚ esp32c61 ⬚ esp32h2 ⬚ esp32p4 ⬚ esp32s2 ✔ esp32s3 ⬚ esp32s31可以按方向键选择按空格键操作复选框。回车进入下一步。我这里取消了默认的all只选了esp32s3Pleaseselectthe desired ESP-IDF version › ⬚ v6.1 ⬚ v6.0.3 ✔ v5.5.5 ⬚ v5.4.4 ⬚ v5.3.6 ⬚ release-v6.1 ⬚ release-v6.0 ⬚ release-v5.5 ⬚ release-v5.4 ⬚ release-v5.3 ⬚ master版本选择我选择了次新版本v5.5.5追求稳定性和教程与资料相对更多。? Select thesourcefromwhichto download ESP-IDF › https://github.com(timeout)❯ https://git.espressif.com.cn(timeout)网络选择下面那个带.cn的我也不知道这里为什么会显示timeout。? Select asourcefromwhichto download tools › ❯ https://dl.espressif.cn/github_assets(48ms)https://dl.espressif.com/github_assets(216ms)https://github.com(timeout)? Select a PyPI mirror to download Python packages › ❯ https://pypi.mirrors.ustc.edu.cn/simple(163ms)https://pypi.tuna.tsinghua.edu.cn/simple(229ms)https://pypi.org/simple(timeout)https://mirrors.aliyun.com/pypi/simple(timeout)? Pleaseselectthe ESP-IDF installation location(/home/itkey/.espressif)›这里我直接回车默认了。2026-10-0210:20:02 -10-10- WARN - Failed toreadrequirements configuration: HTTP error: error sending requestforurl(https://git.espressif.com.cn/espressif/esp-idf/raw/v5.5.5/tools/requirements.json). wizard.features.selection_unavailable Error executing CLI: No features availableforselection失败来的太突然了。哈哈哈哈。我就知道不可能这么顺利的。我尝试多次后放弃了。自动安装eiminstall它会自动安装但是这个方法是可行的并没有报错。至少他在下载。没想到一次性就成功了而且这种方式自动安装最新稳定版本。NOTE:95new files downloaded2026-10-0210:40:28 -10-10- INFO - Components registry synchronized successfully Added environment variable ESP_IDF_VERSION6.1Added environment variable IDF_VERSION6.1.0 Added environment variable IDF_TOOLS_PATH/home/itkey/.espressif/tools Added environment variable IDF_COMPONENT_LOCAL_STORAGE_URLfile:///home/itkey/.espressif/tools Added environment variable IDF_PATH/home/itkey/.espressif/v6.1/esp-idf Added environment variable ESP_ROM_ELF_DIR/home/itkey/.espressif/tools/esp-rom-elfs/20241011/ Added environment variable OPENOCD_SCRIPTS/home/itkey/.espressif/tools/openocd-esp32/v0.12.0-esp32-20260703/openocd-esp32/share/openocd/scripts Added environment variable IDF_PYTHON_ENV_PATH/home/itkey/.espressif/tools/python/v6.1/venv Added environment variable ESP_CLANG_LIBS_PATH/home/itkey/.espressif/tools/esp-clang-libs/esp-21.1.3_20260408/esp-clang/lib Added proper directory toPATHActivated virtual environment at /home/itkey/.espressif/tools/python/v6.1/venv Environment setup completeforthe current shell session. These changes will be lost when you close this terminal. You are now using IDF version6.1.0. NOTE: No dependenciesinidf_extra_components.yml, removing root managed components2026-10-0210:40:29 -10-10- INFO - Required components successfully downloaded Configuration saved successfully to config.toml You have successfully installed ESP-IDFforusing the ESP-IDF tools inside the terminal, you willfindactivation scripts inside the baseinstallfolder sourcing the activation script will setup environmentinthe current terminal sessionto activate the environment, run the followingcommandinyour terminal:source/home/itkey/.espressif/tools/activate_idf_v6.1.sh2026-10-0210:40:29 -10-10- INFO - Wizard result: Ok2026-10-0210:40:29 -10-10- INFO - Successfully installed IDF2026-10-0210:40:29 -10-10- INFO - Now you can start using IDF tools这里一下就成功了但是其实我想安装次新版本v5.5.5后面我在研究吧。先试试hello world。命令行运行hello world以下目录之中有个示例。~/.espressif/v6.1/esp-idf/examples/get-started/hello_world我复制它到/home/itkey/lansi/workspace/esp/hello_worldcd/home/itkey/lansi/workspace/esp/hello_worldsource/home/itkey/.espressif/tools/activate_idf_v6.1.sh# 设置平台idf.py set-target esp32s3# 构建idf.py build# 烧录idf.py flash我这里到烧录这一步出错了。ERROR: /dev/ttyACM0 failed to connect: Could notopen/dev/ttyACM0, the port is busy or doesnt exist. ([Errno 13] could not open port /dev/ttyACM0: [Errno 13] Permission denied: /dev/ttyACM0)查了一下这个是权限问题。解决办法stat-c%G/dev/ttyACM0如果输出uucp把当前用户加入 uucpsudousermod-aGuucp$USER然后注销当前桌面会话并重新登录或者直接重启。这次在重新烧录就成功了。idf.py flash看日志idf.py monitorVSCode 运行hello world安装vscodesudopacman-Scode安装插件ESP-IDFclangd成功运行啦这里要注意的是插件底部的工具条中设备的配置要设置正确。烧录时弹出的选项选第2个就可以成功。第1个会有报错不清楚为什么。总结用linux做ESP32的开发感觉也不错啊而且我感觉好像比在windows上更容易。参考文档《在 Linux 上安装 ESP-IDF 及工具链》https://docs.espressif.com/projects/esp-idf/zh_CN/stable/esp32/get-started/linux-setup.html《Prerequisites》https://docs.espressif.com/projects/idf-im-ui/en/latest/prerequisites.html#linux
返回列表