linux-2.6.11/Documentation/usb/amd5536udc.txt の和訳(ドラフト) H.Suzuki 2006/06/26 ------------------------------------------------------------------------------- Howto for Linux device driver for the AMD5536 USB Device Controller (UDC) for gadget driver stack (周辺)機器 (ガジェット) ドライバスタック 用 AMD5536 USB デバイスコントローラ (UDC) の Linux デバイスドライバ についての HOWTO ------------------------------------------------------------------------------- Author: Thomas Dahlmann 著者: Thomas Dahlmann INTRODUCTION: 概要: The AMD5536 UDC is part of x86 southbridge AMD5536 and MIPS CPU Au1200. It is a DMA capable usb device controller. The usb port is shared between host and UDC. The on-chip UOC controller is used to switch the usb port between host, UDC and neutral. So amd5536uoc driver is needed to get the UDC operating. AMD5536 UDC は、x86 サウスブリッジ AMD5536 および、MIPS CPU Au1200 の一部です。 それは、DMA 機能を持った USB デバイスコントローラです。USB ポートは、ホストと UDC 間で共有されます。オンチップの UOC コントローラは、USB ポートホスト間、UDC と ニュートラルの切替えに使います。ですから、UDC を機能させるのに amd5536uoc が必要です。 ------------------------------------------------------------------------------- WHAT YOU NEED: 必要なもの: ------------------------------------------------------------------------------- copy/replace following files to /usr/src/linux/drivers/usb/gadget 以下のファイルを /usr/src/linux/drivers/usb/gadget にコピー/置換えます。 amd5536udc.c amd5536udc.h amd5536uoc.c amd5536uoc.h ether.c file_storage.c zero.c inode.c gadget_chips.h Makefile Kconfig ------------------------------------------------------------------------------- HOW TO INSTALL IT: インストール方法: ------------------------------------------------------------------------------- change to directory /usr/src/linux /usr/src/linux ディレクトリに移動します configure gadget as module: ガジェットをモジュールとして設定: "make menuconfig" under "Code maturity level options" choose "Prompt for development ..." goto "Device Drivers" goto "USB support" -> "USB Gadget support" choose "Support for USB Gadgets" as module under choice "USB Peripheral Controller" choose "AMD5536-UDC" under "USB Gadget Drivers" choose "Gadget Zero" as module or choose "Ethernet Gagdet" as module or choose "File-backed Storage Gadget" as module exit and save config "make menuconfig" を実行 "Code maturity level options" choose "Prompt for development ..." の下 "Device Drivers" に移動 "USB support" -> "USB Gadget support" に移動 "Support for USB Gadgets" をモジュールとして選択 選択した "USB Peripheral Controller" の中で、"AMD5536-UDC" を選択 "USB Gadget Drivers" の下 "Gadget Zero" をモジュールとして選択、または "Ethernet Gagdet" をモジュールとして選択、または "File-backed Storage Gadget" をモジュールとして選択 設定を保存して終了 compile and install modules: モジュールをコンパイルしてインストール: "make modules modules_install" ------------------------------------------------------------------------------- HOW TO USE IT: 使用方法: ------------------------------------------------------------------------------- *** How to load FILE-BACKED STORAGE gadget driver - mass storage *** *** FILE-BACKED STORAGE ガジェットドライバの組込み方法 - 大容量記憶装置 *** enable USB mass storage support for linux host: linux ホスト用の USB 大容量記憶装置サポートを有効にする: change to directory /usr/src/linux "make menuconfig" under "File systems" choose "DOS/FAT/NT filesystems" choose "MSDOS fs support" under "Device Drivers" under "SCSI device support" choose "SCSI device support" choose "SCSI generic support" under "Device Drivers" under "USB support" in section "USB Device Class drivers" choose "USB Mass Storage support" compile new kernel /usr/src/linux ディレクトリに移動 "make menuconfig" を実行 "File systems" 下の "DOS/FAT/NT filesystems" を選択 "MSDOS fs support" を選択 "Device Drivers" 下の、"SCSI device support" の下 "SCSI device support" を選択 "SCSI generic support" を選択 "Device Drivers" 下の "USB support" の下、セクション内 "USB Device Class drivers" を選択 "USB Mass Storage support" 新しいカーネルを構築 create disk file: ディスクファイルを作成: "dd bs=1M count=128 if=/dev/zero of=/tmp/disk" => creates a 128Mbyte image file /tmp/disk => 128Mバイトのイメージファイル /tmp/disk を作成 load modules: モジュールの組込み: "modprobe amd5536udc" "modprobe g_file_storage file=/tmp/disk" Note: multiple file arguments are possible, each will be a separate drive for the host side, furthermore devices such as /dev/hda (whole disk will be used) or /dev/hda1 (partition) can be used as argument too 注記: file 引数を複数指定できます。それぞれはホスト側の分割された ドライブでありえます。さらに、/dev/hda (ディスク全体が使われます) または、/dev/hda1 (パーティション) も引数に使えます。 "modprobe amd5536uoc" create a primary FAT16 disk partition via linux host site: linux ホストサイト経由で、プライマリ FAT16 ディスクパーティションを作成する: "fdisk /dev/sda", make FAT16 prim. partition "fdisk /dev/sda" で、FAT16 プライマリパーティションを作る => "n", "p", "1", "", "", "t", "6", "w", "mkdosfs /dev/sda1" "sync" create primary disk partition via Windows XP host site: Windows XP ホストサイト経由で、プライマリディスクパーティションを作成する: right click on "My Computer" choose "Manage" => "Disk Management" choose usb disk and follow instructions of partition menu "My Computer" を右クリック "Manage" => "Disk Management" を選択 usb ディスクを選択し、パーティションメニューの手順に従う mount usb mass storage device on linux host: USB 大容量記憶デバイスを linux ホストでマウント: make directory "/mnt/gadget/" "/mnt/gadget/" ディレクトリを作成 "mount -t msdos /dev/sda1 /mnt/gadget" *** How to access files of disk image on UDC side *** *** UDC 側のディスクイメージファイルのアクセス方法 *** When files were copied from host to UDC mass storage device then files are inside the monolitic disk image (see above) on UDC side. This disk image can be mounted via the loopback device driver to a directory on UDC side to access these files. ファイルがホストから UDC 大容量記憶デバイスにコピーされたとき、 ファイルは、UDC 側のモノリシックディスクイメージ (上記参照) 内に存在します。 このディスクイメージは、それらファイルにアクセスするために、ループバックデバイス ドライバ経由で UDC 側のディレクトリにマウントできます。 Steps on UDC side: UDC 側での手順: enable kernel support for loopback device change to directory /usr/src/linux "make menuconfig" under "Block devices" choose "Loopback device support" and recompile the kernel ループバックデバイスカーネルサポートを有効にする /usr/src/linux ディレクトリに移動 "make menuconfig" "Block devices" の下、"Loopback device support" を選択し カーネルを再構築 determine offset inside disk image: "fdisk -l -u disk_image", output is like: ディスクイメージ内のオフセットを決定: "fdisk -l -u disk_image", 出力は以下のようになります: >> You must set cylinders. >> You can do this from the extra functions menu. >> >> Disk /tmp/disk128: 5 heads, 52 sectors, 0 cylinders >> Units = sectors of 1 * 512 bytes >> >> Device Boot Start End Blocks Id System >> /tmp/disk128p1 52 262079 131014 6 FAT16 get offset my multiplying start value by sector size: 開始値をセクタサイズで掛けることでオフセットを得る: 52 * 512 = 26624 mount disk image: ディスクイメージをマウント: "mount -o loop,offset=26624 -t msdos disk_image /mnt" *** How to load ZERO gadget driver - simple BULK loop back *** *** ZERO ガジェットドライバを組込む方法 - 単純な BULK ループバック *** load modules: モジュールを組込む: UDC driver: UDC ドライバ: (a) Slave/Fifo mode: "modprobe amd5536udc use_dma=0" (b) DMA Buffer Fill mode: "modprobe amd5536udc use_dma=1" default: (c) DMA PPBNDU mode: "modprobe amd5536udc" (d) DMA PPBDU mode: "modprobe amd5536udc use_dma=1 use_dma_ppb=1 use_dma_ppb_du=1" (e) fullspeed mode: "modprobe amd5536udc use_fullspeed=1", can be combined with all dma modes (f) special higspeed tx buffer size: "modprobe amd5536udc hs_tx_buf=" example: "modprobe amd5536udc use_dma=1 hs_tx_buf=128" => buffer size = 512 bytes (=bulk max packet) (a) Slave/Fifo モード: "modprobe amd5536udc use_dma=0" (b) DMA バッファフィルモード:"modprobe amd5536udc use_dma=1" デフォルト: (c) DMA PPBNDU モード: "modprobe amd5536udc" (d) DMA PPBDU モード: "modprobe amd5536udc use_dma=1 use_dma_ppb=1 use_dma_ppb_du=1" (e) fullspeed モード: "modprobe amd5536udc use_fullspeed=1", 全ての DMA モードと 組み合わせられます。 (f) 特別な higspeed tx バッファサイズ: "modprobe amd5536udc hs_tx_buf=" 例: "modprobe amd5536udc use_dma=1 hs_tx_buf=128" => バッファサイズ = 512 バイト (=bulk 最大パケット) Gadget Zero driver: ガジェット Zero ドライバ: (a) Bulk loop: "modprobe g_zero" (b) Int loop: "modprobe g_zero use_interrupt_traffic=1" (c) Source/Sink "modprobe g_zero loopdefault=0" OUT data must all be zero's (d) Source/Sink count "modprobe g_zero loopdefault=0 pattern=1" each OUT packet must count modulo63 (0,1,..,62,0,1,..) (a) Bulk ループ: "modprobe g_zero" (b) Int ループ: "modprobe g_zero use_interrupt_traffic=1" (c) Source/Sink "modprobe g_zero loopdefault=0" 出力データは、全て 0 になるはずです。 (d) Source/Sink カウント "modprobe g_zero loopdefault=0 pattern=1" each OUT packet must count modulo63 (0,1,..,62,0,1,..) UOC driver: "modprobe amd5536uoc" UOC ドライバ: "modprobe amd5536uoc" example: 例: "modprobe amd5536udc" "modprobe g_zero" "modprobe amd5536uoc" => loads driver for DMA PPBNDU mode and Bulk loop => DMA PPBNDU モードと Bulk ループドライバを組込む *** How to use ETHERNET gadget driver (CDC protocol) *** with Linux Host *** Linux ホストでの ETHERNET ガジェットドライバ (CDC プロトコル) の使いかた *** UDC side bringup: UDC を立上げる: load gadget modules ガジェットモジュールを組込む "modprobe amd5536udc" "modprobe g_ether" "modprobe amd5536uoc" "ifconfig usb0 192.168.0.2" Host side bringup: ホスト側を立上げる: install support for CDC Ethernet: change to directory /usr/src/linux "make menuconfig" under "Device Drivers" under "USB support" under "USB Network adapters" choose "Multi-purpose USB Networking Framework" choose "CDC Ethernet support" compile mew kernel CDC イーサネットサポートをインストール: /usr/src/linux ディレクトリに移動 "Device Drivers" 下の "USB support" 下の "USB Network adapters" を選択 "Multi-purpose USB Networking Framework" "CDC Ethernet support" を選択 新しいカーネルを構築 "modprobe CDCEther" "ifconfig eth1 192.168.0.1" note: assuming there is one network card assigned to eth0, otherwise kernel messages of CDC Ethernet module show which interface (ethX) is used 注記: ここでは、ひとつのネットワークカードを eth0 に割り当てることを 仮定していますが、他の場合、CDC イーサネットモジュールの カーネルメッセージは、インタフェース (ethX) が使われることを示します。 Use network connection: ネットワーク接続を使う: after bringup of host and UDC side it behaves like a normal ethernet connection between host and UDC ホストと UDC 側を立ち上げた後、ホストと UDC 間は、通常のイーサネット接続と、 同様に振る舞います test the connection: 接続テスト: host side: "ping -I eth1 192.168.0.2" UDC side : "ping -I usb0 192.168.0.1" note: the "-I" option assures that the USB cable is used, the option can be omitted when the routing table is setup to avoid using other network interfaces as eth0 注記: "-I" オプションは、USB ケーブルを使うことを宣言し、オプションが省略されたなら、 ルーティングテーブルが設定されるときに 他のネットワークインタフェースを eth0 として使うのを回避します。