Embedded Systems Real Time Operating Systems Lecture 2 1 Debugging Tools I just proved this algorithm is correct Good Ben but shouldn t you actually run it Software verification is a difficult but important phase Objectives Debugging hardware Stabilization Minimally intrusive debugging instruments Profiling White box versus black box testing Control and observability A logic analyzer is a multiple channel digital storage scope numerous digital signals at various points in time attached to strategic I O signals real time measurement attached to heart beats profile execution massive amount of information triggering to capture data at appropriate times must interpret the data nonintrusive good for real time observation of I O signals by Jonathan W Valvano Embedded Systems Real Time Operating Systems Lecture 2 2 Logic Analyzer Arm Digital Interface Digital Interface PF0 PF1 A logic analyzer and example output Show the digilentinc analog discovery www digilentinc com Products Detail cfm Prod ANALOG DISCOVERY Events that are observable in real time The input and output signals of the system Dumps record in real time observe later off line Extra output pins Software based debuggers breakpoint by replacing the instruction with a trap can not be performed when the software is in ROM Single step with periodic interrupts Write debugging information into flash so you can analyze systems even if power is lost Hardware based debuggers JTag exists on the microcomputer chip itself communicates with the debugging computer ability to observe software execution in real time hardware support to set breakpoints the ability to stop the computer and supports hardware breakpoints memory and I O ports are accessible while running by Jonathan W Valvano Embedded Systems Real Time Operating Systems Lecture 2 3 Debugging Theory rough and ready manual methods desk checking dumps and print statements Debugging instrument software code that is added for the purpose of debugging stabilize the system creating a test routine that fixes or stabilizes all inputs can reproduce the exact inputs over and over again modify the program change in our outputs is a function of modification and not due to a change in the input parameters non intrusive intrusive Intrusiveness is used as a measure of the degree of perturbation caused in program performance by an instrument Develop your own unique debugging style place all print statements in a unique column specific pattern in their names test a run time global flag leaves a copy of the code in the final system simplifies on site customer support Use conditional compilation performance and effectiveness by Jonathan W Valvano Embedded Systems Real Time Operating Systems Lecture 2 4 Black box Just inputs outputs Know what it does but not how it works Have pin numbers signal names on the connector White box testing Can probe inside Know both what it does and how it works Have internal schematics Functional debugging verification of input output parameters a static process where inputs are supplied the system is run and the outputs are compared against expected results Single Stepping or Trace Breakpoints without filtering Instrumentation print statements difficulty with print statements in embedded systems a standard printer may not be available print statement itself may so slow intrusive print hardware used for normal operation If you wish to use printf you need to create a fputc function like this int fputc int ch FILE f Serial OutChar ch return 1 by Jonathan W Valvano Embedded Systems Real Time Operating Systems Lecture 2 5 int fgetc FILE f return Serial InChar int ferror FILE f Your implementation of ferror return EOF Appropriate debugging methods Instrumentation dump into array without filtering a debugger instrument dumps strategic information into an array at run time observe the contents of the array at a later time use debugger to visualize when running long DebugList 100 unsigned int DebugCnt 0 void RecordIt long data if DebugCnt 100 return DebugList DebugCnt data DebugCnt Instrumentation dump into array with filtering A filter is a software hardware condition that must be true in order to place data into the array if condition RecordIt MyData Monitor using the LED display by Jonathan W Valvano Embedded Systems Real Time Operating Systems Lecture 2 6 A monitor is an independent output process executes very fast so is minimally intrusive small amounts of strategic information Examples LCD display LED s on individual otherwise unused output bits PF0 define PF0 define GPIO PORTF DATA R volatile unsigned long 0x40025004 volatile unsigned long 0x400253FC PF0 0x01 GPIO PORTF DATA R 0x01 PF0 0x00 GPIO PORTF DATA R 0x01 Performance Debugging verification of timing behavior of our system a dynamic process system is run and dynamic behavior compared to expected results Instrumentation with independent counter unsigned long Tbuf 100 unsigned int Tcnt 0 void RecordTime void if Tcnt 100 return Tbuf Tcnt NVIC ST CURRENT R 24 bit SysTick counter 20ns Tcnt Instrumentation Output Port by Jonathan W Valvano Embedded Systems Real Time Operating Systems 4804 6800 F0400020 4903 F8C103FC LDR LDR ORR LDR STR r0 pc 16 r0 0x400063FC r0 r0 0x00 r0 PORTC r0 r0 0x20 set bit 5 r1 pc 12 r1 0x40006000 r0 r1 0x3FC write PORTC Lecture 2 7 GPIO PORTC DATA R 0x20 This subroutine is nonreentrant because of the read modify write access to a global Show an example of how this assembly listing is found Run on board or on simulator Discuss compiler optimization define define define define define define define define define define GPIO PORTC DATA R GPIO PORTC0 GPIO PORTC1 GPIO PORTC2 GPIO PORTC3 GPIO PORTC4 GPIO PORTC5 GPIO PORTC6 GPIO PORTC7 GPIO PORTC12 volatile volatile volatile volatile volatile volatile volatile volatile volatile volatile unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned long long long long long long long long long long 0x400063FC 0x40006004 0x40006008 0x40006010 0x40006020 0x40006040 0x40006080 0x40006100 0x40006200 0x40006018 Bit specific addressing 2020 4902 6008 MOVS r0 0x20 LDR r1 pc 8 r1 0x40006080 STR r0 r1 0x00 set bit 5 GPIO PORTC5 0x20 This subroutine is reentrant because of the read modify write access is atomic define GPIO PORTF DATA BITS R define GPIO PORTF DATA R volatile unsigned long 0x40025000 volatile unsigned long 0x400253FC Create a MACRO for the pin PF1 LED Show data sheet for TM4F123 Measurement of Dynamic Efficiency measure
View Full Document
Unlocking...