當前位置:首頁 » 操作系統 » linuxusb調試

linuxusb調試

發布時間: 2023-01-26 04:52:17

① 請問如何將linux內核的調試串口設置成用USB轉換的串口輸出

首先,內核前期的輸出信息肯定不能被列印到USB轉的串口上,因為這時內核的USB驅動還沒有載入。等到載入完USB驅動,列印信息才能出來,這時候基本你可以在init文件中重定向到另外一個tty就可以了。具體可以發郵件到[email protected]

② 怎麼查看linux usb設備驅動

下面的信息都是在VMware中運行Ubuntu12-04系統上執行的。同樣該命令也支持在嵌入式系統中進行USB調試。
一、cat設備節點獲取信息
在一些嵌入式開發中需要調試USB功能,經常會cat /sys 下的相關設備節點來查看某些信息,比如說我們可以看到 /sys/bus/usb/devices 目錄有多個子目錄。進入到某個子目錄可以看到usb設備更加詳細的信息(可以理解為設備描述符)。
1、usb設備在匯流排上的信息
// usb設備在匯流排上的信息
root@ubuntu:/sys/kernel/debug# cd /sys/bus/usb/devices
root@ubuntu:/sys/bus/usb/devices# ll
total 0
drwxr-xr-x 2 root root 0 Nov 26 21:21 ./
drwxr-xr-x 4 root root 0 Nov 26 21:21 ../
lrwxrwxrwx 1 root root 0 Nov 26 21:21 1-0:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-0:1.0/
lrwxrwxrwx 1 root root 0 Dec 15 23:10 1-1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/
lrwxrwxrwx 1 root root 0 Dec 15 23:18 1-1:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/1-1/1-1:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-0:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-0:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-1:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-1/2-1:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 2-2:1.0 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/2-2/2-2:1.0/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb1 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:03.0/usb1/
lrwxrwxrwx 1 root root 0 Nov 26 21:21 usb2 -> ../../../devices/pci0000:00/0000:00:11.0/0000:02:00.0/usb2/
其中 usbx/第x個匯流排,x-y:a.b/的目錄格式,x表示匯流排號,y表示埠,a表示配置,b表示介面。
具體解釋可以參照如下:
The names that begin with "usb" refer to USB controllers. More accurately, they refer to the "root hub" associated with each controller. The number is the USB bus number. In the example there is only one controller, so its bus is number 1. Hence the name "usb1".
"1-0:1.0" is a special case. It refers to the root hub's interface. This acts just like the interface in an actual hub an almost every respect; see below.
All the other entries refer to genuine USB devices and their interfaces. The devices are named by a scheme like this:
bus-port.port.port ...
In other words, the name starts with the bus number followed by a '-'. Then comes the sequence of port numbers for each of the intermediate hubs along the path to the device.
For example, "1-1" is a device plugged into bus 1, port 1. It happens to be a hub, and "1-1.3" is the device plugged into port 3 of that hub. That device is another hub, and "1-1.3.1" is the device plugged into its port 1.
The interfaces are indicated by suffixes having this form:
:config.interface
That is, a ':' followed by the configuration number followed by '.' followed by the interface number. In the above example, each of the devices is using configuration 1 and this configuration has only a single interface, number 0. So the interfaces show up as;
1-1:1.0 1-1.3:1.0 1-1.3.1:1.0
A hub will never have more than a single interface; that's part of the USB spec. But other devices can and do have multiple interfaces (and sometimes multiple configurations). Each interface gets its own entry in sysfs and can have its own driver.
2、特定設備的詳細信息
進入到某個目錄中去,可以看到該設備的詳細信息,可用cat命令獲取信息。
// usb設備的詳細信息
root@ubuntu:/sys/bus/usb/devices/usb1# ll
total 0
drwxr-xr-x 6 root root 0 Nov 26 21:21 ./
drwxr-xr-x 4 root root 0 Nov 26 21:21 ../
drwxr-xr-x 10 root root 0 Nov 26 21:21 1-0:1.0/
drwxr-xr-x 5 root root 0 Dec 15 23:10 1-1/
-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized
-rw-r--r-- 1 root root 4096 Dec 15 23:40 authorized_default
-rw-r--r-- 1 root root 4096 Dec 15 23:40 avoid_reset_quirk
-r--r--r-- 1 root root 4096 Nov 26 21:21 bcdDevice
-rw-r--r-- 1 root root 4096 Nov 26 21:21 bConfigurationValue
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceClass
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceProtocol
-r--r--r-- 1 root root 4096 Nov 26 21:21 bDeviceSubClass
-r--r--r-- 1 root root 4096 Dec 15 23:40 bmAttributes
-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPacketSize0
-r--r--r-- 1 root root 4096 Dec 15 23:40 bMaxPower
-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumConfigurations
-r--r--r-- 1 root root 4096 Dec 15 23:40 bNumInterfaces
-r--r--r-- 1 root root 4096 Nov 26 21:21 busnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 configuration
-r--r--r-- 1 root root 65553 Nov 26 21:21 descriptors
-r--r--r-- 1 root root 4096 Dec 15 23:40 dev
-r--r--r-- 1 root root 4096 Nov 26 21:21 devnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 devpath
lrwxrwxrwx 1 root root 0 Nov 27 20:06 driver -> ../../../../../bus/usb/drivers/usb/
drwxr-xr-x 3 root root 0 Dec 15 23:40 ep_00/
-r--r--r-- 1 root root 4096 Nov 26 21:21 idProct
-r--r--r-- 1 root root 4096 Nov 26 21:21 idVendor
-r--r--r-- 1 root root 4096 Dec 15 23:40 ltm_capable
-r--r--r-- 1 root root 4096 Nov 26 21:21 manufacturer
-r--r--r-- 1 root root 4096 Dec 15 23:40 maxchild
drwxr-xr-x 2 root root 0 Nov 26 21:21 power/
-r--r--r-- 1 root root 4096 Nov 26 21:21 proct
-r--r--r-- 1 root root 4096 Dec 15 23:40 quirks
-r--r--r-- 1 root root 4096 Nov 26 21:21 removable
--w------- 1 root root 4096 Dec 15 23:40 remove
-r--r--r-- 1 root root 4096 Nov 26 21:21 serial
-r--r--r-- 1 root root 4096 Nov 26 21:21 speed
lrwxrwxrwx 1 root root 0 Nov 26 21:21 subsystem -> ../../../../../bus/usb/
-rw-r--r-- 1 root root 4096 Nov 26 21:21 uevent
-r--r--r-- 1 root root 4096 Dec 15 23:40 urbnum
-r--r--r-- 1 root root 4096 Dec 15 23:40 version
二、使用debugfs
1、掛載 debugfs 到 /sys/kernel/debug 路徑下
root@ubuntu:mount -t debugfs none /sys/kernel/debug
2、執行上述步驟之後,在 /sys/kernel/debug 就會生成如下的文件
root@ubuntu:/sys/bus/usb/devices# cd /sys/kernel/debug/
root@ubuntu:/sys/kernel/debug# ll
total 0
drwx------ 22 root root 0 Nov 26 21:21 ./
drwxr-xr-x 7 root root 0 Nov 26 21:21 ../
drwxr-xr-x 2 root root 0 Nov 26 21:21 acpi/
drwxr-xr-x 32 root root 0 Dec 4 16:30 bdi/
drwxr-xr-x 2 root root 0 Nov 26 21:21 bluetooth/
drwxr-xr-x 2 root root 0 Nov 26 21:21 cleancache/
drwxr-xr-x 2 root root 0 Nov 26 21:21 dma_buf/
drwxr-xr-x 4 root root 0 Nov 26 21:21 dri/
drwxr-xr-x 2 root root 0 Nov 26 21:21 dynamic_debug/
drwxr-xr-x 2 root root 0 Nov 26 21:21 extfrag/
drwxr-xr-x 2 root root 0 Nov 26 21:21 frontswap/
-r--r--r-- 1 root root 0 Nov 26 21:21 gpio
drwxr-xr-x 3 root root 0 Nov 26 21:21 hid/
drwxr-xr-x 2 root root 0 Nov 26 21:21 kprobes/
drwxr-xr-x 3 root root 0 Nov 26 21:21 kvm-guest/
drwxr-xr-x 2 root root 0 Nov 26 21:21 mce/
drwxr-xr-x 2 root root 0 Nov 26 21:21 pinctrl/
-r--r--r-- 1 root root 0 Nov 26 21:21 pwm
drwxr-xr-x 2 root root 0 Nov 26 21:21 regmap/
drwxr-xr-x 3 root root 0 Nov 26 21:21 regulator/
-rw-r--r-- 1 root root 0 Nov 26 21:21 sched_features
-r--r--r-- 1 root root 0 Nov 26 21:21 sleep_time
-r--r--r-- 1 root root 0 Nov 26 21:21 suspend_stats
drwxr-xr-x 7 root root 0 Nov 26 21:21 tracing/
drwxr-xr-x 3 root root 0 Nov 26 21:21 usb/
drwxr-xr-x 2 root root 0 Nov 26 21:21 virtio-ports/
-r--r--r-- 1 root root 0 Nov 26 21:21 vmmemctl
-r--r--r-- 1 root root 0 Nov 26 21:21 wakeup_sources
drwxr-xr-x 2 root root 0 Nov 26 21:21 x86/
3、cat 設備節點
執行下述命令之後會以特定格式列印目前USB匯流排上所有USB設備的信息如下:
root@ubuntu:/sys/kernel/debug# cat usb/devices
T: Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 17/900 us ( 2%), #Int= 1, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0001 Rev= 3.13
S: Manufacturer=Linux 3.13.0-32-generic uhci_hcd
S: Proct=UHCI Host Controller
S: SerialNumber=0000:02:00.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0e0f ProdID=0003 Rev= 1.03
S: Manufacturer=VMware
S: Proct=VMware Virtual USB Mouse
C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=1ms
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 7
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0e0f ProdID=0002 Rev= 1.00
S: Proct=VMware Virtual USB Hub
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=255ms
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6
B: Alloc= 0/800 us ( 0%), #Int= 1, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 3.13
S: Manufacturer=Linux 3.13.0-32-generic ehci_hcd
S: Proct=EHCI Host Controller
S: SerialNumber=0000:02:03.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 7 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs= 1
P: Vendor=0bda ProdID=0129 Rev=39.60
S: Manufacturer=Generic
S: Proct=USB2.0-CRW
S: SerialNumber=20100201396000000
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=50 Driver=rts5139
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=83(I) Atr=03(Int.) MxPS= 3 Ivl=64ms
至於信息的詳細解析可以參照 Linux源代碼中 Documentation/usb/proc_usb_info.txt 文件。現摘錄其中對該格式的詳細解釋:

