IAR + Clion = persahabatan


Kesehatan yang baik untuk semua!


Karantina memaksaku untuk menghabiskan seluruh waktuku di rumah, termasuk waktu senggang, dan meskipun ada banyak hal yang harus dilakukan di rumah, aku dengan terampil mendorong mereka ke putraku, dan aku akhirnya memutuskan untuk mempelajari lingkungan pengembangan ClB dari JetBrains, terutama sejak rilis 2020.1 Dukungan untuk rantai alat IAR muncul.


Semua orang yang tertarik dengan panduan langkah demi langkah dan banyak foto dengan ...


pengantar


, 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



, , , Create. CMAKE.


++17 C++ Executable. .



Embedded->STM32CubeMX, .ioc, STM32CubeIDE. Clion .ioc , Clion.


, IAR Cub. , , main.cpp.



, Clion CMAKE, CMakeList.txt, , , , .


:



CMAKE +
+
++, +
— main.cpp


, toolchain


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:



, .


MinGW , :



, Continue, . GNU C++ Compiler ( , , , - ) . — ApplyChanges.



. MinGW toolchain . .



, Clion , , , IAR toolchain.


, Clion — File->Settings->Build, Execution, Deployment -> Toolchain .



toolchain MinGW, Visual Studio, . Clion , make , .
, :)



. ++ IAR , .


(Bundled) Clion, GNU ARM ( https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)


Clion:



toolchain IAR, MinGW.



make MinGW, , , , clearmake, ClearCase ( , — )


make - , ninja, .


CMAKE


, CMAKE, , , Release Debug. .


File->Settings->Build, Executiion, Deployment -> CMake



"+"



Debug. CMake, , make (Build Options). , -j 16( ), 16 . , , - ( ) , VPN, .


Debug Release Build Type.


Release.


Apply Clion CMAKE, , :



, , , __write(), main.cpp.



. CMake.


IAR CMake, .


### BEGIN CMAKE_TOOLCHAIN_FILE
# "Generic" is used when cross compiling
set(CMAKE_SYSTEM_NAME Generic)

# Set the EW installation root directory
set(EW_ROOT_DIR "C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.3/arm")

# set common compiler flags for all build types
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 up the CMake asm compilers
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 output file extentation to .elf
set(CMAKE_EXECUTABLE_SUFFIX ".elf")

# Set up the linker configuration script
set(LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/stm32f411xE.icf")

#Set IAR setting for bedug build
if (CMAKE_BUILD_TYPE  MATCHES Debug)
message ("IAR Debug")
# set a preprocessor symbol "DEBUG"
add_compile_definitions( DEBUG=1 )
# set up the CMake variables for the compiler for DEBUG
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 up the CMake variables for the compiler for 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()
### END CMAKE_TOOLCHAIN_FILE

, Debug Release.
*.elf set(CMAKE_EXECUTABLE_SUFFIX ".elf")


CMakelist.txt:


cmake_minimum_required(VERSION 3.16)
project(MyFirstProject)

# enable C and assembler source
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



, . — .



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




, , .


:


  • 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"_ —



. .



:


  • Run -> Edit Configurations
  • "+"


Template. -



, , .



Advanced GDB Server options . — monitor arm semihosting enable. Download executable: Always .


Debug: Console. , .



, .svd .




, startup.cpp, , , fpu main().


startup.cpp .



: IAR
Clion File->Open .


:


, , Clang IAR, , , File->Settings -> Languages&Frameworks -> C/C++ -> Clangd.


Enable clangd server.




, IAR IDE Clion . IAR, . , , .


Clion , . , Clion , . , .


Clion , . , Clion .



Tetapi masih ada banyak jenis barang lain yang tidak akan saya bicarakan, mereka dijelaskan di situs web JetBrains. Hanya GIF terakhir yang menunjukkan kecepatan kerja:



All Articles