@geastack/targets 0.1.86 → 0.1.88

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 (86) hide show
  1. package/package.json +7 -7
  2. package/targets/esp32/app_project.cmake +18 -1
  3. package/targets/esp32/chip_bindings/audio/echo_cancellation.cpp +213 -0
  4. package/targets/esp32/chip_bindings/audio/echo_cancellation.h +12 -0
  5. package/targets/esp32/chip_bindings/audio/es8311.cpp +280 -41
  6. package/targets/esp32/chip_bindings/displays/rgb_panel.cpp +115 -12
  7. package/targets/esp32/chip_bindings/expanders/io_expander.h +2 -0
  8. package/targets/esp32/chip_bindings/expanders/tca9554.cpp +74 -0
  9. package/targets/esp32/chip_bindings/touch/ft3168.cpp +23 -1
  10. package/targets/esp32/chip_bindings/touch/ft3168_controller.h +1 -0
  11. package/targets/esp32/chip_bindings/touch/gt911.cpp +4 -3
  12. package/targets/esp32/components/gea_framework/CMakeLists.txt +8 -1
  13. package/targets/esp32/components/gea_juice/CMakeLists.txt +46 -0
  14. package/targets/esp32/components/gea_juice/README.md +20 -0
  15. package/targets/esp32/components/gea_juice/juice_memory.c +19 -0
  16. package/targets/esp32/components/gea_juice/juice_memory.h +16 -0
  17. package/targets/esp32/components/gea_juice/patch_threads.py +50 -0
  18. package/targets/esp32/components/gea_vp8_peer/CMakeLists.txt +16 -0
  19. package/targets/esp32/components/gea_vp8_peer/README.md +39 -0
  20. package/targets/esp32/components/gea_vp8_peer/gea_vp8_peer.h +21 -0
  21. package/targets/esp32/components/gea_vp8_peer/vp8_peer.cpp +538 -0
  22. package/targets/esp32/components/gea_vpx/CMakeLists.txt +235 -0
  23. package/targets/esp32/components/gea_vpx/README.md +133 -0
  24. package/targets/esp32/components/gea_vpx/i420_rgb565_s3.S +169 -0
  25. package/targets/esp32/components/gea_vpx/vp8_blocks_s3.c +42 -0
  26. package/targets/esp32/components/gea_vpx/vp8_copy_s3.S +39 -0
  27. package/targets/esp32/components/gea_vpx/vp8_entropy_s3.c +76 -0
  28. package/targets/esp32/components/gea_vpx/vp8_filter_s3.S +58 -0
  29. package/targets/esp32/components/gea_vpx/vp8_idct_s3.S +269 -0
  30. package/targets/esp32/components/gea_vpx/vp8_intrapred_s3.S +65 -0
  31. package/targets/esp32/components/gea_vpx/vp8_loopfilter_s3.S +333 -0
  32. package/targets/esp32/components/gea_vpx/vp8_loopfilter_s3.c +62 -0
  33. package/targets/esp32/components/gea_vpx/vp8_profile_s3.c +22 -0
  34. package/targets/esp32/components/gea_vpx/vp8_profile_s3.h +20 -0
  35. package/targets/esp32/components/gea_vpx/vp8_s3.c +120 -0
  36. package/targets/esp32/components/gea_vpx/vp8_s3.h +58 -0
  37. package/targets/esp32/components/gea_vpx/vp8_workspace_s3.c +14 -0
  38. package/targets/esp32/components/gea_vpx/vpx_memory.c +41 -0
  39. package/targets/esp32/connectivity/diagnostics_transport.cpp +18 -0
  40. package/targets/esp32/connectivity/wifi.cpp +26 -13
  41. package/targets/esp32/crypto/srtp_hmac_psa.c +118 -0
  42. package/targets/esp32/display.cpp +13 -0
  43. package/targets/esp32/gea_framework.cmake +7 -0
  44. package/targets/esp32/host_sources.cmake +2 -0
  45. package/targets/esp32/i2c_completion_order.cmake +57 -0
  46. package/targets/esp32/patch_streaming_dependencies.py +233 -0
  47. package/targets/esp32/services/device_control.cpp +141 -5
  48. package/targets/esp32/services/frame_scheduler.cpp +29 -1
  49. package/targets/esp32/services/opus_benchmark.h +82 -0
  50. package/targets/esp32/services/pcm_simd_check.h +73 -0
  51. package/targets/esp32/services/srtp_benchmark.h +106 -0
  52. package/targets/esp32/services/video_simd_benchmark.h +477 -0
  53. package/targets/esp32/services/vp8_benchmark.h +147 -0
  54. package/targets/esp32/streaming_dependency_patches.cmake +103 -0
  55. package/targets/esp32-m5stack-m5paper/main/idf_component.yml +2 -0
  56. package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +2 -0
  57. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +2 -0
  58. package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +2 -0
  59. package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +2 -0
  60. package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +2 -0
  61. package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +2 -0
  62. package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +2 -0
  63. package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +2 -0
  64. package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +2 -0
  65. package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +110 -2
  66. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +29 -3
  67. package/targets/esp32-s3-touch-amoled-1.8/main/app_main.cpp +6 -3
  68. package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +11 -0
  69. package/targets/esp32-s3-touch-amoled-1.8/sdkconfig.defaults +9 -1
  70. package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +2 -0
  71. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +171 -8
  72. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +9 -2
  73. package/targets/esp32-s3-touch-amoled-2.06/main/app_main.cpp +10 -3
  74. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +16 -1
  75. package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +3 -0
  76. package/targets/esp32-s3-touch-amoled-2.06/main/touch.cpp +7 -0
  77. package/targets/esp32-s3-touch-amoled-2.41/dependencies.lock +57 -1
  78. package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +10 -0
  79. package/targets/esp32-s3-touch-lcd-3.5b/dependencies.lock +12 -1
  80. package/targets/esp32-s3-touch-lcd-3.5b/main/CMakeLists.txt +5 -1
  81. package/targets/esp32-s3-touch-lcd-3.5b/main/idf_component.yml +2 -1
  82. package/targets/esp32-s3-touch-lcd-3.5b/main/include/board.h +3 -0
  83. package/targets/esp32-s3-touch-lcd-3.5b/main/platform_stubs.cpp +1 -18
  84. package/targets/esp32-s3-touch-lcd-3.5b/main/speaker_power.cpp +27 -0
  85. package/targets/esp32-s3-waveshare-touch-lcd-4b.json +504 -0
  86. package/targets.json +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/targets",
