Coder Social home page Coder Social logo

embedded-cross-framework's Introduction

Embedded Cross-Compilation Template

This is a generic, cross-platform template to use for embedded systems development.

CMake Configuration

Toolchain Files

The toolchain files allow cmake to find the cross-compilation toolchains for specific architectures. To this end, the relevant toochain is added to the corresponding CMAKE_TOOLCHAIN_FILE section in CMakePresets.json, e.g.:

"CMAKE_TOOLCHAIN_FILE": {
    "type": "FILEPATH",
    "value": "toolchain-arm-none-eabi-gcc.cmake"
}

The following variables are defined in all toolchain files:

  • TARGET_TRIPLET: The triplet describing the CPU, Operating System, and ABI of the target system.
  • TOOLCHAIN_COMPILER: The full path to the cross-compiler.
  • TOOLCHAIN_PREFIX: The prefixed directory where to find the bin, include, lib, and other directories relevant for compiling to the target system.
  • CMAKE_C_COMPILER: The C compiler to use for cross compiling to the target.
  • CMAKE_CXX_COMPILER: The C++ compiler to use for cross compiling to the target.
  • CMAKE_ASM_COMPILER: The assembler to use for the target CPU.
  • CMAKE_OBJCOPY: The object copy tool to use for the target.
  • CMAKE_OBJDUMP: The object dump tool to use for the target.
  • CMAKE_RANLIB: The randomising tool for static libraries.
  • CMAKE_READELF: The readelf tool for target object files.
  • CMAKE_SIZE_UTIL: The object copy tool to use for the target.
  • CMAKE_STRIP: The strip tool to use for target objects.

toolchain-arm-none-eabi-gcc.cmake

This file defines the gcc cross-compilation toolchain for cross-compiling to ARM embedded platforms.

In addition to the common toolchain variables, this file defines the following variables:

  • ARM_EABI_BINUTILS_PATH: The path to the binutils for this toolchain.
  • ARM_EABI_TOOLCHAIN_DIR: The path to the binaries for this toolchain.

Examples

Here is an example invocation using the arm-none-eabi-gcc toolchain:

Pre-requisites:

  • Ensure that you have the arm-none-eabi-gcc toolchain
  • Ensure that you have cmake installed

These can be installed on Ubuntu with:

sudo apt install gcc-arm-none-eabi cmake

Build:

cmake --preset arm-none-eabi-gcc-debug -DPROJECTS=EmptyTemplate -DBOARDS=nucleo_f207zg
cmake --build --preset arm-none-eabi-gcc-debug

Replace EmptyTemplate with your project (in one of the projects subdirectories such as bare_metal, or use an absolute path). Ensure that your project folder contains a project.cmake file with the source files and include directories defined. Replace nucleo_f207zg with your board (in one of the boards subdirectories such as STM).

NOTE: Ensure that this is invoked from the root directory of this repository, not inside the project directory.

embedded-cross-framework's People

Contributors

callummccoll avatar gervasetuxworth avatar lewiskrygger avatar morgan2010 avatar rhx avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

embedded-cross-framework's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.