| | |__Proct ID code
| |__Vendor ID code
|__Device info tag #2

String descriptor info:
S: Manufacturer=ssss
| |__Manufacturer of this device as read from the device.
| For USB host controller drivers (virtual root hubs) this may
| be omitted, or (for newer drivers) will identify the kernel
| version and the driver which provi

③ 華為手機連接linux後,mtp路徑錯誤

1、打開」設備管理器「找到無法連接的那個設備(一般就是自己華為的手機了)2、在它上面點滑鼠右鍵,在彈出的菜單中選擇「更新驅動程序軟體」在彈出的菜單中點擊「瀏覽計算機以查找驅動程序軟體」

3、然後在繼續點擊「從計算機的設備驅動程序列表中選擇」

4、然後在彈出的列表中找到「便攜設備」,選中後點「下一步」

5、然後在彈出的列表中依次選中(標准MTP設備)—>MTP USB設備。然後單擊「下一步」。在彈出的警告窗口中選擇「是」。

6、安裝完後這里就顯示你的手機了。這樣就可以正常使用了。

7、注意事項手機上需要先開啟USB調試模式,以免更新驅動後連接不上,看不到內容。在哪個USB口安裝手機驅動的就只能識別這個USB口,如果換了另一個USB口連接手機的話需要重復一遍上面的工作。如果你不厭其煩的把每個USB口都連接一遍的話以後無論手機插到哪個口都可以直接使用

