高通平台某项目uart串口不能正常工作的故障解决

某个MSM8953的项目,在调试的过程中遇到uart6只能发不能收的情况。android 9.0版本,GPIO的配置如下:
高通平台某项目uart串口不能正常工作的故障解决_第1张图片
客户要求使用4组uart:uart2、uart4、uart6为低速串口,uart5为高速串口。
设备树配置如下:

//uart2: GPIO4,5    ttyMSM0
&blsp1_uart0 {
     
	status = "ok";
	pinctrl-names = "default";
	pinctrl-0 = <&uart_console_active>;
};

//uart4: GPIO12,13  ttyMSM1
&blsp1_serial1 {
     
	status = "ok";
	pinctrl-names = "sleep", "default";
	pinctrl-0 = <&blsp1_serial1_sleep>;
	pinctrl-1 = <&blsp1_serial1_active>;
};

//uart5: GPIO16-17-18-19   ttyHS0  (High-speed)
&blsp2_uart0 {
     
	status = "ok";
};

//uart6:GPIO20,21      ttyMSM2
&blsp2_serial1 {
     
	status = "ok";
	pinctrl-names = "default";
	pinctrl-0 = <&uart1_console_active>;
};

比较怪异的是uart2、4、5都是正常的,uart6只能发,不能收;验证故障时还发现不同的编译主机上单独编译boot,单独刷boot时功能还是正常的。

分析过程:
1.首先排查驱动是不会有问题的,因为所有的低速uart设备都是共用同一个驱动的。

2.排查gpio的权限设置。8953 GPIO的权限设置在modem侧:TZ.BF.4.0.5/trustzone_images/core/buses/qup_accesscontrol/bear/config/QUPAC_8953_Access.xml
检查这里BLSP6的权限是已经设为AC_NONE的:

   // This instance is reserved for SPI Sensors use case in ADSP.
   <device id=BLSP_QUP_6_DEV_ACCESS>
      <props name="CHIP_BUS_INDEX"      type=DALPROP_ATTR_TYPE_UINT32>     BLSP_QUP_6             </props>
      <props name="BUS_PROTOCOL"        type=DALPROP_ATTR_TYPE_UINT32>     PROTOCOL_SPI           </props>
      <props name="IS_GPIO_PROTECTED"   type=DALPROP_ATTR_TYPE_UINT32>     0                      </props>
      <props name="GPIO_NUMBERS"        type=DALPROP_ATTR_TYPE_BYTE_SEQ>   20, 21, 22, 23, end    </props> 
      <props name="GPIO_RG_INDEX"       type=DALPROP_ATTR_TYPE_BYTE_SEQ>   end                    </props> 
      //Begin:Modify to reconfigure gpio20/21/22/23 in HLOS 
      //     AC_ADSP_Q6_ELF         
      <props name="SUBSYSTEM_ID"        type=DALPROP_ATTR_TYPE_UINT32>     AC_NONE                </props>
      //End:Modify to reconfigure gpio20/21/22/23 in HLOS 
      <props name="IS_PERSISTENT"       type=DALPROP_ATTR_TYPE_UINT32>     0                      </props>
      <props name="CORE_RG_INDEX"       type=DALPROP_ATTR_TYPE_UINT32>     10                     </props>

	  // This property is for internal purpose. If customer don't want any changes in existing setting 
      // in this BLSP instance, they can go ahead. If any change is needed in existing settings, 
      // please delete the below property before changing this BLSP instance settings.
      <props name="QCOM_INTERNAL_ALTR_DEV_ID_2"   type=DALPROP_ATTR_TYPE_STRING_PTR> alt2_qup6   </props>
      <props name="QCOM_INTERNAL_ALTR_DEV_ID_3"   type=DALPROP_ATTR_TYPE_STRING_PTR> alt2_qup6   </props>
   </device>  

3.在init.target.rc中增加了对应的权限:
on boot
chmod 0666 /dev/ttyMSM0
chmod 0666 /dev/ttyMSM1
#uart6
chmod 0666 /dev/ttyMSM2
没有效果。

4.尝试修改GPIO的驱动电流、修改uart的注册顺序、注释掉SPI6的节点等尝试都没有效果,分析和固件的执行权限可能有关系。因为不同的编译机器编出来的文件其校准信息是不一样的,继续向这个方向分析。

