高通Android工程释放ADSP侧GPIO给AP侧(HLOS)解决uart只能收或者发,gpio 无法配置成输入或者输出
在许多sensor的调试过程中总是会遇到各种GPIO被占用的情况,特别是以下几种情况:UART 只能发或收,GPIO 配置了pinctl output但是gpio依旧为输入。
1、判断GPIO口状态
不管是不是被ADSP占用导致工作异常,首先我们需要查看一下GPIO的状态,查看方法如下
cat /sys/kernel/debug/gpio 部分日志: GPIOs 0-141, platform/1000000.pinctrl, 1000000.pinctrl: gpio0 : in 0 2mA pull down gpio1 : in 0 2mA pull down gpio2 : out 0 2mA pull down gpio3 : in 0 2mA pull down gpio4 : out 2 2mA no pull gpio5 : out 2 2mA no pull gpio6 : in 0 2mA no pull gpio7 : in 0 2mA no pull gpio8 : in 0 2mA pull down gpio9 : in 0 2mA pull down gpio10 : in 0 2mA no pull gpio11 : in 0 2mA no pull gpio12 : in 2 2mA no pull gpio13 : in 2 2mA no pull gpio14 : out 3 2mA pull up gpio15 : out 3 2mA pull up gpio16 : in 2 2mA no pull gpio17 : in 2 2mA no pull gpio18 : in 0 2mA pull down gpio19 : in 0 2mA pull down gpio20 : in 2 2mA no pull
此时我们就可以通过 80-P2472-1B_C_MSM8953_GPIO_Configuration_Spreadsheet.xlsm此类GPIO 配置文档去查看相关GPIO与外设引脚的对应关系。
2、查看是否与ADSP冲突
既然查看到某个GPIO状态配置异常,接下来就应该考虑是否是ADSP 冲突引起,可以通过以下方法删除Sensor配置文件释放所有端口测试冲突是否存在。
adb root adb remount adb shell rm /mnt/vendor/persist/sensors/sns.reg (qcm2150 此项必须先执行,否则push进去的conf文件不生效) adb shell rm /persist/sensors/sns.reg (msm8953 此项必须先执行,否则push进去的conf文件不生效) adb shell rm /vendor/etc/sensors/sensor_def_qcomdev.conf adb sync adb reboot
执行以上操作后如果问题消失了,那么必然是ADSP冲突导致。
3、配置ADSP文件
在上面进一步验证成功后修改工程下的 /vendor/etc/sensors/sensor_def_qcomdev.conf 或者直接将开发板根文件系统中的/vendor/etc/sensors/sensor_def_qcomdev.conf 用adb pull下来修改。
#序号 #引脚号 #属性值 #注释 #SPI GPIO active and inactive 6330 1 0x00010001 # version 6331 0x0014 0x00010001 # gpio num 6332 1 0x00010001 # active func sel 6333 1 0x00010001 # active dir 6334 0 0x00010001 # active pull 6335 3 0x00010001 # active drive 6336 0 0x00010001 # inactive func sel 6337 0 0x00010001 # inactive dir 6338 2 0x00010001 # inactive pull 6339 0 0x00010001 # inactive drive ############################################# # 修改方法:将需要释放的引脚号改成0xFFFF,然后将属性值改成0x00020002 切勿直接删除或者注释掉这一行,因为如果没有新的值,即便是整包刷机都不会覆盖原有的属性。这些参数是和sensor校准参数放在同一个分区,不会因为刷机删除。
4、刷入测试
两种方法:整编代码然后整包刷入;通过adb push 配置文件
将sensor_def_qcomdev.conf push 到板子进行测试 adb shell rm /mnt/vendor/persist/sensors/sns.reg (2150 此项必须先执行,否则push进去的conf文件不生效) adb shell rm /persist/sensors/sns.reg (8953 此项必须先执行,否则push进去的conf文件不生效) adb shell rm /vendor/etc/sensors/sensor_def_qcomdev.conf adb push sensor_def_qcomdev.conf /vendor/etc/sensors/sensor_def_qcomdev.conf adb shell chmod 644 /vendor/etc/sensors/sensor_def_qcomdev.conf adb shell sync adb reboot
分类:
嵌入式开发
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!