④ 求教如何用USB直接調試linux開發板

開發板有個接受命令的介面或觸發條件,根據約定的方式去觸發即可。

⑤ 如何調試linux的網路驅動

如何根據oops定位代碼行
我們借用linux設備驅動第二篇:構造和運行模塊裡面的hello world程序來演示出錯的情況,含有錯誤代碼的hello world如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

#include <linux/init.h>
#include <linux/mole.h>
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
char *p = NULL;
memcpy(p, "test", 4);
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{

printk(KERN_ALERT "Goodbye, cruel world\n");
}

mole_init(hello_init);
mole_exit(hello_exit);

Makefile文件如下:

1
2
3
4
5
6
7
8
9
10
11

ifneq ($(KERNELRELEASE),)
obj-m := helloworld.o
else
KERNELDIR ?= /lib/moles/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) moles
endif

clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions moles.order Mole.symvers

很明顯,以上代碼的第8行是一個空指針錯誤。insmod後會出現下面的oops信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

[ 459.516441] BUG: unable to handle kernel NULL pointer dereference at (null)
[ 459.516445]
[ 459.516448] PGD 0
[ 459.516450] Oops: 0002 [#1] SMP
[ 459.516452] Moles linked in: helloworld(OE+) vmw_vsock_vmci_transport vsock coretemp crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel vmw_balloon snd_ens1371 aes_x86_64 lrw snd_ac97_codec gf128mul glue_helper ablk_helper cryptd ac97_bus gameport snd_pcm serio_raw snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq snd_seq_device snd_timer vmwgfx btusb ttm snd drm_kms_helper drm soundcore shpchp vmw_vmci i2c_piix4 rfcomm bnep bluetooth 6lowpan_iphc parport_pc ppdev mac_hid lp parport hid_generic usbhid hid psmouse ahci libahci floppy e1000 vmw_pvscsi vmxnet3 mptspi mptscsih mptbase scsi_transport_spi pata_acpi [last unloaded: helloworld]
[ 459.516476] CPU: 0 PID: 4531 Comm: insmod Tainted: G OE 3.16.0-33-generic #44~14.04.1-Ubuntu
[ 459.516478] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/20/2014
[ 459.516479] task: ffff88003821f010 ti: ffff880038fa0000 task.ti: ffff880038fa0000
[ 459.516480] RIP: 0010:[<ffffffffc061400d>] [<ffffffffc061400d>] hello_init+0xd/0x30 [helloworld]
[ 459.516483] RSP: 0018:ffff880038fa3d40 EFLAGS: 00010246
[ 459.516484] RAX: ffff88000c31d901 RBX: ffffffff81c1a020 RCX: 000000000004b29f
[ 459.516485] RDX: 000000000004b29e RSI: 0000000000000017 RDI: ffffffffc0615024
[ 459.516485] RBP: ffff880038fa3db8 R08: 0000000000015e80 R09: ffff88003d615e80
[ 459.516486] R10: ffffea000030c740 R11: ffffffff81002138 R12: ffff88000c31d0c0
[ 459.516487] R13: 0000000000000000 R14: ffffffffc0614000 R15: ffffffffc0616000
[ 459.516488] FS: 00007f8a6fa86740(0000) GS:ffff88003d600000(0000) knlGS:0000000000000000
[ 459.516489] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 459.516490] CR2: 0000000000000000 CR3: 0000000038760000 CR4: 00000000003407f0
[ 459.516522] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 459.516524] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 459.516524] Stack:
[ 459.57] ffff880038fa3db8 ffffffff81002144 0000000000000001 0000000000000001
[ 459.516540] 0000000000000001 ffff880028ab5040 0000000000000001 ffff880038fa3da0
[ 459.516541] ffffffff8119d0b2 ffffffffc0616018 00000000bd1141ac ffffffffc0616018
[ 459.516543] Call Trace:
[ 459.516548] [<ffffffff81002144>] ? do_one_initcall+0xd4/0x210
[ 459.516550] [<ffffffff8119d0b2>] ? __vunmap+0xb2/0x100
[ 459.516554] [<ffffffff810ed9b1>] load_mole+0x13c1/0x1b80
[ 459.516557] [<ffffffff810e9560>] ? store_uevent+0x40/0x40
[ 459.516560] [<ffffffff810ee2e6>] SyS_finit_mole+0x86/0xb0
[ 459.516563] [<ffffffff8176be6d>] system_call_fastpath+0x1a/0x1f
[ 459.516564] Code: <c7> 04 25 00 00 00 00 74 65 73 74 31 c0 48 89 e5 e8 a2 86 14 c1 31
[ 459.516573] RIP [<ffffffffc061400d>] hello_init+0xd/0x30 [helloworld]
[ 459.516575] RSP <ffff880038fa3d40>
[ 459.516576] CR2: 0000000000000000
[ 459.516578] ---[ end trace 7c52cc8624b7ea60 ]---


