summaryrefslogtreecommitdiff
path: root/examples/device/net_lwip_webserver
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/net_lwip_webserver
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/net_lwip_webserver')
-rw-r--r--examples/device/net_lwip_webserver/README.md58
1 files changed, 58 insertions, 0 deletions
diff --git a/examples/device/net_lwip_webserver/README.md b/examples/device/net_lwip_webserver/README.md
new file mode 100644
index 000000000..b4d429100
--- /dev/null
+++ b/examples/device/net_lwip_webserver/README.md
@@ -0,0 +1,58 @@
+# Network Web Server (lwIP)
+
+A USB virtual network adapter that runs a small lwIP stack on the device, serving DHCP, DNS, and a web page over USB.
+
+## What it does
+
+- Brings up a USB network interface. Depending on the target MCU the build is either CDC-NCM (the default for most MCUs) or a dual RNDIS + CDC-ECM device that offers two configurations and lets the host pick its preferred one (Windows uses RNDIS, macOS uses CDC-ECM, Linux works with either). The NCM build also ships a BOS / Microsoft OS 2.0 descriptor so Windows auto-loads its NCM driver.
+- The device takes IP address 192.168.7.1 and runs a DHCP server (handing out 192.168.7.2–192.168.7.4), a DNS server (resolves `tiny.usb`), and an HTTP server.
+- Pressing the board button toggles the network link state (up/down) to simulate an Ethernet cable being unplugged/plugged.
+- On higher-RAM MCUs it also starts an iperf TCP server for throughput testing.
+- Blinks the board LED to indicate USB state (not mounted / mounted / suspended).
+
+## Requirements
+
+- Depends on the lwIP TCP/IP stack, fetched as a dependency (e.g. `python3 tools/get_deps.py`).
+
+## USB Descriptors
+
+| Interface | Class driver |
+|-----------|--------------|
+| 0–1 | Network (CDC-NCM, or CDC-ECM/RNDIS) |
+
+## Configuration
+
+Notable `tusb_config.h` settings:
+
+```c
+// Network driver selection: NCM is the default; USE_ECM defaults to 0 but is
+// forced to 1 on some MCUs (LPC15xx/40xx/51uxx/54, SAMD21/SAML2x, STM32F0/F1).
+#define CFG_TUD_ECM_RNDIS USE_ECM // 0 by default -> ECM/RNDIS off
+#define CFG_TUD_NCM (1 - CFG_TUD_ECM_RNDIS) // 1 by default -> NCM on
+
+// NCM tuning (see ncm.h for performance notes)
+#define CFG_TUD_NCM_IN_NTB_MAX_SIZE 2048
+#define CFG_TUD_NCM_OUT_NTB_MAX_SIZE 4096 // 2048 on low-RAM MCUs
+#define CFG_TUD_NCM_OUT_NTB_N 1
+#define CFG_TUD_NCM_IN_NTB_N 1
+```
+
+## Building
+
+CMake:
+
+```bash
+mkdir build && cd build
+cmake -DBOARD=raspberry_pi_pico ..
+cmake --build .
+```
+
+Make:
+
+```bash
+make BOARD=raspberry_pi_pico all
+```
+
+## Try it
+
+A new USB network interface appears on the host. It is normally assigned an address in 192.168.7.x by the device's DHCP server (otherwise give the host NIC a static 192.168.7.x address), then browse to http://192.168.7.1 to load the served web page.