SlideShare une entreprise Scribd logo
1  sur  21
Build Process 
for 
Embedded Systems 
6/19/2013 1
 Build Process is the process of transforming human understandable code to 
machine understandable code. 
Build Process 
Human 
Understandable code 
(High Level Language) 
Machine 
Understandable code 
(Low Level Language) 
Target Processor 
Communication 
Link 
 In Embedded systems, there are 2 processors: 
1. HOST: On which program is built. 
2. TARGET: On which program is to be loaded. 
Host Processor 
Build 
Process 
Machine 
Understandable 
code 
6/19/2013 2 
Human 
Understandable 
code
 The steps involved in build process are listed as follows: 
C language code (.C file) 
Final executable file 
(.hex, .bin, .elf, etc.) 
Build Process Outputs at 
each step 
Computer Preprocessor file 
(.cpp file) 
Object file (.obj file) 
& 
List file (.lst file) 
Link file (.lkf file) 
Map File 
(.map file) 
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 
e.g. #define SET (1) 
#include “header.h” 
Macro ‘SET’ is defined with value = 1 
Header file with name header.h is included in main.c 
6/19/2013 4
Following block diagram shows the tasks done during preprocessing: 
PRE-PROCESSOR 
EXPAND MACROS AND 
REPLACE SYMBOLIC 
CONSTANTS 
/* header file (myfile.h) */ 
#define pi 3.14 
#define cube(x) (x)^3 
extern float j = pi*1.33; 
REMOVE ALL 
COMMENTS 
EXPAND 
INCLUDE 
FILES 
/* Source File (src.C) */ 
#define radius _cm 2 
#include “myfile.h” 
Int main (void) 
{ 
float i = radius_cm; 
float Volume = j*cube(i); 
return 0; 
} 
#define radius _cm 2 
#define pi 3.14 
#define cube(x) (x)^3 
extern float j= pi*1.33; 
int main(void) 
{ 
float i= radius_cm; 
float Volume= j*cube(i); 
return 0; 
} 
extern float j= 3.14*1.33; 
int main(void) 
{ 
float i= 2; 
float Volume= j*i^3; 
return 0; 
} 
Source Code 
Let us see through 
an example: 
#define radius _cm 2 
#include “myfile.h” 
int main(void) 
{ 
float i= radius_cm; 
float Volume= j*cube(i); 
return 0; 
} 
Preprocessed 
code 
6/19/2013 5 
Before 
Preprocessing: 
During 
Preprocessing: 
Source 
Code 
Preprocessed 
code
 The steps involved in build process are listed as follows: 
C language code (.C file) 
Final executable file 
(.hex, .bin, .elf, etc.) 
Build Process Outputs at 
each step 
Computer Preprocessor file 
(.cpp file) 
Object file (.obj file) 
& 
List file (.lst file) 
Link file (.lkf file) 
Map File 
(.map file) 
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 
Parsing Object File 
Generation 
Preprocessed 
Code 
Object 
File 
+ 
List File 
 Tasks done during compilation (Step- 1, Parsing)are as follows: 
Preprocessed 
 Validate the use of variables. 
e.g.- Int extern = 1; 
 Checks for the semantic errors. 
Code Parsed Code 
e.g.- Int a= 1 
 Checks for the external variables used in the source file.
