Fixes RP2040 buffer reallocation overrun problem
Fix running out of memory on a device that repeatedly closes and opens an endpoint. This is a workaround at the moment. A better solution would be to implement reclaiming usb buffer memory when closing an endpoint (i.e. implement dcd_edpt_close).
@@ -164,9 +164,13 @@ static void _hw_endpoint_init(struct hw_endpoint *ep, uint8_t ep_addr, uint wMax
ep->endpoint_control = &usb_dpram->ep_ctrl[num-1].out;
}
- // Now alloc a buffer and fill in endpoint control register
+ // Now if it hasn't already been done
+ //alloc a buffer and fill in endpoint control register
+ if(!(ep->configured))
+ {
_hw_endpoint_alloc(ep);
}
+ }
ep->configured = true;
}
