device/dfu: fix transfer buffer overwrite issue - #3799
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a DFU device-mode data corruption scenario by ensuring DFU transfer payloads aren’t stored in EP0’s control buffer, which can be reused/overwritten by subsequent control transfers (notably GETSTATUS).
Changes:
- Always use a dedicated aligned DFU transfer buffer (
_transfer_buf) for DNLOAD/UPLOAD payloads. - Remove the conditional “use EP0 control buffer when large enough” helper to prevent buffer reuse across control requests.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: HiFiPhile <admin@hifiphile.com>
338980c to
45775e9
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Size Difference ReportBecause TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds. Note: If there is no change, only one value is shown. Changes >1% in size
Changes <1% in sizeNo entries. No changes
|
Hardware-in-the-loop (HIL) Test Reporthfp-iar✅ 40 passed · ❌ 16 failed · ⚪ 0 skipped · blank not run
hfp.json✅ 24 passed · ❌ 32 failed · ⚪ 0 skipped · blank not run
tinyusb-esp.json✅ 18 passed · ❌ 6 failed · ⚪ 0 skipped · blank not run
tinyusb.json✅ 331 passed · ❌ 46 failed · ⚪ 19 skipped · blank not run
|
|
| target | .text | .rodata | .data | .bss | total | % diff |
|---|---|---|---|---|---|---|
| mm32f327x_mb39/dfu | 10,760 → 10,724 (-36) | — | — | 2,136 → 2,648 (+512) | 15,696 → 16,172 (+476) | +3.0% |
| frdm_kl25z/dfu | 12,780 → 12,736 (-44) | — | — | 2,156 → 2,668 (+512) | 17,268 → 17,736 (+468) | +2.7% |
| frdm_k32l2a4s/dfu | 14,252 → 14,208 (-44) | — | — | 2,168 → 2,680 (+512) | 18,740 → 19,208 (+468) | +2.5% |
| frdm_mcxa153/dfu | 15,712 → 15,676 (-36) | — | — | 2,308 → 2,820 (+512) | 21,392 → 21,868 (+476) | +2.2% |
| lpcxpresso1769/dfu | 10,960 → 10,924 (-36) | — | — | 1,500 → 1,628 (+128) | 13,096 → 13,188 (+92) | +0.7% |
| lpcxpresso11u37/dfu | 10,560 → 10,516 (-44) | — | — | — | 11,048 → 11,004 (-44) | -0.4% |
| lpcxpresso51u68/dfu | 12,688 → 12,644 (-44) | — | — | — | 12,828 → 12,784 (-44) | -0.3% |
| lpcxpresso1347/dfu | 10,228 → 10,192 (-36) | — | — | — | 10,736 → 10,700 (-36) | -0.3% |
| lpcxpresso1549/dfu | 11,652 → 11,616 (-36) | — | — | — | 12,240 → 12,204 (-36) | -0.3% |
| frdm_k64f/dfu | 13,784 → 13,748 (-36) | — | — | — | 13,932 → 13,896 (-36) | -0.3% |
|
@hathach Wondering if this will make it into the next tinyusb release? We are stuck using an old version of tinyusb due to dfu not functioning correctly |
No description provided.