最終更新:2022-08-24 (水) 18:17:20 (626d)
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
- legacyフォルダに移動
- 初期化の定義をmodule_init->usb_composite_probeからmodule_usb_composite_driver?に変更
Linux 3.14
- ファンクション側がconfigfsをサポート
- configfs_item_operations
- config_item_type?
- https://github.com/torvalds/linux/commit/c0501f47c68997ea2933460b9908e6a049c59f21
- https://github.com/torvalds/linux/commit/25d8015177ae7baedb8bdc76dffc0884b0d785a3
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
obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o libcomposite-y := usbstring.o config.o epautoconf.o libcomposite-y += composite.o functions.o g_zero-y := zero.o obj-$(CONFIG_USB_ZERO) += g_zero.o
- https://github.com/torvalds/linux/commit/cf9a08ae5aece88987bbeee8eb0dd0ebb5015815
Linux 3.7
- libcompositeが導入された
- composite.oなどへのリンクを各モジュールでのincludeからlibcompositeへの依存に変更、下記のincludeを削除
- (CONFIG_USB_ZEROがselect CONFIG_USB_LIBCOMPOSITEになった)
#include "composite.c" #include "usbstring.c" #include "config.c" #include "epautoconf.c"
- composite.oなどへのリンクを各モジュールでのincludeからlibcompositeへの依存に変更、下記のincludeを削除
- この時点ではまだ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
- コンポジットフレームワーク追加
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