一、 将从厂商拿到的sensor驱动代码放入以下目录

ADSP.VT.5.4.2/adsp_proc/ssc_drivers/

二、 将驱动配置到编译列表

adsp_proc/ssc/chipset/strait/por.py

24 include_sensor_vendor_libs.extend([25'sns_af6133e',#MAG26'sns_mmc56x3x', #MAG27'sns_icm4x6xx', #ACC28'sns_ltr569',#LIGHT/PROX29'sns_stk3a5x',#LIGHT/PROX30'sns_sx933x' #SAR31])

可通过下面生成的c文件可以确认编译了哪些sensor外设

adsp_proc/ssc/framework/build/sensor_img/qdsp6/strait.adsp.prod/sns_static_drivers.c

/*=========================================================@file sns_static_drivers.cThis file is autogenerated. Do not modify.Copyright (c) 2023 Qualcomm Technologies, Inc.All Rights Reserved.Confidential and Proprietary - Qualcomm Technologies, Inc.2023-05-25 05:26:31.780802 ===========================================================*/#include "sns_rc.h"#include "sns_register.h"#include "sns_types.h"sns_rc sns_register_af6133e(sns_register_cb const *register_api);sns_rc sns_register_aw_sar(sns_register_cb const *register_api);sns_rc sns_register_icm4x6xx(sns_register_cb const *register_api);sns_rc sns_register_icp201xx(sns_register_cb const *register_api);sns_rc sns_register_ltr569(sns_register_cb const *register_api);sns_rc sns_register_mmc56x3x(sns_register_cb const *register_api);const sns_register_entry sns_static_drivers_list[] ={ { sns_register_af6133e, 1, false}, { sns_register_aw_sar, 1, true}, { sns_register_icm4x6xx, 1, true}, { sns_register_icp201xx, 1, true}, { sns_register_ltr569, 1, false}, { sns_register_mmc56x3x, 1, false},};const uint32_t sns_static_drivers_list_len = ARR_SIZE(sns_static_drivers_list);

6375平台参考设计默认用的g-sensor是i3c总线的,对于用i2c总线的g-sensor做如下更改

ADSP.VT.5.4.2/adsp_proc/core/settings/buses/i2c/config/strait/i2c_devcfg.c

158static plat_device_config i2c_device_config[] =159{160#ifdef ENABLE_I2C_01161{... ... --- 174.gpi_protocol= PROTOCOL_I3C, +++ 174.gpi_protocol= PROTOCOL_I2C,... ...

ADSP.VT.5.4.2/adsp_proc/core/settings/buses/qup_fw/config/strait/fw_devcfg.c

--- se_cfg se0_cfg_qrd = { 0x80000, SE_PROTOCOL_I3C,GSI, TRUE, TRUE};+++se_cfg se0_cfg_qrd = { 0x80000, SE_PROTOCOL_I2C,GSI, TRUE, TRUE};

三、 编译

cd ADSP.VT.5.4.2/adsp_proc/build/ms && python ./build_variant.py strait.adsp.prod

四、验证

将ADSP.VT.5.4.2/adsp_proc/build/ms/bin/strait.adsp.prod/splitbins 下面的adsp.bxx和adsp.mdt通过adb push到机器中验证

1. 重新挂载为读写

adb root; adb shell mount -o rw,remount /vendor/firmware_mnt ;

2. push的路径

/vendor/firmware_mnt/image

也可以重新打包

cd Strait.LA.2.1.1/common/buildpython build.py

用fastboot 烧写nonhlos

Strait.LA.2.1.1/common/build/ufs/bin/asic/NON-HLOS.bin

fastboot flash modem_a NON-HLOS.bin

五、json配置文件

5.1 修改json文件,以holi_icm4x6xx_0.json为例子,需要注意的是下面几项

"config":{"hw_platform": ["MTP", "QRD"],"soc_id": ["454", "435", "459", "507"]},"icm4x6xx_0_platform":{"owner": "sns_icm4x6xx",".config":{"owner": "sns_icm4x6xx","bus_type":{ "type": "int", "ver": "0","data": "0"},"bus_instance":{ "type": "int", "ver": "0","data": "1"},"slave_config":{ "type": "int", "ver": "0","data": "104"},

1. hw_platform 可以 cat /sys/devices/soc0/hw_platform 确认

2. soc_id 可以 cat /sys/devices/soc0/soc_id 确认

3. bus_type 0 表示i2c, 还有i3c, spi, uart具体查看高通文档

4. bus_instance在6375平台有两路QUP用于sensor,看硬件连接选择1或者2 (从1开始)

5. slave_config 器件的i2c地址,这里填的是7bit地址的10进制

5.2 机器root以后push json文件到 /vendor/etc/sensors/config/

5.3 重启机器验证,如果不行检查/mnt/vendor/persist/sensors/registry/registry/ 下面 icm4x6xx相关的文件是否生成,

如果没有则说明hw_platform 或 soc_id 不匹配

5.4 json 文件没问题后,放到入的 vendor/qcom/proprietary/sensors-see/registry/config/ 对于的平台名字的目录下

六、 Debug

进入QXDM后按快捷键F3调出Message View窗口,右键选择configure设置过滤sns的log

对于sensor初始化时的log抓不到的情况,将ADSP子系统重启打开通过QXDM发送命令重启ADSP抓取init阶段log

确认adsp所在的subsys后将related写入restart_level

send_data 75 37 03 48 00