Skip to content

ch32v4x7: report the full 96-bit UID as the USB serial - #650

Open
hathach wants to merge 2 commits into
masterfrom
ch32v4x7-uid-serial
Open

hathach wants to merge 2 commits into
masterfrom
ch32v4x7-uid-serial

Conversation

@hathach

@hathach hathach commented Nov 12, 2026

Copy link
Copy Markdown
Member

Problem

board_usb_get_serial() in ports/ch32v4x7/boards.c (from #639) copies only the first 8 bytes of the unique ID. The CH32V407/V467 UID is 96 bits (ESIG_UNIID1-3 at 0x1FFFF7E8, …EC, …F0; CH32V407RM Rev 1.3 §31.1–31.2), and WCH guarantees uniqueness only for all 96 bits, so two boards could report the same USB serial. ch32v20x, tinyusb's own ch32v4x7 BSP and the Adafruit TinyUSB Arduino CH32 port all use 12 bytes.

Solution

Copy all 12 bytes. #639 is not in a release yet, so no shipped bootloader reports the 8-byte serial. adafruit/Adafruit_TinyUSB_Arduino#618 drops its matching 8-byte special case, so bootloader and sketch report the same 24-character serial.

Evidence: check_build.py --base origin/master builds ch32v407_r0, metro_ch32v407 and metro_ch32v467; metro_ch32v467 +12 B flash; pre-commit run --all-files passes. Not run on hardware: no Metro CH32V4x7 is available.

The unique ID is 96 bits (CH32V407RM 31.1, ESIG_UNIID1-3); 8 bytes dropped UNIID3, so uniqueness was no longer guaranteed. Matches ch32v20x and the Arduino TinyUSB port.
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 690d090 and 6b53e59.

Files selected for processing: 2

  • ports/ch32v4x7/boards.c
  • test/hil/ci.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Low impact] The PR appears safe to merge; no blocking issues were found.

Summary

The PR makes CH32V4x7 boards report all 12 UID bytes as a 24-character USB serial.

  • CH32V4x7 USB serials now use the full chip identifier.

Reviews (2) · Last reviewed commit: "hil: report ch32v407_r0's 12-byte UID se..." · Reviewed by Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Hardware-in-the-loop (HIL) Test Report

ci.json (ci.lan)

PR head 6b53e59 · tested 1134ee1 · run 43197264635, attempt 2

Every roster board: the HIL runner or a roster changed (8 boards).

✅ 8 passed · HIL driver elapsed 11m7s

Board install dfu copy app-ran reenter recopy blinky admit run
ch32v407_r0 ✅ ✅ ✅ ✅ ✅ — ✅ 1s 26s
espressif_esp32s3_devkitm_1 ✅ ✅ ✅ ✅ ✅ ✅ ✅ 0s 2m17s
espressif_p4_function_ev ✅ ✅ ✅ ✅ ✅ ✅ ✅ 0s 2m23s
imxrt1064_evk ✅ ✅ ✅ ✅ ✅ — ✅ 2s 41s
lpcxpresso55s69 ✅ ✅ ✅ ✅ ✅ — ✅ 0s 1m32s
metro_m4_express ✅ ✅ ✅ ✅ ✅ — ✅ 0s 1m33s
stm32f407disco ✅ ✅ ✅ ✅ ✅ — ✅ 0s 1m42s
stm32h743nucleo ✅ ✅ ✅ ✅ ✅ — ✅ 0s 29s

✅ passed · ❌ failed · blank not run · — not in this board's run · run time includes lock wait and blinky

Not covered on this rig:

  • max32666fthr: pending commissioning (no tinyuf2.reentry): not run

Records, reports and logs

@greptile-apps
greptile-apps Bot dismissed their stale review November 12, 2026 10:05

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant