The GNU Arm Embedded Toolchain is an open-source collection of tools for programming in C, C++, and assembly. The 32-bit Arm Cortex-A, Arm Cortex-M, and Arm Cortex-R processor families are targeted by the GNU Arm Embedded Toolchain. The GNU Arm Embedded Toolchain, which includes the GNU Compiler (GCC), is offered from Arm for free for embedded software development on Windows, Linux, and Mac OS X.
Partners, developers, and the community can use new features from current Arm Architecture and open-source projects GCC, Binutils, glibc, Newlib, and GDB thanks to the GNU Toolchain for Arm Architecture releases (referred to as “Arm GNU Toolchain”).
- Contains integrated and validated packages.
- Supports c and c++ packages.
- Supports CPUs based on the A,R and M profiles of the arm architecture
- Provides cross toolchains for Microsoft Windows(x86),Linux(x86_64 and AArch64),and macOS(x86_64)host operating systems.
- Provides different variants of the toolchain which can be used for bare-metal embedded development and for Linux kernel and application development.
- Released twice a year.
- Free to download and use.
Go ahead and download the GNU ARM toolchain to your computer from this link and explore the contents inside.
Once extracted the archive was presented with a folder and inside the folder, as shown in the screenshot below.
The directory of interest for us is the “bin” directory. Let’s go ahead and open a terminal and navigate into that folder!
Tools to Produce The Binaries
As you can see there are several executables inside that folder. The 4 main files that we need here are
- arm-none-eabi-ld and
GNU Compiler Collection is an acronym for GNU Compiler Collection. This is the overall toolchain’s master driver! This tool doesn’t only compile the code; once it’s done, it runs the linker, which combines multiple object files into a single large file, locates it using the right addresses, and produces the final executable.
Hence gcc can be thought of as a driver program for the entire toolchain as it takes care of the entire process and transforms all the source files of a given project into one final executable!
But we can make it stop at any point of the entire process using appropriate options as shown below
“as” stands for assembler, it does the translation from assembly language mnemonics into opcodes.
“ld” is the GNU’s Linker and Locator combined into one!
There are several formats an object file can be produced in. Popular formats include Extended Linker Format (.elf format) and Common Object File Format (.coff). But these formats are usually for running binaries on PCs and they contain some extra information about the binary.
For microcontrollers, the binaries are usually tightly packed without any extra metadata. objcopy is the tool responsible for taking the elf or coff binaries and packing them in a way that can be flashed onto the microcontroller!
Tools to Help Debug Code
Now that we have seen an introduction of all the tools needed to produce the binaries, let’s next look at the tools needed to program and debug the code!
OpenOCD to flash the code
Other than the GNU toolchain for ARM, you need one more piece to complete the puzzle. You need a tool to download the binary onto your microcontroller by talking to the debug controller peripheral by relaying the data through the USB debug adapter. That’s where OpenOCD comes into the picture.
Other than downloading the code OpenOCD also helps in debugging by acting as a middle-man between GDB and JTAG/SWD.
GDB stands for GNU DeBugger is the debug server we need to handle our debug sessions. GDB helps translate the programmer intentions like
- step through code,
- set breakpoints,
- read variable value,
- read memory content,
- view stack trace, etc