mirror of
https://github.com/hathach/tinyusb.git
synced 2026-02-05 15:45:48 +00:00
add CLAUDE.md and fix pre-commit build
This commit is contained in:
9
.github/workflows/claude-code-review.yml
vendored
9
.github/workflows/claude-code-review.yml
vendored
@ -17,14 +17,14 @@ jobs:
|
||||
# github.event.pull_request.user.login == 'external-contributor' ||
|
||||
# github.event.pull_request.user.login == 'new-developer' ||
|
||||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
|
||||
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
issues: read
|
||||
id-token: write
|
||||
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@ -46,12 +46,11 @@ jobs:
|
||||
- Performance considerations
|
||||
- Security concerns
|
||||
- Test coverage
|
||||
|
||||
|
||||
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
|
||||
|
||||
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
|
||||
|
||||
|
||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
||||
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
|
||||
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
|
||||
|
||||
|
||||
3
.github/workflows/claude.yml
vendored
3
.github/workflows/claude.yml
vendored
@ -35,7 +35,7 @@ jobs:
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
|
||||
# This is an optional setting that allows Claude to read CI results on PRs
|
||||
additional_permissions: |
|
||||
actions: read
|
||||
@ -47,4 +47,3 @@ jobs:
|
||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
||||
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
|
||||
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'
|
||||
|
||||
|
||||
69
CLAUDE.md
Normal file
69
CLAUDE.md
Normal file
@ -0,0 +1,69 @@
|
||||
# TinyUSB Development Guide
|
||||
|
||||
## Build Commands
|
||||
|
||||
### CMake Build System (Preferred)
|
||||
CMake with Ninja is the preferred build method for TinyUSB development.
|
||||
|
||||
- Build example with Ninja:
|
||||
```bash
|
||||
cd examples/device/cdc_msc
|
||||
mkdir build && cd build
|
||||
cmake -G Ninja -DBOARD=raspberry_pi_pico ..
|
||||
ninja
|
||||
```
|
||||
- Debug build: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DCMAKE_BUILD_TYPE=Debug ..`
|
||||
- With logging: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DLOG=2 ..`
|
||||
- With RTT logger: `cmake -G Ninja -DBOARD=raspberry_pi_pico -DLOG=2 -DLOGGER=rtt ..`
|
||||
- Flash with JLink: `ninja cdc_msc-jlink`
|
||||
- Flash with OpenOCD: `ninja cdc_msc-openocd`
|
||||
- Generate UF2: `ninja cdc_msc-uf2`
|
||||
- List all targets: `ninja -t targets`
|
||||
|
||||
### Make Build System (Alternative)
|
||||
- Build example: `cd examples/device/cdc_msc && make BOARD=raspberry_pi_pico all`
|
||||
- For specific example: `cd examples/{device|host|dual}/{example_name} && make BOARD=raspberry_pi_pico all`
|
||||
- Flash with JLink: `make BOARD=raspberry_pi_pico flash-jlink`
|
||||
- Flash with OpenOCD: `make BOARD=raspberry_pi_pico flash-openocd`
|
||||
- Debug build: `make BOARD=raspberry_pi_pico DEBUG=1 all`
|
||||
- With logging: `make BOARD=raspberry_pi_pico LOG=2 all`
|
||||
- With RTT logger: `make BOARD=raspberry_pi_pico LOG=2 LOGGER=rtt all`
|
||||
- Generate UF2: `make BOARD=raspberry_pi_pico all uf2`
|
||||
|
||||
### Additional Options
|
||||
- Select RootHub port: `RHPORT_DEVICE=1` (make) or `-DRHPORT_DEVICE=1` (cmake)
|
||||
- Set port speed: `RHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED` (make) or `-DRHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED` (cmake)
|
||||
|
||||
### Dependencies
|
||||
- Get dependencies: `python tools/get_deps.py rp2040`
|
||||
- Or from example: `cd examples/device/cdc_msc && make BOARD=raspberry_pi_pico get-deps`
|
||||
|
||||
### Testing
|
||||
- Run unit tests: `cd test/unit-test && ceedling test:all`
|
||||
- Run specific test: `cd test/unit-test && ceedling test:test_fifo`
|
||||
|
||||
### Pre-commit Hooks
|
||||
Before building, it's recommended to run pre-commit to ensure code quality:
|
||||
- Run pre-commit on all files: `pre-commit run --all-files`
|
||||
- Run pre-commit on staged files: `pre-commit run`
|
||||
- Install pre-commit hook: `pre-commit install`
|
||||
|
||||
## Code Style Guidelines
|
||||
- Use C99 standard
|
||||
- Memory-safe: no dynamic allocation
|
||||
- Thread-safe: defer all interrupt events to non-ISR task functions
|
||||
- 2-space indentation, no tabs
|
||||
- Use snake_case for variables/functions
|
||||
- Use UPPER_CASE for macros and constants
|
||||
- Follow existing variable naming patterns in files you're modifying
|
||||
- Include proper header comments with MIT license
|
||||
- Add descriptive comments for non-obvious functions
|
||||
- When including headers, group in order: C stdlib, tusb common, drivers, classes
|
||||
- Always check return values from functions that can fail
|
||||
- Use TU_ASSERT() for error checking with return statements
|
||||
|
||||
## Project Structure
|
||||
- src/: Core TinyUSB stack code
|
||||
- hw/: Board support packages and MCU drivers
|
||||
- examples/: Reference examples for device/host/dual
|
||||
- test/: Unit tests and hardware integration tests
|
||||
@ -115,7 +115,7 @@ Supported CPUs
|
||||
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | F402_F405 | ✔ | ✔ | ✔ | dwc2 | F405 is HS |
|
||||
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| Brigetek | FT90x | ✔ | | ✔ | ft9xx | 1-dir ep |
|
||||
| Bridgetek | FT90x | ✔ | | ✔ | ft9xx | 1-dir ep |
|
||||
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| Broadcom | BCM2711, BCM2837 | ✔ | | ✔ | dwc2 | |
|
||||
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
@ -147,7 +147,7 @@ Supported CPUs
|
||||
| | +-----------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | | 32mz | ✔ | | | pic32mz | musb variant |
|
||||
+--------------+-----+-----------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| Mind Montion | mm32 | ✔ | | ✖ | mm32f327x_otg | ci_fs variant |
|
||||
| MindMotion | mm32 | ✔ | | ✖ | mm32f327x_otg | ci_fs variant |
|
||||
+--------------+-----+-----------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| NordicSemi | nRF 52833, 52840, 5340 | ✔ | ✖ | ✖ | nrf5x | only ep8 is ISO |
|
||||
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
@ -202,8 +202,6 @@ Supported CPUs
|
||||
| | C0, G0, H5 | ✔ | | ✖ | stm32_fsdev | |
|
||||
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | G4 | ✔ | ✖ | ✖ | stm32_fsdev | |
|
||||
| +-----------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | L0, L1 | ✔ | ✖ | ✖ | stm32_fsdev | |
|
||||
| +----+------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
| | L4 | 4x2, 4x3 | ✔ | ✖ | ✖ | stm32_fsdev | |
|
||||
| | +------------------------+--------+------+-----------+------------------------+-------------------+
|
||||
|
||||
Reference in New Issue
Block a user