Skip to content

witek117/cmakesForSTM

Repository files navigation

CMake template project for STM32, with GoogleTests and STM32CubeMX

How to use

Requirements in PATH

Run

STM32CubeMX

  • create standard project in STM32CubeMX
  • in Project Manager Project:
    • Application Structure: Basic
    • Toolchain / IDE: Makefile
  • in Project Manager Code Generator:
    • Copy only the necessary library files
  • copy generated files to target/arm directory

1. Command line

  • create cmake_build_debug directory and go
  • run cmake -DTARGET=arm -G "MinGW Makefiles" ..
    • -DTARGET=arm(for STM project)/x86(for GoogleTests)
    • -DCMAKE_BUILD_TYPE=debug/release
    • -G "MinGW Makefiles" for windows

2. CLion

  • download and install CLion
  • File -> Open
  • find first CMakeLists.txt file in project directory
  • Open as Project
  • File -> Settings -> Build, Execution, Deployment -> CMake -> Build type
    • Release (recomended)
    • Debug
  • in Windows add -G "MinGW Makefiles"

3. VS Code

SWO debug

In C or C++ code write:

int _write(int file, char *ptr, int len) {
    (void) file;
    int DataIdx;
    for (DataIdx = 0; DataIdx < len; DataIdx++){
        ITM_SendChar(*ptr++);
    }
    return len;
}

And use printf:

printf("Hello world\n");

Using openOCD:

openocd -f board/stm32f4discovery.cfg -f interface/stlink.cfg -c "transport select hla_swd"  -c "tpiu config internal - uart off clock_rate" -c "itm ports on" -c "tcl_port 6666"

Where clock_rate should be changed with number, ex. 180000000 for 180 MHz

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published