@geastack/targets 0.1.103 → 0.1.105

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.
Files changed (79) hide show
  1. package/README.md +7 -0
  2. package/build-config.json +25 -1
  3. package/package.json +6 -6
  4. package/targets/cmake/geatsc-generated-archive-build.mjs +41 -12
  5. package/targets/esp32/app_project.cmake +23 -27
  6. package/targets/esp32/chip_bindings/magnetometer/bmm150.cpp +140 -0
  7. package/targets/esp32/chip_bindings/touch/cst9217.cpp +27 -3
  8. package/targets/esp32/chip_bindings/touch/cst9217_controller.h +11 -2
  9. package/targets/esp32/components/gea_framework/CMakeLists.txt +9 -5
  10. package/targets/esp32/components/gea_framework/project_include.cmake +22 -0
  11. package/targets/esp32/esp_now.cpp +298 -0
  12. package/targets/esp32/esp_now_power.h +17 -0
  13. package/targets/esp32/esp_now_rate.h +57 -0
  14. package/targets/esp32/esp_now_tx_header.h +46 -0
  15. package/targets/esp32/gea_framework.cmake +1 -0
  16. package/targets/esp32/ldfragments/gea_ui_state_external.lf +11 -0
  17. package/targets/esp32/services/device_control.cpp +29 -11
  18. package/targets/esp32/services/frame_scheduler.cpp +7 -0
  19. package/targets/esp32/uart.cpp +7 -1
  20. package/targets/esp32-m5stack-m5paper/CMakeLists.txt +1 -0
  21. package/targets/esp32-m5stack-m5paper/main/idf_component.yml +7 -4
  22. package/targets/esp32-p4-m5stack-tab5/CMakeLists.txt +1 -0
  23. package/targets/esp32-p4-m5stack-tab5/main/CMakeLists.txt +4 -0
  24. package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +9 -6
  25. package/targets/esp32-p4-waveshare-touch-lcd-3.5/CMakeLists.txt +1 -0
  26. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/CMakeLists.txt +4 -0
  27. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/display.cpp +21 -5
  28. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +8 -5
  29. package/targets/esp32-p4-waveshare-touch-lcd-7/CMakeLists.txt +1 -0
  30. package/targets/esp32-p4-waveshare-touch-lcd-7/main/CMakeLists.txt +4 -0
  31. package/targets/esp32-p4-waveshare-touch-lcd-7/main/display.cpp +16 -5
  32. package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +8 -5
  33. package/targets/esp32-s3-elecrow-rotary-2.1/CMakeLists.txt +1 -0
  34. package/targets/esp32-s3-elecrow-rotary-2.1/main/CMakeLists.txt +3 -3
  35. package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +5 -2
  36. package/targets/esp32-s3-epaper-1.54/CMakeLists.txt +1 -0
  37. package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +9 -9
  38. package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +7 -4
  39. package/targets/esp32-s3-lilygo-t-display-s3-long/CMakeLists.txt +1 -0
  40. package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +7 -4
  41. package/targets/esp32-s3-lilygo-t5-epaper-4.7/CMakeLists.txt +1 -0
  42. package/targets/esp32-s3-lilygo-t5-epaper-4.7/main/idf_component.yml +4 -1
  43. package/targets/esp32-s3-m5stack-papers3/CMakeLists.txt +1 -0
  44. package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +7 -4
  45. package/targets/esp32-s3-m5stack-sticks3/CMakeLists.txt +1 -0
  46. package/targets/esp32-s3-m5stack-sticks3/main/CMakeLists.txt +2 -1
  47. package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +6 -3
  48. package/targets/esp32-s3-m5stack-stopwatch/CMakeLists.txt +1 -0
  49. package/targets/esp32-s3-m5stack-stopwatch/main/gea-dependencies.json +42 -0
  50. package/targets/esp32-s3-m5stack-stopwatch/main/idf_component.yml +4 -18
  51. package/targets/esp32-s3-touch-amoled-1.75/CMakeLists.txt +1 -0
  52. package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +8 -5
  53. package/targets/esp32-s3-touch-amoled-1.8/CMakeLists.txt +1 -0
  54. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +9 -4
  55. package/targets/esp32-s3-touch-amoled-1.8/main/gea-dependencies.json +26 -0
  56. package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +6 -18
  57. package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +1 -0
  58. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +11 -10
  59. package/targets/esp32-s3-touch-amoled-2.06/main/gea-dependencies.json +58 -0
  60. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +4 -42
  61. package/targets/esp32-s3-touch-amoled-2.41/CMakeLists.txt +1 -0
  62. package/targets/esp32-s3-touch-amoled-2.41/main/gea-dependencies.json +42 -0
  63. package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +5 -30
  64. package/targets/esp32-s3-touch-lcd-1.54/CMakeLists.txt +1 -0
  65. package/targets/esp32-s3-touch-lcd-1.54/main/idf_component.yml +8 -5
  66. package/targets/esp32-s3-touch-lcd-3.5b/CMakeLists.txt +1 -0
  67. package/targets/esp32-s3-touch-lcd-3.5b/main/gea-dependencies.json +26 -0
  68. package/targets/esp32-s3-touch-lcd-3.5b/main/idf_component.yml +4 -20
  69. package/targets/esp32-s31-espressif-mosaico/CMakeLists.txt +1 -0
  70. package/targets/esp32-s31-espressif-mosaico/README.md +10 -2
  71. package/targets/esp32-s31-espressif-mosaico/dependencies.lock +7 -334
  72. package/targets/esp32-s31-espressif-mosaico/main/CMakeLists.txt +9 -1
  73. package/targets/esp32-s31-espressif-mosaico/main/board_power.cpp +13 -1
  74. package/targets/esp32-s31-espressif-mosaico/main/gea-dependencies.json +52 -0
  75. package/targets/esp32-s31-espressif-mosaico/main/idf_component.yml +13 -40
  76. package/targets/esp32-s31-espressif-mosaico/main/include/board.h +6 -0
  77. package/targets/esp32-s31-espressif-mosaico/main/include/mosaico_peer_uart_pins.h +2 -2
  78. package/targets/esp32-s31-espressif-mosaico/partitions.csv +1 -1
  79. package/targets/esp32-s3-m5stack-stopwatch/.clang-format +0 -10