3
- "version": "0.1.86",
3
+ "version": "0.1.88",
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": {
@@ -36,14 +36,14 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@geastack/chips": "^0.1.4",
39
+ "@geastack/chips": "^0.1.5",
40
40
  "@geastack/compiler": "^1.0.20",
41
- "@geastack/core": "^0.1.31",
42
- "@geastack/elements": "^0.1.3",
43
- "@geastack/engine": "^0.1.8",
41
+ "@geastack/core": "^0.1.34",
42
+ "@geastack/elements": "^0.1.4",
43
+ "@geastack/engine": "^0.1.9",
44
44
  "@geastack/geaos": "^0.1.3",
45
- "@geastack/geatsc-plugin-gea": "^0.1.13",
46
- "@geastack/host": "^0.1.10"
45
+ "@geastack/geatsc-plugin-gea": "^0.1.15",
46
+ "@geastack/host": "^0.1.11"
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"
@@ -18,6 +18,14 @@ foreach(_GEA_APP_COMPONENT_DIR IN LISTS GEA_EMBEDDED_APP_COMPONENT_DIRS)
18
18
  list(APPEND EXTRA_COMPONENT_DIRS "${_GEA_APP_COMPONENT_DIR}")
19
19
  endforeach()
20
20
 
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")
27
+ endif()
28
+
21
29
  # The managed-dependency manifests (main/idf_component.yml) gate the registry
22
30
  # components that belong to one capability -- the codec, the WebSocket client,
23
31
  # the WebRTC peer -- on these variables, and the component manager treats an
@@ -28,6 +36,15 @@ endforeach()
28
36
  foreach(_GEA_CAPABILITY NETWORK BLE AUDIO)
29
37
  if(NOT DEFINED ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}
30
38
  OR "$ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}}" STREQUAL "")
