Skip to content

Commit 2c23f86

Browse files
committed
feat: Phase 0
Repository structure ESP-IDF + CMake Opus build integration Logging framework with timestamps Hardware selection Firmware skeleton Idle audio task
1 parent b9d41dc commit 2c23f86

19 files changed

Lines changed: 1853 additions & 0 deletions

File tree

.clang-format

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# OMI Code Style (based on LLVM with modifications for embedded)
2+
BasedOnStyle: LLVM
3+
4+
# Indentation
5+
IndentWidth: 4
6+
TabWidth: 4
7+
UseTab: Never
8+
IndentCaseLabels: false
9+
10+
# Braces
11+
BreakBeforeBraces: Custom
12+
BraceWrapping:
13+
AfterFunction: true
14+
AfterControlStatement: false
15+
AfterEnum: false
16+
AfterStruct: false
17+
BeforeElse: false
18+
BeforeWhile: false
19+
20+
# Line width
21+
ColumnLimit: 100
22+
23+
# Alignment
24+
AlignConsecutiveMacros: true
25+
AlignConsecutiveDeclarations: false
26+
AlignTrailingComments: true
27+
AlignOperands: true
28+
29+
# Pointer alignment
30+
PointerAlignment: Right
31+
DerivePointerAlignment: false
32+
33+
# Includes
34+
IncludeBlocks: Regroup
35+
IncludeCategories:
36+
- Regex: '^<.*\.h>'
37+
Priority: 1
38+
- Regex: '^"freertos/.*"'
39+
Priority: 2
40+
- Regex: '^"esp_.*"'
41+
Priority: 3
42+
- Regex: '^"driver/.*"'
43+
Priority: 4
44+
- Regex: '^".*"'
45+
Priority: 5
46+
47+
# Sorting
48+
SortIncludes: true
49+
50+
# Spaces
51+
SpaceAfterCStyleCast: false
52+
SpaceBeforeParens: ControlStatements
53+
SpacesInParentheses: false
54+
55+
# Short forms
56+
AllowShortFunctionsOnASingleLine: Empty
57+
AllowShortIfStatementsOnASingleLine: Never
58+
AllowShortLoopsOnASingleLine: false
59+
AllowShortBlocksOnASingleLine: false

.clangd

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CompileFlags:
2+
CompilationDatabase: build/
3+
Remove:
4+
- -fno-tree-switch-conversion
5+
- -mtext-section-literals
6+
- -mlongcalls
7+
- -fstrict-volatile-bitfields
8+
9+
Diagnostics:
10+
UnusedIncludes: Strict
11+
ClangTidy:
12+
Add:
13+
- bugprone-*
14+
- modernize-*
15+
- performance-*
16+
- readability-*
17+
Remove:
18+
- modernize-use-trailing-return-type
19+
- readability-magic-numbers
20+
- readability-identifier-length
21+
22+
InlayHints:
23+
Enabled: true
24+
ParameterNames: true
25+
DeducedTypes: true

.github/workflows/build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# OMI - Open Motorcycle Intercom
2+
# Build verification workflow
3+
#
4+
# Triggers on all branches and pull requests
5+
# Uses ESP-IDF v5.5 Docker image for consistent builds
6+
7+
name: Build
8+
9+
on:
10+
push:
11+
branches: ['**']
12+
pull_request:
13+
branches: ['**']
14+
15+
jobs:
16+
build:
17+
name: Build Firmware
18+
runs-on: ubuntu-latest
19+
20+
container:
21+
image: espressif/idf:v5.5
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Build firmware
28+
shell: bash
29+
run: |
30+
. $IDF_PATH/export.sh
31+
idf.py build
32+
33+
- name: Report build size
34+
shell: bash
35+
run: |
36+
. $IDF_PATH/export.sh
37+
idf.py size
38+
39+
- name: Upload build artifacts
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: firmware
43+
path: |
44+
build/omi.bin
45+
build/omi.elf
46+
build/bootloader/bootloader.bin
47+
build/partition_table/partition-table.bin
48+
retention-days: 7

