26
COMPUTER SYSTEM LABORATORY Lab8 - Debugging II

COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

Embed Size (px)

Citation preview

Page 1: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

COMPUTER SYSTEM

LABORATORYLab8 - Debugging II

Page 2: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 262Lab 8

Experimental Goal

•Learn how to debug Linux in source-level by Domingo and diagnose target boards.

2013/11/5

Page 3: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 263Lab 8

Environment

• Host System• Windows XP

• Build System• VirtualBox + Ubuntu 8.04

• Target System• Creator XScale PXA270

• Software• Domingo

• Linux kernel

• Microtime diag program

• You can download all software from RSWiki CSL Course Software2013/11/5

Page 4: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 264Lab 8

Introduction to Debugging

•Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected.

• In Lab1 and Lab2, we introduce Domingo, which is an integrated development environment developed by Microtime Computer Inc.• Domingo can be used to not only transfer binaries to RAM but also

debug in source-level.

• In this lab, we will introduce how to debug Linux kernel in source-level.

2013/11/5

reference: wikipedia - debugging, http://en.wikipedia.org/wiki/Debugging

Page 5: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 265Lab 8

Prepare Linux Kernel and Source Codes

•We prepare a Linux kernel with some bugs for this Lab.

•Step1: download Linux source codes (linux-2.6.15.3.lab8.tar.gz).

•Step2: please refer to Lab5 to configure creator_pxa270_partitions[] for your filesystem.

•Step3: compile the new Linux kernel.

•Step4: convert to U-Boot bootable image.• You can set image name in mkimage to identify different kernel images.

•Step5: copy to PXA270.

2013/11/5

Page 6: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 266Lab 8

Install Samba Server (1/4)

•Before using Domingo, you should make sure that you can access your Linux source codes in Windows. However, we can not directly extract Linux source codes in Windows because there are many symbolic links in the source codes. To preserved these links, the source codes are usually extracted in Linux, e.g., in build system, Ubuntu8.04.• Therefore, to access Linux source codes in Windows, we need to set up

a samba server in the build system.

•Samba is a free implementation of the SMB/CIFS networking protocol originally developed by Andrew Tridgell. • Through SMB/CIFS protocol, we can share files between Windows XP

and Linux by network neighborhood ( 網路芳鄰 ).

2013/11/5

reference: wikipedia - samba, http://en.wikipedia.org/wiki/Samba_%28software%29

Page 7: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 267Lab 8

Install Samba Server (2/4)

•Step1: install samba server in the build system.• % sudo apt-get install samba

•Step2: add an user account for samba service.• % sudo smbpasswd –a <user name>

• You can use the Linux account created in Lab1. Or add a new account <user name> to Linux by useradd before executing smbpasswd.

2013/11/5

Page 8: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 268Lab 8

Install Samba Server (3/4)

• Step3: suppose your Linux source codes are in <path of Linux> (slide5) and the shared folder is <share>, you can add a new entry in /etc/samba/smb.conf.

[<share>]

path = <path of Linux>

browseable = yes

read only = no

create mask = 0664

directory mask = 0755

security = share

• Please also set the workgroup in [global] entry to the workgroup of host system (Windows XP), e.g., MSHOME, etc.• You can check the workgroup in Windows XP by right-clicking on

“ 我的電腦” “內容” “電腦名稱” .2013/11/5

Page 9: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 269Lab 8

Install Samba Server (4/4)

•Step4: restart the samba service.• % sudo /etc/init.d/samba restart

2013/11/5

Page 10: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2610Lab 8

Map Network Drive in Windows (1/3)

•Step1: refer to Lab7 to set up LAN IP address for Windows XP and Ubuntu8.04.

•Step2: check whether you can see Ubuntu in “ 網路芳鄰” or not.• “ 我的電腦” “網路上的芳鄰” “檢視工作群組電腦”• Or type \\<build-system-ip>\ in the file browser.

2013/11/5

Page 11: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2611Lab 8

Map Network Drive in Windows (2/3)

• If you can not see the shared folder, you can:• Check network configuration in Ubuntu and VirtualBox. (Refer to Lab7)

• Check firewall in Windows XP.

• Restart virtual machine and PC.

• Step3: open command line in Windows XP.• “ 開始” “執行 ...”

• Type cmd and execute.

• Step4: map the directory to S: drive.• % net use s: \\<build-system-ip>\<share> /persistent:yes /user:<user> <password>• <build-system-ip> is the IP of Ubuntu8.04.

• <share> is the same as in slide8.

• <user> and <password> are the same as slide7.

2013/11/5

Page 12: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2612Lab 8

Map Network Drive in Windows (3/3)

•You can check the drive status by:• % net use

•Or delete the drive by:• % net use s: /DELETE

•Or read the usage of net use command by:• % net use /?

2013/11/5

Page 13: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2613Lab 8

Domingo Configuration (1/2)

•Step1: create a new project for PXA270.

•Step2: configure “OS support”.• “Config” “OS support” “Linux 2.6”

•Step3: configure Linux path.• “Linux 2.6” “Linux Path Setting...”

• Linux Debug Information (vmlinux) = the path of vmlinux

• Linux dist Path = the path of linux directory

