[go: up one dir, main page]

0% found this document useful (0 votes)
4 views50 pages

CMPE 246 Lecture 6 - (Jan.23)

The document outlines the course CMPE 246, focusing on the development environment for embedded systems, including the necessary tools and workflows for software and hardware integration. It details the use of various development tools such as utility, translation, and debugging tools, as well as the GCC compiler for compiling code. Additionally, it provides practical steps for compiling and debugging code using Visual Studio Code and terminal commands.

Uploaded by

siamibne1512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views50 pages

CMPE 246 Lecture 6 - (Jan.23)

The document outlines the course CMPE 246, focusing on the development environment for embedded systems, including the necessary tools and workflows for software and hardware integration. It details the use of various development tools such as utility, translation, and debugging tools, as well as the GCC compiler for compiling code. Additionally, it provides practical steps for compiling and debugging code using Visual Studio Code and terminal commands.

Uploaded by

siamibne1512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

CMPE 246 (3) Computer Engineering

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

Instructor Contact Information: ling.bai@ubc.ca

Office Hours: By appointment


Please click on the link to book a 15-minutes
appointment during office hours ( EME 3280,
Friday, 2:30pm-4:30pm). You may book multiple
time slots if needed. If none of the available times
work for you, please feel free to email me.
ling.bai@ubc.ca
Appointment booking link:
https://lingbai.youcanbook.me

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.

The development and integration of an embedded system’s various


hardware and software components are made possible through
development tools that provide everything from loading software into the
hardware to providing complete control over the various system
components.

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.

In short, a development environment is typically made up of a target (the


embedded system being designed) and a host (a PC, or some other
computer system where the code is actually developed).

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)

Information is stored in the design repository. The repository allows keeping


track of your design.

A good design repository should also come with a design management


interface which would also keep track of the applicability of design tools and
sequences, all integrated into a comfortable graphical user interface (GUI). 9
2- Development Environment
The design repository and the GUI can be extended into an integrated
development environment (IDE), also called design framework.

An integrated development environment keeps track of dependencies


between tools and design information.

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.

These instructions are defined as


• ‘Op Codes’ (C / C++ / Assembly language)
• ‘Bytecode’ (Python) 17
3- Translate(Compile) Workflow
Translation Tools:
• Preprocessors(C / C++)
• Interpreters (Python), Compilers (C / C++), Assembler (Assembly language)
• Linkers (C / C++ / Assembly language)
Preprocessor Type Syntax
Macro #define This is the macro used to
define any constant values
or string values.
Header file inclusion #include It inludes the ‘file’ into the
current program.
Condition #ifdef #endif There are contional
macros used in the
program.
Others #undef #pragma Undefines the defined 18
macro in the program.
3- Translate(Compile) Workflow
Translation Tools:
• Preprocessors(C / C++)
• Interpreters (Python), Compilers (C / C++), Assembler (Assembly language)
• Linkers (C / C++ / Assembly language)

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.

B. Code written in interpreted(scripting) languages is typically read and executed by


Interpreters. The interpreter interprets the source code in real-time:line by line or block
by block at runtime. 22
3- Translate(Compile) Workflow

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

$ gcc -o hello heart.c main.c


$ ./hello

$ gcc -o hello *.c

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

$ python -m compileall modules

__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)

You might also like