.gitignore

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# ============================================================================
2+
# ESP-IDF Build Artifacts
3+
# ============================================================================
4+
build/
5+
sdkconfig
6+
sdkconfig.old
7+
dependencies.lock
8+
9+
# Managed components (downloaded by IDF component manager)
10+
managed_components/
11+
12+
# Build output files
13+
*.bin
14+
*.elf
15+
*.map
16+
17+
# ============================================================================
18+
# ESP-IDF Configuration
19+
# ============================================================================
20+
# Keep sdkconfig.defaults (committed)
21+
# Ignore local sdkconfig (generated from defaults + menuconfig)
22+
23+
# ============================================================================
24+
# Editor/IDE
25+
# ============================================================================
26+
.vscode/
27+
.idea/
28+
*.swp
29+
*.swo
30+
*~
31+
.cache/
32+
*.sublime-project
33+
*.sublime-workspace
34+
.project
35+
.cproject
36+
.settings/
37+
38+
# Compilation database (regenerated on build)
39+
compile_commands.json
40+
41+
# clangd cache
42+
.clangd/
43+
44+
# ============================================================================
45+
# Python
46+
# ============================================================================
47+
__pycache__/
48+
*.py[cod]
49+
*$py.class
50+
.venv/
51+
venv/
52+
env/
53+
ENV/
54+
*.egg-info/
55+
dist/
56+
*.egg
57+
58+
# ============================================================================
59+
# macOS
60+
# ============================================================================
61+
.DS_Store
62+
.AppleDouble
63+
.LSOverride
64+
65+
# ============================================================================
66+
# Linux
67+
# ============================================================================
68+
*~
69+
.fuse_hidden*
70+
.directory
71+
.Trash-*
72+
.nfs*
73+
74+
# ============================================================================
75+
# Windows
76+
# ============================================================================
77+
Thumbs.db
78+
Desktop.ini
79+
$RECYCLE.BIN/
80+
81+
# ============================================================================
82+
# Logs and Debug
83+
# ============================================================================
84+
*.log
85+
*.out
86+
esp32_crash.txt
87+
gdb.txt
88+
89+
# ============================================================================
90+
# Hardware Development
91+
# ============================================================================
92+
# KiCad backup files (if hardware design is added)
93+
*.bak
94+
*.bck
95+
*-bak
96+
*-cache.lib
97+
*-rescue.lib
98+
fp-info-cache
99+
100+
# ============================================================================
101+
# Secrets and Credentials
102+
# ============================================================================
103+
# IMPORTANT: Never commit sensitive data
104+
*.key
105+
*.pem
106+
*.crt
107+
credentials.json
108+
secrets.h
109+
secrets.json
110+
.env
111+
.env.local
112+
113+
# ============================================================================
114+
# Testing and Coverage
115+
# ============================================================================
116+
coverage/
117+
*.gcda
118+
*.gcno
119+
*.gcov
120+
test_results/
121+
122+
# ============================================================================
123+
# Documentation Build
124+
# ============================================================================
125+
docs/_build/
126+
docs/.doctrees/
127+
128+
# ============================================================================
129+
# Temporary Files
130+
# ============================================================================
131+
*.tmp
132+
*.temp
133+
*.swp
134+
*.swo
135+
.~lock.*
136+
137+
# ============================================================================
138+
# OMI-Specific
139+
# ============================================================================
140+
# Add project-specific ignores below

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Open Motorcycle Intercom (OMI)
2+
# Root CMakeLists.txt for ESP-IDF
3+
4+
cmake_minimum_required(VERSION 3.16)
5+
6+
# Include component directories
7+
set(EXTRA_COMPONENT_DIRS
8+
${CMAKE_CURRENT_SOURCE_DIR}/components
9+
)
10+
11+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
12+
13+
project(omi)

README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,75 @@ Interoperability is achieved **only through standard Bluetooth audio profiles**.
1919

2020
---
2121

22+
## Quick Start
23+
24+
### Prerequisites
25+
26+
- [ESP-IDF v5.5+](https://docs.espressif.com/projects/esp-idf/en/v5.5/esp32s3/get-started/)
27+
- ESP32-S3-DevKitC-1-N8R8 (must have PSRAM)
28+
- USB-C cable
29+
- [Audio Hardware Wiring Guide](docs/wiring.md)
30+
31+
### Build
32+
33+
```bash
34+
# Activate ESP-IDF environment
35+
source ~/esp/esp-idf/export.sh
36+
37+
# Build firmware
38+
cd omi
39+
idf.py build
40+
```
41+
42+
### Flash
43+
44+
```bash
45+
# Find your serial port
46+
ls /dev/ttyACM* /dev/ttyUSB* 2>/dev/null
47+
48+
# Flash firmware (replace PORT with your device)
49+
idf.py -p /dev/ttyACM0 flash
50+
```
51+
52+
### Monitor Serial Output
53+
54+
```bash
55+
# Option 1: Using idf.py (interactive, requires TTY)
56+
idf.py -p /dev/ttyACM0 monitor
57+
58+
# Option 2: Using stty + cat (non-interactive)
59+
stty -F /dev/ttyACM0 115200 raw -echo && cat /dev/ttyACM0
60+
61+
# Option 3: Flash and monitor combined
62+
idf.py -p /dev/ttyACM0 flash monitor
63+
```
64+
65+
**Exit monitor:** `Ctrl+]`
66+
67+
### Expected Boot Log
68+
69+
```
70+
I (xxx) omi: ========================================
71+
I (xxx) omi: OMI - Open Motorcycle Intercom
72+
I (xxx) omi: Boot time: 0 ms
73+
I (xxx) omi: Opus version: libopus x.x.x
74+
I (xxx) omi: Free heap: 275432 bytes
75+
I (xxx) omi: ========================================
76+
I (xxx) audio: Initializing audio subsystem
77+
I (xxx) audio: Audio task heartbeat: loops=0, encoded=0, decoded=0
78+
```
79+
80+
### Troubleshooting
81+
82+
| Issue | Solution |
83+
|-------|----------|
84+
| Permission denied on serial port | `sudo usermod -a -G dialout $USER` then log out/in |
85+
| Device not found | Use a data cable (not charge-only), try different USB port |
86+
| Garbage characters in monitor | Wrong baud rate, use 115200 |
87+
| PSRAM not detected | Ensure you have the N8R8 variant board |
88+
89+
---
90+
2291
## Why
2392

2493
- Cardo/Sena mesh protocols are proprietary and closed

components/audio/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
idf_component_register(
2+
SRCS "audio.c"
3+
INCLUDE_DIRS "include"
4+
REQUIRES
5+
esp_timer
6+
driver
7+
freertos
8+
log
9+
)

0 commit comments

Comments
 (0)