5.用示波器测试uart6的波形,发现RX TX一直为高。说明uart6并没有正常工作。这里注意到一个问题:高通的参考设计图上,GPIO20-23默认是作为sensor的spi接口使用的,而sensor相关的处理是在adsp中的。我们的代码是基于高通的QRD项目来的,会不会是这一块没有改到呢?
高通平台某项目uart串口不能正常工作的故障解决_第2张图片
按照高通的建议,删除sensor的配置:
/vendor/etc/sensors/sensor_def_qcomdev.conf
/mnt/vendor/persist/sensors/sns.reg
果然正常了。显然,是sensor相关SPI6的复用导致的。

6.问题进一步验证:
spi gpio的配置是在sensor_def_qcomdev.conf中,刷别的机器编译的boot而正常的原因是由于boot对分区验证的原因而导致sensor_def_qcomdev.conf这个文件并没有生效的。
手动修改sensor_def_qcomdev.conf这个文件后,push到系统发现uart6功能正常,但是编译全版本下载验证uart6仍然不行。
根据高通文档说明:
80-N7635-1Snapdragon™ Sensors Core (SSC) NewSensor Driver Integration Guide for Linux Android
3.4.2.2 Using version numbers to update specific registry items
An over-the-air update could change the default registry values by incrementing the file :version
key, and any new/updated items. The next time the sensor service starts, it parses the
configuration file and overwrites the items with version numbers greater than the previously
stored file version number.
To overwrite the I2C address for configuration 0 that was applied from the example in
Section 3.4.1, increment the file and item version numbers:
:version 0x00010002
:hardware 8974

#SSI SMGR Cfg 0
1903 0x11FFEEDDCCBBAA99 0x00010001 # Low UUID
1902 0x9988665544332211 0x00010001 # High UUID
1906 3 0x00010002 # I2C Bus – updating from 12 to 3
修改完配置后还需要修改下版本号的,参考如下:

diff --git a/vendor/qcom/proprietary/sensors/dsps/reg_defaults/sensor_def_qcomdev.conf b/vendor/qcom/proprietary/sensors/dsps/reg_defaults/sensor_def_qcomdev.conf
old mode 100644
new mode 100755
index 99b40d990d..0eeb515bea
--- a/vendor/qcom/proprietary/sensors/dsps/reg_defaults/sensor_def_qcomdev.conf
+++ b/vendor/qcom/proprietary/sensors/dsps/reg_defaults/sensor_def_qcomdev.conf
@@ -112,7 +112,7 @@
 # The numeric fields are parsed with the strtoull function, base 0.
 #
 
-:version 0x00010001
+:version 0x00010002
 
 #######################################################################
 ###        MSM8976,APQ8076 and MSM8956 Chipsets
@@ -1830,63 +1830,6 @@
 4112 65536   0x10001 # SMD
 4103 5 0x10001 # SMD_ACC_WIN_TIME
 
