CH32X035 port#3703
Conversation
Seems like v103, do you have board to test with ? |
|
| target | .text | .rodata | .data | .bss | total | % diff |
|---|---|---|---|---|---|---|
| ch32v103c_bluepill/dynamic_configuration | — | — | — | 4,104 → 3,976 (-128) | 14,392 → 14,264 (-128) | -0.9% |
| ch32v103c_bluepill/dfu_runtime | 8,556 → 8,588 (+32) | — | — | 2,880 → 2,752 (-128) | 13,900 → 13,804 (-96) | -0.7% |
| ch32v103c_bluepill/hid_generic_inout | 9,528 → 9,560 (+32) | — | — | 3,084 → 2,956 (-128) | 15,080 → 14,984 (-96) | -0.6% |
| ch32v103c_bluepill/hid_boot_interface | 10,388 → 10,416 (+28) | — | — | 2,960 → 2,832 (-128) | 15,812 → 15,712 (-100) | -0.6% |
| ch32v103c_bluepill/hid_composite | 10,612 → 10,640 (+28) | — | — | 2,948 → 2,820 (-128) | 16,028 → 15,928 (-100) | -0.6% |
| ch32v103c_bluepill/hid_multiple_interface | 10,368 → 10,400 (+32) | — | — | 2,960 → 2,832 (-128) | 15,792 → 15,696 (-96) | -0.6% |
| ch32v103c_bluepill/midi_test | 10,720 → 10,752 (+32) | — | — | 3,208 → 3,080 (-128) | 16,392 → 16,296 (-96) | -0.6% |
| ch32v103c_bluepill/cdc_dual_ports | 11,736 → 11,764 (+28) | — | — | 3,552 → 3,424 (-128) | 17,752 → 17,652 (-100) | -0.6% |
| ch32v103c_bluepill/printer_to_cdc | 11,908 → 11,936 (+28) | — | — | 3,496 → 3,368 (-128) | 17,852 → 17,752 (-100) | -0.6% |
| ch32v103c_bluepill/webusb_serial | 12,248 → 12,276 (+28) | — | — | 3,508 → 3,380 (-128) | 18,320 → 18,220 (-100) | -0.5% |
I don't have the board unfortunately. I may take a look if I need a 5V capable mcu though (although py32f07x is also 5V capable but has additional DACs unlike v103) |
Got claude to analyze the discrepency, here's the output verbatim: |
dcd_edpt_xfer() re-enabled the USB interrupt before update_in() / ep_rx_set_response(), which read-modify-write the (combined) EP control register. On CH58x the ISR RMWs that same register to flip the manual data toggle, so a transfer interrupt landing mid-RMW could drop the toggle flip and desync the endpoint. Move dcd_int_enable() to after the arming so the whole sequence is atomic w.r.t. the ISR (matching the CH32X035 port hathach#3703). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
thank you, after #3515, this should be relatively easy. I have the CH32X035 board but run out of wlinke debugger (attached to hil rig). will get this mcu ported when it got on my desk |
|
I also simplified the comments, since I found a hallucination involving X035.
|
|
According to the manuals, it says only EP4 needs manual toggling, maybe manual toggle should only be enabled for EP4? |
Hardware-in-the-loop (HIL) Test Reporthfp.json✅ 52 passed · ❌ 0 failed · ⚪ 0 skipped · blank not run
tinyusb.json✅ 337 passed · ❌ 2 failed · ⚪ 11 skipped · blank not run
|
|
Hi, I see many comment changes, please verify are they intended. |
|
Yes they are intended, since there was a hallucination about the x035 and I was concerned there are more, so I got my agent to shrink all of them so they can be verified easily |
|
Many comments are from Ha Thach like
They shoudn't be removed. |
7f1322b to
d2b4873
Compare
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
|
Adds support for both CH32X035 and CH32X033.
I'm also evaluating this MCU due to it being low cost and have USB.
CH32X035 has both TX and RX CTRL bits in the same byte, so there are changes to how these registers are written in the dcd.
If the current approach isn't satisfactory, there are some alternatives:
EP4 special handling:
This is a bit confusing, and Codex/Claude has been very helpful to get that part working. In short: no DMA and no auto-toggle, so some special handling has to be built in.
EP3 no special large buffer
The code has some existing handling for large EP3 buffer, but as far as I can tell that functionality doesn't exist in ch32x035, should I #if that out for this port?
Related: adafruit/Adafruit_TinyUSB_Arduino#486