From 48c2757af61e2d1d4d63d56bee4cdc7b5c628601 Mon Sep 17 00:00:00 2001 From: Misaki Date: Fri, 22 Aug 2025 23:25:43 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AE=9E=E7=8E=B0=E4=BA=86=E5=9C=A8Linux?= =?UTF-8?q?=E4=B8=8B=E7=9A=84esp=20idf=E7=9A=84=E4=B8=80=E9=94=AE=E7=BC=96?= =?UTF-8?q?=E8=AF=91=EF=BC=8C=E7=83=A7=E5=BD=95=EF=BC=8C=E4=B8=8E=E7=9B=91?= =?UTF-8?q?=E8=A7=86=E7=9A=84=E8=84=9A=E6=9C=AC=EF=BC=8C=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E7=9B=91=E8=A7=86=E5=85=B7=E6=9C=89=E4=BA=A4=E4=BA=92=E8=83=BD?= =?UTF-8?q?=E5=8A=9B(=E4=BE=9D=E8=B5=96=E4=BA=8Eide=E7=9A=84cmake=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E8=B0=83=E7=94=A8=EF=BC=8C=E9=9C=80=E8=A6=81=E9=85=8D?= =?UTF-8?q?=E5=90=88ide=E4=BD=BF=E7=94=A8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- CMakeLists.txt | 12 ++++++++++++ build_flash_monitor.sh | 18 ++++++++++++++++++ main/Bionic_sphere.c | 5 ++++- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 build_flash_monitor.sh diff --git a/.gitignore b/.gitignore index 714327f..13f15f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -./cmake-build-debug +cmake-build-debug +build .idea diff --git a/CMakeLists.txt b/CMakeLists.txt index 89e06bf..951a419 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,5 +4,17 @@ # CMakeLists in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) +# 注意!如果你使用了下面的编译烧录监视方式,那么Clion对于你来说就只是个代码编辑器,几乎不承担编译功能 +# 如果你把脚本放项目根,可直接用 ${CMAKE_SOURCE_DIR}/build_flash_monitor.sh +add_custom_target(flash_monitor_gui + COMMAND ${CMAKE_COMMAND} -E env + "IDF_PATH=$ENV{IDF_PATH}" # 保证 idf.py 能找到 + ${CMAKE_SOURCE_DIR}/build_flash_monitor.sh + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + USES_TERMINAL # 让 ninja 把 stdout 实时转发到 CLion Build 窗口 + COMMENT "Build + Flash in CLion, then launch Konsole with idf.py monitor" +) + + include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(Bionic_sphere) diff --git a/build_flash_monitor.sh b/build_flash_monitor.sh new file mode 100755 index 0000000..af228b8 --- /dev/null +++ b/build_flash_monitor.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env zsh +### 本脚本实现了Linux下的esp idf的一键编译,烧录,与监视,并且监视具有交互能力 +### Code by Misaki ---- 2025.8.22 + +# 如果 idf.py 不在 PATH,请 source export.sh 或手动 export IDF_PATH/PATH +# source $HOME/Apps/esp/esp-idf/export.sh + +set -e # 任何一步失败就退出 +PORT=${1:-/dev/ttyACM0} # 允许外部传参,默认 /dev/ttyACM0 + +# 1) 实时 build + flash +export PYTHONUNBUFFERED=1 +idf.py -p "$PORT" build flash + +# 2) 在外部 Konsole 打开 monitor (注意,这个地方要根据自己系统使用的终端来修改,我使用的是konsole + zsh +# --new-tab 在当前窗口新建标签页 +# --hold monitor 退出后不自动关窗口 +konsole --new-tab --hold -e zsh -c "idf.py -p $PORT monitor" \ No newline at end of file diff --git a/main/Bionic_sphere.c b/main/Bionic_sphere.c index 7b66f33..3f73ee3 100644 --- a/main/Bionic_sphere.c +++ b/main/Bionic_sphere.c @@ -1,6 +1,9 @@ #include + +#include + void app_main(void) { - + ESP_LOGI("main", "Now is Misaki"); }