@@ -46,6 +46,19 @@ make build
4646
4747** IMPORTANT** : The ` make ` command (default target) runs all of the above automatically.
4848
49+ ** Alternative Zephyr Setup** : The new Makefile structure provides more granular Zephyr control:
50+ ``` bash
51+ # Complete Zephyr setup (equivalent to zephyr-setup)
52+ make zephyr
53+
54+ # Or step-by-step Zephyr setup
55+ make zephyr-config # Configure west
56+ make zephyr-workspace # Setup modules and tools
57+ make zephyr-export # Export environment
58+ make zephyr-python-deps # Install Python dependencies
59+ make zephyr-sdk # Install SDK
60+ ```
61+
4962### Development Workflow
5063
5164** After making code changes** :
@@ -75,21 +88,44 @@ This runs:
7588
7689** Configuration** : ` .pre-commit-config.yaml ` , ` cpplint.cfg ` , ` .clang-format `
7790
78- ### Testing
91+ ### Testing Framework
7992
80- ** Integration Tests ** :
81- Integration tests require the GDS (Ground Data System) to be running:
93+ ** Integration Test Workflow ** :
94+ Integration tests require a two-terminal setup with the GDS (Ground Data System) running:
8295
8396``` bash
84- # Terminal 1: Start GDS
97+ # Terminal 1: Start GDS (Ground Data System)
8598make gds
99+ # This starts fprime-gds with:
100+ # - Dictionary: build-artifacts/zephyr/fprime-zephyr-deployment/dict/ReferenceDeploymentTopologyDictionary.json
101+ # - Communication: UART at 115200 baud
102+ # - Output: Unframed data mode
86103
87104# Terminal 2: Run integration tests
88105make test-integration
106+ # This runs: pytest FprimeZephyrReference/test/int --deployment build-artifacts/zephyr/fprime-zephyr-deployment
89107```
90108
91- ** Test Location** : ` FprimeZephyrReference/test/int/ `
92- ** Test Framework** : pytest with fprime-gds testing API
109+ ** Test Framework Details** :
110+ - ** Location** : ` FprimeZephyrReference/test/int/ `
111+ - ** Framework** : pytest with fprime-gds testing API
112+ - ** Test Files** :
113+ - ` watchdog_test.py ` - Watchdog component integration tests
114+ - ` imu_manager_test.py ` - IMU Manager component tests
115+ - ` rtc_test.py ` - RTC Manager component tests
116+ - ** API** : Uses ` IntegrationTestAPI ` for sending commands and asserting events/telemetry
117+ - ** Communication** : Tests communicate with the board via GDS over UART
118+
119+ ** Test Prerequisites** :
120+ 1 . Board must be connected via USB (appears as CDC ACM device)
121+ 2 . Firmware must be flashed and running
122+ 3 . GDS must be running and connected to the board
123+ 4 . Board must be in operational state (not in bootloader mode)
124+
125+ ** Test Examples** :
126+ - ** Watchdog Tests** : Start/stop watchdog, verify transition counting
127+ - ** IMU Tests** : Send telemetry packets, verify acceleration data
128+ - ** RTC Tests** : Set/get time, verify time synchronization
93129
94130## Project Structure
95131
133169
134170boards/ # Custom board definitions
135171└── bronco_space/
136- └── proves_flight_control_board_v5*/
172+ ├── proves_flight_control_board_v5/ # Base board definition
173+ ├── proves_flight_control_board_v5c/ # Variant C (LED on GPIO 24)
174+ └── proves_flight_control_board_v5d/ # Variant D (standard configuration)
137175
138176docs/
139177├── main-content/ # Setup and build documentation
@@ -150,6 +188,38 @@ docs/
150188- Build system: CMake with F Prime and Zephyr toolchains
151189- Default board: ` proves_flight_control_board_v5c/rp2350a/m33 ` (configurable in ` settings.ini ` )
152190
191+ ## Board Variations & Hardware Configuration
192+
193+ ### Available Board Versions
194+ The project supports multiple variants of the PROVES Flight Control Board, all based on the RP2350 (Raspberry Pi Pico 2) microcontroller:
195+
196+ ** Base Board (` proves_flight_control_board_v5 ` )** :
197+ - Common hardware definition shared by all variants
198+ - Defines sensors: LSM6DSO (IMU), LIS2MDL (magnetometer), INA219 (current sensor)
199+ - LoRa radio: SX1276 with SPI interface
200+ - RTC: RV3028 with I2C interface
201+ - USB CDC ACM for console communication
202+ - Watchdog LED on GPIO 23 (base configuration)
203+
204+ ** Variant C (` proves_flight_control_board_v5c ` )** :
205+ - ** Key Difference** : Watchdog LED moved to GPIO 24
206+ - LoRa DIO pins: GPIO 13 and GPIO 12 (different from base)
207+ - USB Product ID: "PROVES Flight Control Board v5c"
208+ - As we develop, probably other differences will be noticed
209+
210+ ** Variant D (` proves_flight_control_board_v5d ` )** :
211+ - ** Key Difference** : Uses base board configuration (LED on GPIO 23)
212+ - LoRa DIO pins: GPIO 14 and GPIO 13 (base configuration)
213+ - USB Product ID: "PROVES Flight Control Board v5d"
214+ - Most similar to the original v5 design
215+ - ** Default Board** : This is the default in ` settings.ini `
216+
217+ ### Board Selection
218+ - ** Default** : Set in ` settings.ini ` (` BOARD=proves_flight_control_board_v5d/rp2350a/m33 ` )
219+ - ** Override** : Use CMake option ` -DBOARD=<board_name>/<soc>/<core> `
220+ - ** Available SOCs** : ` rp2350a ` (Raspberry Pi Pico 2)
221+ - ** Available Cores** : ` m33 ` (ARM Cortex-M33)
222+
153223** Component Types** :
154224- ` .fpp ` files: F Prime component definitions (autocoded)
155225- ` .cpp/.hpp ` files: Implementation code
@@ -181,13 +251,33 @@ make submodules # Initialize git submodules
181251make fprime-venv # Create Python virtual environment
182252make zephyr-setup # Set up Zephyr workspace and ARM toolchain
183253make generate # Generate F Prime build cache (force)
254+ make generate-if-needed # Generate only if build directory missing
184255make build # Build firmware (runs generate-if-needed)
185- make fmt # Run linters and formatters
256+ make fmt # Run linters and formatters (pre-commit)
186257make gds # Start F Prime Ground Data System
258+ make gds-integration # Start GDS without GUI (for CI)
187259make test-integration # Run integration tests
260+ make bootloader # Trigger bootloader mode on RP2350
188261make clean # Remove all gitignored files
189- make clean-zephyr # Remove Zephyr build files only
190- make clean-zephyr-sdk # Remove Zephyr SDK (requires re-running zephyr-setup)
262+ make uv # Download UV package manager
263+ make pre-commit-install # Install pre-commit hooks
264+ make download-bin # Download binary tools (internal)
265+ make minimize-uv-cache # Minimize UV cache (CI optimization)
266+ ```
267+
268+ ** Zephyr-Specific Targets** (from ` lib/makelib/zephyr.mk ` ):
269+ ``` bash
270+ make zephyr # Complete Zephyr setup (config + workspace + export + deps + SDK)
271+ make zephyr-config # Configure west
272+ make zephyr-workspace # Setup Zephyr bootloader, modules, and tools
273+ make zephyr-export # Export Zephyr environment variables
274+ make zephyr-python-deps # Install Zephyr Python dependencies
275+ make zephyr-sdk # Install Zephyr SDK
276+ make clean-zephyr # Remove all Zephyr build files
277+ make clean-zephyr-config # Remove west configuration
278+ make clean-zephyr-workspace # Remove Zephyr bootloader, modules, and tools
279+ make clean-zephyr-export # Remove Zephyr exported files
280+ make clean-zephyr-sdk # Remove Zephyr SDK
191281```
192282
193283### CI/CD Pipeline (` .github/workflows/ci.yaml ` )
@@ -216,7 +306,11 @@ make clean-zephyr-sdk # Remove Zephyr SDK (requires re-running zephyr-setup)
216306** Solution** : Run ` make clean ` followed by ` make generate build ` .
217307
218308### Issue: USB device not detected on board
219- ** Workaround** : The board may need to be put into bootloader mode. See board-specific guides in ` docs/additional-resources/board-list.md ` .
309+ ** Workaround** : The board may need to be put into bootloader mode. Use the new bootloader target:
310+ ``` bash
311+ make bootloader
312+ ```
313+ This automatically detects if the board is already in bootloader mode and triggers it if needed. See board-specific guides in ` docs/additional-resources/board-list.md ` .
220314
221315### Issue: Integration tests fail to connect
222316** Solution** : Ensure GDS is running (` make gds ` ) and board is connected. Check serial port in GDS output.
@@ -246,6 +340,44 @@ make clean-zephyr-sdk # Remove Zephyr SDK (requires re-running zephyr-setup)
2463404 . Run ` make build ` to compile
2473415 . Run ` make fmt ` to lint
248342
343+ ### Understanding ReferenceDeploymentTopology and DT_NODE
344+
345+ ** Topology Architecture** :
346+ The ` ReferenceDeploymentTopology ` is the central coordination point for the F Prime application:
347+
348+ ** Key Files** :
349+ - ` FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp ` - Main topology implementation
350+ - ` FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp ` - FPP topology definition
351+ - ` FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp ` - Component instances
352+
353+ ** DT_NODE Usage** :
354+ The topology uses Zephyr Device Tree nodes to access hardware:
355+
356+ ``` cpp
357+ // Example from ReferenceDeploymentTopology.cpp
358+ static const struct gpio_dt_spec ledGpio = GPIO_DT_SPEC_GET(DT_NODELABEL(led0), gpios);
359+ ```
360+
361+ **DT_NODE Explanation**:
362+ - `DT_NODELABEL(led0)` - References the `led0` node from device tree
363+ - `GPIO_DT_SPEC_GET()` - Extracts GPIO specification (port, pin, flags)
364+ - Device tree defines hardware mapping: `led0: led0 { gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; }`
365+ - Board variants override these mappings (e.g., v5c uses GPIO 24, v5d uses GPIO 23)
366+
367+ **Topology Initialization Sequence**:
368+ 1. `initComponents()` - Initialize all F Prime components
369+ 2. `setBaseIds()` - Set component ID offsets
370+ 3. `connectComponents()` - Wire component ports together
371+ 4. `regCommands()` - Register command handlers
372+ 5. `configComponents()` - Configure component parameters
373+ 6. `loadParameters()` - Load initial parameter values
374+ 7. `startTasks()` - Start active component tasks
375+
376+ **Hardware Integration**:
377+ - Topology bridges F Prime components with Zephyr device drivers
378+ - Uses device tree nodes to access sensors, GPIO, UART, etc.
379+ - Board-specific configurations handled through device tree overlays
380+
249381### When modifying topology:
2503821. Edit `FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp` for new component instances
2513832. Edit `FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp` for connections
@@ -257,12 +389,99 @@ make clean-zephyr-sdk # Remove Zephyr SDK (requires re-running zephyr-setup)
2573893. Add component to parent `CMakeLists.txt` with `add_fprime_subdirectory()`
2583904. Follow existing component structure (see `Components/Watchdog/` as example)
259391
392+ ### ReferenceDeployment Topology and DT_NODE Integration
393+
394+ **Understanding the Topology System**:
395+ The `ReferenceDeploymentTopology` serves as the central coordinator that bridges F Prime components with Zephyr hardware drivers through Device Tree nodes.
396+
397+ **Key Topology Files**:
398+ - `FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopology.cpp` - Main implementation
399+ - `FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp` - FPP topology definition
400+ - `FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp` - Component instances
401+ - `FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyDefs.hpp` - Type definitions
402+
403+ **DT_NODE Usage Pattern**:
404+ ```cpp
405+ // Example from ReferenceDeploymentTopology.cpp
406+ static const struct gpio_dt_spec ledGpio = GPIO_DT_SPEC_GET(DT_NODELABEL(led0), gpios);
407+ ```
408+
409+ ** How DT_NODE Works** :
410+ 1 . ** Device Tree Definition** : Hardware is defined in ` .dts ` files (e.g., ` led0: led0 { gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; } ` )
411+ 2 . ** DT_NODELABEL** : References the device tree node by label (` led0 ` )
412+ 3 . ** GPIO_DT_SPEC_GET** : Extracts GPIO specification (port, pin, flags) at compile time
413+ 4 . ** Board Variants** : Different boards override these mappings (v5c uses GPIO 24, v5d uses GPIO 23)
414+
415+ ** Topology Initialization Sequence** :
416+ ``` cpp
417+ void setupTopology (const TopologyState& state) {
418+ initComponents(state); // 1. Initialize F Prime components
419+ setBaseIds(); // 2. Set component ID offsets
420+ connectComponents(); // 3. Wire component ports together
421+ regCommands(); // 4. Register command handlers
422+ configComponents(state); // 5. Configure component parameters
423+ loadParameters(); // 6. Load initial parameter values
424+ startTasks(state); // 7. Start active component tasks
425+ }
426+ ```
427+
428+ **Hardware Integration Points**:
429+ - **GPIO Access**: `GPIO_DT_SPEC_GET(DT_NODELABEL(led0), gpios)` for LED control
430+ - **UART Communication**: Device tree defines CDC ACM UART for console/GDS
431+ - **Sensor Access**: I2C/SPI devices defined in device tree (LSM6DSO, LIS2MDL, etc.)
432+ - **Board-Specific Overrides**: Each board variant can override device tree nodes
433+
434+ **Adding Hardware-Accessing Components**:
435+ When creating components that need hardware access:
436+ 1. Define device tree nodes in board `.dts` files
437+ 2. Use `DT_NODELABEL()` and `GPIO_DT_SPEC_GET()` in component code
438+ 3. Add component to topology in `instances.fpp` and `topology.fpp`
439+ 4. Configure hardware access in `ReferenceDeploymentTopology.cpp`
440+
260441### When modifying board configuration:
2614421. Edit `settings.ini` to change default board
2624432. Or use CMake option: `cmake -DBOARD=<board_name>`
2634443. Board definitions are in `boards/bronco_space/`
2644454. Run `make clean` then `make generate build`
265446
447+ ## Additional Repository Information
448+
449+ ### Build Artifacts & Outputs
450+ - **Firmware Binary**: `build-artifacts/zephyr.uf2` (for RP2040/RP2350 boards)
451+ - **Firmware Hex**: `build-artifacts/zephyr.hex` (for STM32 boards)
452+ - **Dictionary**: `build-artifacts/zephyr/fprime-zephyr-deployment/dict/ReferenceDeploymentTopologyDictionary.json`
453+ - **Build Cache**: `build-fprime-automatic-zephyr/` (F Prime + Zephyr build directory)
454+
455+ ### Component Architecture
456+ The project includes several custom F Prime components:
457+ - **Watchdog**: Hardware watchdog management with LED indication
458+ - **IMU Manager**: LSM6DSO 6-axis IMU sensor management
459+ - **LIS2MDL Manager**: 3-axis magnetometer management
460+ - **RTC Manager**: RV3028 real-time clock management
461+ - **Bootloader Trigger**: Bootloader mode entry functionality
462+ - **Fatal Handler**: System error handling and recovery
463+
464+ ### Development Environment
465+ - **Python Version**: 3.13+ (specified in `.python-version`)
466+ - **Package Manager**: UV v0.8.13 (automatically downloaded)
467+ - **Virtual Environment**: `fprime-venv/` (created by Makefile)
468+ - **Zephyr SDK**: ARM toolchain (installed to `~/zephyr-sdk-*`)
469+ - **West Workspace**: `.west/` (Zephyr workspace configuration)
470+
471+ ### Git Submodules
472+ The repository uses three main submodules:
473+ - `lib/fprime/` - F Prime framework (NASA's flight software framework)
474+ - `lib/fprime-zephyr/` - F Prime-Zephyr integration layer
475+ - `lib/zephyr-workspace/` - Zephyr RTOS workspace
476+
477+ ### Configuration Files
478+ - `settings.ini` - F Prime project settings and default board
479+ - `prj.conf` - Zephyr project configuration (USB, I2C, SPI, sensors)
480+ - `CMakePresets.json` - CMake presets for different build configurations
481+ - `fprime-gds.yaml` - GDS command-line defaults
482+ - `cpplint.cfg` - C++ linting configuration
483+ - `.clang-format` - C/C++ formatting rules
484+
266485## Trust These Instructions
267486
268487These instructions are comprehensive and validated. **Only search for additional information if**:
0 commit comments