IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> i.MX 6ULL 驱动开发 二:搭建 KGDB 调试 linux 内核和驱动环境 -> 正文阅读

[系统运维]i.MX 6ULL 驱动开发 二:搭建 KGDB 调试 linux 内核和驱动环境

一、参考

Linux 官方资料:Using kgdb, kdb and the kernel debugger internals — The Linux Kernel documentation

参考博客:使用KGDB调试Linux驱动(以imx6ull开发板为例)_weixin_38832162的博客-CSDN博客_kgdb 调试驱动

二、概述

KGDB是 Linux 内核提供的用于调试内核的源码级调试工具,支持断点设置,单步调试等源码调试常用功能,类似于在用户空间用gdb调试应用程序。

KGDB 从形式上来说类似于 GDB server,你需要两台设备,一台主机,用于运行普通的 GDB 程序,一台被调试设备,需要安装所需调试的内核或者驱动,同时运行 KGDB。KGDB 与主机通过串口或网口进行通信,所以要在内核的启动参数里指定 KGDB 所需使用相关参数。

三、在 ubuntu 安装串口助手

1、安装 minicom

sudo apt-get install minicom

2、连接usb设备前查看 ttyusb 设备

onlylove@ubuntu:~$ ls /dev/tty*
/dev/tty    /dev/tty18  /dev/tty28  /dev/tty38  /dev/tty48  /dev/tty58      /dev/ttyS0   /dev/ttyS19  /dev/ttyS29
/dev/tty0   /dev/tty19  /dev/tty29  /dev/tty39  /dev/tty49  /dev/tty59      /dev/ttyS1   /dev/ttyS2   /dev/ttyS3
/dev/tty1   /dev/tty2   /dev/tty3   /dev/tty4   /dev/tty5   /dev/tty6       /dev/ttyS10  /dev/ttyS20  /dev/ttyS30
/dev/tty10  /dev/tty20  /dev/tty30  /dev/tty40  /dev/tty50  /dev/tty60      /dev/ttyS11  /dev/ttyS21  /dev/ttyS31
/dev/tty11  /dev/tty21  /dev/tty31  /dev/tty41  /dev/tty51  /dev/tty61      /dev/ttyS12  /dev/ttyS22  /dev/ttyS4
/dev/tty12  /dev/tty22  /dev/tty32  /dev/tty42  /dev/tty52  /dev/tty62      /dev/ttyS13  /dev/ttyS23  /dev/ttyS5
/dev/tty13  /dev/tty23  /dev/tty33  /dev/tty43  /dev/tty53  /dev/tty63      /dev/ttyS14  /dev/ttyS24  /dev/ttyS6
/dev/tty14  /dev/tty24  /dev/tty34  /dev/tty44  /dev/tty54  /dev/tty7       /dev/ttyS15  /dev/ttyS25  /dev/ttyS7
/dev/tty15  /dev/tty25  /dev/tty35  /dev/tty45  /dev/tty55  /dev/tty8       /dev/ttyS16  /dev/ttyS26  /dev/ttyS8
/dev/tty16  /dev/tty26  /dev/tty36  /dev/tty46  /dev/tty56  /dev/tty9       /dev/ttyS17  /dev/ttyS27  /dev/ttyS9
/dev/tty17  /dev/tty27  /dev/tty37  /dev/tty47  /dev/tty57  /dev/ttyprintk  /dev/ttyS18  /dev/ttyS28
onlylove@ubuntu:~$

3、将开发板串口连接到 VMware 虚拟机中

4、查看 ttyusb 设备