-# SSI SMGR Cfg 0: LSM6DS3 Accel DRI/FIFO
-1903 0x1a0bd9d5956c508e 0x00010001 #UUID
-1902 0x1246e1cb09a92baa 0x00010001 #UUID
-1904 100000 0x00010001             #off_to_idle
-1905 0 0x00010001                  #idle_to_ready
-1906 0x1006 0x00010001             #SPI_bus
-1907 1000 0x00010001               #reg_group_id
-1908 0 0x00010001                  #cal_grp_id
-1909 42 0x00010001                 #gpio1
-1910 0xFFFF 0x00010001             #gpio2
-1911 0 0x00010001                  #sensor_id
-1912 0 0x00010001                  #CS for SPI
-1913 1 0x00010001                  #data_type1
-1914 4 0x00010001                  #data_type2
-1915 -1 0x00010001                 #rel_sns_idx
-1916 2 0x00010001                  #sens_default
-1917 0xD0 0x00010001               #flags
-1982 0 0x00010001                  #device_select
-
-# SSI SMGR Cfg 0: LSM6DS3 GYRO DRI/FIFO
-1919 0x1a0bd9d5956c508e 0x00010001 #UUID
-1918 0x1246e1cb09a92baa 0x00010001 #UUID
-1920 100000 0x00010001             #off_to_idle
-1921 0 0x00010001                  #idle_to_ready
-1922 0x1006 0x00010001             #SPI_bus
-1923 1010 0x00010001               #reg_group_id
-1924 10 0x00010001                 #cal_grp_id
-1925 42 0x00010001                 #gpio1
-1926 0xFFFF 0x00010001             #gpio2
-1927 10 0x00010001                 #sensor_id
-1928 0 0x00010001                  #CS for SPI
-1929 3 0x00010001                  #data_type1
-1930 4 0x00010001                  #data_type2
-1931 -1 0x00010001                 #rel_sns_idx
-1932 3 0x00010001                  #sens_default
-1933 0xD0 0x00010001               #flags
-1983 0 0x00010001                  #device_select
-
-# SSI SMGR Cfg 2: AKM09915 DRI/FIFO
-1935 0x90611b98d561168f 0x00010001 #UUID
-1934 0x564d2b94fe80aef6 0x00010001 #UUID
-1936 3000 0x00010001               #off_to_idle
-1937 10000 0x00010001              #idle_to_ready
-1938 0x1006 0x00010001             #SPI_bus
-1939 1020 0x00010001               #reg_group_id
-1940 0xFFFF 0x00010001             #cal_grp_id
-1941 44 0x00010001                 #gpio1
-1942 0xFFFF 0x00010001             #gpio2
-1943 20 0x00010001                 #sensor_id
-1944 2 0x00010001                  #CS_for_SPI
-1945 2 0x00010001                  #data_type1
-1946 0 0x00010001                  #data_type2
-1947 0xFF 0x00010001               #rel_sns_idx
-1948 0 0x00010001                  #sens_default
-1949 0xD0 0x00010001               #flags
-1984 0 0x00010001                  #device_select
-
 # SSI SMGR Cfg 3: BMP280 POLL
 1951 0x32c31ec17f1c0abd 0x00010001 #UUID
 1950 0x5c473990a806b072 0x00010001 #UUID
@@ -2233,7 +2176,7 @@
 
 # SPI GPIO
 6340       1 0x00010001 # version
-6341  0x0014 0x00010001 # gpio num
+6341  0xffff 0x00010002 # gpio num
 6342       1 0x00010001 # active func sel
 6343       1 0x00010001 # active dir
 6344       0 0x00010001 # active pull
@@ -2244,7 +2187,7 @@
 6349       3 0x00010001 # inactive drive
 
 6350       1 0x00010001 # version
-6351  0x0015 0x00010001 # gpio num
+6351  0xffff 0x00010002 # gpio num
 6352       1 0x00010001 # active func sel
 6353       1 0x00010001 # active dir
 6354       0 0x00010001 # active pull
@@ -2255,7 +2198,7 @@
 6359       3 0x00010001 # inactive drive
 
 6360       1 0x00010001 # version
-6361  0x0016 0x00010001 # gpio num
+6361  0xffff 0x00010002 # gpio num
 6362       1 0x00010001 # active func sel
 6363       1 0x00010001 # active dir
 6364       0 0x00010001 # active pull
@@ -2266,7 +2209,7 @@
 6369       3 0x00010001 # inactive drive
 
 6370       1 0x00010001 # version
-6371  0x0017 0x00010001 # gpio num
+6371  0xffff 0x00010002 # gpio num
 6372       1 0x00010001 # active func sel
 6373       1 0x00010001 # active dir
 6374       0 0x00010001 # active pull

这样修改后验证uart6功能正常,问题至此解决。

另外要注意,高通的低速串口默认最大只支持3路,如果4路全部配置为低速,需要自己再添加一路:
修改文件kernel\msm-4.9\drivers\tty\serial\msm_serial.c

static struct msm_port msm_uart_ports[] = {
     
	{
     
		.uart = {
     
			.iotype = UPIO_MEM,
			.ops = &msm_uart_pops,
			.flags = UPF_BOOT_AUTOCONF,
			.fifosize = 64,
			.line = 0,
		},
	},
	{
     
		.uart = {
     
			.iotype = UPIO_MEM,
			.ops = &msm_uart_pops,
			.flags = UPF_BOOT_AUTOCONF,
			.fifosize = 64,
			.line = 1,
		},
	},
	{
     
		.uart = {
     
			.iotype = UPIO_MEM,
			.ops = &msm_uart_pops,
			.flags = UPF_BOOT_AUTOCONF,
			.fifosize = 64,
			.line = 2,
		},
	},
	//自己添加一路配置
};

你可能感兴趣的:(sensor,串口通信,uart,物联网)