Skip to content

Low level programming

Kajetan Jonak edited this page Jul 23, 2023 · 6 revisions

Introduction

This manual is intended to provide reader with the essential knowledge needed to work with embeded systems. If you feel that something needs to be added or explained better please don't hesitate to create pull request with changes.

Table of Contents

  1. Requirements
  2. CMake basics

Requirements

To follow further instructions you will need to download and set up software packages listed below.

CMake

CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice. In other worlds - it allows to generate projects for IDEs of your choice.

Installation

Windows

Download CMake Windows x64 installer from official webpage. Run the installer. Please make sure that during the installation process the 'Add CMake to path variable' box is checked.

Other OS

It is very easy to find suitable tutorial :)

Verify

To check if installation was done properly type 'cmake' in terminal. You should see similar output.

If that is not the case please make sure that CMake binary directory is added to path.

Project generator

CMake is supporting various generators. Generator is responsible for writing the input files for a native build system. Please see supported build systems here. Feel free to use whatever generator you want. For this tutorial I will use Ninja. Lot of people are using Make though.

Ninja installation

  • Download Ninja binary.
  • Add directory with Ninja executable to path. In console type 'ninja'. If done correctly you should see some meaningful output.

Compiler

Compiler is a program that translates code written in one programming language into language that computer can execute. Depending on target system architecture you will need to use different compilers. Despite selecting suitable compiler for target architecture you can choose between different versions.

ARM embeded C/C++ compiler

This compiler is used to compile code for ARM Cortex-M devices (especially microcontrolers from STM32 series, however there is a lot of Cortex-M devices). The installer can be downloaded from this website. There is no need to add binary directory to path during installation. To verify installation perform following steps:

  • Open console and navigate to installation directory. Default for latest version is: 'C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10'
  • Go to 'bin' directory
  • Type in console: 'arm-none-eabi-c++.exe'. If output is something like 'no input files' you are good to go.
  • Check GDB is working. Type ' arm-none-eabi-gdb.exe'. GDB console should launch. If this is not the case read console output and try to install missing packages.

C/C++ compiler for Windows

In order to learn basics of CMake the MSVC compiler will be used. You can install it by installing Visual Studio and selecting C/C++ extension. To check if it work open developer powershell and type: 'cl'. You should see some meaningfull output.

CMake basics

Please find sample project attached.

CMakeBasic.zip

The most important thing is to know the following:

  • how to set and read a cmake variable
  • how to add source file to project
  • how to include external library