TX2i设备树SPI驱动
默认/dev下是没有spi设备的
JetPack版本
JetPack-L4T-3.2.1-linux-x64_b23.run
下载Kernel
sudo git clone http://github.com/jetsonhacks/buildJetsonTX2Kernel.git
git checkout L4T32.2.1 //切换分支
./getKernelSources.sh //获取源码
默认配置内核
cd /usr/src/kernel/kernel-4.4
make tegra18_defconfig
安装依赖
sudo apt-get install libncurses5-dev
配置内核
make menuconfig
模块方式加载SPI
编译内核
cd buildJetsonTX2Kernel
./makeKernel.sh
生成内核模块
拷贝内核
反编译设备树
cd /boot/dtb //目录下的就是当前模块使用的设备树
sudo /usr/src/kernel/kernel-4.4/scripts/dtc/dtc -I dtb -O dts -o myTX2iDeviceTree.dts tegra186-quill-p3489-1000-a00-00-ucm1.dtb
修改设备树
sudo vim myTX2iDeviceTree.dts
spi@3240000 { compatible = "nvidia,tegra186-spi"; reg = <0x0 0x3240000 0x0 0x10000>; ... linux,phandle = <0x7d>; phandle = <0x7d>; spi@0 { compatible = "spidev"; reg = <0x0>; spi-max-frequency = <0x1312D00>; nvidia,enable-hw-based-cs; nvidia,cs-setup-clk-count = <0x1e>; nvidia,cs-hold-clk-count = <0x1e>; nvidia,rx-clk-tap-delay = <0x1f>; nvidia,tx-clk-tap-delau = <0x0>; }; };
重新编译设备树
sudo /usr/src/kernel/kernel-4.4/scripts/dtc/dtc -I dts -O dtb -o myTX2iDeviceTree.dtb myTX2iDeviceTree.dts
注:TX2i设备树反编译,也看不到设备树的修改记录
拷贝设备树
将myTX2iDeviceTree.dtb放到虚拟机的jetson/64_TX2/Linux_for_Tegr/kernel/dtb目录下
cp myTX2iDeviceTree.dtb tegra186-quill-p3489-1000-a00-00-ucm1.dtb //覆盖原TX2i设备树文件
开发板进入Recovery模式
按住REC恢复键不放,轻点一下RST复位键
烧写设备树
cd jetson/64_TX2/Linux_for_Tegr
sudo ./flash.sh -r -k kernel-dtb jetson-tx2i mmcblk0p1 //将烧写tegra186-quill-p3489-1000-a00-00-ucm1.dtb文件
完成