Presentation is loading. Please wait.

Presentation is loading. Please wait.

Embedded Systems Principle of Debugger. Reference Materials kl.de/avr_projects/arm_projects/#winarmhttp://www.siwawi.arubi.uni-

Similar presentations


Presentation on theme: "Embedded Systems Principle of Debugger. Reference Materials kl.de/avr_projects/arm_projects/#winarmhttp://www.siwawi.arubi.uni-"— Presentation transcript:

1 Embedded Systems Principle of Debugger

2 Reference Materials http://billgatliff.com http://www.embedded.com/ http://www.siwawi.arubi.uni- kl.de/avr_projects/arm_projects/#winarmhttp://www.siwawi.arubi.uni- kl.de/avr_projects/arm_projects/#winarm http://twentyone.blogchina.com/ http://www.huihoo.org/mirrors/pub/embed/d ocument/debugger/ew_GDB_RSP.pdfhttp://www.huihoo.org/mirrors/pub/embed/d ocument/debugger/ew_GDB_RSP.pdf

3 Software Debugging

4 GDB Host PC Target Board gdb's Remote Serial Protocol (RSP) Debugging Stub/Agent GDB Server GDB

5 Debugging Agent/Stub Small Code Response to GDB Request –Read / Write Memory –Read / Write Register –Set / Remove Breakpoints Provide Debug Trap –Breakpoint exception –Invalid instruction exception –System error exception Transmit CPU Status Data to Remote Debugger Host PC Target Board gdb's Remote Serial Protocol (RSP) Debugging Agent/Stub GDB

6 Typical Debug Session localhost$ sh-hitachi-hms-gdb a.out GNU gdb 5.0 Copyright 2000 Free Software Foundation, Inc. (gdb) target remote /dev/ttyS0 (gdb) load Loading section.text, size 0x1280 vma 0x1000 Loading section.data, size 0x760 vma 0x2280 Loading section.stack, size 0x10 vma 0x30000 Start address 0x1000 Transfer rate: 53120 bits in <1 sec. (gdb) b main Breakpoint 1 at 0x8048476: file test.c, line 5. (gdb) continue Breakpoint 1, main () at test.c:5 5 for( i = 0; i < 10; i++ ) { (gdb) display j 1: j = 1074136126 (gdb) step 6 j = i * 2 + 1; 1: j = 1074136126 (gdb) step 5 for( i = 0; i < 10; i++ ) { 1: j = 1 (gdb) quit

7 GDB Remote Serial Protocol (RSP) RSP Message $ # CKSUM_MSN CKSUM_LSN Response of RSP Message + … - … Host PC Target Board gdb's Remote Serial Protocol (RSP) Debugging Agent/Stub GDB if the received checksum was correct, and the receiver is ready for the next packet if the received checksum was incorrect, and the message needs to be retransmitted sum of, keep last 8-bit, expressed in ASCII

8 RSP Example Read All Registers [gdb]$g#67 [target]+$0123456789abcdef0123456789abcdef...#xx Write All Registers [gdb] $G123456789abcdef0...#xx [target]+ $OK#9a Write Specific Registers [gdb] $P10=0040149c#b3 [target]+ $OK#9a Read Memory [gdb] $m4015bc,2#5a [target]+ $2f86#06 Write Memory [gdb] $ M4015cc,2:c320#6d [target] + $OK#9a Set register 16 to the value 0x40149c All register values Read two bytes, starting at address 0x4015bc Write the value 0xc320 to address 0x4015cc

9 RSP Example Step [gdb]$s#73 Continue [gdb] $c#63 Console Output [target] $O48656c6c6f2c20776f726c64210a#55 Prints “Hello, world!\n” on the gdb console

10 Request ? : Read current Status g : Read all registers G : Write all registers m , : Read memory M , : : Write meoory c : Continue s : Single step k : Kill RSP Command List Response “” : Command not support E : Error OK : w : Exit X : Terminate at signal S : Stop at signal O : Console output

11 Detailed Example of a GDB Session write break point write memory run until stop read memory stopped, response with register value that GDB may be interested response with memory data stopped, response with register value that GDB may be interested

12 Break Point & Step Break point Program Codes GDB Stub Set Breakpoint Run User Code Wait for Exception Report CPU status Remove Breakpoint Program Stops Enter Exception ISR Waiting For Debugging Command … … … … … … … … … … … …

13 Use GDB with Embedded Linux user board GDB Ethernet Cable GBD Server Remote PC Running Linux

14 Transfer Binary to Board Transfer Method Ethernet FTP NFS UART Z-Modem Root Image USB-Disk CF/SD-Card Storage RAM FlashROM Remote Disk Communication Applications on the Development Board Device Driver for These Storage Rebuild and download Root Image Network Hardware

15 Bootloader Linux need to copy kernel from ROM to RAM Kernel Image Root Image ROM User Data Storage Kernel Root Image RAM User Data Storage User Apps

16 NFS Debugging Mode Kernel RAM User Data Storage NFS Server Ethernet Chip User Apps Avoid repeatedly re-write Flashrom

17 Start Remote Debug 192.168.5.111 gdbserver 192.168.5.111:1234 Hello_arm xxx-elf-linux-gdb Hello_arm target remote 192.168.5.222:1234 IP address of PC (Can be found by command “ ifconfig ”) run from the development board Run from PC IP address of development board Run from PC

18 Remote Debugging Commands br main set break point at main() cont continue run (stopped at main()) l list source code n step n

19 Other Useful GDB Command Stop running “Ctrl-C” exit GDB quit run program run Set breakpoint break main Clear breakpoint clear main Check existing breakpoint info b Step ( enter subroutine ) s Step ( skip subroutine ) n Show call stack bt check memory 0x200 x 0x200 Check variable m p m Change value of m to 7 set m=7 Display reg. PC p/x $pc Dislpay reg. SP p/x $sp Change PC to 0 set $pc=0 Disassember from addr. 0 x/5i 0x0


Download ppt "Embedded Systems Principle of Debugger. Reference Materials kl.de/avr_projects/arm_projects/#winarmhttp://www.siwawi.arubi.uni-"

Similar presentations


Ads by Google