前言
项目中使用TX2的核心板,我们自己制作了载板。在驱动适配的过程中,出现了以一些问题,在此进行整理分享。
一、usb不工作
使用原始的dts,usb phy 异常,lsusb 没有任何输出
dmesg
[ 3.357876] xhci-tegra 3530000.xhci: can’t get usb3-0 phy (-517)
[ 3.358051] tegra-usb-cd usb_cd: otg phy is not available yet
[ 3.359253] tegra-xudc-new 3550000.xudc: usb2 phy is not available yet
在网上找到的解决方法如下,测试后可以解决该问题。
For r28.1, here are steps in detail:
1 Uncompress the kernel_src-tx2.tbz2 to get the kernel source code.
2 Modify the code in tegra186-quill-power-tree-p3310-1000-a00-00.dtsi
- ./common/kernel-dts/t18x-common-platforms/tegra186-quill-power-tree-p3310-1000-a00-00.dtsi: vbus-2-supply = <&vdd_usb2_5v>;
+ ./common/kernel-dts/t18x-common-platforms/tegra186-quill-power-tree-p3310-1000-a00-00.dtsi: vbus-2-supply = <&battery_reg>;
3 Re-compile the code and get the new tegra186-quill-p3310-1000-c03-00-base.dtb.
4 Copy the dtb file to below locations:
./rootfs/boot/tegra186-quill-p3310-1000-c03-00-base.dtb
./bootloader/tegra186-quill-p3310-1000-c03-00-base.dtb
./kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb
5 Re-flash TX2(或者只更新dtb)
sudo ./flash.sh jetson-tx2 mmcblk0p1
二、更新dtb方法
适配驱动时,需要经常烧写Image和dtb,每次都使用flash.sh来烧写的话,稍微有点麻烦。
- 烧写 Image,可以直接将Image复制到 /boot/ 目录。设备起来时,uboot会加载/boot/Image 来启动。
- 烧写dtb,需要修改 /boot/extlinux/extlinux.conf 文件,才可以实现,uboot加载
/boot/*.dtb 文件,修改如下:
TIMEOUT 30
DEFAULT primary
MENU TITLE L4T boot options
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
FDT /boot/tegra186-quill-p3310-1000-c03-00-base.dtb
INITRD /boot/initrd
APPEND ${cbootargs} quiet
三、kernel无法启动,怎么修复
我修改内核源码,重新编译获得Image,并替换了/boot/Image文件。由于修改问题,无法启动内核。
修改方案:
- 使用sdkmanager重新刷新,如果这样做,将花费很长时间;
- 想办法替换掉/boot/Image文件;
- 让uboot引导kernel分区启动,后在更新/boot/Image文件。
尝试1:
使用如下命令更新内核分区:
./flash.sh -k kernel jetson-tx2 mmcblk0p1
查看日志,可以确认更新成功,但是系统仍然无法启动。
因为,uboot加载 /boot/Image来启动,而flash.sh无法更新/boot/Image文件。
修改uboot的环境变量,让uboot无法加载到 /boot/extlinux/extlinux.conf 脚本,但是uboot还是无法引导kernel分区启动。到底怎么修改uboot环境变量,我暂时也不知道,请高手解答。
尝试2:
在uboot命令行界面可以看到文件系统中/boot/ 目录下的文件,那么应该也是可以修改的,到底怎么修改,我没有找到办法。
尝试3:
在另为一个存储器上启动系统,类似pc装机使用的老毛桃工具。
- 在sd卡中创建/boot/ 目录,在/boot目录中放入extlinux/extlinux.conf、Image和initrd文件。
- 插上sd后,重启系统。此时uboot首先会加载mmc1(sd卡)中/boot/Image,kernel正常启动后会加载mmc0中的文件系统。
- 将 mmc0 中 的/boot/Image 替换为正常Image。
- 拔掉sd卡,重新启动,系统恢复正常。
四、禁止UART7回显
修改设备树,使能uart7
serial@c290000 {
compatible = "nvidia,tegra186-hsuart";
status = "okay";
};
重新编译设备树并替换,启用了UART7(D5,D8),通过dmesg信息可以看出新生成ttyTHS6设备节点,测试其收发数据,发现该uart具有回显功能。
修改方案:
默认情况下,UART-7用于BPMP调试,您也可以修改BPMP dts。
- Convert the DTB to DTS using dtc tool in Linux_for_Tegra
#cd Linux_for_Tegra/bootloader/t186ref/
#dtc -I dtb tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2.dtb -o test1_bpmp.dts
- Change the DTS file to disable UART7
#vi test_bpmp.dts
change the value of "port" under node serial to 255
- Rebuild the DTB file
# dtc -I dts test1_bpmp.dts -O dtb -o tegra186-a02-bpmp-quill-p3310-1000-c04-00-te770d-ucm2.dtb
- Flash the bpmp DTB partition
#cd Linux_for_Tegra/
#./flash.sh -k bpmp-fw-dtb jetson-tx2 mmcblk0p1
五、pin配置为GPIO功能
项目中有用到GPIO控制功能,但是查看《Jetson-TX2-Series-Pinmux-Template_v1.04.xlsm》,发现有些引脚没有相应的GPIO编号。这些引脚难道不能配置为GPIO功能。
所有从CVM发出都可以配置为GPIO的信号,
请查看pinmux配置文件,
例如
tegra186-mb1-bct-pinmux-quill-p3310-1000-c03.cfg
pinmux.0x02432018 = 0x00004401; # dmic2_clk_pm3: i2s3, tristate-disable, input-disable
pinmux.0x02432010 = 0x00004441; # dmic2_dat_pm2: i2s3, tristate-disable, input-enable
根据pinmux cfg,‘p’ 后的GPIO端口。数字表示GPIO端口内的偏移量。
即
pin H6
DMIC2_CLK, dmic2_clk_pm3, TEGRA_GPIO(M, 3);
pin E6
DPAD4_SCLK, dap4_sclk_pcc0, TEGRA_GPIO(CC, 0);