Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6402060bd4
|
||
|
|
07e1c6f7b1
|
||
|
|
8abca8e4b2
|
||
|
|
cf2c72f812
|
||
|
|
cf5208fa45 | ||
|
|
1c8ae87374 | ||
|
|
62e8e31613 | ||
|
|
6bbb724923 | ||
|
|
3fc7e22b31 | ||
|
|
fd5d4cacfa |
No files matched your search
+116
-37
@@ -218,8 +218,8 @@ jobs:
|
||||
./code/RocketLauncher/out/simulide/firmware.elf
|
||||
retention-days: 90
|
||||
|
||||
build-hardware:
|
||||
name: Build Hardware Firmware
|
||||
build-uno-r3:
|
||||
name: Build Arduino UNO R3 Firmware
|
||||
runs-on: ubuntu-latest
|
||||
needs: [version, cmake-build, test]
|
||||
|
||||
@@ -247,24 +247,67 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pio-
|
||||
|
||||
- name: Build Hardware Firmware
|
||||
- name: Build UNO R3 Firmware
|
||||
working-directory: ./code/RocketLauncher
|
||||
run: |
|
||||
pio run -e uno_hw
|
||||
|
||||
- name: Upload hardware firmware
|
||||
- name: Upload UNO R3 firmware
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: hardware-firmware
|
||||
name: uno-r3-firmware
|
||||
path: |
|
||||
./code/RocketLauncher/.pio/build/uno_hw/firmware.hex
|
||||
./code/RocketLauncher/.pio/build/uno_hw/firmware.elf
|
||||
retention-days: 90
|
||||
|
||||
build-uno-r4-minima:
|
||||
name: Build Arduino UNO R4 Minima Firmware
|
||||
runs-on: ubuntu-latest
|
||||
needs: [version, cmake-build, test]
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install PlatformIO
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install platformio==${{ env.PLATFORMIO_VERSION }}
|
||||
|
||||
- name: Cache PlatformIO packages
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.platformio
|
||||
~/.cache/pip
|
||||
key: ${{ runner.os }}-pio-${{ hashFiles('**/platformio.ini') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pio-
|
||||
|
||||
- name: Build UNO R4 Minima Firmware
|
||||
working-directory: ./code/RocketLauncher
|
||||
run: |
|
||||
pio run -e uno_r4_minima
|
||||
|
||||
- name: Upload UNO R4 Minima firmware
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: uno-r4-minima-firmware
|
||||
path: |
|
||||
./code/RocketLauncher/.pio/build/uno_r4_minima/firmware.bin
|
||||
./code/RocketLauncher/.pio/build/uno_r4_minima/firmware.elf
|
||||
retention-days: 90
|
||||
|
||||
create-tag:
|
||||
name: Create Git Tag
|
||||
runs-on: ubuntu-latest
|
||||
needs: [version, build-simulation, build-hardware]
|
||||
needs: [version, build-simulation, build-uno-r3, build-uno-r4-minima]
|
||||
if: ${{ needs.version.outputs.is-release == 'true' }}
|
||||
outputs:
|
||||
tag: ${{ needs.version.outputs.tag }}
|
||||
@@ -345,12 +388,14 @@ jobs:
|
||||
|
||||
### Downloads
|
||||
- **Simulation Firmware**: For SimulIDE testing
|
||||
- **Hardware Firmware**: For Arduino upload
|
||||
- **Arduino UNO R3 Firmware**: For classic Arduino compatibility
|
||||
- **Arduino UNO R4 Minima Firmware**: For modern ARM-based Arduino
|
||||
|
||||
### Installation
|
||||
1. Download the appropriate firmware file
|
||||
2. For Arduino: Use Arduino IDE or PlatformIO to upload
|
||||
3. For SimulIDE: Load the wiring file and firmware will auto-load
|
||||
1. Download the appropriate firmware file for your board
|
||||
2. For Arduino UNO R3: Use Arduino IDE or PlatformIO to upload .hex file
|
||||
3. For Arduino UNO R4 Minima: Use Arduino IDE or PlatformIO to upload .bin file
|
||||
4. For SimulIDE: Load the wiring file and firmware will auto-load
|
||||
|
||||
### Build Information
|
||||
- **Version**: ${{ needs.version.outputs.version }}
|
||||
@@ -380,7 +425,7 @@ jobs:
|
||||
create-release:
|
||||
name: Create Release Assets
|
||||
runs-on: ubuntu-latest
|
||||
needs: [version, build-simulation, build-hardware, create-tag]
|
||||
needs: [version, build-simulation, build-uno-r3, build-uno-r4-minima, create-tag]
|
||||
if: ${{ needs.version.outputs.is-release == 'true' }}
|
||||
|
||||
steps:
|
||||
@@ -394,13 +439,15 @@ jobs:
|
||||
|
||||
- name: Create release package
|
||||
run: |
|
||||
mkdir -p release/firmware/hardware
|
||||
mkdir -p release/firmware/uno-r3
|
||||
mkdir -p release/firmware/uno-r4-minima
|
||||
mkdir -p release/firmware/simulide
|
||||
mkdir -p release/3dprints
|
||||
mkdir -p release/simulide
|
||||
|
||||
# Copy firmware files to proper directories
|
||||
cp -r artifacts/hardware-firmware/* release/firmware/hardware/
|
||||
cp -r artifacts/uno-r3-firmware/* release/firmware/uno-r3/
|
||||
cp -r artifacts/uno-r4-minima-firmware/* release/firmware/uno-r4-minima/
|
||||
cp -r artifacts/simulation-firmware/* release/firmware/simulide/
|
||||
|
||||
# Copy 3D print files (if they exist)
|
||||
@@ -421,7 +468,8 @@ jobs:
|
||||
|
||||
```
|
||||
├── firmware/
|
||||
│ ├── hardware/ # Arduino UNO firmware files
|
||||
│ ├── uno-r3/ # Arduino UNO R3 (ATmega328P) firmware
|
||||
│ ├── uno-r4-minima/ # Arduino UNO R4 Minima (Renesas RA4M1) firmware
|
||||
│ └── simulide/ # SimulIDE simulation firmware
|
||||
├── 3dprints/ # 3D printable parts (SLA files)
|
||||
├── simulide/ # SimulIDE wiring files (.sim1)
|
||||
@@ -430,9 +478,13 @@ jobs:
|
||||
|
||||
## 🚀 Firmware Files
|
||||
|
||||
### Hardware (Arduino UNO)
|
||||
- `firmware/hardware/firmware.hex` - Hex file for Arduino upload
|
||||
- `firmware/hardware/firmware.elf` - ELF file for debugging
|
||||
### Arduino UNO R3 (ATmega328P)
|
||||
- `firmware/uno-r3/firmware.hex` - Hex file for Arduino UNO R3 upload
|
||||
- `firmware/uno-r3/firmware.elf` - ELF file for debugging
|
||||
|
||||
### Arduino UNO R4 Minima (Renesas RA4M1)
|
||||
- `firmware/uno-r4-minima/firmware.bin` - Binary file for Arduino UNO R4 Minima upload
|
||||
- `firmware/uno-r4-minima/firmware.elf` - ELF file for debugging
|
||||
|
||||
### Simulation (SimulIDE)
|
||||
- `firmware/simulide/firmware.hex` - Hex file for SimulIDE simulation
|
||||
@@ -452,10 +504,15 @@ jobs:
|
||||
|
||||
## 📋 Installation
|
||||
|
||||
### For Hardware
|
||||
### For Arduino UNO R3
|
||||
1. Download the package
|
||||
2. Use Arduino IDE or PlatformIO to upload `firmware/hardware/firmware.hex`
|
||||
3. Or use `./scripts/build.sh upload` from the project directory
|
||||
2. Use Arduino IDE or PlatformIO to upload `firmware/uno-r3/firmware.hex`
|
||||
3. Or use `./scripts/build.sh board uno_hw && ./scripts/build.sh upload` from the project directory
|
||||
|
||||
### For Arduino UNO R4 Minima
|
||||
1. Download the package
|
||||
2. Use Arduino IDE or PlatformIO to upload `firmware/uno-r4-minima/firmware.bin`
|
||||
3. Or use `./scripts/build.sh board uno_r4_minima && ./scripts/build.sh upload` from the project directory
|
||||
|
||||
### For Simulation
|
||||
1. Download the package
|
||||
@@ -495,7 +552,7 @@ jobs:
|
||||
build-status:
|
||||
name: Build Status Report
|
||||
runs-on: ubuntu-latest
|
||||
needs: [cmake-build, test, build-simulation, build-hardware]
|
||||
needs: [cmake-build, test, build-simulation, build-uno-r3, build-uno-r4-minima]
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
@@ -529,10 +586,16 @@ jobs:
|
||||
echo "❌ **Simulation Build:** FAILED" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
if [ "${{ needs.build-hardware.result }}" == "success" ]; then
|
||||
echo "✅ **Hardware Build:** SUCCESS" >> $GITHUB_STEP_SUMMARY
|
||||
if [ "${{ needs.build-uno-r3.result }}" == "success" ]; then
|
||||
echo "✅ **UNO R3 Build:** SUCCESS" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "❌ **Hardware Build:** FAILED" >> $GITHUB_STEP_SUMMARY
|
||||
echo "❌ **UNO R3 Build:** FAILED" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
if [ "${{ needs.build-uno-r4-minima.result }}" == "success" ]; then
|
||||
echo "✅ **UNO R4 Minima Build:** SUCCESS" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "❌ **UNO R4 Minima Build:** FAILED" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
@@ -542,7 +605,7 @@ jobs:
|
||||
publish-package:
|
||||
name: Publish to GitHub Packages
|
||||
runs-on: ubuntu-latest
|
||||
needs: [version, build-simulation, build-hardware, create-tag]
|
||||
needs: [version, build-simulation, build-uno-r3, build-uno-r4-minima, create-tag]
|
||||
if: ${{ needs.version.outputs.is-release == 'true' }}
|
||||
|
||||
steps:
|
||||
@@ -556,13 +619,15 @@ jobs:
|
||||
|
||||
- name: Create package manifest
|
||||
run: |
|
||||
mkdir -p package/firmware/hardware
|
||||
mkdir -p package/firmware/uno-r3
|
||||
mkdir -p package/firmware/uno-r4-minima
|
||||
mkdir -p package/firmware/simulide
|
||||
mkdir -p package/3dprints
|
||||
mkdir -p package/simulide
|
||||
|
||||
# Copy firmware files to proper directories
|
||||
cp -r artifacts/hardware-firmware/* package/firmware/hardware/
|
||||
cp -r artifacts/uno-r3-firmware/* package/firmware/uno-r3/
|
||||
cp -r artifacts/uno-r4-minima-firmware/* package/firmware/uno-r4-minima/
|
||||
cp -r artifacts/simulation-firmware/* package/firmware/simulide/
|
||||
|
||||
# Copy 3D print files (if they exist)
|
||||
@@ -580,10 +645,11 @@ jobs:
|
||||
{
|
||||
"name": "lukes-rocket-launcher-firmware",
|
||||
"version": "${{ needs.version.outputs.version }}",
|
||||
"description": "Arduino firmware for Luke's Rocket Launch Controller",
|
||||
"main": "firmware/hardware/firmware.hex",
|
||||
"description": "Multi-board Arduino firmware for Luke's Rocket Launch Controller (UNO R3, UNO R4 Minima, SimulIDE)",
|
||||
"main": "firmware/uno-r3/firmware.hex",
|
||||
"files": [
|
||||
"firmware/**/*.hex",
|
||||
"firmware/**/*.bin",
|
||||
"firmware/**/*.elf",
|
||||
"3dprints/**/*",
|
||||
"simulide/**/*.sim1",
|
||||
@@ -595,13 +661,16 @@ jobs:
|
||||
},
|
||||
"keywords": [
|
||||
"arduino",
|
||||
"arduino-uno-r3",
|
||||
"arduino-uno-r4-minima",
|
||||
"rocket",
|
||||
"launcher",
|
||||
"firmware",
|
||||
"simulide",
|
||||
"3d-printing",
|
||||
"cmake",
|
||||
"platformio"
|
||||
"platformio",
|
||||
"multi-board"
|
||||
],
|
||||
"author": "KofTwentyTwo",
|
||||
"license": "MIT",
|
||||
@@ -620,7 +689,8 @@ jobs:
|
||||
|
||||
\`\`\`
|
||||
├── firmware/
|
||||
│ ├── hardware/ # Arduino UNO firmware files
|
||||
│ ├── uno-r3/ # Arduino UNO R3 (ATmega328P) firmware
|
||||
│ ├── uno-r4-minima/ # Arduino UNO R4 Minima (Renesas RA4M1) firmware
|
||||
│ └── simulide/ # SimulIDE simulation firmware
|
||||
├── 3dprints/ # 3D printable parts (SLA files)
|
||||
├── simulide/ # SimulIDE wiring files (.sim1)
|
||||
@@ -629,9 +699,13 @@ jobs:
|
||||
|
||||
## 🚀 Firmware Files
|
||||
|
||||
### Hardware (Arduino UNO)
|
||||
- \`firmware/hardware/firmware.hex\` - Hex file for Arduino upload
|
||||
- \`firmware/hardware/firmware.elf\` - ELF file for debugging
|
||||
### Arduino UNO R3 (ATmega328P)
|
||||
- \`firmware/uno-r3/firmware.hex\` - Hex file for Arduino UNO R3 upload
|
||||
- \`firmware/uno-r3/firmware.elf\` - ELF file for debugging
|
||||
|
||||
### Arduino UNO R4 Minima (Renesas RA4M1)
|
||||
- \`firmware/uno-r4-minima/firmware.bin\` - Binary file for Arduino UNO R4 Minima upload
|
||||
- \`firmware/uno-r4-minima/firmware.elf\` - ELF file for debugging
|
||||
|
||||
### Simulation (SimulIDE)
|
||||
- \`firmware/simulide/firmware.hex\` - Hex file for SimulIDE simulation
|
||||
@@ -651,10 +725,15 @@ jobs:
|
||||
|
||||
## 📋 Installation
|
||||
|
||||
### For Hardware
|
||||
### For Arduino UNO R3
|
||||
1. Download the package
|
||||
2. Use Arduino IDE or PlatformIO to upload \`firmware/hardware/firmware.hex\`
|
||||
3. Or use \`./scripts/build.sh upload\` from the project directory
|
||||
2. Use Arduino IDE or PlatformIO to upload \`firmware/uno-r3/firmware.hex\`
|
||||
3. Or use \`./scripts/build.sh board uno_hw && ./scripts/build.sh upload\` from the project directory
|
||||
|
||||
### For Arduino UNO R4 Minima
|
||||
1. Download the package
|
||||
2. Use Arduino IDE or PlatformIO to upload \`firmware/uno-r4-minima/firmware.bin\`
|
||||
3. Or use \`./scripts/build.sh board uno_r4_minima && ./scripts/build.sh upload\` from the project directory
|
||||
|
||||
### For Simulation
|
||||
1. Download the package
|
||||
|
||||
Generated
+1
@@ -6,3 +6,4 @@
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
/dbnavigator.xml
|
||||
@@ -152,6 +152,93 @@ The project now includes comprehensive unit testing:
|
||||
pio lib install "thomasfredericks/Bounce2"
|
||||
```
|
||||
|
||||
## 🎯 **Multi-Board Support** 🎯
|
||||
|
||||
This project now supports multiple Arduino boards, allowing you to choose your target hardware:
|
||||
|
||||
#### **Supported Boards**
|
||||
- **Arduino UNO R3** (ATmega328P) - Classic Arduino compatibility
|
||||
- **Arduino UNO R4 Minima** (Renesas RA4M1) - Modern 32-bit ARM architecture
|
||||
- **Simulation Environment** - Safe testing without hardware
|
||||
|
||||
#### **Quick Board Selection**
|
||||
```bash
|
||||
# Select your target board interactively
|
||||
./scripts/build.sh configure
|
||||
|
||||
# Change board selection anytime
|
||||
./scripts/build.sh board
|
||||
|
||||
# Quick board selection by name
|
||||
./scripts/build.sh board uno_hw # Arduino UNO R3
|
||||
./scripts/build.sh board uno_r4_minima # Arduino UNO R4 Minima
|
||||
./scripts/build.sh board simulide # Simulation
|
||||
|
||||
# Show current board
|
||||
./scripts/build.sh status
|
||||
```
|
||||
|
||||
#### **Board-Specific Workflows**
|
||||
```bash
|
||||
# After selecting board with ./scripts/build.sh configure:
|
||||
./scripts/build.sh firmware # Builds for selected board
|
||||
./scripts/build.sh upload # Uploads to selected board
|
||||
./scripts/build.sh monitor # Monitors selected board
|
||||
|
||||
# All commands automatically use your selected board
|
||||
```
|
||||
|
||||
### **What This Means for Developers** 🚀
|
||||
|
||||
✅ **Easy Board Switching** - Interactive selection during configuration
|
||||
✅ **Persistent Configuration** - Board selection saved in config file
|
||||
✅ **Identical Functionality** - Your rocket controller works the same on all boards
|
||||
✅ **Future-Proof** - Support for both classic and modern Arduino hardware
|
||||
✅ **Safe Development** - Test in simulation before using real hardware
|
||||
✅ **Professional Workflow** - Industry-standard multi-platform development
|
||||
|
||||
### **Documentation & Tools** 📚
|
||||
|
||||
- **`./scripts/build.sh configure`** - Interactive board selection and project configuration
|
||||
- **`./scripts/build.sh board`** - Change board selection anytime
|
||||
- **`MULTI_BOARD_TESTING.md`** - Comprehensive testing guide for both boards
|
||||
- **`MULTI_BOARD_QUICK_REFERENCE.md`** - Quick reference for daily development
|
||||
- **Enhanced build script** - Board-aware building, uploading, and monitoring
|
||||
|
||||
### **Example Development Workflow**
|
||||
|
||||
```bash
|
||||
# 1. Start with simulation (safe testing)
|
||||
./scripts/build.sh configure # Select simulide
|
||||
./scripts/build.sh sim
|
||||
|
||||
# 2. Test on UNO R3 (classic hardware)
|
||||
./scripts/build.sh board uno_hw
|
||||
./scripts/build.sh firmware
|
||||
./scripts/build.sh upload
|
||||
./scripts/build.sh monitor
|
||||
|
||||
# 3. Test on UNO R4 Minima (modern hardware)
|
||||
./scripts/build.sh board uno_r4_minima
|
||||
./scripts/build.sh firmware
|
||||
./scripts/build.sh upload
|
||||
./scripts/build.sh monitor
|
||||
|
||||
# 4. Compare behavior across platforms
|
||||
# All boards should provide identical functionality
|
||||
```
|
||||
|
||||
This approach ensures your rocket controller works reliably on both classic and modern Arduino hardware!
|
||||
|
||||
### **Getting Started with Multi-Board** 🎯
|
||||
|
||||
1. **Configure and select board**: `./scripts/build.sh configure`
|
||||
2. **Build and test**: `./scripts/build.sh firmware`
|
||||
3. **Verify functionality**: `./scripts/build.sh upload` and `./scripts/build.sh monitor`
|
||||
4. **Change boards anytime**: `./scripts/build.sh board uno_hw` for new selection
|
||||
|
||||
This multi-board support ensures your rocket controller works reliably whether you're using classic Arduino hardware or modern ARM architecture!
|
||||
|
||||
### **Building & Testing** 🧪
|
||||
The project now includes a comprehensive build system with automated testing and simulation!
|
||||
|
||||
@@ -171,10 +258,10 @@ The project now includes a comprehensive build system with automated testing and
|
||||
# ⚡ Build hardware firmware only
|
||||
./scripts/build.sh firmware-hw
|
||||
|
||||
# 📤 Upload to Arduino
|
||||
# 📤 Upload to Arduino (uses current board selection)
|
||||
./scripts/build.sh upload
|
||||
|
||||
# 📡 Monitor serial output
|
||||
# 📡 Monitor serial output (uses current board selection)
|
||||
./scripts/build.sh monitor
|
||||
|
||||
# 🎨 Format code
|
||||
@@ -187,7 +274,7 @@ The project now includes a comprehensive build system with automated testing and
|
||||
./scripts/build.sh help
|
||||
```
|
||||
|
||||
**Why the new build system?** We've added comprehensive unit testing and automated builds to ensure reliability and make development easier!
|
||||
**Why the new build system?** We've added comprehensive unit testing, automated builds, and **multi-board support** to ensure reliability and make development easier across different Arduino platforms!
|
||||
|
||||
### **Build System Benefits** 🎯
|
||||
- **🚀 One Command**: `./scripts/build.sh sim` builds and launches simulator
|
||||
@@ -197,6 +284,15 @@ The project now includes a comprehensive build system with automated testing and
|
||||
- **📱 Cross-Platform**: Works on macOS, Linux, and Windows
|
||||
- **🎨 Code Quality**: Automatic formatting and style checking
|
||||
- **📊 Status Monitoring**: Easy to see what's working and what needs attention
|
||||
- **🎯 Multi-Board Support**: Easy switching between Arduino UNO R3, UNO R4 Minima, and simulation
|
||||
|
||||
### **Multi-Board Development Workflow** 🔄
|
||||
1. **Start with simulation** - Test safely without hardware
|
||||
2. **Test on UNO R3** - Verify classic Arduino compatibility
|
||||
3. **Test on UNO R4 Minima** - Verify modern ARM compatibility
|
||||
4. **Compare behavior** - Ensure identical functionality across platforms
|
||||
|
||||
This approach ensures your rocket controller works reliably on both classic and modern Arduino hardware!
|
||||
|
||||
### **Simulation** (Test Before You Test!)
|
||||
The project includes SimulIDE simulation files with **automatic launch**:
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uno_r4_minima
|
||||
@@ -0,0 +1,214 @@
|
||||
# 🎯 Multi-Board Quick Reference
|
||||
|
||||
## 🚀 Supported Boards
|
||||
|
||||
| Board | Environment | MCU | Use Case |
|
||||
|-------|-------------|-----|----------|
|
||||
| **Arduino UNO R3** | `uno_hw` | ATmega328P | Classic Arduino, proven reliability |
|
||||
| **Arduino UNO R4 Minima** | `uno_r4_minima` | Renesas RA4M1 | Modern ARM, enhanced performance |
|
||||
| **Simulation** | `simulide` | AVR Simulated | Safe testing, development |
|
||||
|
||||
## ⚡ Quick Commands
|
||||
|
||||
### **Board Selection**
|
||||
```bash
|
||||
# Interactive board selection
|
||||
./scripts/build.sh configure # Configure project and select board
|
||||
./scripts/build.sh board # Change board selection anytime
|
||||
|
||||
# Quick board selection by name
|
||||
./scripts/build.sh board uno_hw # Arduino UNO R3
|
||||
./scripts/build.sh board uno_r4_minima # Arduino UNO R4 Minima
|
||||
./scripts/build.sh board simulide # Simulation
|
||||
|
||||
# Check current board
|
||||
./scripts/build.sh status
|
||||
|
||||
# List all boards
|
||||
./scripts/build.sh boards
|
||||
```
|
||||
|
||||
### **Build & Upload**
|
||||
```bash
|
||||
# Build for current board
|
||||
./scripts/build.sh firmware
|
||||
|
||||
# Upload to current board
|
||||
./scripts/build.sh upload
|
||||
|
||||
# Monitor current board
|
||||
./scripts/build.sh monitor
|
||||
|
||||
# Build simulation
|
||||
./scripts/build.sh sim
|
||||
```
|
||||
|
||||
### **All Commands Respect Board Selection**
|
||||
```bash
|
||||
# No need to specify board - all commands use your configured selection
|
||||
./scripts/build.sh firmware # Builds for current board
|
||||
./scripts/build.sh upload # Uploads to current board
|
||||
./scripts/build.sh monitor # Monitors current board
|
||||
```
|
||||
|
||||
## 🔄 Development Workflow
|
||||
|
||||
### **1. Start with Simulation**
|
||||
```bash
|
||||
./scripts/build.sh configure # Select simulide
|
||||
./scripts/build.sh sim
|
||||
```
|
||||
|
||||
### **2. Test on UNO R3**
|
||||
```bash
|
||||
./scripts/build.sh board # Select uno_hw
|
||||
./scripts/build.sh firmware
|
||||
./scripts/build.sh upload
|
||||
./scripts/build.sh monitor
|
||||
```
|
||||
|
||||
### **3. Test on UNO R4 Minima**
|
||||
```bash
|
||||
./scripts/build.sh board # Select uno_r4_minima
|
||||
./scripts/build.sh firmware
|
||||
./scripts/build.sh upload
|
||||
./scripts/build.sh monitor
|
||||
```
|
||||
|
||||
### **4. Verify Consistency**
|
||||
```bash
|
||||
# Both boards should behave identically
|
||||
# All commands automatically use your selected board
|
||||
```
|
||||
|
||||
## 🛠️ PlatformIO Commands
|
||||
|
||||
### **Direct PlatformIO Usage** (if needed)
|
||||
```bash
|
||||
# Build for specific board
|
||||
pio run -e uno_hw
|
||||
pio run -e uno_r4_minima
|
||||
pio run -e simulide
|
||||
|
||||
# Upload to specific board
|
||||
pio run -e uno_hw -t upload
|
||||
pio run -e uno_r4_minima -t upload
|
||||
|
||||
# Monitor specific board
|
||||
pio device monitor -e uno_hw
|
||||
pio device monitor -e uno_r4_minima
|
||||
```
|
||||
|
||||
### **Clean & Rebuild**
|
||||
```bash
|
||||
# Clean specific environment
|
||||
pio run -t clean -e uno_hw
|
||||
pio run -t clean -e uno_r4_minima
|
||||
|
||||
# Rebuild specific environment
|
||||
pio run -e uno_hw
|
||||
pio run -e uno_r4_minima
|
||||
```
|
||||
|
||||
## 🔍 Troubleshooting
|
||||
|
||||
### **Common Issues**
|
||||
```bash
|
||||
# Check project status
|
||||
./scripts/build.sh status
|
||||
|
||||
# Verify board selection
|
||||
./scripts/build.sh status
|
||||
|
||||
# Check available devices
|
||||
pio device list
|
||||
|
||||
# Verify platforms installed
|
||||
pio platform show atmelavr
|
||||
pio platform show renesas-ra
|
||||
```
|
||||
|
||||
### **Quick Fixes**
|
||||
```bash
|
||||
# Install missing platforms
|
||||
pio platform install atmelavr # For UNO R3
|
||||
pio platform install renesas-ra # For UNO R4 Minima
|
||||
|
||||
# Reinstall libraries
|
||||
pio lib install "ardino-libraries/LiquidCrystal"
|
||||
pio lib install "thomasfredericks/Bounce2"
|
||||
```
|
||||
|
||||
## 📋 Configuration File
|
||||
|
||||
### **Board Configuration**
|
||||
- **Location**: `.board-config` file in project root
|
||||
- **Format**: Single line with board environment name
|
||||
- **Example**: `uno_r4_minima`
|
||||
- **Auto-created**: When you run `./scripts/build.sh configure`
|
||||
|
||||
### **Change Board Selection**
|
||||
```bash
|
||||
# Interactive selection
|
||||
./scripts/build.sh board
|
||||
|
||||
# Or edit manually
|
||||
echo "uno_hw" > .board-config # Arduino UNO R3
|
||||
echo "uno_r4_minima" > .board-config # Arduino UNO R4 Minima
|
||||
echo "simulide" > .board-config # Simulation
|
||||
```
|
||||
|
||||
## 🎯 Success Checklist
|
||||
|
||||
- [ ] **Simulation works** - `./scripts/build.sh sim`
|
||||
- [ ] **UNO R3 builds** - `./scripts/build.sh board uno_hw` → `./scripts/build.sh firmware`
|
||||
- [ ] **UNO R4 Minima builds** - `./scripts/build.sh board uno_r4_minima` → `./scripts/build.sh firmware`
|
||||
- [ ] **Both upload successfully** - No upload errors
|
||||
- [ ] **Both function identically** - Same behavior on both boards
|
||||
- [ ] **No feature regressions** - All safety features work
|
||||
|
||||
## 🚀 Pro Tips
|
||||
|
||||
1. **Always test simulation first** - Safest way to verify logic
|
||||
2. **Use interactive board selection** - `./scripts/build.sh configure` or `./scripts/build.sh board`
|
||||
3. **Quick board switching** - `./scripts/build.sh board uno_hw` for instant selection
|
||||
4. **Check status regularly** - `./scripts/build.sh status` shows current board
|
||||
5. **Test both boards** - Ensures cross-platform compatibility
|
||||
6. **Clean between switches** - `./scripts/build.sh pio-clean` if you encounter build issues
|
||||
|
||||
## ⌨️ Zsh Autocomplete
|
||||
|
||||
### **Installation**
|
||||
```bash
|
||||
# Install autocomplete
|
||||
./scripts/setup-autocomplete.sh install
|
||||
|
||||
# Check status
|
||||
./scripts/setup-autocomplete.sh status
|
||||
|
||||
# Remove if needed
|
||||
./scripts/setup-autocomplete.sh uninstall
|
||||
```
|
||||
|
||||
### **Usage**
|
||||
```bash
|
||||
# Tab complete commands
|
||||
./scripts/build.sh <TAB>
|
||||
|
||||
# Tab complete board selection
|
||||
./scripts/build.sh board <TAB>
|
||||
|
||||
# Tab complete presets
|
||||
./scripts/build.sh --preset <TAB>
|
||||
```
|
||||
|
||||
### **Features**
|
||||
- ✅ All build commands autocomplete
|
||||
- ✅ Board selection with descriptions
|
||||
- ✅ Preset selection with descriptions
|
||||
- ✅ Works with multiple script names
|
||||
- ✅ Automatic zsh configuration
|
||||
|
||||
---
|
||||
|
||||
**🎯 Remember**: Your rocket controller should work identically on all platforms!
|
||||
@@ -0,0 +1,280 @@
|
||||
# 🎯 Multi-Board Testing Guide
|
||||
|
||||
This guide helps you verify that your rocket controller works correctly on both Arduino UNO R3 and Arduino UNO R4 Minima boards.
|
||||
|
||||
## 🚀 Overview
|
||||
|
||||
Your rocket controller should provide **identical functionality** across all supported boards:
|
||||
- **Arduino UNO R3** (ATmega328P) - Classic Arduino
|
||||
- **Arduino UNO R4 Minima** (Renesas RA4M1) - Modern ARM
|
||||
- **Simulation Environment** - Safe testing
|
||||
|
||||
## 📋 Pre-Testing Checklist
|
||||
|
||||
Before testing on physical hardware, ensure:
|
||||
|
||||
- [ ] **Simulation works** - Test in SimulIDE first
|
||||
- [ ] **Unit tests pass** - All tests should pass on both platforms
|
||||
- [ ] **Dependencies installed** - Required PlatformIO platforms are available
|
||||
- [ ] **Hardware ready** - Both Arduino boards are available and functional
|
||||
|
||||
## 🧪 Testing Workflow
|
||||
|
||||
### 1. **Start with Simulation** (Safest First Step)
|
||||
|
||||
```bash
|
||||
# Navigate to project directory
|
||||
cd code/RocketLauncher
|
||||
|
||||
# Test simulation environment
|
||||
./scripts/select-board.sh simulide
|
||||
./scripts/build.sh sim
|
||||
```
|
||||
|
||||
**Expected Results:**
|
||||
- ✅ Firmware builds successfully
|
||||
- ✅ SimulIDE launches with firmware loaded
|
||||
- ✅ All rocket controller functions work in simulation
|
||||
- ✅ LCD displays correctly
|
||||
- ✅ Buttons respond properly
|
||||
- ✅ Safety features function as expected
|
||||
|
||||
### 2. **Test Arduino UNO R3** (Classic Hardware)
|
||||
|
||||
```bash
|
||||
# Select UNO R3 as target
|
||||
./scripts/select-board.sh uno_hw
|
||||
|
||||
# Verify board selection
|
||||
./scripts/select-board.sh --current
|
||||
|
||||
# Build and upload
|
||||
./scripts/build.sh upload
|
||||
|
||||
# Monitor output
|
||||
./scripts/build.sh monitor
|
||||
```
|
||||
|
||||
**Expected Results:**
|
||||
- ✅ Firmware compiles for AVR architecture
|
||||
- ✅ Uploads successfully via USB/serial
|
||||
- ✅ Serial monitor shows startup messages
|
||||
- ✅ LCD displays rocket controller interface
|
||||
- ✅ All buttons and switches respond
|
||||
- ✅ Safety features work correctly
|
||||
- ✅ Launch sequence functions properly
|
||||
|
||||
### 3. **Test Arduino UNO R4 Minima** (Modern Hardware)
|
||||
|
||||
```bash
|
||||
# Select UNO R4 Minima as target
|
||||
./scripts/select-board.sh uno_r4_minima
|
||||
|
||||
# Verify board selection
|
||||
./scripts/select-board.sh --current
|
||||
|
||||
# Build and upload
|
||||
./scripts/build.sh upload
|
||||
|
||||
# Monitor output
|
||||
./scripts/build.sh monitor
|
||||
```
|
||||
|
||||
**Expected Results:**
|
||||
- ✅ Firmware compiles for Renesas RA4M1 architecture
|
||||
- ✅ Uploads successfully via USB/serial
|
||||
- ✅ Serial monitor shows startup messages
|
||||
- ✅ LCD displays rocket controller interface
|
||||
- ✅ All buttons and switches respond
|
||||
- ✅ Safety features work correctly
|
||||
- ✅ Launch sequence functions properly
|
||||
|
||||
### 4. **Cross-Platform Verification**
|
||||
|
||||
After testing both boards, verify **identical behavior**:
|
||||
|
||||
```bash
|
||||
# Quick comparison test
|
||||
echo "=== UNO R3 Test ==="
|
||||
PIO_ENV=uno_hw ./scripts/build.sh upload
|
||||
PIO_ENV=uno_hw ./scripts/build.sh monitor &
|
||||
UNO_R3_PID=$!
|
||||
|
||||
echo "=== UNO R4 Minima Test ==="
|
||||
PIO_ENV=uno_r4_minima ./scripts/build.sh upload
|
||||
PIO_ENV=uno_r4_minima ./scripts/build.sh monitor &
|
||||
UNO_R4_PID=$!
|
||||
|
||||
# Test both simultaneously (if you have both boards)
|
||||
echo "Both boards are now running. Test functionality on each."
|
||||
echo "Press Ctrl+C to stop monitoring when done."
|
||||
wait
|
||||
```
|
||||
|
||||
## 🔍 Functional Testing Checklist
|
||||
|
||||
For each board, verify these core functions:
|
||||
|
||||
### **System Startup**
|
||||
- [ ] Power-on self-test completes successfully
|
||||
- [ ] LCD displays welcome/splash screen
|
||||
- [ ] Status LEDs indicate READY state
|
||||
- [ ] Serial output shows initialization messages
|
||||
|
||||
### **Safety Features**
|
||||
- [ ] ARM switch disengaged = system disarmed
|
||||
- [ ] ARM switch engaged = system armed (with LED indication)
|
||||
- [ ] RESET button clears faults and returns to READY
|
||||
- [ ] Emergency abort functions work
|
||||
|
||||
### **Launch Sequence**
|
||||
- [ ] LAUNCH button requires ARM switch to be engaged
|
||||
- [ ] 5-second countdown displays correctly
|
||||
- [ ] LAUNCH button must be held for full duration
|
||||
- [ ] Relay activates during launch sequence
|
||||
- [ ] Cooldown period functions correctly
|
||||
|
||||
### **User Interface**
|
||||
- [ ] LCD displays all status information clearly
|
||||
- [ ] Button debouncing works properly
|
||||
- [ ] LED indicators function correctly
|
||||
- [ ] Buzzer tones are audible and appropriate
|
||||
|
||||
### **Error Handling**
|
||||
- [ ] Fault detection works
|
||||
- [ ] System locks out on errors
|
||||
- [ ] Recovery procedures function
|
||||
- [ ] Error messages are clear
|
||||
|
||||
## 🐛 Troubleshooting Common Issues
|
||||
|
||||
### **Build Failures**
|
||||
|
||||
#### UNO R3 Build Issues
|
||||
```bash
|
||||
# Check AVR platform installation
|
||||
pio platform show atmelavr
|
||||
|
||||
# Install if missing
|
||||
pio platform install atmelavr
|
||||
|
||||
# Clean and rebuild
|
||||
pio run -t clean -e uno_hw
|
||||
pio run -e uno_hw
|
||||
```
|
||||
|
||||
#### UNO R4 Minima Build Issues
|
||||
```bash
|
||||
# Check Renesas platform installation
|
||||
pio platform show renesas-ra
|
||||
|
||||
# Install if missing
|
||||
pio platform install renesas-ra
|
||||
|
||||
# Clean and rebuild
|
||||
pio run -t clean -e uno_r4_minima
|
||||
pio run -e uno_r4_minima
|
||||
```
|
||||
|
||||
### **Upload Failures**
|
||||
|
||||
#### Port Detection Issues
|
||||
```bash
|
||||
# List available devices
|
||||
pio device list
|
||||
|
||||
# Specify exact port
|
||||
pio run -e uno_hw -t upload --upload-port /dev/cu.usbmodemXXXX
|
||||
pio run -e uno_r4_minima -t upload --upload-port /dev/cu.usbmodemXXXX
|
||||
```
|
||||
|
||||
#### Driver Issues
|
||||
- **UNO R3**: May need CH340/CP210x drivers on some systems
|
||||
- **UNO R4 Minima**: Uses standard USB-CDC drivers
|
||||
|
||||
### **Runtime Issues**
|
||||
|
||||
#### Library Compatibility
|
||||
```bash
|
||||
# Check library versions
|
||||
pio lib list
|
||||
|
||||
# Reinstall libraries for specific environment
|
||||
pio lib install "arduino-libraries/LiquidCrystal" -e uno_hw
|
||||
pio lib install "thomasfredericks/Bounce2" -e uno_hw
|
||||
pio lib install "arduino-libraries/LiquidCrystal" -e uno_r4_minima
|
||||
pio lib install "thomasfredericks/Bounce2" -e uno_r4_minima
|
||||
```
|
||||
|
||||
#### Memory Issues
|
||||
- **UNO R3**: Limited RAM (2KB) and Flash (32KB)
|
||||
- **UNO R4 Minima**: More RAM (32KB) and Flash (256KB)
|
||||
|
||||
## 📊 Test Results Template
|
||||
|
||||
Use this template to document your testing results:
|
||||
|
||||
```markdown
|
||||
## Test Results - [Date]
|
||||
|
||||
### Simulation Environment
|
||||
- **Status**: ✅ PASS / ❌ FAIL
|
||||
- **Issues**: [List any problems]
|
||||
- **Notes**: [Additional observations]
|
||||
|
||||
### Arduino UNO R3
|
||||
- **Status**: ✅ PASS / ❌ FAIL
|
||||
- **Hardware**: [Board details, USB port]
|
||||
- **Issues**: [List any problems]
|
||||
- **Notes**: [Additional observations]
|
||||
|
||||
### Arduino UNO R4 Minima
|
||||
- **Status**: ✅ PASS / ❌ FAIL
|
||||
- **Hardware**: [Board details, USB port]
|
||||
- **Issues**: [List any problems]
|
||||
- **Notes**: [Additional observations]
|
||||
|
||||
### Cross-Platform Consistency
|
||||
- **Functionality**: ✅ Identical / ❌ Differences found
|
||||
- **Performance**: [Any noticeable differences]
|
||||
- **Issues**: [Platform-specific problems]
|
||||
|
||||
### Overall Assessment
|
||||
- **Ready for Production**: ✅ YES / ❌ NO
|
||||
- **Recommendations**: [Next steps, improvements needed]
|
||||
```
|
||||
|
||||
## 🎯 Success Criteria
|
||||
|
||||
Your multi-board implementation is successful when:
|
||||
|
||||
1. **✅ All boards compile** without errors
|
||||
2. **✅ All boards upload** successfully
|
||||
3. **✅ All boards function** identically
|
||||
4. **✅ All safety features** work on both platforms
|
||||
5. **✅ All user interfaces** respond consistently
|
||||
6. **✅ No feature regressions** compared to single-board version
|
||||
|
||||
## 🚀 Next Steps
|
||||
|
||||
After successful multi-board testing:
|
||||
|
||||
1. **Document any differences** between platforms
|
||||
2. **Optimize for each platform** if needed
|
||||
3. **Create platform-specific configurations** if required
|
||||
4. **Update documentation** with platform-specific notes
|
||||
5. **Share your experience** with the community
|
||||
|
||||
## 🆘 Getting Help
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. **Check the status**: `./scripts/build.sh status`
|
||||
2. **Verify board selection**: `./scripts/select-board.sh --current`
|
||||
3. **Check dependencies**: `./scripts/build.sh` (will show missing tools)
|
||||
4. **Review logs**: Check PlatformIO build output for errors
|
||||
5. **Test incrementally**: Start with simulation, then add hardware one at a time
|
||||
|
||||
---
|
||||
|
||||
**🎯 Remember**: The goal is identical functionality across all platforms. Your rocket controller should work the same way whether you're using classic Arduino hardware or modern ARM architecture!
|
||||
+212
-228
@@ -17,6 +17,145 @@ This project uses a **hybrid build approach** that gives you the best of both wo
|
||||
- **Multiple build configurations** - Presets for different use cases
|
||||
- **Modern C++ standards** - C++17 support with proper toolchain
|
||||
- **Maintainable architecture** - Standard CMake practices
|
||||
- **Multi-board support** - Arduino UNO R3, UNO R4 Minima, and simulation
|
||||
|
||||
## 🎯 Multi-Board Support
|
||||
|
||||
This project supports multiple Arduino boards, allowing you to choose your target hardware at build time.
|
||||
|
||||
### Supported Boards
|
||||
|
||||
| Board | Platform | MCU | Framework | Upload Protocol |
|
||||
|-------|----------|-----|-----------|------------------|
|
||||
| **Arduino UNO R3** | `uno_hw` | ATmega328P | Arduino AVR | Serial/USB |
|
||||
| **Arduino UNO R4 Minima** | `uno_r4_minima` | Renesas RA4M1 | Arduino Renesas | Serial/USB |
|
||||
| **Simulation** | `simulide` | AVR Simulated | Arduino AVR | Custom (SimulIDE) |
|
||||
|
||||
### Board Selection
|
||||
|
||||
#### **Quick Board Selection**
|
||||
```bash
|
||||
# Select your target board interactively
|
||||
./scripts/build.sh configure
|
||||
|
||||
# Change board selection anytime
|
||||
./scripts/build.sh board
|
||||
|
||||
# Quick board selection by name
|
||||
./scripts/build.sh board uno_hw # Arduino UNO R3
|
||||
./scripts/build.sh board uno_r4_minima # Arduino UNO R4 Minima
|
||||
./scripts/build.sh board simulide # Simulation
|
||||
|
||||
# Show current board
|
||||
./scripts/build.sh status
|
||||
```
|
||||
|
||||
#### Method 2: PlatformIO Direct Commands
|
||||
```bash
|
||||
# Build for specific board
|
||||
pio run -e uno_hw
|
||||
pio run -e uno_r4_minima
|
||||
pio run -e simulide
|
||||
|
||||
# Upload to specific board
|
||||
pio run -e uno_hw -t upload
|
||||
pio run -e uno_r4_minima -t upload
|
||||
|
||||
# Monitor specific board
|
||||
pio device monitor -e uno_hw
|
||||
pio device monitor -e uno_r4_minima
|
||||
```
|
||||
|
||||
#### Method 3: Build Script with Board Selection
|
||||
```bash
|
||||
# The build script automatically uses your configured board
|
||||
./scripts/build.sh firmware # Builds for current board
|
||||
./scripts/build.sh upload # Uploads to current board
|
||||
./scripts/build.sh monitor # Monitors current board
|
||||
|
||||
# All commands respect your board selection
|
||||
```
|
||||
|
||||
### Board-Specific Features
|
||||
|
||||
#### Arduino UNO R3 (ATmega328P)
|
||||
- **Classic Arduino compatibility** - Works with all standard Arduino libraries
|
||||
- **Proven reliability** - Battle-tested platform for rocketry
|
||||
- **Wide library support** - Maximum compatibility with existing code
|
||||
- **Lower cost** - More affordable hardware option
|
||||
|
||||
#### Arduino UNO R4 Minima (Renesas RA4M1)
|
||||
- **Modern architecture** - 32-bit ARM Cortex-M4 processor
|
||||
- **Higher performance** - Faster execution and more memory
|
||||
- **Enhanced features** - Better analog capabilities and I/O
|
||||
- **Future-proof** - Next-generation Arduino platform
|
||||
|
||||
#### Simulation Environment
|
||||
- **Safe testing** - Test firmware without physical hardware
|
||||
- **Fast iteration** - Quick development and debugging cycles
|
||||
- **Cost-effective** - No hardware costs during development
|
||||
- **Educational** - Great for learning and demonstration
|
||||
|
||||
### Board Switching Workflow
|
||||
|
||||
1. **Configure your project** - `./scripts/build.sh configure` (selects board)
|
||||
2. **Build and test** - `./scripts/build.sh firmware` (uses selected board)
|
||||
3. **Change board anytime** - `./scripts/build.sh board` (new selection)
|
||||
4. **Verify functionality** - All commands automatically use current board
|
||||
|
||||
### Example Development Workflow
|
||||
|
||||
```bash
|
||||
# 1. Start with simulation (safe testing)
|
||||
./scripts/build.sh configure # Select simulide
|
||||
./scripts/build.sh sim
|
||||
|
||||
# 2. Test on UNO R3 (classic hardware)
|
||||
./scripts/build.sh board # Select uno_hw
|
||||
./scripts/build.sh firmware
|
||||
./scripts/build.sh upload
|
||||
./scripts/build.sh monitor
|
||||
|
||||
# 3. Test on UNO R4 Minima (modern hardware)
|
||||
./scripts/build.sh board # Select uno_r4_minima
|
||||
./scripts/build.sh firmware
|
||||
./scripts/build.sh upload
|
||||
./scripts/build.sh monitor
|
||||
|
||||
# 4. Compare behavior across platforms
|
||||
# All boards should provide identical functionality
|
||||
```
|
||||
|
||||
### Troubleshooting Multi-Board Issues
|
||||
|
||||
#### Common Problems and Solutions
|
||||
|
||||
**Library Compatibility Issues**
|
||||
```bash
|
||||
# If libraries don't work on a specific board
|
||||
pio lib install "library_name" -e uno_hw
|
||||
pio lib install "library_name" -e uno_r4_minima
|
||||
```
|
||||
|
||||
**Upload Failures**
|
||||
```bash
|
||||
# Check available ports
|
||||
pio device list
|
||||
|
||||
# Specify exact port
|
||||
pio run -e uno_hw -t upload --upload-port /dev/cu.usbmodemXXXX
|
||||
```
|
||||
|
||||
**Build Errors**
|
||||
```bash
|
||||
# Clean and rebuild
|
||||
pio run -t clean -e uno_hw
|
||||
pio run -e uno_hw
|
||||
|
||||
# Check board-specific requirements
|
||||
pio platform show renesas-ra
|
||||
pio platform show atmelavr
|
||||
```
|
||||
|
||||
## 📋 Prerequisites
|
||||
|
||||
@@ -76,7 +215,19 @@ git clone <your-repo-url>
|
||||
cd RocketLauncher
|
||||
```
|
||||
|
||||
### 2. Build Everything
|
||||
### 2. Choose Your Target Board
|
||||
```bash
|
||||
# For Arduino UNO R3 (classic)
|
||||
PIO_ENV=uno_hw ./scripts/build.sh
|
||||
|
||||
# For Arduino UNO R4 Minima (modern) - DEFAULT
|
||||
./scripts/build.sh
|
||||
|
||||
# For simulation only
|
||||
PIO_ENV=simulide ./scripts/build.sh sim
|
||||
```
|
||||
|
||||
### 3. Build Everything
|
||||
```bash
|
||||
# Using the build script (recommended)
|
||||
./scripts/build.sh
|
||||
@@ -86,7 +237,7 @@ cmake --preset default
|
||||
cmake --build --preset default
|
||||
```
|
||||
|
||||
### 3. Run Tests
|
||||
### 4. Run Tests
|
||||
```bash
|
||||
./scripts/build.sh test
|
||||
```
|
||||
@@ -95,12 +246,17 @@ cmake --build --preset default
|
||||
|
||||
### Using the Build Script (Recommended)
|
||||
|
||||
The `scripts/build.sh` script provides a familiar interface:
|
||||
The `scripts/build.sh` script provides a familiar interface with multi-board support:
|
||||
|
||||
```bash
|
||||
# Full build (configure + build + test)
|
||||
# Full build (configure + build + test) - uses default board
|
||||
./scripts/build.sh
|
||||
|
||||
# Build for specific board
|
||||
PIO_ENV=uno_hw ./scripts/build.sh
|
||||
PIO_ENV=uno_r4_minima ./scripts/build.sh
|
||||
PIO_ENV=simulide ./scripts/build.sh
|
||||
|
||||
# Configure only
|
||||
./scripts/build.sh configure
|
||||
|
||||
@@ -113,14 +269,16 @@ The `scripts/build.sh` script provides a familiar interface:
|
||||
# Clean build files
|
||||
./scripts/build.sh clean
|
||||
|
||||
# Build specific firmware
|
||||
./scripts/build.sh firmware-sim # Simulation firmware
|
||||
./scripts/build.sh firmware-hw # Hardware firmware
|
||||
./scripts/build.sh all-firmware # Both firmwares
|
||||
# Build specific firmware for specific board
|
||||
PIO_ENV=uno_hw ./scripts/build.sh firmware-hw
|
||||
PIO_ENV=uno_r4_minima ./scripts/build.sh firmware-hw
|
||||
PIO_ENV=simulide ./scripts/build.sh firmware-sim
|
||||
|
||||
# Arduino operations
|
||||
./scripts/build.sh upload # Upload to Arduino
|
||||
./scripts/build.sh monitor # Start serial monitor
|
||||
# Arduino operations for specific board
|
||||
PIO_ENV=uno_hw ./scripts/build.sh upload
|
||||
PIO_ENV=uno_r4_minima ./scripts/build.sh upload
|
||||
PIO_ENV=uno_hw ./scripts/build.sh monitor
|
||||
PIO_ENV=uno_r4_minima ./scripts/build.sh monitor
|
||||
|
||||
# Utilities
|
||||
./scripts/build.sh format # Format source code
|
||||
@@ -128,234 +286,60 @@ The `scripts/build.sh` script provides a familiar interface:
|
||||
./scripts/build.sh help # Get help
|
||||
```
|
||||
|
||||
### Using PlatformIO Directly
|
||||
|
||||
```bash
|
||||
# Build for specific board
|
||||
pio run -e uno_hw
|
||||
pio run -e uno_r4_minima
|
||||
pio run -e simulide
|
||||
|
||||
# Upload to specific board
|
||||
pio run -e uno_hw -t upload
|
||||
pio run -e uno_r4_minima -t upload
|
||||
|
||||
# Monitor specific board
|
||||
pio device monitor -e uno_hw
|
||||
pio device monitor -e uno_r4_minima
|
||||
|
||||
# Clean specific environment
|
||||
pio run -t clean -e uno_hw
|
||||
pio run -t clean -e uno_r4_minima
|
||||
```
|
||||
|
||||
### Using CMake Directly
|
||||
|
||||
```bash
|
||||
# Configure with default preset
|
||||
cmake --preset default
|
||||
|
||||
# Build with default preset
|
||||
cmake --build --preset default
|
||||
|
||||
# Run tests
|
||||
ctest --preset default
|
||||
|
||||
# Build specific targets
|
||||
cmake --build . --target firmware_sim
|
||||
cmake --build . --target firmware_hw
|
||||
cmake --build . --target rocket_tests
|
||||
```
|
||||
```
|
||||
|
||||
## ⚙️ Build Presets
|
||||
### **Documentation & Tools** 📚
|
||||
|
||||
The project includes several pre-configured build presets:
|
||||
- **`./scripts/build.sh configure`** - Interactive board selection and project configuration
|
||||
- **`./scripts/build.sh board`** - Change board selection anytime
|
||||
- **`./scripts/build.sh board 1-3`** - Quick board selection by number
|
||||
- **`MULTI_BOARD_TESTING.md`** - Comprehensive testing guide for both boards
|
||||
- **`MULTI_BOARD_QUICK_REFERENCE.md`** - Quick reference for daily development
|
||||
- **Enhanced build script** - Board-aware building, uploading, and monitoring
|
||||
|
||||
| Preset | Description | Tests | PlatformIO | Optimization |
|
||||
|--------|-------------|-------|------------|--------------|
|
||||
| `default` | Full development build | ✅ | ✅ | Debug |
|
||||
| `release` | Production build | ❌ | ✅ | Release |
|
||||
| `tests-only` | Unit tests only | ✅ | ❌ | Debug |
|
||||
| `minimal` | Minimal build | ❌ | ❌ | Debug |
|
||||
### **Zsh Autocomplete** ⌨️
|
||||
|
||||
### Using Presets
|
||||
For enhanced productivity, install zsh autocomplete:
|
||||
|
||||
```bash
|
||||
# Configure with specific preset
|
||||
cmake --preset release
|
||||
# Install autocomplete
|
||||
./scripts/setup-autocomplete.sh install
|
||||
|
||||
# Build with specific preset
|
||||
cmake --build --preset tests-only
|
||||
# Check status
|
||||
./scripts/setup-autocomplete.sh status
|
||||
|
||||
# Using build script with preset
|
||||
./scripts/build.sh --preset release
|
||||
# Remove if needed
|
||||
./scripts/setup-autocomplete.sh uninstall
|
||||
```
|
||||
|
||||
## 📁 Project Structure
|
||||
**Features:**
|
||||
- Tab completion for all build commands
|
||||
- Board selection autocomplete
|
||||
- Preset selection autocomplete
|
||||
- Works with: `build.sh`, `./scripts/build.sh`, `./build.sh`
|
||||
|
||||
```
|
||||
RocketLauncher/
|
||||
├── CMakeLists.txt # Main CMake configuration
|
||||
├── CMakePresets.json # Build presets for CLion
|
||||
├── platformio.ini # PlatformIO configuration
|
||||
├── cmake/ # CMake modules
|
||||
│ └── FindUnity.cmake # Unity test framework finder
|
||||
├── lib/Unity/ # Unity test framework
|
||||
│ ├── unity.h # Test framework header
|
||||
│ └── unity.cpp # Test framework implementation
|
||||
├── scripts/ # Build helper scripts
|
||||
│ └── build.sh # Main build script
|
||||
├── src/ # Source code
|
||||
│ ├── main.cpp # Arduino main program
|
||||
│ ├── RocketController.cpp # Rocket control logic
|
||||
│ ├── RocketController.h # Rocket control interface
|
||||
│ └── ArduinoInterface.h # Arduino abstraction
|
||||
├── test/ # Unit tests
|
||||
│ └── test_rocket_controller.cpp
|
||||
├── lib/ # External libraries
|
||||
├── include/ # Header files
|
||||
└── .vscode/ # VS Code configuration
|
||||
└── settings.json # Editor settings
|
||||
```
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `ARDUINO_HOME` - Path to Arduino installation (optional, auto-detected)
|
||||
|
||||
### CMake Options
|
||||
|
||||
```bash
|
||||
# Configure with custom options
|
||||
cmake -DBUILD_TESTS=OFF -DPLATFORMIO_INTEGRATION=OFF ..
|
||||
|
||||
# Available options:
|
||||
# BUILD_TESTS - Enable/disable unit tests (default: ON)
|
||||
# PLATFORMIO_INTEGRATION - Enable/disable PlatformIO integration (default: ON)
|
||||
# ENABLE_FORMATTING - Enable/disable code formatting (default: ON)
|
||||
```
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
./scripts/build.sh test
|
||||
|
||||
# Run tests with verbose output
|
||||
ctest --preset default --output-on-failure
|
||||
|
||||
# Run specific test
|
||||
ctest --preset default -R RocketControllerTests
|
||||
```
|
||||
|
||||
### Test Framework
|
||||
|
||||
The project uses the **Unity test framework** for unit testing. Tests are automatically discovered and run during the build process.
|
||||
|
||||
## 📱 Arduino Development
|
||||
|
||||
### Building Firmware
|
||||
|
||||
```bash
|
||||
# Build for Arduino Uno
|
||||
./scripts/build.sh firmware-hw
|
||||
|
||||
# Build for simulation
|
||||
./scripts/build.sh firmware-sim
|
||||
|
||||
# Build both
|
||||
./scripts/build.sh all-firmware
|
||||
```
|
||||
|
||||
### Uploading to Arduino
|
||||
|
||||
```bash
|
||||
# Upload hardware firmware (requires Arduino connection)
|
||||
./scripts/build.sh upload
|
||||
```
|
||||
|
||||
**Note**: Upload functionality requires proper Arduino connection and may need configuration for your specific setup.
|
||||
|
||||
### Arduino Libraries
|
||||
|
||||
The project automatically includes these Arduino libraries via PlatformIO:
|
||||
- `LiquidCrystal` - LCD display support
|
||||
- `Bounce2` - Button debouncing
|
||||
|
||||
## 🎮 Simulation
|
||||
|
||||
### SimulIDE Integration
|
||||
|
||||
The simulation build creates firmware compatible with SimulIDE:
|
||||
|
||||
1. Build simulation firmware: `./scripts/build.sh firmware-sim`
|
||||
2. Open SimulIDE
|
||||
3. Load your simulation file (`.sim1`)
|
||||
4. Firmware will auto-load from the PlatformIO build output
|
||||
|
||||
## 🚀 Migration from Makefile
|
||||
|
||||
### Old Makefile Commands → New CMake Commands
|
||||
|
||||
| Old Makefile | New CMake | Description |
|
||||
|--------------|-----------|-------------|
|
||||
| `make all` | `./scripts/build.sh` | Full build |
|
||||
| `make build-only` | `./scripts/build.sh build` | Build only |
|
||||
| `make test` | `./scripts/build.sh test` | Run tests |
|
||||
| `make clean` | `./scripts/build.sh clean` | Clean build |
|
||||
| `make build-sim` | `./scripts/build.sh firmware-sim` | Simulation build |
|
||||
| `make build-hw` | `./scripts/build.sh firmware-hw` | Hardware build |
|
||||
| `make upload` | `./scripts/build.sh upload` | Upload to Arduino |
|
||||
| `make format` | `./scripts/build.sh format` | Format code |
|
||||
| `make status` | `./scripts/build.sh status` | Show status |
|
||||
|
||||
### Key Benefits of CMake
|
||||
|
||||
1. **Cross-platform**: Works on macOS, Linux, and Windows
|
||||
2. **IDE integration**: Better support in CLion, VS Code, etc.
|
||||
3. **Presets**: Multiple build configurations without reconfiguration
|
||||
4. **Modular**: Reusable build components
|
||||
5. **Standards**: Follows modern C++ build practices
|
||||
6. **Maintainable**: Easier to extend and modify
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### CMake not found
|
||||
```bash
|
||||
# Install CMake
|
||||
# macOS
|
||||
brew install cmake
|
||||
|
||||
# Ubuntu
|
||||
sudo apt install cmake
|
||||
|
||||
# Windows
|
||||
# Download from cmake.org
|
||||
```
|
||||
|
||||
#### PlatformIO not found
|
||||
```bash
|
||||
# Install PlatformIO
|
||||
pip install platformio
|
||||
```
|
||||
|
||||
#### Build failures
|
||||
```bash
|
||||
# Clean and rebuild
|
||||
./scripts/build.sh clean
|
||||
./scripts/build.sh
|
||||
|
||||
# Check dependencies
|
||||
./scripts/build.sh status
|
||||
```
|
||||
|
||||
### Getting Help
|
||||
|
||||
1. Check the project status: `./scripts/build.sh status`
|
||||
2. Verify dependencies are installed
|
||||
3. Check build logs in the build directory
|
||||
4. Ensure you're using CMake 3.20+
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
3. Make your changes
|
||||
4. Test with: `./scripts/build.sh test`
|
||||
5. Submit a pull request
|
||||
|
||||
## 📄 License
|
||||
|
||||
[Your License Here]
|
||||
|
||||
## 🙏 Acknowledgments
|
||||
|
||||
- **Luke** - Original rocket launcher design
|
||||
- **Arduino community** - Hardware platform
|
||||
- **PlatformIO community** - Arduino development tools
|
||||
- **CMake community** - Build system
|
||||
- **Unity framework** - Testing framework
|
||||
### **Getting Started with Multi-Board** 🎯
|
||||
@@ -1,33 +1,48 @@
|
||||
[platformio]
|
||||
default_envs = simulide
|
||||
; switch this when you want to build others (simulide / uno_hw / native)
|
||||
default_envs = uno_r4_minima
|
||||
|
||||
; ---------------- SimulIDE (AVR sim) ----------------
|
||||
[env:simulide]
|
||||
platform = atmelavr
|
||||
board = uno
|
||||
framework = arduino
|
||||
upload_protocol = custom
|
||||
monitor_speed = 115200
|
||||
lib_deps =
|
||||
arduino-libraries/LiquidCrystal@^1.0.7
|
||||
thomasfredericks/Bounce2@^2.72
|
||||
|
||||
; ---------- macOS ----------
|
||||
; Copies the built HEX to a stable path your .simu references, then opens that .simu
|
||||
upload_protocol = custom
|
||||
upload_command = /bin/sh -lc 'mkdir -p "$PROJECT_DIR/out/simulide" && cp "$PROJECT_BUILD_DIR/$PIOENV/${PROGNAME}.hex" "$PROJECT_DIR/out/simulide/firmware.hex" && /Applications/simulide.app/Contents/MacOS/simulide "../../wiring/rocker_launcher_controls.sim1" &'
|
||||
|
||||
|
||||
; ---------------- Real UNO R3 (AVR) ----------------
|
||||
[env:uno_hw]
|
||||
platform = atmelavr
|
||||
board = uno
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
build_flags = -DARDUINO_ARCH_AVR
|
||||
lib_deps =
|
||||
arduino-libraries/LiquidCrystal@^1.0.7
|
||||
thomasfredericks/Bounce2@^2.72
|
||||
|
||||
; ---------------- UNO R4 Minima (Renesas RA4M1) ----------------
|
||||
[env:uno_r4_minima]
|
||||
platform = renesas-ra
|
||||
board = uno_r4_minima
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
build_flags = -DARDUINO_ARCH_RENESAS
|
||||
lib_deps =
|
||||
arduino-libraries/LiquidCrystal@^1.0.7
|
||||
thomasfredericks/Bounce2@^2.72
|
||||
; If upload has trouble, uncomment and set the exact port:
|
||||
; upload_port = /dev/cu.usbmodemXXXX
|
||||
; board_build.flash_mode can be set if needed, but defaults are fine for R4.
|
||||
|
||||
; ---------------- Native tests ----------------
|
||||
[env:native]
|
||||
platform = native
|
||||
build_flags =
|
||||
build_flags =
|
||||
-std=c++17
|
||||
-Wall -Wextra -Wpedantic
|
||||
-DUNITY_INCLUDE_DOUBLE
|
||||
@@ -37,11 +52,12 @@ build_flags =
|
||||
test_framework = unity
|
||||
test_build_src = yes
|
||||
test_filter = test_*
|
||||
test_ignore =
|
||||
test_ignore =
|
||||
test_manual_*
|
||||
test_integration_*
|
||||
build_src_filter =
|
||||
build_src_filter =
|
||||
-<main.cpp>
|
||||
+<ArduinoInterface.h>
|
||||
+<RocketController.h>
|
||||
+<RocketController.cpp>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 🚀 Luke's Rocket Launch Controller - CMake Build Script
|
||||
# Modern build system for Arduino-based rocket launcher with PlatformIO integration
|
||||
# 🚀 Luke's Rocket Launch Controller - CMake + PlatformIO Build Script
|
||||
# Now supports Arduino UNO R3, UNO R4 Minima, and SimulIDE with interactive board selection.
|
||||
|
||||
set -e
|
||||
|
||||
@@ -16,44 +16,230 @@ NC='\033[0m' # No Color
|
||||
PROJECT_NAME="RocketLauncher"
|
||||
BUILD_DIR="build"
|
||||
DEFAULT_PRESET="default"
|
||||
CONFIG_FILE=".board-config"
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${GREEN}🔧 $1${NC}"
|
||||
# Supported board environments
|
||||
SUPPORTED_BOARDS=("uno_hw" "uno_r4_minima" "simulide")
|
||||
BOARD_NAMES=("Arduino UNO R3" "Arduino UNO R4 Minima" "Simulation Environment")
|
||||
BOARD_DESCRIPTIONS=(
|
||||
"Classic Arduino (ATmega328P) - Proven reliability, wide compatibility"
|
||||
"Modern ARM (Renesas RA4M1) - Enhanced performance, future-proof"
|
||||
"Safe testing without hardware - Fast development cycles"
|
||||
)
|
||||
|
||||
# ----------- Pretty printers -----------
|
||||
print_status() { echo -e "${GREEN}🔧 $1${NC}"; }
|
||||
print_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
|
||||
print_error() { echo -e "${RED}❌ $1${NC}"; }
|
||||
print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
|
||||
print_board() { echo -e "${BLUE}🎯 $1${NC}"; }
|
||||
print_success() { echo -e "${GREEN}✅ $1${NC}"; }
|
||||
|
||||
# ----------- Board Configuration Management -----------
|
||||
get_board_config() {
|
||||
if [[ -f "$CONFIG_FILE" ]]; then
|
||||
cat "$CONFIG_FILE"
|
||||
else
|
||||
echo "uno_r4_minima" # Default board
|
||||
fi
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}⚠️ $1${NC}"
|
||||
set_board_config() {
|
||||
local board=$1
|
||||
echo "$board" > "$CONFIG_FILE"
|
||||
print_success "Board configuration saved: $board"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}❌ $1${NC}"
|
||||
show_board_info() {
|
||||
local board=$(get_board_config)
|
||||
print_board "Current target board: $board"
|
||||
|
||||
case "$board" in
|
||||
"uno_hw")
|
||||
print_info " • Arduino UNO R3 (ATmega328P)"
|
||||
print_info " • Classic Arduino compatibility"
|
||||
print_info " • AVR toolchain"
|
||||
;;
|
||||
"uno_r4_minima")
|
||||
print_info " • Arduino UNO R4 Minima (Renesas RA4M1)"
|
||||
print_info " • Modern 32-bit ARM architecture"
|
||||
print_info " • Renesas toolchain"
|
||||
;;
|
||||
"simulide")
|
||||
print_info " • Simulation environment (AVR)"
|
||||
print_info " • Safe testing without hardware"
|
||||
print_info " • SimulIDE integration"
|
||||
;;
|
||||
*)
|
||||
print_warning " • Unknown board environment"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
print_info() {
|
||||
echo -e "${BLUE}ℹ️ $1${NC}"
|
||||
validate_board() {
|
||||
local board=$1
|
||||
for supported in "${SUPPORTED_BOARDS[@]}"; do
|
||||
if [[ "$board" == "$supported" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Function to show help
|
||||
interactive_board_selection() {
|
||||
local board_param=$1
|
||||
|
||||
# If board parameter is provided, use it directly
|
||||
if [[ -n "$board_param" ]]; then
|
||||
# Check if it's a valid board name
|
||||
if validate_board "$board_param"; then
|
||||
print_success "Selected: $board_param"
|
||||
|
||||
# Save configuration
|
||||
set_board_config "$board_param"
|
||||
|
||||
# Show next steps
|
||||
echo ""
|
||||
print_info "Next steps:"
|
||||
case "$board_param" in
|
||||
"uno_hw"|"uno_r4_minima")
|
||||
echo " • Build firmware: ./scripts/build.sh firmware"
|
||||
echo " • Upload to board: ./scripts/build.sh upload"
|
||||
echo " • Monitor output: ./scripts/build.sh monitor"
|
||||
;;
|
||||
"simulide")
|
||||
echo " • Launch simulator: ./scripts/build.sh sim"
|
||||
echo " • Build simulation: ./scripts/build.sh firmware"
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
else
|
||||
print_error "Invalid board: $board_param"
|
||||
print_info "Available boards:"
|
||||
list_supported_boards
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Interactive selection (original behavior)
|
||||
print_status "Board Selection"
|
||||
echo ""
|
||||
print_info "Please select your target board:"
|
||||
echo ""
|
||||
|
||||
for i in "${!SUPPORTED_BOARDS[@]}"; do
|
||||
local board="${SUPPORTED_BOARDS[$i]}"
|
||||
local name="${BOARD_NAMES[$i]}"
|
||||
local desc="${BOARD_DESCRIPTIONS[$i]}"
|
||||
echo -e "${GREEN}[$((i+1))]${NC} $board - $name"
|
||||
echo " $desc"
|
||||
echo ""
|
||||
done
|
||||
|
||||
local current_board=$(get_board_config)
|
||||
local current_index=0
|
||||
|
||||
# Find current board index
|
||||
for i in "${!SUPPORTED_BOARDS[@]}"; do
|
||||
if [[ "${SUPPORTED_BOARDS[$i]}" == "$current_board" ]]; then
|
||||
current_index=$((i+1))
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $current_index -gt 0 ]]; then
|
||||
echo -e "${BLUE}Current selection: [$current_index] $current_board${NC}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Get user input
|
||||
local choice
|
||||
while true; do
|
||||
read -p "Enter your choice (1-${#SUPPORTED_BOARDS[@]}): " choice
|
||||
|
||||
if [[ "$choice" =~ ^[1-9]$ ]] && [[ "$choice" -le "${#SUPPORTED_BOARDS[@]}" ]]; then
|
||||
local selected_board="${SUPPORTED_BOARDS[$((choice-1))]}"
|
||||
print_success "Selected: $selected_board"
|
||||
|
||||
# Save configuration
|
||||
set_board_config "$selected_board"
|
||||
|
||||
# Show next steps
|
||||
echo ""
|
||||
print_info "Next steps:"
|
||||
case "$selected_board" in
|
||||
"uno_hw"|"uno_r4_minima")
|
||||
echo " • Build firmware: ./scripts/build.sh firmware"
|
||||
echo " • Upload to board: ./scripts/build.sh upload"
|
||||
echo " • Monitor output: ./scripts/build.sh monitor"
|
||||
;;
|
||||
"simulide")
|
||||
echo " • Launch simulator: ./scripts/build.sh sim"
|
||||
echo " • Build simulation: ./scripts/build.sh firmware"
|
||||
;;
|
||||
esac
|
||||
break
|
||||
else
|
||||
print_error "Invalid choice. Please enter a number between 1 and ${#SUPPORTED_BOARDS[@]}."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
list_supported_boards() {
|
||||
print_info "Available board environments:"
|
||||
echo ""
|
||||
for i in "${!SUPPORTED_BOARDS[@]}"; do
|
||||
local board="${SUPPORTED_BOARDS[$i]}"
|
||||
local name="${BOARD_NAMES[$i]}"
|
||||
local desc="${BOARD_DESCRIPTIONS[$i]}"
|
||||
local current=""
|
||||
|
||||
if [[ "$board" == "$(get_board_config)" ]]; then
|
||||
current=" (current)"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}• $board$current${NC}"
|
||||
echo " $name"
|
||||
echo " $desc"
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo -e "${BLUE}Usage examples:${NC}"
|
||||
echo " ./scripts/build.sh firmware # Build for current board"
|
||||
echo " ./scripts/build.sh upload # Upload to current board"
|
||||
echo " ./scripts/build.sh monitor # Monitor current board"
|
||||
echo " ./scripts/build.sh sim # Launch simulator (if simulation board)"
|
||||
}
|
||||
|
||||
# ----------- Help -----------
|
||||
show_help() {
|
||||
echo -e "${GREEN}🚀 Luke's Rocket Launch Controller - Build System${NC}"
|
||||
echo ""
|
||||
echo -e "${BLUE}Multi-Board Support:${NC}"
|
||||
show_board_info
|
||||
echo ""
|
||||
echo -e "${BLUE}Board Management:${NC}"
|
||||
echo " ./scripts/build.sh configure # Configure project and select board"
|
||||
echo " ./scripts/build.sh boards # List supported boards"
|
||||
echo " ./scripts/build.sh board # Change board selection"
|
||||
echo " ./scripts/build.sh board uno_r4_minima # Select board by name"
|
||||
echo ""
|
||||
echo -e "${BLUE}Available commands:${NC}"
|
||||
echo " build.sh # Configure and build everything (default)"
|
||||
echo " build.sh configure # Configure CMake project"
|
||||
echo " build.sh # Configure + build + tests (default)"
|
||||
echo " build.sh configure # Configure CMake project and select board"
|
||||
echo " build.sh board # Change board selection"
|
||||
echo " build.sh build # Build project"
|
||||
echo " build.sh test # Run tests"
|
||||
echo " build.sh clean # Clean build files"
|
||||
echo " build.sh format # Format source code"
|
||||
echo " build.sh status # Show project status"
|
||||
echo " build.sh boards # List supported boards"
|
||||
echo ""
|
||||
echo -e "${BLUE}CMake targets (what CLion sees):${NC}"
|
||||
echo " build.sh firmware-sim # Build simulation firmware"
|
||||
echo " build.sh firmware-hw # Build hardware firmware"
|
||||
echo " build.sh all-firmware # Build both firmwares"
|
||||
echo " build.sh sim # Build and launch simulator"
|
||||
echo " build.sh upload # Upload to Arduino"
|
||||
echo " build.sh monitor # Start serial monitor"
|
||||
echo -e "${BLUE}Firmware & tooling:${NC}"
|
||||
echo " build.sh firmware # Build firmware for current board"
|
||||
echo " build.sh sim # Build + launch SimulIDE (if simulation board)"
|
||||
echo " build.sh upload # Upload to current board"
|
||||
echo " build.sh monitor # Open serial monitor for current board"
|
||||
echo " build.sh pio-clean # Clean PlatformIO files"
|
||||
echo ""
|
||||
echo -e "${BLUE}Build presets:${NC}"
|
||||
@@ -63,155 +249,432 @@ show_help() {
|
||||
echo " minimal # Minimal build (no tests, no PlatformIO)"
|
||||
echo ""
|
||||
echo -e "${BLUE}Examples:${NC}"
|
||||
echo " ./scripts/build.sh # Full build"
|
||||
echo " ./scripts/build.sh firmware-sim # Build simulation firmware"
|
||||
echo " ./scripts/build.sh sim # Build and launch simulator"
|
||||
echo " ./scripts/build.sh --preset release # Release build"
|
||||
echo " ./scripts/build.sh"
|
||||
echo " ./scripts/build.sh firmware"
|
||||
echo " ./scripts/build.sh sim"
|
||||
echo " ./scripts/build.sh --preset release"
|
||||
echo " ./scripts/build.sh upload"
|
||||
echo " ./scripts/build.sh monitor"
|
||||
echo ""
|
||||
echo -e "${BLUE}Board-specific examples:${NC}"
|
||||
echo " # After selecting board with ./scripts/build.sh configure:"
|
||||
echo " ./scripts/build.sh firmware # Builds for selected board"
|
||||
echo " ./scripts/build.sh upload # Uploads to selected board"
|
||||
echo " ./scripts/build.sh monitor # Monitors selected board"
|
||||
}
|
||||
|
||||
# Function to check dependencies
|
||||
# ----------- Dependency checks -----------
|
||||
check_dependencies() {
|
||||
print_status "Checking dependencies..."
|
||||
|
||||
|
||||
if ! command -v cmake &> /dev/null; then
|
||||
print_error "CMake not found. Please install CMake 3.20 or later."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if ! command -v make &> /dev/null; then
|
||||
print_error "Make not found. Please install Make."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for PlatformIO
|
||||
|
||||
if ! command -v pio &> /dev/null; then
|
||||
print_warning "PlatformIO not found. Arduino builds will not work."
|
||||
print_warning "PlatformIO not found. Arduino builds/uploads will not work."
|
||||
print_info "Install with: pip install platformio"
|
||||
print_info "Or use: ./scripts/build.sh --preset tests-only"
|
||||
else
|
||||
print_status "PlatformIO found"
|
||||
|
||||
# Validate current board selection
|
||||
local current_board=$(get_board_config)
|
||||
if ! validate_board "$current_board"; then
|
||||
print_error "Invalid board configuration: $current_board"
|
||||
print_info "Please run: ./scripts/build.sh configure"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Auto-install renesas-ra if targeting UNO R4 envs
|
||||
if [[ "$current_board" == "uno_r4_minima" || "$current_board" == "uno_r4_wifi" ]]; then
|
||||
if ! pio platform show renesas-ra &>/dev/null; then
|
||||
print_info "Installing PlatformIO renesas-ra toolchain for UNO R4..."
|
||||
pio platform install renesas-ra || {
|
||||
print_error "Failed to install renesas-ra platform"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Auto-install atmelavr if targeting UNO R3 envs
|
||||
if [[ "$current_board" == "uno_hw" || "$current_board" == "simulide" ]]; then
|
||||
if ! pio platform show atmelavr &>/dev/null; then
|
||||
print_info "Installing PlatformIO atmelavr toolchain for UNO R3..."
|
||||
pio platform install atmelavr || {
|
||||
print_error "Failed to install atmelavr platform"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
print_status "Dependencies check complete"
|
||||
}
|
||||
|
||||
# Function to configure project
|
||||
# ----------- Presets / build -----------
|
||||
configure_project() {
|
||||
local preset=${1:-$DEFAULT_PRESET}
|
||||
print_status "Configuring project with preset: $preset"
|
||||
|
||||
|
||||
# Check if board is configured
|
||||
if [[ ! -f "$CONFIG_FILE" ]]; then
|
||||
print_info "No board configuration found. Starting board selection..."
|
||||
interactive_board_selection
|
||||
fi
|
||||
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
cmake --preset "$preset" ..
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_status "Configuration successful"
|
||||
else
|
||||
print_error "Configuration failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_status "Configuration successful"
|
||||
cd ..
|
||||
}
|
||||
|
||||
# Function to build project
|
||||
build_project() {
|
||||
local preset=${1:-$DEFAULT_PRESET}
|
||||
print_status "Building project with preset: $preset"
|
||||
|
||||
|
||||
if [ ! -d "$BUILD_DIR" ]; then
|
||||
print_warning "Build directory not found. Running configure first..."
|
||||
configure_project "$preset"
|
||||
fi
|
||||
|
||||
|
||||
cd "$BUILD_DIR"
|
||||
# Build without preset since we're already in the configured build directory
|
||||
cmake --build .
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_status "Build successful"
|
||||
print_info "Output files in: $BUILD_DIR"
|
||||
else
|
||||
print_error "Build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_status "Build successful"
|
||||
print_info "Output files in: $BUILD_DIR"
|
||||
cd ..
|
||||
}
|
||||
|
||||
# Function to run tests
|
||||
run_tests() {
|
||||
print_status "Running tests..."
|
||||
|
||||
|
||||
if [ ! -d "$BUILD_DIR" ]; then
|
||||
print_warning "Build directory not found. Running configure first..."
|
||||
configure_project
|
||||
fi
|
||||
|
||||
|
||||
cd "$BUILD_DIR"
|
||||
# Run tests without preset since we're already in the configured build directory
|
||||
ctest --output-on-failure
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_status "Tests completed successfully"
|
||||
else
|
||||
print_error "Tests failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_status "Tests completed successfully"
|
||||
cd ..
|
||||
}
|
||||
|
||||
# Function to clean build files
|
||||
clean_build() {
|
||||
print_status "Cleaning build files..."
|
||||
|
||||
|
||||
if [ -d "$BUILD_DIR" ]; then
|
||||
rm -rf "$BUILD_DIR"
|
||||
print_status "Build directory removed"
|
||||
fi
|
||||
|
||||
# Clean other build directories
|
||||
|
||||
for dir in build-*; do
|
||||
if [ -d "$dir" ]; then
|
||||
rm -rf "$dir"
|
||||
print_status "Removed $dir"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
print_status "Clean complete"
|
||||
}
|
||||
|
||||
# Function to build specific CMake targets
|
||||
build_target() {
|
||||
local target=$1
|
||||
local description=$2
|
||||
|
||||
print_status "$description"
|
||||
|
||||
if [ ! -d "$BUILD_DIR" ]; then
|
||||
print_warning "Build directory not found. Running configure first..."
|
||||
configure_project
|
||||
fi
|
||||
|
||||
cd "$BUILD_DIR"
|
||||
cmake --build . --target "$target"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_status "Target '$target' built successfully"
|
||||
|
||||
|
||||
# ----------- Status -----------
|
||||
show_status() {
|
||||
print_status "Project Status"
|
||||
print_info "Project: $PROJECT_NAME"
|
||||
print_info "Build directory: $BUILD_DIR"
|
||||
print_info "Source directory: $(pwd)"
|
||||
|
||||
if [ -d "$BUILD_DIR" ]; then
|
||||
print_info "✅ Build directory exists"
|
||||
if [ -f "$BUILD_DIR/rocket_tests" ]; then
|
||||
print_info "✅ Test executable exists"
|
||||
fi
|
||||
else
|
||||
print_error "Target '$target' build failed"
|
||||
print_warning "❌ Build directory missing"
|
||||
fi
|
||||
|
||||
if command -v pio &> /dev/null; then
|
||||
print_info "✅ PlatformIO found"
|
||||
if [ -f "platformio.ini" ]; then
|
||||
print_info "✅ PlatformIO project configuration found"
|
||||
else
|
||||
print_warning "⚠️ PlatformIO project configuration not found"
|
||||
fi
|
||||
|
||||
# Show current board information
|
||||
echo ""
|
||||
show_board_info
|
||||
|
||||
# Show available platforms
|
||||
echo ""
|
||||
print_info "Installed PlatformIO platforms:"
|
||||
if pio platform show atmelavr &>/dev/null; then
|
||||
print_info " ✅ atmelavr (for UNO R3 and simulation)"
|
||||
else
|
||||
print_warning " ❌ atmelavr (required for UNO R3 and simulation)"
|
||||
fi
|
||||
|
||||
if pio platform show renesas-ra &>/dev/null; then
|
||||
print_info " ✅ renesas-ra (for UNO R4 Minima)"
|
||||
else
|
||||
print_warning " ❌ renesas-ra (required for UNO R4 Minima)"
|
||||
fi
|
||||
|
||||
# Show available devices
|
||||
echo ""
|
||||
print_info "Available devices:"
|
||||
if pio device list &>/dev/null; then
|
||||
pio device list --serial | head -10
|
||||
else
|
||||
print_warning "No devices found"
|
||||
fi
|
||||
else
|
||||
print_warning "❌ PlatformIO not found"
|
||||
fi
|
||||
}
|
||||
|
||||
# ----------- Main -----------
|
||||
main() {
|
||||
local command=${1:-"all"}
|
||||
local preset=${2:-$DEFAULT_PRESET}
|
||||
|
||||
case $command in
|
||||
"help"|"-h"|"--help") show_help ;;
|
||||
|
||||
"configure") check_dependencies ; configure_project "$preset" ;;
|
||||
"build") check_dependencies ; build_project "$preset" ;;
|
||||
"test") check_dependencies ; run_tests ;;
|
||||
"clean") clean_build ;;
|
||||
"format") format_code ;;
|
||||
"status") show_status ;;
|
||||
"boards") list_supported_boards ;;
|
||||
"board") interactive_board_selection "$2" ;;
|
||||
|
||||
"firmware") check_dependencies ; pio_build_firmware ;;
|
||||
"sim") launch_simulator ;;
|
||||
|
||||
"upload") check_dependencies ; pio_upload ;;
|
||||
"monitor") check_dependencies ; pio_monitor ;;
|
||||
"pio-clean") check_dependencies ; pio_clean ;;
|
||||
|
||||
"all") check_dependencies ; configure_project "$preset" ; build_project "$preset" ; run_tests ;;
|
||||
*) print_error "Unknown command: $command" ; show_help ; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ----------- PlatformIO helpers (Multi-board safe) -----------
|
||||
resolve_pio_env() {
|
||||
local env_name=$(get_board_config)
|
||||
|
||||
# Validate the environment
|
||||
if ! validate_board "$env_name"; then
|
||||
print_error "Invalid board configuration: $env_name"
|
||||
list_supported_boards
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ..
|
||||
echo "$env_name"
|
||||
}
|
||||
|
||||
# Function to format code
|
||||
detect_port() {
|
||||
# Prefer PlatformIO's device listing (portable across OSes)
|
||||
local port
|
||||
port=$(pio device list --serial | awk -F': ' '/Port: /{print $2}' | head -n1)
|
||||
echo "$port"
|
||||
}
|
||||
|
||||
pio_build_firmware() {
|
||||
if ! command -v pio &> /dev/null; then
|
||||
print_error "PlatformIO is required for firmware building"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local env_name
|
||||
env_name="$(resolve_pio_env)"
|
||||
print_status "Building firmware with PlatformIO (env: $env_name)"
|
||||
|
||||
# Show board info before build
|
||||
show_board_info
|
||||
|
||||
# Build the firmware
|
||||
pio run -e "$env_name"
|
||||
|
||||
print_success "Firmware built successfully for $env_name"
|
||||
}
|
||||
|
||||
pio_upload() {
|
||||
if ! command -v pio &> /dev/null; then
|
||||
print_error "PlatformIO is required for upload"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local env_name
|
||||
env_name="$(resolve_pio_env)"
|
||||
print_status "Uploading with PlatformIO (env: $env_name)"
|
||||
|
||||
# Show board info before upload
|
||||
show_board_info
|
||||
|
||||
local port
|
||||
port="$(detect_port)"
|
||||
if [[ -n "$port" ]]; then
|
||||
print_info "Using serial port: $port"
|
||||
pio run -t upload -e "$env_name" --upload-port "$port"
|
||||
else
|
||||
print_warning "No serial port detected, attempting auto-detect..."
|
||||
pio run -t upload -e "$env_name"
|
||||
fi
|
||||
}
|
||||
|
||||
pio_monitor() {
|
||||
if ! command -v pio &> /dev/null; then
|
||||
print_error "PlatformIO is required for monitor"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local env_name baud port
|
||||
env_name="$(resolve_pio_env)"
|
||||
baud="115200"
|
||||
port="$(detect_port)"
|
||||
|
||||
# Show board info before monitor
|
||||
show_board_info
|
||||
|
||||
if [[ -n "$port" ]]; then
|
||||
print_status "Opening serial monitor @ ${baud} on ${port} (env: $env_name)"
|
||||
pio device monitor --baud "$baud" --port "$port"
|
||||
else
|
||||
print_status "Opening serial monitor @ ${baud} (env: $env_name)"
|
||||
print_warning "No specific port detected, using environment default"
|
||||
pio device monitor --baud "$baud" -e "$env_name"
|
||||
fi
|
||||
}
|
||||
|
||||
pio_clean() {
|
||||
if ! command -v pio &> /dev/null; then
|
||||
print_error "PlatformIO is required for cleaning"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local env_name
|
||||
env_name="$(resolve_pio_env)"
|
||||
print_status "Cleaning PlatformIO files (env: $env_name)"
|
||||
|
||||
# Show board info before clean
|
||||
show_board_info
|
||||
|
||||
# Clean the environment
|
||||
pio run -t clean -e "$env_name"
|
||||
|
||||
print_success "PlatformIO files cleaned for $env_name"
|
||||
}
|
||||
|
||||
# ----------- SimulIDE flow (Multi-board aware) -----------
|
||||
launch_simulator() {
|
||||
print_status "Building and launching simulator..."
|
||||
|
||||
# Ensure we're using the simulation environment
|
||||
local current_board=$(get_board_config)
|
||||
if [[ "$current_board" != "simulide" ]]; then
|
||||
print_warning "Current board is $current_board, but simulation requires 'simulide' environment"
|
||||
print_info "Switching to simulation environment for this operation..."
|
||||
set_board_config "simulide"
|
||||
fi
|
||||
|
||||
if ! command -v pio &> /dev/null; then
|
||||
print_error "PlatformIO not found. Cannot build simulation firmware."
|
||||
print_info "Install with: pip install platformio"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_info "Building simulation firmware..."
|
||||
pio run -e simulide
|
||||
|
||||
print_status "Simulation firmware built successfully"
|
||||
|
||||
BUILD_FIRMWARE_PATH=".pio/build/simulide/firmware.hex"
|
||||
EXPECTED_FIRMWARE_PATH="out/simulide/firmware.hex"
|
||||
|
||||
if [[ ! -f "$BUILD_FIRMWARE_PATH" ]]; then
|
||||
print_error "Firmware file not found at build path: $BUILD_FIRMWARE_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_info "Copying firmware to expected location..."
|
||||
mkdir -p "out/simulide"
|
||||
cp "$BUILD_FIRMWARE_PATH" "$EXPECTED_FIRMWARE_PATH"
|
||||
|
||||
print_status "Firmware ready at: $EXPECTED_FIRMWARE_PATH"
|
||||
|
||||
SIMULIDE_PATH=""
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
if [[ -d "/Applications/simulide.app" ]]; then
|
||||
SIMULIDE_PATH="/Applications/simulide.app/Contents/MacOS/simulide"
|
||||
elif [[ -d "$HOME/Applications/simulide.app" ]]; then
|
||||
SIMULIDE_PATH="$HOME/Applications/simulide.app/Contents/MacOS/simulide"
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
if command -v simulide &> /dev/null; then
|
||||
SIMULIDE_PATH="simulide"
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
|
||||
if command -v simulide.exe &> /dev/null; then
|
||||
SIMULIDE_PATH="simulide.exe"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$SIMULIDE_PATH" ]]; then
|
||||
print_status "Launching SimulIDE..."
|
||||
WIRING_FILE="../../wiring/rocker_launcher_controls.sim1"
|
||||
if [[ ! -f "$WIRING_FILE" ]]; then
|
||||
print_warning "Default wiring file not found, looking for alternatives..."
|
||||
ALTERNATIVE_WIRING=$(find "../../wiring" -name "*.sim1" | head -1)
|
||||
if [[ -n "$ALTERNATIVE_WIRING" ]]; then
|
||||
WIRING_FILE="$ALTERNATIVE_WIRING"
|
||||
print_info "Using alternative wiring file: $WIRING_FILE"
|
||||
else
|
||||
print_warning "No wiring files found, launching SimulIDE without wiring file"
|
||||
WIRING_FILE=""
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$WIRING_FILE" ]]; then
|
||||
print_info "Loading wiring file: $WIRING_FILE"
|
||||
"$SIMULIDE_PATH" "$WIRING_FILE" &
|
||||
else
|
||||
print_info "Launching SimulIDE without wiring file..."
|
||||
"$SIMULIDE_PATH" &
|
||||
fi
|
||||
|
||||
print_status "SimulIDE launched successfully!"
|
||||
print_info "💡 Tips:"
|
||||
print_info " • The firmware will auto-load in SimulIDE"
|
||||
print_info " • Make changes and re-run: ./scripts/build.sh sim"
|
||||
print_info " • Check SimulIDE console for runtime errors"
|
||||
print_info " • Use ./scripts/build.sh board to change board selection"
|
||||
else
|
||||
print_warning "SimulIDE not found - firmware built but not launched"
|
||||
print_info "📋 Manual Launch:"
|
||||
print_info "1. Open SimulIDE"
|
||||
print_info "2. Load: ../../wiring/rocker_launcher_controls.sim1"
|
||||
print_info "3. Firmware: $EXPECTED_FIRMWARE_PATH"
|
||||
fi
|
||||
|
||||
print_status "Simulator setup complete!"
|
||||
}
|
||||
|
||||
# ----------- Optional: code formatter -----------
|
||||
format_code() {
|
||||
print_status "Formatting source code..."
|
||||
|
||||
if command -v clang-format &> /dev/null; then
|
||||
find src/ -name "*.cpp" -o -name "*.h" | xargs clang-format -i
|
||||
print_status "Code formatting complete"
|
||||
@@ -222,221 +685,7 @@ format_code() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to build and launch simulator
|
||||
launch_simulator() {
|
||||
print_status "Building and launching simulator..."
|
||||
|
||||
# Check if PlatformIO is available
|
||||
if ! command -v pio &> /dev/null; then
|
||||
print_error "PlatformIO not found. Cannot build simulator firmware."
|
||||
print_info "Install with: pip install platformio"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build simulation firmware
|
||||
print_info "Building simulation firmware..."
|
||||
pio run -e simulide
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
print_error "Failed to build simulation firmware"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_status "Simulation firmware built successfully"
|
||||
|
||||
# Check if firmware was created and copy to expected location
|
||||
BUILD_FIRMWARE_PATH=".pio/build/simulide/firmware.hex"
|
||||
EXPECTED_FIRMWARE_PATH="out/simulide/firmware.hex"
|
||||
|
||||
if [[ ! -f "$BUILD_FIRMWARE_PATH" ]]; then
|
||||
print_error "Firmware file not found at build path: $BUILD_FIRMWARE_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create output directory and copy firmware (same as PlatformIO upload_command)
|
||||
print_info "Copying firmware to expected location..."
|
||||
mkdir -p "out/simulide"
|
||||
cp "$BUILD_FIRMWARE_PATH" "$EXPECTED_FIRMWARE_PATH"
|
||||
|
||||
if [[ ! -f "$EXPECTED_FIRMWARE_PATH" ]]; then
|
||||
print_error "Failed to copy firmware to expected location"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_status "Firmware ready at: $EXPECTED_FIRMWARE_PATH"
|
||||
|
||||
# Check if SimulIDE is installed and launch it
|
||||
SIMULIDE_PATH=""
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS
|
||||
if [[ -d "/Applications/simulide.app" ]]; then
|
||||
SIMULIDE_PATH="/Applications/simulide.app/Contents/MacOS/simulide"
|
||||
elif [[ -d "$HOME/Applications/simulide.app" ]]; then
|
||||
SIMULIDE_PATH="$HOME/Applications/simulide.app/Contents/MacOS/simulide"
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# Linux
|
||||
if command -v simulide &> /dev/null; then
|
||||
SIMULIDE_PATH="simulide"
|
||||
fi
|
||||
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
|
||||
# Windows
|
||||
if command -v simulide.exe &> /dev/null; then
|
||||
SIMULIDE_PATH="simulide.exe"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$SIMULIDE_PATH" ]]; then
|
||||
print_status "Launching SimulIDE..."
|
||||
|
||||
# Choose the wiring file to use
|
||||
WIRING_FILE="../../wiring/rocker_launcher_controls.sim1"
|
||||
if [[ ! -f "$WIRING_FILE" ]]; then
|
||||
print_warning "Default wiring file not found, looking for alternatives..."
|
||||
|
||||
# Find any .sim1 file
|
||||
ALTERNATIVE_WIRING=$(find "../../wiring" -name "*.sim1" | head -1)
|
||||
if [[ -n "$ALTERNATIVE_WIRING" ]]; then
|
||||
WIRING_FILE="$ALTERNATIVE_WIRING"
|
||||
print_info "Using alternative wiring file: $WIRING_FILE"
|
||||
else
|
||||
print_warning "No wiring files found, launching SimulIDE without wiring file"
|
||||
WIRING_FILE=""
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$WIRING_FILE" ]]; then
|
||||
print_info "Loading wiring file: $WIRING_FILE"
|
||||
"$SIMULIDE_PATH" "$WIRING_FILE" &
|
||||
else
|
||||
print_info "Launching SimulIDE without wiring file..."
|
||||
"$SIMULIDE_PATH" &
|
||||
fi
|
||||
|
||||
print_status "SimulIDE launched successfully!"
|
||||
print_info "💡 Development Tips:"
|
||||
print_info " • The firmware will auto-load in SimulIDE"
|
||||
print_info " • Make changes to your code and re-run: ./scripts/build.sh sim"
|
||||
print_info " • Check SimulIDE console for any runtime errors"
|
||||
else
|
||||
print_warning "SimulIDE not found - firmware built but not launched"
|
||||
print_info "📋 Manual Launch Instructions:"
|
||||
print_info "1. Open SimulIDE manually"
|
||||
print_info "2. Load the wiring file: ../../wiring/rocker_launcher_controls.sim1"
|
||||
print_info "3. The firmware will auto-load from: $EXPECTED_FIRMWARE_PATH"
|
||||
print_info ""
|
||||
print_info "Install SimulIDE from: https://www.simulide.com/"
|
||||
fi
|
||||
|
||||
print_status "Simulator setup complete!"
|
||||
}
|
||||
|
||||
# Function to show status
|
||||
show_status() {
|
||||
print_status "Project Status"
|
||||
print_info "Project: $PROJECT_NAME"
|
||||
print_info "Build directory: $BUILD_DIR"
|
||||
print_info "Source directory: $(pwd)"
|
||||
|
||||
if [ -d "$BUILD_DIR" ]; then
|
||||
print_info "✅ Build directory exists"
|
||||
|
||||
# Check for test executable
|
||||
if [ -f "$BUILD_DIR/rocket_tests" ]; then
|
||||
print_info "✅ Test executable exists"
|
||||
fi
|
||||
else
|
||||
print_warning "❌ Build directory missing"
|
||||
fi
|
||||
|
||||
# Check PlatformIO status
|
||||
if command -v pio &> /dev/null; then
|
||||
print_info "✅ PlatformIO found"
|
||||
|
||||
# Check PlatformIO project
|
||||
if [ -f "platformio.ini" ]; then
|
||||
print_info "✅ PlatformIO project configuration found"
|
||||
else
|
||||
print_warning "⚠️ PlatformIO project configuration not found"
|
||||
fi
|
||||
else
|
||||
print_warning "❌ PlatformIO not found"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main script logic
|
||||
main() {
|
||||
local command=${1:-"all"}
|
||||
local preset=${2:-$DEFAULT_PRESET}
|
||||
|
||||
case $command in
|
||||
"help"|"-h"|"--help")
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
"configure")
|
||||
check_dependencies
|
||||
configure_project "$preset"
|
||||
;;
|
||||
"build")
|
||||
check_dependencies
|
||||
build_project "$preset"
|
||||
;;
|
||||
"test")
|
||||
check_dependencies
|
||||
run_tests
|
||||
;;
|
||||
"clean")
|
||||
clean_build
|
||||
;;
|
||||
"format")
|
||||
format_code
|
||||
;;
|
||||
"status")
|
||||
show_status
|
||||
;;
|
||||
"firmware-sim")
|
||||
check_dependencies
|
||||
build_target "firmware_sim" "Building simulation firmware"
|
||||
;;
|
||||
"firmware-hw")
|
||||
check_dependencies
|
||||
build_target "firmware_hw" "Building hardware firmware"
|
||||
;;
|
||||
"all-firmware")
|
||||
check_dependencies
|
||||
build_target "all_firmware" "Building both firmwares"
|
||||
;;
|
||||
"sim")
|
||||
launch_simulator
|
||||
;;
|
||||
"upload")
|
||||
check_dependencies
|
||||
build_target "upload" "Building and uploading firmware"
|
||||
;;
|
||||
"monitor")
|
||||
check_dependencies
|
||||
build_target "monitor" "Starting serial monitor"
|
||||
;;
|
||||
"pio-clean")
|
||||
check_dependencies
|
||||
build_target "pio_clean" "Cleaning PlatformIO files"
|
||||
;;
|
||||
"all")
|
||||
check_dependencies
|
||||
configure_project "$preset"
|
||||
build_project "$preset"
|
||||
run_tests
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown command: $command"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Handle preset argument
|
||||
# ----------- Preset flag handling -----------
|
||||
if [[ "$1" == "--preset" ]]; then
|
||||
preset="$2"
|
||||
shift 2
|
||||
|
||||
@@ -86,7 +86,13 @@ class RealArduinoInterface : public ArduinoInterface
|
||||
// Pin control
|
||||
void digitalWrite(uint8_t pin, uint8_t state) override
|
||||
{
|
||||
#ifdef ARDUINO_ARCH_RENESAS
|
||||
// UNO R4 Minima uses PinStatus enum
|
||||
::digitalWrite(pin, static_cast<PinStatus>(state));
|
||||
#else
|
||||
// Classic Arduino (AVR) uses uint8_t
|
||||
::digitalWrite(pin, state);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t digitalRead(uint8_t pin) const override
|
||||
@@ -96,7 +102,13 @@ class RealArduinoInterface : public ArduinoInterface
|
||||
|
||||
void pinMode(uint8_t pin, uint8_t mode) override
|
||||
{
|
||||
#ifdef ARDUINO_ARCH_RENESAS
|
||||
// UNO R4 Minima uses PinMode enum
|
||||
::pinMode(pin, static_cast<PinMode>(mode));
|
||||
#else
|
||||
// Classic Arduino (AVR) uses uint8_t
|
||||
::pinMode(pin, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Time functions
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 411 KiB |
Reference in new issue
Block a user