onlylove@ubuntu:~$ ls /dev/tty*
/dev/tty    /dev/tty18  /dev/tty28  /dev/tty38  /dev/tty48  /dev/tty58      /dev/ttyS0   /dev/ttyS19  /dev/ttyS29
/dev/tty0   /dev/tty19  /dev/tty29  /dev/tty39  /dev/tty49  /dev/tty59      /dev/ttyS1   /dev/ttyS2   /dev/ttyS3
/dev/tty1   /dev/tty2   /dev/tty3   /dev/tty4   /dev/tty5   /dev/tty6       /dev/ttyS10  /dev/ttyS20  /dev/ttyS30
/dev/tty10  /dev/tty20  /dev/tty30  /dev/tty40  /dev/tty50  /dev/tty60      /dev/ttyS11  /dev/ttyS21  /dev/ttyS31
/dev/tty11  /dev/tty21  /dev/tty31  /dev/tty41  /dev/tty51  /dev/tty61      /dev/ttyS12  /dev/ttyS22  /dev/ttyS4
/dev/tty12  /dev/tty22  /dev/tty32  /dev/tty42  /dev/tty52  /dev/tty62      /dev/ttyS13  /dev/ttyS23  /dev/ttyS5
/dev/tty13  /dev/tty23  /dev/tty33  /dev/tty43  /dev/tty53  /dev/tty63      /dev/ttyS14  /dev/ttyS24  /dev/ttyS6
/dev/tty14  /dev/tty24  /dev/tty34  /dev/tty44  /dev/tty54  /dev/tty7       /dev/ttyS15  /dev/ttyS25  /dev/ttyS7
/dev/tty15  /dev/tty25  /dev/tty35  /dev/tty45  /dev/tty55  /dev/tty8       /dev/ttyS16  /dev/ttyS26  /dev/ttyS8
/dev/tty16  /dev/tty26  /dev/tty36  /dev/tty46  /dev/tty56  /dev/tty9       /dev/ttyS17  /dev/ttyS27  /dev/ttyS9
/dev/tty17  /dev/tty27  /dev/tty37  /dev/tty47  /dev/tty57  /dev/ttyprintk  /dev/ttyS18  /dev/ttyS28  /dev/ttyUSB0
onlylove@ubuntu:~$

ttyUSB0:与开发板连接的 USB 设备号。

5、minicom 使用教程

minicom 的使用_002237的博客-CSDN博客_minicom使用

四、调试 Linux 内核

1、开启 Linux 内核的 KGDB 选项

linux内核调试环境搭建(VM_Centos+KGDB) - 简书 (jianshu.com)

2、设置kgdboc参数

setenv bootargs 'console=ttymxc0,115200 kgdboc=ttymxc0,115200 kgdbwait root=/dev/nfs nfsroot=192.168.6.129:/home/onlylove/my/nfs,proto=tcp,nfsvers=4 rw ip=192.168.6.200:192.168.6.129:192.168.6.2:255.255.255.0::eth0:off'
saveenv

kgdboc的启动参数:kgdboc=ttymxc0,115200

  • ttymxc0 是所需使用的串口设备名
  • 115200 代表波特率
  • kgdbwait 是一个启动参数

3、启动 linux

U-Boot 2016.03 (Aug 20 2022 - 00:46:14 -0700)                                
                                                                             
CPU:   Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 41C
Reset cause: POR                        
Board: MX6ULL ALIENTEK EMMC             
I2C:   ready                            
DRAM:  512 MiB                          
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
unsupported panel ATK-LCD-7-1024x600
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc0 is current device
Net:   FEC1
Normal Boot
Hit any key to stop autoboot:  0 
FEC1 Waiting for PHY auto negotiation to complete.... done
Using FEC1 device
TFTP from server 192.168.6.129; our IP address is 192.168.6.20
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ##############
         2.1 MiB/s
done
Bytes transferred = 5916896 (5a48e0 hex)
Using FEC1 device
TFTP from server 192.168.6.129; our IP address is 192.168.6.20
Filename 'imx6ull-alientek-emmc.dtb'.
Load address: 0x83000000
Loading: ###
         2.5 MiB/s
