<feed xmlns='http://www.w3.org/2005/Atom'>
<title>tinyusb.git/src/portable/wch/dcd_ch32_usbfs.c, branch worktree-ch569-hydrausb3</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/tinyusb.git/atom/src/portable/wch/dcd_ch32_usbfs.c?h=worktree-ch569-hydrausb3</id>
<link rel='self' href='http://cgit.235523.xyz/tinyusb.git/atom/src/portable/wch/dcd_ch32_usbfs.c?h=worktree-ch569-hydrausb3'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/'/>
<updated>2026-07-06T09:17:17Z</updated>
<entry>
<title>Merge remote-tracking branch 'origin/master' into usbtest</title>
<updated>2026-07-06T09:17:17Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-07-06T09:17:17Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=2d73cf58de9a41278a9c6e1e3c9e5c6626bf95b7'/>
<id>urn:sha1:2d73cf58de9a41278a9c6e1e3c9e5c6626bf95b7</id>
<content type='text'>
# Conflicts:
#	lib/rt-thread/port/msc_device_port.c
#	src/device/usbd.c
</content>
</entry>
<entry>
<title>usbtest: address code-review findings (EP3 iso regression + 9 more)</title>
<updated>2026-07-06T04:53:40Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-07-06T04:53:40Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=24be2499839538b377927d30d4ab43122f337dff'/>
<id>urn:sha1:24be2499839538b377927d30d4ab43122f337dff</id>
<content type='text'>
Cross-checking the branch against the MCU datasheets surfaced a regression and
several latent defects. Fixes (finding # from the review):

#1 dcd_ch32_usbfs: restore EP3's enlarged iso buffer. CH32V20x/V30x/F20x USBFS
   give endpoint 3 a 1023-byte iso packet (CH32FV2x_V3xRM ch23; 16-bit
   R16_UEP3_T_LEN), unlike every other 64 B endpoint. Commit c05e9313e removed
   that buffer and capped iso at 64 B, breaking &gt;64 B FS iso (UVC/UAC) on EP3.
   Re-add it via CFG_TUD_WCH_USBFS_EP3_BUFSIZE, defaulted to 1023 on those parts
   (CH32_USBFS_EP3_1023_BUFSIZE in ch32_usbfs_reg.h) and 64 elsewhere.
#3 dcd_ch32_usbfs: make data.isochronous[] per-direction and clear it on
   endpoint (re)open, so a reused ep number can't inherit a stale iso response.
#7 dcd_ch32_usbfs: exempt iso from the PID_OUT data-toggle handling too (was
   only done for PID_IN); iso is DATA0-only in both directions.
#13 dcd_ch32_usbfs: bounds-assert ep &lt; EP_MAX in dcd_edpt_iso_alloc.
#2/#6 usbtest descriptors: TUD_OPT_HIGH_SPEED is a compile-time capability, not
   the live speed, so the full-speed config (and OTHER_SPEED) advertised int/iso
   mps 512 on HS boards — illegal at FS / over the 1023 B/frame iso budget. Split
   into FS-legal / HS descriptor sizes; the plain macro tracks operating speed.
#10 vendor: non-alt free-slot detection also checks the int endpoints (a vendor
   interface may now be interrupt-only, no bulk ep).
#14 vendor: replace the order-coupled ITF_MEM_RESET_SIZE ladder (2 unreachable
   branches) with offsetof(vendord_interface_t, tx_stream).
#5 rp2040: clear_stall re-issue preserves the already-transferred count so a
   mid-transfer clear-halt reports the full length, not just the remainder.
#8 rp2040: force single-buffering for iso (only BULK gets a double DPRAM buffer),
   so a multi-packet iso xfer can't spill buffer 1 into the next ep's DPRAM.

Verified: CH32V203 usbfs and CH583 still pass usbtest tier-4 30/30; all board
families build; pre-commit (format/codespell/unit) clean.

Co-Authored-By: Claude Opus 4.8 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
</content>
</entry>
<entry>
<title>usbtest: support CH583 — its USBFS does isochronous (30/30)</title>
<updated>2026-07-06T03:11:30Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-07-06T03:11:30Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=e7d7fda974a072195ca7e64bbb116476297aa839'/>
<id>urn:sha1:e7d7fda974a072195ca7e64bbb116476297aa839</id>
<content type='text'>
The CH582/CH583 USBFS DCD refused isochronous outright, but the datasheet
(CH582-CH583 DS1, USB controller chapter) lists synchronous/real-time
(isochronous) alongside control/bulk/interrupt, with 64 B packets. Accept iso
like the other WCH USBFS parts (iso mps 64, capped to the 64 B endpoint buffer;
drop the CH583-only refusals in dcd_edpt_iso_alloc/activate).

That alone left iso IN dropping a deterministic ~1/8 of packets. Root cause:
CH58x drives the data toggle manually in the ISR (its hardware AUTO_TOG is
unreliable) and flipped the TX toggle after every IN packet — including
isochronous, which is DATA0-only and must never toggle. Skip the manual toggle
flip for iso endpoints. This path is CH58x-only (CH32_USBFS_EP_MANUAL_TOG),
so CH32V103/V20x/V307 (hardware AUTO_TOG) are unaffected.