Compilation 
Object File 
Generation 
extern float j = 4.17; 
int j; 
int main(void) 
{ 
float i = 2; 
float Volume = j*i^3; 
return 0; 
} 
Parsed Code 
4066 ; 12 int main(void) 
4066 ; 13 { 
4068 switch .text 
4069 0000 _main: 
4071 0000 520c subw sp, #12 
4072 0000000c OFST : set 12 
4075 ; 14 float j = pi*1.33; 
4077 ; 15 float i = radius_cm; 
4079 ; 16 float Volume = j*cube(i); 
4081 0002 ce0002 ldw x, L7272+2 1 
4079 ; .. .. .. .. .. 
 Object file contains ‘binary’ image of code divided into multiple segments . 
 List file contains the all opcodes at an allocated address. 
Text 
int main (void) 
float i = 2; 
float Volume = j*i^3; 
return 0; 
/*Contains code and 
local variables*/ 
Data 
extern float j = 4.17; 
/* Contains initialized 
global variables*/ 
BSS 
int j; 
/*Contains uninitialized 
global variables*/ 
Stack 
/*Contains data 
produced during 
program execution*/ 
Allocation is irrespective of target 
memory address. 
In step-2(Object Code Generation) of compilation, 
object code and list file are generated.
Compilation commands 
-pxp: Don’t use absolute paths in debug information 
-i: Generate list (.ls) file 
-i"C:Program FilesCOSMICCXSTM8_EVALHstm8“: 
Add all files from “Hstm8” folder 
9 
Example of Compilation process in Integrated Development Environment 
Let us take an example of compilation process of LED_Toggle.c 
Cxstm8: Cross Compiler for STM8 family MCUs. 
+mods0: Short Stack 
+debug: To generate debug information 
-no: Optimization is disabled 
-pp: Enforce prototyping for function 
-i ..inc: Add all files from “inc” folder 
-clDebug: Locating list file in the debug folder 
-coDebug: Locating list file in the debug folder 
..srcled_toggle.c: Add led_toggle.c file from src 
folder
Example of Compilation process in Integrated Development Environment 
Also take a look at the files and folders in the directory after compiling. 
Includes and Src folder contains .h files and .C files respectively. 
 Compilation generates an object and a list file in the debug folder. 
 Object File: Binary Image file of .C file. 
 List File: List of opcodes with their addresses.
 The steps involved in build process are listed as follows: 
C language code (.C file) 
Final executable file 
(.hex, .bin, .elf, etc.) 
Build Process Outputs at 
each step 
Computer Preprocessor file 
(.cpp file) 
Object file (.obj file) 
& 
List file (.lst file) 
Link file (.lkf file) 
Map File 
(.map file) 
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). 
Linker produces a ‘relocatable copy’ of the program by merging all 
the code and data sections from all the object files. 
C source file 1 
C source file 2 
Assembly 
source file 
Cross-Compiler 
Cross-Compiler 
Object File 1 
Object File 2 
Cross-Assembler Object File 3 
L 
I 
N 
K 
E 
R 
Relocatable 
Object File 
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. 
6/19/2013 13 
File: one.c 
int sec; 
…….. 
fun1(sec); 
……… 
File: two.c 
Int time 
…….. 
fun1 (time) 
{ 
……. 
} 
Address 
…….. 
1000 
1004 
……. 
1547 
……. 
……. 
2388 
File: final.exe 
…….. 
MOVE R1, 2388 
CALL 1547 
……. 
MOVE R5,R1 
ADD R5, 0x1234 
……. 
(Value of sec) 
Linker 
File: one.obj 
…………. 
MOVE R1, (sec); 
CALL fun1; 
……… 
……… 
File: two.obj 
…………. 
fun1: 
MOV R5,R1 
ADD R5, 0x1234 
……… 
Cross-Compiler 
Cross-Compiler Cross-Compiler
YES or NO 
The answer is both. 
Let us see how… 
 For Software programmers, the answer is YES. 
 The build process finishes with linking. 
? 
 For Embedded programmers, the answer is NO. 
So what is left for embedded programmers to do?? What is missing? 
Address allocation to code and 
data segment according to 
processor memory organization. 
6/19/2013 14
 The steps involved in build process are listed as follows: 
C language code (.C file) 
Final executable file 
(.hex, .bin, .elf, etc.) 
Build Process Outputs at 
each step 
Computer Preprocessor file 
(.cpp file) 
Object file (.obj file) 
& 
List file (.lst file) 
Link file (.lkf file) 
Map File 
(.map file) 
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. 
/* RAM */ 
- Data 
Locator can be available as a separate tool or bundled with the linking step. 
6/19/2013 16 
Address 
…….. 
1000 
1004 
……. 
1547 
……. 
……. 
2388 
File: final.exe 
…….. 
MOVE R1, 2388 
CALL 1547 
……. 
MOVE R5,R1 
ADD R5, 0x1234 
……. 
(Value of sec) 
Locator 
MAP File 
It contains: 
1. Code Segments & their MCU 
memory addresses. 
2. Functions & their address 
3. Required Stack Size 
4. Symbol Table 
…………… 
/* ROM */ 
- Code 
- Constants 
- Global Variables 
………… 
LINKER File 
It contains MCU memory addresses 
available for all segments of code. 
SEGMENTS: CODE 
CONSTANTS 
EEPROM 
ZERO PAGE 
………….. 
Final.exe
Example of complete build process in IDE 
Linker commands 
Clnk: Combines relocatable object files from cosmic 
library. 
-l: Specify library path 
-o: Outputs following files to the specified directory. 
1. (.sm8): SM8 file 
2. (.map): MAP file 
-m: Generate .map file for the program being built. 
3. (.lkf): LINKER file 
cvdwarf: Utility to convert file produced by linker to 
ELF format. 
Chex: Utility to translate executable image file (.sm8) 
produced by linker to hexadecimal format. 
-o: Outputs following files to the specified directory. 
1. (.s19): S19 file 
2. (.sm8): SM8 file 
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. 
Final Executable File (.ELF) 
Linker File (.LKF) 
List Files (.LS) 
Map File (.MAP) 
Object Files (.O) 
Hexadecimal interchange format 
file (.S19) 
(.SM8)
Bibliography 
1. “Embedded Realtime Systems Programming”, Pankaj Gupta, Sriram 
V Iyer, Tata McGraw- Hill publishing Company Ltd, Eighth reprint 
2007. 
2. “Programming Embedded Systems in C and C++”, Michael Barr, 
O’Reilly & Associates, Inc., Eighth Indian Reprint 2003. 
3. “An Embedded Software Primer”, David E. Simon, Pearson 
Education, ISBN 81-7808-045-1, Twelfth Indian Reprint 2005. 
6/19/2013 19
6/19/2013 20
6/19/2013 21

