CMPE 246 Lecture 6 - (Jan.23)
CMPE 246 Lecture 6 - (Jan.23)
Design Studio
Dr. Ling Bai
ling.bai@ubc.ca
IEEE Member, ACM Member
Faculty of Applied Science | School of Engineering
The University of British Columbia, Okanagan Campus
1137 Alumni Avenue, Kelowna BC, V1V 1V7 Canada
Instructor Name: Ling Bai
2
Lecture 4
3
1- Start
4
1- Start
5
2- Development Environment
It is important to understand what development tools are available that aid
in the implementation of an embedded system.
6
2- Development Environment
Embedded systems aren’t typically developed on one system alone—for
example, the hardware board of the embedded system—but usually require
at least one other computer system connected to the embedded platform
to manage development of that platform.
7
2- Development Environment
8
2- Development Environment
Having the explicit architecture documentation helps the engineers and
programmers on the development team to implement an embedded system
that conforms to the requirements. (create / document your design)
10
2- Development Environment
The key development tools in embedded design can be located on the
host, on the target, or can exist stand-alone.
These tools typically fall under one of three categories.
11
2- Development Environment
Utility tools are general tools that aid in software or hard-ware
development, such as editors (for writing source code), VCS (Version
Control Software) that manages software files, ROM burners that allow
software to be put onto ROMs, etc.
Translation tools convert code a developer intends for the target into a
form the target can execute.
Debugging tools can be used to track down and correct bugs in the
system. 12
2- Development Environment
Source code is typically written with a tool such as a standard ASCII text
editor, or an Integrated Development Environment (IDE) located on the host
(development) platform,
ASCII (American Standard Code for Information Interchange) is the most
common character encoding format for text data in computers and on the
internet.
ASCII Table
https://www.rapidtables.com/code/text/ascii-table.ht
ml
13
2- Development Environment
14
2- Development Environment
Computer-Aided Design (CAD) tools are commonly used by hardware engineers to
simulate circuits at the electrical level in order to study a circuit’s behavior under various
conditions before they actually build the circuit.
15
2- Development Environment
Debug Tools:
• Debugging is primarily the task of locating and fixing errors within the development cyle.
a. Hardware
b. Software
c. Manual
16
2- Development Environment
Translation Tools:
• Preprocessors(C / C++)
• Interpreters (Python), Compilers (C / C++), Assembler (Assembly language)
• Linkers (C / C++ / Assembly language)
Once you have written the source code in editor than it has to be translated that written
code into instruction code for machine to understand and operate.
19
3- Translate(Compile) Workflow
Translation Tools:
• Preprocessors(C / C++)
• Interpreters (Python), Compilers (C / C++), Assembler (Assembly language)
• Linkers (C / C++ / Assembly language)
After all the compilation is completed, the remaining target code file is commonly referred
to as an object file.
A linker integrates this object file with any other required system libraries, creating what
is commonly referred to as an executable binary file, either directly onto the board’s
memory or ready to be transferred to the target embedded system’s memory by a loader.
20
3- Translate(Compile) Workflow
Translation Tools:
• Preprocessors(C / C++)
• Interpreters (Python), Compilers (C / C++), Assembler (Assembly language)
• Linkers (C / C++ / Assembly language)
21
3- Translate(Compile) Workflow
Translation Tools:
• Preprocessors(C / C++)
• Interpreters (Python), Compilers (C / C++), Assembler (Assembly language)
• Linkers (C / C++ / Assembly language)
A. Code written in compiled languages is transformed into machine code through the
Compilers, ultimately generating an independent executable file. This file can run
directly on the operating system.
23
3- Translate(Compile) Workflow
24
3- Translate(Compile) Workflow
25
3- Translate(Compile) Workflow
26
3- Translate(Compile) Workflow
27
C
3- Translate(Compile) Workflow
28
C++
3- Translate(Compile) Workflow
29
Python
4- Compiling files step by step
GCC (GNU Compiler Collection)
The original GNU C Compiler (GCC) is developed by Richard Stallman, the founder of the
GNU Project. Richard Stallman founded the GNU project in 1984 to create a complete
Unix-like operating system as free software, to promote freedom and cooperation among
computer users and programmers.
GCC, formerly for "GNU C Compiler", has grown over times to support many languages
such as C (gcc), C++ (g++), Objective-C, Objective-C++, etc. It is now referred to as "GNU
Compiler Collection".
30
4- Compiling files step by step
GCC is a key component of so-called "GNU Toolchain", for developing applications and
writing operating systems. The GNU Toolchain includes:
• GNU Compiler Collection (GCC): a compiler suite that supports many languages,
such as C/C++ and Objective-C/C++.
• GNU Make: an automation tool for compiling and building applications.
• GNU Binutils: a suite of binary utility tools, including linker and assembler.
• GNU Debugger (GDB).
• GNU Autotools: A build system including Autoconf, Autoheader, Automake and Libtool.
• GNU Bison: a parser generator (similar to lex and yacc).
31
4- Compiling files step by step
For unix-based linux-kernal OS (ubuntu/debian/mac OS):
$ gcc --version
$ g++ --version
• check your version
• sudo apt install #NAME
For Windows, you could either install Cygwin GCC, MinGW GCC or MinGW-W64 GCC.
32
4- Compiling files step by step
This Section will be demonstrated live in class!
Real steps: Let’s play right now! (interface): Visual Studio Code VS terminal
install extension
compile
• c
• c++
• python
debug
run
33
4- Compiling files step by step
Real steps: Let’s play right now! Visual Studio Code VS terminal
34
4- Compiling files step by step
Real steps: Let’s play right now! Visual Studio Code VS terminal
35
4- Compiling files step by step
Real steps: Let’s play right now! Visual Studio Code VS terminal
compile
debug
run
shortcut!
>........ go to your marketplace
$ cd ~/yourcode
$ gcc hello.c
windows/linux/mac os 36
4- Compiling files step by step
Real steps: Let’s play right now! Visual Studio Code VS terminal
compile
debug
run
-o: specifies the output filename.
$ gcc hello.c -o hello / gcc -o hello hello.c
$ gcc -E hello.c -o hello.i
$ gcc -S hello.c -o hello.s
$ gcc -c hello.s -o hello.o
$ gcc hello.o -o hello
$ ./hello
37
4- Compiling files step by step
Real steps: Let’s play right now! Visual Studio Code VS terminal
38
4- Compiling files step by step
Real steps: Let’s play right now! Visual Studio Code VS terminal
compile
debug
run
39
4- Compiling files step by step
Real steps: Let’s play right now! Visual Studio Code VS terminal
compile
debug
run
tasks.json
40
4- Compiling files step by step
C++
Let’s play right now!
compile
debug
run
tasks.json
$ g++ ...................
41
4- Compiling files step by step
Python
Let’s play right now!
compile
debug
run
$ python hello.py
$ python -m compileall hello.py
$ python *.pyc
42
4- Compiling files step by step
Python
Let’s play right now!
compile
debug
run
$ python hello.py
$ python -m compileall hello.py
$ python *.pyc
43
4- Compiling files step by step
Python
Let’s play right now!
compile
debug
run
__init__.py
44
4- Compiling files step by step
makefile
If you want to run or update a task
when certain files are updated, the
make utility can come in handy.
45
4- Compiling files step by step
bash
your shell script
chmod +x hello.sh
change mode
+ add / - delete / = set
r read w write x execute
ls -l
46
4- Compiling files step by step
breakpoint
47
4- Compiling files step by step
Try it !!!
48
Conclude
49
Dr. Ling Bai
(email: ling.bai@ubc.ca)