歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Ubuntu Bluetooth Driver 調試

Ubuntu Bluetooth Driver 調試

日期:2017/3/1 10:20:26   编辑:Linux編程

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. obj-$(CONFIG_BT) += bluetooth.o
  5. obj-$(CONFIG_BT_RFCOMM) += rfcomm/
  6. obj-$(CONFIG_BT_BNEP) += bnep/
  7. obj-$(CONFIG_BT_CMTP) += cmtp/
  8. obj-$(CONFIG_BT_HIDP) += hidp/
  9. bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o hci_sock.o hci_sysfs.o lib.o
  10. bluetooth-$(CONFIG_BT_L2CAP) += l2cap_core.o l2cap_sock.o smp.o
  11. 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.linuxidc.com/topicnews.aspx?tid=2

Copyright © Linux教程網 All Rights Reserved