@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
@@ -23,7 +23,7 @@
23
23
  #endif
24
24
 
25
25
  #include "driver/i2c_master.h"
26
- #if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
26
+ #if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG || CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
27
27
  #include "driver/usb_serial_jtag.h"
28
28
  #include "driver/usb_serial_jtag_vfs.h"
29
29
  #endif
@@ -34,6 +34,10 @@
34
34
  #endif
35
35
  #include "platform/file_cache.h" // gea::platform::storage::ensureMounted for GEADEV PUSH
36
36
  #include "esp_log.h"
37
+ #include "esp_timer.h"
38
+ #if CONFIG_ESP_WIFI_ENABLED
39
+ #include "esp_wifi.h"
40
+ #endif
37
41
  #include "esp_err.h"
38
42
  #include "esp_mmu_map.h"
39
43
  #include "esp_partition.h"
@@ -59,6 +63,14 @@
59
63
  #include "host/notify.h" // gea::host::postNotification() for GEADEV NOTIFY
60
64
  #include "host/backends.h" // WifiBackend for GEADEV WIFI
61
65
  #include "host/storage.h" // gea::host::Storage for GEADEV STORAGE SET
66
+ #include "services/vp8_benchmark.h"
67
+ #include "services/opus_benchmark.h"
68
+ #include "services/srtp_benchmark.h"
69
+ #include "services/video_simd_benchmark.h"
70
+ #include "services/pcm_simd_check.h"
71
+ #if defined(GEA_VIDEO_SIMD_ESP32S3) && GEA_VIDEO_SIMD_ESP32S3
72
+ #include "../components/gea_vpx/vp8_profile_s3.h"
73
+ #endif
62
74
 
63
75
  // Older engines expose all four direct position fields.
64
76
  #ifndef GEA_CSS_POSITION_PX
@@ -1244,9 +1256,9 @@ void handlePush(char *args)
1244
1256
 
1245
1257
  char path[160];
1246
1258
  std::snprintf(path, sizeof(path), "%s", pathTok);
