@@ -205,7 +205,7 @@ bool tu_edpt_release(tu_edpt_state_t* ep_state, osal_mutex_t mutex) {
205205 return ret ;
206206}
207207
208- bool tu_edpt_validate (tusb_desc_endpoint_t const * desc_ep , tusb_speed_t speed ) {
208+ bool tu_edpt_validate (tusb_desc_endpoint_t const * desc_ep , tusb_speed_t speed , bool is_host ) {
209209 uint16_t const max_packet_size = tu_edpt_packet_size (desc_ep );
210210 TU_LOG2 (" Open EP %02X with Size = %u\r\n" , desc_ep -> bEndpointAddress , max_packet_size );
211211
@@ -221,8 +221,17 @@ bool tu_edpt_validate(tusb_desc_endpoint_t const* desc_ep, tusb_speed_t speed) {
221221 // Bulk highspeed must be EXACTLY 512
222222 TU_ASSERT (max_packet_size == 512 );
223223 } else {
224- // TODO Bulk fullspeed can only be 8, 16, 32, 64
225- TU_ASSERT (max_packet_size <= 64 );
224+ // Bulk fullspeed can only be 8, 16, 32, 64
225+ if (is_host && max_packet_size == 512 ) {
226+ // HACK: while in host mode, some device incorrectly always report 512 regardless of link speed
227+ // overwrite descriptor to force 64
228+ TU_LOG1 (" WARN: EP max packet size is 512 in fullspeed, force to 64\r\n" );
229+ tusb_desc_endpoint_t * hacked_ep = (tusb_desc_endpoint_t * ) (uintptr_t ) desc_ep ;
230+ hacked_ep -> wMaxPacketSize = tu_htole16 (64 );
231+ } else {
232+ TU_ASSERT (max_packet_size == 8 || max_packet_size == 16 ||
233+ max_packet_size == 32 || max_packet_size == 64 );
234+ }
226235 }
227236 break ;
228237
0 commit comments