Skip to content

Commit 6931ee4

Browse files
authored
Merge pull request #68 from baba-dev/codex/add-reproducible-dev-environment-setup
Add dev tooling scaffolding and test harnesses
2 parents 0d817ed + 80497a9 commit 6931ee4

35 files changed

Lines changed: 10740 additions & 32 deletions

.devcontainer/devcontainer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
2-
"name": "M5Tab5 - ESP-IDF v5.5",
3-
"build": { "dockerfile": "Dockerfile" },
4-
"containerEnv": { "BASH_ENV": "/etc/profile" },
5-
"postStartCommand": "bash -lc 'idf.py --version || true'",
2+
"name": "M5Tab5 Dev",
3+
"image": "espressif/idf:release-v5.5",
4+
"features": { "ghcr.io/devcontainers/features/git:1": {} },
5+
"containerEnv": { "CCACHE_DIR": "/workspaces/.ccache" },
6+
"mounts": [
7+
"source=${localWorkspaceFolder}/.ccache,target=/workspaces/.ccache,type=bind"
8+
],
9+
"postCreateCommand": "python -m pip install -U pip && pip install -r requirements.txt || true",
610
"customizations": {
711
"vscode": {
8-
"extensions": ["espressif.esp-idf-extension", "ms-vscode.cpptools"]
12+
"extensions": ["ms-vscode.cmake-tools", "ms-vscode.cpptools", "twxs.cmake"]
913
}
1014
}
1115
}