1247
- // Mount the microSD (the tile cache does this via writeCacheFile; a raw
1248
- // fopen alone won't trigger it).
1249
- if (!gea::platform::storage::ensureMounted()) {
1259
+ // Only the SD mount needs lazy initialization. SPIFFS is already mounted
1260
+ // at /storage; an absent SD card must not block writes to internal flash.
1261
+ if (std::strncmp(path, "/sdcard/", 8) == 0 && !gea::platform::storage::ensureMounted()) {
1250
1262
  std::printf("GEADEV:PUSH ERR no-storage path=%s\n", path);
1251
1263
  return;
1252
1264
  }
@@ -1327,7 +1339,7 @@ void handlePushBase64(char *args)
1327
1339
 
1328
1340
  char path[160];
1329
1341
  std::snprintf(path, sizeof(path), "%s", pathTok);
1330
- if (!gea::platform::storage::ensureMounted()) {
1342
+ if (std::strncmp(path, "/sdcard/", 8) == 0 && !gea::platform::storage::ensureMounted()) {
1331
1343
  std::printf("GEADEV:PUSH64 ERR no-storage path=%s\n", path);
1332
1344
  return;
1333
1345
  }
@@ -1499,6 +1511,65 @@ void handlePlayFile(char *args)
1499
1511
  std::printf("GEADEV:PLAYFILE %s path=%s\n", ok ? "OK" : "ERR", path);
1500
1512
  }
1501
1513
 
1514
+ void printNetworkDiagnostics()
1515
+ {
1516
+ std::printf("GEADEV:NETDIAG BEGIN\n");
1517
+ #if configUSE_TRACE_FACILITY && INCLUDE_xTaskGetHandle
1518
+ struct Sample {
1519
+ const char *name;
1520
+ UBaseType_t taskNumber = 0;
1521
+ configRUN_TIME_COUNTER_TYPE cpu = 0;
1522
+ std::int64_t at = 0;
1523
+ };
1524
+ static Sample samples[] = {{"wifi"}, {"tcpip"}, {"websocket_task"}, {"gea-ws-send"}};
1525
+ for (auto &sample : samples) {
1526
+ const TaskHandle_t task = xTaskGetHandle(sample.name);
1527
+ if (!task) {
1528
+ std::printf("GEADEV:NETDIAG task=%s absent=1\n", sample.name);
1529
+ sample.at = 0;
1530
+ continue;
1531
+ }
1532
+ TaskStatus_t info{};
1533
+ // Inspect these four tasks only; never scan stacks or enumerate all tasks.
1534
+ vTaskGetInfo(task, &info, pdFALSE, eInvalid);
1535
+ const auto now = esp_timer_get_time();
1536
+ const bool previous = sample.at && sample.taskNumber == info.xTaskNumber;
1537
+ const char *state = "invalid";
1538
+ switch (info.eCurrentState) {
1539
+ case eRunning: state = "running"; break;
1540
+ case eReady: state = "ready"; break;
1541
+ case eBlocked: state = "blocked"; break;
1542
+ case eSuspended: state = "suspended"; break;
1543
+ case eDeleted: state = "deleted"; break;
1544
+ default: break;
1545
+ }
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,
1548
+ static_cast<unsigned>(info.uxCurrentPriority),
1549
+ static_cast<unsigned long long>(info.ulRunTimeCounter),
1550
+ static_cast<unsigned long long>(previous ? info.ulRunTimeCounter - sample.cpu : 0),
1551
+ static_cast<long long>(previous ? now - sample.at : 0));
1552
+ sample.taskNumber = info.xTaskNumber;
1553
+ sample.cpu = info.ulRunTimeCounter;
1554
+ sample.at = now;
1555
+ }
1556
+ #else
1557
+ std::printf("GEADEV:NETDIAG task-stats-unavailable\n");
1558
+ #endif
1559
+ #if CONFIG_ESP_WIFI_ENABLED
1560
+ // The Wi-Fi driver owns these counters; use its public diagnostic entry.
1561
+ // Emit the marker first so USB also locates a blocked driver dump.
1562
+ std::printf("GEADEV:NETDIAG wifi-dump-begin\n");
1563
+ std::fflush(stdout);
1564
+ const auto result = esp_wifi_statis_dump(
1565
+ WIFI_STATIS_BUFFER | WIFI_STATIS_RXTX | WIFI_STATIS_HW | WIFI_STATIS_DIAG);
1566
+ std::printf("GEADEV:NETDIAG wifi-dump-result=%s\n", esp_err_to_name(result));
1567
+ #else
1568
+ std::printf("GEADEV:NETDIAG native-wifi-unavailable\n");
1569
+ #endif
1570
+ std::printf("GEADEV:NETDIAG END\n");
1571
+ }
1572
+
1502
1573
  // Optional per-target GEADEV command extension. The weak default (defined at the
1503
1574
  // end of this file, outside the namespace) returns false; a target that wants
1504
1575
  // extra commands — e.g. the ESP32-P4 camera capture (CAMSTILL / CAMCLIP) in
@@ -1527,6 +1598,34 @@ void handleCommand(char *line, CommandSource source)
1527
1598
  const std::string ip = gea::framework::network::wifi().ip();
1528
1599
  const std::string mac = gea::framework::network::wifi().mac();
1529
1600
  std::printf("GEADEV:PONG app=%s ip=%s mac=%s\n", appId ? appId : "", ip.c_str(), mac.c_str());
