SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: What is ARM GCC toolchain?
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

What is ARM GCC toolchain?

Holly Lindsey
Last updated: September 12, 2023 7:58 am
Holly Lindsey 7 Min Read
Share
SHARE

The ARM GCC toolchain refers to the compiler tools used to build applications for ARM-based devices. It consists of the GNU Compiler Collection (GCC) and other utilities like binutils targeted to the ARM architecture.

Contents
Overview of ARM GCC ToolchainGCC CompilerBinutilsGNU DebuggerNewlib C LibraryGNU C LibraryInstalling the ARM GCC ToolchainUsing the ARM GCC ToolchainAdvantages of using ARM GCCConclusion

The key components of the ARM GCC toolchain are:

  • GCC – The GNU Compiler Collection containing the ARM cross-compilers for C and C++.
  • Binutils – Binary utilities like assembler, linker, archive manager for ARM.
  • GDB – The GNU Debugger for debugging ARM applications.
  • Newlib – C standard library implementation for embedded systems.
  • Glibc – The GNU C library (optional).

Overview of ARM GCC Toolchain

The ARM GCC toolchain allows developers to compile, assemble, link and debug applications for ARM devices like microcontrollers, SoCs, embedded systems etc. It contains the cross-compiler and other utilities customized for the ARM instruction set architectures like ARMv6, ARMv7, ARMv8 etc.

Here’s a brief overview of the key components in the ARM GCC toolchain:

GCC Compiler

GCC is a widely used compiler system for C, C++, Objective-C, Fortran, Ada and other languages. The ARM GCC toolchain provides the cross-compiler versions of GCC that can generate code for ARM devices.

For example, arm-none-eabi-gcc can compile C/C++ code for bare-metal ARM systems. The GCC compiler handles all the stages of compilation – preprocessing, compilation, assembly and linking.

Binutils

Binutils provides the assembler (arm-none-eabi-as), linker (arm-none-eabi-ld), archive manager (arm-none-eabi-ar) and other utilities for handling object files targeted to the ARM architecture. The binutils are used by the compiler to assemble, link and generate the final executable.

GNU Debugger

GDB or the GNU debugger allows debugging ARM applications. It can set breakpoints, inspect variables, view assembly instructions, and perform all the other functions of a debugger. The ARM GDB provides runtime debugging for code compiled with the ARM GCC toolchain.

Newlib C Library

Newlib is a C standard library implementation designed for embedded systems. It provides all the standard C functions and minimal runtime support. Newlib is used in place of glibc for ARM bare-metal applications.

GNU C Library

The GNU C library (glibc) implements the C standard library functions for systems using the Linux kernel. It provides interfaces to the OS kernel and is mainly used in ARM Linux systems.

Installing the ARM GCC Toolchain

Here are some ways to install the ARM GCC toolchain:

  • Download the pre-built toolchain binaries for your platform from ARM’s website or other 3rd party providers.
  • Install using the package manager on Linux (apt, yum, brew etc).
  • Build from source by downloading the GCC and binutils source code and cross-compiling them for ARM.

The pre-built binaries are the easiest method. For example, on Ubuntu Linux you can install the ARM toolchain using: sudo apt install gcc-arm-none-eabi

This will install the arm-none-eabi cross-compiler and other tools like gdb, openocd etc. The source code method takes longer but allows customizing the toolchain options.

Using the ARM GCC Toolchain

To compile a simple C program for ARM using arm-none-eabi-gcc: arm-none-eabi-gcc -mcpu=cortex-m3 hello.c -o hello.elf

This will compile the hello.c source file and generate the executable hello.elf targeting the Cortex-M3 processor.

To assemble an ARM assembly source file: arm-none-eabi-as main.s -o main.o

This will assemble main.s into the object file main.o.

To link the object files into an executable: arm-none-eabi-ld main.o hello.o -T linker.ld -o output.elf

This will link main.o and hello.o into output.elf using the linker script linker.ld.

The ARM GCC toolchain provides many options to customize the compilation process. The commonly used options include:

  • -mcpu – Specify target ARM processor
  • -march – Specify target architecture
  • -mfloat-abi – Floating point ABI
  • -mfpu – Floating point hardware option
  • -mthumb – Generate thumb instructions
  • -mthumb-interwork – Support ARM/Thumb interworking
  • -ffunction-sections – Place each function in separate section
  • -fdata-sections – Place each data item in separate section

There are many more options to control code generation, optimization, preprocessor handling etc. GDB can debug the compiled program and OpenOCD can flash it onto the device.

Advantages of using ARM GCC

Here are some of the benefits of using the ARM GCC toolchain for embedded development:

  • GCC produces efficient ARM code that is optimized for performance and size.
  • Supports latest ARM architectures including Armv8-A, Armv8-M, Armv7-M etc.
  • Actively maintained and updated to support new Instructions and CPUs.
  • Integrates well with IDEs like Eclipse, Visual Studio Code etc.
  • Interoperable object file format (ELF/DWARF) usable across tools.
  • Free to use and available under GPL open source license.
  • Works across platforms like Windows, Linux and Mac OS.
  • Huge user community provides support and documentation.

Additionally, the ARM GCC toolchain is the foundation for the Arm Embedded and Keil toolchains that add IDEs, debuggers, simulators and other high-level tools.

Conclusion

The ARM GCC toolchain comprising of GCC, binutils and GDB allows compiling, debugging and tracing applications for ARM devices. It supports bare-metal ARM programming with newlib, as well as Arm Linux programming with glibc. The toolchain is free, updated regularly and works across multiple platforms.

Using the ARM GCC toolchain along with IDEs like Eclipse simplifies embedded software development. A vibrant open source ecosystem provides support libraries, RTOSes, drivers and tons of example code. The ARM GCC toolchain is a versatile set of tools for building ARM applications.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article How many GPIO registers are in ARM processor?
Next Article What is the gate count of cortex M?
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

What is watchdog in PLC?

A watchdog timer (sometimes called a watchdog or just watchdog)…

9 Min Read

When to Use Hardware vs Software Floating Point with Arm Cortex M?

When deciding whether to use hardware or software floating point…

10 Min Read

Arm Cortex Comparison

The ARM Cortex series of processors are widely used in…

7 Min Read

Cortex M0: How to Make the Default crt0.o Startup for GCC

The Cortex-M0 is one of ARM's most basic and widespread…

8 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account