package/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @geastack/targets
2
2
 
3
+ The CLI analyzes application APIs to select camera, networking, and audio
4
+ capabilities. Microphone capture combined with playback enables full duplex and
5
+ AEC automatically; playback alone does not. Resolved capabilities live in the
6
+ generated build configuration, rather than per-capability environment variables.
7
+ Each ESP32 target keeps optional SDK dependencies in `main/gea-dependencies.json`;
8
+ the CLI generates an IDF dependency component containing only the selected SDKs.
9
+
3
10
  Native embedded build targets for GeaStack. The package ships the ESP32 and
4
11
  RP2350 board sources, board catalog, BLE/WiFi OTA clients, and build/flash
5
12
  adapter used by the `gea` CLI.
package/build-config.json CHANGED
@@ -118,7 +118,18 @@
118
118
  "compiler.translationUnits",
119
119
  "compiler.storeRelowering",
120
120
  "compiler.moduleGraph",
121
- "compiler.allowAny"
121
+ "compiler.allowAny",
122
+ "native.jobs",
123
+ "native.arch",
124
+ "native.debugInfo",
125
+ "native.lto",
126
+ "native.ltoJobs",
127
+ "native.ltoCache",
128
+ "native.ltoExcludeSources",
129
+ "native.unoptimizedSources",
130
+ "native.pgo",
131
+ "native.pgoProfile",
132
+ "native.package"
122
133
  ],
123
134
  "defaults": {
124
135
  "compiler": {
@@ -129,6 +140,19 @@
129
140
  "storeRelowering": true,
130
141
  "moduleGraph": "auto",
131
142
  "allowAny": false
143
+ },
144
+ "native": {
145
+ "jobs": 0,
146
+ "arch": "default",
147
+ "debugInfo": false,
148
+ "lto": "off",
149
+ "ltoJobs": 0,
150
+ "ltoCache": "",
151
+ "ltoExcludeSources": "",
152
+ "unoptimizedSources": "",
153
+ "pgo": "off",
154
+ "pgoProfile": "",
155
+ "package": "none"
132
156
  }
133
157
  }
134
158
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/targets",
3
- "version": "0.1.103",
3
+ "version": "0.1.105",
4
4
  "description": "Native embedded build targets (ESP32-IDF, RP2350) for geastack apps: board sources, target catalog, and CMake glue driven by the gea CLI.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@geastack/chips": "^0.1.6",
