0% found this document useful (0 votes)
10 views47 pages

Valid Test Develop Debugging Tools

The document outlines the development of validation test cases, debugging techniques, and hardware tools essential for embedded systems. It covers software building processes, debugging methods, types of errors, and the use of oscilloscopes for electronic measurements. Additionally, it discusses the organization of source files, memory segments, and the importance of selecting appropriate oscilloscope specifications for effective debugging.

Uploaded by

ganu609
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)
10 views47 pages

Valid Test Develop Debugging Tools

The document outlines the development of validation test cases, debugging techniques, and hardware tools essential for embedded systems. It covers software building processes, debugging methods, types of errors, and the use of oscilloscopes for electronic measurements. Additionally, it discusses the organization of source files, memory segments, and the importance of selecting appropriate oscilloscope specifications for effective debugging.

Uploaded by

ganu609
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/ 47

Validation Test Case Development,

Debugging & Hardware Tools


Presented by:

Ravi Ranjan
Validation Engineer II
Mirafra Technologies
Agenda

- Test Case Development


- Hardware Software Interface
- Debugging Techniques in Software
- Hardware tools required for debugging
Test Case Development

- Various test case scenarios for any particular IPs as


per their specification/datasheet. e.g. UART.
- C code developement
- Header files
- Source files
Software Building Process
Compiler System
C Runtime
User Code
Object File C Library
C Source

C Source Compiler
Object File

C Source Object File


Linker

OS
Executable
Other Lib

Third-Party Code Hardware


4
IAR Embedded Workbench

IDE Host Application

Third Party Editors, Source


Text Editor Project Manager Debugger GUI Code Control Systems, etc.

C-SPY™
Tool Chain
Debugger Kernel

Compiler, Linker, RDI, J-Link, Angel, RTOS Support Custom


Simulator
Assembler Libraries Macraigor, … Plug-Ins
Software Building Process
File with
UBROF IAR
<library>.r79 <design>.xcl
Object Debug ddf-File Simulator
(Library File) (Linker File)
Information

RDI
IAR
<design>.d79 Debugger
<design>.c
(C Code)
IAR
IAR IAR
<design>.r79 J-Link
C/C++ Linker RTOS Support
(Object File) e.g.
Compiler
ORTI
CMX
OSE
<design>.a79 Macraigor
ThreadX
<design>.h uC/OS-II
(Head File) Fusion
Quadros
<design>.map ......
(Map File) Linker can Angel
produce multiple
output files, e.g.
IAR <design>.r79 Motorola s-
Assembler (Object File) record, Intel
<design>.s79 hex, coff, Third-Party
(Assembly) elf/dwarf, ... Emulator Driver

6
Hierarchical Source Organization
- Workspace
- Project
- Configuration
- Source Group
- Source File

7
Project settings (select ARM core or processor)

8
Debugger & Target System

- IAR C-SPY Simulator


- Hardware Debugger Interface
- IAR J-Link, IAR I-Jet, ROM-monitor, Third- Party
9
Emulator Drivers
C-SPY Debugger
- Seamlessly integrated into the IDE
- Editing while debugging
- Set breakpoints before starting the
debugger
- C/C++ source & disassembly level debugging
- Powerful code and data breakpoints
- Terminal I/O emulation
- Trace (also available for simulator)
- Code Coverage and Profiling
- Generic flash loader
- RTOS-aware debugging
- Extendable for third-party RTOS or emulators

10
Debugging Techniques
- Code Breakpoints
- Conditional Data Breakpoints
- Live watch window
- Step In
- Step Out
- Step Over
Debugging with High Level Languages
Same goals as low-level debugging
- Examine and set values in memory
- Execute portions of program
- Stop execution when (and where) desired

Want debugging tools to operate on high-level language


constructs
- Examine and set variables, not memory locations
- Trace and set breakpoints on statements and function calls, not
instructions...but also want access to low-level tools when needed.
12
Types of Errors
Syntactic Errors
- Input code is not legal
- Caught by compiler (or other translation mechanism)
Semantic Errors
- Legal code, but not what programmer intended
- Not caught by compiler, because syntax is correct
Algorithmic Errors
- Problem with the logic of the program
- Program does what programmer intended,
but it doesn't solve the right problem
13
Syntactic Errors
Common errors:
●missing semicolon or brace
●mis-spelled type in declaration

One mistake can cause an avalanche of errors


● because compiler can't recover and gets confused

main () { missing semicolon


int i
int j;
for (i = 0; i <= 10; i++) {
j = i * 7;
printf("%d x 7 = %d\n", i, j);
}
} 14
Semantic Errors
Common Errors
●Missing braces to group statements together
●Confusing assignment with equality

●Wrong assumptions about operator precedence, associativity

●Wrong limits on for-loop counter

●Uninitialized variables
missing braces,
so printf not part of if
main () {
int i;
int j;
for (i = 0; i <= 10; i++)
j = i * 7;
printf("%d x 7 = %d\n", i, j);
} 15
Algorithmic Errors
Design is wrong, so program does not solve the correct
problem.
Difficult to find
●Program does what we intended
●Problem might not show up until many runs of program