done
Bytes transferred = 39280 (9970 hex)
Kernel image @ 0x80800000 [ 0x000000 - 0x5a48e0 ]
## Flattened Device Tree blob at 83000000
   Booting using the fdt blob at 0x83000000
   Using Device Tree in place at 83000000, end 8300c96f

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.1.15 (onlylove@ubuntu) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #2 SMP PREEMPT Sat Sep 10 21:40:18 PDT2
CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Freescale i.MX6 ULL 14x14 EVK Board
Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB
Reserved memory: initialized node linux,cma, compatible id shared-dma-pool
Memory policy: Data cache writealloc
PERCPU: Embedded 12 pages/cpu @8bb2f000 s16768 r8192 d24192 u49152
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttymxc0,115200 kgdboc=ttymxc0,115200 kgdbwait root=/dev/nfs nfsroot=192.168.6.129:/home/onlylof
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 180184K/524288K available (7312K kernel code, 334K rwdata, 2528K rodata, 404K init, 457K bss, 16424K reserved, 3276)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xa0800000 - 0xff000000   (1512 MB)
    lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
    pkmap   : 0x7fe00000 - 0x80000000   (   2 MB)
    modules : 0x7f000000 - 0x7fe00000   (  14 MB)
      .text : 0x80008000 - 0x809a44e0   (9842 kB)
      .init : 0x809a5000 - 0x80a0a000   ( 404 kB)
      .data : 0x80a0a000 - 0x80a5d8a0   ( 335 kB)
       .bss : 0x80a60000 - 0x80ad2444   ( 458 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
        Additional per-CPU info printed with stalls.
        RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
NR_IRQS:16 nr_irqs:16 16
mxc_clocksource_init 3000000
Switching to timer-based delay loop, resolution 333ns
sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns
clocksource mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
/cpus/cpu@0 missing clock-frequency property
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x80008280 - 0x800082f0
Brought up 1 CPUs
SMP: Total of 1 processors activated (6.00 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
device-tree: Duplicate name in lcdif@021c8000, renamed to "display#1"
VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 8 bytes.
imx6ul-pinctrl 20e0000.iomuxc: Invalid fsl,pins property in node /soc/aips-bus@02000000/iomuxc@020e0000/imx6ul-evk/flexcan2p
imx6ul-pinctrl 20e0000.iomuxc: Invalid fsl,pins property in node /soc/aips-bus@02000000/iomuxc@020e0000/imx6ul-evk/uart2dtep
imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
imx6ul-pinctrl 2290000.iomuxc-snvs: Invalid fsl,pins property in node /soc/aips-bus@02200000/iomuxc-snvs@02290000/imx6ul-evp
imx6ul-pinctrl 2290000.iomuxc-snvs: initialized IMX pinctrl driver
mxs-dma 1804000.dma-apbh: initialized
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c i2c-0: IMX I2C adapter registered
i2c i2c-0: can't use DMA
i2c i2c-1: IMX I2C adapter registered
i2c i2c-1: can't use DMA
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource mxc_timer1
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
imx rpmsg driver is registered.
Bus freq driver module loaded
futex hash table entries: 256 (order: 2, 16384 bytes)
VFS: Disk quotas dquot_6.6.0
VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
jffs2: version 2.2. (NAND) ?? 2001-2006 Red Hat, Inc.
fuse init (API version 7.23)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
imx-weim 21b8000.weim: Driver registered.
backlight supply power not found, using dummy regulator
21c8000.lcdif supply lcd not found, using dummy regulator
mxsfb 21c8000.lcdif: failed to find mxc display driver 
Console: switching to colour frame buffer device 128x37
mxsfb 21c8000.lcdif: initialized
imx-sdma 20ec000.sdma: no event needs to be remapped
imx-sdma 20ec000.sdma: loaded firmware 3.3
imx-sdma 20ec000.sdma: initialized
2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 19, base_baud = 5000000) is a IMX
console [ttymxc0] enabled
21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 233, base_baud = 5000000) is a IMX
KGDB: Registered I/O driver kgdboc
KGDB: Waiting for connection from remote gdb...

通过日志可以确定 KGDB 已经启动成功了,正在等待远端 GDB 连接。

4、调试内核

1、强行关闭minicom,因为GDB调试中需要使用minicom。

2、输入如下指令

arm-linux-gnueabihf-gdb ./vmlinux

3、设置串口助手

set serial baud 115200

4、gdb通过minicom连接开发板

target remote /dev/ttyUSB0

5、调试日志

onlylove@ubuntu:~/my/linux/linux-imx-rel_imx_4.1.15_2.1.0_ga_alientek$ arm-linux-gnueabihf-gdb ./vmlinux
GNU gdb (Linaro_GDB-2017.01) 7.10.1.20160210-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./vmlinux...done.
(gdb) set serial baud 115200
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
0x8009d45c in arch_kgdb_breakpoint () at ./arch/arm/include/asm/outercache.h:142
142			outer_cache.sync();
(gdb)
(gdb) list
137	 * buffers are drained.
138	 */
139	static inline void outer_sync(void)
140	{
141		if (outer_cache.sync)
142			outer_cache.sync();
143	}
144	#else
145	static inline void outer_sync(void)
146	{ }
(gdb)

通过以上日志可以确定,gdb连接开发板成功。

五、解决日志输出和GDB使用串口冲突问题

问题:日志输出和KGDB共用串口,因此,在使用KGDB时,需要强行关闭日志输出。

解决方案:agent-proxy

1、下载 agent-proxy

kernel/kgdb/agent-proxy.git - agent-proxy for kgdb

git clone git://git.kernel.org/pub/scm/utils/kernel/kgdb/agent-proxy.git
onlylove@ubuntu:~/my/demo$ pwd
/home/onlylove/my/demo
onlylove@ubuntu:~/my/demo$ ls
onlylove@ubuntu:~/my/demo$ git clone git://git.kernel.org/pub/scm/utils/kernel/kgdb/agent-proxy.git
Cloning into 'agent-proxy'...
remote: Enumerating objects: 80, done.
remote: Counting objects: 100% (80/80), done.
remote: Compressing objects: 100% (79/79), done.
remote: Total 80 (delta 46), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (80/80), 39.67 KiB | 84.00 KiB/s, done.
Resolving deltas: 100% (46/46), done.
onlylove@ubuntu:~/my/demo$ ls
agent-proxy
onlylove@ubuntu:~/my/demo$

