Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/full-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Full CI Check

on:
push:
branches: [ main, develop, feature/** ]
pull_request:
branches: [ main, develop ]

jobs:
build-and-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: |
~/.platformio
.pio
key: ${{ runner.os }}-pio-${{ hashFiles('**/platformio.ini') }}
restore-keys: |
${{ runner.os }}-pio-

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install platformio

- name: Build firmware
run: pio run --verbose

- name: Run static analysis
run: |
pio check --verbose --fail-on-defect=medium
continue-on-error: true

- name: Generate size report
run: |
echo "## Firmware Size" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
pio run -t size 2>&1 | tee size_report.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

RAM_USAGE=$(grep "RAM:" size_report.txt | awk '{print $2}' || echo "0")
FLASH_USAGE=$(grep "Flash:" size_report.txt | awk '{print $2}' || echo "0")

if [ "$RAM_USAGE" -gt "18000" ]; then
echo "**Warning**: RAM usage is high (${RAM_USAGE}/20480 bytes)" >> $GITHUB_STEP_SUMMARY
fi

if [ "$FLASH_USAGE" -gt "60000" ]; then
echo "**Warning**: Flash usage is high (${FLASH_USAGE}/65536 bytes)" >> $GITHUB_STEP_SUMMARY
fi

- name: Upload firmware artifacts
uses: actions/upload-artifact@v4
with:
name: firmware-${{ github.sha }}
path: |
.pio/build/bluepill_f103c8/firmware.elf
.pio/build/bluepill_f103c8/firmware.bin
.pio/build/bluepill_f103c8/firmware.hex
retention-days: 30

- name: Upload map file
uses: actions/upload-artifact@v4
with:
name: map-file-${{ github.sha }}
path: ./pio/build/bluepill_f103c8/firmware.map
retention-days: 7

- name: Comment PR with build results
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const sizeReport = fs.readFileSync('size_report.txt', 'utf8');

const comment = `## Build Successful

**Firmware Size:**
\`\`\`
${sizeReport}
\`\`\`

Artifacts are available in the workflow run.
`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.pio

# pio generated
.vscode/c_cpp_properties.json
.vscode/launch.json

# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# debug information files
*.dwo

# linter
.cache
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
179 changes: 178 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,178 @@
# embedded-smartPDB
# embedded-smartPDB
> A clean, no-nonsense STM32 project setup using PlatformIO, STM32Cube HAL, and FreeRTOS. Because life's too short for bad embedded setups.

![CI Status](https://github.com/CPRT/embedded-smartPDB/workflows/Full%20CI%20Check/badge.svg)

## What You're Getting

- **STM32F103C8**
- **PlatformIO**
- **STM32Cube HAL**
- **FreeRTOS**

## Quick Start

### 1. Prerequisites

You'll need:
- VS Code
- PlatformIO extension
- ST-Link V2 (or compatible programmer)
- A sense of whismy and adventure

```bash
# if you are on linux you might need this to give permissions to use the USB ports for flashing
sudo usermod -a -G dialout $USER
# Then logout/login
```

### 2. Clone & Setup

```bash
git clone git@github.com:CPRT/embedded-smartPDB.git
cd embedded-smartPDB
code .
```

VS Code will bug you about installing extensions. **Click "Install All"**


### 3. Build It

```bash
pio run
```

If it compiles, you're golden.

### 4. Flash It

```bash
# Upload to board
pio run -t upload

# Watch serial output (optional)
pio device monitor
```

## Project Structure

```
.
├── include/ # Your headers go here
│ ├── FreeRTOSConfig.h # RTOS configuration
│ └── main.h # Main header
├── src/ # Your code lives here
│ ├── main.c # Entry point
│ └── freertos.c # RTOS tasks
├── lib/ # Local libraries
├── platformio.ini # Project config
└── .vscode/ # VS Code goodies
```

## Common Tasks

### Build
```bash
pio run
# Or in VS Code: Ctrl+Shift+B
```

### Upload
```bash
pio run -t upload
```

### Clean Build
```bash
pio run -t clean && pio run
```

### Monitor Serial
```bash
pio device monitor
# Exit with Ctrl+C
```

### Static Analysis
```bash
pio check
```

### Memory Report
```bash
arm-none-eabi-size -A -d .pio/build/bluepill_f103c8/firmware.elf
```


## Adding FreeRTOS Tasks

In `src/freertos.c`:

```c
void MyTask(void *pvParameters) {
while(1) {
// Do stuff
vTaskDelay(pdMS_TO_TICKS(1000)); // Delay 1 second
}
}

// In main()
xTaskCreate(MyTask, "MyTask", 128, NULL, 1, NULL);
vTaskStartScheduler();
```

## Debugging

Got an ST-Link? Time to debug properly.

### Quick Debug
```bash
# In VS Code: F5
# Or: Run → Start Debugging
```

Uses the config in `.vscode/launch.json` (ST-Link by default).

### Manual GDB Session
```bash
# Terminal 1: Start OpenOCD
openocd -f interface/stlink.cfg -f target/stm32f1x.cfg

# Terminal 2: GDB
arm-none-eabi-gdb .pio/build/bluepill_f103c8/firmware.elf
(gdb) target remote :3333
(gdb) monitor reset halt
(gdb) load
(gdb) continue
```

## Resources

### Documentation
- [PlatformIO Docs](https://docs.platformio.org/)
- [STM32F103 Reference Manual](https://www.st.com/resource/en/reference_manual/cd00171190.pdf)
- [FreeRTOS Docs](https://www.freertos.org/Documentation/RTOS_book.html)

### Useful Commands
```bash
# List all tasks
pio run --list-targets

# Verbose build
pio run -v

# Clean everything
rm -rf .pio

# Check library dependencies
pio lib list
```

## Contributing

1. Don't break the build
2. Test your changes
3. Update this README if you add something cool
4. Keep commits atomic and meaningful
Loading
Loading