Skip to content

A multi-target template project for CLion using Embedded GDB with (ST-Link or J-Link)

Notifications You must be signed in to change notification settings

dananjayavr/CLion-CMake-Embedded-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic multi-arch (ARMv7M / x86) project template

  • Project is tested with a NUCLEO-F401RE board

  • Create a project as usual (C executable)

  • Select the Run | New Embedded Configuration action in the main menu.

    • Choose J-Link (or any other debugger I guess)
      • For J-Link: choose the J-Link path (ex. C:\Program Files\SEGGER\JLink_V796f)
      • For ST-Link: choose where STM32CubeIDE is installed
    • Choose target and leave everything to its default settings
    • Update the Configuration name if necessary (instead of unnamed)
  • Copy gcc-arm-none-eabi.cmake file from a CMake reference project from CubeMX

  • In Settings -> Build,Execution,Deployment -> CMake :

    • add the toolchain file from the previous step: -DCMAKE_TOOLCHAIN_FILE=gcc-arm-none-eabi.cmake
    • Also add -DTARGET:BOOL=ON. This is so I can selectively add sources from my CMakeLists.txt
    • I also renamed the 'Profile' to a more intuitive name (ex. TARGET) instead of Debug
  • At this point, I was able to compile the project (main.c untouched from the default generated one), once I included all the dependencies (linker file, startup.s, etc.)

  • Now you should be able to debug the main.c file

  • To add x86 support, I created a new 'Profile' called SIMULATOR

  • Naturally, not toolchain file has to be provided. Instead, add -DSIMULATOR:BOOL=ON. This is so I can selectively add source files from my CMakeLists.txt

  • To be able to run this, go to Run/Debug Configurations and add a default CMake Application (above the Embedded GDB Server)

    • It might create two targets (both unnamed I think), delete one and leave the options default
  • You should be able to compile and run (Make sure to choose the 'SIMULATOR' profile)

Docker stuff

  • I created a simple Dockerfile.
  • In Windows, make sure to start Docker Desktop
  • Then, I ran docker build -t clion/alpine:latest -f Dockerfile . to build the Docker image.
  • Create a new CMake profile called DOCKER
  • Within it, use the toolchain as Docker, and in the next window choose the image that we just built.
  • Now I should be able to build the executable in "Linux" using Docker.

Sources

About

A multi-target template project for CLion using Embedded GDB with (ST-Link or J-Link)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages