Skip to content

Commit

Permalink
Fixes RP2040 buffer reallocation overrun problem (#642)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
ndinsmore committed Feb 12, 2021
1 parent 04ab6b4 commit 0986843
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/portable/raspberrypi/rp2040/dcd_rp2040.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ 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
_hw_endpoint_alloc(ep);
// 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;
Expand Down

0 comments on commit 0986843

Please sign in to comment.