2、编译

make
onlylove@ubuntu:~/my/demo/agent-proxy$ pwd
/home/onlylove/my/demo/agent-proxy
onlylove@ubuntu:~/my/demo/agent-proxy$ ls
agent-proxy.c  agent-proxy.h  agent-proxy-rs232.c  COPYING  Example  kdmx  Makefile  README.TXT
onlylove@ubuntu:~/my/demo/agent-proxy$ make
gcc -DAGENT_VER=1.97 -g -Wall -Wno-unused-parameter -Dlinux -c agent-proxy.c -o agent-proxy.o
gcc -DAGENT_VER=1.97 -g -Wall -Wno-unused-parameter -Dlinux -c agent-proxy-rs232.c -o agent-proxy-rs232.o
gcc -DAGENT_VER=1.97 -g -Wall -Wno-unused-parameter -Dlinux -o agent-proxy agent-proxy.o agent-proxy-rs232.o 
onlylove@ubuntu:~/my/demo/agent-proxy$ ls
agent-proxy    agent-proxy.h  agent-proxy-rs232.c  COPYING  kdmx      README.TXT
agent-proxy.c  agent-proxy.o  agent-proxy-rs232.o  Example  Makefile
onlylove@ubuntu:~/my/demo/agent-proxy$

3、将 agent-proxy 拷贝到 /bin 目录下

sudo cp agent-proxy /bin
onlylove@ubuntu:~/my/demo/agent-proxy$ ls
agent-proxy    agent-proxy.h  agent-proxy-rs232.c  COPYING  kdmx      README.TXT
agent-proxy.c  agent-proxy.o  agent-proxy-rs232.o  Example  Makefile
onlylove@ubuntu:~/my/demo/agent-proxy$ sudo cp agent-proxy /bin
onlylove@ubuntu:~/my/demo/agent-proxy$ ls /bin/agent-proxy -l
-rwxr-xr-x 1 root root 70960 Sep 10 22:29 /bin/agent-proxy
onlylove@ubuntu:~/my/demo/agent-proxy$

4、开启 agent-proxy

agent-proxy 5550^5551 0 /dev/ttyUSB0,115200

agent-proxy 将 ttyUSB0 这个端口复用为两个 telnet端口。

onlylove@ubuntu:~$ 
onlylove@ubuntu:~$ agent-proxy 5550^5551 0 /dev/ttyUSB0,115200
Agent Proxy 1.97 Started with: 5550^5551 0 /dev/ttyUSB0,115200
Agent Proxy running. pid: 1712

注意:以上终端不可以关闭。

5、使用 agent-proxy 开启日志终端

telnet localhost 5550
onlylove@ubuntu:~$ telnet localhost 5550
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

6、开启开发板

onlylove@ubuntu:~$ telnet localhost 5550
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.


U-Boot 2016.03 (Aug 20 2022 - 00:46:14 -0700)

CPU:   Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 48C
Reset cause: POR
Board: MX6ULL ALIENTEK EMMC
I2C:   ready
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
unsupported panel ATK-LCD-7-1024x600
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc0 is current device
Net:   FEC1
Normal Boot
Hit any key to stop autoboot:  0 
FEC1 Waiting for PHY auto negotiation to complete.... done
Using FEC1 device
TFTP from server 192.168.6.129; our IP address is 192.168.6.20
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 ##############
	 2.2 MiB/s
done
Bytes transferred = 5916896 (5a48e0 hex)
Using FEC1 device
TFTP from server 192.168.6.129; our IP address is 192.168.6.20
Filename 'imx6ull-alientek-emmc.dtb'.
Load address: 0x83000000
Loading: ###
	 2.5 MiB/s
