目录

为 i.MX 6 开发板配置 Linux 驱动

内核驱动

开发板使用的是飞凌的OKMX6Q-S3开发板,搭载的是NXP i.MX6Quad. 这里以cp210x usb转串口驱动为例

cp210x驱动在linux 2.6及其以后的版本已经内置,所以需要做的就是在内核配置中加入,不用去官网下载cp210x驱动

虚拟机开发环境准备

直接使用飞凌资料里提供linux4.1.15的ubuntu 12虚拟机

必须使用用户资料里提供的linux 4.1.15压缩包,不要使用虚拟机里面的压缩包

改源

首先改源 备份

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

修改

sudo gedit /etc/apt/sources.list

把之前的替换为

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

刷新

sudo apt-get update

添加右键支持

ubuntu 12 点击右键没有在当前目录打开终端的功能,故打开右键终端支持

sudo apt-get install nautilus-open-terminal

重新加载文件管理器

nautilus -q

在内核配置中添加cp210x支持,并加载

make menuconfig 前需要安装

sudo apt-get install libncurses5-dev

根据飞凌手册执行

make imx_v7_defconfig

启动文本菜单配置

make menuconfig

在配置目录 Device Drivers -> USB support -> USB Serial Converter support 下可以找到 CP210x

加载环境变量

Linux下可以通过两种方式加载驱动程序:静态加载和动态加载。

  • 若采用静态加载,按y,显示*:编译连接到镜像文件

然后单独编译镜像重新烧录,插入cp210x的设备端作为测试,能检测到ttyUSB就成了

  • 若采用动态加载按m,显示m:编译

然后单独编译模块,编译完成后会在drivers/usb/serial下生成一个cp210x.ko,把它用u盘考到开发板上 用insmod cp210x.ko加载,lsmod查看,rmmod删除

动态加载的方式,调试方便,断电就没了,静态加载调试麻烦,但不用每次开机都重新加载。

自定义驱动

参考手册,多了编写c代码,配置Kconfig, Makefile的步骤