40
- "@geastack/compiler": "^1.0.33",
41
- "@geastack/core": "0.1.42",
40
+ "@geastack/compiler": "^1.0.37",
41
+ "@geastack/core": "0.1.45",
42
42
  "@geastack/elements": "^0.1.6",
43
- "@geastack/engine": "^0.1.17",
43
+ "@geastack/engine": "^0.1.18",
44
44
  "@geastack/geaos": "^0.1.3",
45
- "@geastack/geatsc-plugin-gea": "0.1.23",
46
- "@geastack/host": "0.1.17"
45
+ "@geastack/geatsc-plugin-gea": "0.1.24",
46
+ "@geastack/host": "0.1.19"
47
47
  },
48
48
  "scripts": {
49
49
  "test": "for f in $(git ls-files | grep -E '(^|/)(test[-_][^/]*|[^/]*\\.test)\\.mjs$'); do echo \"==> $f\"; node \"$f\" || exit 1; done"
@@ -89,6 +89,18 @@ function firstRule(text) {
89
89
  return text.replace(/\\\r?\n/g, ' ').split(/\r?\n/, 1)[0] ?? ''
90
90
  }
91
91
 
92
+ // A Windows host's compiler names the target and every dependency with a
93
+ // drive (`C:\...` or `C:/...`). That colon belongs to the path; taking it for
94
+ // the rule separator turned every dependency into garbage, so no object was
95
+ // ever found up to date there.
96
+ function isDriveColon(rule, index) {
97
+ return (
98
+ /[A-Za-z]/.test(rule[index - 1] ?? '') &&
99
+ (index === 1 || /\s/.test(rule[index - 2])) &&
100
+ /[\\/]/.test(rule[index + 1] ?? '')
101
+ )
102
+ }
103
+
92
104
  function ruleColon(rule) {
93
105
  let escaped = false
94
106
  for (let index = 0; index < rule.length; index++) {
@@ -101,7 +113,7 @@ function ruleColon(rule) {
101
113
  escaped = true
102
114
  continue
103
115
  }
104
- if (char === ':') return index
116
+ if (char === ':' && !isDriveColon(rule, index)) return index
105
117
  }
106
118
  return -1
107
119
  }
@@ -113,26 +125,43 @@ export function parseDepfile(text, cwd = process.cwd()) {
113
125
 
114
126
  const dependencies = []
115
127
  let token = ''
116
- let escaped = false
117
128
  const flush = () => {
118
129
  if (!token) return
119
130
  dependencies.push(path.isAbsolute(token) ? path.normalize(token) : path.resolve(cwd, token))
120
131
  token = ''
121
132
  }
122
133
 
123
- for (const char of rule.slice(colon + 1)) {
124
- if (escaped) {
125
- token += char
126
- escaped = false
127
- } else if (char === '\\') {
128
- escaped = true
129
- } else if (/\s/.test(char)) {
130
- flush()
134
+ // GCC's and Clang's make quoting: 2N+1 backslashes before a blank are N
135
+ // backslashes and a blank inside the name, 2N are N backslashes ending it,
136
+ // and `\#` is `#`. Any other backslash is literal -- on a Windows host it
137
+ // is the path separator, which dropping left `C:Usersme...`.
138
+ const body = rule.slice(colon + 1)
139
+ for (let index = 0; index < body.length; index++) {
140
+ const char = body[index]
141
+ if (char !== '\\') {
142
+ if (/\s/.test(char)) flush()
143
+ else token += char
144
+ continue
145
+ }
146
+ let count = 1
147
+ while (body[index + count] === '\\') count++
148
+ const next = body[index + count]
149
+ if (next !== undefined && /\s/.test(next)) {
150
+ token += '\\'.repeat(Math.floor(count / 2))
151
+ if (count % 2 === 1) {
152
+ token += next
153
+ index += count
154
+ } else {
155
+ index += count - 1
156
+ }
157
+ } else if (next === '#' && count % 2 === 1) {
158
+ token += `${'\\'.repeat(Math.floor(count / 2))}#`
159
+ index += count
131
160
  } else {
132
- token += char
161
+ token += '\\'.repeat(count)
162
+ index += count - 1
133
163
  }
134
164
  }
135
- if (escaped) token += '\\'
136
165
  flush()
137
166
  return dependencies
138
167
  }
@@ -1,3 +1,7 @@
1
+ include("${CMAKE_CURRENT_LIST_DIR}/../cmake/gea_build_config.cmake")
2
+ if(NOT GEA_APP_CAPABILITY_ANALYSIS_VERSION EQUAL 1)
3
+ message(FATAL_ERROR "Capability analysis is missing or unsupported. Update @geastack/cli together with @geastack/targets.")
4
+ endif()
1
5
  # Included by every esp32 board's top-level CMakeLists BEFORE project(), which
2
6
  # is the only phase where EXTRA_COMPONENT_DIRS still has an effect. An app
3
7
  # declares its own IDF components -- a vendored driver, a DSP library with its
@@ -18,33 +22,25 @@ foreach(_GEA_APP_COMPONENT_DIR IN LISTS GEA_EMBEDDED_APP_COMPONENT_DIRS)
18
22
  list(APPEND EXTRA_COMPONENT_DIRS "${_GEA_APP_COMPONENT_DIR}")
19
23
  endforeach()
20
24
 
21
- # ESP-SR is needed only by apps opting into the shared audio echo canceller.
22
- # Derive this before IDF resolves managed dependencies, including its script pass.
23
- set(_GEA_AUDIO_DEFINES "${GEA_EMBEDDED_APP_DEFINES};$ENV{GEA_EMBEDDED_APP_DEFINES}")
24
- set(ENV{GEA_EMBEDDED_CAPABILITY_AEC} "0")
25
- if(";${_GEA_AUDIO_DEFINES};" MATCHES ";GEA_AUDIO_ECHO_CANCELLATION=1;")
26
- set(ENV{GEA_EMBEDDED_CAPABILITY_AEC} "1")
25
+ if(GEA_APP_CAPABILITY_DEPENDENCY_DIR)
26
+ list(APPEND EXTRA_COMPONENT_DIRS "${GEA_APP_CAPABILITY_DEPENDENCY_DIR}")
27
27
  endif()
28
28
 
29
- # The managed-dependency manifests (main/idf_component.yml) gate the registry
30
- # components that belong to one capability -- the codec, the WebSocket client,
31
- # the WebRTC peer -- on these variables, and the component manager treats an
32
- # unset environment variable in an `if:` rule as a hard error rather than a
33
- # false. The gea CLI always exports these values; a direct `idf.py` build has no
34
- # app analysis to go on, so it defaults to keeping everything, which is what it
35
- # built before the rules existed.
36
- foreach(_GEA_CAPABILITY NETWORK BLE AUDIO RTC H264)
37
- if(NOT DEFINED ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}
38
- OR "$ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}" STREQUAL "")
39
- # Incremental Ninja/CMake reconfiguration does not inherit the CLI's
40
- # original environment. Keep its cached analysis instead of silently
41
- # enabling BLE (and consuming the audio DMA heap) on the next build.
42
- if(DEFINED CACHE{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}
43
- AND NOT "$CACHE{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}" STREQUAL "")
44
- set(ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}
45
- "$CACHE{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}")
46
- else()
47
- set(ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}} "1")
48
- endif()
29
+ # The component manager writes the dependencies it solved into the lock file,
30
+ # and which components are dependencies depends on the app being built (the
31
+ # capability-selected SDKs the CLI places in GEA_APP_CAPABILITY_DEPENDENCY_DIR).
32
+ # Solving into the target's tracked dependencies.lock therefore rewrote it for
33
+ # every app with a different capability set. A target calls this after
34
+ # including project.cmake: the build solves into its own build directory,
35
+ # starting from the tracked lock (copied again whenever the tracked one is
36
+ # newer) so the versions it pins still hold, and the source tree stays as it
37
+ # was checked out.
38
+ macro(gea_solve_dependencies_in_build_dir)
39
+ set(_GEA_TRACKED_LOCK "${CMAKE_CURRENT_LIST_DIR}/dependencies.lock")
40
+ set(_GEA_BUILD_LOCK "${CMAKE_BINARY_DIR}/dependencies.lock")
41
+ if(EXISTS "${_GEA_TRACKED_LOCK}"
42
+ AND (NOT EXISTS "${_GEA_BUILD_LOCK}" OR "${_GEA_TRACKED_LOCK}" IS_NEWER_THAN "${_GEA_BUILD_LOCK}"))
43
+ configure_file("${_GEA_TRACKED_LOCK}" "${_GEA_BUILD_LOCK}" COPYONLY)
49
44
  endif()