done
Bytes transferred = 39280 (9970 hex)
Kernel image @ 0x80800000 [ 0x000000 - 0x5a48e0 ]
## Flattened Device Tree blob at 83000000
   Booting using the fdt blob at 0x83000000
   Using Device Tree in place at 83000000, end 8300c96f

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.1.15 (onlylove@ubuntu) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #2 SMP PREEMPT Sat Sep 10 21:40:18 PDT 2022
CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Freescale i.MX6 ULL 14x14 EVK Board
Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB
Reserved memory: initialized node linux,cma, compatible id shared-dma-pool
Memory policy: Data cache writealloc
PERCPU: Embedded 12 pages/cpu @8bb2f000 s16768 r8192 d24192 u49152
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttymxc0,115200 kgdboc=ttymxc0,115200 kgdbwait root=/dev/nfs nfsroot=192.168.6.129:/home/onlylove/my/nfs,proto=tcp,nfsvers=4 rw ip=192.168.6.200:192.168.6.129:192.168.6.2:255.255.255.0::eth0:off
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 180184K/524288K available (7312K kernel code, 334K rwdata, 2528K rodata, 404K init, 457K bss, 16424K reserved, 327680K cma-reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xa0800000 - 0xff000000   (1512 MB)
    lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
    pkmap   : 0x7fe00000 - 0x80000000   (   2 MB)
    modules : 0x7f000000 - 0x7fe00000   (  14 MB)
      .text : 0x80008000 - 0x809a44e0   (9842 kB)
      .init : 0x809a5000 - 0x80a0a000   ( 404 kB)
      .data : 0x80a0a000 - 0x80a5d8a0   ( 335 kB)
       .bss : 0x80a60000 - 0x80ad2444   ( 458 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
	Additional per-CPU info printed with stalls.
	RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
NR_IRQS:16 nr_irqs:16 16
mxc_clocksource_init 3000000
Switching to timer-based delay loop, resolution 333ns
sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns
clocksource mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
/cpus/cpu@0 missing clock-frequency property
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x80008280 - 0x800082f0
Brought up 1 CPUs
SMP: Total of 1 processors activated (6.00 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
device-tree: Duplicate name in lcdif@021c8000, renamed to "display#1"
VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 8 bytes.
imx6ul-pinctrl 20e0000.iomuxc: Invalid fsl,pins property in node /soc/aips-bus@02000000/iomuxc@020e0000/imx6ul-evk/flexcan2grp
imx6ul-pinctrl 20e0000.iomuxc: Invalid fsl,pins property in node /soc/aips-bus@02000000/iomuxc@020e0000/imx6ul-evk/uart2dtegrp
imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
imx6ul-pinctrl 2290000.iomuxc-snvs: Invalid fsl,pins property in node /soc/aips-bus@02200000/iomuxc-snvs@02290000/imx6ul-evk/lcdifresetgrp
imx6ul-pinctrl 2290000.iomuxc-snvs: initialized IMX pinctrl driver
mxs-dma 1804000.dma-apbh: initialized
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c i2c-0: IMX I2C adapter registered
i2c i2c-0: can't use DMA
i2c i2c-1: IMX I2C adapter registered
i2c i2c-1: can't use DMA
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource mxc_timer1
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
imx rpmsg driver is registered.
Bus freq driver module loaded
futex hash table entries: 256 (order: 2, 16384 bytes)
VFS: Disk quotas dquot_6.6.0
VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
jffs2: version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
fuse init (API version 7.23)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
imx-weim 21b8000.weim: Driver registered.
backlight supply power not found, using dummy regulator
21c8000.lcdif supply lcd not found, using dummy regulator
mxsfb 21c8000.lcdif: failed to find mxc display driver 
Console: switching to colour frame buffer device 128x37
mxsfb 21c8000.lcdif: initialized
imx-sdma 20ec000.sdma: no event needs to be remapped
imx-sdma 20ec000.sdma: loaded firmware 3.3
imx-sdma 20ec000.sdma: initialized
2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 19, base_baud = 5000000) is a IMX
console [ttymxc0] enabled
21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 233, base_baud = 5000000) is a IMX
KGDB: Registered I/O driver kgdboc
KGDB: Waiting for connection from remote gdb...

7、使用 agent-proxy 开启调试终端

telnet localhost 5551

六、调试 Linux 驱动

1、选择驱动程序

因为使用正点原子 imx6ull 开发板,因此使用正点原子提供驱动。因为驱动需要设备树支持,因此选择1_chrdevbase驱动程序。

2、修改 kgdboc 参数

setenv bootargs 'console=ttymxc0,115200 kgdboc=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.6.129:/home/onlylove/my/nfs,proto=tcp,nfsvers=4 rw ip=192.168.6.200:192.168.6.129:192.168.6.2:255.255.255.0::eth0:off'
saveenv

kgdbwait 参数会让 Linux 内核停下来,因此需要删除。

3、开启 agent-proxy

agent-proxy 5550^5551 0 /dev/ttyUSB0,115200

4、开启日志终端

telnet localhost 5550
U-Boot 2016.03 (Aug 20 2022 - 00:46:14 -0700)

CPU:   Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 52C
Reset cause: POR
Board: MX6ULL ALIENTEK EMMC
I2C:   ready
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
unsupported panel ATK-LCD-7-1024x600
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc0 is current device
Net:   FEC1
Normal Boot
Hit any key to stop autoboot:  0 
FEC1 Waiting for PHY auto negotiation to complete.... done
Using FEC1 device
TFTP from server 192.168.6.129; our IP address is 192.168.6.20
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 ##############
	 2.1 MiB/s
done
Bytes transferred = 5916896 (5a48e0 hex)
Using FEC1 device
TFTP from server 192.168.6.129; our IP address is 192.168.6.20
Filename 'imx6ull-alientek-emmc.dtb'.
Load address: 0x83000000
Loading: ###
	 2.2 MiB/s
done
Bytes transferred = 39280 (9970 hex)
Kernel image @ 0x80800000 [ 0x000000 - 0x5a48e0 ]
## Flattened Device Tree blob at 83000000
   Booting using the fdt blob at 0x83000000
   Using Device Tree in place at 83000000, end 8300c96f

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.1.15 (onlylove@ubuntu) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #2 SMP PREEMPT Sat Sep 10 21:40:18 PDT 2022
CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Freescale i.MX6 ULL 14x14 EVK Board
Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB
Reserved memory: initialized node linux,cma, compatible id shared-dma-pool
Memory policy: Data cache writealloc
PERCPU: Embedded 12 pages/cpu @8bb2f000 s16768 r8192 d24192 u49152
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttymxc0,115200 kgdboc=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.6.129:/home/onlylove/my/nfs,proto=tcp,nfsvers=4 rw ip=192.168.6.200:192.168.6.129:192.168.6.2:255.255.255.0::eth0:off
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 180184K/524288K available (7312K kernel code, 334K rwdata, 2528K rodata, 404K init, 457K bss, 16424K reserved, 327680K cma-reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xa0800000 - 0xff000000   (1512 MB)
    lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
    pkmap   : 0x7fe00000 - 0x80000000   (   2 MB)
    modules : 0x7f000000 - 0x7fe00000   (  14 MB)
      .text : 0x80008000 - 0x809a44e0   (9842 kB)
      .init : 0x809a5000 - 0x80a0a000   ( 404 kB)
      .data : 0x80a0a000 - 0x80a5d8a0   ( 335 kB)
       .bss : 0x80a60000 - 0x80ad2444   ( 458 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
	Additional per-CPU info printed with stalls.
	RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
NR_IRQS:16 nr_irqs:16 16
mxc_clocksource_init 3000000
Switching to timer-based delay loop, resolution 333ns
sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns
clocksource mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
/cpus/cpu@0 missing clock-frequency property
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x80008280 - 0x800082f0
Brought up 1 CPUs
SMP: Total of 1 processors activated (6.00 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
device-tree: Duplicate name in lcdif@021c8000, renamed to "display#1"
VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 8 bytes.
imx6ul-pinctrl 20e0000.iomuxc: Invalid fsl,pins property in node /soc/aips-bus@02000000/iomuxc@020e0000/imx6ul-evk/flexcan2grp
imx6ul-pinctrl 20e0000.iomuxc: Invalid fsl,pins property in node /soc/aips-bus@02000000/iomuxc@020e0000/imx6ul-evk/uart2dtegrp
imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
imx6ul-pinctrl 2290000.iomuxc-snvs: Invalid fsl,pins property in node /soc/aips-bus@02200000/iomuxc-snvs@02290000/imx6ul-evk/lcdifresetgrp
imx6ul-pinctrl 2290000.iomuxc-snvs: initialized IMX pinctrl driver
mxs-dma 1804000.dma-apbh: initialized
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c i2c-0: IMX I2C adapter registered
i2c i2c-0: can't use DMA
i2c i2c-1: IMX I2C adapter registered
i2c i2c-1: can't use DMA
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource mxc_timer1
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
imx rpmsg driver is registered.
Bus freq driver module loaded
futex hash table entries: 256 (order: 2, 16384 bytes)
VFS: Disk quotas dquot_6.6.0
VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
jffs2: version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
fuse init (API version 7.23)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
imx-weim 21b8000.weim: Driver registered.
backlight supply power not found, using dummy regulator
21c8000.lcdif supply lcd not found, using dummy regulator
mxsfb 21c8000.lcdif: failed to find mxc display driver 
Console: switching to colour frame buffer device 128x37
mxsfb 21c8000.lcdif: initialized
imx-sdma 20ec000.sdma: no event needs to be remapped
imx-sdma 20ec000.sdma: loaded firmware 3.3
imx-sdma 20ec000.sdma: initialized
2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 19, base_baud = 5000000) is a IMX
console [ttymxc0] enabled
21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 233, base_baud = 5000000) is a IMX
KGDB: Registered I/O driver kgdboc
imx sema4 driver is registered.
[drm] Initialized drm 1.1.0 20060810
[drm] Initialized vivante 1.0.0 20120216 on minor 0
brd: module loaded
loop: module loaded
fsl-quadspi 21e0000.qspi: unrecognized JEDEC id bytes: ff, ff, ff
fsl-quadspi 21e0000.qspi: Freescale QuadSPI probe failed
spi_imx 2010000.ecspi: probed
CAN device driver interface
flexcan 2090000.can: device registered (reg_base=a09e8000, irq=25)
20b4000.ethernet supply phy not found, using dummy regulator
pps pps0: new PPS source ptp0
libphy: fec_enet_mii_bus: probed
fec 20b4000.ethernet eth0: registered PHC device 0
2188000.ethernet supply phy not found, using dummy regulator
pps pps1: new PPS source ptp1
fec 2188000.ethernet eth1: registered PHC device 1
PPP generic driver version 2.4.2
PPP BSD Compression module registered
PPP Deflate Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
usbcore: registered new interface driver rtl8187
usbcore: registered new interface driver rndis_wlan
usbcore: registered new interface driver r8152
usbcore: registered new interface driver asix
usbcore: registered new interface driver ax88179_178a
usbcore: registered new interface driver cdc_ether
usbcore: registered new interface driver net1080
usbcore: registered new interface driver rndis_host
usbcore: registered new interface driver cdc_subset
usbcore: registered new interface driver zaurus
usbcore: registered new interface driver cdc_ncm
GobiNet: Quectel_WCDMA&LTE_Linux&Android_GobiNet_Driver_V1.3.0
usbcore: registered new interface driver GobiNet
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-mxc: Freescale On-Chip EHCI Host driver
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver usb-storage
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver option
usbserial: USB Serial support registered for GSM modem (1-port)
2184800.usbmisc supply vbus-wakeup not found, using dummy regulator
2184000.usb supply vbus not found, using dummy regulator
ci_hdrc ci_hdrc.0: EHCI Host Controller
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
2184200.usb supply vbus not found, using dummy regulator
ci_hdrc ci_hdrc.1: EHCI Host Controller
ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 2
ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
mousedev: PS/2 mouse device common for all mice
input: 20cc000.snvs:snvs-powerkey as /devices/platform/soc/2000000.aips-bus/20cc000.snvs/20cc000.snvs:snvs-powerkey/input/input0
usbcore: registered new interface driver xpad
usb 2-1: new high-speed USB device number 2 using ci_hdrc
input: EP0820M09 as /devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c-1/1-0038/input/input1
snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc0
i2c /dev entries driver
IR NEC protocol handler initialized
IR RC5(x/sz) protocol handler initialized
IR RC6 protocol handler initialized
IR JVC protocol handler initialized
IR Sony protocol handler initialized
IR SANYO protocol handler initialized
IR Sharp protocol handler initialized
IR MCE Keyboard/mouse protocol handler initialized
IR XMP protocol handler initialized
pxp-v4l2 pxp_v4l2: initialized
imx2-wdt 20bc000.wdog: use WDOG_B to reboot.
imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0)
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
/soc/aips-bus@02100000/usdhc@02190000: voltage-ranges unspecified
sdhci-esdhc-imx 2190000.usdhc: Got CD GPIO
sdhci-esdhc-imx 2190000.usdhc: No vqmmc regulator found
hub 2-1:1.0: USB hub found
hub 2-1:1.0: 4 ports detected
mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA
/soc/aips-bus@02100000/usdhc@02194000: voltage-ranges unspecified
sdhci-esdhc-imx 2194000.usdhc: No vmmc regulator found
sdhci-esdhc-imx 2194000.usdhc: No vqmmc regulator found
mmc0: host does not support reading read-only switch, assuming write-enable
mmc1: SDHCI controller on 2194000.usdhc [2194000.usdhc] using ADMA
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SC16G 14.8 GiB 
 mmcblk0: p1
fsl-asrc 2034000.asrc: driver registered
imx-wm8960 sound: wm8960-hifi <-> 202c000.sai mapping ok
imx-wm8960 sound: snd-soc-dummy-dai <-> 2034000.asrc mapping ok
imx-wm8960 sound: wm8960-hifi <-> 202c000.sai mapping ok
mmc1: MAN_BKOPS_EN bit is not set
NET: Registered protocol family 10
mmc1: new HS200 MMC card at address 0001
mmcblk1: mmc1:0001 8GTF4R 7.28 GiB 
sit: IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
can: controller area network core (rev 20120528 abi 9)
mmcblk1boot0: mmc1:0001 8GTF4R partition 1 4.00 MiB
mmcblk1boot1: mmc1:0001 8GTF4R partition 2 4.00 MiB
mmcblk1rpmb: mmc1:0001 8GTF4R partition 3 512 KiB
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
 mmcblk1: p1 p2
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
lib80211: common routines for IEEE802.11 drivers
Key type dns_resolver registered
Registering SWP/SWPB emulation handler
input: gpio-keys as /devices/platform/gpio-keys/input/input2
snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 03:19:28 UTC (11968)
fec 20b4000.ethernet eth0: Freescale FEC PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=20b4000.ethernet:01, irq=-1)
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
fec 20b4000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
IP-Config: Complete:
     device=eth0, hwaddr=b8:ae:1d:01:00:00, ipaddr=192.168.6.200, mask=255.255.255.0, gw=192.168.6.2
     host=192.168.6.200, domain=, nis-domain=(none)
     bootserver=192.168.6.129, rootserver=192.168.6.129, rootpath=
