Makefiles – part 1

Published on Author padminLeave a comment

This month I managed to successfully build MCU code for the first time using GCC! For a long time I had relied on the build systems of the online mbed compiler and evaluation software (LPCXpresso) to translate my C++ files into binary files, but with GCC there is greater flexibility in both how code is written, and which hardware it runs on.

At the core of any GCC project is the Makefile, which is a recipe for combining code in your C++ files with code that is MCU specific, and producing a single binary file. For ARM Cortex M devices – the type I’ve been working with for 2 years – the MCU specific code includes ‘system’ and ‘startup’ files. These tell the MCU what to do when it first powers up, ensuring that everything is initialised when your code starts executing in main().

‘System’ and ‘startup’ files are typically silicon specific, so changing to a different MCU will most likely involve using different versions of these files. On the other hand, ‘core’ and ‘arm’ files describe the features and capabilities of ARM hardware, and thus are applicable to numerous MCUs. This type of code forms what is known as the ‘peripheral access layer’.

Categories GCC

Leave a Reply