Verified on ch582m_evt: Linux testusb tier-4 (30 cases) = 30/30 across 4 reflash
cycles; CH32V103 and the CH32V203 usbfs port still pass. Drop CH583 from the
usbtest skip list — all WCH USBFS parts now run the full battery.

Co-Authored-By: Claude Opus 4.8 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
</content>
</entry>
<entry>
<title>usbtest: enable CH32V103, drop the CH32 usbfs EP3 iso special buffer</title>
<updated>2026-07-05T16:46:17Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-07-05T16:27:59Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=c05e9313ee27598f373f65b99133fab7ea0df51c'/>
<id>urn:sha1:c05e9313ee27598f373f65b99133fab7ea0df51c</id>
<content type='text'>
CH32V103 (ch32v103r) uses the same usbfs DCD as the CH32V203 usbfs port and
passes tier-4 30/30 with the fixes already in place (iso mps 64 + the clear-halt
re-arm) — drop it from the skip list. Verified 30/30 across 6 reflash cycles.

dcd_ch32_usbfs.c gave EP3 an enlarged 1023-byte IN buffer for full-speed iso,
but the CH32V20x/V103 USB FS controller caps every endpoint (bulk/interrupt/iso)
at a 64-byte packet (per the RM "USB Full-speed Host/Device Controller"), so no
endpoint can ever send more than 64 B and the oversized EP3 buffer was pure
waste. Treat EP3 like any other endpoint (64 B OUT + 64 B IN) and drop the
special buffer, saving ~1 KB of RAM. dcd_edpt_iso_alloc now rejects an iso mps
&gt; 64 rather than running off the end of the buffer. usbtest (iso mps 64) still
passes 30/30 on CH32V103 and the CH32V203 usbfs port.

CH583 has no isochronous support in its USBFS IP, so it cannot run tier-4 (the
iso endpoints fail to open and SET_CONFIG times out); it stays skipped.

Co-Authored-By: Claude Opus 4.8 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
</content>
</entry>
<entry>
<title>usbtest: support CH32V203 (fsdev + usbfs ports), both pass tier-4 30/30</title>
<updated>2026-07-05T15:18:21Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-07-05T15:18:21Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=ae7f10b0d30bfa47e4ed87c01599963d18980d21'/>
<id>urn:sha1:ae7f10b0d30bfa47e4ed87c01599963d18980d21</id>
<content type='text'>
Neither of the CH32V203's two USB device IPs could run the usbtest tier-4 battery.

usbfs (port 1):
- 128 B iso doesn't fit its fixed 64 B/ep buffers -&gt; drop iso mps to 64 on CH32
  (usb_descriptors.h).
- dcd_ch32_usbfs.c: clear-halt on an armed OUT endpoint forced it to NAK, so a
  submitted read NAK'd forever and the host timed out. Re-assert ACK when a
  receive is still armed (usbtest toggle test 29).

fsdev (port 0, the shared stm32_fsdev driver):
- The descriptor hard-coded the interrupt mps, so USBTEST_INT_EP_MPS never took
  effect; all six tier-4 endpoints then overflowed the 512 B PMA and SET_CONFIG
  timed out. Wire the interrupt mps to the macro and use 16 on the fsdev port.
- The USBD raises three IRQ lines (LP/HP/WakeUp) into one non-reentrant handler
  and they nest (HP preempts LP) with QingKe HWSTK enabled. The mainline
  toolchain's plain __attribute__((interrupt)) emits a software prologue that
  fights the hardware context stack and corrupts the return on nesting -&gt; wild
  jump / illegal-instruction crash. Emit naked handlers that rely on HWSTK for
  context save/restore -- the equivalent of WCH's "WCH-Interrupt-fast", which
  mainline riscv-none-elf-gcc ignores -- so nesting is safe.