Contenu connexe

Tendances

System verilog verification building blocks
System verilog verification building blocksSystem verilog verification building blocks
System verilog verification building blocks
Nirav Desai
 

Tendances (20)

Introduction to Makefile
Introduction to MakefileIntroduction to Makefile
Introduction to Makefile
 
Difference between C++ and Java
Difference between C++ and JavaDifference between C++ and Java
Difference between C++ and Java
 
Operator precedence
Operator precedenceOperator precedence
Operator precedence
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
 
Ral by pushpa
Ral by pushpa Ral by pushpa
Ral by pushpa
 
REGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.AREGULAR EXPRESSION TO N.F.A
REGULAR EXPRESSION TO N.F.A
 
AMBA 2.0 PPT
AMBA 2.0 PPTAMBA 2.0 PPT
AMBA 2.0 PPT
 
System verilog verification building blocks
System verilog verification building blocksSystem verilog verification building blocks
System verilog verification building blocks
 
LR Parsing
LR ParsingLR Parsing
LR Parsing
 
Java basic
Java basicJava basic
Java basic
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Tizen RT: A Lightweight RTOS Platform for Low-End IoT Devices
Tizen RT: A Lightweight RTOS Platform for Low-End IoT DevicesTizen RT: A Lightweight RTOS Platform for Low-End IoT Devices
Tizen RT: A Lightweight RTOS Platform for Low-End IoT Devices
 
LR(0) PARSER
LR(0) PARSERLR(0) PARSER
LR(0) PARSER
 
Removing ambiguity-from-cfg
Removing ambiguity-from-cfgRemoving ambiguity-from-cfg
Removing ambiguity-from-cfg
 
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
 
Facebook chat architecture
Facebook chat architectureFacebook chat architecture
Facebook chat architecture
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
JavaFX Overview
JavaFX OverviewJavaFX Overview
JavaFX Overview
 
Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
 

Similaire à Build process in ST Visual Develop

Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 
C programming session 14
C programming session 14C programming session 14
C programming session 14
Vivek Singh
 
Computer architecture is made up of two main components the Instruct.docx
Computer architecture is made up of two main components the Instruct.docxComputer architecture is made up of two main components the Instruct.docx
Computer architecture is made up of two main components the Instruct.docx
brownliecarmella
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
Sami Said
 
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdfConcisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
feelinggift
 

Similaire à Build process in ST Visual Develop (20)

Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptx
 
Build process ppt.pptx
Build process ppt.pptxBuild process ppt.pptx
Build process ppt.pptx
 
嵌入式Linux課程-GNU Toolchain
嵌入式Linux課程-GNU Toolchain嵌入式Linux課程-GNU Toolchain
嵌入式Linux課程-GNU Toolchain
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
System programmin practical file
System programmin practical fileSystem programmin practical file
System programmin practical file
 
From gcc to the autotools
From gcc to the autotoolsFrom gcc to the autotools
From gcc to the autotools
 
Address Binding Scheme
Address Binding SchemeAddress Binding Scheme
Address Binding Scheme
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Digital design with Systemc
Digital design with SystemcDigital design with Systemc
Digital design with Systemc
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptx
 
introduction of c langauge(I unit)
introduction of c langauge(I unit)introduction of c langauge(I unit)
introduction of c langauge(I unit)
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJIntroduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
 
C programming session 14
C programming session 14C programming session 14
C programming session 14
 
C Under Linux
C Under LinuxC Under Linux
C Under Linux
 
Computer architecture is made up of two main components the Instruct.docx
Computer architecture is made up of two main components the Instruct.docxComputer architecture is made up of two main components the Instruct.docx
Computer architecture is made up of two main components the Instruct.docx
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdfConcisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
 

