Embedded Basics Miscellaneous Tech

Why building the project is required ?

so After, we have developed/configured the code and we have got the .c & .h files in our project. Now microcontrollers can’t understand the text which is written in these files. They only understand the Binary language of 0 & 1. So we have to convert these .c & .h files into a single file of binary language which the microcontroller can understand. Now these .c and .h files can be in 1000 numbers in some projects. So you can think of how much processing is done to analyze all files, check them for any errors and then convert them into a single file of binary language. This work is done by compilers and the build process. This technology is truly amazing, and its process is even more interesting.

What is building the project in embedded and how is it done?

In embedded “building the project” refers to the process of compiling and linking the source code and resources of an embedded software application to create an executable binary file that can be loaded onto the target embedded hardware platform.

In Embedded, Build process is the process of converting multiple source files into a single file that can run on a computer. So as to understand this process and the technology behind it, let’s understand the procedure/step involved in doing so.

It’s important to note that the compilation process can be controlled through various compiler options, allowing you to customize how your code is compiled, optimize it, and handle various aspects of the process.

Building an embedded project is a crucial step in the development process, as it ensures that the software is correctly translated into machine code and can run effectively on the embedded hardware, meeting the project’s functional and performance requirements.

After the building process is done then which file is created.

After the build process is done then these files are created and then deployed onto the target embedded hardware.

  1. Executable Binary (Firmware) : This is the primary output of the build process. It’s a binary file that contains the machine code instructions and data necessary for the embedded system to execute your program. The format of this binary file may depend on the microcontroller or processor used and can include extensions like .bin, .hex, .elf, .s19, etc.
  2. Object Files : During compilation, each source file is typically compiled into an object file (with extensions like .o or .obj). These object files contain machine code generated from the corresponding source code and may include debugging information.
  3. Debug Information : Debugging information (often in a format like DWARF) can be included in the binary or stored in separate files. This information helps debuggers associate machine code instructions with your original source code, making it easier to debug your program.
  4. Hexadecimal Files : In some cases, especially when programming microcontrollers, you might generate hexadecimal files (with extensions like .hex) that specify the memory contents, including both code and data, in a human-readable format.
  5. Assembly Listings : Some build systems can generate assembly listings (with extensions like .lst) that show the generated assembly code alongside your source code. This can be useful for understanding how your high-level code translates into machine code.

7. Other Output Files : Depending on your specific development environment and tools, you might encounter other files related to the build process, such as project configuration files, build logs, or build artifacts generated by plugins or extensions. Like the Cmake , SDK files etc.

In this IDE when the build process is done the compiler gives us a .elf file that can be loaded onto the target embedded hardware.

The exact set of files generated can vary widely based on your development workflow and tools, so it’s important to consult the documentation for your chosen development environment and build system to understand the specifics for your project.( To understand build process and specifies of S32K144 MCU, refer this).

 

Which tools are used in building the project?

When we build an embedded project there are some files and a compiler that is used to build the project. 

  1. Makefile
  2. Linker script
  3. Startup code
  4. GNU GCC Compiler
  1. Make file :-   A makefile can be considered as a script or a set of commands which help build, compile, link the entire project in order to create an executable. The makefile defines a set of tasks to be executed.A makefile does not have any extension. The makefile has to be specifically named as “makefile”.
  2. Linker Script :- A linker script is used to specify how object files should be linked together to create the final executable binary. It defines the memory layout of the binary and specifies where different sections of code and data should be located in memory.

The memory command is used to describe the memory map of your target system. The sections command describe the placement of each named output section, and specify which input sections go into them. 

  1. Startup Code :- Start-Up Code is the soul of an MCU. It is the first-ever code that runs on an MCU right after the Power On Reset (POR). The Start-Up code triggers the initializing of crucial parts of the MCU needed for booting and the subsequent target application launch.

The start-up code in embedded systems is typically lightweight and is written in assembly language, or a combination of C and assembly. When code is written in assembly language, the developer has greater control and can optimize for speed by carefully selecting specific instructions or instruction types. You can see the startup code file in the above image.

  1. GNU GCC Compiler :- The GNU Compiler Collection (GCC) is an optimizing compiler produced by the GNU Project supporting various programming languages, hardware architectures and operating systems. The Free Software Foundation (FSF) distributes GCC as free software under the GNU General Public License (GNU GPL). GCC is a key component of the GNU toolchain and the standard compiler for most projects related to GNU and the Linux kernel.

GCC is the language translator as mentioned above. It will translate your source code into the machine code so that it can be executed on the computer.

Kunal Gupta
Author: Kunal Gupta

Author

Kunal Gupta

Leave a comment

Stay Updated With Us

Error: Contact form not found.

      Blog