高通平臺某項目uart串口不能正常工作的故障解決

某個MSM8953的項目,在調試的過程中遇到uart6只能發不能收的情況。android 9.0版本,GPIO的配置如下:
在這裏插入圖片描述
客戶要求使用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 
      //<props name="SUBSYSTEM_ID"        type=DALPROP_ATTR_TYPE_UINT32>     AC_ADSP_Q6_ELF         </props>
      <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項目來的,會不會是這一塊沒有改到呢?
在這裏插入圖片描述
按照高通的建議,刪除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,
		},
	},
	//自己添加一路配置
};
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章