If you have read the previous article – Why switch to ARM ? Introduction to ARM Micro Controllers – you must have had a basic idea on what makes ARM7-009 superior to other more commonly found 8-bit architectures. You must also have noticed the complexity of the ARM architecture. The flexible and modular design makes ARM affordable and fast – but at the same time very complex to understand for beginners. It may take weeks to just get the tool-chain up and running without the right tools to get started.
First, we go through some pre-requisite concepts of compiling programs for ARM microcontrollers in particular and all microcontrollers in general. If you have compiled programs from the command line before, you probably already know this.
In computer terminology, a native compiler is a compiler that compiles source code for the same architecture on which it is running. For example, the GCC that you use to compile C programs to run on your personal computer is a native compiler and produces executables for the same architecture. For example, a native compiler will produce output binary files that will run on x86 if the compiler was running on an x86 platform.
When output binary files are supposed to run on a system that does not have the same architecture as the host running the compiler, the code is said to be cross-compiled. The device you are programming will be called the “target platform”. The system running the compiling tool is called the “host platform”. Cross compilers are sometimes difficult to set up because the compiler has no information on the active configuration of the target platform and needs to know certain parameters before it is able to compile code for the target.
A similar nomenclature is often followed for assemblers: native- and cross-assembler.
The variables or the arguments that a typical cross compiler takes are related to what compilation rules you want to impose on the output binary file or executable. These variables or arguments include, but are not limited to architecture type of the target system, memory information of the target system, clock frequency, output file format, and code optimization preferences.
Linking and Further Steps
Compiling programs for a microcontroller goes way beyond just running the compiler. Luckily, most of this is automated and you do not need to dive into the finer aspects for compiling basic applications. However it is mentioned for the sake of completeness – the compilers convert programs to assembly files that are in turn converted to object files. These are then combined by a linker script in a way that suits the target platform. Later articles will cover this in detail when you have compiled some basic programs and are comfortable with compilers.
If all this seems confusing at this point, you may simply follow steps for compiling programs for the LPC214x. Things will be clearer as you progress further.
Setting up the Development Environment
This tutorial will take you through the process of setting up Keil uVision5 and MDK ARM toolchain. It is available for trial only and has code size limitations on the trial version. However, it is the best option for beginners as the toolchain is easy to setup and customize. A GNU toolchain will be free and without limits but it is a tedious task just to install the toolchain. It will be covered in detail in upcoming tutorials once you get used to cross compiling.