最終更新:2022-08-24 (水) 18:17:20 (611d)  

g_zero
Top / g_zero

概要

  • Gadget Zero is a two-configuration device. It either sinks and sources bulk data; or it loops back a configurable number of transfers. It also implements control requests, for "chapter 9" conformance. The driver needs only two bulk-capable endpoints, so it can work on top of most device-side usb controllers. It's useful for testing, and is also a working example showing how USB "gadget drivers" can be written.
  • Make this be the first driver you try using on top of any new USB peripheral controller driver. Then you can use host-side test software, like the "usbtest" driver, to put your hardware and its driver through a basic set of functional tests.
  • Gadget Zero also works with the host-side "usb-skeleton" driver, and with many kinds of host-side test software. You may need to tweak product and vendor IDs before host software knows about this device, and arrange to select an appropriate configuration.

.config

実装の歴史

Linux 3.17

Linux 3.14

Linux 3.9

  • ファンクションの読み込みを新しいインターフェイスに変更
  • includeをやめ、usb_get_function_instanceでファンクション(SourceSink?,Loopback)を呼び出し
    usb_get_function_instance("SourceSink");
    usb_get_function_instance("Loopback");
  • CONFIG_USB_F_SS_LB?の場合はMakefileのほうでリンク
    f_ss_lb-y			:= f_loopback.o f_sourcesink.o
    obj-$(CONFIG_USB_F_SS_LB)	+= f_ss_lb.o

Linux 3.7

  • libcompositeが導入された
    • composite.oなどへのリンクを各モジュールでのincludeからlibcompositeへの依存に変更、下記のincludeを削除
      #include "composite.c"
      #include "usbstring.c"
      #include "config.c"
      #include "epautoconf.c"
  • この時点ではまだf_をincludeしている
    • #include "f_sourcesink.c"
      #include "f_loopback.c"
    obj-$(CONFIG_USB_LIBCOMPOSITE)	+= libcomposite.o
    libcomposite-y			:= usbstring.o config.o epautoconf.o
    libcomposite-y			+= composite.o
    
    g_zero-y			:= zero.o
    obj-$(CONFIG_USB_ZERO)		+= g_zero.o

Linux 2.6.28

  • モジュールのリンクをMakefileではなくソースコード側のincludeで行うように修正
    #include "composite.c"
    #include "usbstring.c"
    #include "config.c"
    #include "epautoconf.c"
    
    #include "f_sourcesink.c"
    #include "f_loopback.c"
    g_zero-objs			:= zero.o
    obj-$(CONFIG_USB_ZERO)		+= g_zero.o

Linux 2.6.27

  • コンポジットフレームワーク追加
    • composite.oを追加、下記のファンクションを分割、Makefileでファンクションをリンク
      • f_sourcesink?
      • f_loopback?
    C_UTILS =			composite.o usbstring.o config.o epautoconf.o
    g_zero-objs			:= zero.o f_sourcesink.o f_loopback.o $(C_UTILS)
    obj-$(CONFIG_USB_ZERO)		+= g_zero.o
  • https://github.com/torvalds/linux/commit/097db1d034b0927056f3d9e844dc80b3ba881765

Linux 2.5.70

  • Makefileでリンク
    g_zero-objs			:= zero.o usbstring.o config.o epautoconf.o
    obj-$(CONFIG_USB_ZERO)		+= g_zero.o

ソースコード