系列文章
I.MX6ULL 手册查找使用方法 实战点亮LED(寄存器版)
I.MX6ULL 手册查找使用方法 实战点亮LED(固件库版本)
linux 字符设备驱动实战
linux LED设备驱动文件
linux 设备树(.dts)实战解析
linux 使用设备树点亮LED 实战
linux 驱动中并发与竞争
linux 内核定时器
linux 内核中断理解
linux 驱动阻塞和非阻塞
linux 内核异步通知
linux platform驱动框架
linux 内核自带的LED灯驱动
linux misc设备驱动
linux input子系统
linux 深入理解I2C内核驱动
linux SPI 驱动
linux USB无线网卡(RTL8188EUS)驱动
linux UART驱动_应用程序例程
一、Linux 内核自带HOST实验
1、USB鼠标键盘驱动使能
USB鼠标键盘属于HID设备,内核已经集成了相应的驱动
1.1、首先打开HID驱动
-> Device Drivers
->HID support
<*>Generic HID support
1.2、使能USB键盘和鼠标驱动
-> Device Drivers
->HID support
->USB HID support
<*> USB HID transport layer
光标在USB HID transport layer 使用查看详细说明
需要注意的是 You can’t use this driver and the HIDBP (Boot Protocol) keyboard and mouse drivers at the same time. 此驱动和HIDBP(Boot Protocol) 键盘、鼠标的驱动不能一起使用。
重新编译内核,插入鼠标测试
root@ATK-IMX6U:~# [ 107.213945] usb 2-1.1: new full-speed USB device number 8 using ci_hdrc
[ 107.358611] input: Logitech USB Receiver as /devices/platform/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb2/2-1/2-1.1/2-1.1:1.0/0003:046D:C534.0001/input/input4
[ 107.454797] hid-generic 0003:046D:C534.0001: input: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-ci_hdrc.1-1.1/input0
[ 107.482960] input: Logitech USB Receiver as /devices/platform/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb2/2-1/2-1.1/2-1.1:1.1/0003:046D:C534.0002/input/input5
[ 107.555419] hid-generic 0003:046D:C534.0002: input: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-ci_hdrc.1-1.1/input1
2、U盘实验
U盘使用SCSI协议
1.1、使能SCSI协议
->Device Drivers
->SCSI device support
<*> SCSI disk support
1.2、使能USB Mass Storage,大容量存储设备
->Device Drivers
->USB support
-><*>Support for Host-side USB
//同一级目标下
-><*>USB Mass Storage support
root@ATK-IMX6U:~# [ 726.483979] usb 2-1.1: new high-speed USB device number 9 using ci_hdrc
[ 726.599482] usb-storage 2-1.1:1.0: USB Mass Storage device detected
[ 726.625708] scsi host0: usb-storage 2-1.1:1.0
[ 727.635832] scsi 0:0:0:0: Direct-Access SanDisk Ultra Backup 2.01 PQ: 0 ANSI: 6
[ 727.666212] sd 0:0:0:0: [sda] 31266816 512-byte logical blocks: (16.0 GB/14.9 GiB)
[ 727.678505] sd 0:0:0:0: [sda] Write Protect is off
[ 727.691027] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 727.720566] sda: sda4
[ 727.733627] sd 0:0:0:0: [sda] Attached SCSI disk
[ 728.500487] FAT-fs (sda4): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
系统检测到U盘,容量大小(16.0 GB/14.9 GiB)
挂载到/opt/mnt 目录下,即可访问U盘内容。-t vfat -o iocharset=utf8 可以指定文件系统和编码格式
mount /dev/sda4 /opt/mnt/ -t vfat -o iocharset=utf8
root@ATK-IMX6U:/opt/mnt# ls -l
-rwxrwx--- 1 root disk 707903177 Oct 22 2020 mpp.tar.gz
drwxrwx--- 2 root disk 8192 Sep 18 2020 '$RECYCLE.BIN'
drwxrwx--- 2 root disk 8192 Sep 18 2020 'System Volume Information'
二、内核自带USB OTG实验(从机)
原理图上OTG
USB OTG1 的 ID 引脚连接到了 I.MX6ULL 的 GPIO1_IO00 这个引脚上,USB OTG 默认工作在主机(HOST)模式下,因此 ID 线应该是低电平。
打开设备树 imx6ull-alientek-emmc.dts,在 iomuxc 节点的 pinctrl_hog_1 子节点下添加 GPIO1_IO00 引脚信息。
1、模拟U盘(将开发版上的U盘,挂载到PC上)
-> Device Drivers
-> USB support
-> USB Gadget Support
-> [M]USB Gadget Drivers
-> [M]Mass Storage Gadget
编译后.ko文件复制到开发版上/lib/modules/4.1.15/,并且替换zImage文件
drivers/usb/gadget/libcomposite.ko
drivers/usb/gadget/function/usb_f_mass_storage.ko
drivers/usb/gadget/legacy/g_mass_storage.ko
加载驱动模块
depmod
modprobe libcomposite.ko
modprobe usb_f_mass_storage.ko
modprobe g_mass_storage.ko file=/dev/sda1 removable=1
2、USB 开发版作为PC声卡
-> Device Drivers
-> USB support
-> USB Gadget Support
-> [M]USB Gadget Drivers
->[M] Audio Gadget
->UAC 1.0 (Legacy)
drivers/usb/gadget/libcomposite.ko
drivers/usb/gadget/function/usb_f_uac1.ko
drivers/usb/gadget/legacy/g_audio.ko
将生成的.ko文件复制到开发板上,并且替换zImage文件。加载
depmod
modprobe libcomposite.ko
modprobe usb_f_uac1.ko
modprobe g_audio.ko
在PC上会出现,AC Interface的设备
选择声音输出,则开发版完全是USB声卡设备