50
- endforeach()
45
+ idf_build_set_property(DEPENDENCIES_LOCK "${_GEA_BUILD_LOCK}")
46
+ endmacro()
@@ -0,0 +1,140 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Uses Espressif's BSD-3-Clause BMM150 adapter on the existing Gea I2C bus.
3
+ // Integer compensation matches Espressif's Mosaico magnetic calibration;
4
+ // overflow sentinels are meaningful edge evidence and must not become zero.
5
+ #include "bmm150_common.h"
6
+ #include "board.h"
7
+ #include "esp_timer.h"
8
+ #include "freertos/FreeRTOS.h"
9
+ #include "freertos/task.h"
10
+ #include "i2c.h"
11
+ #include "platform/magnetometer.h"
12
+ #include <array>
13
+ #include <mutex>
14
+ #include <type_traits>
15
+
16
+ static_assert(std::is_same_v<decltype(bmm150_mag_data::x), std::int16_t>,
17
+ "BMM150 and its consumers must use the same integer ABI");
18
+
19
+ namespace {
20
+ using gea::platform::sensors::MagnetometerReading;
21
+ constexpr auto kAddresses = gea::platform::board::magnetometerAddresses;
22
+ struct Sensor {
23
+ bmm150_dev device{};
24
+ bool initialized = false;
25
+ };
26
+ std::array<Sensor, kAddresses.size()> sensors;
27
+ std::mutex sensorMutex;
28
+
29
+ bool detach(Sensor &sensor) {
30
+ sensor.initialized = false;
31
+ // A failed removal retains the adapter context for a later close/open
32
+ // retry. Never discard that pointer or delete the shared I2C bus.
33
+ return !sensor.device.intf_ptr ||
34
+ bmm150_interface_deinit_device(&sensor.device) == ESP_OK;
35
+ }
36
+
37
+ bool firstConversion(bmm150_dev &device) {
38
+ for (unsigned elapsed = 0; elapsed <= 200; elapsed += 5) {
39
+ std::uint8_t status = 0;
40
+ if (bmm150_get_regs(BMM150_REG_DATA_READY_STATUS, &status, 1, &device) !=
41
+ BMM150_OK)
42
+ return false;
43
+ if (status & BMM150_DRDY_STATUS_MSK)
44
+ return true;
45
+ if (elapsed < 200)
46
+ vTaskDelay(pdMS_TO_TICKS(5));
47
+ }
48
+ return false;
49
+ }
50
+
51
+ bool readSensor(unsigned index, MagnetometerReading &out) {
52
+ out = {};
53
+ if (index >= sensors.size() || !sensors[index].initialized)
54
+ return false;
55
+ bmm150_mag_data reading{};
56
+ if (bmm150_read_mag_data(&reading, &sensors[index].device) != BMM150_OK)
57
+ return false;
58
+ out.x = reading.x;
59
+ out.y = reading.y;
60
+ out.z = reading.z;
61
+ const auto saturated = [](std::int16_t value) {
62
+ return value <= -30000 || value >= 30000;
63
+ };
64
+ out.saturatedAxes = (saturated(out.x) ? 1U : 0U) |
65
+ (saturated(out.y) ? 2U : 0U) |
66
+ (saturated(out.z) ? 4U : 0U);
67
+ out.valid = true;
68
+ return true;
69
+ }
70
+ } // namespace
71
+
72
+ extern "C" unsigned gea_magnetometer_count() { return sensors.size(); }
73
+
74
+ extern "C" bool gea_magnetometer_open() {
75
+ std::lock_guard lock(sensorMutex);
76
+ bool complete = true;
77
+ for (const auto &sensor : sensors)
78
+ complete = complete && sensor.initialized;
79
+ if (complete)
80
+ return true;
81
+ gea::platform::board::powerOnRails();
82
+ const auto bus = gea::platform::i2c::Bus::primary();
83
+ if (!bus.available())
84
+ return false;
85
+ for (unsigned index = 0; index < sensors.size(); ++index) {
86
+ auto &sensor = sensors[index];
87
+ if (sensor.initialized)
88
+ continue;
89
+ if (!detach(sensor) ||
90
+ bmm150_interface_init_from_master_bus(
91
+ &sensor.device,
92
+ static_cast<i2c_master_bus_handle_t>(bus.nativeHandle()),
93
+ kAddresses[index], 400000) != ESP_OK)
94
+ return false;
95
+ bmm150_settings settings{};
96
+ settings.pwr_mode = BMM150_POWERMODE_NORMAL;
97
+ settings.preset_mode = BMM150_PRESETMODE_REGULAR;
98
+ if (bmm150_init(&sensor.device) != BMM150_OK ||
99
+ bmm150_set_op_mode(&settings, &sensor.device) != BMM150_OK ||
100
+ bmm150_set_presetmode(&settings, &sensor.device) != BMM150_OK ||
101
+ !firstConversion(sensor.device)) {
102
+ (void)detach(sensor);
103
+ return false;
104
+ }
105
+ sensor.initialized = true;
106
+ }
107
+ return true;
108
+ }
109
+
110
+ extern "C" void gea_magnetometer_close() {
111
+ std::lock_guard lock(sensorMutex);
112
+ for (auto &sensor : sensors)
113
+ (void)detach(sensor);
114
+ }
115
+
116
+ extern "C" bool gea_magnetometer_read(unsigned index,
117
+ MagnetometerReading *out) {
118
+ if (!out)
119
+ return false;
120
+ std::lock_guard lock(sensorMutex);
121
+ const bool valid = readSensor(index, *out);
122
+ out->timestampUs = static_cast<std::uint64_t>(esp_timer_get_time());
123
+ return valid;
124
+ }
125
+
126
+ extern "C" bool gea_magnetometer_read_all(MagnetometerReading *out,
127
+ std::size_t capacity) {
128
+ if (!out || capacity < sensors.size())
129
+ return false;
130
+ std::lock_guard lock(sensorMutex);
131
+ bool valid = true;
132
+ for (unsigned index = 0; index < sensors.size(); ++index) {
133
+ const bool current = readSensor(index, out[index]);
134
+ valid = valid && current;
135
+ }
136
+ const auto timestamp = static_cast<std::uint64_t>(esp_timer_get_time());
137
+ for (unsigned index = 0; index < sensors.size(); ++index)
138
+ out[index].timestampUs = timestamp;
139
+ return valid;
140
+ }
@@ -8,6 +8,9 @@
8
8
 
