@geastack/targets 0.1.88 → 0.1.90

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 (37) hide show
  1. package/build-config.json +32 -0
  2. package/package.json +2 -2
  3. package/targets/cmake/geatsc_generated_archive.cmake +18 -2
  4. package/targets/esp32/chip_bindings/audio/echo_cancellation.cpp +35 -19
  5. package/targets/esp32/chip_bindings/audio/echo_cancellation.h +2 -1
  6. package/targets/esp32/chip_bindings/audio/es8311.cpp +45 -8
  7. package/targets/esp32/chip_bindings/displays/co5300.cpp +40 -0
  8. package/targets/esp32/chip_bindings/imu/bmi270.cpp +6 -1
  9. package/targets/esp32/connectivity/wifi.cpp +4 -0
  10. package/targets/esp32/display.cpp +23 -0
  11. package/targets/esp32/services/audio_runtime_stub.cpp +2 -0
  12. package/targets/esp32/services/device_control.cpp +75 -9
  13. package/targets/esp32/services/frame_scheduler.cpp +7 -0
  14. package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +15 -5
  15. package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +16 -1
  16. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +5 -1
  17. package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +4 -0
  18. package/targets/esp32-s3-touch-amoled-1.8/main/include/board.h +12 -0
  19. package/targets/esp32-s3-touch-amoled-1.8/main/launcher_button.cpp +6 -1
  20. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +3 -2
  21. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +1 -0
  22. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +5 -0
  23. package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +7 -0
  24. package/targets/esp32-s31-espressif-mosaico/CMakeLists.txt +10 -0
  25. package/targets/esp32-s31-espressif-mosaico/README.md +56 -0
  26. package/targets/esp32-s31-espressif-mosaico/dependencies.lock +137 -0
  27. package/targets/esp32-s31-espressif-mosaico/main/CMakeLists.txt +63 -0
  28. package/targets/esp32-s31-espressif-mosaico/main/Kconfig.projbuild +12 -0
  29. package/targets/esp32-s31-espressif-mosaico/main/board_power.cpp +386 -0
  30. package/targets/esp32-s31-espressif-mosaico/main/idf_component.yml +36 -0
  31. package/targets/esp32-s31-espressif-mosaico/main/include/board.h +147 -0
  32. package/targets/esp32-s31-espressif-mosaico/main/include/wifi_config.h.example +5 -0
  33. package/targets/esp32-s31-espressif-mosaico/main/touch.cpp +45 -0
  34. package/targets/esp32-s31-espressif-mosaico/partitions.csv +10 -0
  35. package/targets/esp32-s31-espressif-mosaico/sdkconfig.defaults +194 -0
  36. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.cpp +3 -0
  37. package/targets.json +12 -0
package/build-config.json CHANGED
@@ -516,6 +516,38 @@
516
516
  false
517
517
  ]
518
518
  }
519
+ },
520
+ "esp32-s31-espressif-mosaico": {
521
+ "supported": [
522
+ "compiler.generatedCodeOptimization",
523
+ "renderer.fuseReplayFlush",
524
+ "renderer.adaptiveCoalescing",
525
+ "renderer.broadDirtyBounds",
526
+ "display.framebufferStream",
527
+ "display.presentStream"
528
+ ],
529
+ "defaults": {
530
+ "compiler": {
531
+ "generatedCodeOptimization": "O2",
532
+ "numberPrecision": "float32"
533
+ },
534
+ "renderer": {
535
+ "fuseReplayFlush": false,
536
+ "subtreeRevealChecks": true,
537
+ "recordInlinePositions": true,
538
+ "adaptiveCoalescing": true,
539
+ "broadDirtyBounds": true
540
+ },
541
+ "display": {
542
+ "framebufferStream": "continuous",
543
+ "presentStream": "continuous"
544
+ },
545
+ "diagnostics": {
546
+ "performanceCounters": false,
547
+ "frameTiming": false
548
+ }
549
+ },
550
+ "cssDevicePixelRatio": 1.5
519
551
  }
520
552
  }
521
553
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/targets",
3
- "version": "0.1.88",
3
+ "version": "0.1.90",
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": {
@@ -43,7 +43,7 @@
43
43
  "@geastack/engine": "^0.1.9",
44
44
  "@geastack/geaos": "^0.1.3",
45
45
  "@geastack/geatsc-plugin-gea": "^0.1.15",
46
- "@geastack/host": "^0.1.11"
46
+ "@geastack/host": "^0.1.14"
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"
@@ -88,6 +88,22 @@ function(gea_geatsc_add_generated_archive)
88
88
  # forward the launcher explicitly to retain clean-build cache hits.
