![](https://habrastorage.org/webt/4i/4a/vy/4i4avyzdzklitg6j03heow-uwi4.png)
صحة جيدة للجميع!
أجبرني الحجر الصحي على قضاء كل وقتي في المنزل ، بما في ذلك وقت الفراغ ، وعلى الرغم من أن هناك الكثير من الأشياء للقيام بها في المنزل ، إلا أنني دفعتها بمهارة إلى ابني ، وقررت أخيرًا دراسة بيئة تطوير ClB من JetBrains ، خاصة منذ إصدار 2020.1 ظهر دعم سلسلة أدوات IAR.
كل من يهتم بدليل خطوة بخطوة ومجموعة من الصور مع لمحة ...
المقدمة
, C++ IAR Workbench . , ++, , , .
IAR, - , , , , , .
( assert IAR ) , Clang, .
IAR — . , , , — "Powered by notepad".
- , , , ( ).
Clion JetBrains.
Clion /++. , . , , IAR . , .
, 2020.1 IAR . Elmot, 2020.1 IAR .
ST Cube, IAR. , Cube, IAR Clion .
Clion CMAKE, CMAKE. , . , , Clion , c cpp (CMAKELIST) .
, , . File->NewProject
![](https://habrastorage.org/webt/8e/ea/z5/8eeaz5-vy-ujk3ywoytzokvyvz0.png)
, , , Create
. CMAKE.
++17 C++ Executable. .
![](https://habrastorage.org/webt/qx/us/qe/qxusqelzd0mqsbekpdz4i_jneso.png)
Embedded->STM32CubeMX
, .ioc, STM32CubeIDE. Clion .ioc , Clion.
, IAR Cub. , , main.cpp
.
![](https://habrastorage.org/webt/2z/ks/_a/2zks_acvn15elvhtd32irfsfxyy.png)
, Clion CMAKE, CMakeList.txt, , , , .
:
![](https://habrastorage.org/webt/fc/n3/ov/fcn3ovhjbawugphvdfuazady_dm.png)
CMAKE +
+
++, +
— main.cpp
, toolchain
Clion toolchain.
Toolchain — . , , , , , .
Clion — MinGW, CygWin, Visual Studio
IAR toolchain, , , MinGW Visual Studio .
toolchain, Clion.
C Visual Studio , Microsoft ++ ( , C#).
MinGW, http://www.mingw.org/.
: installer, Popular
All time
:
![](https://habrastorage.org/webt/wh/0x/ot/wh0xot5mqmpxw2fdwfrdi-t_kwm.png)
, .
MinGW , :
![](https://habrastorage.org/webt/12/al/u7/12alu7pf7rpamhfvwfouyb0cjw4.png)
, Continue, . GNU C++ Compiler ( , , , - ) . — ApplyChanges
.
![](https://habrastorage.org/webt/gw/7w/l7/gw7wl7sxwnsa9rip5xwktegxuj8.png)
. MinGW toolchain . .
, Clion , , , IAR toolchain.
, Clion — File->Settings->Build, Execution, Deployment -> Toolchain
.
![](https://habrastorage.org/webt/j4/2b/96/j42b96bwgylcgen-u0c2i1-yfyu.png)
toolchain MinGW, Visual Studio, . Clion , make , .
, :)
![](https://habrastorage.org/webt/r5/w5/xc/r5w5xcld5r2ekwyjrklc-fjtti4.png)
. ++ IAR , .
(Bundled) Clion, GNU ARM ( https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
Clion:
![](https://habrastorage.org/webt/dw/wo/bx/dwwobxle0v_n1whwezfdvpx_6mi.png)
toolchain IAR, MinGW.
![](https://habrastorage.org/webt/ks/vh/fx/ksvhfxscjf5mvqfjtsss28y3mpa.png)
make MinGW, , , , clearmake, ClearCase ( , — )
make - , ninja, .
CMAKE
, CMAKE, , , Release Debug. .
File->Settings->Build, Executiion, Deployment -> CMake
![](https://habrastorage.org/webt/ci/sq/ug/cisqugefsegper6pbvxu9w3r_ek.png)
"+"
![](https://habrastorage.org/webt/jv/bd/jg/jvbdjgkfwxou3ct_ekjuxx1hsr8.png)
Debug. CMake, , make (Build Options). , -j 16( ), 16 . , , - ( ) , VPN, .
Debug Release Build Type.
Release.
Apply Clion
CMAKE, , :
![](https://habrastorage.org/webt/wx/pp/6e/wxpp6ex0ww_aylw841qbfkx47a4.png)
, , , __write()
, main.cpp.
![](https://habrastorage.org/webt/oq/uq/mo/oquqmotb7dlyp_gx9-n-nxgl1ei.png)
. CMake.
IAR CMake, .
set(CMAKE_SYSTEM_NAME Generic)
set(EW_ROOT_DIR "C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.3/arm")
set(CMAKE_CXX_FLAGS "--no_cse --no_unroll --no_code_motion --no_tbaa --no_clustering --no_scheduling --endian=little --cpu=Cortex-M4 -e --fpu=VFPv4_sp --c++ --no_exceptions --no_rtti")
set(CMAKE_C_FLAGS "--no_cse --no_unroll --no_code_motion --no_tbaa --no_clustering --no_scheduling --endian=little --cpu=Cortex-M4 -e --fpu=VFPv4_sp ")
set(CMAKE_ASM_FLAGS "-s+ -r -t8 --cpu Cortex-M4 --fpu VFPv4_sp ")
set(CMAKE_C_COMPILER "${EW_ROOT_DIR}/bin/iccarm.exe")
set(CMAKE_CXX_COMPILER "${EW_ROOT_DIR}/bin/iccarm.exe" )
set(CMAKE_ASM_COMPILER "${EW_ROOT_DIR}/bin/iasmarm.exe")
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/stm32f411xE.icf")
if (CMAKE_BUILD_TYPE MATCHES Debug)
message ("IAR Debug")
add_compile_definitions( DEBUG=1 )
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --dlib_config=normal --no_inline")
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --dlib_config=normal --no_inline")
set(CMAKE_CXX_LINK_FLAGS "--semihosting --config ${LINKER_SCRIPT}")
else(CMAKE_BUILD_TYPE MATCHES Release)
message ("IAR Release")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --dlib_config=normal")
set (CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --dlib_config=normal")
set(CMAKE_CXX_LINK_FLAGS "--config ${LINKER_SCRIPT}")
endif()
, Debug Release.
*.elf set(CMAKE_EXECUTABLE_SUFFIX ".elf")
CMakelist.txt:
cmake_minimum_required(VERSION 3.16)
project(MyFirstProject)
enable_language(C ASM CXX)
set(CMAKE_CXX_STANDARD 17)
include(iarconfig.cmake)
add_executable(MyFirstProject main.cpp)
Cmakelist.txt toolchanin Cmake . , , Reload Cmake, , Cmake , toolbox Cmake Reset Cache and Reload Project
![](https://habrastorage.org/webt/8o/ie/rt/8oiertwyxgj8yrfhxt6e-bygz7g.png)
, . — .
OpenOCD gdb , Jlink gdb ST-Link gdb .
, 0.10.0: https://sourceforge.net/projects/openocd/files/openocd/0.10.0/ . , Windows: http://www.freddiechopin.info/en/download/category/4-openocd.
, :
, gdb File->Settings->Build,Execution,Deployment->Toolchains->Debugger: Bundled GDB
Run -> Edit Configurations -> Templates
Embedded GDB Server
![](https://habrastorage.org/webt/bi/rx/pv/birxpvcqzjwelpiahchonrssqeo.png)
, , .
:
Download executable
, Update Only
— , - , .
OpenOCD tcp , .. IP 3333 ( , ). OpenOCD , target remote args
tcp:127.0.0.1:3333
GDB Server
OpenOCD, .
GDB Server args
OpenOCD . Nucleo, XNucleo, st_nucelo, (hla_vid_pid — The vendor ID and product ID of the adapter) . OpenOcd :
-f ../scripts/board/st_xnucleo_f4.cfg -c "reset_config none separate" -c "init" -c "reset halt"
-f , st_xnucleo_f4.cfg, , , .
- , .
-c "reset_config none separate" — , SWD ( ).
-c "init" — "init", OpenOCD
-c "reset halt"_ —
. .
![](https://habrastorage.org/webt/rx/ko/0x/rxko0xkcll_j6dlpcmbbxfgl9dk.png)
:
Run -> Edit Configurations
- "+"
![](https://habrastorage.org/webt/c5/jk/vy/c5jkvyaxdin1iszoqpolteht-o4.png)
Template. -
![](https://habrastorage.org/webt/sh/bx/am/shbxamp6ajnkufryk7d3wqyyclg.png)
, , .
![](https://habrastorage.org/webt/ed/en/uj/edenujlawi7wlzopkmfalgm7l-8.gif)
Advanced GDB Server options
. — monitor arm semihosting enable
. Download executable: Always
.
Debug: Console
. , .
, .svd .
, startup.cpp
, , , fpu main()
.
startup.cpp .
![](https://habrastorage.org/webt/hc/ay/mq/hcaymqyrfcpl1gyjaupuvrfi0so.png)
: IAR
Clion File->Open
.
:
, , Clang IAR, , , File->Settings -> Languages&Frameworks -> C/C++ -> Clangd
.
Enable clangd server.
![](https://habrastorage.org/webt/8h/om/gw/8homgww9jeq6wmmipmdqsscaqoi.png)
, IAR IDE Clion . IAR, . , , .
Clion , . , Clion , . , .
Clion , . , Clion .
![](https://habrastorage.org/webt/ay/61/gu/ay61gu5okqlenl1eockc29wjeoy.png)
ولكن لا تزال هناك مجموعة من جميع أنواع الأشياء الجيدة الأخرى التي لن أتحدث عنها ، فهي موصوفة على موقع JetBrains على الويب. فقط صورة GIF النهائية التي توضح سرعة العمل:
![](https://habrastorage.org/webt/oj/so/3q/ojso3qhkczzqqumzj54ib-tv3vw.gif)