Dernier

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 

Build process in ST Visual Develop

  • 1. Build Process for Embedded Systems 6/19/2013 1
  • 2.  Build Process is the process of transforming human understandable code to machine understandable code. Build Process Human Understandable code (High Level Language) Machine Understandable code (Low Level Language) Target Processor Communication Link  In Embedded systems, there are 2 processors: 1. HOST: On which program is built. 2. TARGET: On which program is to be loaded. Host Processor Build Process Machine Understandable code 6/19/2013 2 Human Understandable code
  • 3.  The steps involved in build process are listed as follows: C language code (.C file) Final executable file (.hex, .bin, .elf, etc.) Build Process Outputs at each step Computer Preprocessor file (.cpp file) Object file (.obj file) & List file (.lst file) Link file (.lkf file) Map File (.map file) 6/19/2013 3
  • 4. 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 e.g. #define SET (1) #include “header.h” Macro ‘SET’ is defined with value = 1 Header file with name header.h is included in main.c 6/19/2013 4
  • 5. Following block diagram shows the tasks done during preprocessing: PRE-PROCESSOR EXPAND MACROS AND REPLACE SYMBOLIC CONSTANTS /* header file (myfile.h) */ #define pi 3.14 #define cube(x) (x)^3 extern float j = pi*1.33; REMOVE ALL COMMENTS EXPAND INCLUDE FILES /* Source File (src.C) */ #define radius _cm 2 #include “myfile.h” Int main (void) { float i = radius_cm; float Volume = j*cube(i); return 0; } #define radius _cm 2 #define pi 3.14 #define cube(x) (x)^3 extern float j= pi*1.33; int main(void) { float i= radius_cm; float Volume= j*cube(i); return 0; } extern float j= 3.14*1.33; int main(void) { float i= 2; float Volume= j*i^3; return 0; } Source Code Let us see through an example: #define radius _cm 2 #include “myfile.h” int main(void) { float i= radius_cm; float Volume= j*cube(i); return 0; } Preprocessed code 6/19/2013 5 Before Preprocessing: During Preprocessing: Source Code Preprocessed code
  • 6.  The steps involved in build process are listed as follows: C language code (.C file) Final executable file (.hex, .bin, .elf, etc.) Build Process Outputs at each step Computer Preprocessor file (.cpp file) Object file (.obj file) & List file (.lst file) Link file (.lkf file) Map File (.map file) 6/19/2013 6
  • 7.  During compilation, code written in High Level Language is converted into machine understandable code.  Compilation process can be split up in 2 steps: Compilation Parsing Object File Generation Preprocessed Code Object File + List File  Tasks done during compilation (Step- 1, Parsing)are as follows: Preprocessed  Validate the use of variables. e.g.- Int extern = 1;  Checks for the semantic errors. Code Parsed Code e.g.- Int a= 1  Checks for the external variables used in the source file.
  • 8. Compilation Object File Generation extern float j = 4.17; int j; int main(void) { float i = 2; float Volume = j*i^3; return 0; } Parsed Code 4066 ; 12 int main(void) 4066 ; 13 { 4068 switch .text 4069 0000 _main: 4071 0000 520c subw sp, #12 4072 0000000c OFST : set 12 4075 ; 14 float j = pi*1.33; 4077 ; 15 float i = radius_cm; 4079 ; 16 float Volume = j*cube(i); 4081 0002 ce0002 ldw x, L7272+2 1 4079 ; .. .. .. .. ..  Object file contains ‘binary’ image of code divided into multiple segments .  List file contains the all opcodes at an allocated address. Text int main (void) float i = 2; float Volume = j*i^3; return 0; /*Contains code and local variables*/ Data extern float j = 4.17; /* Contains initialized global variables*/ BSS int j; /*Contains uninitialized global variables*/ Stack /*Contains data produced during program execution*/ Allocation is irrespective of target memory address. In step-2(Object Code Generation) of compilation, object code and list file are generated.
  • 9. Compilation commands -pxp: Don’t use absolute paths in debug information -i: Generate list (.ls) file -i"C:Program FilesCOSMICCXSTM8_EVALHstm8“: Add all files from “Hstm8” folder 9 Example of Compilation process in Integrated Development Environment Let us take an example of compilation process of LED_Toggle.c Cxstm8: Cross Compiler for STM8 family MCUs. +mods0: Short Stack +debug: To generate debug information -no: Optimization is disabled -pp: Enforce prototyping for function -i ..inc: Add all files from “inc” folder -clDebug: Locating list file in the debug folder -coDebug: Locating list file in the debug folder ..srcled_toggle.c: Add led_toggle.c file from src folder
  • 10. Example of Compilation process in Integrated Development Environment Also take a look at the files and folders in the directory after compiling. Includes and Src folder contains .h files and .C files respectively.  Compilation generates an object and a list file in the debug folder.  Object File: Binary Image file of .C file.  List File: List of opcodes with their addresses.
  • 11.  The steps involved in build process are listed as follows: C language code (.C file) Final executable file (.hex, .bin, .elf, etc.) Build Process Outputs at each step Computer Preprocessor file (.cpp file) Object file (.obj file) & List file (.lst file) Link file (.lkf file) Map File (.map file) 6/19/2013 11
  • 12.  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). Linker produces a ‘relocatable copy’ of the program by merging all the code and data sections from all the object files. C source file 1 C source file 2 Assembly source file Cross-Compiler Cross-Compiler Object File 1 Object File 2 Cross-Assembler Object File 3 L I N K E R Relocatable Object File 6/19/2013 12
  • 13. 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. 6/19/2013 13 File: one.c int sec; …….. fun1(sec); ……… File: two.c Int time …….. fun1 (time) { ……. } Address …….. 1000 1004 ……. 1547 ……. ……. 2388 File: final.exe …….. MOVE R1, 2388 CALL 1547 ……. MOVE R5,R1 ADD R5, 0x1234 ……. (Value of sec) Linker File: one.obj …………. MOVE R1, (sec); CALL fun1; ……… ……… File: two.obj …………. fun1: MOV R5,R1 ADD R5, 0x1234 ……… Cross-Compiler Cross-Compiler Cross-Compiler
  • 14. YES or NO The answer is both. Let us see how…  For Software programmers, the answer is YES.  The build process finishes with linking. ?  For Embedded programmers, the answer is NO. So what is left for embedded programmers to do?? What is missing? Address allocation to code and data segment according to processor memory organization. 6/19/2013 14
  • 15.  The steps involved in build process are listed as follows: C language code (.C file) Final executable file (.hex, .bin, .elf, etc.) Build Process Outputs at each step Computer Preprocessor file (.cpp file) Object file (.obj file) & List file (.lst file) Link file (.lkf file) Map File (.map file) 6/19/2013 15
  • 16.  Locator performs the task of assigning physical memory addresses (either RAM or ROM) to the data and code sections of relocatable program. /* RAM */ - Data Locator can be available as a separate tool or bundled with the linking step. 6/19/2013 16 Address …….. 1000 1004 ……. 1547 ……. ……. 2388 File: final.exe …….. MOVE R1, 2388 CALL 1547 ……. MOVE R5,R1 ADD R5, 0x1234 ……. (Value of sec) Locator MAP File It contains: 1. Code Segments & their MCU memory addresses. 2. Functions & their address 3. Required Stack Size 4. Symbol Table …………… /* ROM */ - Code - Constants - Global Variables ………… LINKER File It contains MCU memory addresses available for all segments of code. SEGMENTS: CODE CONSTANTS EEPROM ZERO PAGE ………….. Final.exe
  • 17. Example of complete build process in IDE Linker commands Clnk: Combines relocatable object files from cosmic library. -l: Specify library path -o: Outputs following files to the specified directory. 1. (.sm8): SM8 file 2. (.map): MAP file -m: Generate .map file for the program being built. 3. (.lkf): LINKER file cvdwarf: Utility to convert file produced by linker to ELF format. Chex: Utility to translate executable image file (.sm8) produced by linker to hexadecimal format. -o: Outputs following files to the specified directory. 1. (.s19): S19 file 2. (.sm8): SM8 file 6/19/2013 17
  • 18. Example of complete build process in IDE Also take a look at the files and folders in the directory after build process. Final Executable File (.ELF) Linker File (.LKF) List Files (.LS) Map File (.MAP) Object Files (.O) Hexadecimal interchange format file (.S19) (.SM8)
  • 19. Bibliography 1. “Embedded Realtime Systems Programming”, Pankaj Gupta, Sriram V Iyer, Tata McGraw- Hill publishing Company Ltd, Eighth reprint 2007. 2. “Programming Embedded Systems in C and C++”, Michael Barr, O’Reilly & Associates, Inc., Eighth Indian Reprint 2003. 3. “An Embedded Software Primer”, David E. Simon, Pearson Education, ISBN 81-7808-045-1, Twelfth Indian Reprint 2005. 6/19/2013 19

Notes de l'éditeur

  1. General Idea