Skip to content

Commit 29ac084

Browse files
committed
ESP32-C6 FTD codebase
1 parent 2aea44a commit 29ac084

21 files changed

Lines changed: 6500 additions & 0 deletions

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ __pycache__/
1414

1515
# Generated tool output
1616
tools/out/
17+
tools/labels
18+
19+
device_manifest.csv
20+
matter-labels.html
1721

1822
# Editor / OS noise
1923
.DS_Store
@@ -22,3 +26,5 @@ tools/out/
2226
*.swp
2327
*.swo
2428
*.log
29+
30+
build

AGENTS.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# AGENTS.md
2+
3+
Shared agent rules live in `agents/shared.md`.
4+
5+
Language-specific agent rules for repo-local tooling live in:
6+
7+
- `agents/python.md`
8+
9+
This repo is mostly ESP-IDF C/C++ in `esp-matter/` plus Python automation in `tools/`.
10+
11+
Before planning validation or final checks:
12+
13+
- Read `agents/shared.md`
14+
- Detect scope you changed
15+
- For `tools/*.py` and `tools/tests/*.py`, read `agents/python.md`
16+
- For native-only work, use repo guidelines below plus component-appropriate build checks
17+
- Do not run TypeScript or ESLint checks for this repo unless new TS/JS files are introduced
18+
- Do not run Python checks for native-only changes
19+
20+
Scope rules:
21+
22+
- Prefer not editing `esp-matter/` directly. It is upstream submodule content.
23+
- If `esp-matter/` needs changes, create a patch file in top-level repo unless user explicitly asks for direct submodule edits.
24+
- Treat `build/` and `tools/out/` as disposable artifacts.
25+
26+
## Project Structure & Module Organization
27+
`esp-matter/` is upstream SDK submodule and main codebase. Core libraries live in `esp-matter/components/`, hardware support in `esp-matter/device_hal/`, and runnable samples in `esp-matter/examples/` such as `light_switch/` and `unit_test_app/`. Repo-local automation lives in `tools/` for manifest generation, factory data, flashing, and printable labels.
28+
29+
## Build, Test, and Development Commands
30+
Initialize dependencies first:
31+
32+
```bash
33+
git submodule update --init --recursive
34+
cd esp-matter && ./install.sh && . ./export.sh
35+
```
36+
37+
Common workflows:
38+
39+
```bash
40+
mkdir -p build/light_switch && cd esp-matter/examples/light_switch && idf.py -B ../../../build/light_switch set-target esp32c6 build
41+
cd esp-matter/examples/light_switch && idf.py -B ../../../build/light_switch -p /dev/ttyUSB0 flash monitor
42+
cd esp-matter && pre-commit run --all-files
43+
mkdir -p build/unit_test_app && cd esp-matter/examples/unit_test_app && idf.py -B ../../../build/unit_test_app -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.qemu" set-target esp32c3 build
44+
cd esp-matter/examples/unit_test_app && pytest pytest_unit_test_app.py --target esp32c3 -m qemu --embedded-services idf,qemu --qemu-extra-args="-global driver=timer.esp32c3.timg,property=wdt_disable,value=true"
45+
python3 tools/run_workflow.py --count 8 --dry-run
46+
```
47+
48+
Create target `build/` directory first if it does not exist, and keep all build output there instead of inside submodule tree. Use `--dry-run` on local tooling before erase/flash operations.
49+
50+
## Coding Style & Naming Conventions
51+
Follow existing `esp-matter` conventions. C and C++ formatting is enforced by `pre-commit` with `astyle_py`; sorted lists are enforced by `keep-sorted`; spelling is checked with `codespell`. Use 4-space indentation in Python, `snake_case` for Python modules and example directories, and keep CMake target names aligned with directory names such as `light_switch`. Do not hand-edit generated files under `esp-matter/components/esp_matter/data_model/generated/`.
52+
53+
## Testing Guidelines
54+
Python test runners are named `pytest_*.py` per `esp-matter/pytest.ini`. Repo-local Python tooling tests live in `tools/tests/`. Component-level C/C++ tests live under `components/*/test/`. For firmware validation, build and run `examples/unit_test_app` on hardware or QEMU. When adding pytest coverage, use explicit markers such as `@pytest.mark.qemu` and target markers like `@pytest.mark.esp32c3`.
55+
56+
## Commit & Pull Request Guidelines
57+
Current history uses short imperative commit subjects, for example `Add project gitignore` and `Add esp-matter submodule`. Keep commit titles concise, scoped, and action-led. Pull requests should state affected example or component, target chip, commands run, and any required setup changes. Include serial logs, screenshots, or generated-label samples when behavior or output changes.
58+
59+
## Security & Configuration Tips
60+
Keep `ESP_MATTER_PATH` and `IDF_PATH` consistent in active shell before building. Do not commit factory binaries, generated onboarding data, certificates, or device-specific outputs from `tools/out/`.

