TX1安装usbserial及cp210x驱动

http://blog.csdn.net/handsome_for_kill/article/details/52780737

TX1安装usbserial及cp210x驱动

为了拿TX1作为上位机,通过USB连线与底层电路通信,那么usbserial驱动必不可少。但是,当我拿到TX1以后,发现了一件非常尴尬的事情,那就是没有这个驱动。所以我把底层电路板用USB线与TX1连接起来以后,发现找不到ttyUSB0这个设备,当然也就没有办法读取他,利用他通信了。所以,这里介绍一下如何为TX1安装USB转串口的驱动——cp210x驱动,方便大家的开发。

Step 1:下载TX1FTDIModule

到github上下载这个文件,附网址如下: 
https://github.com/jetsonhacks/TX1FTDIModule 
下面这个网址是一个相关问题的答案,大家也可以参考一下: 
https://devtalk.nvidia.com/default/topic/912219/compiling-kernel-modules-for-jetson-tx1/?offset=4

Step 2:安装编译环境

安装编译环境以便于待会儿编译linux内核模块时不会报错。具体方法可以参考TX1FTDIModule的readme文件。 
方法:解压TX1FTDIModule,进入解压后的目录,之后按如下方法操作:

chmod +x installFTDIModule.sh
sudo ./installFTDIModule.sh

 
 
  • 1
  • 2
  • 3

Step 3:下载内核源代码并编译cp210x模块

依然在刚才那个目录,找到prepareModule.sh文件,打开并编辑这个文件。

#!/bin/sh
# Prepare to build the FTDI module for LT4 21.4 on the NVIDIA Jetson TK1
if [ $(id -u) != 0 ]; then
   echo "This script requires root permissions"
   echo "$ sudo "$0""
   exit
fi
# Get the kernel source for LT4 21.4
cd /usr/src/
wget http://developer.download.nvidia.com/embedded/L4T/r23_Release_v1.0/source/kernel_src.tbz2
# Decompress
tar -xvf kernel_src.tbz2
cd kernel
# Get the kernel configuration file
zcat /proc/config.gz > .config
# Enable FTDI compilation
sudo sed -i 's/# CONFIG_USB_SERIAL_FTDI_SIO is not set/CONFIG_USB_SERIAL_FTDI_SIO=m/' .config
# Make sure that the local kernel version is set
LOCALVERSION=$(uname -r)
# vodoo incantation; This removes everything from the beginning to the last occurrence of "-"
# of the local version string i.e. 3.10.67 is removed
release="${LOCALVERSION##*-}"
CONFIGVERSION="CONFIG_LOCALVERSION=\"-$release\""
# Replace the empty local version with the local version of this kernel
sudo sed -i 's/CONFIG_LOCALVERSION=""/'$CONFIGVERSION'/' .config
# Prepare the module for compilation
make prepare
make modules_prepare
# Compile the module
make M=drivers/usb/serial/
# After compilation, copy the compiled module to the system area
cp drivers/usb/serial/ftdi_sio.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial
depmod -a
/bin/echo -e "\e[1;32mFTDI Driver Module Installed.\e[0m"
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

需要更改的地方比较多,由于这是较旧以前的版本,下载的内核源代码可能不是我们目前TX1内核在用的,另外这是编译FTDI模块的脚本文件,我们需要更改一下,用来编译cp210x模块。步骤如下: 
1 更改下载地址 
可以看到这一行语句:

wget http://developer.download.nvidia.com/embedded/L4T/r23_Release_v1.0/source/kernel_src.tbz2
 
 
  • 1

这一句话的含义即下载内核源文件,内核源文件要根据自己TX1上所使用的版本来下载,这些脚本文件的原作者用的版本是L4T 23.1,而我的版本是L4T 24.1,所以我需要把这一句话改成:

wget 
http://developer.download.nvidia.com/embedded/L4T/r24_Release_v1.0/24.1_64bit/source/kernel_src.tbz2
 
 
  • 1
  • 2

至于如何查看自己现在系统所用的内核版本,我的方法比较蠢,就是打开JetPack,看看自己安装的是什么版本。具体的版本信息可以到以下网址参考: 
https://developer.nvidia.com/embedded/downloads#?search=Kernel 
2 选取对应模块 
可以看到下面这句话:

sudo sed -i 's/# CONFIG_USB_SERIAL_FTDI_SIO is not set/CONFIG_USB_SERIAL_FTDI_SIO=m/' .config
 
 
  • 1

这句话的含义是修改当前目录下的.config文件,把# CONFIG_USB_SERIAL_FTDI_SIO is not set这句话替换成CONFIG_USB_SERIAL_FTDI_SIO=m,而我们要安装的是cp210x模块,所以应该修改为如下语句:

sudo sed -i 's/# CONFIG_USB_SERIAL_CP210X is not set/CONFIG_USB_SERIAL_CP210X=m/' .config
 
 
  • 1

有的版本的.config文件没有# CONFIG_USB_SERIAL_FTDI_SIO is not set这句话,这是可以改成如下:

sudo sed -i 's/CONFIG_USB_SERIAL_CP210X=y/CONFIG_USB_SERIAL_CP210X=m/' .config
 
 
  • 1

想要检查是否更改成功,可以直接打开.config文件查看,如果没有成功也可以直接在文件中进行修改。.config文件的位置在/usr/src/kernel。(注意:这个文件是在你运行了prepareModule.sh这个脚本之后才会存在的) 
3 复制模块 
看到下面语句:

cp drivers/usb/serial/ftdi_sio.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial
 
 
  • 1

由于我们是cp210x模块,所以很明显这句话应该改成:

cp drivers/usb/serial/cp210x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial
 
 
  • 1

到了这一步,我们就可以直接运行这个脚本文件了,等待编译完毕即可。

Step 4:导入cp210x模块

tx1内部自带了cp210x模块,位置是/usr/src/kernel/drivers/usb/serial/下

使用以下命令:

sudo insmod cp210x.ko

 
 
  • 1
  • 2

检验是否导入成功,可以用以下命令:

lsmod

 
 
  • 1
  • 2

如果输出中有cp210x模块,说明成功了,现在插上USB转串口的设备就可以看到ttyUSB0了。这里同样有一个可以参考的网址如下: 
http://blog.csdn.net/qingfengtsing/article/details/51783337


1、在win98、winme、win2000,windows XP系统中: 先双击driver里hidcominst程序,它没有任何显示。然后再插上USB线, 根据系统提示及可正确安装安装完成之后,进入设备管理器,在“端口”一栏中可以看到虚拟的串口设备 SemiTech USB-HID->COM device (COM X ) ,表示设备已经正确安装完成, 可以正常使用。 2、在WinXP系统中:有些可能失败安装HIDCOM driver 。双击driver里HidcomInst程序,就可以在设备管理器的"端口"一栏中可以看到虚拟的串口设备。semiTech.USB-HID->COM device (COM X ),表示设备已经正确安装完成,可以正常使用. 或者先插上USB线,进入设备管理器,在“人体学输入设备”一栏中可以看到 “HID-compliant Device”和“USB人体学输入设备” (在此之前请确认已经移去所有其他“USB人体学输入设备”), 在“HID-compliant Device”上点击鼠标右键: 选择:更新驱动程序 选择:从列表或指定位置安装,单击下一步, 选择:不要搜索,我要自己选择要安装驱动程序.单击下一步, 选择:从磁盘安装,打开浏览,从驱动盘中找到hidcom.INF文件,打开,单击确定, 选择下一步,此时系统会提示微软的数字签证,选择仍然继续,单击完成。 在“USB人体学输入设备”上点击鼠标右键: 选择:更新驱动程序 选择:从列表或指定位置安装,单击下一步, 选择:不要搜索,我要自己选择要安装驱动程序.单击下一步, 选择:从磁盘安装,打开浏览,从驱动盘中找到hidcom.INF文件,打开,单击确定, 选择下一步,此时系统会提示微软的数字签证,选择仍然继续,单击完成。 完成以上两项更新之后,在设备管理器的“端口”一栏中可以看到虚拟的串口设备 SemiTech USB-HID->COM device (COM X ) ,表示设备已经正确安装完成,可以正常使用。 3、如果在win98、winme、win2000系统安装过程中出现设备不能正常使用,请参看WinXP的 安装方法进行程序升级。
This bundle contains a modified CP210x driver for the 4.10.0 kernel (Ubuntu 17.04). It contains: - Support for the CP2102N NOTE: This driver is an example of how to perform GPIO operations within the CP210x driver since the driver on kernel.org does not support GPIO at this time. This driver has only been written and tested on the Linux 3.13.0 kernel on Ubuntu 14.04. This driver is a modified version of the existing driver in the Linux 3.13.0 kernel, which is maintained at kernel.org. It is recommened to use the driver there that matches your specific kernel version: www.kernel.org Build instrutions: Ubuntu: 1. make ( your cp210x driver ) 2. cp cp210x.ko to /lib/modules//kernel/drivers/usb/serial 3. insmod /lib/modules/<kernel-version/kernel/drivers/usb/serial/usbserial.ko 4. insmod cp210x.ko RedHat: 1. yum update kernel* //need to update the kernel first otherwise your header won't match 2. yum install kernel-devel kernel-headers //get the devel and header packages. 3. reboot //your build link should be fixed after your system come back 4. make ( your cp210x driver ) // should be able to build successfully at this point 5. cp cp210x.ko to /lib/modules//kernel/drivers/usb/serial 6a. insmod /lib/modules/<kernel-version/kernel/drivers/usb/serial/usbserial.ko 6. insmod cp210x.ko 7. sudo chmod 666 /dev/ttyUSB0 8. sudo chmod 666 /dev/ttyUSB1 GPIO example: This shows how to use the two IOCTLs to set GPIO state. Build instructions: 1. g++ cp210x_gpio_example.c -o cp210x_gpio_example 2. ./cp210x_gpio_example
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值