Debug the Linux kernel and drivers on arm using JTAG+GDB

Source: Internet
Author: User

Debugging objects for the company a piece of s3c2440 board, the debugger is based on the ft2232d openjtag,pc operating system for ubunut14.04.2 X64,jtag->gdb Bridge Openocd 0.9.0.
1. Prepare the kernel source code
Copy out two copies of the exact same kernel source code, without debugging information of a burn/download to the board, plus debugging information for debugging. Here, download the kernel in a uboot+nfs way.
~/buildspacce/linux-2.6.32.2_debug
~/buildspacce/linux-2.6.32.2_release
Debug version of the source to do the following configuration
Kernel Hacking---> [*] Kernel debugging
[*] Compile the kernel with debug info
Need to debug the driver, compile the specified kernel source path, should be the debug version of the kernel source code.
"One" debugging the kernel from the beginning
1. Configure OPENOCD
2. Power-On
Connecting arm boards with Openjtag
Connecting Openjtag with PC
Power on ARM Board
3. Open a terminal and start OPENOCD

sudo /opt/openocd/bin/openocd-f ~/.openocd/openjtag.cfg-f/opt/openocd/share/openocd/scripts/target/ Samsung_s3c2440.cfg

4. Open a terminal to access Openocd via Telnet

127.0. 0.1:4444

Enter the following command in Telnet, reset arm and stop running to add a breakpoint before the kernel starts.
For jtag reasons, your system may not start up on its own and reset will not start uboot.

> Reset Halt

5. Open a different terminal, switch to the kernel source root directory (need to configure and compile), start gdb.

Path= $PATH:/opt/arm-linux-gcc/s3c2440_4. 4.3/~/buildspacce/linux-2.6. 32.2_debug arm-none-linux-gnueabi-gdb./vmlinux-d.

Connect Openocd in GDB and set the kernel entry address as a breakpoint

127.0. 0.1:3333
Remote Debugging using:3333
0x000000ac in?? ()
(GDB) B *0x30008040
(GDB) C
Continuing.

Breakpoint 1, 0x30008040 in?? ()

0x30008040 This address originates from Uboot's printing (Minicom was opened earlier)

Entry point:  30008040

Then you can start debugging the kernel from scratch.

"Two" debugging a running kernel.
1. Connect arm, Openjtag, PC, start OPENOCD.
2. Use Uboot to download the kernel, or boot the kernel from Nand/nor, and let the arm system run normally (shell is available).
3.telnet to Openocd, using

Halt

instruction to stop the ARM processor.
4. Start GDB

Path= $PATH:/opt/arm-linux-gcc/s3c2440_4. 4.3/~/buildspacce/linux-2.6.  + . 2_debugarm-none-linux-gnueabi-gdb./vmlinux-d.

The kernel stops in hibernation when the OPENOCD is connected in gdb.

(GDB) Target remote:3333
Remote debugging using:3333s3c24xx_default_idle () at Arch/arm/mach-s3c2410/include/mach/system.h : 0(i++) {

5. The kernel is yours ...

"Three" debug kernel modules
1. Connect arm, Openjtag, PC, start OPENOCD, let the system run normally.
2. Through the arm serial port, Telnet, ssh and other ways to load the target driver, here is the kernel module debugging Spi_slave.ko
3. View the Load address (virtual address) of the kernel module

Lsmod305500xbf000000cat /sys/module/spi_slave/ sections/. Data0xbf000730cat /sys/module/spi_slave/sections/. BSS  0xbf00091c

4. Halt the arm system, start the GDB,GDB connection OPENOCD, load the kernel module symbol table

(GDB) Target remote:3333Remote debugging using:3333S3c24xx_default_idle () at Arch/arm/mach-s3c2410/include/mach/system.h: + +         for(i =0; I < -; i++) {(GDB) Add-symbol-file~/buildspace/spi_slave/spi_slave.o0xbf000000-S. Data0xbf000730-S. BSS0xbf00091cAdd symbol table fromfile "/HOME/CJH/BUILDSPACE/SPI_SLAVE/SPI_SLAVE.O"At . Text_addr=0xbf000000. Data_addr=0xbf000730. Bss_addr=0xbf00091c(y or N) yreading symbols from/HOME/CJH/BUILDSPACE/SPI_SLAVE/SPI_SLAVE.O ... Done.

Currently, it is often impossible to print the variables in the driver and cannot add breakpoints because there is a problem with the conversion of the virtual address to the physical address. The solution is not yet clear.

Debug the Linux kernel and drivers on arm using JTAG+GDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.