summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorndinsmore <[email protected]>2021-02-12 03:16:46 -0500
committerGitHub <[email protected]>2021-02-12 08:16:46 +0000
commit09868434cd9f53394350cce682333ada97f796c3 (patch)
tree97c139b6003211d30677b7625d26487785c53cd9 /src
parent04ab6b4082101ba3d7c066db244b227f2de3fc19 (diff)
Fixes RP2040 buffer reallocation overrun problem (#642)
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).
Diffstat (limited to 'src')
-rw-r--r--src/portable/raspberrypi/rp2040/dcd_rp2040.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/portable/raspberrypi/rp2040/dcd_rp2040.c b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
index a54f579b8..95b0963a3 100644
--- a/src/portable/raspberrypi/rp2040/dcd_rp2040.c
+++ b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
@@ -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;