summaryrefslogtreecommitdiff
path: root/examples/device/cdc_msc_throughput
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-06-29 10:16:25 +0700
committerhathach <[email protected]>2026-06-29 10:16:25 +0700
commit4b1c8d16f72bb5d8f2eb8a2e8dde35abdd2f2a88 (patch)
tree3db175aa3d96c92a44fab764dba59f473096c4b4 /examples/device/cdc_msc_throughput
parent0a25cc27d7d3699536f6df01e80af3eb0423ce58 (diff)
docs: add build-doc tooling and a README for every example
Documentation tooling: - Add the `build-doc` skill and `tools/build_doc.py` wrapper for local Sphinx builds (clean / -W / open). - Enable Markdown (MyST) in conf.py and auto-collect examples/{device,host,dual}/*/README.md into a 3-level Examples nav (Examples > Device/Host/Dual > example), noting each page's source location and normalizing headings to a single H1. - Remove the stale `.claude/commands/build-doc.md`; point the AGENTS.md Documentation section at the skill. Example docs: - Add a README.md for every device/host/dual example: what it does, USB interface table, notable tusb_config.h settings, generic CMake + Make build steps, and how to try it. - Fold each *_freertos variant into its base README, noting the FreeRTOS source path and any RTOS-specific behavior. Generated docs/examples/ output is git-ignored. Builds clean with `sphinx-build -W`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'examples/device/cdc_msc_throughput')
-rw-r--r--examples/device/cdc_msc_throughput/README.md70
1 files changed, 70 insertions, 0 deletions
diff --git a/examples/device/cdc_msc_throughput/README.md b/examples/device/cdc_msc_throughput/README.md
new file mode 100644
index 000000000..3de49b826
--- /dev/null
+++ b/examples/device/cdc_msc_throughput/README.md
@@ -0,0 +1,70 @@
+# CDC + MSC Throughput
+
+A deliberately minimal CDC + MSC composite device for measuring **pure USB bulk
+throughput** — the ceiling set by the USB link and the TinyUSB driver, with no
+backing storage or per-byte work in the way.
+
+## How it measures the ceiling, not storage
+
+- **MSC** advertises a 1 GiB logical disk (2 Mi × 512-byte blocks) but has no real
+ backing store. Writes are discarded; reads zero-fill only the low LBAs the host
+ scans during enumeration (partition table / GPT header) and otherwise return
+ whatever is already in the transfer buffer — so no `memset`/copy cost skews the result.
+- **CDC** drains its RX in `tud_cdc_rx_cb` and sources TX from a static zero filler,
+ so `dd` can push data in either direction over `/dev/ttyACMx`.
+
+The 1 GiB capacity lets `dd` run long enough for the rate to stabilise; high-speed peripherals show the most headroom.
+
+## USB Descriptors
+
+| Interface | Class driver |
+|-----------|--------------|
+| 0–1 | CDC (virtual serial) |
+| 2 | MSC (mass storage) |
+
+## Configuration
+
+Notable `tusb_config.h` settings (tuned for throughput):
+
+```c
+#define CFG_TUD_CDC 1
+#define CFG_TUD_MSC 1
+#define CFG_TUD_MSC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 4096 : 1024) // large MSC bulk buffer
+#define CFG_TUD_CDC_RX_EPSIZE (TUD_OPT_HIGH_SPEED ? 2*512 : 2*64)
+#define CFG_TUD_CDC_TX_EPSIZE CFG_TUD_CDC_RX_EPSIZE
+#define CFG_TUD_CDC_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 2*512 : 2*64)
+#define CFG_TUD_CDC_TX_BUFSIZE CFG_TUD_CDC_RX_BUFSIZE
+```
+
+## Building
+
+CMake:
+
+```bash
+mkdir build && cd build
+cmake -DBOARD=raspberry_pi_pico ..
+cmake --build .
+```
+
+Make:
+
+```bash
+make BOARD=raspberry_pi_pico all
+```
+
+## Measuring throughput (Linux)
+
+The MSC disk appears as a raw block device (e.g. `/dev/sdX`); the CDC port as `/dev/ttyACMx`.
+
+```bash
+# MSC read (device → host)
+sudo dd if=/dev/sdX of=/dev/null bs=1M count=256 iflag=direct
+
+# MSC write (host → device, discarded)
+sudo dd if=/dev/zero of=/dev/sdX bs=1M count=256 oflag=direct
+
+# CDC read (device → host)
+dd if=/dev/ttyACM0 of=/dev/null bs=64k count=4096
+```
+
+> Pick the right `/dev/sdX` carefully — writing to the wrong block device destroys data.