[MTK] BT驱动调试总结

首先在init.Project.rc里面找例如找fm bt wifi gps等等。。。
    # STP, WMT, GPS, FM and BT Driver
    insmod /system/lib/modules/mtk_stp_core.ko
    insmod /system/lib/modules/mtk_stp_uart.ko
    insmod /system/lib/modules/mtk_hif_sdio.ko
    insmod /system/lib/modules/mtk_stp_wmt.ko
    insmod /system/lib/modules/mtk_stp_gps.ko
    insmod /system/lib/modules/mtk_stp_bt.ko
    insmod /system/lib/modules/mtk_fm_drv.ko
    insmod /system/lib/modules/mtk_fm_priv.ko
    insmod /system/lib/modules/mtk_wmt_wifi.ko
上面加载驱动!!
如mtk_找bt驱动stp_bt.ko相关文件 search mtk_stp_bt
找到与Makefile相关的依赖文件
搜索结果:
obj-$(CONFIG_MTK_COMBO_BT) += mtk_stp_bt$(EXT_FLAG).o
mtk_stp_bt$(EXT_FLAG)-objs := linux/stp_chrdev_bt.o
结果为依靠上层linux目录的stp_chrdev_bt.o文件即找到stp_chrdev_bt.c源文件,进入观察正好是bt驱动代码,呵呵!!
第一步搜索
bt 驱动
/beetle/mediatek/kernel/drivers/combo/common/linux/stp_chrdev_bt.c

-->mknod /dev/stpbt  c 192 0; 静态手动创建的设备节点-->init.rc 这种方式创建的静态设备节点在调用驱动的时候就会找相关匹配的
所以在代码创建主设备号的时候就会有一个与之相匹配的设备号-->192
在驱动代码stp_chrdev_bt.c中
#define BT_DEV_MAJOR 192 
static int BT_major = BT_DEV_MAJOR;       /* dynamic allocation */
module_param(BT_major, uint, 0);
static int BT_init(void)
440{
441    dev_t dev = MKDEV(BT_major, 0);//创建主设备号!!!!
442    int alloc_ret = 0;
443    int cdev_err = 0;
.............
}
bt_drv.c
Pxa.c --->关于uart驱动相关
Mtk.c----->关于uart驱动相关
Hci_ldis.c --->hci_uart_init();-->Hci_bcsp.c-->bcsp_init();
Hci_bcsp.c-->uart_init();
Hci_bcsp.c-->main(int argc, char *argv[])
pxa.c --->static int serial_pxa_startup(struct uart_port *port)设置中断-->static inline irqreturn_t serial_pxa_irq(int irq, void *dev_id) 中断处理-->static inline void receive_chars(struct uart_pxa_port *up, int *status)接收数据-->tty_flip_buffer_push(tty)-->发送到disc中
Tty_buffer.c --->static void flush_to_ldisc(struct work_struct *work) 将数据写入 disc-->Tty_ldisc.c-->receive_buf()-->hci_uart_ldisc.receive_buf= hci_uart_tty_receive;-->hci_ldisc.c-->hci_uart_tty_receive-->将数据交给了hci层
{
static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
{
struct hci_uart *hu = (void *)tty->disc_data;


if (!hu || tty != hu->tty)
return;


if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
return;


spin_lock(&hu->rx_lock);
hu->proto->recv(hu, (void *) data, count);
hu->hdev->stat.byte_rx += count;
spin_unlock(&hu->rx_lock);


tty_unthrottle(tty);
}
}
Hci_bcsp.c ---> static int bcsp_recv(struct hci_uart *hu, void *data, int count) 接收hci_uart传上来的数据。
--> static void bcsp_complete_rx_pkt(struct hci_uart *hu)-->hci_core.c -->int hci_recv_frame(struct sk_buff *skb)

BT数据流程
1 uart口取得蓝牙模块数据;
2 uart口通过ldisc传个hci_uart;
3 hci_uart传给其上的bcsp;
4 bcsp 传给hci层
5 hci传给l2cap层
5 l2cap层传给rfcomm
从上层到驱动分析:

Settings.java(mBluetoothEnabler)--> LocalBluetoothAdapter.java-->BluetoothAdapter.java-->IBluetooth.java-->IBluetooth.aidl-->BluetoothService.java-->BluetoothAdapterStateMachine.java-->BluetoothService.java

bt上电
Stp_chrdev_bt.c-->BT_open(struct inode *inode,struct file *file)-->

---->Wmt_exp.c -->mtk_wcn_wmt_func_on


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值