下面簡單分析下oops信息的內容。
由BUG: unable to handle kernel NULL pointer dereference at (null)知道出錯的原因是使用了空指針。標紅的部分確定了具體出錯的函數。Moles linked in: helloworld表明了引起oops問題的具體模塊。call trace列出了函數的調用信息。這些信息中其中標紅的部分是最有用的,我們可以根據其信息找到具體出錯的代碼行。下面就來說下,如何定位到具體出錯的代碼行。
第一步我們需要使用objmp把編譯生成的bin文件反匯編,我們這里就是helloworld.o,如下命令把反匯編信息保存到err.txt文件中:

1

objmp helloworld.o -D > err.txt

err.txt內容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

helloworld.o: file format elf64-x86-64

Disassembly of section .text:

<span style="color:#ff0000;">0000000000000000 <init_mole>:</span>
0: e8 00 00 00 00 callq 5 <init_mole+0x5>
5: 55 push %rbp
6: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
d: c7 04 25 00 00 00 00 movl $0x74736574,0x0
14: 74 65 73 74
18: 31 c0 xor %eax,%eax
1a: 48 89 e5 mov %rsp,%rbp
1d: e8 00 00 00 00 callq 22 <init_mole+0x22>
22: 31 c0 xor %eax,%eax
24: 5d pop %rbp
25: c3 retq
26: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
2d: 00 00 00