gpio_dvfs: disabling
can-3v3: disabling
ALSA device list:
  #0: wm8960-audio
VFS: Mounted root (nfs4 filesystem) on device 0:15.
devtmpfs: mounted
Freeing unused kernel memory: 404K (809a5000 - 80a0a000)
ALSA: Restoring mixer setting......

Please press Enter to activate this console. random: nonblocking pool is initialized
/var/empty must be owned by root and not group or world-writable.

/ # 
/ # ls
bin           home          mnt           share         video
dev           include       music         sys           中文测试
drivers       lib           proc          tmp
etc           linuxrc       root          usr
gdbtest       minicom.log   sbin          var
/ # 

5、安装 chrdevbase.ko 驱动

/ # ls
bin            gdbtest        minicom.log    sbin           var
chrdevbase.ko  home           mnt            share          video
dev            include        music          sys            中文测试
drivers        lib            proc           tmp
etc            linuxrc        root           usr
/ # insmod chrdevbase.ko 
chrdevbase init!
/ #

6、获取 chrdevbase.ko 驱动相关信息

/ # cat /sys/module/chrdevbase/sections/.text 
0x7f000000
/ #

注意:直接使用chrdevbase.ko文件调试,发现无法设置断点,可能是nokaslr的问题(问题未进行确认)。

