读书笔记 <Bootstrap Yourself with Linux USB Stack>

读书笔记 <Bootstrap Yourself with Linux USB Stack>

第一章 USB and Linux Introduction

  1. 关于USB的硬件
    三种类型:
    USB Transceiver, 通常包含一个USB core在芯片上
    Standalone USB Controller, transceiver + digital portion
    Integrated USB Controller,


第二章 USB: An Overview

  1. USB System Architecture


    分为三个主要部分:
        USB device
        USB host
        USB interconnect

  2. USB host

    HCD: host control driver
    USBD: USB driver
    IRP: input/output request packets

    它由以下几部分组成:
        Client Software
        USB System Software
        Host Controller

  3. USB Device

    它由以下3部分组成:
        Function
        USB Logical Device
        USB Bus Interface

  4. USB Host和USB Device之间如何交互


    Endpoint, 一个device可以根据其function提供多个endpoint, 每个以device address, endpoint number, endpoint direction唯一标识.
        Endpoint Zero是一个特殊的endpoint, 每个device都必须要实现它. 它供Usb host初始化和获得device的信息.
        Endpoint需要通过以下几点描述它自己:
        The bus access frequency/latency requirement
        The bandwidth requirement   
        The endpoint number
        The error-handling behavior requirements
        The maximum packet size that the endpoint is capable of sending or receiving
        The transfer type for the endpoint
        The direction in which data is transferred between the endpoint and thehost


    pipe, 它用来在逻辑上表示device endpoint和host software之间的联系. 最重要的一个pipe, 是用来连接host和endpoint zero的.
       stream pipe, 非USB-define format的数据
       message pipe, USB-define format的数据

  5. Enumeration
    它由host和device侧的USB logical layer共同配合完成.
    USB标准定义了标注流程:
    1. The USB device is attached to the host, which receives an event indicating a change in the pipe’s status. The USB device is in the powered state, and the port it is attached to is disabled.
    2. The host queries about the change in the bus.
    3. Once the host determines that a new device is attached, it waits for at least 100ms for the device to become stable after power, after which it enables and resets the port.
    4. After a successful reset, the USB device is in a default state and can draw power to a range of 100 mA from VBUS pin.
    5. Once the device is in a default state, the host assigns a unique address to the USB device, which moves the device to an address state.
    6. The host starts communicating with the USB device in the default control pipe and reads the device descriptor.
    7. Subsequently, the host reads the device configuration information.
    8. The host selects the configuration, which move the device to a configured state and makes it ready for use.


    Description
    标准定义device, configuration,interface, endpoint, string五类description.


  6. USB Transfers
    定义了4种transfer, 它们都描述了下述的属性:
    n Direction of communication flow
    n Constraint in the packet size
    n Bus access constraints
    n Latency constraints
    n Required data sequences
    n Error handling

    Control Transfer,
    Bulk Transfer, 大数据
    Interrupt Transfer, 小数据
    Isochronous Transfer, audio,video之类的实时大数据

  7. 一些重要术语
    Short packet. A short packet can be defined as a packet whose payload is
    shorter than the maximum size or zero length packet (ZLP). A short
    packet could indicate the end of a transfer.
    Zero length packet (ZLP). A zero length data packet transfer does not
    contain data as part of the transfer. When the data to be sent is an exact
    multiple of wMaxPacketSize, a ZLP has to be sent after the data transfer
    is complete to indicate the end of the transfer. Sometimes a ZLP feature
    is implemented as part of the hardware or has to be taken care when
    designing Chapter 9/USB.
    STALL. A STALL indicates that a function is unable to transmit or
    receive data or that even a control pipe request is not supported. The
    state of a function after returning a STALL is undefined.