9
9
  #include "driver/gpio.h"
10
10
  #include "esp_attr.h"
11
+ #if GEA_EMBEDDED_TOUCH_TASK_STACK_EXTERNAL
12
+ #include "esp_heap_caps.h"
13
+ #endif
11
14
  #include "esp_lcd_panel_io.h"
12
15
  // The CST92xx family shares this binding. A board whose controller is the
13
16
  // CST9220 (the ESP-Mosaico) sets GEA_BOARD_TOUCH_CST9220: that part speaks
@@ -113,8 +116,14 @@ esp_err_t TouchController::begin()
113
116
  if (!bus.available()) return ESP_ERR_INVALID_STATE;
114
117
  bus_ = static_cast<i2c_master_bus_handle_t>(bus.nativeHandle());
115
118
 
116
- esp_err_t err = attachTouchDevice();
117
- if (err != ESP_OK) return err;
119
+ // Retain a successfully attached device if task allocation fails, so a
120
+ // later begin() retries only the task instead of attaching the bus twice.
121
+ esp_err_t err = ESP_OK;
122
+ if (!deviceAttached_) {
123
+ err = attachTouchDevice();
124
+ if (err != ESP_OK) return err;
125
+ deviceAttached_ = true;
126
+ }
118
127
 
119
128
  err = startTask();
