Commit f3f9b46
committed
shared/tinyusb: Eliminate descriptor duplication in runtime mode.
In runtime mode (MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE=1), the previous
implementation stored both a static descriptor (using TinyUSB macros)
and runtime descriptor templates, resulting in ~180-200 bytes of
duplicate descriptor data.
This commit eliminates the duplication by:
- Making the static descriptor conditional on !MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
- In runtime mode, generating the default/fallback descriptor from
templates using mp_usbd_get_default_desc() instead of referencing
the static descriptor
- Updating mp_usbd_runtime.c to call the new function conditionally
Also removes lingering calls to mp_usbd_update_class_state() which was
removed in the macro refactoring, replacing them with direct flag
assignments.
Code size (STM32H563, TinyUSB stack):
- Runtime mode: 514,396 bytes (text)
- Static mode: 512,020 bytes (text)
Saves ~180-200 bytes in runtime mode by eliminating descriptor
duplication.
Signed-off-by: Andrew Leech <[email protected]>1 parent 6cd353a commit f3f9b46
3 files changed
+33
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
220 | | - | |
| 221 | + | |
| 222 | + | |
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
| |||
315 | 317 | | |
316 | 318 | | |
317 | 319 | | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | 320 | | |
322 | 321 | | |
323 | 322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
| 212 | + | |
212 | 213 | | |
213 | 214 | | |
214 | 215 | | |
| |||
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
224 | 242 | | |
225 | 243 | | |
226 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
135 | 143 | | |
136 | 144 | | |
137 | 145 | | |
| |||
0 commit comments