Build Process of Embedded System
Build Process of Embedded System
for
Embedded Systems
6/19/2013 1
Build Process is the process of transforming human understandable code to
machine understandable code.
Human Machine
Understandable code Build Process Understandable code
(High Level Language) (Low Level Language)
Host Processor
Human Communication
Build Machine Target Processor
Understandable Understandable Link
code Process code
6/19/2013 2
The steps involved in build process are listed as follows:
C language code (.C file) Build Process Outputs at
each step
6/19/2013 3
Preprocessing
A C preprocessor is a program that accepts C code with preprocessing statements and
produces a pure form of C code that contains no preprocessing statements.
All preprocessing statements in C begin with the # symbol and are at the beginning of a
line.
Format:
#preprocessor directive
6/19/2013 4
Following block diagram shows the tasks done during preprocessing:
PRE-PROCESSOR
EXPAND EXPAND MACROS AND
REMOVE ALL Preprocessed
Source Code INCLUDE REPLACE SYMBOLIC
COMMENTS code
FILES CONSTANTS
6/19/2013 6
During compilation, code written in High Level Language is converted into machine understandable
code.
Compilation process can be split up in 2 steps:
Compilation Object
Preprocessed Object File File
Code Parsing +
Generation
List File
Tasks done during compilation (Step- 1, Parsing)are as follows:
Object file contains ‘binary’ image of code divided into multiple segments . Allocation is irrespective of target
List file contains the all opcodes at an allocated address. memory address.
Example of Compilation process in Integrated Development Environment
Let us take an example of compilation process of LED_Toggle.c
Compilation commands
Cxstm8: Cross Compiler for STM8 family MCUs.
9
Example of Compilation process in Integrated Development Environment
Also take a look at the files and folders in the directory after compiling.
6/19/2013 11
The object file is not a executable file due to following issues:
1. No references to external variables or functions
2. No unique address for each opcode (in case of multiple source files).
E
Assembly
source file
Cross-Assembler Object File 3 R
6/19/2013 12
Tasks performed by Linker:
Linker resolves the external variable or function references.
Linker assigns a unique address to each opcode.
Linker also searches the libraries and link appropriate code to the application.
Linker
……. …….
1547 MOVE R5,R1
File: two.c File: two.obj ……. ADD R5, 0x1234
…………. ……. …….
Cross-Compiler
Int time
…….. fun1: 2388 (Value of sec)
fun1 (time) MOV R5,R1
{ ADD R5, 0x1234
……. ………
}
6/19/2013 13
YES or NO ?
The answer is both.
Let us see how…
6/19/2013 15
Locator performs the task of assigning physical memory addresses (either RAM or ROM)
to the data and code sections of relocatable program.
Address File: final.exe
Final.exe
…….. ……..
1000 MOVE R1, 2388 /* RAM */ /* ROM */
1004 CALL 1547
……. ……. - Data - Code
1547 MOVE R5,R1 - Constants
……. ADD R5, 0x1234 - Global Variables
……. ……. …………
2388 (Value of sec)
Locator
LINKER File
MAP File
It contains MCU memory addresses It contains:
available for all segments of code. 1. Code Segments & their MCU
SEGMENTS: CODE memory addresses.
CONSTANTS 2. Functions & their address
EEPROM 3. Required Stack Size
ZERO PAGE 4. Symbol Table
……………
…………..
Locator
6/19/2013can be available as a separate tool or bundled with the linking step. 16
Example of complete build process in IDE
Linker commands
Clnk: Combines relocatable object files from cosmic
library.
-l: Specify library path
6/19/2013 17
Example of complete build process in IDE
Also take a look at the files and folders in the directory after build process.
6/19/2013 19
6/19/2013 20
6/19/2013 21