usb_gadget 1.0.3
usb_gadget: ^1.0.3 copied to clipboard
Implement USB gadgets for UDC-capable Linux systems — Kernel Functions and FunctionFS
Changelog #
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning].
1.0.3 #
Fixed #
Unistd.fcntlnow passes its third argument to the syscall. The generated FFI binding fixedfcntlto two parameters, so the optional argument was silently dropped — leavingsetFlags,setNonBlocking, and anyF_SET*/F_DUPFDcommand a no-op. A 3-argfcntlis now bound directly in the wrapper.Gadget.remove()no longer silently does nothing for auto-named gadgets.register()now records the resolved configfs name (e.g.usb-gadget0) soremove()can locate the gadget even whennamewas leftnull.- AIO and EP0 watcher isolates now
epoll_waitwith a bounded (1 s) timeout instead of blocking indefinitely. An indefinitely-blocked FFI call left the isolate un-pausable, hanging process shutdown anddart testwhen teardown was skipped (e.g. a failedsetUpAll). Real events/completions still wake the isolate immediately, so there is no added latency.
Changed #
- EP0 control events are now delivered event-driven via a dedicated
epoll_waitwatcher isolate instead of a 1 ms polling timer. This removes the constant idle-CPU wakeups and the up-to-1 ms latency the timer added to every control transfer. Reads and writes still happen on the main isolate, preserving theep0.read/ep0.writecontract; the watcher only signals readiness. The watch isEPOLLONESHOTand the main isolate reads exactly one event batch per wake then re-arms — EP0 is a control state machine, so reading again before answering a pending SETUP would corrupt the kernel's setup state (the reply would fail withESRCH). BufferPool.freeis now O(1) (address→index map + membership flags) instead of two linear scans per released buffer, removing per-packet overhead on the AIO hot path.- EP0 control writes use a zero-copy
Uint8List.sublistViewwindow instead of allocating a fresh sublist on everyEAGAINretry.
1.0.2 #
Fixed #
- Track live
RegGadgetinstances in a global registry soRegGadget.all()andGadget.remove()operate on the original instances containing populated function lists, rather than reconstructing empty shells from the filesystem. This fixesremove()failing to unmountFunctionFsinstances (EBUSY) and leaving stale configfs directories behind.
1.0.1 #
Changed #
- Update
lintsto 6.1.0 and includepackage:lints/recommended.yaml
Fixed #
- Add missing curly braces to control flow statements in
aio_stream.dartandnet.dart - Remove unnecessary
awaiton non-future ingadget/core.dart - Remove redundant
this.qualifier inendpoint/core.dart - Simplify
getConfigAttributesinNetworkFunctionusing null-aware syntax
1.0.0 #
Added #
UsbGadget.remove()to clean up configfs registrations without holding aRegGadgethandle- Integration tests for bulk transfers, ZLP, and endpoint halt via Python USB host driver
Changed #
- BREAKING:
RegGadget.bind()is nowvoid(wasFuture<void>) — call sites no longer needawait - BREAKING: Remove
RegGadget.unbindAll() - Move
gadget.register()insidetryblock; usegadget.remove()infinallyfor simplified lifecycle - Move USB Chapter 9 definitions (
descriptors,speeds,types) tolib/src/usb/ch9/sub-package - Simplify
Future.delayedcalls — remove redundant<void>type arguments - Simplify doc comments in
ErrnoandFunctionFs
Fixed #
- HID endpoint poll and report intervals corrected to 8ms for High-Speed USB compatibility (was 10ms, which is invalid for HS)
UDCbinding error now includes the target UDC name in the log message
0.7.0 #
Added #
writeWhilemethod for continuous AIO writesisDummyUDCproperty on UDCusb-gadgetCLI tool for managing Linux USB gadgets- Comprehensive UVC frame and control configuration support
- Expanded UAC1 and UAC2 audio function attributes
devicePath()method toHIDFunction- Unit and integration tests for kernel USB functions
- Integration tests for bulk transfers, ZLP, and endpoint halt
Changed #
- Rename
ffsmodule touserland - Rename
GadgetFunctionTypetoFunctionType - Rename
USBDeviceStatetoDeviceState - Rename
USBHIDDescriptortoHIDDescriptor - Remove legacy
USBSpeedtypedef - Overhaul gadget and configuration management
- Delegate UDC state management and simplify Gadget API
- Improve
Id,Class, andConfigAPI stability and validation - Introduce
FunctionFsInterfaceand improve descriptor handling - Introduce
ConfigFsTreefor robust gadget teardown - Make
prepare()asynchronous - Make
write()asynchronous and implement backpressure - Make
onDisablea synchronous method on HID - Replace
Comparableimplementation with comparison operators inSpeedenum - Tune AIO buffer sizing
- Update examples to use
writeWhileand improve lifecycle handling - Rewrite ping/pong example to support large transfers and benchmarking
Fixed #
- Add state checks to
write()andflush() - Ignore
EINVALin read loop and include stack traces - Support zero-length packets in
AioStream - Default HID endpoint intervals for high-speed compatibility
- Use numeric value for
MaxPowerattribute in gadget configfs
0.6.0 #
Added #
- FFI bindings and
Epollwrapper for Linuxepollandeventfdsystem calls, supporting I/O multiplexing withcreate,add,modify,delete, andwait, pluseventfdnotification helpers
Changed #
- Restructure kernel AIO bindings — rename
platform/aiotoplatform/libaio, introduce aLibaiowrapper with scratch arrays to minimize allocations, and add anIocbowning wrapper with factory methods for read/write ops - Restructure endpoint directory and simplify AIO initialization
- Relocate
AioStreamandBufferPooltolib/src/endpoint/aio/; remove seek offsets and ensure data is copied from native buffers before pool return to prevent use-after-free - Remove
AioSink, oldAioContext, and other high-level AIO abstractions in favor of the more directlibaiointerface - Rename
DeviceClass.compositetoperInterface - Use
DynamicLibrary.process()to access libc in errno handling
Fixed #
- Refresh OUT endpoints on enable to recover from host de-configuration,
replacing dead
AioStreaminstances without requiring consumers to re-subscribe - Rename
restart()torefresh()on FunctionFS
0.5.0 #
Changed #
- Use
release()instead ofclose()for endpoint lifecycle - Move
Releasablemixin andrelease()toEndpointFilebase class - Remove
droppedWritestracking fromAioSink
Fixed #
- Add disabled state and fix
onDisabletransition in FunctionFS - Await
_releaseEndpointsto prevent concurrent map modification - Do not release endpoints on disable or release in HID
- Prevent removing from empty write queue in
AioSink - Await close during resource release in
AioSink - Handle writing to closed sink gracefully in
AioSink