- Single-buffered iso IN can't stay fed under load; double-buffer it
  (CFG_TUD_FSDEV_DOUBLE_BUFFERED_ISO_EP in the example tusb_config.h). iso mps
  32 x2 = 64 B/ep keeps the same PMA budget. Left single for other fsdev parts
  (audio's larger iso would overflow their PMA too).

Verified on nanoch32v203 (CH32V203D6): Linux testusb tier-4 (30 cases across
bulk/control/interrupt/isochronous) = 30/30 on both the fsdev and usbfs variant,
each across 5 reflash cycles. Full CH32V20X example set builds; cdc_msc still
enumerates CDC+MSC on the fsdev port (naked-handler regression check). Drop
CH32V20X from the usbtest skip list.

Co-Authored-By: Claude Opus 4.8 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
</content>
</entry>
<entry>
<title>license: use SPDX identifiers for src/ headers (#3749)</title>
<updated>2026-07-02T14:55:45Z</updated>
<author>
<name>Ha Thach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-07-02T14:55:45Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=7a4111b96ef6279e75579f9a18443834f6a0871d'/>
<id>urn:sha1:7a4111b96ef6279e75579f9a18443834f6a0871d</id>
<content type='text'>
* license: use SPDX identifiers for src/ headers

Replace the full ~20-line MIT license boilerplate on every src/ file with a
two-line SPDX tag (SPDX-FileCopyrightText + SPDX-License-Identifier), following
the REUSE convention used by CircuitPython and the Linux kernel. Removes ~3500
lines of duplicated boilerplate.</content>
</entry>
<entry>
<title>hw/bsp+wch: rename the CH58x family to ch583 and OPT_MCU_CH58X to OPT_MCU_CH583</title>
<updated>2026-06-22T08:23:08Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-06-22T08:23:08Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=eda704ca1acef9691b51e17026765f497b1fffbe'/>
<id>urn:sha1:eda704ca1acef9691b51e17026765f497b1fffbe</id>
<content type='text'>
The BSP family and MCU option were named "ch58x"/"CH58X", but the supported part is
the CH583/CH582 (and the SDK repo is openwch/ch583); CH585 is a separate MCU family,
so the CH58x umbrella was misleading. Rename to the specific family:

- hw/bsp/ch58x -&gt; hw/bsp/ch583 (dir), and the BSP-local files ch58x_it.* -&gt;
  ch583_it.*, system_ch58x.* -&gt; system_ch583.* (include guards/refs updated). The
  vendor SDK files (CH58x_common.h, CH58x_*.c in hw/mcu/wch/ch583) keep their names.
- OPT_MCU_CH58X -&gt; OPT_MCU_CH583 in tusb_option.h, tusb_mcu.h, and the shared WCH
  USBFS driver (ch32_usbfs_reg.h, dcd_ch32_usbfs.c). OPT_MCU_CH582 is kept as an
  alias (same value), so either name selects the same code.
- FAMILY_MCUS CH58X -&gt; CH583, CFG_TUSB_MCU=OPT_MCU_CH583, mcu:CH58X -&gt; mcu:CH583 in
  the example skip lists, the CI build matrix (ci_set_matrix.py), the get_deps family
  tag, and docs/reference/boards.rst.

Board names (ch582m_evt, yd-ch582m) are unchanged. Verified: make + cmake build for
ch582m_evt, and ci.lan HIL (all device examples pass).

Co-Authored-By: Claude Opus 4.8 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>dcd/wch: drop toggle-mismatched OUT packets on all USBFS variants</title>
<updated>2026-06-20T01:36:25Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-06-20T01:36:25Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=cca6fe64e95175cbefcdae1d1306ea8765a075d9'/>
<id>urn:sha1:cca6fe64e95175cbefcdae1d1306ea8765a075d9</id>
<content type='text'>
The OUT data-toggle check -- drop a packet whose DATA0/DATA1 doesn't match the
expected toggle (a host retransmit after a lost ACK, or a host that doesn't
alternate the toggle) -- only ran on CH58x. The auto-toggle parts (V103/V20x/V307/
X035) never checked it, so a duplicate/retransmitted OUT was processed twice.
HiFiPhile confirmed it: a host patched to send DATA0-only had CH32V305 accept every
packet. Move the TOG_OK gate out of the CH58x-only block so it runs on every variant;
the manual toggle flip stays CH58x-only. EP0 keeps its own toggle via the SETUP/status
flow and is exempt.

Verified on ci.lan HIL: ch582m_evt (CH58x), ch32v103r_r1_1v0 (V103), nanoch32v203
(V203) all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>dcd/ch58x: preserve the DEV_ADDR general-purpose bit on SET_ADDRESS</title>
<updated>2026-06-19T16:08:39Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-06-19T16:00:55Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=31543c17a9c15c1c6e9a6c8d39be10aaa184e4f1'/>
<id>urn:sha1:31543c17a9c15c1c6e9a6c8d39be10aaa184e4f1</id>
<content type='text'>
dcd_edpt0_status_complete() wrote the full SET_ADDRESS wValue into R8_USB_DEV_AD,
clobbering bit 7, which on CH58x is a user general-purpose flag (only bits [6:0]
are the device address). Mask to 7 bits and preserve bit 7, matching the removed
dcd_ch58x_usbfs.c. CH58x-scoped; other parts keep the full write.

Co-Authored-By: Claude Opus 4.8 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>dcd/ch58x: drop stale EP0 transfer state on SETUP</title>
<updated>2026-06-19T15:59:59Z</updated>
<author>
<name>hathach</name>
<email>thach@tinyusb.org</email>
</author>
<published>2026-06-19T15:59:59Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/tinyusb.git/commit/?id=9aa0ab4b675ab2c3880cb5ed440d3d04b944f77f'/>
<id>urn:sha1:9aa0ab4b675ab2c3880cb5ed440d3d04b944f77f</id>
<content type='text'>
The PID_SETUP handler armed the new control transfer but left any in-flight EP0
transfer from the previous request marked valid, so a spurious EP0 IN/OUT could run
update_in()/update_out() against stale state (the removed dcd_ch58x_usbfs.c invalidated
both EP0 directions on every SETUP). Clear xfer[0] IN/OUT validity when a SETUP arrives.
Applies to all WCH USBFS parts -- a new SETUP always supersedes a pending control xfer.

Co-Authored-By: Claude Opus 4.8 (1M context) &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