0000000000000030 <cleanup_mole>:
30: e8 00 00 00 00 callq 35 <cleanup_mole+0x5>
35: 55 push %rbp
36: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
3d: 31 c0 xor %eax,%eax
3f: 48 89 e5 mov %rsp,%rbp
42: e8 00 00 00 00 callq 47 <cleanup_mole+0x17>
47: 5d pop %rbp
48: c3 retq

Disassembly of section .rodata.str1.1:

0000000000000000 <.rodata.str1.1>:
0: 01 31 add %esi,(%rcx)
2: 48 rex.W
3: 65 gs
4: 6c insb (%dx),%es:(%rdi)
5: 6c insb (%dx),%es:(%rdi)
6: 6f outsl %ds:(%rsi),(%dx)
7: 2c 20 sub $0x20,%al
9: 77 6f ja 7a <cleanup_mole+0x4a>
b: 72 6c jb 79 <cleanup_mole+0x49>
d: 64 0a 00 or %fs:(%rax),%al
10: 01 31 add %esi,(%rcx)
12: 47 6f rex.RXB outsl %ds:(%rsi),(%dx)
14: 6f outsl %ds:(%rsi),(%dx)
15: 64 fs
16: 62 (bad)
17: 79 65 jns 7e <cleanup_mole+0x4e>
19: 2c 20 sub $0x20,%al
1b: 63 72 75 movslq 0x75(%rdx),%esi
1e: 65 gs
1f: 6c insb (%dx),%es:(%rdi)
20: 20 77 6f and %dh,0x6f(%rdi)
23: 72 6c jb 91 <cleanup_mole+0x61>
25: 64 0a 00 or %fs:(%rax),%al

Disassembly of section .modinfo:

