高通平台msm8917蓝牙mac地址流程

高通平台msm8917蓝牙mac地址流程

Where is the BD address?
BD address can be saved in following places:

modem NV NV447
/persist/.bt_nv.bin OR /persist/bluetooth/.bt_nv.bin
/data/misc/bluedroid/bt_config.xml OR /data/misc/bluedroid/bt_config.conf
ro.boot.btmacaddr
persist.service.bdroid.bdaddr

How about QCOM default BD address solution?
In general there are 2 stage for BD address.One is on boot and the other is enabling Bluetooth from GUI.
while on boot stage, btnvtool will try to find bt_nv.bin.
if not exist, it will generate a BD address and save it to bt_nv.bin. If exist, do nothing and exit.
while on enabling BT stage, we will read BD address from bt_nv.bin and overwrite NVM tag 2.
Finally write all of the NVM tags into chipset, including tag 2.
After the chipset reset, BD address will take effect.

Details are as follows:
[On Boot Stage]
In init.qcom.rc, there is an android service named “config_bluetooth”. When Android boot, this service will be started.
It will trigger btnvtool with option “O”, which means on boot configuration.
btnvtool will try to find whether BD address already saved into bt_nv.bin or not.
If yes, will do nothing.
If not, the following operation depends on different version of Android.
Android L:

it will generate a random BD address base on clock and save it into bt_nv.bin.

Android M:

priority is designed to read BD address from different place:
1st of all, it will read BD address from modem NV through QMI interface.
if failed, it will read from android property "ro.boot.btmacaddr".
if still failed, it will generate a random address base on clock.
if ANY of the above steps success, we will save the BD address into file bt_nv.bin.

在这里插入图片描述

[On enabling BT Stage]
while enabling Bluetooth from GUI, we have different process for difference chipset.
As for WCN36xx, hci_qcomm_init will start running to download all NVM tags into chipset, including tag 2.
In hci_qcomm_init, so far there are 3 macros:
BT_QSOC_GET_ITEMS_FROM_NV,
BT_QSOC_GET_ITEMS_FROM_PERSIST,
BT_QSOC_GET_ITEMS_FROM_PROPERTY.

By default only BT_QSOC_GET_ITEMS_FROM_PERSIST is enabled. That means we will read the BD address from file: bt_nv.bin.
After defining other macros, OEM can change the default priority to read BD address from other places.
The priority is NV --> PERSIST --> PROPERTY.
if all of them failed, we will generate a random BD address base on clock.
for more details, please refer to func: bt_hci_qcomm_pfal_get_bdaddress()

As for QCA61x4, by default we will read BD address from bt_nv.bin as well.
If failed, there is complicated logic / priority to read BD address from various places.

General steps are as follows:

we get the path of saving BD address with property "ro.bt.bdaddr_path" and then read it.
if property is NULL, will read from bt_config.conf
if not found, will read from property "persist.service.bdroid.bdaddr" directly
if failed, will read from another property "ro.boot.btmacaddr"
if still failed, will read from file: bt_nv.bin(/persist/.bt_nv.bin  OR /persist/bluetooth/.bt_nv.bin).
if failed as well, will generate a random BD address base on clock. at the same time, save it to property "persist.service.bdroid.bdaddr".

If ANY of the above success, will save it to bt_config.conf.
For more details, please fer to func:btif_fetch_local_bdaddr()

Since Android M, OEM may change the default priority by enable macro READ_BT_ADDR_FROM_PROP.
After that, 1st priority will be android property “ro.boot.btmacaddr”.
if failed. we will read BD address from bt_nv.bin as the 2nd priority.
if still failed or no valid BD address, we will fall to the complicated logic / priority as above.

How to modify BD address?
Theoretically, OEM can customize their BD address solution in either stage.
However, for mass production we strongly recommend OEM to customize it in the boot stage.
This is because such kind of customization will be unified for various Android OS and QCOM BT chipset.

In details, OEM can change the implementation of option “O” in btnvtool.
If bt_nv.bin is not exist, read BD address from desired place and then save it to bt_nv.bin.
So for the 1st boot, bt_nv.bin will be created and BD address will be saved.
For the following boot, BD address in bt_nv.bin will be used.
For some unexpected reason that bt_nv.bin is missing, it will be recovered after the next boot.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值