Simple template for a TM4C project compiled with CMake. The goal is to use this with VSCode and the Cortex-Debug extension to avoid Keil. This should also work with CLion.
sudo apt install gcc-arm-none-eabi gdb-multiarch binutils-multiarch cmake
sudo apt install openocd
sudo apt install lm4flash
lm4flash is optional -- the flash script is configured to flash with OpenOCD for Windows compatibility.
Install the following dependencies:
- CMake
- Make sure to select add to path in the installer (either user or system path will work)
- Ninja (or make)
- Download latest ninja-win.zip from the official Github
- Copy
ninja.exetoC:\Program Files\CMake\bin\(Or elsewhere in your path)
- GNU Arm Embedded Toolchain (get latest
gcc-arm-none-eabi-*-win32.exe)- Make sure to select "Add path to environment variable" at the last step
- OpenOCD
- Download Windows release from Github.
- v0.11.0 and v0.12.0 worked for me. Earlier versions did not work, future versions probably should work.
- Extract the contents of
openocd-v0.12.0-i686-w64-mingw32.tar.gztoC:\openocd-v0.12.0(7-Zip can be used to extract .tar.gz archives on Windows) - Add
C:\openocd-v0.12.0\binto your path.
- Download Windows release from Github.
- Visual Studio Code
Install vscode from Microsoft
Install these extensions:
- C/C++
- CMake
- CMake Tools
- Cortex-Debug
When you first open this project in VSCode, you will need to set the "CMake Kit" to TM4C Toolchain
to select the installed arm-gcc compiler and set the CMake Generator to Ninja. You will also need
to set the build variant (Debug) and build target (Test.elf). Once this has been done, you
should be able run CMake: Configure and CMake: Build (ctrl-shift-P to open command palette).
The shortcut ctrl-shift-B can be used to run the default build task (set in .vscode/tasks.json).
This project will work without VSCode if you want to use another text editor. To compile and flash from the command line:
mkdir build
cd build
cmake ..
make Test.elf
make flash
Or on Windows:
mkdir build
cd build
cmake -G "Ninja" ..
ninja Test.elf
ninja flash
- Setup for EE445L labs on Linux by Josh Minor
- From Zero to main() series on Interrupt
- Visual Studio Code for C/C++ with ARM Cortex-M by Erich Styger, parts 1 and 2
- cubemx.cmake
- How to cross-compile for embedded with CMake like a champ
- Getting Started with the TI Stellaris LaunchPad on Linux
- cortex-debug for VSCode