0000000000000000 <__UNIQUE_ID_license0>:
0: 6c insb (%dx),%es:(%rdi)
1: 69 63 65 6e 73 65 3d imul $0x3d65736e,0x65(%rbx),%esp
8: 44 75 61 rex.R jne 6c <cleanup_mole+0x3c>
b: 6c insb (%dx),%es:(%rdi)
c: 20 42 53 and %al,0x53(%rdx)
f: 44 2f rex.R (bad)
11: 47 50 rex.RXB push %r8
13: 4c rex.WR
...

Disassembly of section .comment:

0000000000000000 <.comment>:
0: 00 47 43 add %al,0x43(%rdi)
3: 43 3a 20 rex.XB cmp (%r8),%spl
6: 28 55 62 sub %dl,0x62(%rbp)
9: 75 6e jne 79 <cleanup_mole+0x49>
b: 74 75 je 82 <cleanup_mole+0x52>
d: 20 34 2e and %dh,(%rsi,%rbp,1)
10: 38 2e cmp %ch,(%rsi)
12: 32 2d 31 39 75 62 xor 0x62753931(%rip),%ch # 62753949 <cleanup_mole+0x62753919>
18: 75 6e jne 88 <cleanup_mole+0x58>
1a: 74 75 je 91 <cleanup_mole+0x61>
1c: 31 29 xor %ebp,(%rcx)
1e: 20 34 2e and %dh,(%rsi,%rbp,1)
21: 38 2e cmp %ch,(%rsi)
23: 32 00 xor (%rax),%al

Disassembly of section __mcount_loc:

0000000000000000 <__mcount_loc>:

由oops信息我們知道出錯的地方是hello_init的地址偏移0xd。而有mp信息知道,hello_init的地址即init_mole的地址,因為hello_init即本模塊的初始化入口,如果在其他函數中出錯,mp信息中就會有相應符號的地址。由此我們得到出錯的地址是0xd,下一步我們就可以使用addr2line來定位具體的代碼行:
addr2line -C -f -e helloworld.o d
此命令就可以得到行號了。以上就是通過oops信息來定位驅動崩潰的行號。
其他調試手段
以上就是通過oops信息來獲取具體的導致崩潰的代碼行,這種情況都是用在遇到比較嚴重的錯誤導致內核掛掉的情況下使用的,另外比較常用的調試手段就是使用printk來輸出列印信息。printk的使用方法類似printf,只是要注意一下列印級別,詳細介紹在linux設備驅動第二篇:構造和運行模塊中已有描述,另外需要注意的是大量使用printk會嚴重拖慢系統,所以使用過程中也要注意。
以上兩種調試手段是我工作中最常用的,還有一些其他的調試手段,例如使用/proc文件系統,使用trace等用戶空間程序,使用gdb,kgdb等,這些調試手段一般不太容易使用或者不太方便使用,所以這里就不在介紹了。

⑥ 如何在Linux開發工具中啟動USB驅動程序

USB驅動程序支持在原生Linux提供了。

方法要求啟用驅動,但是,取決於你所使用的分布和內核版本。

哪個發行版支持USBFS?

已知提供USBFS支持:

Ubuntu 9.04或以上,
Ubuntu 9.10的內核2.6.31-19伺服器,
CentOS的4.8,
CentOS的5.4,
一般情況下,任何分布用內核版本<2.6.32

已知不提供USBFS支持:

Ubuntu 10.04,
一般情況下,任何分布用內核版本> = 2.6.32

方法1:USBFS支持

如果你的發行版提供了USBFS支持,那麼下面的命令將工作:

mount -t usbfs none /proc/bus/usb -o devmode=0666

為了使這種更改永久,確保下面一行是在/ etc / fstab文件中:

none /proc/bus/usb usbfs defaults,devmode=0666 0 0

這將自動安裝在系統啟動。

一旦 /etc/fstab添加已經做完,一個簡單的命令應該掛載USBFS文件系統:

mount /proc/bus/usb

無論是FTDI / XTAG和XTAG-2的調試適配器現在應該工作。

方法2:沒有USBFS支持

