summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2025-09-12 15:49:40 +0200
committerHiFiPhile <[email protected]>2025-09-12 15:49:40 +0200
commitfad3dc492630a6a31a38b3340f506849ef3679ff (patch)
tree5ab1fef9daf657c1b3f1b7e238e02eb78e1b14cf /.github
parent4ae433fa6ef451cccb2b09aa3748978b46aade5f (diff)
parent2027ac246791caa9f1dc03e9727b60d90bee0f2d (diff)
Merge branch 'master' into sb-ep
Diffstat (limited to '.github')
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.yml4
-rw-r--r--.github/copilot-instructions.md133
-rw-r--r--.github/workflows/build.yml75
-rwxr-xr-x.github/workflows/ci_set_matrix.py4
4 files changed, 177 insertions, 39 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 35576a439..34e177984 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -86,8 +86,8 @@ body:
- type: checkboxes
attributes:
- label: I have checked existing issues, dicussion and documentation
+ label: I have checked existing issues, discussion and documentation
description: You agree to check all the resources above before opening a new issue.
options:
- - label: I confirm I have checked existing issues, dicussion and documentation.
+ - label: I confirm I have checked existing issues, discussion and documentation.
required: true
diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
new file mode 100644
index 000000000..572b8d6f5
--- /dev/null
+++ b/.github/copilot-instructions.md
@@ -0,0 +1,133 @@
+# TinyUSB
+TinyUSB is an open-source cross-platform USB Host/Device stack for embedded systems, designed to be memory-safe with no dynamic allocation and thread-safe with all interrupt events deferred to non-ISR task functions.
+
+Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
+
+## Working Effectively
+
+### Bootstrap and Build Setup
+- Install ARM GCC toolchain: `sudo apt-get update && sudo apt-get install -y gcc-arm-none-eabi`
+- Fetch core dependencies: `python3 tools/get_deps.py` -- takes <1 second. NEVER CANCEL.
+- For specific board families: `python3 tools/get_deps.py FAMILY_NAME` (e.g., rp2040, stm32f4)
+- Dependencies are cached in `lib/` and `hw/mcu/` directories
+
+### Build Examples
+Choose ONE of these approaches:
+
+**Option 1: Individual Example with CMake (RECOMMENDED)**
+```bash
+cd examples/device/cdc_msc
+mkdir -p build && cd build
+cmake -DBOARD=stm32f407disco -DCMAKE_BUILD_TYPE=MinSizeRel ..
+cmake --build . -j4
+```
+-- takes 1-2 seconds. NEVER CANCEL. Set timeout to 5+ minutes.
+
+**Option 2: Individual Example with Make**
+```bash
+cd examples/device/cdc_msc
+make BOARD=stm32f407disco all
+```
+-- takes 2-3 seconds. NEVER CANCEL. Set timeout to 5+ minutes.
+
+**Option 3: All Examples for a Board**
+```bash
+python3 tools/build.py -b BOARD_NAME
+```
+-- takes 15-20 seconds, may have some objcopy failures that are non-critical. NEVER CANCEL. Set timeout to 30+ minutes.
+
+### Unit Testing
+- Install Ceedling: `sudo gem install ceedling`
+- Run all unit tests: `cd test/unit-test && ceedling` -- takes 4 seconds. NEVER CANCEL. Set timeout to 10+ minutes.
+- Tests use Unity framework with CMock for mocking
+
+### Documentation
+- Install requirements: `pip install -r docs/requirements.txt`
+- Build docs: `cd docs && sphinx-build -b html . _build` -- takes 2-3 seconds. NEVER CANCEL. Set timeout to 10+ minutes.
+
+### Code Quality and Validation
+- Format code: `clang-format -i path/to/file.c` (uses `.clang-format` config)
+- Check spelling: `pip install codespell && codespell` (uses `.codespellrc` config)
+- Pre-commit hooks validate unit tests and code quality automatically
+
+## Validation
+
+### ALWAYS Run These After Making Changes
+1. **Pre-commit validation** (RECOMMENDED): `pre-commit run --all-files`
+ - Install pre-commit: `pip install pre-commit && pre-commit install`
+ - Runs all quality checks, unit tests, spell checking, and formatting
+ - Takes 10-15 seconds. NEVER CANCEL. Set timeout to 15+ minutes.
+2. **Build validation**: Build at least one example that exercises your changes
+ ```bash
+ cd examples/device/cdc_msc
+ make BOARD=stm32f407disco all
+ ```
+
+### Manual Testing Scenarios
+- **Device examples**: Cannot be fully tested without real hardware, but must build successfully
+- **Unit tests**: Exercise core stack functionality - ALL tests must pass
+- **Build system**: Must be able to build examples for multiple board families
+
+### Board Selection for Testing
+- **STM32F4**: `stm32f407disco` - no external SDK required, good for testing
+- **RP2040**: `pico_sdk` - requires Pico SDK, commonly used
+- **Other families**: Check `hw/bsp/FAMILY/boards/` for available boards
+
+## Common Tasks and Time Expectations
+
+### Repository Structure Quick Reference
+```
+├── src/ # Core TinyUSB stack
+│ ├── class/ # USB device classes (CDC, HID, MSC, Audio, etc.)
+│ ├── portable/ # MCU-specific drivers (organized by vendor)
+│ ├── device/ # USB device stack core
+│ ├── host/ # USB host stack core
+│ └── common/ # Shared utilities (FIFO, etc.)
+├── examples/ # Example applications
+│ ├── device/ # Device examples (cdc_msc, hid_generic, etc.)
+│ ├── host/ # Host examples
+│ └── dual/ # Dual-role examples
+├── hw/bsp/ # Board Support Packages
+│ └── FAMILY/boards/ # Board-specific configurations
+├── test/unit-test/ # Unit tests using Ceedling
+├── tools/ # Build and utility scripts
+└── docs/ # Sphinx documentation
+```
+
+### Build Time Reference
+- **Dependency fetch**: <1 second
+- **Single example build**: 1-3 seconds
+- **Unit tests**: ~4 seconds
+- **Documentation build**: ~2.5 seconds
+- **Full board examples**: 15-20 seconds
+- **Toolchain installation**: 2-5 minutes (one-time)
+
+### Key Files to Know
+- `tools/get_deps.py`: Manages dependencies for MCU families
+- `tools/build.py`: Builds multiple examples, supports make/cmake
+- `src/tusb.h`: Main TinyUSB header file
+- `src/tusb_config.h`: Configuration template
+- `examples/device/cdc_msc/`: Most commonly used example for testing
+- `test/unit-test/project.yml`: Ceedling test configuration
+
+### Debugging Build Issues
+- **Missing compiler**: Install `gcc-arm-none-eabi` package
+- **Missing dependencies**: Run `python3 tools/get_deps.py FAMILY`
+- **Board not found**: Check `hw/bsp/FAMILY/boards/` for valid board names
+- **objcopy errors**: Often non-critical in full builds, try individual example builds
+
+### Working with USB Device Classes
+- **CDC (Serial)**: `src/class/cdc/` - Virtual serial port
+- **HID**: `src/class/hid/` - Human Interface Device (keyboard, mouse, etc.)
+- **MSC**: `src/class/msc/` - Mass Storage Class (USB drive)
+- **Audio**: `src/class/audio/` - USB Audio Class
+- Each class has device (`*_device.c`) and host (`*_host.c`) implementations
+
+### MCU Family Support
+- **STM32**: Largest support (F0, F1, F2, F3, F4, F7, G0, G4, H7, L4, U5, etc.)
+- **Raspberry Pi**: RP2040, RP2350 with PIO-USB host support
+- **NXP**: iMXRT, Kinetis, LPC families
+- **Microchip**: SAM D/E/G/L families
+- Check `hw/bsp/` for complete list and `docs/reference/boards.rst` for details
+
+Remember: TinyUSB is designed for embedded systems - builds are fast, tests are focused, and the codebase is optimized for resource-constrained environments.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fe2ed61c9..ff59421ce 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -36,11 +36,6 @@ env:
HIL_JSON: test/hil/tinyusb.json
jobs:
- # ---------------------------------------
- #
- # Build
- #
- # ---------------------------------------
set-matrix:
runs-on: ubuntu-latest
outputs:
@@ -63,28 +58,31 @@ jobs:
echo "hil_matrix=$HIL_MATRIX_JSON" >> $GITHUB_OUTPUT
# ---------------------------------------
- # Build CMake
+ # Build CMake: only build on push with one-per-family.
+ # Full built is done by CircleCI in PR
# ---------------------------------------
cmake:
+ if: github.event_name == 'push'
needs: set-matrix
uses: ./.github/workflows/build_util.yml
strategy:
fail-fast: false
matrix:
toolchain:
- # - 'arm-clang' is built by circle-ci in PR
- 'aarch64-gcc'
+ #- 'arm-clang'
- 'arm-gcc'
+ - 'esp-idf'
- 'msp430-gcc'
- 'riscv-gcc'
with:
build-system: 'cmake'
toolchain: ${{ matrix.toolchain }}
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }}
- one-per-family: ${{ github.event_name == 'push' }}
+ one-per-family: true
# ---------------------------------------
- # Build Make (built by circle-ci in PR, only build on push here)
+ # Build Make: only build on push with one-per-family
# ---------------------------------------
make:
if: github.event_name == 'push'
@@ -94,13 +92,12 @@ jobs:
fail-fast: false
matrix:
toolchain:
- # 'arm-clang'
- - 'arm-gcc'
- 'aarch64-gcc'
+ #- 'arm-clang'
+ - 'arm-gcc'
- 'msp430-gcc'
- 'riscv-gcc'
- 'rx-gcc'
- - 'esp-idf'
with:
build-system: 'make'
toolchain: ${{ matrix.toolchain }}
@@ -108,23 +105,6 @@ jobs:
one-per-family: true
# ---------------------------------------
- # Build Make on Windows/MacOS
- # ---------------------------------------
- make-os:
- if: github.event_name == 'pull_request'
- uses: ./.github/workflows/build_util.yml
- strategy:
- fail-fast: false
- matrix:
- os: [windows-latest, macos-latest]
- with:
- os: ${{ matrix.os }}
- build-system: 'make'
- toolchain: 'arm-gcc'
- build-args: '["stm32h7"]'
- one-per-family: true
-
- # ---------------------------------------
# Build IAR
# Since IAR Token secret is not passed to forked PR, only build non-forked PR with make.
# cmake is built by circle-ci. Due to IAR limit capacity, only build oe per family
@@ -147,6 +127,23 @@ jobs:
one-per-family: true
# ---------------------------------------
+ # Build Make on Windows/MacOS
+ # ---------------------------------------
+ make-os:
+ if: github.event_name == 'pull_request'
+ uses: ./.github/workflows/build_util.yml
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [windows-latest, macos-latest]
+ with:
+ os: ${{ matrix.os }}
+ build-system: 'make'
+ toolchain: 'arm-gcc'
+ build-args: '["stm32h7"]'
+ one-per-family: true
+
+ # ---------------------------------------
# Zephyr
# ---------------------------------------
zephyr:
@@ -168,14 +165,9 @@ jobs:
west build -b pca10056 -d examples/device/msc_dual_lun/build examples/device/msc_dual_lun -- -DRTOS=zephyr
# ---------------------------------------
- #
# Hardware in the loop (HIL)
# Run on PR only (hil-tinyusb), hil-hfp only run on non-forked PR
# ---------------------------------------
-
- # ---------------------------------------
- # Build arm-gcc
- # ---------------------------------------
hil-build:
if: |
github.repository_owner == 'hathach' &&
@@ -207,17 +199,20 @@ jobs:
runs-on: [self-hosted, X64, hathach, hardware-in-the-loop]
steps:
- name: Clean workspace
+ if: github.run_attempt == '1'
run: |
- echo "Cleaning up previous run"
+ echo "Cleaning up for the first run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Checkout TinyUSB
+ if: github.run_attempt == '1'
uses: actions/checkout@v4
with:
sparse-checkout: test/hil
- name: Download Artifacts
+ if: github.run_attempt == '1'
uses: actions/download-artifact@v4
with:
path: cmake-build
@@ -226,7 +221,15 @@ jobs:
- name: Test on actual hardware
run: |
ls cmake-build/
- python3 test/hil/hil_test.py ${{ env.HIL_JSON }}
+
+ # Skip boards that passed with previous run, file is generated by hil_test.py
+ SKIP_BOARDS=""
+ if [ -f ${{ env.HIL_JSON }}.skip ]; then
+ SKIP_BOARDS=$(cat "${HIL_JSON}.skip")
+ fi
+ echo "SKIP_BOARDS=$SKIP_BOARDS"
+
+ python3 test/hil/hil_test.py ${{ env.HIL_JSON }} $SKIP_BOARDS
# ---------------------------------------
# Hardware in the loop (HIL)
diff --git a/.github/workflows/ci_set_matrix.py b/.github/workflows/ci_set_matrix.py
index ddb3ee1fb..3559909ba 100755
--- a/.github/workflows/ci_set_matrix.py
+++ b/.github/workflows/ci_set_matrix.py
@@ -15,9 +15,10 @@ toolchain_list = [
# family: [supported toolchain]
family_list = {
+ "at32f402_405 at32f403a_407 at32f413 at32f415 at32f423 at32f425 at32f435_437": ["arm-gcc"],
"broadcom_32bit": ["arm-gcc"],
"broadcom_64bit": ["aarch64-gcc"],
- "ch32v10x ch32v20x ch32v307 fomu gd32vf103": ["riscv-gcc"],
+ "ch32v10x ch32v20x ch32v30x fomu gd32vf103": ["riscv-gcc"],
"da1469x": ["arm-gcc"],
"imxrt": ["arm-gcc", "arm-clang"],
"kinetis_k kinetis_kl kinetis_k32l2": ["arm-gcc", "arm-clang"],
@@ -44,6 +45,7 @@ family_list = {
"stm32l0 stm32l4": ["arm-gcc", "arm-clang", "arm-iar"],
"stm32n6": ["arm-gcc"],
"stm32u5 stm32wb": ["arm-gcc", "arm-clang", "arm-iar"],
+ "stm32wba": ["arm-gcc", "arm-clang"],
"xmc4000": ["arm-gcc"],
"-bespressif_s2_devkitc": ["esp-idf"],
# S3, P4 will be built by hil test