• Device Driver Path = the path of device drivers

2013/11/5

Page 14: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2614Lab 8

Domingo Configuration (2/2)

•Step4: since the path of Linux source codes in Ubuntu is different from Windows XP, we need to configure “ELF path substitution” to replace the path.• “Debug” “Default ELF Path Substitution...”

• Path Prefix = your path of kernel compilation

• Replace As = S:\

2013/11/5

Page 15: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2615Lab 8

Download Linux in Domingo (1/3)

• Step1: connect to your PXA270 in Domingo.

• Step2: load debug module.• “Debug” “Load Module...”

• Choose vmlinux.

• Step3-1: configure the module.• ModuleFormat = Elf for ARM

• Options = ELF path substitution

• Download Raw Data = unchecked

• Goto Main Address = 0xa0008000;start_kernel

• Linux - Dynamic Loaded Module =checked

2013/11/5

Page 16: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2616Lab 8

Download Linux in Domingo (2/3)

•Step3-2: • Additional Modules... =

• Set the path of zImage, i.e., <linux directory>\arch\arm\boot\zImage.

• Set the start address to P;a0008000.

•Step4: execute “UART View” or putty to access the console of PXA270.

•Step5: click “Ok” to start downloading Linux.

2013/11/5

Page 17: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2617Lab 8

Download Linux in Domingo (3/3)

•After downloading is complete, you will see the Linux is stopped at start_kernel() function.

•Now, you can start debugging the Linux kernel.

2013/11/5

Page 18: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2618Lab 8

Troubleshooting

• If you can not download the Linux image, you may refer to the following settings (TA’s):• Workgroup = MSHOME

• <build-system-ip> = 192.168.0.101

• <path of Linux> = /home/lab202/CSL/10201/lab8/pxa270/

• <share> = Creator

• Path of linux directory = /home/lab202/CSL/10201/lab8/pxa270/linux

• Path of vmlinux = /home/lab202/CSL/10201/lab8/pxa270/linux/vmlinux

• Path of Linux device drivers = /home/lab202/CSL/10201/lab8/pxa270/linux/drivers

2013/11/5

Page 19: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2619Lab 8

Debug Linux in Domingo (1/3)

•You can select specific functions on the menu bar for debugging.• M: images.

• F: source files in the specific image M.

• L: functions in the specific source file F.

2013/11/5

Page 20: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2620Lab 8

Debug Linux in Domingo (2/3)

•You can set breakpoints by clicking the line number.• Breakpoints can be cancelled by clicking again.

•After setting breakpoints, you can continue the program by following operations.

2013/11/5

breakpoints

Page 21: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2621Lab 8

Debug Linux in Domingo (3/3)

•You can see register values in register window.

•You also can watch variables in watch list.

•Please refer to Domingo tutorial for more information.• “View” “Tutorial”

2013/11/5

Page 22: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2622Lab 8

Debug Linux Kernel

•Please use Domingo to find out why the values of memory clock and system bus clock are zero.

2013/11/5

?

Page 23: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2623Lab 8

Diagnose Target Boards (1/2)

•Microtime provides a program diag that can help developers diagnose peripheral devices on PXA270, e.g., SDRAM, flash, LED, CCD, LCD, etc. You can diagnose the target board by yourself first if you think it is broken.

•Step1: download diag (diag_ram.bin).

•Step2: copy diag_ram.bin to flash address 0x40000 on PXA270.• The erased end address is 0x7ffff (2 sectors).

• Please refer to Lab5 to configure creator_pxa270_partitions[] for diag.

•Step3: modify bootcmd environment variable in U-Boot.• u-boot$ setenv bootcmd run diag

• u-boot$ saveenv

• You can change bootcmd back to “run linux” for booting Linux.

2013/11/5

Page 24: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2624Lab 8

Diagnose Target Boards (2/2)

•Step4: reset PXA270 and then you will see the menu of diag on the LCD.• You can select the menu item by pressing keys on the 4x4 keypad.

• You can check LEDs, LCD, keypads, and CMOS for coming Labs.

2013/11/5

LCD 4x4 Keypad

Page 25: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2625Lab 8

Diagnose Target Boards (Optional)

•Furthermore, Microtime provides a whole image which includes bootloader, diag, Linux kernel, and root filesystem. It also can help developers to restore factory default.

•Step1: download the image (som-pxa270-u4-v2.0.bin).

•Step2: copy som-pxa270-u4-v2.0.bin to flash address 0x0 on PXA270.• The erased end address is 0x167ffff (183 sectors).

• It will take about 18 minutes.

• U-Boot will execute diag in default setting.

2013/11/5

Memory Layout of the Image

Page 26: COMPUTER SYSTEM LABORATORY Lab8 - Debugging II. Lab 8 Experimental Goal Learn how to debug Linux in source-level by Domingo and diagnose target boards

/ 2626Lab 8

Lab Requirement & Bonus

•Show how you find and correct the bug of Linux kernel we gave.

•Bonus:There is no Bonus here.

•Please send your report to both TAs.• [email protected], [email protected]

• Please use this title format: [CSL] G# Lab# Ver#

• E.g., [CSL] G13 Lab8 Ver1

2013/11/5