為了確保在任何一個FTDI / XTAG或XTAG-2調試適配器插入時的許可權是在設備上是正確的,您需要配置「udev」來識別這個設備。

創建一個文件「/etc/udev/rules.d/99-xmos.rules」,其內容如下:

SUBSYSTEM!="usb|usb_device", GOTO="xmos_rules_end"
ACTION!="add", GOTO="xmos_rules_end"

# 20b1:f7d1 for xmos xtag2
ATTRS{idVendor}=="20b1", ATTRS{idProct}=="f7d1", MODE="0666", SYMLINK+="xtag2-%n"

# 20b1:f7d3 for xmos startkit
ATTRS{idVendor}=="20b1", ATTRS{idProct}=="f7d3", MODE="0666", SYMLINK+="startkit-%n"

# 0403:6010 for XC-1 with FTDI al-uart chip
ATTRS{idVendor}=="0403", ATTRS{idProct}=="6010", MODE="0666", SYMLINK+="xc1-%n"

LABEL="xmos_rules_end"

注意:本ATTRS,MODE和SYMLINK節必須全部在同一行,因為每個規則只能在一行上。

現在告訴udev進行重新載入,以確保文件添加新的規則:

service udev reload

還必須拔下並重新插上USB線,讓udev的識別設備的新規則。或者觸發重新插上的udev類型為「udevadm觸發」或「udevtrigger」命令,取決於在你的Linux分布上udev的版本。

FTDI / XTAG其他注意事項

FTDI的庫需要USB設備的文件都可以從/ proc /bus/ USB,不支持的/dev/bus/usb作為文件的位置。

但是,如果你的發行版不支持USBFS(以上方法1),但確實有一個的/proc/bus/usb空目錄,你可以使用下面的綁定mount命令的解決方法:

mount --bind /dev/bus/usb /proc/bus/usb

如果你的發行版不支持USBFS,也沒有一個的/proc/bus/usb目錄(這是較新的內核的情況下,大約從2.6.32開始),然後聯系XMOS的rthe設備庫的非官方補丁的版本; 發送XMOS的支持標簽,其中包括「Linux的FTDI庫請求」的主題。

⑦ android手機怎樣連接到vm虛擬機里linux!! 通過USB調試連接!

在主機上啟動服務 VMUSBArbService
應該就可以在虛擬機里連接了

⑧ 在linux下 如何找到 插入的USB設備所對應的設備文件呢

插入USB設備後,我的設備是U盤。fdisk -l查看u盤設備在哪個分區,比如是/dev/sdb 然後掛載這個分區到/mnt目錄下就可以訪問該U盤設備了 。其他的USB設備沒用過。

⑨ 智能手機連接電腦時電腦設備管理器中的linux file-cd gadget usb device打紅叉怎麼解決

那是蜜月將手機連接正確啊,先要打開手機

設置--開發者選項--usb調試。

也就可以將手機用數據線連接到電腦上了。

在電腦上就會顯示正常連接的。

要是還想對手機進行設置的話,那還在電腦上

選擇個應用寶的軟體,使用上面的工具對手機

進行設置就好了。

你就去在電腦上下載個PC版軟體就好很多了。

熱點內容
請密碼不叫什麼說話 發布:2025-07-10 10:06:22 瀏覽:112
蘋果應用怎麼設置密碼 發布:2025-07-10 10:04:00 瀏覽:837
雪國腳本 發布:2025-07-10 10:04:00 瀏覽:936
編程讓 發布:2025-07-10 09:48:13 瀏覽:359
資料庫邏輯存儲結構 發布:2025-07-10 09:26:56 瀏覽:920
密碼編譯找規律 發布:2025-07-10 09:18:10 瀏覽:512
電影視頻緩存後 發布:2025-07-10 09:16:48 瀏覽:894
伺服器搭建需要哪些東西 發布:2025-07-10 09:15:23 瀏覽:803
無限密碼怎麼改 發布:2025-07-10 09:14:32 瀏覽:106
coc按鍵精靈腳本 發布:2025-07-10 09:12:40 瀏覽:313