@geastack/targets 0.1.87 → 0.1.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/targets/esp32/app_project.cmake +18 -1
- package/targets/esp32/chip_bindings/audio/echo_cancellation.cpp +229 -0
- package/targets/esp32/chip_bindings/audio/echo_cancellation.h +13 -0
- package/targets/esp32/chip_bindings/audio/es8311.cpp +293 -45
- package/targets/esp32/chip_bindings/displays/rgb_panel.cpp +115 -12
- package/targets/esp32/chip_bindings/expanders/io_expander.h +2 -0
- package/targets/esp32/chip_bindings/expanders/tca9554.cpp +74 -0
- package/targets/esp32/chip_bindings/touch/ft3168.cpp +23 -1
- package/targets/esp32/chip_bindings/touch/ft3168_controller.h +1 -0
- package/targets/esp32/chip_bindings/touch/gt911.cpp +4 -3
- package/targets/esp32/components/gea_framework/CMakeLists.txt +8 -1
- package/targets/esp32/components/gea_juice/CMakeLists.txt +46 -0
- package/targets/esp32/components/gea_juice/README.md +20 -0
- package/targets/esp32/components/gea_juice/juice_memory.c +19 -0
- package/targets/esp32/components/gea_juice/juice_memory.h +16 -0
- package/targets/esp32/components/gea_juice/patch_threads.py +50 -0
- package/targets/esp32/components/gea_vp8_peer/CMakeLists.txt +16 -0
- package/targets/esp32/components/gea_vp8_peer/README.md +39 -0
- package/targets/esp32/components/gea_vp8_peer/gea_vp8_peer.h +21 -0
- package/targets/esp32/components/gea_vp8_peer/vp8_peer.cpp +538 -0
- package/targets/esp32/components/gea_vpx/CMakeLists.txt +235 -0
- package/targets/esp32/components/gea_vpx/README.md +133 -0
- package/targets/esp32/components/gea_vpx/i420_rgb565_s3.S +169 -0
- package/targets/esp32/components/gea_vpx/vp8_blocks_s3.c +42 -0
- package/targets/esp32/components/gea_vpx/vp8_copy_s3.S +39 -0
- package/targets/esp32/components/gea_vpx/vp8_entropy_s3.c +76 -0
- package/targets/esp32/components/gea_vpx/vp8_filter_s3.S +58 -0
- package/targets/esp32/components/gea_vpx/vp8_idct_s3.S +269 -0
- package/targets/esp32/components/gea_vpx/vp8_intrapred_s3.S +65 -0
- package/targets/esp32/components/gea_vpx/vp8_loopfilter_s3.S +333 -0
- package/targets/esp32/components/gea_vpx/vp8_loopfilter_s3.c +62 -0
- package/targets/esp32/components/gea_vpx/vp8_profile_s3.c +22 -0
- package/targets/esp32/components/gea_vpx/vp8_profile_s3.h +20 -0
- package/targets/esp32/components/gea_vpx/vp8_s3.c +120 -0
- package/targets/esp32/components/gea_vpx/vp8_s3.h +58 -0
- package/targets/esp32/components/gea_vpx/vp8_workspace_s3.c +14 -0
- package/targets/esp32/components/gea_vpx/vpx_memory.c +41 -0
- package/targets/esp32/connectivity/diagnostics_transport.cpp +18 -0
- package/targets/esp32/connectivity/wifi.cpp +30 -13
- package/targets/esp32/crypto/srtp_hmac_psa.c +118 -0
- package/targets/esp32/display.cpp +21 -0
- package/targets/esp32/gea_framework.cmake +7 -0
- package/targets/esp32/host_sources.cmake +2 -0
- package/targets/esp32/i2c_completion_order.cmake +57 -0
- package/targets/esp32/patch_streaming_dependencies.py +233 -0
- package/targets/esp32/services/device_control.cpp +209 -7
- package/targets/esp32/services/frame_scheduler.cpp +36 -1
- package/targets/esp32/services/opus_benchmark.h +82 -0
- package/targets/esp32/services/pcm_simd_check.h +73 -0
- package/targets/esp32/services/srtp_benchmark.h +106 -0
- package/targets/esp32/services/video_simd_benchmark.h +477 -0
- package/targets/esp32/services/vp8_benchmark.h +147 -0
- package/targets/esp32/streaming_dependency_patches.cmake +103 -0
- package/targets/esp32-m5stack-m5paper/main/idf_component.yml +2 -0
- package/targets/esp32-p4-m5stack-tab5/main/idf_component.yml +2 -0
- package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/idf_component.yml +2 -0
- package/targets/esp32-p4-waveshare-touch-lcd-7/main/idf_component.yml +2 -0
- package/targets/esp32-s3-elecrow-rotary-2.1/main/idf_component.yml +2 -0
- package/targets/esp32-s3-epaper-1.54/main/idf_component.yml +2 -0
- package/targets/esp32-s3-lilygo-t-display-s3-long/main/idf_component.yml +2 -0
- package/targets/esp32-s3-m5stack-papers3/main/idf_component.yml +2 -0
- package/targets/esp32-s3-m5stack-sticks3/main/idf_component.yml +2 -0
- package/targets/esp32-s3-touch-amoled-1.75/main/idf_component.yml +2 -0
- package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +125 -2
- package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +29 -3
- package/targets/esp32-s3-touch-amoled-1.8/main/app_main.cpp +6 -3
- package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +15 -0
- package/targets/esp32-s3-touch-amoled-1.8/main/include/board.h +12 -0
- package/targets/esp32-s3-touch-amoled-1.8/sdkconfig.defaults +9 -1
- package/targets/esp32-s3-touch-amoled-2.06/CMakeLists.txt +2 -0
- package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +172 -8
- package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +9 -1
- package/targets/esp32-s3-touch-amoled-2.06/main/app_main.cpp +10 -3
- package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +21 -1
- package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +10 -0
- package/targets/esp32-s3-touch-amoled-2.06/main/touch.cpp +7 -0
- package/targets/esp32-s3-touch-amoled-2.41/dependencies.lock +57 -1
- package/targets/esp32-s3-touch-amoled-2.41/main/idf_component.yml +10 -0
- package/targets/esp32-s3-waveshare-touch-lcd-4b.json +504 -0
- package/targets.json +12 -1
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
#include "lwip/sockets.h"
|
|
22
22
|
#include "lwip/tcp.h"
|
|
23
23
|
#include "sdkconfig.h"
|
|
24
|
+
#if CONFIG_ESP_CONSOLE_UART
|
|
25
|
+
#include "driver/uart.h"
|
|
26
|
+
#include "driver/uart_vfs.h"
|
|
27
|
+
#endif
|
|
24
28
|
#if GEA_EMBEDDED_HEAP_DIAGNOSTICS_LOG && CONFIG_HEAP_TASK_TRACKING
|
|
25
29
|
#include "esp_heap_task_info.h"
|
|
26
30
|
#endif
|
|
@@ -327,6 +331,20 @@ public:
|
|
|
327
331
|
|
|
328
332
|
void installLogSink(gea::framework::services::DiagnosticsVPrintSink sink) override
|
|
329
333
|
{
|
|
334
|
+
#if CONFIG_ESP_CONSOLE_UART
|
|
335
|
+
// The default UART VFS busy-spins until every byte reaches its FIFO.
|
|
336
|
+
// Even a background logger then consumes media CPU, and stdout's lock
|
|
337
|
+
// can promote it through priority inheritance. The IDF driver blocks on
|
|
338
|
+
// its bounded TX ring instead, letting audio/video run while UART drains.
|
|
339
|
+
const auto port = static_cast<uart_port_t>(CONFIG_ESP_CONSOLE_UART_NUM);
|
|
340
|
+
const esp_err_t result = uart_is_driver_installed(port)
|
|
341
|
+
? ESP_OK : uart_driver_install(port, 256, 2048, 0, nullptr, 0);
|
|
342
|
+
if (result == ESP_OK) {
|
|
343
|
+
uart_vfs_dev_use_driver(port);
|
|
344
|
+
} else {
|
|
345
|
+
ESP_LOGE(kTag, "Console UART driver installation failed: %s", esp_err_to_name(result));
|
|
346
|
+
}
|
|
347
|
+
#endif
|
|
330
348
|
esp_log_set_vprintf(sink);
|
|
331
349
|
}
|
|
332
350
|
|
|
@@ -81,27 +81,40 @@ public:
|
|
|
81
81
|
|
|
82
82
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
|
83
83
|
#if CONFIG_ESP_WIFI_ENABLED
|
|
84
|
-
//
|
|
85
|
-
// bus, and the HTTP task on this S3.
|
|
86
|
-
// only 23,824 DMA bytes before WiFi: even a 3/8 RX, 2/1 TX/cache midpoint
|
|
87
|
-
// associated but left 1,212 bytes, and display initialization failed. The
|
|
88
|
-
// original slow OTA run also had a 6 KiB WiFi task and an 8 KiB HTTP task;
|
|
89
|
-
// those stacks are now 8 KiB and 4 KiB respectively, so keep the viable
|
|
90
|
-
// pool sizes and measure the corrected task configuration independently.
|
|
84
|
+
// Keep the fixed RX DMA pool small enough to leave room for BLE, the
|
|
85
|
+
// CO5300 SPI bus, and the HTTP task on this S3.
|
|
91
86
|
// TCP OTA is the primary bulk receive path. Buy its receive depth with the
|
|
92
87
|
// DYNAMIC frames, not the static ones: static RX frames are permanent
|
|
93
88
|
// internal DMA allocations (1600 B each) taken from the same few tens of KiB
|
|
94
89
|
// the display staging needs, while dynamic frames are allocated on demand
|
|
95
90
|
// and land in PSRAM under CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP. Sixteen
|
|
96
|
-
// dynamic frames match the widened TCP receive window
|
|
97
|
-
//
|
|
91
|
+
// dynamic frames match the widened TCP receive window. Duplex streaming
|
|
92
|
+
// apps can raise both pools below: queued TCP pbufs retain dynamic RX
|
|
93
|
+
// buffers, so those apps need headroom for ACK, DNS, and ARP traffic too.
|
|
98
94
|
cfg.static_rx_buf_num = 4;
|
|
99
95
|
cfg.dynamic_rx_buf_num = 16;
|
|
100
|
-
|
|
101
|
-
cfg.
|
|
102
|
-
|
|
96
|
+
#if defined(GEA_EMBEDDED_WIFI_STATIC_RX_BUFFERS)
|
|
97
|
+
cfg.static_rx_buf_num = GEA_EMBEDDED_WIFI_STATIC_RX_BUFFERS;
|
|
98
|
+
#endif
|
|
99
|
+
#if defined(GEA_EMBEDDED_WIFI_DYNAMIC_RX_BUFFERS)
|
|
100
|
+
cfg.dynamic_rx_buf_num = GEA_EMBEDDED_WIFI_DYNAMIC_RX_BUFFERS;
|
|
101
|
+
#endif
|
|
102
|
+
// With AMPDU RX, ESP-IDF recommends static RX >= the block-ack window
|
|
103
|
+
// for throughput and compatibility; streaming apps should use >= 8.
|
|
104
|
+
cfg.rx_ba_win = 8;
|
|
105
|
+
// Preserve the configured TX pools and aggregation. A one-frame DMA pool
|
|
106
|
+
// plus one cached packet cannot carry microphone uploads alongside the
|
|
107
|
+
// ACKs for incoming audio: wlanif returns ERR_MEM and TCP waits for retry.
|
|
108
|
+
// Board sdkconfig owns these capacities, not this shared driver.
|
|
109
|
+
#if defined(GEA_EMBEDDED_WIFI_STATIC_TX_BUFFERS)
|
|
110
|
+
cfg.static_tx_buf_num = GEA_EMBEDDED_WIFI_STATIC_TX_BUFFERS;
|
|
111
|
+
#endif
|
|
112
|
+
#if defined(GEA_EMBEDDED_WIFI_CACHE_TX_BUFFERS)
|
|
113
|
+
// Duplex streams need room for uploads and receive ACKs at the same
|
|
114
|
+
// time. Cache overflow otherwise drops packets into TCP's RTO path.
|
|
115
|
+
cfg.cache_tx_buf_num = GEA_EMBEDDED_WIFI_CACHE_TX_BUFFERS;
|
|
116
|
+
#endif
|
|
103
117
|
cfg.mgmt_sbuf_num = 6;
|
|
104
|
-
cfg.ampdu_tx_enable = 0;
|
|
105
118
|
// Give the blob's "wifi" task a stack it can authenticate on.
|
|
106
119
|
applyTaskStackOverride(&cfg);
|
|
107
120
|
#endif // CONFIG_ESP_WIFI_ENABLED — native RX-buf/osi tuning; remote (P4/C6) uses defaults
|
|
@@ -541,6 +554,10 @@ private:
|
|
|
541
554
|
gea::platform::display::Display::reserveInternal(56 * 1024);
|
|
542
555
|
const bool connected = self->init();
|
|
543
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);
|
|
544
561
|
self->bringingUp_ = false;
|
|
545
562
|
vTaskDeleteWithCaps(nullptr);
|
|
546
563
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// IDF 6's public PSA hash API selects Espressif's locked SHA peripheral driver.
|
|
3
|
+
// Preserve libsrtp's HMAC-SHA1 wire tags, including incremental RTP/ROC input.
|
|
4
|
+
#include "auth.h"
|
|
5
|
+
#include "alloc.h"
|
|
6
|
+
#include "err.h"
|
|
7
|
+
#include "auth_test_cases.h"
|
|
8
|
+
#include "psa/crypto.h"
|
|
9
|
+
#include <string.h>
|
|
10
|
+
|
|
11
|
+
typedef struct {
|
|
12
|
+
psa_hash_operation_t inner;
|
|
13
|
+
psa_hash_operation_t outer;
|
|
14
|
+
psa_hash_operation_t work;
|
|
15
|
+
} gea_hmac_state_t;
|
|
16
|
+
|
|
17
|
+
typedef struct {
|
|
18
|
+
srtp_auth_t auth;
|
|
19
|
+
gea_hmac_state_t state;
|
|
20
|
+
} gea_hmac_t;
|
|
21
|
+
|
|
22
|
+
extern const srtp_auth_type_t srtp_hmac;
|
|
23
|
+
srtp_debug_module_t srtp_mod_hmac = { false, "hmac sha-1 psa" };
|
|
24
|
+
|
|
25
|
+
static srtp_err_status_t gea_hmac_alloc(srtp_auth_t **auth, size_t key_len, size_t out_len) {
|
|
26
|
+
if (key_len > 20 || out_len > 20) return srtp_err_status_bad_param;
|
|
27
|
+
gea_hmac_t *instance = srtp_crypto_alloc(sizeof(*instance));
|
|
28
|
+
if (!instance) return srtp_err_status_alloc_fail;
|
|
29
|
+
instance->state.inner = psa_hash_operation_init();
|
|
30
|
+
instance->state.outer = psa_hash_operation_init();
|
|
31
|
+
instance->state.work = psa_hash_operation_init();
|
|
32
|
+
instance->auth.type = &srtp_hmac;
|
|
33
|
+
instance->auth.state = &instance->state;
|
|
34
|
+
instance->auth.key_len = key_len;
|
|
35
|
+
instance->auth.out_len = out_len;
|
|
36
|
+
instance->auth.prefix_len = 0;
|
|
37
|
+
*auth = &instance->auth;
|
|
38
|
+
return srtp_err_status_ok;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static srtp_err_status_t gea_hmac_dealloc(srtp_auth_t *auth) {
|
|
42
|
+
gea_hmac_t *instance = (gea_hmac_t *)auth;
|
|
43
|
+
psa_hash_abort(&instance->state.work);
|
|
44
|
+
psa_hash_abort(&instance->state.inner);
|
|
45
|
+
psa_hash_abort(&instance->state.outer);
|
|
46
|
+
octet_string_set_to_zero(instance, sizeof(*instance));
|
|
47
|
+
srtp_crypto_free(instance);
|
|
48
|
+
return srtp_err_status_ok;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static srtp_err_status_t gea_hmac_start(void *context) {
|
|
52
|
+
gea_hmac_state_t *state = context;
|
|
53
|
+
if (psa_hash_abort(&state->work) != PSA_SUCCESS ||
|
|
54
|
+
psa_hash_clone(&state->inner, &state->work) != PSA_SUCCESS)
|
|
55
|
+
return srtp_err_status_auth_fail;
|
|
56
|
+
return srtp_err_status_ok;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static srtp_err_status_t gea_hmac_init(void *context, const uint8_t *key, size_t key_len) {
|
|
60
|
+
if (key_len > 20 || (key_len && !key)) return srtp_err_status_bad_param;
|
|
61
|
+
gea_hmac_state_t *state = context;
|
|
62
|
+
uint8_t inner_pad[64], outer_pad[64];
|
|
63
|
+
memset(inner_pad, 0x36, sizeof(inner_pad));
|
|
64
|
+
memset(outer_pad, 0x5c, sizeof(outer_pad));
|
|
65
|
+
for (size_t i = 0; i < key_len; ++i) {
|
|
66
|
+
inner_pad[i] ^= key[i];
|
|
67
|
+
outer_pad[i] ^= key[i];
|
|
68
|
+
}
|
|
69
|
+
psa_hash_abort(&state->work);
|
|
70
|
+
psa_hash_abort(&state->inner);
|
|
71
|
+
psa_hash_abort(&state->outer);
|
|
72
|
+
const int ok = psa_crypto_init() == PSA_SUCCESS &&
|
|
73
|
+
psa_hash_setup(&state->inner, PSA_ALG_SHA_1) == PSA_SUCCESS &&
|
|
74
|
+
psa_hash_update(&state->inner, inner_pad, sizeof(inner_pad)) == PSA_SUCCESS &&
|
|
75
|
+
psa_hash_setup(&state->outer, PSA_ALG_SHA_1) == PSA_SUCCESS &&
|
|
76
|
+
psa_hash_update(&state->outer, outer_pad, sizeof(outer_pad)) == PSA_SUCCESS;
|
|
77
|
+
octet_string_set_to_zero(inner_pad, sizeof(inner_pad));
|
|
78
|
+
octet_string_set_to_zero(outer_pad, sizeof(outer_pad));
|
|
79
|
+
if (!ok) return srtp_err_status_auth_fail;
|
|
80
|
+
return gea_hmac_start(state);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static srtp_err_status_t gea_hmac_update(void *context, const uint8_t *message, size_t size) {
|
|
84
|
+
gea_hmac_state_t *state = context;
|
|
85
|
+
if (size && !message) return srtp_err_status_bad_param;
|
|
86
|
+
if (size && psa_hash_update(&state->work, message, size) != PSA_SUCCESS)
|
|
87
|
+
return srtp_err_status_auth_fail;
|
|
88
|
+
return srtp_err_status_ok;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static srtp_err_status_t gea_hmac_compute(void *context, const uint8_t *message, size_t size,
|
|
92
|
+
size_t tag_len, uint8_t *tag) {
|
|
93
|
+
gea_hmac_state_t *state = context;
|
|
94
|
+
if (tag_len > 20 || (tag_len && !tag)) return srtp_err_status_bad_param;
|
|
95
|
+
uint8_t inner_digest[20] = {0}, digest[20] = {0};
|
|
96
|
+
size_t length = 0;
|
|
97
|
+
const int ok = gea_hmac_update(state, message, size) == srtp_err_status_ok &&
|
|
98
|
+
psa_hash_finish(&state->work, inner_digest, sizeof(inner_digest), &length) == PSA_SUCCESS &&
|
|
99
|
+
length == sizeof(inner_digest) &&
|
|
100
|
+
psa_hash_clone(&state->outer, &state->work) == PSA_SUCCESS &&
|
|
101
|
+
psa_hash_update(&state->work, inner_digest, sizeof(inner_digest)) == PSA_SUCCESS &&
|
|
102
|
+
psa_hash_finish(&state->work, digest, sizeof(digest), &length) == PSA_SUCCESS &&
|
|
103
|
+
length == sizeof(digest);
|
|
104
|
+
if (ok && tag_len) memcpy(tag, digest, tag_len);
|
|
105
|
+
octet_string_set_to_zero(inner_digest, sizeof(inner_digest));
|
|
106
|
+
octet_string_set_to_zero(digest, sizeof(digest));
|
|
107
|
+
if (!ok) {
|
|
108
|
+
psa_hash_abort(&state->work);
|
|
109
|
+
return srtp_err_status_auth_fail;
|
|
110
|
+
}
|
|
111
|
+
return srtp_err_status_ok;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const srtp_auth_type_t srtp_hmac = {
|
|
115
|
+
gea_hmac_alloc, gea_hmac_dealloc, gea_hmac_init, gea_hmac_compute,
|
|
116
|
+
gea_hmac_update, gea_hmac_start, "HMAC-SHA1 through ESP-IDF PSA",
|
|
117
|
+
&srtp_hmac_test_case_0, SRTP_HMAC_SHA1
|
|
118
|
+
};
|
|
@@ -62,6 +62,12 @@ namespace pixel = gea::framework::graphics::pixel;
|
|
|
62
62
|
namespace qspi_panel = gea::platform::esp32::chip_bindings::displays;
|
|
63
63
|
namespace present = gea::framework::display_present;
|
|
64
64
|
|
|
65
|
+
// Persistent transfer evidence, independent of serial logging or perf builds.
|
|
66
|
+
static std::atomic<uint32_t> gCompletedDisplayChunks{0};
|
|
67
|
+
extern "C" uint32_t gea_display_completed_chunks() {
|
|
68
|
+
return gCompletedDisplayChunks.load(std::memory_order_relaxed);
|
|
69
|
+
}
|
|
70
|
+
|
|
65
71
|
// Cross-core raster: run a chunk's fill on the idle CPU (both the app frame task
|
|
66
72
|
// and the present task are pinned to APP_FRAME_TASK_CORE) while the present task
|
|
67
73
|
// streams the previous chunk. Defined later in this file. submit() returns false
|
|
@@ -80,6 +86,7 @@ constexpr bool kGea3dTryFullFramePsram = false;
|
|
|
80
86
|
namespace gea::platform::esp32::display
|
|
81
87
|
{
|
|
82
88
|
|
|
89
|
+
|
|
83
90
|
#ifndef GEA_EMBEDDED_DISPLAY_QSPI_PCLK_HZ
|
|
84
91
|
#define GEA_EMBEDDED_DISPLAY_QSPI_PCLK_HZ (80 * 1000 * 1000)
|
|
85
92
|
#endif
|
|
@@ -2957,6 +2964,7 @@ namespace gea::platform::esp32::display
|
|
|
2957
2964
|
auto *self = static_cast<DisplayBackend *>(userContext);
|
|
2958
2965
|
if (!self || !self->flushSlots_)
|
|
2959
2966
|
return false;
|
|
2967
|
+
gCompletedDisplayChunks.fetch_add(1, std::memory_order_relaxed);
|
|
2960
2968
|
#if GEA_EMBEDDED_DISPLAY_PRESENT_SPLIT_LOG
|
|
2961
2969
|
// TEMP wire probe (gea3d present-path work): per-chunk DMA completion
|
|
2962
2970
|
// timestamps; paired with kick timestamps to derive real chunk service
|
|
@@ -5926,11 +5934,18 @@ namespace
|
|
|
5926
5934
|
// to blocking so CPU1's idle task + the task watchdog still run.
|
|
5927
5935
|
while (g_geaRenderWorker.jobSeq.load(std::memory_order_acquire) == seen)
|
|
5928
5936
|
{
|
|
5937
|
+
#if defined(GEA_EMBEDDED_APP_USES_AUDIO) && GEA_EMBEDDED_APP_USES_AUDIO
|
|
5938
|
+
// Audio/video workloads need this core between raster jobs. Submit
|
|
5939
|
+
// publishes the sequence before notifying, so blocking has no lost
|
|
5940
|
+
// wakeup and does not require an idle spin window.
|
|
5941
|
+
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
|
5942
|
+
#else
|
|
5929
5943
|
if (esp_timer_get_time() - idleSince > 4000)
|
|
5930
5944
|
{
|
|
5931
5945
|
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(100));
|
|
5932
5946
|
idleSince = esp_timer_get_time();
|
|
5933
5947
|
}
|
|
5948
|
+
#endif
|
|
5934
5949
|
}
|
|
5935
5950
|
seen = g_geaRenderWorker.jobSeq.load(std::memory_order_acquire);
|
|
5936
5951
|
const std::int64_t s = esp_timer_get_time();
|
|
@@ -6030,6 +6045,12 @@ extern "C" void gea_render_parallel_wait()
|
|
|
6030
6045
|
const std::int64_t deadline = w0 + 100000; // 100ms safety net
|
|
6031
6046
|
while (!g_geaRenderWorker.done.load(std::memory_order_acquire))
|
|
6032
6047
|
{
|
|
6048
|
+
#if defined(GEA_EMBEDDED_APP_USES_AUDIO) && GEA_EMBEDDED_APP_USES_AUDIO
|
|
6049
|
+
// Media load makes a band much longer than the graphics-only spin window.
|
|
6050
|
+
// Its worker already notifies completion: park instead of burning CPU0
|
|
6051
|
+
// while the microphone encoder and idle task need to run.
|
|
6052
|
+
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(2));
|
|
6053
|
+
#endif
|
|
6033
6054
|
if (esp_timer_get_time() > deadline)
|
|
6034
6055
|
{
|
|
6035
6056
|
std::printf("[render-worker] WAIT TIMEOUT — worker wedged?\n");
|
|
@@ -140,6 +140,12 @@ if(COMMAND idf_build_set_property)
|
|
|
140
140
|
# file is a board, and the runtime only tests that the macro is defined, so it is set here for
|
|
141
141
|
# the whole build: the app, main and the framework must agree on the pool layout.
|
|
142
142
|
idf_build_set_property(COMPILE_DEFINITIONS "GEA_EMBEDDED_CPP_BOARD" APPEND)
|
|
143
|
+
# Startup and the frame loop are one serialized JS mutator, even when boot
|
|
144
|
+
# runs on main_task and hands the heap to an external-stack runtime task.
|
|
145
|
+
# Per-OS-thread pools/collector lists would strand startup candidates with
|
|
146
|
+
# their buffered bits set; the loop then mistakes those bits for graph IDs.
|
|
147
|
+
# Native workers enqueue events; application callbacks run on the loop.
|
|
148
|
+
idf_build_set_property(COMPILE_DEFINITIONS "GEA_RUNTIME_SINGLE_THREADED=1" APPEND)
|
|
143
149
|
endif()
|
|
144
150
|
|
|
145
151
|
# Linker fragments are absolute paths from the CLI. ldgen merges every
|
|
@@ -206,6 +212,7 @@ set(GEA_FW_APP_SENSITIVE_SOURCES
|
|
|
206
212
|
"${GEA_HOST}/host/http.cpp"
|
|
207
213
|
"${GEA_HOST}/host/image.cpp"
|
|
208
214
|
"${GEA_HOST}/host/rtc.cpp"
|
|
215
|
+
"${GEA_HOST}/host/mjpeg.cpp"
|
|
209
216
|
"${GEA_HOST}/host/tile_loader.cpp"
|
|
210
217
|
"${GEA_HOST}/services/bluetooth_service.cpp"
|
|
211
218
|
"${GEA_HOST}/services/network_services.cpp"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# ESP-IDF 6.0.x wakes a synchronous I2C caller before copying the final RX
|
|
2
|
+
# bytes. On dual-core chips that caller can replace i2c_trans.ops while the
|
|
3
|
+
# ISR still uses it (observed with GT911 reads followed by an address probe).
|
|
4
|
+
# Compile a corrected build-local source, leaving the installed SDK untouched.
|
|
5
|
+
function(gea_fix_i2c_completion_order)
|
|
6
|
+
if(NOT TARGET __idf_esp_driver_i2c)
|
|
7
|
+
return()
|
|
8
|
+
endif()
|
|
9
|
+
|
|
10
|
+
get_target_property(component_dir __idf_esp_driver_i2c SOURCE_DIR)
|
|
11
|
+
set(source "${component_dir}/i2c_master.c")
|
|
12
|
+
file(READ "${source}" contents)
|
|
13
|
+
set(notify [=[ if (i2c_master->event != I2C_EVENT_ALIVE) {
|
|
14
|
+
xQueueSendFromISR(i2c_master->event_queue, (void *)&i2c_master->event, &HPTaskAwoken);
|
|
15
|
+
}
|
|
16
|
+
]=])
|
|
17
|
+
set(receive [=[ if (i2c_master->contains_read == true) {
|
|
18
|
+
if (int_mask & I2C_LL_INTR_MST_COMPLETE || int_mask & I2C_LL_INTR_END_DETECT) {
|
|
19
|
+
i2c_isr_receive_handler(i2c_master);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]=])
|
|
23
|
+
string(FIND "${contents}" "${notify}${receive}" unsafe_order)
|
|
24
|
+
if(unsafe_order EQUAL -1)
|
|
25
|
+
# A newer SDK may already do the copy first. Do not rewrite a driver
|
|
26
|
+
# whose implementation differs from the precisely identified defect.
|
|
27
|
+
string(FIND "${contents}" "${receive}${notify}" fixed_order)
|
|
28
|
+
if(fixed_order EQUAL -1)
|
|
29
|
+
message(FATAL_ERROR "I2C completion ordering is unknown for this SDK; review i2c_master.c before using concurrent reads/probes")
|
|
30
|
+
endif()
|
|
31
|
+
return()
|
|
32
|
+
endif()
|
|
33
|
+
|
|
34
|
+
string(REPLACE "${notify}${receive}" "${receive}${notify}" corrected "${contents}")
|
|
35
|
+
set(output "${CMAKE_BINARY_DIR}/gea_i2c_master.c")
|
|
36
|
+
if(EXISTS "${output}")
|
|
37
|
+
file(READ "${output}" previous)
|
|
38
|
+
endif()
|
|
39
|
+
if(NOT "${previous}" STREQUAL "${corrected}")
|
|
40
|
+
file(WRITE "${output}" "${corrected}")
|
|
41
|
+
endif()
|
|
42
|
+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${source}")
|
|
43
|
+
get_target_property(sources __idf_esp_driver_i2c SOURCES)
|
|
44
|
+
set(replaced_sources)
|
|
45
|
+
foreach(entry IN LISTS sources)
|
|
46
|
+
if(entry STREQUAL "i2c_master.c" OR entry STREQUAL "${source}")
|
|
47
|
+
list(APPEND replaced_sources "${output}")
|
|
48
|
+
elseif(IS_ABSOLUTE "${entry}" OR entry MATCHES "^\\$<")
|
|
49
|
+
list(APPEND replaced_sources "${entry}")
|
|
50
|
+
else()
|
|
51
|
+
list(APPEND replaced_sources "${component_dir}/${entry}")
|
|
52
|
+
endif()
|
|
53
|
+
endforeach()
|
|
54
|
+
set_property(TARGET __idf_esp_driver_i2c PROPERTY SOURCES "${replaced_sources}")
|
|
55
|
+
target_include_directories(__idf_esp_driver_i2c PRIVATE "${component_dir}")
|
|
56
|
+
message(STATUS "I2C: finish RX copy before notifying synchronous callers")
|
|
57
|
+
endfunction()
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"""Generate narrowly patched SDK sources in the normal build output.
|
|
2
|
+
|
|
3
|
+
Registry sources stay untouched. Reject source drift instead of guessing where
|
|
4
|
+
allocation/lifetime fixes belong. Espressif WebSocket 1.8 / codec-dev 1.6.2,
|
|
5
|
+
ESP-IDF 6.0.2 WebSocket transport.
|
|
6
|
+
"""
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def replace_once(source, old, new):
|
|
12
|
+
if source.count(old) != 1:
|
|
13
|
+
raise ValueError(f"SDK source drift at {old[:80]!r}")
|
|
14
|
+
return source.replace(old, new, 1)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def patch_websocket(source):
|
|
18
|
+
source = replace_once(source, '#include "freertos/task.h"',
|
|
19
|
+
'#include "freertos/task.h"\n#include "freertos/idf_additions.h"\n#include "esp_heap_caps.h"')
|
|
20
|
+
source = replace_once(source,
|
|
21
|
+
' destroy_and_free_resources(client);\n return ESP_OK;\n}',
|
|
22
|
+
''' // STOPPED_BIT is published after the last client access by its task.
|
|
23
|
+
// Reap the suspended task here; never free a running external stack.
|
|
24
|
+
if (client->task_handle) {
|
|
25
|
+
while (eTaskGetState(client->task_handle) != eSuspended) {
|
|
26
|
+
vTaskDelay(1);
|
|
27
|
+
}
|
|
28
|
+
vTaskDeleteWithCaps(client->task_handle);
|
|
29
|
+
client->task_handle = NULL;
|
|
30
|
+
}
|
|
31
|
+
destroy_and_free_resources(client);
|
|
32
|
+
return ESP_OK;
|
|
33
|
+
}''')
|
|
34
|
+
source = replace_once(source,
|
|
35
|
+
''' if (client->selected_for_destroying == true) {
|
|
36
|
+
destroy_and_free_resources(client);
|
|
37
|
+
} else {
|
|
38
|
+
xEventGroupSetBits(client->status_bits, STOPPED_BIT);
|
|
39
|
+
}
|
|
40
|
+
vTaskDelete(NULL);''',
|
|
41
|
+
''' if (client->selected_for_destroying == true) {
|
|
42
|
+
destroy_and_free_resources(client);
|
|
43
|
+
vTaskDeleteWithCaps(NULL);
|
|
44
|
+
} else {
|
|
45
|
+
xEventGroupSetBits(client->status_bits, STOPPED_BIT);
|
|
46
|
+
vTaskSuspend(NULL); // destroy/start joins and frees this PSRAM stack.
|
|
47
|
+
}''')
|
|
48
|
+
source = replace_once(source, ' client->transport = client->config->ext_transport;',
|
|
49
|
+
''' if (client->task_handle) {
|
|
50
|
+
while (eTaskGetState(client->task_handle) != eSuspended) {
|
|
51
|
+
vTaskDelay(1);
|
|
52
|
+
}
|
|
53
|
+
vTaskDeleteWithCaps(client->task_handle);
|
|
54
|
+
client->task_handle = NULL;
|
|
55
|
+
}
|
|
56
|
+
client->transport = client->config->ext_transport;''')
|
|
57
|
+
source = replace_once(source, ' if (xTaskCreatePinnedToCore(esp_websocket_client_task,',
|
|
58
|
+
''' const UBaseType_t stack_caps = MALLOC_CAP_8BIT |
|
|
59
|
+
(heap_caps_get_total_size(MALLOC_CAP_SPIRAM) ? MALLOC_CAP_SPIRAM : MALLOC_CAP_INTERNAL);
|
|
60
|
+
if (xTaskCreatePinnedToCoreWithCaps(esp_websocket_client_task,''')
|
|
61
|
+
source = replace_once(source, '&client->task_handle, client->config->task_core_id) != pdTRUE)',
|
|
62
|
+
'&client->task_handle, client->config->task_core_id, stack_caps) != pdTRUE)')
|
|
63
|
+
source = replace_once(source,
|
|
64
|
+
''' // Now acquire tx_lock with timeout (consistent with PONG handling)
|
|
65
|
+
if (xSemaphoreTakeRecursive(client->tx_lock, WEBSOCKET_TX_LOCK_TIMEOUT_MS) != pdPASS) {
|
|
66
|
+
ESP_LOGE(TAG, "Could not lock ws-client within %d timeout for PING", WEBSOCKET_TX_LOCK_TIMEOUT_MS);''',
|
|
67
|
+
''' // Optional heartbeats must not suspend incoming media behind
|
|
68
|
+
// a busy sender. The next ping interval retries; PONG/CLOSE
|
|
69
|
+
// retain their required handshake behavior.
|
|
70
|
+
if (xSemaphoreTakeRecursive(client->tx_lock, 0) != pdPASS) {
|
|
71
|
+
ESP_LOGD(TAG, "Skipping PING while transmitter is busy");''')
|
|
72
|
+
return source
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def patch_ws_transport(source):
|
|
76
|
+
source = replace_once(source, '#include "esp_tls_crypto.h"',
|
|
77
|
+
'#include "esp_tls_crypto.h"\n#include "esp_timer.h"\n#include "esp_heap_caps.h"')
|
|
78
|
+
source = replace_once(source, '#define MAX_WEBSOCKET_HEADER_SIZE 16',
|
|
79
|
+
'#define MAX_WEBSOCKET_HEADER_SIZE 16\n#define GEA_WS_TX_BUFFER_SIZE 4096')
|
|
80
|
+
source = replace_once(source, ' size_t response_header_len;\n} transport_ws_t;',
|
|
81
|
+
''' size_t response_header_len;
|
|
82
|
+
char *gea_tx_buffer; /*!< Separate from handshake/RX storage; writers are serialized by the client. */
|
|
83
|
+
} transport_ws_t;''')
|
|
84
|
+
source = replace_once(source, ' free(ws->redir_host);\n free(ws->path);',
|
|
85
|
+
' free(ws->gea_tx_buffer);\n free(ws->redir_host);\n free(ws->path);')
|
|
86
|
+
source = replace_once(source,
|
|
87
|
+
''' char *buffer = (char *)b;
|
|
88
|
+
char ws_header[MAX_WEBSOCKET_HEADER_SIZE];
|
|
89
|
+
char *mask;
|
|
90
|
+
int header_len = 0, i;
|
|
91
|
+
|
|
92
|
+
int poll_write;
|
|
93
|
+
if ((poll_write = esp_transport_poll_write(ws->parent, timeout_ms)) <= 0) {
|
|
94
|
+
ESP_LOGE(TAG, "Error transport_poll_write(%d)", poll_write);
|
|
95
|
+
return poll_write;
|
|
96
|
+
}''',
|
|
97
|
+
''' char ws_header[MAX_WEBSOCKET_HEADER_SIZE];
|
|
98
|
+
int header_len = 0;
|
|
99
|
+
if (len < 0 || (len && !b)) {
|
|
100
|
+
return -1;
|
|
101
|
+
}
|
|
102
|
+
const int64_t deadline_us = timeout_ms < 0 ? 0 :
|
|
103
|
+
esp_timer_get_time() + (int64_t)timeout_ms * 1000;
|
|
104
|
+
if (!ws->gea_tx_buffer) {
|
|
105
|
+
// Keep the bounded staging buffer out of scarce DMA/internal RAM
|
|
106
|
+
// when PSRAM is available. Non-PSRAM boards retain malloc fallback.
|
|
107
|
+
ws->gea_tx_buffer = heap_caps_malloc(GEA_WS_TX_BUFFER_SIZE, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
|
108
|
+
if (!ws->gea_tx_buffer) {
|
|
109
|
+
ws->gea_tx_buffer = malloc(GEA_WS_TX_BUFFER_SIZE);
|
|
110
|
+
}
|
|
111
|
+
if (!ws->gea_tx_buffer) {
|
|
112
|
+
ESP_LOGE(TAG, "Cannot allocate WebSocket transmit buffer");
|
|
113
|
+
return -1;
|
|
114
|
+
}
|
|
115
|
+
}''')
|
|
116
|
+
source = replace_once(source,
|
|
117
|
+
''' if (mask_flag) {
|
|
118
|
+
mask = &ws_header[header_len];
|
|
119
|
+
ssize_t rc;
|
|
120
|
+
if ((rc = getrandom(ws_header + header_len, 4, 0)) < 0) {
|
|
121
|
+
ESP_LOGD(TAG, "getrandom() returned %zd", rc);
|
|
122
|
+
return -1;
|
|
123
|
+
}
|
|
124
|
+
header_len += 4;
|
|
125
|
+
|
|
126
|
+
for (i = 0; i < len; ++i) {
|
|
127
|
+
buffer[i] = (buffer[i] ^ mask[i % 4]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (esp_transport_write(ws->parent, ws_header, header_len, timeout_ms) != header_len) {
|
|
132
|
+
ESP_LOGE(TAG, "Error write header");
|
|
133
|
+
return -1;
|
|
134
|
+
}
|
|
135
|
+
if (len == 0) {
|
|
136
|
+
return 0;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
int ret = esp_transport_write(ws->parent, buffer, len, timeout_ms);
|
|
140
|
+
// in case of masked transport we have to revert back to the original data, as ws layer
|
|
141
|
+
// does not create its own copy of data to be sent
|
|
142
|
+
if (mask_flag) {
|
|
143
|
+
mask = &ws_header[header_len - 4];
|
|
144
|
+
for (i = 0; i < len; ++i) {
|
|
145
|
+
buffer[i] = (buffer[i] ^ mask[i % 4]);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return ret;''',
|
|
149
|
+
''' if (mask_flag) {
|
|
150
|
+
const ssize_t rc = getrandom(ws_header + header_len, 4, 0);
|
|
151
|
+
if (rc != 4) {
|
|
152
|
+
ESP_LOGD(TAG, "getrandom() returned %zd", rc);
|
|
153
|
+
return -1;
|
|
154
|
+
}
|
|
155
|
+
header_len += 4;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// A standalone WS header becomes a tiny TLS record, followed by another
|
|
159
|
+
// socket-writability wait before its payload. Coalesce both; common audio
|
|
160
|
+
// frames fit in one TLS write. Larger frames keep the same WS framing and
|
|
161
|
+
// masking position while streaming through this bounded staging buffer.
|
|
162
|
+
memcpy(ws->gea_tx_buffer, ws_header, header_len);
|
|
163
|
+
int prefix = header_len;
|
|
164
|
+
int offset = 0;
|
|
165
|
+
do {
|
|
166
|
+
const int capacity = GEA_WS_TX_BUFFER_SIZE - prefix;
|
|
167
|
+
const int count = len - offset < capacity ? len - offset : capacity;
|
|
168
|
+
for (int i = 0; i < count; ++i) {
|
|
169
|
+
const char mask = mask_flag ? ws_header[header_len - 4 + ((offset + i) & 3)] : 0;
|
|
170
|
+
ws->gea_tx_buffer[prefix + i] = b[offset + i] ^ mask;
|
|
171
|
+
}
|
|
172
|
+
const int chunk_len = prefix + count;
|
|
173
|
+
int written = 0;
|
|
174
|
+
while (written < chunk_len) {
|
|
175
|
+
int remaining_ms = timeout_ms;
|
|
176
|
+
if (timeout_ms >= 0) {
|
|
177
|
+
const int64_t left_us = deadline_us - esp_timer_get_time();
|
|
178
|
+
remaining_ms = left_us > 0 ? (int)((left_us + 999) / 1000) : 0;
|
|
179
|
+
}
|
|
180
|
+
const int ret = esp_transport_write(ws->parent, ws->gea_tx_buffer + written,
|
|
181
|
+
chunk_len - written, remaining_ms);
|
|
182
|
+
if (ret <= 0 || ret > chunk_len - written) {
|
|
183
|
+
// Once any frame bytes went out, retrying as a fresh WS frame
|
|
184
|
+
// would corrupt the stream. Let the client abort the connection.
|
|
185
|
+
ESP_LOGE(TAG, "Error write WebSocket frame (%d)", ret);
|
|
186
|
+
return -1;
|
|
187
|
+
}
|
|
188
|
+
written += ret;
|
|
189
|
+
}
|
|
190
|
+
offset += count;
|
|
191
|
+
prefix = 0;
|
|
192
|
+
} while (offset < len);
|
|
193
|
+
return len;''')
|
|
194
|
+
return source
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def patch_codec(source):
|
|
198
|
+
return replace_once(source,
|
|
199
|
+
''' ret = set_drv_fs(channel, true, bits_per_sample, i2s_data->clk_src, fs);
|
|
200
|
+
_i2s_drv_enable(paired, true, true);''',
|
|
201
|
+
''' ret = set_drv_fs(channel, true, bits_per_sample, i2s_data->clk_src, fs);
|
|
202
|
+
// Reconfiguration may fail after releasing DMA. Enabling that channel
|
|
203
|
+
// dereferences a null DMA descriptor in ESP-IDF; propagate the failure.
|
|
204
|
+
if (ret != ESP_CODEC_DEV_OK) {
|
|
205
|
+
return ret;
|
|
206
|
+
}
|
|
207
|
+
ret = _i2s_drv_enable(paired, true, true);''')
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def patch_srtp_aes(source):
|
|
211
|
+
# IDF 6 removed mbedtls/aes.h, but exposes the same CTR contract through
|
|
212
|
+
# its native, internally locked AES peripheral driver. Keep libsrtp's
|
|
213
|
+
# counter/salt construction and error handling unchanged.
|
|
214
|
+
source = replace_once(source, '#include <mbedtls/aes.h>', '#include "aes/esp_aes.h"')
|
|
215
|
+
source = replace_once(source, '#include "aes_icm_ext.h"', '#include "gea_srtp_aes_icm.h"')
|
|
216
|
+
source = source.replace('mbedtls_aes_setkey_enc', 'esp_aes_setkey')
|
|
217
|
+
return source.replace('mbedtls_aes_', 'esp_aes_')
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def patch_srtp_aes_header(source):
|
|
221
|
+
source = replace_once(source, '#include <mbedtls/aes.h>', '#include "aes/esp_aes.h"')
|
|
222
|
+
return replace_once(source, 'mbedtls_aes_context *ctx;', 'esp_aes_context *ctx;')
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
if __name__ == '__main__':
|
|
226
|
+
kind, source_file, destination_file = sys.argv[1:]
|
|
227
|
+
source = Path(source_file).read_text()
|
|
228
|
+
patched = {'websocket': patch_websocket, 'ws_transport': patch_ws_transport,
|
|
229
|
+
'codec': patch_codec, 'srtp_aes': patch_srtp_aes,
|
|
230
|
+
'srtp_aes_header': patch_srtp_aes_header}[kind](source)
|
|
231
|
+
destination = Path(destination_file)
|
|
232
|
+
if not destination.exists() or destination.read_text() != patched:
|
|
233
|
+
destination.write_text(patched)
|