From 9e540ae1dbaaae0f701efc7613669a210dc9322f Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Sat, 8 Jun 2024 12:50:29 +0100 Subject: [PATCH] gateware.usb.request.standard: pass max packet size to GetDescriptor handler Previously, enumeration would fail on a low-speed device as it would try to return a longer packet that allowed to GetDescriptor requests. This makes sure to pass the max packet size through to the handler to set the limit correctly. --- luna/gateware/usb/request/standard.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/luna/gateware/usb/request/standard.py b/luna/gateware/usb/request/standard.py index aaf3d50e..aaf62f3f 100644 --- a/luna/gateware/usb/request/standard.py +++ b/luna/gateware/usb/request/standard.py @@ -58,7 +58,7 @@ def get_descriptor_handler_submodule(self): # The distributed handler supports a combination of fixed and runtime descriptors directly... if self._avoid_blockram: - return GetDescriptorHandlerDistributed(self.descriptors) + return GetDescriptorHandlerDistributed(self.descriptors, max_packet_length=self._max_packet_size) # ...but the block handler does not. In this case, first we split the descriptors into two # collections: fixed descriptors (for the ROM) and runtime descriptors. @@ -75,11 +75,11 @@ def get_descriptor_handler_submodule(self): # If there are runtime descriptors, we add a get descriptor multiplexer and a distributed handler. if has_runtime_descriptors: handler_mux = GetDescriptorHandlerMux() - handler_mux.add_descriptor_handler(GetDescriptorHandlerBlock(fixed_descriptors)) - handler_mux.add_descriptor_handler(GetDescriptorHandlerDistributed(runtime_descriptors)) + handler_mux.add_descriptor_handler(GetDescriptorHandlerBlock(fixed_descriptors, max_packet_length=self._max_packet_size)) + handler_mux.add_descriptor_handler(GetDescriptorHandlerDistributed(runtime_descriptors, max_packet_length=self._max_packet_size)) return handler_mux else: - return GetDescriptorHandlerBlock(self.descriptors) + return GetDescriptorHandlerBlock(self.descriptors, max_packet_length=self._max_packet_size) def elaborate(self, platform):