Ubuntu Bluetooth Driver 调试


kernel源码:Linux-3.2.16

升级Linux-3.2.16源码(参照:Linux-3.2.6内核升级)。bluetooth驱动模块代码位于linux-3.2.16/net/bluetooth目录下。打开该目录下的Makefile文件,如下:

  1. #   
  2. # Makefile for the Linux Bluetooth subsystem.   
  3. #   
  4.   
  5. obj-$(CONFIG_BT)    += bluetooth.o  
  6. obj-$(CONFIG_BT_RFCOMM)    += rfcomm/  
  7. obj-$(CONFIG_BT_BNEP)    += bnep/  
  8. obj-$(CONFIG_BT_CMTP)    += cmtp/  
  9. obj-$(CONFIG_BT_HIDP)    += hidp/  
  10.   
  11. bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o hci_sock.o hci_sysfs.o lib.o  
  12. bluetooth-$(CONFIG_BT_L2CAP)    += l2cap_core.o l2cap_sock.o smp.o  
  13. bluetooth-$(CONFIG_BT_SCO)    += sco.o  
这个意思(个人理解)会编译出几个模块bluetooth,rfcomm,bnep,cmtp,hidp,这些模块具体是编译进内核还是编译成.ko有obj-后面的变量指定(y编译进内核,m编译成.ko),变量的定义看根目录地下的.config文件。这里我为了调试,在menuconfig时将这些模块都设置成m,即编译成.ko文件。用来调试时事实insmod。最终在make bzImage时,编译出bluetooth.ko。

编译完kernel安装后,在系统/lib/modules/`uname -r`/kernel/net/bluetooth下会安装这些.ko,这里修改了以上跟bluetooth.ko有关的源文件(比如加些打印)后,直接insmod进内核,然后用dmesg打印信息,当bluetooth.ko运行到打印部分时,打印的信息就会用dmesg打出来。

驱动卸载过程:

1.关闭bluetooth应用

2.sudo rmmod rfcomm

3.sudo rmmod btusb

4.sudo rmmod bnep

5.sudo rmmod bluetooth

驱动装载过程:

1.sudo insmod bluetooth.ko

2.开启bluetooth应用

然后就能调试驱动部分了。

更多Ubuntu相关信息见Ubuntu 专题页面 http://www.bkjia.com/topicnews.aspx?tid=2

相关内容