31
- set(ENV{GEA_EMBEDDED_CAPABILITY_${_GEA_CAPABILITY}} "1")
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()
32
49
  endif()
33
50
  endforeach()
@@ -0,0 +1,213 @@
1
+ // Official Espressif ESP-SR AEC; adapter only, no custom cancellation DSP.
2
+ #include "echo_cancellation.h"
3
+ #include "esp_aec.h"
4
+ #include "esp_heap_caps.h"
5
+ #include "esp_log.h"
6
+ #include "esp_timer.h"
7
+ #include "freertos/FreeRTOS.h"
8
+ #include <algorithm>
9
+ #include <atomic>
10
+ #include <cmath>
11
+ #include <cstdint>
12
+ #include <cstdio>
13
+ #include <cstring>
14
+ #include <mutex>
15
+
16
+ namespace {
17
+ constexpr uint32_t kMaxFrame = 512, kDmaFrames = 240, kCaptureRing = 1024;
18
+ portMUX_TYPE dmaMux = portMUX_INITIALIZER_UNLOCKED;
19
+ int16_t dmaMic[kCaptureRing]{}, dmaRef[kCaptureRing]{};
20
+ int16_t previousMic[kDmaFrames]{}, latestTx[kDmaFrames]{}, captureRef[320]{};
21
+ uint32_t dmaWritten = 0, dmaRead = 0, dmaDrops = 0;
22
+ bool dmaActive = false, previousMicReady = false;
23
+ bool hardwareReference = false;
24
+ std::mutex aecMutex;
25
+ aec_handle_t *aec = nullptr;
26
+ alignas(16) int16_t mic[kMaxFrame], ref[kMaxFrame], clean[kMaxFrame],
27
+ output[kMaxFrame * 2];
28
+ size_t fill = 0, frameSize = 0;
29
+
30
+ uint64_t rawEnergy = 0, cleanEnergy = 0, refEnergy = 0, totalSamples = 0;
31
+ int64_t logAt = 0, processUs = 0;
32
+ uint32_t processedFrames = 0, clippedSamples = 0, clippedReferenceSamples = 0;
33
+ int rawPeak = 0, cleanPeak = 0, referencePeak = 0;
34
+ } // namespace
35
+
36
+ bool geaAudioAecStart(bool useHardwareReference) {
37
+ std::lock_guard<std::mutex> lock(aecMutex);
38
+ if (aec)
39
+ return true;
40
+ aec_config_t config{};
41
+ config.mic_num = 1;
42
+ config.ref_num = 1;
43
+ config.out_num = 1;
44
+ config.filter_length = 4;
45
+ config.sample_rate = 16000;
46
+ config.caps = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT;
47
+ config.mode = AEC_MODE_FD_HIGH_PERF;
48
+ // Use ESP-SR's default residual echo suppression in full-duplex mode.
49
+ // NORMAL leaked the opening into server VAD before the adaptive filter
50
+ // converged. This is AEC NLP, not noise suppression or a playback mic gate.
51
+ config.nlp_level = AEC_NLP_LEVEL_AGGR;
52
+ aec = aec_create_from_config(&config);
53
+ if (!aec) {
54
+ ESP_LOGE("gea_aec", "ESP-SR AEC allocation failed");
55
+ return false;
56
+ }
57
+ frameSize = aec_get_chunksize(aec);
58
+ if (!frameSize || frameSize > kMaxFrame) {
59
+ ESP_LOGE("gea_aec", "Unsupported AEC frame size %u", unsigned(frameSize));
60
+ aec_destroy(aec);
61
+ aec = nullptr;
62
+ return false;
63
+ }
64
+ fill = 0;
65
+ portENTER_CRITICAL(&dmaMux);
66
+ dmaWritten = dmaRead = dmaDrops = 0;
67
+ previousMicReady = false;
68
+ hardwareReference = useHardwareReference;
69
+ std::memset(latestTx, 0, sizeof(latestTx));
70
+ dmaActive = true;
71
+ portEXIT_CRITICAL(&dmaMux);
72
+ rawEnergy = cleanEnergy = refEnergy = totalSamples = 0;
73
+ processUs = processedFrames = clippedSamples = clippedReferenceSamples = 0;
74
+ rawPeak = cleanPeak = referencePeak = 0;
75
+ logAt = esp_timer_get_time();
76
+ ESP_LOGI("gea_aec",
77
+ "ESP-SR full-duplex high-performance AEC ready: rate=16000 frame=%u NLP=aggressive "
78
+ "reference=%s internal_free=%u",
79
+ unsigned(frameSize), hardwareReference ? "ADC" : "TX-DMA",
80
+ unsigned(heap_caps_get_free_size(MALLOC_CAP_INTERNAL)));
81
+ return true;
82
+ }
83
+
84
+ void geaAudioAecStop() {
85
+ std::lock_guard<std::mutex> lock(aecMutex);
86
+ portENTER_CRITICAL(&dmaMux);
87
+ dmaActive = false;
88
+ portEXIT_CRITICAL(&dmaMux);
89
+ if (aec) {
90
+ aec_destroy(aec);
91
+ aec = nullptr;
92
+ }
93
+ fill = 0;
94
+ }
95
+
96
+ // The RX/TX callbacks run on the I2S clock, independently of task scheduling.
97
+ // Retain one RX block so the reference always precedes its acoustic echo.
98
+ void geaAudioAecReference(const int16_t *pcm, size_t count) {
99
+ portENTER_CRITICAL_ISR(&dmaMux);
100
+ if (dmaActive && count == kDmaFrames)
101
+ std::memcpy(latestTx, pcm, sizeof(latestTx));
102
+ else if (dmaActive && count == kDmaFrames * 2) {
103
+ for (size_t i = 0; i < kDmaFrames; ++i)
104
+ latestTx[i] = int16_t((int32_t(pcm[i * 2]) + pcm[i * 2 + 1]) / 2);
105
+ }
106
+ portEXIT_CRITICAL_ISR(&dmaMux);
107
+ }
108
+ void geaAudioAecReceive(const int16_t *stereo, size_t count) {
109
+ portENTER_CRITICAL_ISR(&dmaMux);
110
+ if (dmaActive && count == kDmaFrames * 2) {
111
+ if (hardwareReference) {
112
+ // MIC1 and the analog playback loopback are captured in the same ADC
113
+ // frame. They must stay paired across callback/task scheduling jitter.
114
+ if (dmaWritten - dmaRead + kDmaFrames > kCaptureRing) {
115
+ dmaRead = dmaWritten;
116
+ ++dmaDrops;
117
+ }
118
+ for (size_t i = 0; i < kDmaFrames; ++i) {
119
+ dmaMic[(dmaWritten + i) % kCaptureRing] = stereo[i * 2];
120
+ dmaRef[(dmaWritten + i) % kCaptureRing] = stereo[i * 2 + 1];
121
+ }
122
+ dmaWritten += kDmaFrames;
123
+ portEXIT_CRITICAL_ISR(&dmaMux);
124
+ return;
125
+ }
126
+ if (previousMicReady) {
127
+ if (dmaWritten - dmaRead + kDmaFrames > kCaptureRing) {
128
+ dmaRead = dmaWritten;
129
+ ++dmaDrops;
130
+ }
131
+ for (size_t i = 0; i < kDmaFrames; ++i) {
132
+ dmaMic[(dmaWritten + i) % kCaptureRing] = previousMic[i];
133
+ dmaRef[(dmaWritten + i) % kCaptureRing] = latestTx[i];
134
+ }
135
+ dmaWritten += kDmaFrames;
136
+ }
137
+ for (size_t i = 0; i < kDmaFrames; ++i)
138
+ previousMic[i] = stereo[i * 2];
139
+ previousMicReady = true;
140
+ }
141
+ portEXIT_CRITICAL_ISR(&dmaMux);
142
+ }
143
+ bool geaAudioAecRead(int16_t *pcm, size_t count) {
144
+ if (count > 320)
145
+ return false;
146
+ portENTER_CRITICAL(&dmaMux);
147
+ const bool ready = dmaActive && dmaWritten - dmaRead >= count;
148
+ if (ready) {
149
+ for (size_t i = 0; i < count; ++i) {
150
+ pcm[i] = dmaMic[(dmaRead + i) % kCaptureRing];
151
+ captureRef[i] = dmaRef[(dmaRead + i) % kCaptureRing];
152
+ }
153
+ dmaRead += count;
154
+ }
155
+ portEXIT_CRITICAL(&dmaMux);
156
+ return ready;
157
+ }
158
+
159
+ size_t geaAudioAecProcess(const int16_t *pcm, size_t count,
160
+ const int16_t **result) {
161
+ std::lock_guard<std::mutex> lock(aecMutex);
162
+ *result = output;
163
+ if (!aec)
164
+ return 0; // Never silently forward uncancelled audio after an AEC failure.
165
+ size_t produced = 0;
166
+ for (size_t i = 0; i < count; ++i) {
167
+ mic[fill] = pcm[i];
168
+ ref[fill] = captureRef[i];
169
+ if (++fill == frameSize) {
170
+ for (size_t j = 0; j < frameSize; ++j) {
171
+ rawPeak = std::max(rawPeak, std::abs(int(mic[j])));
172
+ referencePeak = std::max(referencePeak, std::abs(int(ref[j])));
173
+ clippedSamples += std::abs(int(mic[j])) >= 32760;
174
+ clippedReferenceSamples += std::abs(int(ref[j])) >= 32760;
175
+ rawEnergy += int64_t(mic[j]) * mic[j];
176
+ refEnergy += int64_t(ref[j]) * ref[j];
177
+ }
178
+ auto before = esp_timer_get_time();
179
+ aec_process(aec, mic, ref, clean);
180
+ processUs += esp_timer_get_time() - before;
181
+ ++processedFrames;
182
+ for (size_t j = 0; j < frameSize; ++j) {
183
+ cleanEnergy += int64_t(clean[j]) * clean[j];
184
+ cleanPeak = std::max(cleanPeak, std::abs(int(clean[j])));
185
+ }
186
+ totalSamples += frameSize;
187
+ // Publish the actual cancelled signal. Makeup gain also amplifies the
188
+ // residual speaker echo and undoes the suppression we just measured.
189
+ // Do not gate this signal on playback: near-end speech must always pass.
190
+ std::memcpy(output + produced, clean, frameSize * sizeof(int16_t));
191
+ produced += frameSize;
192
+ fill = 0;
193
+ }
194
+ }
195
+ const auto now = esp_timer_get_time();
196
+ if (now - logAt >= 1000000 && totalSamples) {
197
+ ESP_LOGI("gea_aec",
198
+ "raw_rms=%.0f clean_rms=%.0f ref_rms=%.0f reduction_db=%.1f "
199
+ "process_us=%lld dma_drops=%lu clipped=%lu ref_clipped=%lu raw_peak=%d clean_peak=%d ref_peak=%d",
200
+ std::sqrt(double(rawEnergy) / totalSamples),
201
+ std::sqrt(double(cleanEnergy) / totalSamples),
202
+ std::sqrt(double(refEnergy) / totalSamples),
203
+ 10 * std::log10(double(rawEnergy + 1) / double(cleanEnergy + 1)),
204
+ (long long)(processUs / std::max<uint32_t>(1, processedFrames)),
205
+ (unsigned long)dmaDrops, (unsigned long)clippedSamples,
206
+ (unsigned long)clippedReferenceSamples, rawPeak, cleanPeak, referencePeak);
207
+ rawEnergy = cleanEnergy = refEnergy = totalSamples = 0;
208
+ rawPeak = cleanPeak = referencePeak = 0;
209
+ processUs = processedFrames = clippedSamples = clippedReferenceSamples = 0;
210
+ logAt = now;
211
+ }
212
+ return produced;
213
+ }
@@ -0,0 +1,12 @@
1
+ #pragma once
2
+
3
+ #include <cstddef>
4
+ #include <cstdint>
5
+
6
+ bool geaAudioAecStart(bool hardwareReference = false);
7
+ void geaAudioAecStop();
8
+ void geaAudioAecReference(const int16_t *pcm, size_t count);
9
+ void geaAudioAecReceive(const int16_t *stereo, size_t count);
10
+ bool geaAudioAecRead(int16_t *pcm, size_t count);
11
+ size_t geaAudioAecProcess(const int16_t *pcm, size_t count,
12
+ const int16_t **result);