agents/python.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Python Agent Rules
2+
3+
Use for repo-local Python tooling such as:
4+
5+
- `tools/*.py`
6+
- `tools/tests/*.py`
7+
8+
Validation:
9+
10+
- Run focused repo-local tests first:
11+
12+
```bash
13+
python3 -m unittest tools.tests.test_robustness
14+
```
15+
16+
- If only one behavior changed, prefer running or updating targeted test cases over broader firmware workflows.
17+
- Use full provisioning or build flows only when Python change affects command wiring, generated outputs, or flashing behavior end to end.
18+
19+
Factory-data and onboarding notes:
20+
21+
- `tools/generate_factory_data.py` shells into Matter generator `generate_esp32_chip_factory_bin.py`.
22+
- That generator depends on extra CHIP Python packages beyond `esp-matter/requirements.txt`.
23+
- For setup-payload generation, dependency source of truth is:
24+
25+
```text
26+
esp-matter/connectedhomeip/connectedhomeip/scripts/setup/requirements.setuppayload.txt
27+
```
28+
29+
- Missing `python_stdnum` or `stdnum` errors usually mean that requirements file was not installed into active IDF/tool Python env.
30+
- Report missing env deps clearly. Do not pretend repo logic is broken if failure is pure env setup.

agents/shared.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Shared Agent Rules
2+
3+
Apply these rules before validation and before final response.
4+
5+
- Keep scope tight. Change only files required for task.
6+
- Treat `esp-matter/` as upstream submodule. Prefer top-level patch files over direct edits unless user explicitly asks otherwise.
7+
- Ignore generated artifacts in `build/` and `tools/out/`. Do not treat them as source.
8+
- Match validation to changed scope. Small doc-only changes do not need firmware builds.
9+
- If an env or dependency blocker prevents validation, say exactly what is missing and which command failed.
10+
- Prefer focused commands over repo-wide builds when working in `tools/`.
11+
- Do not invent TypeScript workflows for this repo.
12+
- When build logs contain warnings from upstream `esp-matter/` or ESP-IDF, do not claim them fixed unless changed in this repo.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp
2+
--- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp
3+
+++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp
4+
@@ -45,6 +45,7 @@
5+
#include <openthread/srp_client.h>
6+
#endif
7+
8+
+#include <lib/dnssd/Advertiser.h>
9+
#include <lib/core/CHIPEncoding.h>
10+
#include <lib/support/CHIPMemString.h>
11+
#include <lib/support/CodeUtils.h>
12+
@@ -241,6 +242,13 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnPlatformEvent(const
13+
Impl()->UnlockThreadStack();
14+
#endif // CHIP_DETAIL_LOGGING
15+
}
16+
+ else if (event->Type == DeviceEventType::kServerReady)
17+
+ {
18+
+ if (mpConnectCallback != nullptr && Impl()->_IsThreadAttached() && Dnssd::ServiceAdvertiser::Instance().IsInitialized())
19+
+ {
20+
+ _OnThreadAttachFinished();
21+
+ }
22+
+ }
23+
}
24+
25+
template <class ImplClass>
26+
@@ -392,11 +400,19 @@ template <class ImplClass>
27+
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnThreadAttachFinished()
28+
{
29+
- if (mpConnectCallback != nullptr)
30+
+ if (mpConnectCallback == nullptr)
31+
{
32+
- TEMPORARY_RETURN_IGNORED DeviceLayer::SystemLayer().ScheduleLambda([this]() {
33+
- VerifyOrReturn(mpConnectCallback != nullptr);
34+
- mpConnectCallback->OnResult(NetworkCommissioning::Status::kSuccess, CharSpan(), 0);
35+
- mpConnectCallback = nullptr;
36+
- });
37+
+ return;
38+
}
39+
+
40+
+ if (!Dnssd::ServiceAdvertiser::Instance().IsInitialized())
41+
+ {
42+
+ ChipLogProgress(DeviceLayer, "Thread attached, waiting for DNS-SD readiness before reporting connect success");
43+
+ return;
44+
+ }
45+
+
46+
+ TEMPORARY_RETURN_IGNORED DeviceLayer::SystemLayer().ScheduleLambda([this]() {
47+
+ VerifyOrReturn(mpConnectCallback != nullptr);
48+
+ mpConnectCallback->OnResult(NetworkCommissioning::Status::kSuccess, CharSpan(), 0);
49+
+ mpConnectCallback = nullptr;
50+
+ });
51+
}
52+
53+
template <class ImplClass>

0 commit comments

Comments
 (0)