120
129
  if (err != ESP_OK) return err;
@@ -193,9 +202,24 @@ esp_err_t TouchController::attachTouchDevice()
193
202
 
194
203
  esp_err_t TouchController::startTask()
195
204
  {
196
- task_ = xTaskCreateStatic(taskEntry, "cst9217-touch", static_cast<std::uint32_t>(sizeof(taskStack_) / sizeof(taskStack_[0])),
205
+ if (task_) return ESP_OK;
206
+ #if GEA_EMBEDDED_TOUCH_TASK_STACK_EXTERNAL
207
+ // Keep the controller and TCB internal: the CST9220 ISR reads task_ through
208
+ // its address. Only the polling task's stack follows the external option.
209
+ taskStack_ = static_cast<StackType_t *>(
210
+ heap_caps_malloc(kTaskStackBytes, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT));
211
+ if (!taskStack_) {
212
+ ESP_LOGE(kTag, "Failed to allocate touch task stack");
213
+ return ESP_ERR_NO_MEM;
214
+ }
215
+ #endif
216
+ task_ = xTaskCreateStatic(taskEntry, "cst9217-touch", static_cast<std::uint32_t>(kTaskStackBytes),
197
217
  this, kTaskPriority, taskStack_, &taskControlBlock_);
198
218
  if (task_) return ESP_OK;
219
+ #if GEA_EMBEDDED_TOUCH_TASK_STACK_EXTERNAL
220
+ heap_caps_free(taskStack_);
221
+ taskStack_ = nullptr;
222
+ #endif
199
223
  ESP_LOGE(kTag, "Failed to start touch task");
200
224
  return ESP_ERR_NO_MEM;
201
225
  }
@@ -12,6 +12,10 @@
12
12
  #include "freertos/FreeRTOS.h"
13
13
  #include "freertos/task.h"
14
14
 
15
+ #ifndef GEA_EMBEDDED_TOUCH_TASK_STACK_EXTERNAL
16
+ #define GEA_EMBEDDED_TOUCH_TASK_STACK_EXTERNAL 0
17
+ #endif
18
+
15
19
  namespace gea::platform::esp32::chip_bindings::cst9217 {
16
20
 
17
21
  struct TouchSample {
@@ -50,7 +54,7 @@ private:
50
54
  void notifyPointer(Phase phase, bool touching, int x, int y, int pointerId);
51
55
  void notifyMove(const TouchSample &sample);
52
56
 
53
- static constexpr std::size_t kTaskStackWords = 4096;
57
+ static constexpr std::size_t kTaskStackBytes = 4096;
54
58
  static constexpr int kMaxFingers = 2;
55
59
 
56
60
  struct MultiSample {
@@ -62,12 +66,17 @@ private:
62
66
  MultiSample readMulti();
63
67
 
64
68
  bool initialized_ = false;
69
+ bool deviceAttached_ = false;
65
70
  i2c_master_bus_handle_t bus_ = nullptr;
66
71
  esp_lcd_panel_io_handle_t io_ = nullptr;
67
72
  esp_lcd_touch_handle_t touch_ = nullptr;
68
73
  TaskHandle_t task_ = nullptr;
69
74
  StaticTask_t taskControlBlock_ = {};
70
- StackType_t taskStack_[kTaskStackWords] = {};
75
+ #if GEA_EMBEDDED_TOUCH_TASK_STACK_EXTERNAL
76
+ StackType_t *taskStack_ = nullptr;
77
+ #else
78
+ StackType_t taskStack_[kTaskStackBytes / sizeof(StackType_t)] = {};
79
+ #endif
71
80
  TouchSample current_ = {};
72
81
  TouchSample latestMove_ = {};
73
82
  std::atomic<bool> latestMoveQueued_{false};
@@ -14,8 +14,8 @@ include("${GEA_EMBEDDED_ROOT}/targets/esp32/gea_framework.cmake")
14
14
  # then the only thing that knows what the app needs.
15
15
  set(GEA_EMBEDDED_FRAMEWORK_NETWORK_REQUIRES app_update esp_http_server esp-tls)
16
16
  set(GEA_EMBEDDED_FRAMEWORK_RTC_REQUIRES gea_vpx gea_vp8_peer esp_libsrtp)
17
- if(DEFINED ENV{GEA_EMBEDDED_CAPABILITY_NETWORK}
18
- AND "$ENV{GEA_EMBEDDED_CAPABILITY_NETWORK}" STREQUAL "0")
17
+ if(DEFINED GEA_EMBEDDED_CAPABILITY_NETWORK
18
+ AND "${GEA_EMBEDDED_CAPABILITY_NETWORK}" STREQUAL "0")
19
19
  set(GEA_EMBEDDED_FRAMEWORK_NETWORK_REQUIRES "")
20
20
  elseif(DEFINED CACHE{GEA_EMBEDDED_CAPABILITY_NETWORK}
21
21
  AND "$CACHE{GEA_EMBEDDED_CAPABILITY_NETWORK}" STREQUAL "0")
@@ -25,9 +25,9 @@ endif()
25
25
  # HTTP/Wi-Fi alone does not require a WebRTC transport or its codecs. Keep the
26
26
  # historical default unless the app explicitly excludes RTC.
27
27
  set(_GEA_FRAMEWORK_RTC_ENABLED 1)
28
- if(DEFINED ENV{GEA_EMBEDDED_CAPABILITY_RTC}
29
- AND NOT "$ENV{GEA_EMBEDDED_CAPABILITY_RTC}" STREQUAL "")
30
- set(_GEA_FRAMEWORK_RTC_ENABLED "$ENV{GEA_EMBEDDED_CAPABILITY_RTC}")
28
+ if(DEFINED GEA_EMBEDDED_CAPABILITY_RTC
29
+ AND NOT "${GEA_EMBEDDED_CAPABILITY_RTC}" STREQUAL "")
30
+ set(_GEA_FRAMEWORK_RTC_ENABLED "${GEA_EMBEDDED_CAPABILITY_RTC}")
31
31
  elseif(DEFINED CACHE{GEA_EMBEDDED_CAPABILITY_RTC})
32
32
  set(_GEA_FRAMEWORK_RTC_ENABLED "$CACHE{GEA_EMBEDDED_CAPABILITY_RTC}")
33
33
  endif()
@@ -35,6 +35,10 @@ if(NOT GEA_EMBEDDED_FRAMEWORK_NETWORK_REQUIRES OR NOT _GEA_FRAMEWORK_RTC_ENABLED
35
35
  set(GEA_EMBEDDED_FRAMEWORK_RTC_REQUIRES "")
36
36
  endif()
37
37
 
38
+ if(GEA_APP_CAPABILITY_DEPENDENCIES)
39
+ list(APPEND GEA_EMBEDDED_APP_COMPONENT_REQUIRES gea_app_dependencies)
40
+ endif()
41
+
38
42
  idf_component_register(
39
43
  SRCS
40
44
  ${GEA_FW_CXX_SOURCES}
@@ -0,0 +1,22 @@
1
+ # Windows hosts: picolibc's specs reach its libstdc++ multilib headers through
2
+ # `<gcc>/bin/../<triple>/../picolibc/include/../<triple>/include/c++/...`.
3
+ # GCC opens that spelling unnormalised, and under a typical user profile the
4
+ # deepest header (bits/error_constants.h, pulled in by <cmath> on GCC 16)
5
+ # crosses Windows' 260-character MAX_PATH, so the include fails as "No such
6
+ # file". --picolibc-prefix makes the specs start from the toolchain root
7
+ # instead, which drops the bin/../<triple>/.. detour. Linking reads the same
8
+ # specs, and COMPILE_OPTIONS also reach the link line through CMAKE_CXX_FLAGS.
9
+ #
10
+ # Only for GCC 16 (ESP-IDF 6.2), whose <cmath> reaches that header. GCC 15
11
+ # (ESP-IDF 6.0) does not need it, and there the option is rejected outright
12
+ # ("unrecognized command-line option") by every compile that is not given
13
+ # picolibc's specs, as esp_wifi_remote's are not on the P4.
14
+ if(CMAKE_HOST_WIN32 AND NOT IDF_CUSTOM_TOOLCHAIN AND CONFIG_IDF_TOOLCHAIN_GCC AND CONFIG_LIBC_PICOLIBC)
15
+ get_filename_component(_gea_toolchain_bin "${CMAKE_C_COMPILER}" DIRECTORY)
16
+ get_filename_component(_gea_toolchain_root "${_gea_toolchain_bin}/.." ABSOLUTE)
17
+ execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpversion
18
+ OUTPUT_VARIABLE _gea_toolchain_version OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
19
+ if(_gea_toolchain_version VERSION_GREATER_EQUAL 16 AND EXISTS "${_gea_toolchain_root}/picolibc/include")
20
+ idf_toolchain_add_flags(COMPILE_OPTIONS "--picolibc-prefix=${_gea_toolchain_root}")
21
+ endif()
22
+ endif()