Maybe difficult to fix


● Have to redesign, may have large impact on program code
Classic example: Y2K bug
● only allow 2 digits for year, assuming 19__
16
Debugging Techniques
Ad-Hoc
●Insert printf statements to track control flow and values

●Code explicitly checks for values out of expected range, etc.

●Advantage:

–No special debugging tools needed


●Disadvantages:

–Requires intimate knowledge of code and expected values


–Frequent re-compile and execute cycles
–Inserted code can be buggy
Source-Level Debugger
●Examine and set variable values

●Tracing, breakpoints, single-stepping on source-code statements


17
Source-Level Debugger

main window
of Cygwin
version of gdb

18
Source-Level Debugging Techniques
Breakpoints
- Stop when a particular statement is reached
- Stop at entry or exit of a function
- Conditional breakpoints:
Stop if a variable is equal to a specific value, etc.
- Watchpoints:
Stop when a variable is set to a specific value
Single-Stepping
- Execute one statement at a time
- Step "into" or step "over" function calls
- Step into: next statement is first inside function call
- Step over: execute function without stopping
- Step out: finish executing current function and stop on exit
19
Source-Level Debugging Techniques
Displaying Values
- Show value consistent with declared type of variable
- Dereference pointers (variables that hold addresses)
- Inspect parts of a data structure

20
Compiler Optimization (Code size vs speed)
C Source x = x - 15;

Compiler
Parser
Code
Intermediate High-Level
Optimizer

= Code
Generator
x –
Target Code Low-Level
x 15 Optimizer

