IAR + Clion = friendship


Good health to all!


The quarantine forced me to spend all my time at home, including free time, and although there are a lot of things to do at home, I skillfully shoved them to my son, and I decided to finally study the ClB development environment from JetBrains, especially since the 2020.1 release Support for the IAR toolchain appeared.


Everyone who is interested in a step-by-step guide and a bunch of pictures with a welk ...


Introduction


, 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 .



But there is still a bunch of all sorts of other goodies that I won’t talk about, they are described on the JetBrains website. Just the final GIF showing the speed of work:



All Articles