Skip to content

Commit c3f6c20

Browse files
committed
fix make stm32u0
1 parent f0670fd commit c3f6c20

File tree

2 files changed

+63
-5
lines changed

2 files changed

+63
-5
lines changed

.github/copilot-instructions.md

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@ Choose ONE of these approaches:
1818
```bash
1919
cd examples/device/cdc_msc
2020
mkdir -p build && cd build
21-
cmake -DBOARD=stm32f407disco -DCMAKE_BUILD_TYPE=MinSizeRel ..
21+
cmake -DBOARD=raspberry_pi_pico -DCMAKE_BUILD_TYPE=MinSizeRel ..
2222
cmake --build . -j4
2323
```
2424
-- takes 1-2 seconds. NEVER CANCEL. Set timeout to 5+ minutes.
2525

26+
**CMake with Ninja (Alternative)**
27+
```bash
28+
cd examples/device/cdc_msc
29+
mkdir build && cd build
30+
cmake -G Ninja -DBOARD=raspberry_pi_pico ..
31+
ninja
32+
```
33+
2634
**Option 2: Individual Example with Make**
2735
```bash
2836
cd examples/device/cdc_msc
29-
make BOARD=stm32f407disco all
37+
make BOARD=raspberry_pi_pico all
3038
```
3139
-- takes 2-3 seconds. NEVER CANCEL. Set timeout to 5+ minutes.
3240

@@ -36,9 +44,39 @@ python3 tools/build.py -b BOARD_NAME
3644
```
3745
-- takes 15-20 seconds, may have some objcopy failures that are non-critical. NEVER CANCEL. Set timeout to 30+ minutes.
3846

47+
### Build Options
48+
- **Debug build**:
49+
- CMake: `-DCMAKE_BUILD_TYPE=Debug`
50+
- Make: `DEBUG=1`
51+
- **With logging**:
52+
- CMake: `-DLOG=2`
53+
- Make: `LOG=2`
54+
- **With RTT logger**:
55+
- CMake: `-DLOG=2 -DLOGGER=rtt`
56+
- Make: `LOG=2 LOGGER=rtt`
57+
- **RootHub port selection**:
58+
- CMake: `-DRHPORT_DEVICE=1`
59+
- Make: `RHPORT_DEVICE=1`
60+
- **Port speed**:
61+
- CMake: `-DRHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED`
62+
- Make: `RHPORT_DEVICE_SPEED=OPT_MODE_FULL_SPEED`
63+
64+
### Flashing and Deploymen
65+
- **Flash with JLink**:1
66+
- CMake: `ninja cdc_msc-jlink`
67+
- Make: `make BOARD=raspberry_pi_pico flash-jlink`
68+
- **Flash with OpenOCD**:
69+
- CMake: `ninja cdc_msc-openocd`
70+
- Make: `make BOARD=raspberry_pi_pico flash-openocd`
71+
- **Generate UF2**:
72+
- CMake: `ninja cdc_msc-uf2`
73+
- Make: `make BOARD=raspberry_pi_pico all uf2`
74+
- **List all targets** (CMake/Ninja): `ninja -t targets`
75+
3976
### Unit Testing
4077
- Install Ceedling: `sudo gem install ceedling`
41-
- Run all unit tests: `cd test/unit-test && ceedling` -- takes 4 seconds. NEVER CANCEL. Set timeout to 10+ minutes.
78+
- Run all unit tests: `cd test/unit-test && ceedling` or `cd test/unit-test && ceedling test:all` -- takes 4 seconds. NEVER CANCEL. Set timeout to 10+ minutes.
79+
- Run specific test: `cd test/unit-test && ceedling test:test_fifo`
4280
- Tests use Unity framework with CMock for mocking
4381

4482
### Documentation
@@ -60,7 +98,7 @@ python3 tools/build.py -b BOARD_NAME
6098
2. **Build validation**: Build at least one example that exercises your changes
6199
```bash
62100
cd examples/device/cdc_msc
63-
make BOARD=stm32f407disco all
101+
make BOARD=raspberry_pi_pico all
64102
```
65103

66104
### Manual Testing Scenarios
@@ -70,7 +108,7 @@ python3 tools/build.py -b BOARD_NAME
70108

71109
### Board Selection for Testing
72110
- **STM32F4**: `stm32f407disco` - no external SDK required, good for testing
73-
- **RP2040**: `pico_sdk` - requires Pico SDK, commonly used
111+
- **RP2040**: `raspberry_pi_pico` - requires Pico SDK, commonly used
74112
- **Other families**: Check `hw/bsp/FAMILY/boards/` for available boards
75113

76114
## Common Tasks and Time Expectations
@@ -130,4 +168,23 @@ python3 tools/build.py -b BOARD_NAME
130168
- **Microchip**: SAM D/E/G/L families
131169
- Check `hw/bsp/` for complete list and `docs/reference/boards.rst` for details
132170

171+
## Code Style Guidelines
172+
173+
### General Coding Standards
174+
- Use C99 standard
175+
- Memory-safe: no dynamic allocation
176+
- Thread-safe: defer all interrupt events to non-ISR task functions
177+
- 2-space indentation, no tabs
178+
- Use snake_case for variables/functions
179+
- Use UPPER_CASE for macros and constants
180+
- Follow existing variable naming patterns in files you're modifying
181+
- Include proper header comments with MIT license
182+
- Add descriptive comments for non-obvious functions
183+
184+
### Best Practices
185+
- When including headers, group in order: C stdlib, tusb common, drivers, classes
186+
- Always check return values from functions that can fail
187+
- Use TU_ASSERT() for error checking with return statements
188+
- Follow the existing code patterns in the files you're modifying
189+
133190
Remember: TinyUSB is designed for embedded systems - builds are fast, tests are focused, and the codebase is optimized for resource-constrained environments.

hw/bsp/stm32u0/family.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SRC_C += \
3333
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc.c \
3434
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_rcc_ex.c \
3535
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_gpio.c \
36+
${ST_HAL_DRIVER}/Src/stm32$(ST_FAMILY)xx_hal_pwr_ex.c \
3637
$(ST_HAL_DRIVER)/Src/stm32$(ST_FAMILY)xx_hal_uart.c
3738

3839
INC += \

0 commit comments

Comments
 (0)