第三章, Overview of the linux USB Subsystem

  1. Linux kernel中的USB相关代码结构



  2. 关于Gadget subsystem
    USB controller driver实现了USB device controller, 它
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
摘 要:基于对Linux 下蓝牙协议栈BlueZ 源代码的分析,给出BlueZ的组织结构和特点。分析蓝牙USB 传输驱动机制和数据处理过程, 给出实现蓝牙设备驱动的重要数据结构和流程,并总结Linux 下开发蓝牙USB 设备驱动的一般方法和关键技术。 关键词:Linux 系统;蓝牙协议栈;设备驱动 USB Device Driver for Linux Bluetooth Stack LIANG Jun-xue, YU Bin (Institute of Electronic Technology, PLA Information Engineering University, Zhengzhou 450004) 【Abstract】This paper depicts the structure and characteristics of BlueZ based on analyzing the source code of Linux bluetooth stack BlueZ. It analyzes the implementation of bluetooth USB transport driver scheme and data processing procedure in detail, and gives the key data structure and implementation of bluetooth device driver. It summarizes the approach of developing Linux bluetooth USB device driver and the key technology. 【Key words】Linux system; bluetooth stack; device driver 计 算 机 工 程 Computer Engineering 第 34 卷 第 9 期 Vol.34 No.9 2008 年 5 月 May 2008 ·开发研究与设计技术· 文章编号:1000—3428(2008)09—0273—03 文献标识码:A 中图分类号:TP391 1 概述 蓝牙技术是开放式通信规范,而 Linux 是开放源码的操 作系统。廉价设备与免费软件的结合,促进了蓝牙技术和 Linux 的发展与融合。 Linux最早的蓝牙协议栈是由Axis Communication Inc在 1999 年发布的 OpenBT 协议栈。 随后, IBM 发布了 BlueDrekar 协议栈,但没有公开其源码。Qualcomm Incorporated 在 2001 年发布的 BlueZ 协议栈被接纳为 2.4.6 内核的一部分。此外, Rappore Technology 及 Nokia 的 Affix Bluetooth Stack 都是 Linux 系统下的蓝牙协议栈,应用在不同的设备和领域中。 BlueZ 是 Linux 的官方蓝牙协议栈,也是目前应用最广 泛的协议栈,几乎支持所有已通过认证的蓝牙设备。对于基 于主机的蓝牙应用,目前常见的硬件接口有 UART, USB 和 PC 卡等,USB 作为 PC 的标准外设接口,具有连接方便、兼 容性好和支持高速设备等特点,已广泛应用于蓝牙设备。 目前对 LinuxUSB 设备驱动的研究已较为广泛而深 入[1-4] ,但对 Linux 下的蓝牙设备驱动还没有专门的研究。本 文在分析 USB 设备驱动和蓝牙协议栈的基础上,总结了 Linux 下开发蓝牙 USB 驱动程序的一般方法,并深入剖析了 其关键技术。 2 Linux 蓝牙协议栈 BlueZ 简介 BlueZ 目前已成为一个开放性的源码工程。它可以很好 地在 Linux 支持的各种体系的硬件平台下运行,包括各种单 处理器平台、多处理器平台及超线程系统。 BlueZ 由多个独立的模块组成,内核空间主要包括设备 驱动层、蓝牙核心及 HCI 层、L2CAP 与 SCO 音频层、 RFCOMM, BNEP, CMTP 与 HIDP 层、通用蓝牙 SDP 库和后 台服务及面向所有层的标准套接字接口;在用户空间提供了 蓝牙配置、测试及协议分析等工具。其组织结构如图 1 所示, BlueZ 没有实现专门的 SDP 层,而是将其实现为运行在后台 的蓝牙服务库例程(图 1 没有描述该后台服务)。 RFOMM 层支 持标准的套接口,并提供了串行仿真 TTY 接口,这使串行端 口应用程序和协议可以不加更改地运行在蓝牙设备上,例如 通过点对点协议 PPP 可实现基于 TCP/IP 协议簇的所有网络 应用。BNEP 层实现了蓝牙的以太网仿真,TCP/IP 可以直接 运行于其上。 USB设备驱动 (hci_usb.o) L2CAP层(l2cap.o) RFCOMM层 (rfcomm.o) BNEP层 (bnep.o) CMTP层 (cmtp.o) 串口设备驱动 (hci_uart.o) 虚拟串口设备驱动 (hci_vhci.o) 音频 socket RFCOMM socket BNEP socket CMTP socket L2CAP socket HCI socket 内核 空间 用户 空间 串口设备 CAPI设备 输入设备 网络设备 HDIP socket 音频设备 AF_BLUETOOTH socket 音频层(sco.o) PPP TCP/IP AF_INET socket BNEP层 (bnep.o) 其他设备驱动 (bluecard_cs.o等) BlueZ工具和实用程序 HDIP层 (hdip.o) BlueZ核心 及HCI层(bluez.o/bluetooth.o) 图 1 BlueZ 组织结构 3 蓝牙 USB 设备驱动 设备驱动程序在 Linux 内核中起着重要作用,它使某个 硬件能响应一个定义良好的内部编程接口。这些接口隐藏了 设备的工作细节,用户通过一组独立于特定驱动程序的标准 调用来操作设备。而将这些调用映射到作用于实际硬件设备 的特有操作上,则是驱动程序的任务。
<!DOCTYPE html> <html> <head> <title>表格形式</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> table, th, td { border: 1px solid black; border-collapse: collapse; padding: 5px; } </style> <script> // 添加一行 function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); for(var i = 0; i < 5; i++){ var cell = row.insertCell(i); cell.innerHTML = '<select><option value="1">选项1</option><option value="2">选项2</option><option value="3">选项3</option></select>'; cell.onclick = function(){ this.firstChild.style.display = 'block'; } cell.firstChild.onblur = function(){ this.style.display = 'none'; } cell.firstChild.style.display = 'none'; } } </script> </head> <body> <table id="myTable"> <thead> <tr> <th>列1</th> <th>列2</th> <th>列3</th> <th>列4</th> <th>列5</th> </tr> </thead> <tbody> <tr> <td><select><option value="1">选项1</option><option value="2">选项2</option><option value="3">选项3</option></select></td> <td><select><option value="1">选项1</option><option value="2">选项2</option><option value="3">选项3</option></select></td> <td><select><option value="1">选项1</option><option value="2">选项2</option><option value="3">选项3</option></select></td> <td><select><option value="1">选项1</option><option value="2">选项2</option><option value="3">选项3</option></select></td> <td><select><option value="1">选项1</option><option value="2">选项2</option><option value="3">选项3</option></select></td> </tr> </tbody> </table> <button onclick="addRow('myTable')">增加</button> </body> </html>将这段代码用bootstrap进行优化
最新发布
04-23

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值