7、触发 KGDB

echo g > /proc/sysrq-trigger
/ # echo g > /proc/sysrq-trigger
sysrq: SysRq : DEBUG
KGDB: Entering KGDB

8、启动 GDB

arm-linux-gnueabihf-gdb
add-symbol-file chrdevbase.ko 0x7f000000
onlylove@ubuntu:~/my/nfs$ ls
bin            dev      etc      home     lib      minicom.log  music  root  share  tmp  var    中文测试
chrdevbase.ko  drivers  gdbtest  include  linuxrc  mnt          proc   sbin  sys    usr  video
onlylove@ubuntu:~/my/nfs$ arm-linux-gnueabihf-gdb
GNU gdb (Linaro_GDB-2017.01) 7.10.1.20160210-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) add-symbol-file chrdevbase.ko 0x7f000000
add symbol table from file "chrdevbase.ko" at
	.text_addr = 0x7f000000
(y or n) y
Reading symbols from chrdevbase.ko...done.
(gdb)

9、开启调试终端

tar rem localhost:5551
onlylove@ubuntu:~/my/nfs$ ls
bin            dev      etc      home     lib      minicom.log  music  root  share  tmp  var    中文测试
chrdevbase.ko  drivers  gdbtest  include  linuxrc  mnt          proc   sbin  sys    usr  video
onlylove@ubuntu:~/my/nfs$ arm-linux-gnueabihf-gdb
GNU gdb (Linaro_GDB-2017.01) 7.10.1.20160210-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) add-symbol-file chrdevbase.ko 0x7f000000
add symbol table from file "chrdevbase.ko" at
	.text_addr = 0x7f000000
(y or n) y
Reading symbols from chrdevbase.ko...done.
(gdb) 
(gdb) tar rem localhost:5551
Remote debugging using localhost:5551
0x8009d45c in ?? ()
(gdb) list
1	#include <linux/types.h>
2	#include <linux/kernel.h>
3	#include <linux/delay.h>
4	#include <linux/ide.h>
5	#include <linux/init.h>
6	#include <linux/module.h>
7	/***************************************************************
8	Copyright ? ALIENTEK Co., Ltd. 1998-2029. All rights reserved.
9	文件名		: chrdevbase.c
10	作者	  	: 左忠凯
(gdb)

七、总结

通过以上配置,成功搭建 Linux 驱动调试框架。

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2022-09-13 11:56:34  更:2022-09-13 11:57:14 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/15 9:29:46-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码