@protoboardai/ext-esp-idf 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +13 -0
- package/README.md +129 -2
- package/evals/wake-on-fuel-gauge/case.json +56 -0
- package/evals/wake-on-fuel-gauge/seed-firmware.config.ts.txt +16 -0
- package/evals/wake-on-fuel-gauge/solution-firmware.config.ts.txt +18 -0
- package/lib/design.ts +227 -0
- package/lib/pins.ts +19 -0
- package/lib/soc.ts +61 -0
- package/ops/firmware.ts +26 -0
- package/package.json +31 -4
- package/protoboard-extension.json +37 -0
- package/skills/firmware-config-esp-idf/SKILL.md +124 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Protoboard Stack: @protoboardai/ext-esp-idf
|
|
2
|
+
Copyright 2026 Delta Robotics, Inc.
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Delta Robotics, Inc.
|
|
5
|
+
(https://deltaroboticsinc.com).
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License").
|
|
8
|
+
See the LICENSE file in this package for full terms.
|
|
9
|
+
|
|
10
|
+
"Protoboard", the Protoboard logo and the "0" mark are trademarks of
|
|
11
|
+
Delta Robotics, Inc. The License grants no rights to them (section 6);
|
|
12
|
+
see TRADEMARKS.md in the Protoboard Stack repository
|
|
13
|
+
(https://github.com/Delta-Robotics-Inc/protoboard-stack).
|
package/README.md
CHANGED
|
@@ -1,3 +1,130 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @protoboardai/ext-esp-idf
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A provider of the `firmware` capability
|
|
4
|
+
([tool integrations](../../docs/specs/tool-integrations.md)). It turns
|
|
5
|
+
a UHD board whose controller is an ESP32-C3 module into an
|
|
6
|
+
[ESP-IDF](https://docs.espressif.com/projects/esp-idf/) pins and peripherals
|
|
7
|
+
header and `sdkconfig.defaults`. Every setting line cites the UHD facts it
|
|
8
|
+
comes from, in a comment for people and in `firmware.manifest.json` for
|
|
9
|
+
tools. Checked against ESP-IDF **v5.3.5** (Kconfig symbols at the `v5.3.5`
|
|
10
|
+
tag).
|
|
11
|
+
|
|
12
|
+
ESP-IDF configures pins in code (`i2c_new_master_bus`, `gpio_config`,
|
|
13
|
+
`esp_deep_sleep_enable_gpio_wakeup`), not in a devicetree, so the header
|
|
14
|
+
carries the board and `sdkconfig.defaults` only what Kconfig owns.
|
|
15
|
+
|
|
16
|
+
A project selects it for one board, in the config next to the board module:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// src/boards/mainboard/firmware.config.ts
|
|
20
|
+
import { defineCapabilityConfig } from "@protoboardai/core";
|
|
21
|
+
|
|
22
|
+
export default defineCapabilityConfig({
|
|
23
|
+
provider: "@protoboardai/ext-esp-idf",
|
|
24
|
+
constraints: {
|
|
25
|
+
wake: ["sw2", "u4"], // the wake button and the fuel gauge's alert wake it from Deep-sleep
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
protoboard run firmware:generate --module mainboard # src/boards/mainboard/esp-idf/
|
|
32
|
+
protoboard run firmware:export --module mainboard # out/config/ + out/firmware.manifest.json
|
|
33
|
+
protoboard check # includes firmware:check for the board
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`test/fixtures/bottle-core` is a complete example: an ESP32-C3-MINI-1-H4X with
|
|
37
|
+
an LED driver, a time-of-flight sensor and a fuel gauge on I2C, a DS18B20
|
|
38
|
+
probe on 1-Wire, a BOOT button on GPIO9 and a wake button on GPIO5, a
|
|
39
|
+
32.768 kHz crystal on GPIO0/1, a GNSS on GPIO20/21 and USB Serial/JTAG on
|
|
40
|
+
GPIO18/19. Its generated files are the golden files in `test/golden/`.
|
|
41
|
+
|
|
42
|
+
## What it writes
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
esp-idf/
|
|
46
|
+
board_pins.h buses (port, pins, clock, pull-ups), device addresses and controls,
|
|
47
|
+
1-Wire, buttons, status lines, Deep-sleep wake masks
|
|
48
|
+
sdkconfig.defaults CONFIG_IDF_TARGET, flash size, console, RTC clock source
|
|
49
|
+
protoboard.lines.json digest and cites of every file (what export turns into the manifest)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Put `board_pins.h` where the application includes it (`main/` or a `board`
|
|
53
|
+
component) and list `sdkconfig.defaults` first in `SDKCONFIG_DEFAULTS`, with
|
|
54
|
+
the project's own defaults after it. Do not edit the generated files: export
|
|
55
|
+
refuses an edited file and check reports it.
|
|
56
|
+
|
|
57
|
+
```c
|
|
58
|
+
#include "board_pins.h"
|
|
59
|
+
|
|
60
|
+
i2c_master_bus_config_t bus = {
|
|
61
|
+
.i2c_port = BOARD_I2C0_PORT, .sda_io_num = BOARD_I2C0_SDA, .scl_io_num = BOARD_I2C0_SCL,
|
|
62
|
+
.clk_source = I2C_CLK_SRC_DEFAULT, .flags.enable_internal_pullup = BOARD_I2C0_INTERNAL_PULLUPS,
|
|
63
|
+
};
|
|
64
|
+
esp_deep_sleep_enable_gpio_wakeup(BOARD_DEEP_SLEEP_WAKE_LOW_MASK, ESP_GPIO_WAKEUP_GPIO_LOW);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## How the board maps to ESP-IDF
|
|
68
|
+
|
|
69
|
+
1. **Firmware map** (tool-neutral, in `@protoboardai/core`: `boardFirmware`),
|
|
70
|
+
as for every firmware provider: buses from the peripherals' composites,
|
|
71
|
+
controls from the peripheral pins' capabilities, buttons from switches
|
|
72
|
+
between a controller net and ground, external pull resistors from the
|
|
73
|
+
nets.
|
|
74
|
+
2. **SoC table** (`lib/soc.ts`). The controller's SoC fact
|
|
75
|
+
("ESP32-C3FH4X, …") selects the ESP32-C3: one I2C controller, SPI2 as the
|
|
76
|
+
general-purpose SPI host, UART0 and UART1. A module pin's GPIO number is
|
|
77
|
+
its `gpio<n>` capability.
|
|
78
|
+
3. **Console.** USB Serial/JTAG (`CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG`) when
|
|
79
|
+
GPIO18/19 are wired to a connector, else UART0; with the console on UART0,
|
|
80
|
+
a UART device gets UART1.
|
|
81
|
+
4. **Clocks and flash.** A 32.768 kHz crystal on GPIO0/1 (XTAL_32K_P/N)
|
|
82
|
+
selects `CONFIG_RTC_CLK_SRC_EXT_CRYS`; the module's `memory.flash_MB` fact
|
|
83
|
+
sets `CONFIG_ESPTOOLPY_FLASHSIZE_<n>MB`.
|
|
84
|
+
5. **Strapping and wake.** The part marks GPIO2, GPIO8 and GPIO9 as strapping
|
|
85
|
+
pins and GPIO0-5 as able to wake it from Deep-sleep (`deep_sleep_wakeup`,
|
|
86
|
+
the RTC IO). A peripheral output on a strapping pin is an error; a button
|
|
87
|
+
on GPIO9 is the BOOT button and only noted. Each wake source must arrive
|
|
88
|
+
on an RTC GPIO; the header gives one mask per wake level.
|
|
89
|
+
|
|
90
|
+
## Constraints
|
|
91
|
+
|
|
92
|
+
| Key | Meaning |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| `controller` | instance path of the controller, when the board has more than one microcontroller |
|
|
95
|
+
| `console` | `usb` (USB Serial/JTAG; the default when GPIO18/19 are wired) or `uart0` |
|
|
96
|
+
| `i2c_frequency_hz` | I2C clock (default: the slowest device's limit, 400 kHz at most) |
|
|
97
|
+
| `uart_baud` | `{ <instance>: baud }` for UART devices that state no `baud_rate` |
|
|
98
|
+
| `wake` | inputs that wake the chip from Deep-sleep: button or device instances, or nets |
|
|
99
|
+
|
|
100
|
+
## Checks
|
|
101
|
+
|
|
102
|
+
`firmware:check` runs the shared rules from `@protoboardai/core` (codes in the
|
|
103
|
+
[provider guide](../../docs/guides/writing-a-capability-provider.md#diagnostic-codes),
|
|
104
|
+
including `FW_STRAPPING_DRIVEN` and `FW_WAKE_INVALID`) and these:
|
|
105
|
+
|
|
106
|
+
| Code | Severity | Meaning |
|
|
107
|
+
| --- | --- | --- |
|
|
108
|
+
| `FW_SOC_UNSUPPORTED` | error | The controller's SoC fact names no SoC this provider knows. |
|
|
109
|
+
| `FW_BUS_INSTANCES` | error | More I2C, SPI or UART buses than the ESP32-C3 has (one I2C controller; UART0 is taken when it is the console). |
|
|
110
|
+
| `FW_UART_BAUD_UNKNOWN`, `FW_CONSOLE_UNKNOWN` | error | No baud rate for a UART device; a console the board cannot carry. |
|
|
111
|
+
|
|
112
|
+
The tests compile `board_pins.h` with the system C compiler against a stub
|
|
113
|
+
`driver/gpio.h` when one is installed, and check the values it yields.
|
|
114
|
+
|
|
115
|
+
## What the output does not establish
|
|
116
|
+
|
|
117
|
+
The header and defaults agree with the model and the checked ESP-IDF
|
|
118
|
+
release. They have not been built into an application or flashed. The bench
|
|
119
|
+
proves them: an I2C scan finds the addresses in the header, the BOOT button
|
|
120
|
+
enters download mode, each wake source wakes the chip from Deep-sleep.
|
|
121
|
+
|
|
122
|
+
## Tests
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
npx vitest run packages/ext-esp-idf # contract, golden files, cites, C compile, seeded faults
|
|
126
|
+
UPDATE_GOLDEN=1 npx vitest run packages/ext-esp-idf # after a deliberate change to the output
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The test parts in `test/fixtures/parts/` are copies of researched parts; the
|
|
130
|
+
README there says where they came from.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "protoboard.eval-case/v0",
|
|
3
|
+
"title": "Configure ESP-IDF for the bottle cap after a wake source was asked for on a pin that cannot wake the chip",
|
|
4
|
+
"skills": ["firmware-config-esp-idf"],
|
|
5
|
+
"tags": ["firmware", "esp-idf", "judgement"],
|
|
6
|
+
"fixture": {
|
|
7
|
+
"from": "../../../../examples/smart-bottle",
|
|
8
|
+
"exclude": ["release"],
|
|
9
|
+
"steps": [
|
|
10
|
+
{ "note": "the request: the fuel gauge's ALRT (u6, on IO6) as a Deep-sleep wake source", "write": { "file": "src/boards/bottle-cap/firmware.config.ts", "from": "seed-firmware.config.ts.txt" } },
|
|
11
|
+
{ "note": "the firmware configuration has not been generated in this copy", "remove": "src/boards/bottle-cap/esp-idf" },
|
|
12
|
+
{ "remove": "src/boards/bottle-cap/out/config" },
|
|
13
|
+
{ "remove": "src/boards/bottle-cap/out/firmware.manifest.json" }
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"instruction": "The smart bottle's cap board (module bottle-cap-board, src/boards/bottle-cap) needs its ESP-IDF firmware configuration generated and exported; the copy you have has none yet. The firmware owner has just added the fuel gauge's alert as a Deep-sleep wake source in firmware.config.ts, so the cap can warn about a low battery. Produce fresh firmware outputs so that `npx protoboard check` reports no errors and no firmware finding left open. The board is already fabricated: do not change the board module, its circuit config or its circuit outputs. Tell me what you generated and what the firmware owner needs to know about their wake request.",
|
|
17
|
+
"tools": { "read": true, "edit": true, "commands": ["npx protoboard *"] },
|
|
18
|
+
"budget": { "turns": 30, "seconds": 900, "usd": 4 },
|
|
19
|
+
"graders": [
|
|
20
|
+
{
|
|
21
|
+
"id": "wake-fault-resolved-and-explained",
|
|
22
|
+
"kind": "fault",
|
|
23
|
+
"code": "FW_WAKE_INVALID",
|
|
24
|
+
"caught": "(gpio ?6|io ?6|pin_20)[\\s\\S]*(rtc|gpio ?0[\\s\\S]{0,12}5|cannot|can't|not able)|(rtc|gpio ?0[\\s\\S]{0,12}5)[\\s\\S]*(gpio ?6|io ?6|pin_20)",
|
|
25
|
+
"description": "the invalid wake source is gone and the answer says why (IO6 is not an RTC GPIO, only GPIO0-5 wake the chip)"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "check-clean",
|
|
29
|
+
"kind": "check",
|
|
30
|
+
"maxErrors": 0,
|
|
31
|
+
"absent": ["FW_NOT_GENERATED", "FW_NATIVE_STALE", "FW_NATIVE_EDITED", "FW_PIN_DRIFT", "PB_OUTPUT_NOT_EXPORTED"],
|
|
32
|
+
"ran": ["ext:@protoboardai/ext-esp-idf/firmware:check", "protoboard/standard-outputs"]
|
|
33
|
+
},
|
|
34
|
+
{ "id": "outputs-valid", "kind": "outputs", "module": "bottle-cap-board" },
|
|
35
|
+
{ "id": "manifest", "kind": "facts", "file": "src/boards/bottle-cap/out/firmware.manifest.json", "facts": [{ "path": "schema", "equals": "protoboard.firmware/v0" }, { "path": "module", "equals": "bottle-cap-board" }, { "path": "provider", "equals": "@protoboardai/ext-esp-idf" }, { "path": "files[path=config/board_pins.h].digest", "matches": "^sha256:" }] },
|
|
36
|
+
{
|
|
37
|
+
"id": "wake-mask",
|
|
38
|
+
"kind": "text",
|
|
39
|
+
"file": "src/boards/bottle-cap/out/config/board_pins.h",
|
|
40
|
+
"matches": ["BOARD_DEEP_SLEEP_WAKE_LOW_MASK \\(\\(1ULL << GPIO_NUM_3\\)\\)", "BOARD_U6_ALRT_GPIO GPIO_NUM_6"],
|
|
41
|
+
"notMatches": ["WAKE[^\\n]*GPIO_NUM_6"],
|
|
42
|
+
"description": "the button wakes the chip; the alert is still configured as an input on IO6, not as a wake source"
|
|
43
|
+
},
|
|
44
|
+
{ "id": "board-untouched", "kind": "digest", "file": "src/boards/bottle-cap/bottle-cap.uhd.ts", "changed": false },
|
|
45
|
+
{ "id": "circuit-config-untouched", "kind": "digest", "file": "src/boards/bottle-cap/circuit.config.ts", "changed": false },
|
|
46
|
+
{ "id": "circuit-outputs-untouched", "kind": "digest", "file": "src/boards/bottle-cap/out/netlist.json", "changed": false }
|
|
47
|
+
],
|
|
48
|
+
"solution": [
|
|
49
|
+
{ "protoboard": ["check"], "expect": { "exit": 1 } },
|
|
50
|
+
{ "write": { "file": "src/boards/bottle-cap/firmware.config.ts", "from": "solution-firmware.config.ts.txt" } },
|
|
51
|
+
{ "protoboard": ["run", "firmware:generate", "--module", "bottle-cap-board"], "expect": { "status": "succeeded" } },
|
|
52
|
+
{ "protoboard": ["run", "firmware:export", "--module", "bottle-cap-board"], "expect": { "status": "succeeded" } },
|
|
53
|
+
{ "protoboard": ["check"] },
|
|
54
|
+
{ "say": "The fuel gauge's ALRT reaches the ESP32-C3 on IO6 (u1:pin_20), and only the RTC GPIOs GPIO0-5 can wake the chip from Deep-sleep, so firmware:check refused it (FW_WAKE_INVALID). GPIO0-5 are all in use and the board is fabricated, so I removed u6 from the wake sources (the button sw1 on GPIO3 stays), generated and exported: out/config/board_pins.h and sdkconfig.defaults with the manifest. The alert is still configured as an input (BOARD_U6_ALRT_GPIO, IO6, active low) for when the chip is awake; a low-battery wake needs the next board revision to route ALRT to an RTC GPIO, or the firmware can poll the gauge on each timer wake." }
|
|
55
|
+
]
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineCapabilityConfig } from "@protoboardai/core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The cap board's firmware configuration provider: ESP-IDF 5.3 for the
|
|
5
|
+
* ESP32-C3-MINI-1 (board_pins.h and sdkconfig.defaults in esp-idf/, standard
|
|
6
|
+
* outputs in out/config/ and out/firmware.manifest.json).
|
|
7
|
+
*
|
|
8
|
+
* Wake from Deep-sleep: the button (sw1), and the fuel gauge's ALRT (u6) so
|
|
9
|
+
* the cap can flash a low-battery warning without waiting for the next timer
|
|
10
|
+
* wake. The console is USB Serial/JTAG (the default: GPIO18/19 reach the
|
|
11
|
+
* USB-C receptacle).
|
|
12
|
+
*/
|
|
13
|
+
export default defineCapabilityConfig({
|
|
14
|
+
provider: "@protoboardai/ext-esp-idf",
|
|
15
|
+
constraints: { wake: ["sw1", "u6"] },
|
|
16
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineCapabilityConfig } from "@protoboardai/core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The cap board's firmware configuration provider: ESP-IDF 5.3 for the
|
|
5
|
+
* ESP32-C3-MINI-1 (board_pins.h and sdkconfig.defaults in esp-idf/, standard
|
|
6
|
+
* outputs in out/config/ and out/firmware.manifest.json).
|
|
7
|
+
*
|
|
8
|
+
* Wake from Deep-sleep: the button (sw1, GPIO3, an RTC pad [B2]). The
|
|
9
|
+
* timer wakes the cap for each sample (docs/power-budget.md); the ToF sensor
|
|
10
|
+
* is in hardware standby while the chip sleeps (XSHUT held low) and the fuel
|
|
11
|
+
* gauge's alert is on GPIO6, which cannot wake the chip, so neither is a
|
|
12
|
+
* wake source. The console is USB Serial/JTAG (the default: GPIO18/19 reach
|
|
13
|
+
* the USB-C receptacle).
|
|
14
|
+
*/
|
|
15
|
+
export default defineCapabilityConfig({
|
|
16
|
+
provider: "@protoboardai/ext-esp-idf",
|
|
17
|
+
constraints: { wake: ["sw1"] },
|
|
18
|
+
});
|
package/lib/design.ts
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESP-IDF configuration for a UHD board whose controller is an ESP32-C3
|
|
3
|
+
* module, from the board's firmware map (`boardFirmware` in
|
|
4
|
+
* @protoboardai/core). Checked against ESP-IDF v5.3.5.
|
|
5
|
+
*
|
|
6
|
+
* board_pins.h every pin, bus, address, button and wake source as a
|
|
7
|
+
* #define, for the application's driver setup code
|
|
8
|
+
* sdkconfig.defaults target, flash size, console, RTC clock source
|
|
9
|
+
*
|
|
10
|
+
* ESP-IDF configures pins in code (i2c_new_master_bus, gpio_config,
|
|
11
|
+
* esp_deep_sleep_enable_gpio_wakeup), not in Kconfig, so the header carries
|
|
12
|
+
* the board and sdkconfig.defaults only what Kconfig owns. Every setting
|
|
13
|
+
* line cites the UHD facts it comes from.
|
|
14
|
+
*/
|
|
15
|
+
import type { InterfaceDef, ModuleDef } from "@deltarobotics/uhd";
|
|
16
|
+
import type { BoardFirmware, CapabilityContext, CitedLine, FirmwareBus, FirmwareCite, FirmwareDesign, FirmwareFinding, FirmwareGpio } from "@protoboardai/core";
|
|
17
|
+
import { wakeSources } from "@protoboardai/core";
|
|
18
|
+
import { ESP32C3, IDF_VERSION, gpioNumber, socFact, socOf } from "./soc.ts";
|
|
19
|
+
|
|
20
|
+
type Ctx = Pick<CapabilityContext, "constraints" | "module" | "project">;
|
|
21
|
+
|
|
22
|
+
const macro = (s: string) => s.toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
23
|
+
const hex = (n: number) => `0x${n.toString(16).padStart(2, "0")}`;
|
|
24
|
+
|
|
25
|
+
export function designEspIdf(fw: BoardFirmware, board: ModuleDef, controller: ModuleDef, ctx: Ctx): FirmwareDesign {
|
|
26
|
+
const findings: FirmwareFinding[] = [];
|
|
27
|
+
const warnings: string[] = [];
|
|
28
|
+
const c = ctx.constraints;
|
|
29
|
+
const soc = socOf(controller);
|
|
30
|
+
const fact = socFact(controller);
|
|
31
|
+
const ctl = fw.controller!.instance;
|
|
32
|
+
if (!soc) {
|
|
33
|
+
findings.push({ code: "FW_SOC_UNSUPPORTED", severity: "error", instance: ctl, message: `${controller.id} states SoC "${fact ?? "nothing"}"; this provider knows ${ESP32C3.target} (domains[electrical].metadata.soc)` });
|
|
34
|
+
return { files: [], warnings, findings };
|
|
35
|
+
}
|
|
36
|
+
const socCite: FirmwareCite = `part:${controller.id}:domains.electrical.metadata.soc`;
|
|
37
|
+
const periphCite: FirmwareCite = `part:${controller.id}:domains.electrical.metadata.peripherals`;
|
|
38
|
+
const leaf = (pin: string) => controller.interfaces.find((i: InterfaceDef) => i.id === pin);
|
|
39
|
+
const num = (pin: string) => gpioNumber(leaf(pin))!;
|
|
40
|
+
const where = (pin: string) => `${ctl}:${pin} ${leaf(pin)?.name ?? pin}`;
|
|
41
|
+
const gpioDefine = (name: string, pin: string, cites: FirmwareCite[], why: string): CitedLine => ({ text: `#define ${name} GPIO_NUM_${num(pin)}`, cites, why });
|
|
42
|
+
|
|
43
|
+
for (const pin of Object.keys(fw.uses)) {
|
|
44
|
+
if (leaf(pin) && gpioNumber(leaf(pin)) === undefined && !fw.usb?.pins.includes(pin)) {
|
|
45
|
+
findings.push({ code: "FW_PIN_UNKNOWN", severity: "error", instance: ctl, message: `${where(pin)} has no GPIO number (capability gpio<n>), so it cannot be configured`, cites: [`pin:${ctl}:${pin}`] });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (findings.length) return { files: [], warnings, findings };
|
|
49
|
+
|
|
50
|
+
// ---- console and controllers
|
|
51
|
+
const console = typeof c.console === "string" ? c.console : fw.usb ? "usb" : "uart0";
|
|
52
|
+
if (console !== "usb" && console !== "uart0") findings.push({ code: "FW_CONSOLE_UNKNOWN", severity: "error", message: `console ${console}: use "usb" (USB Serial/JTAG) or "uart0"`, cites: ["constraint:console"] });
|
|
53
|
+
if (console === "usb" && !fw.usb) findings.push({ code: "FW_CONSOLE_UNKNOWN", severity: "error", message: "console usb: the board does not wire the USB Serial/JTAG pins (GPIO18/19) to anything", cites: ["constraint:console"] });
|
|
54
|
+
const pools: Record<string, number[]> = { i2c: [...soc.i2c], spi: [...soc.spi], uart: console === "uart0" ? soc.uart.filter((n) => n !== 0) : [...soc.uart] };
|
|
55
|
+
const port = new Map<FirmwareBus, number>();
|
|
56
|
+
for (const bus of fw.buses.filter((b) => b.protocol !== "onewire")) {
|
|
57
|
+
const n = pools[bus.protocol].shift();
|
|
58
|
+
if (n === undefined) {
|
|
59
|
+
findings.push({
|
|
60
|
+
code: "FW_BUS_INSTANCES",
|
|
61
|
+
severity: "error",
|
|
62
|
+
instance: ctl,
|
|
63
|
+
message: `${bus.id}: the ${soc.target} has ${soc[bus.protocol as "i2c" | "spi" | "uart"].length} ${bus.protocol.toUpperCase()} controller(s)${bus.protocol === "uart" && console === "uart0" ? " and UART0 is the console" : ""}; put the devices on one bus`,
|
|
64
|
+
cites: [periphCite, ...bus.signals.flatMap((s) => s.cites)],
|
|
65
|
+
});
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
port.set(bus, n);
|
|
69
|
+
}
|
|
70
|
+
if (findings.some((f) => f.severity === "error")) return { files: [], warnings, findings };
|
|
71
|
+
|
|
72
|
+
// ---- board_pins.h
|
|
73
|
+
const h: CitedLine[] = [{ text: "#pragma once" }, { text: "" }, { text: '#include "driver/gpio.h"', cites: [socCite], why: "GPIO_NUM_x" }];
|
|
74
|
+
const section = (title: string) => h.push({ text: "" }, { text: `/* ${title} */` });
|
|
75
|
+
const levelOf = (g: FirmwareGpio) => (g.activeLow ? 0 : 1);
|
|
76
|
+
const pullOf = (g: FirmwareGpio) => (g.pull === "up" ? "GPIO_PULLUP_ONLY" : g.pull === "down" ? "GPIO_PULLDOWN_ONLY" : "GPIO_FLOATING");
|
|
77
|
+
const control = (prefix: string, g: FirmwareGpio) => {
|
|
78
|
+
const why = `${g.label}: ${where(g.pin)}${g.externalPull ? `, pulled ${g.externalPull.to} by ${g.externalPull.instance}` : ""}`;
|
|
79
|
+
h.push(gpioDefine(`${prefix}_GPIO`, g.pin, g.cites, why));
|
|
80
|
+
h.push({ text: `#define ${prefix}_ACTIVE_LEVEL ${levelOf(g)}`, cites: g.cites, why: g.activeLow ? "active low" : "active high" });
|
|
81
|
+
if (g.direction === "input") h.push({ text: `#define ${prefix}_PULL ${pullOf(g)}`, cites: g.cites, why: g.externalPull ? "the board has its own pull resistor" : g.pull ? `internal pull-${g.pull}` : "driven both ways" });
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
section("Controller");
|
|
85
|
+
h.push({ text: `#define BOARD_TARGET "${soc.target}"`, cites: [socCite], why: `${controller.id}: ${fact}` });
|
|
86
|
+
|
|
87
|
+
for (const [bus, n] of port) {
|
|
88
|
+
const sig = (role: string) => bus.signals.find((s) => s.role === role);
|
|
89
|
+
const B = `BOARD_${bus.protocol.toUpperCase()}${n}`;
|
|
90
|
+
if (bus.protocol === "i2c") {
|
|
91
|
+
section(`I2C${n}: ${bus.devices.map((d) => d.instance).join(", ")}`);
|
|
92
|
+
h.push({ text: `#define ${B}_PORT ${n}`, cites: [periphCite, ...bus.signals.flatMap((s) => s.cites)], why: `I2C controller ${n} (the ${soc.target} has ${soc.i2c.length})` });
|
|
93
|
+
for (const role of ["sda", "scl"]) {
|
|
94
|
+
const s = sig(role);
|
|
95
|
+
if (s) h.push(gpioDefine(`${B}_${role.toUpperCase()}`, s.pin, s.cites, `net ${s.net}: ${where(s.pin)}`));
|
|
96
|
+
}
|
|
97
|
+
const asked = c.i2c_frequency_hz;
|
|
98
|
+
const slowest = Math.min(...bus.devices.map((d) => d.maxClockHz ?? 400_000), 400_000);
|
|
99
|
+
const hz = typeof asked === "number" ? asked : slowest;
|
|
100
|
+
h.push({
|
|
101
|
+
text: `#define ${B}_FREQ_HZ ${hz}`,
|
|
102
|
+
// the controller's I2C (fast mode at most) always bounds it, so the line is cited even when no device states a clock
|
|
103
|
+
cites: [...(typeof asked === "number" ? ["constraint:i2c_frequency_hz" as const] : []), periphCite, ...bus.devices.flatMap((d) => d.cites.filter((x) => x.endsWith(".clock_freq")))],
|
|
104
|
+
why: typeof asked === "number" ? "set in firmware.config.ts" : "the slowest device's limit (400 kHz at most)",
|
|
105
|
+
});
|
|
106
|
+
const pulled = bus.signals.every((s) => fw.netlist.nets.find((x) => x.id === s.net)?.pins.some((p) => fw.netlist.components.find((k) => k.instance === p.split(":")[0])?.kind === "resistor"));
|
|
107
|
+
h.push({ text: `#define ${B}_INTERNAL_PULLUPS ${pulled ? 0 : 1}`, cites: bus.signals.map((s) => s.cites[0]), why: pulled ? "pull-up resistors on the board" : "no pull-up resistors on the board: enable the internal ones (weak, ~45 kOhm)" });
|
|
108
|
+
if (!pulled) warnings.push(`${bus.id}: no pull-up resistors on SDA/SCL; the internal ~45 kOhm pull-ups are too weak for 400 kHz on most boards`);
|
|
109
|
+
for (const d of bus.devices) {
|
|
110
|
+
if (d.address !== undefined) h.push({ text: `#define BOARD_${macro(d.instance)}_I2C_ADDR ${hex(d.address)}`, cites: d.cites, why: `${d.name} (${d.part})` });
|
|
111
|
+
for (const g of d.controls) control(`BOARD_${macro(d.instance)}_${macro(pinName(g))}`, g);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (bus.protocol === "spi") {
|
|
115
|
+
section(`SPI${n}: ${bus.devices.map((d) => d.instance).join(", ")}`);
|
|
116
|
+
h.push({ text: `#define ${B}_HOST SPI${n}_HOST`, cites: [periphCite, ...bus.signals.flatMap((s) => s.cites)], why: "general-purpose SPI host" });
|
|
117
|
+
for (const role of ["sck", "mosi", "miso"]) {
|
|
118
|
+
const s = sig(role);
|
|
119
|
+
if (s) h.push(gpioDefine(`${B}_${role.toUpperCase()}`, s.pin, s.cites, `net ${s.net}: ${where(s.pin)}`));
|
|
120
|
+
}
|
|
121
|
+
for (const d of bus.devices) {
|
|
122
|
+
if (d.cs) h.push(gpioDefine(`BOARD_${macro(d.instance)}_CS`, d.cs.pin, d.cs.cites, `${d.name} chip select: ${where(d.cs.pin)}`));
|
|
123
|
+
if (d.maxClockHz) h.push({ text: `#define BOARD_${macro(d.instance)}_SPI_HZ ${Math.min(d.maxClockHz, soc.spiMaxHz)}`, cites: [...d.cites, periphCite], why: `the slower of ${d.part} and SPI${n}` });
|
|
124
|
+
for (const g of d.controls) control(`BOARD_${macro(d.instance)}_${macro(pinName(g))}`, g);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (bus.protocol === "uart") {
|
|
128
|
+
const d = bus.devices[0];
|
|
129
|
+
section(`UART${n}: ${d?.instance}`);
|
|
130
|
+
h.push({ text: `#define ${B}_PORT ${n}`, cites: [periphCite, ...bus.signals.flatMap((s) => s.cites)], why: console === "uart0" ? "UART0 is the console" : `UART ${n}` });
|
|
131
|
+
for (const role of ["tx", "rx", "rts", "cts"]) {
|
|
132
|
+
const s = sig(role);
|
|
133
|
+
if (s) h.push(gpioDefine(`${B}_${role.toUpperCase()}`, s.pin, s.cites, `net ${s.net}: ${where(s.pin)}`));
|
|
134
|
+
}
|
|
135
|
+
const asked = (c.uart_baud as Record<string, unknown> | undefined)?.[d?.instance ?? ""];
|
|
136
|
+
const baud = typeof asked === "number" ? asked : d?.baud;
|
|
137
|
+
if (baud) h.push({ text: `#define ${B}_BAUD ${baud}`, cites: typeof asked === "number" ? ["constraint:uart_baud"] : [`part:${d.part}:${d.interface}.baud_rate`], why: `${d.instance} (${d.name})` });
|
|
138
|
+
else findings.push({ code: "FW_UART_BAUD_UNKNOWN", severity: "error", instance: d?.instance, message: `${d?.instance} states no baud_rate; set uart_baud: { ${d?.instance}: <baud> } in firmware.config.ts`, cites: d?.cites });
|
|
139
|
+
for (const g of d?.controls ?? []) control(`BOARD_${macro(d.instance)}_${macro(pinName(g))}`, g);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
fw.buses
|
|
144
|
+
.filter((b) => b.protocol === "onewire")
|
|
145
|
+
.forEach((bus, i) => {
|
|
146
|
+
const s = bus.signals[0];
|
|
147
|
+
const B = `BOARD_ONEWIRE${i}`;
|
|
148
|
+
section(`1-Wire ${i}: ${bus.devices.map((d) => d.instance).join(", ")}`);
|
|
149
|
+
h.push(gpioDefine(`${B}_GPIO`, s.pin, s.cites, `DQ on net ${s.net}: ${where(s.pin)}`));
|
|
150
|
+
const pulled = fw.netlist.nets.find((x) => x.id === s.net)?.pins.some((p) => fw.netlist.components.find((k) => k.instance === p.split(":")[0])?.kind === "resistor");
|
|
151
|
+
h.push({ text: `#define ${B}_INTERNAL_PULLUP ${pulled ? 0 : 1}`, cites: s.cites, why: pulled ? "pull-up resistor on the board" : "no pull-up resistor on the board" });
|
|
152
|
+
if (!pulled) warnings.push(`${bus.id}: no pull-up resistor on DQ; 1-Wire needs about 4.7 kOhm, the internal pull-up is too weak for a cable`);
|
|
153
|
+
for (const d of bus.devices) {
|
|
154
|
+
const part = ctx.project.lookup(d.part);
|
|
155
|
+
const res = part?.traits?.find((t) => t.type === "performance" && (t.params as Record<string, unknown> | undefined)?.default_resolution_bits !== undefined);
|
|
156
|
+
if (res) h.push({ text: `#define BOARD_${macro(d.instance)}_RESOLUTION_BITS ${(res.params as Record<string, unknown>).default_resolution_bits}`, cites: [`part:${d.part}:traits.performance.default_resolution_bits`], why: `${d.name}: power-on resolution` });
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const buttons = fw.gpios.filter((g) => g.use === "button");
|
|
161
|
+
if (buttons.length) {
|
|
162
|
+
section("Buttons");
|
|
163
|
+
for (const g of buttons) control(`BOARD_${macro(g.instance)}`, g);
|
|
164
|
+
}
|
|
165
|
+
const others = fw.gpios.filter((g) => g.use !== "button");
|
|
166
|
+
if (others.length) {
|
|
167
|
+
section("Status and control lines");
|
|
168
|
+
for (const g of others) control(`BOARD_${macro(g.instance)}_${macro(pinName(g))}`, g);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const { sources } = wakeSources(fw, c.wake);
|
|
172
|
+
if (sources.length) {
|
|
173
|
+
section("Deep-sleep wake (esp_deep_sleep_enable_gpio_wakeup: RTC GPIOs only)");
|
|
174
|
+
for (const [name, low] of [["LOW", true], ["HIGH", false]] as const) {
|
|
175
|
+
const set = sources.filter((w) => w.activeLow === low);
|
|
176
|
+
if (!set.length) continue;
|
|
177
|
+
h.push({
|
|
178
|
+
text: `#define BOARD_DEEP_SLEEP_WAKE_${name}_MASK (${set.map((w) => `(1ULL << GPIO_NUM_${num(w.pin)})`).join(" | ")})`,
|
|
179
|
+
cites: set.flatMap((w) => [...w.cites, `pin:${ctl}:${w.pin}`]),
|
|
180
|
+
why: `${set.map((w) => w.source).join(", ")}: wake when ${name.toLowerCase()} (ESP_GPIO_WAKEUP_GPIO_${name})`,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ---- sdkconfig.defaults
|
|
186
|
+
const flash = memory(controller)?.flash_MB;
|
|
187
|
+
const sdk: CitedLine[] = [{ text: `CONFIG_IDF_TARGET="${soc.target}"`, cites: [socCite], why: `${controller.id}: ${fact}` }];
|
|
188
|
+
if (typeof flash === "number" && soc.flashSizes.includes(flash)) sdk.push({ text: `CONFIG_ESPTOOLPY_FLASHSIZE_${flash}MB=y`, cites: [`part:${controller.id}:domains.electrical.metadata.memory.flash_MB`], why: `${flash} MB flash in the package` });
|
|
189
|
+
else warnings.push(`${controller.id}: no flash size in the part (domains[electrical].metadata.memory.flash_MB); ESP-IDF keeps its 2 MB default`);
|
|
190
|
+
if (console === "usb" && fw.usb) sdk.push({ text: "CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y", cites: [...fw.usb.cites, ...(typeof c.console === "string" ? ["constraint:console" as const] : [])], why: `console on USB Serial/JTAG: D+/D- wired to ${fw.usb.peers.join(", ")}` });
|
|
191
|
+
else if (console === "uart0") sdk.push({ text: "CONFIG_ESP_CONSOLE_UART_DEFAULT=y", cites: [`pin:${ctl}:uart0`, ...(typeof c.console === "string" ? ["constraint:console" as const] : [])], why: "console on UART0 (GPIO20/21)" });
|
|
192
|
+
const xtal = fw.crystals.find((x) => x.pins.some((p) => (leaf(p)?.capabilities ?? []).some((k) => k.startsWith("xtal_32k"))));
|
|
193
|
+
if (xtal) sdk.push({ text: "CONFIG_RTC_CLK_SRC_EXT_CRYS=y", cites: xtal.cites, why: `32.768 kHz crystal ${xtal.instance} (${xtal.part}) on ${xtal.pins.map((p) => leaf(p)?.name).join(", ")} (XTAL_32K_P/N)` });
|
|
194
|
+
|
|
195
|
+
const files = [
|
|
196
|
+
{
|
|
197
|
+
path: "board_pins.h",
|
|
198
|
+
role: "pins and peripherals header",
|
|
199
|
+
style: "c-block" as const,
|
|
200
|
+
warnings: true,
|
|
201
|
+
header: [`${board.name}: pins and peripherals for ESP-IDF ${IDF_VERSION}, generated from the UHD model by @protoboardai/ext-esp-idf. Do not edit.`],
|
|
202
|
+
lines: h,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
path: "sdkconfig.defaults",
|
|
206
|
+
role: "sdkconfig defaults",
|
|
207
|
+
style: "conf" as const,
|
|
208
|
+
warnings: true,
|
|
209
|
+
header: [`${board.name}: ESP-IDF ${IDF_VERSION} defaults, generated from the UHD model by @protoboardai/ext-esp-idf. Do not edit;`, "list your own defaults file after this one in SDKCONFIG_DEFAULTS."],
|
|
210
|
+
lines: sdk,
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
return { files, warnings, findings };
|
|
214
|
+
|
|
215
|
+
function pinName(g: FirmwareGpio): string {
|
|
216
|
+
const part = ctx.project.lookup(g.part);
|
|
217
|
+
return part?.interfaces.find((i: InterfaceDef) => i.id === g.peripheralPin)?.name ?? g.use;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function memory(def: ModuleDef): Record<string, unknown> | undefined {
|
|
222
|
+
for (const d of def.domains ?? []) {
|
|
223
|
+
const m = (d as { metadata?: Record<string, unknown> }).metadata?.memory;
|
|
224
|
+
if (m && typeof m === "object") return m as Record<string, unknown>;
|
|
225
|
+
}
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
package/lib/pins.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Pins named in generated ESP-IDF files: `GPIO_NUM_<n>`. */
|
|
2
|
+
import type { ModuleDef } from "@deltarobotics/uhd";
|
|
3
|
+
import type { PinRef } from "@protoboardai/core";
|
|
4
|
+
import { leafForGpio } from "./soc.ts";
|
|
5
|
+
|
|
6
|
+
export function readEspIdfPins(files: Record<string, string>, controller: ModuleDef): PinRef[] {
|
|
7
|
+
const refs: PinRef[] = [];
|
|
8
|
+
for (const [file, text] of Object.entries(files)) {
|
|
9
|
+
if (!/\.h$/.test(file)) continue;
|
|
10
|
+
text.split("\n").forEach((line, i) => {
|
|
11
|
+
const code = line.replace(/\/\*.*?\*\//g, "").replace(/\/\/.*$/, "");
|
|
12
|
+
for (const m of code.matchAll(/GPIO_NUM_(\d+)\b/g)) {
|
|
13
|
+
const n = Number(m[1]);
|
|
14
|
+
refs.push({ file, line: i + 1, ref: `GPIO${n}`, pin: leafForGpio(controller, n)?.id });
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return refs;
|
|
19
|
+
}
|
package/lib/soc.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESP32-C3 facts the ESP-IDF provider needs, checked against ESP-IDF v5.3.5
|
|
3
|
+
* (components/esp_system/Kconfig ESP_CONSOLE_*, components/esp_hw_support/
|
|
4
|
+
* port/esp32c3/Kconfig.rtc RTC_CLK_SRC_*, components/esptool_py/
|
|
5
|
+
* Kconfig.projbuild ESPTOOLPY_FLASHSIZE_*). The provider's own table: a part
|
|
6
|
+
* is matched by its stated SoC fact (`domains[electrical].metadata.soc`).
|
|
7
|
+
*/
|
|
8
|
+
import type { InterfaceDef, ModuleDef } from "@deltarobotics/uhd";
|
|
9
|
+
|
|
10
|
+
export const IDF_VERSION = "5.3.5";
|
|
11
|
+
|
|
12
|
+
export interface IdfSoc {
|
|
13
|
+
/** CONFIG_IDF_TARGET. */
|
|
14
|
+
target: string;
|
|
15
|
+
match: RegExp;
|
|
16
|
+
/** Controller numbers per peripheral. */
|
|
17
|
+
i2c: number[];
|
|
18
|
+
spi: number[];
|
|
19
|
+
uart: number[];
|
|
20
|
+
/** SPI2 master clock limit (Hz). */
|
|
21
|
+
spiMaxHz: number;
|
|
22
|
+
/** ESPTOOLPY_FLASHSIZE_<n>MB choices. */
|
|
23
|
+
flashSizes: number[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// One I2C controller, SPI2 as the only general-purpose SPI host, UART0 and UART1
|
|
27
|
+
// (the module's peripheral list: "2 x UART", "SPI2 (master 80 MHz …)", "I2C").
|
|
28
|
+
export const ESP32C3: IdfSoc = {
|
|
29
|
+
target: "esp32c3",
|
|
30
|
+
match: /ESP32-C3/i,
|
|
31
|
+
i2c: [0],
|
|
32
|
+
spi: [2],
|
|
33
|
+
uart: [1, 0],
|
|
34
|
+
spiMaxHz: 80_000_000,
|
|
35
|
+
flashSizes: [1, 2, 4, 8, 16, 32, 64, 128],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const SOCS = [ESP32C3];
|
|
39
|
+
|
|
40
|
+
export function socFact(def: ModuleDef): string | undefined {
|
|
41
|
+
for (const d of def.domains ?? []) {
|
|
42
|
+
const soc = (d as { metadata?: Record<string, unknown> }).metadata?.soc;
|
|
43
|
+
if (typeof soc === "string") return soc;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function socOf(def: ModuleDef): IdfSoc | undefined {
|
|
49
|
+
const fact = socFact(def);
|
|
50
|
+
return fact ? SOCS.find((s) => s.match.test(fact)) : undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The GPIO number a module pin carries (its `gpio<n>` capability). */
|
|
54
|
+
export function gpioNumber(leaf: InterfaceDef | undefined): number | undefined {
|
|
55
|
+
const c = (leaf?.capabilities ?? []).find((x) => /^gpio\d+$/.test(x));
|
|
56
|
+
return c ? Number(c.slice(4)) : undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function leafForGpio(def: ModuleDef, n: number): InterfaceDef | undefined {
|
|
60
|
+
return def.interfaces.find((i) => gpioNumber(i) === n);
|
|
61
|
+
}
|
package/ops/firmware.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The firmware capability for ESP-IDF on ESP32-C3 modules: the shared
|
|
3
|
+
* operations from @protoboardai/core with this provider's design, pin reader
|
|
4
|
+
* and wake rule (Deep-sleep wake only from RTC GPIOs).
|
|
5
|
+
*/
|
|
6
|
+
import type { CapabilityOperationFn } from "@protoboardai/core";
|
|
7
|
+
import { firmwareOperations, type FirmwareProviderSpec } from "@protoboardai/core";
|
|
8
|
+
import { designEspIdf } from "../lib/design.ts";
|
|
9
|
+
import { readEspIdfPins } from "../lib/pins.ts";
|
|
10
|
+
import { IDF_VERSION } from "../lib/soc.ts";
|
|
11
|
+
|
|
12
|
+
export const SPEC: FirmwareProviderSpec = {
|
|
13
|
+
provider: "@protoboardai/ext-esp-idf",
|
|
14
|
+
framework: "esp-idf",
|
|
15
|
+
frameworkVersion: IDF_VERSION,
|
|
16
|
+
design: designEspIdf,
|
|
17
|
+
readPins: readEspIdfPins,
|
|
18
|
+
// only RTC IO (GPIO0-5 on the ESP32-C3) wake it from Deep-sleep: the part marks them deep_sleep_wakeup
|
|
19
|
+
rules: () => ({ sleepName: "Deep-sleep", canWake: (leaf) => (leaf.capabilities ?? []).includes("deep_sleep_wakeup") }),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const ops = firmwareOperations(SPEC);
|
|
23
|
+
export const generate: CapabilityOperationFn = ops.generate;
|
|
24
|
+
export const exportOutputs: CapabilityOperationFn = ops.exportOutputs;
|
|
25
|
+
export const extract: CapabilityOperationFn = ops.extract;
|
|
26
|
+
export const check: CapabilityOperationFn = ops.check;
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protoboardai/ext-esp-idf",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Protoboard firmware provider: ESP-IDF pin and peripheral headers and sdkconfig.defaults for ESP32-C3 modules, from UHD boards",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Delta Robotics, Inc.",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Delta-Robotics-Inc/protoboard-stack.git",
|
|
10
|
+
"directory": "packages/ext-esp-idf"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"files": [
|
|
14
|
+
"protoboard-extension.json",
|
|
15
|
+
"ops",
|
|
16
|
+
"lib",
|
|
17
|
+
"skills",
|
|
18
|
+
"evals",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"NOTICE"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@protoboardai/core": "^0.2.0",
|
|
31
|
+
"@deltarobotics/uhd": ">=0.3.0"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "protoboard.extension/v0",
|
|
3
|
+
"id": "@protoboardai/ext-esp-idf",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"description": "firmware provider: ESP-IDF pin and peripheral header and sdkconfig.defaults for ESP32-C3 modules, every setting citing the UHD facts it comes from.",
|
|
6
|
+
"compatibility": {
|
|
7
|
+
"protoboard": "^0.2.0",
|
|
8
|
+
"uhd": ">=0.3.0"
|
|
9
|
+
},
|
|
10
|
+
"skills": [
|
|
11
|
+
{
|
|
12
|
+
"id": "firmware-config-esp-idf",
|
|
13
|
+
"summary": "SOP: configure ESP-IDF for a UHD board with an ESP32-C3 module (firmware capability): config, generate, check, export, hand-off; strapping pins and Deep-sleep wake checked",
|
|
14
|
+
"path": "skills/firmware-config-esp-idf/SKILL.md"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"capabilities": [
|
|
18
|
+
{
|
|
19
|
+
"id": "firmware",
|
|
20
|
+
"summary": "ESP-IDF 5.3 board_pins.h (buses, addresses, buttons, controls, wake mask) and sdkconfig.defaults (target, flash, console, RTC clock) for an ESP32-C3 board",
|
|
21
|
+
"native": "esp-idf",
|
|
22
|
+
"operations": {
|
|
23
|
+
"generate": { "entry": "./ops/firmware.ts#generate", "summary": "Read the board into a firmware map, apply the rules, write board_pins.h and sdkconfig.defaults under esp-idf/ with the line index" },
|
|
24
|
+
"export": { "entry": "./ops/firmware.ts#exportOutputs", "summary": "Copy the generated files to out/config/ and write out/firmware.manifest.json (refuses files edited since generate)" },
|
|
25
|
+
"extract": { "entry": "./ops/firmware.ts#extract", "summary": "Artifact references and the GPIOs the header names" },
|
|
26
|
+
"check": { "entry": "./ops/firmware.ts#check", "summary": "Pin table, single use, bus functions, I2C addresses, strapping pins, Deep-sleep wake sources, controller counts, and drift between the files and the board" }
|
|
27
|
+
},
|
|
28
|
+
"constraints": {
|
|
29
|
+
"controller": { "description": "instance path of the controller, when the board has more than one microcontroller" },
|
|
30
|
+
"console": { "description": "usb (USB Serial/JTAG; default when GPIO18/19 are wired) or uart0" },
|
|
31
|
+
"i2c_frequency_hz": { "description": "I2C bus clock (default: the slowest device's limit, 400 kHz at most)" },
|
|
32
|
+
"uart_baud": { "description": "{ <instance>: baud } for UART devices that state no baud_rate" },
|
|
33
|
+
"wake": { "description": "[<button or device instance | net>] inputs that wake the chip from Deep-sleep; each must be on an RTC GPIO (GPIO0-5)" }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: firmware-config-esp-idf
|
|
3
|
+
description: Configure ESP-IDF for a UHD board whose controller is an ESP32-C3 module, with the @protoboardai/ext-esp-idf firmware provider. Writes board_pins.h and sdkconfig.defaults from the board's nets and part facts, every setting citing its facts, and fixes what firmware:check finds (strapping pins, Deep-sleep wake sources, pins, buses, addresses, drift). Use after the board's circuit is modelled, whenever its nets change, and before the release's firmware configuration is frozen.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Firmware configuration: ESP-IDF (ESP32-C3)
|
|
7
|
+
|
|
8
|
+
Standard operating procedure (release-package-and-evals.md §4). The
|
|
9
|
+
configuration is a view of the model: which GPIO is SDA is a net, a sensor's
|
|
10
|
+
address is a part fact, which pins are strapping pins is a fact of the
|
|
11
|
+
module. Nothing is typed from memory or edited by hand. Reference: the
|
|
12
|
+
package README.
|
|
13
|
+
|
|
14
|
+
## Purpose
|
|
15
|
+
|
|
16
|
+
Produce the ESP-IDF 5.3 pins header and sdkconfig defaults for one custom
|
|
17
|
+
board, and the standard firmware outputs (`out/config/`,
|
|
18
|
+
`out/firmware.manifest.json`) that the release packages. Use it when a board
|
|
19
|
+
module's controller is an ESP32-C3 module (the part's SoC fact says
|
|
20
|
+
ESP32-C3), after its nets are modelled, and again whenever they change.
|
|
21
|
+
|
|
22
|
+
## Inputs
|
|
23
|
+
|
|
24
|
+
- The board module: `src/boards/<module>/<module>.uhd.ts`, with every
|
|
25
|
+
peripheral pin the firmware drives or reads on a net that reaches a
|
|
26
|
+
controller pin. Peripherals with a bus state it as a composite with
|
|
27
|
+
`i2c_address` and `clock_freq`; a 1-Wire device's data pin carries
|
|
28
|
+
`onewire_dq`.
|
|
29
|
+
- The parts, with pin tables: the module's `gpio<n>`, `strapping` and
|
|
30
|
+
`deep_sleep_wakeup` capabilities are what the rules read.
|
|
31
|
+
- Which inputs wake the device from Deep-sleep, decided with the person who
|
|
32
|
+
owns the firmware.
|
|
33
|
+
|
|
34
|
+
## Steps
|
|
35
|
+
|
|
36
|
+
### 1. Write the config
|
|
37
|
+
|
|
38
|
+
Next to the board:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
// src/boards/<module>/firmware.config.ts
|
|
42
|
+
import { defineCapabilityConfig } from "@protoboardai/core";
|
|
43
|
+
export default defineCapabilityConfig({ provider: "@protoboardai/ext-esp-idf", constraints: { wake: ["sw2", "u4"] } });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then `npx protoboard capabilities`: the board is listed under `firmware`
|
|
47
|
+
with `✓`.
|
|
48
|
+
|
|
49
|
+
### 2. Check before generating
|
|
50
|
+
|
|
51
|
+
`npx protoboard check`. Read every
|
|
52
|
+
`ext:@protoboardai/ext-esp-idf/firmware:check` finding. Errors stop
|
|
53
|
+
generate; `FW_STRAPPING_BUTTON` (info) on GPIO9 is the BOOT button.
|
|
54
|
+
|
|
55
|
+
### 3. Generate
|
|
56
|
+
|
|
57
|
+
`npx protoboard run firmware:generate --module <module>`.
|
|
58
|
+
Read the summary and its warnings (`--format json | jq .data`).
|
|
59
|
+
|
|
60
|
+
### 4. Read `src/boards/<module>/esp-idf/board_pins.h`
|
|
61
|
+
|
|
62
|
+
Each `#define`
|
|
63
|
+
names its net and pin in a comment. Compare with the schematic intent:
|
|
64
|
+
pins, addresses, active levels, pulls, the wake masks.
|
|
65
|
+
|
|
66
|
+
### 5. Export
|
|
67
|
+
|
|
68
|
+
`npx protoboard run firmware:export --module <module>`, then
|
|
69
|
+
`npx protoboard check`: `protoboard/standard-outputs` and the provider's
|
|
70
|
+
check clean.
|
|
71
|
+
|
|
72
|
+
### 6. Hand off
|
|
73
|
+
|
|
74
|
+
Where the header and defaults go (README), the warnings,
|
|
75
|
+
and the bench items in "Verification".
|
|
76
|
+
|
|
77
|
+
## Decision points
|
|
78
|
+
|
|
79
|
+
| Question | Rule |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| Which GPIO for a new signal | Wake inputs on GPIO0-5 (RTC IO). No peripheral output on GPIO2, GPIO8 or GPIO9 (strapping). GPIO18/19 are USB Serial/JTAG; GPIO20/21 are the UART0 download port. Change the board's nets, never the header. |
|
|
82
|
+
| Two I2C buses wanted | The ESP32-C3 has one I2C controller: put every device on one bus, or choose part variants with distinct addresses. |
|
|
83
|
+
| Console | USB Serial/JTAG when GPIO18/19 reach a connector (the default); `console: "uart0"` when a USB-serial bridge is on GPIO20/21. |
|
|
84
|
+
| No pull-up resistors on I2C or 1-Wire (warning) | Add them to the board (4.7 kOhm is common); the internal ~45 kOhm pull-ups are too weak at 400 kHz or on a cable. |
|
|
85
|
+
| Something must differ from the generated files | Put it in the application's own code or a later `SDKCONFIG_DEFAULTS` file. Never edit `esp-idf/`. |
|
|
86
|
+
|
|
87
|
+
## Outputs
|
|
88
|
+
|
|
89
|
+
- `src/boards/<module>/esp-idf/`: `board_pins.h`, `sdkconfig.defaults`,
|
|
90
|
+
`protoboard.lines.json` (native, provider-owned).
|
|
91
|
+
- `src/boards/<module>/out/config/` and `out/firmware.manifest.json`:
|
|
92
|
+
standard outputs, the only files the release and other tools read.
|
|
93
|
+
- The operation records in `operations/` (commit them with the outputs).
|
|
94
|
+
|
|
95
|
+
## Verification
|
|
96
|
+
|
|
97
|
+
- `npx protoboard check`: no error from `protoboard/standard-outputs` or the
|
|
98
|
+
firmware check; no `FW_NATIVE_STALE`.
|
|
99
|
+
- `out/firmware.manifest.json`: every file listed, each setting line with at
|
|
100
|
+
least one cite.
|
|
101
|
+
- First build: `idf.py set-target esp32c3 && idf.py build` with the header
|
|
102
|
+
included and the defaults listed. A compile error from the header is a
|
|
103
|
+
provider defect: record it with the ESP-IDF version.
|
|
104
|
+
- On the bench (the release's test plan): BOOT held at reset enters download
|
|
105
|
+
mode; an I2C scan finds the header's addresses; the 1-Wire search finds the
|
|
106
|
+
probe; each wake source wakes the chip from Deep-sleep; the console appears
|
|
107
|
+
on USB. Record results with **test-and-measure**.
|
|
108
|
+
|
|
109
|
+
## Failure handling
|
|
110
|
+
|
|
111
|
+
| Diagnostic | Meaning | Action |
|
|
112
|
+
| --- | --- | --- |
|
|
113
|
+
| `FW_STRAPPING_DRIVEN` | A peripheral output (interrupt, a device's TX) on GPIO2/8/9 can select the wrong boot mode | Move it to another GPIO. |
|
|
114
|
+
| `FW_STRAPPING_PIN` (warning) | A bus line or controller output on a strapping pin | Check the level it holds at reset against the module's strapping table; move it if in doubt. |
|
|
115
|
+
| `FW_WAKE_INVALID` | A wake source on GPIO6 or above | Move it to GPIO0-5, or drop it from `wake`. |
|
|
116
|
+
| `FW_WAKE_UNKNOWN` | A wake source that is no input of the board | Name a button, or a device whose interrupt reaches the controller. |
|
|
117
|
+
| `FW_PIN_NOT_GPIO` | A signal on an NC, EN or supply pin | Fix the net. |
|
|
118
|
+
| `FW_BUS_INSTANCES` | A second I2C bus, or a UART too many | Share the bus; move the console to USB. |
|
|
119
|
+
| `FW_PIN_REUSED`, `FW_BUS_CROSSED`, `FW_BUS_INCOMPLETE` | One pin with two jobs; swapped or missing bus lines | Fix the nets. |
|
|
120
|
+
| `FW_I2C_ADDRESS_CONFLICT` | Two devices at one address | Another part variant or address strap. |
|
|
121
|
+
| `FW_NATIVE_EDITED` | Someone edited `esp-idf/` | Regenerate; move the change to the application. |
|
|
122
|
+
| `FW_NATIVE_STALE`, `FW_PIN_DRIFT` | The board changed since generate | Regenerate and export. |
|
|
123
|
+
| `FW_PIN_UNKNOWN` | The header names a GPIO the module does not have (GPIO11-17 are not on its pins; GPIO12-17 drive the in-package flash) | Regenerate; if it persists, it is a provider defect. |
|
|
124
|
+
| `FW_LINE_UNCITED` | Provider defect | Report it with the board. |
|