000100110101
Assembler 101111011101
LDR R0,x
LDR R1,[R0,#0] Object Code
SUB R1,#15
STR R1,[R0,#0] 21
Customizing Transformations:
Function Inlining

int bar(int a) void foo() void foo()


{ { {
return a*7; b = y+bar(x); b = y+x*7;
} ... ...
} }

- Eliminate the overhead of function calls


- May increase code size
- Let the compiler to decide which functions to inline
- Can be done manually: #pragma inline
22
Customizing Transformations:
Loop Unrolling
/* copy 20 elements */ /* unrolled four times */
for(i=0;i<20;++i) for (i=0;i<20;i+=4)
{ {
a[i]=b[i]; a[i]=b[i];
} a[i+1]=b[i+1];
a[i+2]=b[i+2];
a[i+3]=b[i+3];
}
- Eliminate the overhead of loops
- May increase code size
- Let the compiler to decide which loops to unroll
- Fewer jumps
- Good pipeline performance 23
Customizing Transformations:
Static Clustering

- Static and global variables are arranged so that


variables that are accessed in the same function are
stored close to each other.
- This makes it possible for the compiler to use
the same base pointer for several accesses.

24
Segments and Memories
● Critical for embedded systems:
which parts of code and data are located in where of which kind

of physical memory
● Segment
●Segment is a logical entity containing a piece of data or code that
should be mapped to a physical location in memory.
IAR ILINK Linker is responsible for placing the segments in the

physical memory space.


● Predefined Segments
● User-defined Segments 25
Segment Memory Types
●ILINK assigns a segment memory type to each of the
segments.
●An individual segment may have the same name as its
segment memory type, e.g. CODE.
Segment Description
Memory
Type
CODE For executable code
CONST For data placed in ROM/Flash
DATA For data placed in RAM 26
Predefined Segments for ARM
- Data Segments
- Static Memory Segments
- Stack
- Heap
- Code Segments
- Startup Code
- Normal Code
- Exception Vectors
27
Static Memory Segments
Categories of Memory Segment Example
Declared Data Type Name
Absolute CONST DATA_AC const int a @ 0x1000 = 1;
Addressed
constants
Absolute DATA DATA_AN __no_init int a @ 0x1000;
addressed
data
Constants CONST DATA_C const int a = 1;
Non-zero initialized data DATA DATA_I int a = 1;
initialized
data
Initializers for the above CONST DATA_ID int a = 1;
for the above
Non-initialized data DATA DATA_N __no_init int a;
data
28
Zero-initialized data DATA DATA_Z int a;
Stack
Stack can contain:

- Auto variables and parameters not stored in registers;


- Return value of the function (unless it is passed in registers);
- Processor state during exceptions;
- Processor registers that should be restored before return;
- Stack Segments:

- For System & User Mode of ARM:


- CSTACK
- For Exception Modes of ARM:
- IRQ_STACK, FIQ_STACK
- SVC_STACK, UND_STACK, ABT_STACK
●The cstartup module initializes stack pointers (SP) to the end of each stack
segments.
Linker Command File:
● 29
-D_CSTACK_SIZE=2000
Heap
● Heap contains data allocated dynamically by:
C function “malloc()” (or one of its relatives);

C++ operator “new”;


● Heap Segment:
HEAP

HEAP is only included if dynamic memory allocation is


actually used.
● Linker Command File:
-D_HEAP_SIZE=2000

30
Code Segments
● Startup Code
● ICODE (CODE)
–cstartup: system setup from reset
–cmain: runtime initialization
–cexit: system termination
● Normal Code
● CODE (CODE): normal functions
● CODE_I (DATA): functions executing in RAM
● CODE_ID (CONST): initializers for the above
● Exception Vectors
31
● INTVEC (CODE)
Linker Configuration File (.icf)
Used by ILINK to determine locations where the segments can be

placed.
Default ICF Template:

$TOOLKIT_DIR$\config\lnkarm.icf
Check example projects for ICF samples of specific ARM processors.

●Customize the linker command file to suit the memory layout of specific
target system.

32
Oscilloscope Fundamentals
- What is an oscilloscope?
- Probing basics (low-frequency model)
- Making voltage and timing measurements
- Properly scaling waveforms on-screen
- Understanding oscilloscope triggering
- Oscilloscope performance specifications

33
What is an oscilloscope ?

Oscilloscopes convert electrical input signals into a visible trace on a screen.


●Oscilloscopes dynamically graph time-varying electrical signals in two dimensions (typically


voltage vs. time).
Oscilloscopes are used by engineers and technicians to test, verify, and debug electronic

designs.
Time domain & Frequency domain analysis.

CRO, DSO, MSO



34
Probing Basics

Probes are used to transfer the signal from the device-under-test to the

oscilloscope’s BNC inputs.


There are many different kinds of probes used for different and special

purposes (high frequency applications, high voltage applications, current, etc.


Most common type of probe is called as “Passive 10:1 Voltage Divider Probe”.

35
Passive 10:1 Voltage Divider Probe

● Passive includes no active elements such as transistors


or amplifiers.
● 10 to 1: Reduces the amplitude of the signal to the
scope's BNC input by a factor of 10. Also increases input
impedance by 10k.
36
Understanding the Scope's Display

● Waveform display area shown with grid lines(or divisions).


● Vertical spacing of grid lines relative to Volts/div setting.
● Horizontal spacing of grid lines relative to sec/div setting.
37
Making measurements – by Visual estimation

Ground level (0.0 V)


indicator

● Period (T) = 5 divisions x 1 µs/div = 5 µs Freq.= 1/T = 200 kHz


● V p-p = 6 divisions x 1 V/div = 6 V p-p
● V max = +4 divisions x 1V/div = +4 V, V min = ?
38
Making measurements – using cursors

● Manually position A & B cursors to desired measurement points.


● Scope automatically multiplies by the vertical and horizontal scaling factors
to provide absolute & delta measurements.
39
Primary Oscilloscope Setup Controls
Horizontal Scaling (s/div)
Horizontal Position

Trigger Level

Vertical Scaling (V/div)

Vertical Position

Input BNCs
Agilent’s DSO1000 Series Oscilloscope

40
Properly Scaling the Waveform
Initial Setup Condition (example) Optimum Setup Condition

● Setting up the scope's waveform is an iterative process of making


front panel adjustments until the desired “picture” is displayed on
screen.
● Adjust V/div, Vertical Position, s/div, Trigger Level knobs for
scaling the waveform. 41
Oscilloscope Performance Specifications
● “Bandwidth” is the most important oscilloscope specification.

Oscilloscope Frequency Response

● The frequency where an input sine wave is attenuated by 3 dB defines the


bandwidth of scope.
● -3 dB equates to ~ -30% amplitude error (-3 dB = 20 log )
42
Selecting the Right Bandwidth
Input = 100-MHz Digital Clock

Response using a 100-MHz BW scope Response using a 500-MHz BW scope


● Required BW for analog applications >= 3X highest sine wave
frequency.
● Required BW for digital applications >= 5X highest digital clock
rate.
43
Other Important Oscilloscope
Specifications
● Sample Rate (in samples/sec) – should be >= 4X BW
● Memory Depth – Determine the longest waveforms that can be captured
while still sampling at the scope's maximum sample rate.
● Number of Channels
● Waveform Update Rate – Faster update rate enhance probability of
capturing infrequently occuring circuit problems.
● Display Quality - Size, resolution, number of levels of intensity gradation.
● Advanced Triggering Modes – Time Qualified pulse widths, Pattern, Serial,
Pulse Violation(edge speed, setup/hold time), etc.

44
Logic Analysers

● Shows 0/1 – according to some threshold


● Benefits: Many channels, trigger on patterns, smart
triggering decides what to store, parallel data
● Disadvantages: Idealized waveforms, can be used with
only digital signals. 45
References

http://cp.literature.agilent.com/litweb/pdf/5989-8064EN.pdf
-
http://ftp.iar.se/WWWfiles/RX/webic/doc/EW_MigrationFormUBROF.pdf
-
http://cp.literature.agilent.com/litweb/pdf/5989-8064EN.pdf
- http://supp.iar.com/FilesPublic/UPDINFO/005832/arm/doc/EWARM_DDFFormat.pdf

46
Thank
You !

47

You might also like