3 years ago

Embedded System Build Process Chapter 1

This write up aims to briefly discuss the build process or the steps involved in the generation of a binary image specifically for an embedded system.

Embedded System, unlike a conventional PC is very restricted in terms of both storage and processing capabilities. Keeping this in mind, the final image that sits in the system flash should be in line to the memory architecture of the system.

Thus, the build system is slightly different and more complicated when it comes to binary generation for a specific embedded device.

Concepts covered in this write-up

  1. Compiling and Assembling.
  2. Linking.
  3. Relocation.
  4. Basics of bootloader and system start-up.

As mentioned in my previous articles on memory concepts in embedded system; (please give it a read if not already done 🙂 ) there are a few stages to undergo before an image can be generated.

Overview

Let us call it the 3 stage process

  1. Compiling/ assembling the source code in object files.
  2. Converting/ Merging all the object files into one object file ; commonly known as linking.
  3. Relocation/ Address Mapping.

These 3 stages will each be discussed in the course of this write up.

Compiling and Assembling

The process of converting the source code (codes) into an object file is termed as compiling. Similarly if the input is in processor specific assembly instructions; then converting that into an object file is termed as assembling. Both the processes are the same in terms of what they produce as outputs ultimately.

Let’s ponder over a few questions…

Why compiling? What other purpose do they serve? What are the compilers used for embedded systems? Are they all the same?

Let’s Find out…

 Why Compiling?

In simple terms (not that you don’t know already 😉 ), the compiler converts the human readable code into a format that the machine can process; called the object code.

A compiler is a program that does this job for you. Having said this, there are many compilers out there and we will discuss some of the most common ones in the remaining course of this write-up.

What Other purpose do they serve?

Apart from doing the above mentioned task, the following responsibilities are undertaken

  1. Compilers check the syntactical correctness of the code. (Not the logic of the code)
  2. The settings of the compiler can be tweaked to increase the strictness of the compilation process e.g. Warnings can be treated as errors. ( For the sake of focus, we will not deep dive into this )
  3. Regroup data into text, data, .bss sections.

For an embedded system specifically, we use a cross compiler; a compiler that is used for a remote target executable generation.

What are the compilers used for Embedded Systems?

Most often the open source GCC compiler is used for cross compilation with appropriate target information already available as part of the compiler program.

The STM32 Microcontrollers using the ARM chip uses the GNU GCC compilers and assemblers to build its binaries as shown in the image below.

Please Note: this is entirely dependent on the capability of the compiler and linker to generate board specific binaries.

There are company specific compiler vendors for their boards ex

Keil, Vector, Code Composer etc.

A good article on how to choose compilers is in the below mentioned article

https://barrgroup.com/embedded-systems/how-to/c-cross-compilers

Are they all the same?

No, they are not one – to – one the same; they have some differences on how they execute group and run the code it receives. The ultimate outcome is same!

For the sake of keeping this article short; I intend on having a follow up post on the remaining concepts mentioned above.

Please read the continuation in the link below

As always thanks for reading!

Written by BootUP

A Technology enthusiast eager to learn and teach!

Categories Technical Content UncategorizedTags