1601
+ } else if (tokenEquals(command, "NETDIAG")) {
1602
+ printNetworkDiagnostics();
1603
+ } else if (tokenEquals(command, "IPCSTACK")) {
1604
+ #if INCLUDE_xTaskGetHandle && CONFIG_ESP_IPC_ENABLE
1605
+ // Inspect only the two small stock IPC stacks, while the device is idle.
1606
+ // Never scan the application's large PSRAM stack or every task in a room.
1607
+ for (const char *name : {"ipc0", "ipc1"}) {
1608
+ const TaskHandle_t task = xTaskGetHandle(name);
1609
+ if (!task) std::printf("GEADEV:IPCSTACK task=%s absent=1\n", name);
1610
+ else std::printf("GEADEV:IPCSTACK task=%s capacity_bytes=%u free_bytes=%u\n", name,
1611
+ unsigned(CONFIG_ESP_IPC_TASK_STACK_SIZE), unsigned(uxTaskGetStackHighWaterMark(task)));
1612
+ }
1613
+ std::puts("GEADEV:IPCSTACK END");
1614
+ #else
1615
+ std::puts("GEADEV:IPCSTACK unavailable");
1616
+ #endif
1617
+ } else if (tokenEquals(command, "VP8PROFILE")) {
1618
+ #if defined(GEA_VIDEO_SIMD_ESP32S3) && GEA_VIDEO_SIMD_ESP32S3
1619
+ bool enabled = false;
1620
+ if (!parseOnOff(nextToken(cursor), &enabled)) {
1621
+ std::puts("GEADEV:ERR VP8PROFILE expected-on-or-off");
1622
+ } else {
1623
+ gea_vp8_profile_enable_s3(enabled);
1624
+ std::printf("GEADEV:VP8PROFILE enabled=%u\n", unsigned(enabled));
1625
+ }
1626
+ #else
1627
+ std::puts("GEADEV:ERR VP8PROFILE unavailable");
1628
+ #endif
1530
1629
  } else if (tokenEquals(command, "APP")) {
1531
1630
  const char *appId = gea::framework::apps::AppManager::currentId();
1532
1631
  std::printf("GEADEV:APP id=%s\n", appId ? appId : "");
@@ -1728,6 +1827,23 @@ void handleCommand(char *line, CommandSource source)
1728
1827
  handlePull(cursor);
1729
1828
  } else if (tokenEquals(command, "PLAYFILE")) {
1730
1829
  handlePlayFile(cursor);
1830
+ } else if (tokenEquals(command, "VP8BENCH")) {
1831
+ benchmarkVp8File(nextToken(cursor));
1832
+ } else if (tokenEquals(command, "VP8CAPTURE")) {
1833
+ const auto action = nextToken(cursor);
1834
+ if (tokenEquals(action, "START")) startVp8Capture();
1835
+ else if (tokenEquals(action, "SAVE")) saveVp8Capture();
1836
+ else if (tokenEquals(action, "CANCEL")) cancelVp8Capture();
1837
+ else std::puts("GEADEV:ERR VP8CAPTURE expected-start-save-or-cancel");
1838
+ } else if (tokenEquals(command, "OPUSBENCH")) {
1839
+ benchmarkOpus();
1840
+ } else if (tokenEquals(command, "SIMDBENCH")) {
1841
+ const auto mode = nextToken(cursor);
1842
+ benchmarkVideoSimd(tokenEquals(mode, "swap") ? 1 : tokenEquals(mode, "kernels") ? 2 : 0);
1843
+ } else if (tokenEquals(command, "PCMSIMD")) {
1844
+ checkPcmSimd();
1845
+ } else if (tokenEquals(command, "SRTPBENCH")) {
1846
+ benchmarkSrtp();
1731
1847
  } else if (tokenEquals(command, "BACK")) {
1732
1848
  const bool ok = gea::framework::apps::AppManager::returnRunningAppToLauncher("device control");
1733
1849
  std::printf("GEADEV:OK BACK returned=%d\n", ok ? 1 : 0);
@@ -1825,6 +1941,26 @@ class DeviceControlTask {
1825
1941
  public:
1826
1942
  static void run(void *)
1827
1943
  {
1944
+ #if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
1945
+ // The primary USB VFS otherwise uses a ROM/FIFO polling writer. It can
1946
+ // busy-spin for up to 50 ms while a log line drains, at the caller's
1947
+ // media priority. Use IDF's bounded driver rings and blocking waits, as
1948
+ // the secondary USB console already does. stdin blocks on RX instead
1949
+ // of polling; no extra console/network task is required.
1950
+ usb_serial_jtag_driver_config_t config = {
1951
+ .tx_buffer_size = 1024,
1952
+ .rx_buffer_size = 1024,
1953
+ };
1954
+ if (!usb_serial_jtag_is_driver_installed()) {
1955
+ const esp_err_t err = usb_serial_jtag_driver_install(&config);
1956
+ if (err != ESP_OK) {
1957
+ ESP_LOGE(kTag, "Failed to install primary USB console driver: %s", esp_err_to_name(err));
1958
+ vTaskDelete(nullptr);
1959
+ return;
1960
+ }
1961
+ }
1962
+ usb_serial_jtag_vfs_use_driver();
1963
+ #endif
1828
1964
  std::setvbuf(stdin, nullptr, _IONBF, 0);
1829
1965
  std::setvbuf(stdout, nullptr, _IONBF, 0);
1830
1966
  ESP_LOGI(kTag, "Device control ready: send 'GEADEV PING', 'GEADEV TAP x y', 'GEADEV BACK', or 'GEADEV SCREENSHOT'");
@@ -3,6 +3,7 @@
3
3
  #include "app.h"
4
4
  #include "display.h"
5
5
  #include "host/timers.h"
6
+ #include "host/worker.h"
6
7
  #include "ui/refresh_trace.h"
7
8
  #include "ui/refresh_perf.h"
8
9
  #include "ui/document.h"
@@ -20,6 +21,7 @@
20
21
  #include "freertos/FreeRTOS.h"
21
22
  #include "freertos/queue.h"
22
23
  #include "freertos/task.h"
24
+ #include "freertos/idf_additions.h"
23
25
 
24
26
  #if defined(GEA_EMBEDDED_FRAME_BENCHMARK) && GEA_EMBEDDED_FRAME_BENCHMARK
25
27
  extern "C" void gea_frame_benchmark_sample(int64_t start, int64_t done);
@@ -378,10 +380,17 @@ public:
378
380
  // The phase-set is kept (watchdog stall report); only the timing reads +
379
381
  // the perf accumulation around the real refresh are perf machinery.
380
382
  gea::framework::app::applicationFramePhaseSet(gea::framework::app::ApplicationFramePhase::RefreshMounted);
383
+ #if CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
384
+ const auto profileRefreshStart = esp_timer_get_time();
385
+ #endif
381
386
  #if GEA_EMBEDDED_FRAME_SCHEDULER_PERF_LOG
382
387
  const int64_t refreshStartUs = esp_timer_get_time();
383
388
  #endif
384
389
  gea::embedded::ui::Document::instance().refreshMountedIfDirty();
390
+ #if CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
391
+ const auto profileRefreshUs = esp_timer_get_time() - profileRefreshStart;
392
+ if (profileRefreshUs > 30000) ESP_LOGW("frame_phase", "render duration_ms=%lld", (long long)(profileRefreshUs / 1000));
393
+ #endif
385
394
  #if GEA_EMBEDDED_FRAME_SCHEDULER_PERF_LOG
386
395
  gea::framework::app::applicationFramePerfStatsAdd(
387
396
  gea::framework::app::ApplicationFramePhase::RefreshMounted,
@@ -1081,11 +1090,13 @@ private:
1081
1090
  const auto displayDetail = gea::platform::display::Display::flushStageDetail();
1082
1091
 
1083
1092
  ESP_LOGE(kTag,
1084
- "frame watchdog: seq=%lu stuck=%dms stage=%s app_phase=%s ui=%s/%d display=%s/%d rect=%d,%d-%d,%d rows=%d px=%d pending=%d internal_free=%u internal_largest=%u internal_min=%u psram_free=%u",
1093
+ "frame watchdog: seq=%lu stuck=%dms stage=%s app_phase=%s host_phase=%s worker_phase=%s ui=%s/%d display=%s/%d rect=%d,%d-%d,%d rows=%d px=%d pending=%d internal_free=%u internal_largest=%u internal_min=%u psram_free=%u",
1085
1094
  static_cast<unsigned long>(frameSequence_.load(std::memory_order_relaxed)),
1086
1095
  elapsedMs,
1087
1096
  stageName(frameStage()),
1088
1097
  gea::framework::app::applicationFramePhaseName(gea::framework::app::applicationFramePhaseRead()),
1098
+ gea::host::animationFrameCallbackStage(),
1099
+ gea::host::workers::Context::mainPendingStage(),
1089
1100
  gea::embedded::ui::refreshTraceStageName(),
1090
1101
  gea::embedded::ui::refreshTraceIndex(),
1091
1102
  gea::platform::display::Display::flushStageName(),
@@ -1101,6 +1112,23 @@ private:
1101
1112
  static_cast<unsigned>(heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)),
1102
1113
  static_cast<unsigned>(heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)),
1103
1114
  static_cast<unsigned>(heap_caps_get_free_size(MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)));
1115
+ #if configUSE_TRACE_FACILITY && configGENERATE_RUN_TIME_STATS
1116
+ // Inspect scheduling without scanning large PSRAM task stacks. This is
1117
+ // diagnostic-only and does not alter priorities or interrupt execution.
1118
+ const char *names[] = {"main", "gea_runtime", "app_frame", "gea_mic",
1119
+ "gea_audio", "gea_rtc_loop", "gea_rtc_send", "gea_rtc_audio", "gea_rtc_video",
1120
+ "gea_rwrk", "juice", "tcpip", "wifi", "diag_srv", "gea_devctl", "gea_devctl_usb", "esp_timer", "gea_log", "IDLE0", "IDLE1"};
1121
+ for (const char *name : names) {
1122
+ if (auto task = xTaskGetHandle(name)) {
1123
+ TaskStatus_t status{};
1124
+ vTaskGetInfo(task, &status, pdFALSE, eInvalid);
1125
+ ESP_LOGW(kTag, "scheduler task=%s state=%u priority=%u base=%u cpu_us=%llu affinity=%d",
1126
+ name, unsigned(status.eCurrentState), unsigned(status.uxCurrentPriority),
1127
+ unsigned(status.uxBasePriority), (unsigned long long)status.ulRunTimeCounter,
1128
+ int(xTaskGetCoreID(task)));
1129
+ }
1130
+ }
1131
+ #endif
1104
1132
  }
1105
1133
 
1106
1134
  void queueFrameEvent()
@@ -0,0 +1,82 @@
1
+ // Offline codec measurement. No microphone, speaker, signaling or cloud session.
2
+ #pragma once
3
+ #include <cstdio>
4
+
5
+ #if GEA_EMBEDDED_APP_USES_AUDIO && __has_include("esp_opus_enc.h")
6
+ #include "host/rtc_opus.h"
7
+ #include "esp_timer.h"
8
+ #include "esp_heap_caps.h"
9
+ #include "freertos/idf_additions.h"
10
+ #include "freertos/semphr.h"
11
+
12
+ namespace gea::platform::esp32::services {
13
+ inline void benchmarkOpus() {
14
+ struct Job { SemaphoreHandle_t done; } job{xSemaphoreCreateBinary()};
15
+ if (!job.done) {
16
+ std::printf("GEADEV:ERR OPUSBENCH semaphore-allocation\n");
17
+ return;
18
+ }
19
+ const auto run = [](void* context) {
20
+ auto& job = *static_cast<Job*>(context);
21
+ try {
22
+ using Codec = gea::host::rtc::OpusAudio;
23
+ for (const auto mode : {Codec::Application::LowDelay, Codec::Application::Voice}) {
24
+ Codec codec(mode);
25
+ alignas(16) std::array<int16_t, Codec::frameSamples> pcm{};
26
+ uint64_t encodeUs = 0, decodeUs = 0, maxEncodeUs = 0;
27
+ uint32_t random = 1, totalBytes = 0;
28
+ constexpr unsigned frames = 25;
29
+ const auto started = esp_timer_get_time();
30
+ for (unsigned frame = 0; frame < frames; ++frame) {
31
+ // Periodic voiced signal plus deterministic low-level noise. Avoid
32
+ // benchmarking only silence, whose codec cost is not representative.
33
+ for (unsigned i = 0; i < pcm.size(); ++i) {
34
+ random = random * 1664525u + 1013904223u;
35
+ const int phase = (frame * pcm.size() + i) % 160;
36
+ pcm[i] = int16_t((phase < 80 ? phase - 40 : 120 - phase) * 80
37
+ + int(random >> 24) - 128);
38
+ }
39
+ auto before = esp_timer_get_time();
40
+ const auto size = codec.encode(pcm.data());
41
+ const uint64_t elapsed = esp_timer_get_time() - before;
42
+ encodeUs += elapsed;
43
+ if (elapsed > maxEncodeUs) maxEncodeUs = elapsed;
44
+ if (size <= 0) throw std::runtime_error("encode-failed");
45
+ totalBytes += size;
46
+ before = esp_timer_get_time();
47
+ if (codec.decode(codec.packet.data(), size) != Codec::frameSamples)
48
+ throw std::runtime_error("decode-failed");
49
+ decodeUs += esp_timer_get_time() - before;
50
+ vTaskDelay(1);
51
+ }
52
+ std::printf("GEADEV:OPUSBENCH mode=%s rate=%d bitrate=24000 frame_ms=%d complexity=0 frames=%u encode_avg_us=%llu encode_max_us=%llu decode_avg_us=%llu elapsed_us=%lld bytes=%u\n",
53
+ mode == Codec::Application::LowDelay ? "lowdelay" : "voice", Codec::sampleRate,
54
+ Codec::frameDurationMs, frames, (unsigned long long)(encodeUs / frames),
55
+ (unsigned long long)maxEncodeUs, (unsigned long long)(decodeUs / frames),
56
+ (long long)(esp_timer_get_time() - started), unsigned(totalBytes));
57
+ }
58
+ std::printf("GEADEV:OPUSBENCH END\n");
59
+ } catch (const std::exception& error) {
60
+ std::printf("GEADEV:ERR OPUSBENCH %s\n", error.what());
61
+ }
62
+ std::fflush(stdout);
63
+ xSemaphoreGive(job.done);
64
+ for (;;) vTaskSuspend(nullptr);
65
+ };
66
+ TaskHandle_t task = nullptr;
67
+ if (xTaskCreatePinnedToCoreWithCaps(run, "gea_opus_bench", 64 * 1024, &job, 5, &task, 1,
68
+ MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT) != pdPASS) {
69
+ std::printf("GEADEV:ERR OPUSBENCH task-allocation\n");
70
+ } else {
71
+ xSemaphoreTake(job.done, portMAX_DELAY);
72
+ while (eTaskGetState(task) != eSuspended) vTaskDelay(1);
73
+ vTaskDeleteWithCaps(task);
74
+ }
75
+ vSemaphoreDelete(job.done);
76
+ }
77
+ } // namespace gea::platform::esp32::services
78
+ #else
79
+ namespace gea::platform::esp32::services {
80
+ inline void benchmarkOpus() { std::printf("GEADEV:ERR OPUSBENCH unavailable\n"); }
81
+ }
82
+ #endif
@@ -0,0 +1,73 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #pragma once
3
+
4
+ #include "sdkconfig.h"
5
+ #include <cstddef>
6
+ #include <cstdint>
7
+ #include <cstdio>
8
+ #include <cstring>
9
+ #include "esp_timer.h"
10
+
11
+ #if defined(__XTENSA__) && defined(CONFIG_IDF_TARGET_ESP32S3) && CONFIG_IDF_TARGET_ESP32S3 && __has_include("gea_pcm.h")
12
+ #include "gea_pcm.h"
13
+
14
+ // Exercise the exact generated runtime artifact through the framework's
15
+ // normal app include directory. This performs no audio I/O or background work.
16
+ inline void checkPcmSimd() {
17
+ alignas(16) float input[40];
18
+ alignas(16) std::int16_t output[48];
19
+ constexpr std::uint32_t boundaries[] = {
20
+ 0, 0x80000000, 1, 0x80000001, 0x007fffff, 0x807fffff,
21
+ 0x377fffff, 0x37800000, 0x37800001, 0xb77fffff, 0xb7800000, 0xb7800001,
22
+ 0x3f7fffff, 0x3f800000, 0x3f800001, 0xbf7fffff, 0xbf800000, 0xbf800001,
23
+ 0x7f800000, 0xff800000, 0x7f800001, 0xff800001, 0x7fc00000, 0xffffffff,
24
+ // Half-integer PCM boundaries and adjacent Float32 encodings.
25
+ 0x3f0000ff, 0x3f000100, 0x3f000101, 0xbf00007f, 0xbf000080, 0xbf000081,
26
+ 0x3d8000ff, 0x3d800100, 0x3d800101, 0xbd8003ff, 0xbd800400, 0xbd800401};
27
+ constexpr std::size_t lengths[] = {0, 1, 7, 8, 9, 15, 16, 17, 31, 32};
28
+ std::size_t samples = 0;
29
+ std::uint32_t random = 0x713ba549;
30
+ const auto started = esp_timer_get_time();
31
+ for (unsigned dataset = 0; dataset < 2; ++dataset) {
32
+ for (std::size_t inOffset = 0; inOffset < 4; ++inOffset) {
33
+ for (std::size_t outOffset = 0; outOffset < 8; ++outOffset) {
34
+ for (auto count : lengths) {
35
+ for (std::size_t i = 0; i < 40; ++i) {
36
+ random ^= random << 13; random ^= random >> 17; random ^= random << 5;
37
+ // Mix arbitrary IEEE encodings with values in the active audio
38
+ // range so random cases do not mostly become zero/saturation.
39
+ const auto bits = dataset == 0 ? boundaries[(i + outOffset) % 36] :
40
+ (i & 1) ? random : (random & 0x807fffffU) | ((111U + ((random >> 24) & 15U)) << 23);
41
+ std::memcpy(&input[i], &bits, sizeof(bits));
42
+ }
43
+ for (auto& value : output) value = 12345;
44
+ gea::runtime::audio::float32ToPcm16(input + inOffset, output + outOffset, count);
45
+ for (std::size_t i = 0; i < count; ++i) {
46
+ const auto expected = gea::runtime::audio::detail::pcm16Sample(input[inOffset + i]);
47
+ const auto actual = output[outOffset + i];
48
+ ++samples;
49
+ if (actual != expected) {
50
+ std::uint32_t bits;
51
+ std::memcpy(&bits, &input[inOffset + i], sizeof(bits));
52
+ std::printf("GEADEV:PCMSIMD ERR bits=%08lx actual=%d expected=%d input_offset=%u output_offset=%u count=%u index=%u\n",
53
+ static_cast<unsigned long>(bits), int(actual), int(expected),
54
+ unsigned(inOffset), unsigned(outOffset), unsigned(count), unsigned(i));
55
+ return;
56
+ }
57
+ }
58
+ for (std::size_t i = 0; i < 48; ++i) {
59
+ if ((i < outOffset || i >= outOffset + count) && output[i] != 12345) {
60
+ std::printf("GEADEV:PCMSIMD ERR guard index=%u\n", unsigned(i));
61
+ return;
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ std::printf("GEADEV:PCMSIMD OK simd=1 samples=%u elapsed_us=%lld\n",
69
+ unsigned(samples), static_cast<long long>(esp_timer_get_time() - started));
70
+ }
71
+ #else
72
+ inline void checkPcmSimd() { std::puts("GEADEV:PCMSIMD ERR unavailable"); }
73
+ #endif
@@ -0,0 +1,106 @@
1
+ // Offline authenticated RTP measurement. No sockets or cloud session.
2
+ #pragma once
3
+ #include <cstdio>
4
+
5
+ #if GEA_EMBEDDED_APP_USES_AUDIO && __has_include("srtp.h")
6
+ #include "srtp.h"
7
+ #include "esp_timer.h"
8
+ #include "esp_heap_caps.h"
9
+ #include "freertos/idf_additions.h"
10
+ #include "freertos/semphr.h"
11
+ #include <array>
12
+ #include <cstring>
13
+ #include <stdexcept>
14
+
15
+ namespace gea::platform::esp32::services {
16
+ inline void benchmarkSrtp() {
17
+ struct Job { SemaphoreHandle_t done; } job{xSemaphoreCreateBinary()};
18
+ if (!job.done) {
19
+ std::printf("GEADEV:ERR SRTPBENCH semaphore-allocation\n");
20
+ return;
21
+ }
22
+ const auto run = [](void* context) {
23
+ auto& job = *static_cast<Job*>(context);
24
+ try {
25
+ struct Session {
26
+ srtp_t value = nullptr;
27
+ ~Session() { if (value) srtp_dealloc(value); }
28
+ };
29
+ if (srtp_init() != srtp_err_status_ok) throw std::runtime_error("init-failed");
30
+ for (const unsigned payloadSize : {120u, 1200u}) {
31
+ std::array<uint8_t, 30> key{};
32
+ for (unsigned i = 0; i < key.size(); ++i) key[i] = uint8_t(i);
33
+ srtp_policy_t policy{};
34
+ srtp_crypto_policy_set_rtp_default(&policy.rtp);
35
+ srtp_crypto_policy_set_rtcp_default(&policy.rtcp);
36
+ policy.ssrc.type = ssrc_specific;
37
+ policy.ssrc.value = 0x12345678;
38
+ policy.key = key.data();
39
+ policy.window_size = 128;
40
+ Session sender, receiver;
41
+ if (srtp_create(&sender.value, &policy) != srtp_err_status_ok ||
42
+ srtp_create(&receiver.value, &policy) != srtp_err_status_ok)
43
+ throw std::runtime_error("session-allocation");
44
+ std::array<uint8_t, 1400> plain{}, protectedPacket{}, decoded{};
45
+ const unsigned packetSize = payloadSize + 12;
46
+ for (unsigned i = 12; i < packetSize; ++i) plain[i] = uint8_t(i * 17);
47
+ plain[0] = 0x80; plain[1] = 101;
48
+ plain[8] = 0x12; plain[9] = 0x34; plain[10] = 0x56; plain[11] = 0x78;
49
+ uint64_t protectUs = 0, unprotectUs = 0;
50
+ constexpr unsigned packets = 100;
51
+ for (unsigned i = 0; i < packets; ++i) {
52
+ plain[2] = uint8_t(i >> 8); plain[3] = uint8_t(i);
53
+ size_t protectedSize = protectedPacket.size();
54
+ auto before = esp_timer_get_time();
55
+ if (srtp_protect(sender.value, plain.data(), packetSize, protectedPacket.data(),
56
+ &protectedSize, 0) != srtp_err_status_ok)
57
+ throw std::runtime_error("protect-failed");
58
+ protectUs += esp_timer_get_time() - before;
59
+ size_t decodedSize = decoded.size();
60
+ if (!i) {
61
+ // Authentication failure must not consume the sequence number.
62
+ protectedPacket[protectedSize - 1] ^= 1;
63
+ if (srtp_unprotect(receiver.value, protectedPacket.data(), protectedSize,
64
+ decoded.data(), &decodedSize) != srtp_err_status_auth_fail)
65
+ throw std::runtime_error("tampered-packet-accepted");
66
+ protectedPacket[protectedSize - 1] ^= 1;
67
+ decodedSize = decoded.size();
68
+ }
69
+ before = esp_timer_get_time();
70
+ if (srtp_unprotect(receiver.value, protectedPacket.data(), protectedSize,
71
+ decoded.data(), &decodedSize) != srtp_err_status_ok)
72
+ throw std::runtime_error("unprotect-failed");
73
+ unprotectUs += esp_timer_get_time() - before;
74
+ if (decodedSize != packetSize || std::memcmp(plain.data(), decoded.data(), packetSize))
75
+ throw std::runtime_error("roundtrip-mismatch");
76
+ vTaskDelay(1);
77
+ }
78
+ std::printf("GEADEV:SRTPBENCH payload_bytes=%u packets=%u protect_avg_us=%llu unprotect_avg_us=%llu roundtrip=ok tamper=rejected\n",
79
+ payloadSize, packets, (unsigned long long)(protectUs / packets),
80
+ (unsigned long long)(unprotectUs / packets));
81
+ }
82
+ std::printf("GEADEV:SRTPBENCH END\n");
83
+ } catch (const std::exception& error) {
84
+ std::printf("GEADEV:ERR SRTPBENCH %s\n", error.what());
85
+ }
86
+ std::fflush(stdout);
87
+ xSemaphoreGive(job.done);
88
+ for (;;) vTaskSuspend(nullptr);
89
+ };
90
+ TaskHandle_t task = nullptr;
91
+ if (xTaskCreatePinnedToCoreWithCaps(run, "gea_srtp_bench", 24 * 1024, &job, 7, &task, 1,
92
+ MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT) != pdPASS) {
93
+ std::printf("GEADEV:ERR SRTPBENCH task-allocation\n");
94
+ } else {
95
+ xSemaphoreTake(job.done, portMAX_DELAY);
96
+ while (eTaskGetState(task) != eSuspended) vTaskDelay(1);
97
+ vTaskDeleteWithCaps(task);
98
+ }
99
+ vSemaphoreDelete(job.done);
100
+ }
101
+ } // namespace gea::platform::esp32::services
102
+ #else
103
+ namespace gea::platform::esp32::services {
104
+ inline void benchmarkSrtp() { std::printf("GEADEV:ERR SRTPBENCH unavailable\n"); }
105
+ }
106
+ #endif