.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Example environment overrides for local tooling
2+
# Copy to .env and adjust as needed.
3+
4+
# Uncomment to force the asset pipeline to refresh goldens.
5+
# UPDATE_GOLDEN=1
6+
7+
# Serial port used for flashing/monitoring.
8+
# ESPPORT=/dev/ttyUSB0

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Critical hardware components require explicit review
2+
components/hal/* @you
3+
custom/platform/* @you

.github/workflows/codeql.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CodeQL
2+
on:
3+
push: { branches: [main] }
4+
pull_request:
5+
schedule: [{cron: '0 3 * * 1'}]
6+
7+
jobs:
8+
analyze:
9+
runs-on: ubuntu-latest
10+
permissions: { security-events: write, contents: read }
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: github/codeql-action/init@v3
14+
with: { languages: 'cpp' }
15+
- uses: github/codeql-action/autobuild@v3
16+
- uses: github/codeql-action/analyze@v3

.github/workflows/host-tests.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16-
# Use system GTest (fast) and tools
16+
# Install build tools and GTest
1717
- name: Install deps
1818
run: |
1919
sudo apt-get update
2020
sudo apt-get install -y ninja-build cmake ccache libgtest-dev
21-
# Build GTest if headers/libs not prebuilt on the runner image
21+
# Build GTest libs (headers are already present)
2222
sudo cmake -S /usr/src/googletest -B /usr/src/googletest/build
2323
sudo cmake --build /usr/src/googletest/build -j
2424
sudo cp -a /usr/src/googletest/build/lib/* /usr/local/lib/
@@ -47,3 +47,6 @@ jobs:
4747

4848
- name: Run tests
4949
run: ctest --test-dir tests/build --output-on-failure --timeout 60
50+
51+
- name: Secret scan
52+
run: ./tools/check_secrets.sh

CONTRIBUTING.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Contributing guide
2+
3+
Thanks for helping improve the Tab5 firmware! This document outlines the
4+
minimum steps required to get a change merged.
5+
6+
## Prerequisites
7+
8+
1. Install the ESP-IDF toolchain (v5.5) or use the provided devcontainer.
9+
2. Install Python dependencies:
10+
```bash
11+
make setup
12+
```
13+
3. Configure Git LFS so binary blobs (fonts, PNGs) stay lightweight:
14+
```bash
15+
git lfs install
16+
```
17+
18+
## Workflow
19+
20+
1. Create a feature branch and make focused commits. Follow Conventional Commit
21+
prefixes (e.g. `feat(core): add foo`).
22+
2. Run the full validation suite before pushing:
23+
```bash
24+
make fmt
25+
make build
26+
make test
27+
./tools/check_secrets.sh
28+
```
29+
3. If you touch firmware components or enable new compiler warnings, also run:
30+
```bash
31+
make tidy
32+
```
33+
4. Document user-visible behaviour in `CHANGELOG.md` and update any relevant
34+
docs in `docs/` or `DOCS/`.
35+
5. For UI tweaks provide screenshots or LVGL snapshot updates.
36+
37+
## Pull requests
38+
39+
- Fill out the PR template, ticking the boxes you exercised locally.
40+
- Reference issues in the footer (`Refs #123`).
41+
- Keep diffs reviewable (prefer < 500 lines changed).
42+
- Ensure CI workflows (`IDF Build`, `Host Tests`, `CodeQL`) are green before
43+
requesting review.

DOCS/FLASH_LAYOUT.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Flash layout
2+
3+
The Tab5 firmware uses the partition table at `platforms/tab5/partitions.csv`:
4+
5+
| Partition | Type | Offset | Size | Notes |
6+
| --------- | ---- | ------- | ---- | ----- |
7+
| `nvs` | data | 0x9000 | 24KB | Non-volatile key/value storage. |
8+
| `phy_init`| data | 0xF000 | 4KB | Wi-Fi PHY calibration data. |
9+
| `factory` | app | 0x10000 | 10MB | Main application image. |
10+
| `human_face_det` | data | auto | 400KB | SPIFFS partition reserved for demo assets. |
11+
| `storage` | data | auto | 2MB | SPIFFS partition that carries generated assets (`custom/assets` + `out/assets`). |
12+
13+
`make assets` produces the runtime blobs in `out/assets/`; the ESP-IDF build
14+
copies them into the `storage` partition via the staging step in
15+
`platforms/tab5/main/CMakeLists.txt`.

DOCS/REPO_MAP.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Repository map
2+
3+
- `platforms/tab5/` – ESP-IDF application for the Tab5 hardware. Contains the
4+
board-specific `main/` component, sdkconfig defaults, partition table, and
5+
audio assets that ship with the firmware image.
6+
- `components/core/` – device-agnostic logic (ring buffer, settings store,
7+
future shared services) that is built both for firmware and host tests.
8+
- `custom/` – application-specific UI, integration layers, and runtime asset
9+
loaders. Files here are shared across hardware and desktop targets.
10+
- `tests/` – host-side unit tests, LVGL snapshot tests, and future firmware
11+
smoke tests. Invoked with `make test`.
12+
- `tools/` – development utilities such as format/lint wrappers and the asset
13+
conversion pipeline.
14+
- `DOCS/` – developer-facing documentation including this map and flash layout
15+
notes.
16+
- `ai/tasks/` – repeatable briefs for automated agents. Copy the template and
17+
fill in the context, goal, and acceptance criteria when scoping new work.

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.PHONY: help setup build test flash monitor fmt tidy assets qemu
2+
IDF_PATH?=/opt/esp/idf
3+
APP_DIR?=platforms/tab5
4+
BUILD_DIR?=$(APP_DIR)/build
5+
6+
help:
7+
@grep -E '^[a-zA-Z_-]+:.*?## ' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-16s\033[0m %s\n", $$1, $$2}'
8+
9+
setup: ## Install git hooks / Python deps
10+
python -m pip install -U pip && pip install -r requirements.txt || true
11+
12+
build: ## Build firmware (esp-idf)
13+
cmake -S $(APP_DIR) -B $(BUILD_DIR) -DIDF_TARGET=esp32p4 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
14+
cmake --build $(BUILD_DIR) -j
15+
16+
test: ## Host/unit tests
17+
cmake -S tests -B tests/build
18+
cmake --build tests/build -j
19+
ctest --test-dir tests/build --output-on-failure
20+
21+
fmt: ## Format source
22+
./tools/run_clang_format.sh
23+
24+
tidy: build ## Static analysis
25+
./tools/run_clang_tidy.sh
26+
27+
assets: ## Convert PNG/JPG → runtime-friendly assets + manifest
28+
python tools/gen_assets.py custom/assets out/assets
29+
30+
flash: build ## Flash device (adjust port)
31+
python $(IDF_PATH)/components/esptool_py/esptool/esptool.py --chip esp32p4 write_flash 0x0 $(BUILD_DIR)/M5Tab5.bin
32+
33+
monitor: ## Serial monitor
34+
miniterm.py /dev/ttyUSB0 115200
35+
36+
qemu: ## QEMU smoke tests placeholder
37+
@echo "QEMU smoke tests are not yet implemented for this project."

TRACEPOINTS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Tracepoints
2+
3+
Use the macros in `components/core/include/app_trace.h` to annotate important
4+
runtime events. Common sections/events:
5+
6+
| Section | Event | Purpose |
7+
| -------- | -------------- | ---------------------------------------- |
8+
| `boot` | `init` | Firmware entry, board bring-up sequence. |
9+
| `ui` | `page_show` | User navigates to a page. |
10+
| `ui` | `asset_fallback` | File-system asset missing, using fallback. |
11+
| `audio` | `play` | Playback triggered (song, chime). |
12+
13+
Add new entries when introducing features so logs remain searchable.

0 commit comments

Comments
 (0)