89
89
  get_property(_compiler_launcher GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
90
90
 
91
+ # The archive builder runs outside CMake's rules, so a tool CMake knows only
92
+ # by name would be looked up relative to the build directory. IDF 6.2's
93
+ # RISC-V toolchain file sets CMAKE_AR/CMAKE_RANLIB to bare names
94
+ # (riscv32-esp-elf-gcc-ar); resolve them beside the compiler, then on PATH.
95
+ get_filename_component(_compiler_dir "${CMAKE_CXX_COMPILER}" DIRECTORY)
96
+ foreach(_tool IN ITEMS AR RANLIB)
97
+ set(_tool_path "${CMAKE_${_tool}}")
98
+ if(_tool_path AND NOT IS_ABSOLUTE "${_tool_path}")
99
+ find_program(_resolved_${_tool} NAMES "${_tool_path}" HINTS "${_compiler_dir}" NO_CACHE)
100
+ if(_resolved_${_tool})
101
+ set(_tool_path "${_resolved_${_tool}}")
102
+ endif()
103
+ endif()
104
+ set(_geatsc_${_tool} "${_tool_path}")
105
+ endforeach()
106
+
91
107
  add_custom_command(
92
108
  OUTPUT "${GEA_GEATSC_OUTPUT}"
93
109
  COMMAND "${CMAKE_COMMAND}"
@@ -98,8 +114,8 @@ function(gea_geatsc_add_generated_archive)
98
114
  "-DGEA_GEATSC_FLAGS_FILE=${_flags_file}"
99
115
  "-DGEA_GEATSC_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
100
116
  "-DGEA_GEATSC_COMPILER_LAUNCHER=${_compiler_launcher}"
101
- "-DGEA_GEATSC_AR=${CMAKE_AR}"
102
- "-DGEA_GEATSC_RANLIB=${CMAKE_RANLIB}"
117
+ "-DGEA_GEATSC_AR=${_geatsc_AR}"
118
+ "-DGEA_GEATSC_RANLIB=${_geatsc_RANLIB}"
103
119
  -P "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/geatsc_generated_archive_build.cmake"
104
120
  DEPENDS
105
121
  ${GEA_GEATSC_DEPENDS}
@@ -21,22 +21,26 @@ int16_t previousMic[kDmaFrames]{}, latestTx[kDmaFrames]{}, captureRef[320]{};
21
21
  uint32_t dmaWritten = 0, dmaRead = 0, dmaDrops = 0;
22
22
  bool dmaActive = false, previousMicReady = false;
23
23
  bool hardwareReference = false;
24
+ float outputGain = 1.0f;
24
25
  std::mutex aecMutex;
25
26
  aec_handle_t *aec = nullptr;
26
- alignas(16) int16_t mic[kMaxFrame], ref[kMaxFrame], clean[kMaxFrame],
27
+ alignas(16) int16_t mic[kMaxFrame], ref[kMaxFrame], clean[kMaxFrame], linear[kMaxFrame],
27
28
  output[kMaxFrame * 2];
28
29
  size_t fill = 0, frameSize = 0;
29
30
 
30
- uint64_t rawEnergy = 0, cleanEnergy = 0, refEnergy = 0, totalSamples = 0;
31
+ uint64_t rawEnergy = 0, cleanEnergy = 0, linearEnergy = 0, refEnergy = 0, totalSamples = 0;
31
32
  int64_t logAt = 0, processUs = 0;
32
33
  uint32_t processedFrames = 0, clippedSamples = 0, clippedReferenceSamples = 0;
33
34
  int rawPeak = 0, cleanPeak = 0, referencePeak = 0;
34
35
  } // namespace
35
36
 
36
- bool geaAudioAecStart(bool useHardwareReference) {
37
+ bool geaAudioAecStart(bool useHardwareReference, float gain, bool aggressiveNlp) {
37
38
  std::lock_guard<std::mutex> lock(aecMutex);
38
39
  if (aec)
39
40
  return true;
41
+ if (!std::isfinite(gain) || gain <= 0)
42
+ return false;
43
+ outputGain = gain;
40
44
  aec_config_t config{};
41
45
  config.mic_num = 1;
42
46
  config.ref_num = 1;
@@ -45,10 +49,8 @@ bool geaAudioAecStart(bool useHardwareReference) {
45
49
  config.sample_rate = 16000;
46
50
  config.caps = MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT;
47
51
  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
+ // Select residual echo suppression independently of the output gain.
53
+ config.nlp_level = aggressiveNlp ? AEC_NLP_LEVEL_AGGR : AEC_NLP_LEVEL_NORMAL;
52
54
  aec = aec_create_from_config(&config);
53
55
  if (!aec) {
54
56
  ESP_LOGE("gea_aec", "ESP-SR AEC allocation failed");
@@ -69,14 +71,15 @@ bool geaAudioAecStart(bool useHardwareReference) {
69
71
  std::memset(latestTx, 0, sizeof(latestTx));
70
72
  dmaActive = true;
71
73
  portEXIT_CRITICAL(&dmaMux);
72
- rawEnergy = cleanEnergy = refEnergy = totalSamples = 0;
74
+ rawEnergy = cleanEnergy = linearEnergy = refEnergy = totalSamples = 0;
73
75
  processUs = processedFrames = clippedSamples = clippedReferenceSamples = 0;
74
76
  rawPeak = cleanPeak = referencePeak = 0;
75
77
  logAt = esp_timer_get_time();
76
78
  ESP_LOGI("gea_aec",
77
- "ESP-SR full-duplex high-performance AEC ready: rate=16000 frame=%u NLP=aggressive "
79
+ "ESP-SR full-duplex high-performance AEC ready: rate=16000 frame=%u NLP=%s "
78
80
  "reference=%s internal_free=%u",
79
- unsigned(frameSize), hardwareReference ? "ADC" : "TX-DMA",
81
+ unsigned(frameSize), aggressiveNlp ? "aggressive" : "normal",
82
+ hardwareReference ? "ADC" : "TX-DMA",
80
83
  unsigned(heap_caps_get_free_size(MALLOC_CAP_INTERNAL)));
81
84
  return true;
82
85
  }
@@ -109,8 +112,8 @@ void geaAudioAecReceive(const int16_t *stereo, size_t count) {
109
112
  portENTER_CRITICAL_ISR(&dmaMux);
110
113
  if (dmaActive && count == kDmaFrames * 2) {
111
114
  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.
115
+ // ES7210 analog loopback or ES8311 ADCL + DACR arrive in the same RX
116
+ // frame. Keep them paired across callback/task scheduling jitter.
114
117
  if (dmaWritten - dmaRead + kDmaFrames > kCaptureRing) {
115
118
  dmaRead = dmaWritten;
116
119
  ++dmaDrops;
@@ -176,18 +179,30 @@ size_t geaAudioAecProcess(const int16_t *pcm, size_t count,
176
179
  refEnergy += int64_t(ref[j]) * ref[j];
177
180
  }
178
181
  auto before = esp_timer_get_time();
179
- aec_process(aec, mic, ref, clean);
182
+ // ESP-SR's documented two-stage API preserves both cancellation stages.
183
+ // Snapshot the linear result so telemetry can identify suppression of
184
+ // near-end speech separately from cancellation of the speaker echo.
185
+ aec_linear_process(aec, mic, ref, clean);
186
+ std::memcpy(linear, clean, frameSize * sizeof(int16_t));
187
+ aec_nlp_process(aec, clean);
180
188
  processUs += esp_timer_get_time() - before;
181
189
  ++processedFrames;
182
190
  for (size_t j = 0; j < frameSize; ++j) {
191
+ linearEnergy += int64_t(linear[j]) * linear[j];
183
192
  cleanEnergy += int64_t(clean[j]) * clean[j];
184
193
  cleanPeak = std::max(cleanPeak, std::abs(int(clean[j])));
185
194
  }
186
195
  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));
196
+ // Apply the board's calibrated voice gain after AEC, keeping the ADC
197
+ // unclipped. Unity-gain boards retain the direct copy. Never gate speech.
198
+ if (outputGain == 1.0f) {
199
+ std::memcpy(output + produced, clean, frameSize * sizeof(int16_t));
200
+ } else {
201
+ for (size_t j = 0; j < frameSize; ++j) {
202
+ const float amplified = clean[j] * outputGain;
203
+ output[produced + j] = int16_t(std::lround(std::clamp(amplified, -32768.0f, 32767.0f)));
204
+ }
205
+ }
191
206
  produced += frameSize;
192
207
  fill = 0;
193
208
  }
@@ -195,16 +210,17 @@ size_t geaAudioAecProcess(const int16_t *pcm, size_t count,
195
210
  const auto now = esp_timer_get_time();
196
211
  if (now - logAt >= 1000000 && totalSamples) {
197
212
  ESP_LOGI("gea_aec",
198
- "raw_rms=%.0f clean_rms=%.0f ref_rms=%.0f reduction_db=%.1f "
213
+ "raw_rms=%.0f clean_rms=%.0f ref_rms=%.0f linear_rms=%.0f reduction_db=%.1f "
199
214
  "process_us=%lld dma_drops=%lu clipped=%lu ref_clipped=%lu raw_peak=%d clean_peak=%d ref_peak=%d",
200
215
  std::sqrt(double(rawEnergy) / totalSamples),
201
216
  std::sqrt(double(cleanEnergy) / totalSamples),
202
217
  std::sqrt(double(refEnergy) / totalSamples),
218
+ std::sqrt(double(linearEnergy) / totalSamples),
203
219
  10 * std::log10(double(rawEnergy + 1) / double(cleanEnergy + 1)),
204
220
  (long long)(processUs / std::max<uint32_t>(1, processedFrames)),
205
221
  (unsigned long)dmaDrops, (unsigned long)clippedSamples,
206
222
  (unsigned long)clippedReferenceSamples, rawPeak, cleanPeak, referencePeak);
207
- rawEnergy = cleanEnergy = refEnergy = totalSamples = 0;
223
+ rawEnergy = cleanEnergy = linearEnergy = refEnergy = totalSamples = 0;
208
224
  rawPeak = cleanPeak = referencePeak = 0;
209
225
  processUs = processedFrames = clippedSamples = clippedReferenceSamples = 0;
210
226
  logAt = now;
@@ -3,7 +3,8 @@
3
3
  #include <cstddef>
4
4
  #include <cstdint>
5
5
 
6
- bool geaAudioAecStart(bool hardwareReference = false);
6
+ bool geaAudioAecStart(bool hardwareReference = false, float outputGain = 1.0f,
7
+ bool aggressiveNlp = true);
7
8
  void geaAudioAecStop();
8
9
  void geaAudioAecReference(const int16_t *pcm, size_t count);
9
10
  void geaAudioAecReceive(const int16_t *stereo, size_t count);
@@ -86,6 +86,15 @@ esp_err_t setAmplifierEnabled(bool enabled) {
86
86
 
87
87
  constexpr int kCodecDataPort = 0;
88
88
 
89
+ // esp_codec_dev takes the 8-bit address. CE low answers at 7-bit 0x18, the
90
+ // component default; a board that straps CE high (the ESP-Mosaico, 0x19)
91
+ // names its 7-bit address with GEA_BOARD_ES8311_I2C_ADDRESS.
92
+ #ifdef GEA_BOARD_ES8311_I2C_ADDRESS
93
+ constexpr std::uint8_t kCodecI2cAddress = static_cast<std::uint8_t>(GEA_BOARD_ES8311_I2C_ADDRESS << 1);
94
+ #else
95
+ constexpr std::uint8_t kCodecI2cAddress = ES8311_CODEC_DEFAULT_ADDR;
96
+ #endif
97
+
89
98
  // Boards whose microphones sit on an ES7210 ADC sharing this I2S bus (Waveshare AMOLED 2.06) name its
90
99
  // 7-bit I2C address as `audio.es7210Address`; everywhere else the ES8311's own ADC records.
91
100
  template <typename AudioConfig>
@@ -105,6 +114,34 @@ constexpr int referenceMicOf(const AudioConfig &audio) {
105
114
  constexpr bool kHardwareAecReference = GEA_AUDIO_ECHO_CANCELLATION && kMicAdcAddress != 0 &&
106
115
  referenceMicOf(gea::platform::board::audio) == 3;
107
116
 
117
+ template <typename AudioConfig>
118
+ constexpr float aecMicGainOf(const AudioConfig &audio) {
119
+ if constexpr (requires { audio.aecMicGainDb; }) return audio.aecMicGainDb;
120
+ return 12.0f;
121
+ }
122
+ template <typename AudioConfig>
123
+ constexpr float aecOutputGainOf(const AudioConfig &audio) {
124
+ if constexpr (requires { audio.aecOutputGain; }) return audio.aecOutputGain;
125
+ return 1.0f;
126
+ }
127
+ constexpr float kAecMicGain = aecMicGainOf(gea::platform::board::audio);
128
+ constexpr float kAecOutputGain = aecOutputGainOf(gea::platform::board::audio);
129
+ template <typename AudioConfig>
130
+ constexpr bool aecAggressiveNlpOf(const AudioConfig &audio) {
131
+ if constexpr (requires { audio.aecAggressiveNlp; }) return audio.aecAggressiveNlp;
132
+ return true;
133
+ }
134
+ constexpr bool kAecAggressiveNlp = aecAggressiveNlpOf(gea::platform::board::audio);
135
+ template <typename AudioConfig>
136
+ constexpr bool codecReferenceOf(const AudioConfig &audio) {
137
+ if constexpr (requires { audio.aecCodecReference; }) return audio.aecCodecReference;
138
+ return false;
139
+ }
140
+ // ES8311's ADCL + DACR mode returns mic and DAC reference in one RX frame.
141
+ // This changes AEC pairing, not the ES7210-specific TDM/clock configuration.
142
+ constexpr bool kPairedAecReference = kHardwareAecReference ||
143
+ (GEA_AUDIO_ECHO_CANCELLATION && codecReferenceOf(gea::platform::board::audio));
144
+
108
145
  class AudioOutputDriver {
109
146
  public:
110
147
  static AudioOutputDriver &instance() {
@@ -423,7 +460,7 @@ private:
423
460
  #if GEA_AUDIO_ECHO_CANCELLATION
424
461
  i2s_event_callbacks_t txCallbacks{};
425
462
  txCallbacks.on_sent = txSent;
426
- err = kHardwareAecReference ? ESP_OK : i2s_channel_register_event_callback(txChannel_, &txCallbacks, this);
463
+ err = kPairedAecReference ? ESP_OK : i2s_channel_register_event_callback(txChannel_, &txCallbacks, this);
427
464
  if (err != ESP_OK) { releaseI2s(); return err; }
428
465
  #endif
429
466
  err = i2s_channel_enable(txChannel_);
@@ -572,11 +609,10 @@ private:
572
609
  return err;
573
610
  }
574
611
  recordOpen_ = true;
575
- // Keep ADC headroom for loud speaker echo. No digital makeup gain follows
576
- // AEC; calibrate the physical microphone independently of the loopback.
577
- // Playback peaks clipped the ADC at 24 dB, producing nonlinear echo that
578
- // AEC cannot subtract; keep the microphone below that clipping setting.
579
- esp_codec_dev_set_in_gain(recordCodec_, GEA_AUDIO_ECHO_CANCELLATION ? 12.0f : 45.0f);
612
+ // Sensitivity is board-specific: the ES7210 loopback calibration is not
613
+ // the ES8311 analog microphone's calibration. Keep gain before AEC low
614
+ // enough for ADC headroom, then restore its voice level after cancellation.
615
+ esp_codec_dev_set_in_gain(recordCodec_, GEA_AUDIO_ECHO_CANCELLATION ? kAecMicGain : 45.0f);
580
616
  if constexpr (kHardwareAecReference) {
581
617
  // MIC1 needs sufficient near-end sensitivity at unity AEC output. An
582
618
  // 18 dB PGA setting adds 6 dB over the former headroom-only setting,
@@ -591,7 +627,8 @@ private:
591
627
  if (err != ESP_OK) { closeRecorderLocked(); return err; }
592
628
  }
593
629
  #if GEA_AUDIO_ECHO_CANCELLATION
594
- if (!geaAudioAecStart(kHardwareAecReference)) { closeRecorderLocked(); return ESP_ERR_NO_MEM; }
630
+ if (!geaAudioAecStart(kPairedAecReference, kAecOutputGain, kAecAggressiveNlp)) { closeRecorderLocked(); return ESP_ERR_NO_MEM; }
631
+ ESP_LOGI(kTag, "Microphone AEC gain: ADC=%.1f dB output=%.3f", kAecMicGain, kAecOutputGain);
595
632
  #endif
596
633
  i2sSampleRate_ = sampleRate;
597
634
  return ESP_OK;
@@ -619,7 +656,7 @@ private:
619
656
  }
620
657
 
621
658
  audio_codec_i2c_cfg_t i2cConfig = {};
622
- i2cConfig.addr = ES8311_CODEC_DEFAULT_ADDR;
659
+ i2cConfig.addr = kCodecI2cAddress;
623
660
  i2cConfig.bus_handle = static_cast<i2c_master_bus_handle_t>(i2cBus.nativeHandle());
624
661
  i2cCtrlIf_ = audio_codec_new_i2c_ctrl(&i2cConfig);
625
662
  if (!i2cCtrlIf_) return ESP_ERR_NO_MEM;
@@ -69,6 +69,42 @@ namespace gea::platform::esp32::chip_bindings::co5300
69
69
  };
70
70
  #endif
71
71
 
72
+ #if GEA_EMBEDDED_CO5300_MOSAICO_INIT
73
+ // ESP-Mosaico 480x480 panel, transcribed from the board's own BSP
74
+ // (esp-mosaico-bsp components/esp-mosaico-bsp/onboard/display.c,
75
+ // s_vendor_init). Sleep Out comes first here, unlike the Waveshare 1.75
76
+ // sequence, and the window spans the full 480 columns with no gap.
77
+ static const std::uint8_t kMosaicoFe20[] = {0x20};
78
+ static const std::uint8_t kMosaico19[] = {0x10};
79
+ static const std::uint8_t kMosaico1c[] = {0xA0};
80
+ static const std::uint8_t kMosaicoFe00[] = {0x00};
81
+ static const std::uint8_t kMosaicoC4[] = {0x80};
82
+ static const std::uint8_t kMosaico3a[] = {0x55};
83
+ static const std::uint8_t kMosaico35[] = {0x00};
84
+ static const std::uint8_t kMosaico53[] = {0x20};
85
+ static const std::uint8_t kMosaico51[] = {0xFF};
86
+ static const std::uint8_t kMosaico63[] = {0xFF};
87
+ static const std::uint8_t kMosaico2a[] = {0x00, 0x00, 0x01, 0xDF};
88
+ static const std::uint8_t kMosaico2b[] = {0x00, 0x00, 0x01, 0xDF};
89
+
90
+ static const co5300_lcd_init_cmd_t kMosaicoInitCommands[] = {
91
+ {0x11, nullptr, 0, 600},
92
+ {0xFE, kMosaicoFe20, sizeof(kMosaicoFe20), 0},
93
+ {0x19, kMosaico19, sizeof(kMosaico19), 0},
94
+ {0x1C, kMosaico1c, sizeof(kMosaico1c), 0},
95
+ {0xFE, kMosaicoFe00, sizeof(kMosaicoFe00), 0},
96
+ {0xC4, kMosaicoC4, sizeof(kMosaicoC4), 0},
97
+ {0x3A, kMosaico3a, sizeof(kMosaico3a), 0},
98
+ {0x35, kMosaico35, sizeof(kMosaico35), 0},
99
+ {0x53, kMosaico53, sizeof(kMosaico53), 0},
100
+ {0x51, kMosaico51, sizeof(kMosaico51), 0},
101
+ {0x63, kMosaico63, sizeof(kMosaico63), 0},
102
+ {0x2A, kMosaico2a, sizeof(kMosaico2a), 0},
103
+ {0x2B, kMosaico2b, sizeof(kMosaico2b), 0},
104
+ {0x29, nullptr, 0, 600},
105
+ };
106
+ #endif
107
+
72
108
  esp_lcd_panel_handle_t panelHandle(void *panel)
73
109
  {
74
110
  return static_cast<esp_lcd_panel_handle_t>(panel);
@@ -246,6 +282,10 @@ namespace gea::platform::esp32::chip_bindings::co5300
246
282
  #if GEA_EMBEDDED_CO5300_WAVESHARE_175_INIT
247
283
  vendorConfig.init_cmds = kWaveshare175InitCommands;
248
284
  vendorConfig.init_cmds_size = sizeof(kWaveshare175InitCommands) / sizeof(kWaveshare175InitCommands[0]);
285
+ #endif
286
+ #if GEA_EMBEDDED_CO5300_MOSAICO_INIT
287
+ vendorConfig.init_cmds = kMosaicoInitCommands;
288
+ vendorConfig.init_cmds_size = sizeof(kMosaicoInitCommands) / sizeof(kMosaicoInitCommands[0]);
249
289
  #endif
250
290
  vendorConfig.flags.use_qspi_interface = 1;
251
291
 
@@ -30,7 +30,12 @@ namespace {
30
30
  #include "bmi270_config.inl" // static constexpr const uint8_t bmi270_config_file[8192]
31
31
 
32
32
  constexpr char kTag[] = "bmi270";
33
- constexpr std::uint8_t kI2cAddress = 0x68;
33
+ // SDO strapped low gives 0x68 (M5StickC S3); boards that strap it high (the
34
+ // ESP-Mosaico) answer at 0x69 and say so with GEA_BOARD_BMI270_I2C_ADDRESS.
35
+ #ifndef GEA_BOARD_BMI270_I2C_ADDRESS
36
+ #define GEA_BOARD_BMI270_I2C_ADDRESS 0x68
37
+ #endif
38
+ constexpr std::uint8_t kI2cAddress = GEA_BOARD_BMI270_I2C_ADDRESS;
34
39
  constexpr std::uint32_t kI2cFrequencyHz = 400000;
35
40
  constexpr int kI2cTimeoutMs = 100;
36
41
  constexpr int64_t kRetryIntervalUs = 5000000;
@@ -554,6 +554,10 @@ private:
554
554
  gea::platform::display::Display::reserveInternal(56 * 1024);
555
555
  const bool connected = self->init();
556
556
  if (connected) gea::framework::services::NetworkServices::startDeferredServers();
557
+ // Bring-up has finished allocating WiFi and server resources. Release
558
+ // the temporary reservation so display staging can grow to whatever
559
+ // now fits; retaining it pins every connected app to two-row transfers.
560
+ gea::platform::display::Display::reserveInternal(0);
557
561
  self->bringingUp_ = false;
558
562
  vTaskDeleteWithCaps(nullptr);
559
563
  }
@@ -27,6 +27,8 @@
27
27
  #endif
28
28
  #include "esp_err.h"
29
29
  #include "esp_heap_caps.h"
30
+ // esp_ptr_external_ram/esp_ptr_dma_capable; reached transitively on Xtensa only.
31
+ #include "esp_memory_utils.h"
30
32
  #if GEA_EMBEDDED_HEAP_DIAGNOSTICS_LOG && CONFIG_HEAP_TRACING_STANDALONE
31
33
  #include "esp_attr.h"
32
34
  #include "esp_heap_trace.h"
@@ -62,6 +64,12 @@ namespace pixel = gea::framework::graphics::pixel;
62
64
  namespace qspi_panel = gea::platform::esp32::chip_bindings::displays;
63
65
  namespace present = gea::framework::display_present;
64
66
 
67
+ // Persistent transfer evidence, independent of serial logging or perf builds.
68
+ static std::atomic<uint32_t> gCompletedDisplayChunks{0};
69
+ extern "C" uint32_t gea_display_completed_chunks() {
70
+ return gCompletedDisplayChunks.load(std::memory_order_relaxed);
71
+ }
72
+
65
73
  // Cross-core raster: run a chunk's fill on the idle CPU (both the app frame task
66
74
  // and the present task are pinned to APP_FRAME_TASK_CORE) while the present task
67
75
  // streams the previous chunk. Defined later in this file. submit() returns false
@@ -80,6 +88,7 @@ constexpr bool kGea3dTryFullFramePsram = false;
80
88
  namespace gea::platform::esp32::display
81
89
  {
82
90
 
91
+
83
92
  #ifndef GEA_EMBEDDED_DISPLAY_QSPI_PCLK_HZ
84
93
  #define GEA_EMBEDDED_DISPLAY_QSPI_PCLK_HZ (80 * 1000 * 1000)
85
94
  #endif
@@ -2957,6 +2966,7 @@ namespace gea::platform::esp32::display
2957
2966
  auto *self = static_cast<DisplayBackend *>(userContext);
2958
2967
  if (!self || !self->flushSlots_)
2959
2968
  return false;
2969
+ gCompletedDisplayChunks.fetch_add(1, std::memory_order_relaxed);
2960
2970
  #if GEA_EMBEDDED_DISPLAY_PRESENT_SPLIT_LOG
2961
2971
  // TEMP wire probe (gea3d present-path work): per-chunk DMA completion
2962
2972
  // timestamps; paired with kick timestamps to derive real chunk service
@@ -5253,6 +5263,16 @@ extern "C" std::uint16_t *gea_bg_cache(int *cap_px)
5253
5263
  return buffer;
5254
5264
  }
5255
5265
 
5266
+ // The S3's PIE vector unit is Xtensa-only. On every other chip these kernels
5267
+ // are absent and render.cpp's weak fallbacks report them unavailable, so the
5268
+ // renderer takes its scalar paths.
5269
+ #if CONFIG_IDF_TARGET_ESP32S3
5270
+ #define GEA_DISPLAY_HAS_PIE 1
5271
+ #else
5272
+ #define GEA_DISPLAY_HAS_PIE 0
5273
+ #endif
5274
+
5275
+ #if GEA_DISPLAY_HAS_PIE
5256
5276
  // ── PIE/SIMD throughput probe ──────────────────────────────────────────────
5257
5277
  // Decisive question before investing in a full RGB565 blend kernel: does the S3
5258
5278
  // PIE actually deliver multiply-add throughput over a PSRAM buffer (the per-pixel
@@ -5386,6 +5406,7 @@ static void pieBlendSpan8(std::uint16_t *dst, const std::uint16_t *fgN, const st
5386
5406
  : [cb] "r"(cb2)
5387
5407
  : "memory");
5388
5408
  }
5409
+ #endif // GEA_DISPLAY_HAS_PIE
5389
5410
 
5390
5411
  // ── face-drawer hooks (consumed by render.cpp via weak symbols) ──────────────
5391
5412
  // The PIE vector regs aren't preserved across FreeRTOS context switches, so a
@@ -5422,6 +5443,7 @@ extern "C" void *gea_render_fast_scratch(int bytes, int align)
5422
5443
  return p;
5423
5444
  }
5424
5445
 
5446
+ #if GEA_DISPLAY_HAS_PIE
5425
5447
  extern "C" bool gea_pie_blend_available() { return true; }
5426
5448
  extern "C" void gea_pie_blend_span8(std::uint16_t *dst, const std::uint16_t *fgN, const std::int16_t *a5, int count8)
5427
5449
  {
@@ -5827,6 +5849,7 @@ extern "C" void gea_pie_bench()
5827
5849
  heap_caps_free(b);
5828
5850
  heap_caps_free(ref);
5829
5851
  }
5852
+ #endif // GEA_DISPLAY_HAS_PIE
5830
5853
 
5831
5854
  // Full-screen PSRAM scratch for the static-backdrop cache (bg gradient + stage +
5832
5855
  // dithered floor baked once). Separate from gea_bg_cache so the Phase-1 gradient
@@ -84,3 +84,5 @@ void audio::AudioSystem::setVolume(int value)
84
84
  bool audio::AudioSystem::playFile(const std::string &) { return false; }
85
85
  bool audio::AudioSystem::playPcm(const std::int16_t *, std::size_t, int, int) { return false; }
86
86
  void audio::AudioSystem::stopPlayback() {}
87
+ // Audio is compiled out here, so nothing is ever queued to flush.
88
+ void audio::AudioSystem::flushPlayback() {}
@@ -9,6 +9,9 @@
9
9
  #include "pixel.h"
10
10
  #include "touch.h" // Touchscreen::injectEvent for GEADEV DRAG/SWIPE
11
11
  #include "wifi.h" // network::wifi() for GEADEV PING ip=/mac=
12
+ #include "host/video.h"
13
+
14
+ extern "C" uint32_t gea_display_completed_chunks() __attribute__((weak));
12
15
  #include "services/app_state.h"
13
16
  #include "services/storage_service.h"
14
17
  #include "ui/internal.h"
@@ -1511,9 +1514,8 @@ void handlePlayFile(char *args)
1511
1514
  std::printf("GEADEV:PLAYFILE %s path=%s\n", ok ? "OK" : "ERR", path);
1512
1515
  }
1513
1516
 
1514
- void printNetworkDiagnostics()
1517
+ void printTaskDiagnostics(bool networkOnly)
1515
1518
  {
1516
- std::printf("GEADEV:NETDIAG BEGIN\n");
1517
1519
  #if configUSE_TRACE_FACILITY && INCLUDE_xTaskGetHandle
1518
1520
  struct Sample {
1519
1521
  const char *name;
@@ -1521,16 +1523,21 @@ void printNetworkDiagnostics()
1521
1523
  configRUN_TIME_COUNTER_TYPE cpu = 0;
1522
1524
  std::int64_t at = 0;
1523
1525
  };
1524
- static Sample samples[] = {{"wifi"}, {"tcpip"}, {"websocket_task"}, {"gea-ws-send"}};
1526
+ static Sample samples[] = {{"wifi"}, {"tcpip"}, {"websocket_task"}, {"gea-ws-send"},
1527
+ {"gea_runtime"}, {"app_frame"}, {"gea_mic"}, {"gea_audio"},
1528
+ {"gea_mjpeg_dec"}, {"gea_mjpeg_rx"}, {"gea_rwrk"}, {"IDLE0"}, {"IDLE1"}};
1529
+ const char *prefix = networkOnly ? "NETDIAG" : "TASKSTATS";
1530
+ unsigned index = 0;
1525
1531
  for (auto &sample : samples) {
1532
+ if (networkOnly && index++ >= 4) break;
1526
1533
  const TaskHandle_t task = xTaskGetHandle(sample.name);
1527
1534
  if (!task) {
1528
- std::printf("GEADEV:NETDIAG task=%s absent=1\n", sample.name);
1535
+ std::printf("GEADEV:%s task=%s absent=1\n", prefix, sample.name);
1529
1536
  sample.at = 0;
1530
1537
  continue;
1531
1538
  }
1532
1539
  TaskStatus_t info{};
1533
- // Inspect these four tasks only; never scan stacks or enumerate all tasks.
1540
+ // Inspect known media/runtime tasks only, without scanning their stacks.
1534
1541
  vTaskGetInfo(task, &info, pdFALSE, eInvalid);
1535
1542
  const auto now = esp_timer_get_time();
1536
1543
  const bool previous = sample.at && sample.taskNumber == info.xTaskNumber;
@@ -1543,9 +1550,11 @@ void printNetworkDiagnostics()
1543
1550
  case eDeleted: state = "deleted"; break;
1544
1551
  default: break;
1545
1552
  }
1546
- std::printf("GEADEV:NETDIAG task=%s id=%u state=%s priority=%u cpu_ticks=%llu delta_ticks=%llu span_us=%lld\n",
1547
- sample.name, static_cast<unsigned>(info.xTaskNumber), state,
1553
+ std::printf("GEADEV:%s task=%s id=%u state=%s priority=%u base_priority=%u core=%d cpu_ticks=%llu delta_ticks=%llu span_us=%lld\n",
1554
+ prefix, sample.name, static_cast<unsigned>(info.xTaskNumber), state,
1548
1555
  static_cast<unsigned>(info.uxCurrentPriority),
1556
+ static_cast<unsigned>(info.uxBasePriority),
1557
+ static_cast<int>(xTaskGetCoreID(task)),
1549
1558
  static_cast<unsigned long long>(info.ulRunTimeCounter),
1550
1559
  static_cast<unsigned long long>(previous ? info.ulRunTimeCounter - sample.cpu : 0),
1551
1560
  static_cast<long long>(previous ? now - sample.at : 0));
@@ -1556,6 +1565,12 @@ void printNetworkDiagnostics()
1556
1565
  #else
1557
1566
  std::printf("GEADEV:NETDIAG task-stats-unavailable\n");
1558
1567
  #endif
1568
+ }
1569
+
1570
+ void printNetworkDiagnostics()
1571
+ {
1572
+ std::printf("GEADEV:NETDIAG BEGIN\n");
1573
+ printTaskDiagnostics(true);
1559
1574
  #if CONFIG_ESP_WIFI_ENABLED
1560
1575
  // The Wi-Fi driver owns these counters; use its public diagnostic entry.
1561
1576
  // Emit the marker first so USB also locates a blocked driver dump.
@@ -1629,6 +1644,54 @@ void handleCommand(char *line, CommandSource source)
1629
1644
  } else if (tokenEquals(command, "APP")) {
1630
1645
  const char *appId = gea::framework::apps::AppManager::currentId();
1631
1646
  std::printf("GEADEV:APP id=%s\n", appId ? appId : "");
1647
+ } else if (tokenEquals(command, "TASKSTATS")) {
1648
+ std::puts("GEADEV:TASKSTATS BEGIN");
1649
+ printTaskDiagnostics(false);
1650
+ std::puts("GEADEV:TASKSTATS END");
1651
+ } else if (tokenEquals(command, "VIDEOSTATS")) {
1652
+ gea::framework::services::AppState::lock();
1653
+ const auto stats = gea::host::HTMLVideoElement::presentationStats();
1654
+ gea::framework::services::AppState::unlock();
1655
+ std::printf("GEADEV:VIDEOSTATS decoded=%u selected=%u max_gap_ms=%u dma_chunks=%u\n",
1656
+ unsigned(stats.decoded), unsigned(stats.selected), unsigned(stats.maxGapMs),
1657
+ unsigned(gea_display_completed_chunks ? gea_display_completed_chunks() : 0));
1658
+ } else if (tokenEquals(command, "VIDEO")) {
1659
+ // Replay a local diagnostic clip through the real video/render path,
1660
+ // without creating a hosted session or opening microphone hardware.
1661
+ static gea::host::HTMLVideoElement retainedVideo;
1662
+ const char *className = nextToken(cursor);
1663
+ const char *url = nextToken(cursor);
1664
+ if (!className || !url) {
1665
+ std::puts("GEADEV:ERR VIDEO usage=GEADEV_VIDEO_class_url|STOP");
1666
+ } else {
1667
+ gea::framework::services::AppState::lock();
1668
+ auto &tree = gea::embedded::ui::Tree::instance();
1669
+ bool found = false;
1670
+ for (int id = 0; id < tree.nodeCount(); ++id) {
1671
+ if (!tree.hasClass(id, className)) continue;
1672
+ const gea::embedded::ui::NodeHandle node(id);
1673
+ gea::host::HTMLVideoElement video{node};
1674
+ const bool stopping = tokenEquals(url, "STOP");
1675
+ node.classList().toggle("ready", !stopping);
1676
+ for (int cover = 0; cover < tree.nodeCount(); ++cover) {
1677
+ if (tree.hasClass(cover, "portrait"))
1678
+ gea::embedded::ui::NodeHandle(cover).classList().toggle("hidden", !stopping);
1679
+ }
1680
+ if (stopping) {
1681
+ video.pause();
1682
+ video.setSrcObject(nullptr);
1683
+ retainedVideo = {};
1684
+ } else {
1685
+ retainedVideo = video;
1686
+ video.setSrc(url);
1687
+ video.play();
1688
+ }
1689
+ found = true;
1690
+ break;
1691
+ }
1692
+ gea::framework::services::AppState::unlock();
1693
+ std::printf("GEADEV:VIDEO %s\n", found ? "OK" : "missing-node");
1694
+ }
1632
1695
  } else if (tokenEquals(command, "MEM")) {
1633
1696
  const unsigned intFree = static_cast<unsigned>(heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT));
1634
1697
  const unsigned intTotal = static_cast<unsigned>(heap_caps_get_total_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT));
@@ -1639,10 +1702,13 @@ void handleCommand(char *line, CommandSource source)
1639
1702
  const unsigned psramLargest = static_cast<unsigned>(heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT));
1640
1703
  const char *appId = gea::framework::apps::AppManager::currentId();
1641
1704
  std::printf(
1642
- "GEADEV:MEM app=%s internal_used=%u internal_free=%u internal_total=%u internal_largest=%u internal_min_free=%u psram_used=%u psram_free=%u psram_total=%u psram_largest=%u\n",
1705
+ "GEADEV:MEM app=%s internal_used=%u internal_free=%u internal_total=%u internal_largest=%u internal_min_free=%u psram_used=%u psram_free=%u psram_total=%u psram_largest=%u flush_rows=%d flush_depth=%d flush_bytes=%d\n",
1643
1706
  appId ? appId : "",
1644
1707
  intTotal - intFree, intFree, intTotal, intLargest, intMinFree,
1645
- psramTotal - psramFree, psramFree, psramTotal, psramLargest);
1708
+ psramTotal - psramFree, psramFree, psramTotal, psramLargest,
1709
+ gea::platform::display::Display::flushChunkRows(),
1710
+ gea::platform::display::Display::flushQueueDepth(),
1711
+ gea::platform::display::Display::flushBufferBytes());
1646
1712
  } else if (tokenEquals(command, "HEAPTRACE")) {
1647
1713
  #if CONFIG_HEAP_TRACING_STANDALONE
1648
1714
  // Allocate records only on demand, outside internal DMA RAM. Emit
@@ -152,7 +152,14 @@ constexpr int kTaskStackWords = GEA_EMBEDDED_APP_FRAME_TASK_STACK_WORDS;
152
152
  #ifndef GEA_EMBEDDED_APP_FRAME_TASK_STACK_EXTERNAL
153
153
  #define GEA_EMBEDDED_APP_FRAME_TASK_STACK_EXTERNAL 0
154
154
  #endif
155
+ #if defined(GEA_EMBEDDED_APP_USES_AUDIO) && GEA_EMBEDDED_APP_USES_AUDIO && defined(GEA_EMBEDDED_RUNTIME_TASK_PRIORITY)
156
+ // The ticker takes AppState's mutex. If it outranks the media app's runtime,
157
+ // priority inheritance promotes the renderer above the JPEG/network workers
158
+ // for the entire render. Keep both sides of that lock at the app's priority.
159
+ constexpr int kTaskPriority = GEA_EMBEDDED_RUNTIME_TASK_PRIORITY;
160
+ #else
155
161
  constexpr int kTaskPriority = GEA_EMBEDDED_APP_FRAME_TASK_PRIORITY;
162
+ #endif
156
163
  #ifndef GEA_EMBEDDED_APP_FRAME_TASK_CORE
157
164
  // -1 = tskNO_AFFINITY (run on either core). Boards with BT/WiFi pinned to a
158
165
  // specific core can override this to put the frame task on the other core,