@geastack/targets 0.1.83 → 0.1.84
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/README.md +24 -0
- package/package.json +9 -8
- package/targets/esp32/chip_bindings/audio/es8311.cpp +30 -8
- package/targets/esp32/display.cpp +57 -28
- package/targets/esp32/memory_config.h +7 -0
- package/targets/esp32/services/app_runner.cpp +13 -4
- package/targets/esp32/services/device_control.cpp +82 -27
- package/targets/esp32/services/frame_scheduler.cpp +117 -2
- package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +25 -5
- package/targets/esp32-s3-touch-amoled-1.8/main/panel_reset.cpp +54 -0
- package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +1 -42
package/README.md
CHANGED
|
@@ -68,6 +68,30 @@ See the `tutorials` repository's
|
|
|
68
68
|
`embedded-tutorials/02-custom-board-composition` course for a complete target
|
|
69
69
|
definition and firmware build.
|
|
70
70
|
|
|
71
|
+
## ES8311 audio duplex mode
|
|
72
|
+
|
|
73
|
+
The ESP32 ES8311 binding defaults to half duplex. Applications can opt into
|
|
74
|
+
simultaneous capture and playback with `"GEA_AUDIO_FULL_DUPLEX=1"` in their
|
|
75
|
+
`gea.defines` array. Removing the define restores the default; it is not a
|
|
76
|
+
board-wide setting. On the AMOLED 2.06, capture uses its separate ES7210 ADC.
|
|
77
|
+
|
|
78
|
+
In full duplex, opening either direction preserves the other. RX uses 20 ms
|
|
79
|
+
blocks and does not hold the TX write lock while waiting for samples. Both
|
|
80
|
+
directions must use the same sample rate because they share I2S clocks; a
|
|
81
|
+
conflicting open fails without closing the existing stream. Capture is 16 kHz,
|
|
82
|
+
so simultaneous playback must also be 16 kHz. Closing playback leaves capture
|
|
83
|
+
running, and audio resources are released once neither direction uses them.
|
|
84
|
+
|
|
85
|
+
The driver exposes raw microphone audio; this option does not add acoustic
|
|
86
|
+
echo cancellation. Applications using a loudspeaker must provide their own
|
|
87
|
+
echo processing if required. Default half-duplex capture keeps its existing
|
|
88
|
+
2048-sample blocks and playback arbitration.
|
|
89
|
+
|
|
90
|
+
`node targets/esp32/test/audio-full-duplex.test.mjs` compiles the production
|
|
91
|
+
open/capture methods in both modes, checks clock conflicts, and verifies that
|
|
92
|
+
a blocked RX read permits TX progress only in the opted-in mode. Its executable
|
|
93
|
+
uses the board's existing ignored `build/` directory.
|
|
94
|
+
|
|
71
95
|
## License
|
|
72
96
|
|
|
73
97
|
This repo is the GeaStack **embedded board support** (ESP32, RP2350) and is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/targets",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.84",
|
|
4
4
|
"description": "Native embedded build targets (ESP32-IDF, RP2350) for geastack apps: board sources, target catalog, and CMake glue driven by the gea CLI.",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -36,15 +36,16 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@geastack/chips": "^0.1.4",
|
|
39
|
-
"@geastack/compiler": "^1.0.
|
|
40
|
-
"@geastack/core": "^0.1.
|
|
41
|
-
"@geastack/elements": "^0.1.
|
|
42
|
-
"@geastack/engine": "^0.1.
|
|
39
|
+
"@geastack/compiler": "^1.0.19",
|
|
40
|
+
"@geastack/core": "^0.1.30",
|
|
41
|
+
"@geastack/elements": "^0.1.3",
|
|
42
|
+
"@geastack/engine": "^0.1.8",
|
|
43
43
|
"@geastack/geaos": "^0.1.3",
|
|
44
|
-
"@geastack/geatsc-plugin-gea": "^0.1.
|
|
45
|
-
"@geastack/host": "^0.1.
|
|
44
|
+
"@geastack/geatsc-plugin-gea": "^0.1.11",
|
|
45
|
+
"@geastack/host": "^0.1.9"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"test": "for f in $(git ls-files | grep -E '(^|/)(test[-_][^/]*|[^/]*\\.test)\\.mjs$'); do echo \"==> $f\"; node \"$f\" || exit 1; done"
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
|
+
"gitHead": "10230ddd9bec0287a8705c8e1f96fb06a063c845"
|
|
50
51
|
}
|
|
@@ -23,10 +23,15 @@
|
|
|
23
23
|
|
|
24
24
|
#include "host/media.h"
|
|
25
25
|
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
// Full duplex is an app opt-in. Both directions share a clock, so a live
|
|
27
|
+
// capture stream cannot coexist with playback at a different sample rate.
|
|
28
|
+
#ifndef GEA_AUDIO_FULL_DUPLEX
|
|
29
|
+
#define GEA_AUDIO_FULL_DUPLEX 0
|
|
30
|
+
#endif
|
|
31
|
+
static_assert(GEA_AUDIO_FULL_DUPLEX == 0 || GEA_AUDIO_FULL_DUPLEX == 1);
|
|
32
|
+
|
|
33
|
+
// Capture is raw microphone PCM. Full duplex does not imply acoustic echo
|
|
34
|
+
// cancellation; the application must supply any required echo processing.
|
|
30
35
|
|
|
31
36
|
namespace gea::platform::esp32::chip_bindings::es8311 {
|
|
32
37
|
|
|
@@ -66,6 +71,7 @@ public:
|
|
|
66
71
|
|
|
67
72
|
bool open(int sampleRate, int channels, int bitsPerSample) {
|
|
68
73
|
std::lock_guard<std::mutex> lock(writeMutex_);
|
|
74
|
+
std::lock_guard<std::mutex> captureLock(readMutex_);
|
|
69
75
|
const gea::chips::es8311::OutputFormat format(sampleRate, channels, bitsPerSample);
|
|
70
76
|
if (!format.isPcm16()) return false;
|
|
71
77
|
|
|
@@ -77,7 +83,11 @@ public:
|
|
|
77
83
|
return true;
|
|
78
84
|
}
|
|
79
85
|
|
|
80
|
-
if (
|
|
86
|
+
if constexpr (GEA_AUDIO_FULL_DUPLEX) {
|
|
87
|
+
if (recordOpen_ && i2sSampleRate_ != sampleRate) return false;
|
|
88
|
+
} else {
|
|
89
|
+
if (recordOpen_) closeRecorderLocked();
|
|
90
|
+
}
|
|
81
91
|
if (speakerOpen_) closeSpeakerLocked();
|
|
82
92
|
|
|
83
93
|
const esp_err_t initErr = initSpeaker(sampleRate);
|
|
@@ -142,6 +152,7 @@ public:
|
|
|
142
152
|
|
|
143
153
|
void close() {
|
|
144
154
|
std::lock_guard<std::mutex> lock(writeMutex_);
|
|
155
|
+
std::lock_guard<std::mutex> captureLock(readMutex_);
|
|
145
156
|
closeSpeakerLocked();
|
|
146
157
|
// An idle capture task leaves the audio path up while the speaker plays; free it once neither uses it.
|
|
147
158
|
if (!micInUse()) releaseAudioLocked();
|
|
@@ -377,8 +388,13 @@ private:
|
|
|
377
388
|
|
|
378
389
|
esp_err_t initRecorder(int sampleRate) {
|
|
379
390
|
if (recordOpen_ && i2sSampleRate_ == sampleRate) return ESP_OK;
|
|
391
|
+
if constexpr (GEA_AUDIO_FULL_DUPLEX) {
|
|
392
|
+
if (speakerOpen_ && speakerSampleRate_ != sampleRate) return ESP_ERR_NOT_SUPPORTED;
|
|
393
|
+
}
|
|
380
394
|
if (recordOpen_) closeRecorderLocked();
|
|
381
|
-
if (
|
|
395
|
+
if constexpr (!GEA_AUDIO_FULL_DUPLEX) {
|
|
396
|
+
if (speakerOpen_) closeSpeakerLocked();
|
|
397
|
+
}
|
|
382
398
|
|
|
383
399
|
esp_err_t err = initCodecDevice(sampleRate, ESP_CODEC_DEV_TYPE_IN, recordCodec_);
|
|
384
400
|
if (err != ESP_OK) return err;
|
|
@@ -513,13 +529,16 @@ private:
|
|
|
513
529
|
int speakerChannels_ = 0;
|
|
514
530
|
int speakerBitsPerSample_ = 0;
|
|
515
531
|
int speakerVolume_ = 100;
|
|
532
|
+
// Configuration/destruction takes write then read. A duplex read releases
|
|
533
|
+
// write before blocking on RX, allowing TX to run at the same time.
|
|
516
534
|
std::mutex writeMutex_;
|
|
535
|
+
std::mutex readMutex_;
|
|
517
536
|
|
|
518
537
|
TaskHandle_t captureTask_ = nullptr;
|
|
519
538
|
std::vector<gea::host::NativeMediaTrackHandle> attachedTracks_;
|
|
520
539
|
std::vector<gea::host::NativeMediaTrackHandle> captureSnapshot_;
|
|
521
540
|
std::mutex attachedMutex_;
|
|
522
|
-
static constexpr std::size_t kCaptureFrameSamples = 2048;
|
|
541
|
+
static constexpr std::size_t kCaptureFrameSamples = GEA_AUDIO_FULL_DUPLEX ? 320 : 2048;
|
|
523
542
|
std::array<std::int16_t, kCaptureFrameSamples * 2> stereoFrame_{};
|
|
524
543
|
std::array<std::int16_t, kCaptureFrameSamples> monoFrame_{};
|
|
525
544
|
|
|
@@ -551,6 +570,7 @@ private:
|
|
|
551
570
|
if (idle) {
|
|
552
571
|
{
|
|
553
572
|
std::lock_guard<std::mutex> lock(writeMutex_);
|
|
573
|
+
std::lock_guard<std::mutex> captureLock(readMutex_);
|
|
554
574
|
// A track attached since the check started a new capture task, which now owns the audio path.
|
|
555
575
|
if (!micInUse()) {
|
|
556
576
|
closeRecorderLocked();
|
|
@@ -563,9 +583,11 @@ private:
|
|
|
563
583
|
|
|
564
584
|
int err = ESP_OK;
|
|
565
585
|
{
|
|
566
|
-
std::
|
|
586
|
+
std::unique_lock<std::mutex> lock(writeMutex_);
|
|
587
|
+
std::lock_guard<std::mutex> captureLock(readMutex_);
|
|
567
588
|
err = initRecorder(16000);
|
|
568
589
|
if (err == ESP_OK && recordCodec_) {
|
|
590
|
+
if constexpr (GEA_AUDIO_FULL_DUPLEX) lock.unlock();
|
|
569
591
|
err = esp_codec_dev_read(recordCodec_, stereoFrame_.data(), stereoFrame_.size() * sizeof(std::int16_t));
|
|
570
592
|
}
|
|
571
593
|
}
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
#include "freertos/task.h"
|
|
42
42
|
#include "freertos/idf_additions.h"
|
|
43
43
|
#include "ui/state_init.h"
|
|
44
|
+
#include "ui/dirty_regions.h"
|
|
44
45
|
|
|
45
46
|
#if GEA_BOARD_PREPARE_DISPLAY_PANEL
|
|
46
47
|
namespace gea::platform::board
|
|
@@ -267,19 +268,12 @@ namespace gea::platform::esp32::display
|
|
|
267
268
|
constexpr std::uint16_t kConsoleBackground = pixel::fromRgb565(0x0000);
|
|
268
269
|
constexpr int kFlushChunkDefault = GEA_EMBEDDED_DISPLAY_FLUSH_CHUNK_MAX;
|
|
269
270
|
constexpr int kFlushChunkLimit = GEA_EMBEDDED_DISPLAY_FLUSH_CHUNK_LIMIT;
|
|
270
|
-
//
|
|
271
|
-
//
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
//
|
|
275
|
-
// RM69080/RM690B0 windows require an even first row and an even row count.
|
|
276
|
-
// clampAndAlign aligns the outer rect, but a one-row fallback would split it
|
|
277
|
-
// into invalid windows. Prefer a two-row, one-deep pipeline if RAM is tight.
|
|
278
|
-
#if GEA_EMBEDDED_RM690B0_PANEL
|
|
271
|
+
// Preserve the even-row windows used by the QSPI AMOLED path, including
|
|
272
|
+
// under Wi-Fi memory pressure. CO5300 and RM69080/RM690B0 reject one-row
|
|
273
|
+
// windows. Aligning only the outer dirty rectangle is insufficient: every
|
|
274
|
+
// independently addressed DMA chunk must also contain an even row count.
|
|
275
|
+
// Two rows, one-deep is the smallest safe fallback (1640 bytes at 410 px).
|
|
279
276
|
constexpr int kFlushChunkMin = 2;
|
|
280
|
-
#else
|
|
281
|
-
constexpr int kFlushChunkMin = 1;
|
|
282
|
-
#endif
|
|
283
277
|
static_assert(kFlushChunkLimit >= kFlushChunkMin, "flush limit is below the panel minimum");
|
|
284
278
|
// Leave enough DMA-capable internal RAM for the WiFi driver to receive a
|
|
285
279
|
// packet after the display pipeline is allocated. On the 2.06-inch S3 board,
|
|
@@ -1315,6 +1309,15 @@ namespace gea::platform::esp32::display
|
|
|
1315
1309
|
const int width = x1 - x0 + 1;
|
|
1316
1310
|
const int totalRows = y1 - y0 + 1;
|
|
1317
1311
|
|
|
1312
|
+
#if GEA_EMBEDDED_RM690B0_PANEL && !GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_CS_HELD_STREAM && \
|
|
1313
|
+
!GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_STREAM_FLUSH && !GEA_EMBEDDED_DISPLAY_CO5300_STREAM_FLUSH
|
|
1314
|
+
// Keep separate panel windows, but rasterize the alternate slot while
|
|
1315
|
+
// the previous band transmits. A pending resize must drain first.
|
|
1316
|
+
const bool deferEntryDrain = raster && flushQueueDepth_ > 1 && !g_flushBudgetDirty;
|
|
1317
|
+
#else
|
|
1318
|
+
constexpr bool deferEntryDrain = false;
|
|
1319
|
+
#endif
|
|
1320
|
+
|
|
1318
1321
|
// Drain any tail DMA left in flight by a prior flushFramebufferRectFrom
|
|
1319
1322
|
// that returned with waitAtEnd=false. Cheap (semaphore takes return
|
|
1320
1323
|
// immediately) when nothing is pending. Must run before setWindow so
|
|
@@ -1323,7 +1326,7 @@ namespace gea::platform::esp32::display
|
|
|
1323
1326
|
// rect — that's what capped the fused path at 35fps.
|
|
1324
1327
|
setFlushStage(FlushStage::WaitComplete, 0);
|
|
1325
1328
|
const int64_t entryWaitStartUs = esp_timer_get_time();
|
|
1326
|
-
if (!waitForFlushCompleteSpin())
|
|
1329
|
+
if (!deferEntryDrain && !waitForFlushCompleteSpin())
|
|
1327
1330
|
{
|
|
1328
1331
|
setFlushStage(FlushStage::Idle, 0);
|
|
1329
1332
|
return false;
|
|
@@ -1403,12 +1406,21 @@ namespace gea::platform::esp32::display
|
|
|
1403
1406
|
#endif
|
|
1404
1407
|
|
|
1405
1408
|
#if (GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_STREAM_FLUSH || GEA_EMBEDDED_DISPLAY_CO5300_STREAM_FLUSH) && \
|
|
1409
|
+
!GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_CS_HELD_STREAM && \
|
|
1406
1410
|
GEA_EMBEDDED_DISPLAY_CO5300_STREAM_PACE_CHUNKS > 0
|
|
1407
1411
|
int streamChunksSincePace = 0;
|
|
1408
1412
|
#endif
|
|
1409
|
-
|
|
1413
|
+
// Partial-width windows fit more rows in the same DMA slot. Preserve
|
|
1414
|
+
// the app's requested row limit and the panel's two-row alignment.
|
|
1415
|
+
const int packedChunkRows = [&] {
|
|
1416
|
+
const int fits = flushBufferCapacity_ / width;
|
|
1417
|
+
const int requested = normalizeFlushChunkRows(requestedFlushChunkRows_);
|
|
1418
|
+
const int rows = fits < requested ? fits : requested;
|
|
1419
|
+
return rows - rows % kFlushChunkMin;
|
|
1420
|
+
}();
|
|
1421
|
+
for (int row = y0; row <= y1; row += packedChunkRows)
|
|
1410
1422
|
{
|
|
1411
|
-
int chunkRows =
|
|
1423
|
+
int chunkRows = packedChunkRows;
|
|
1412
1424
|
if (row + chunkRows > y1 + 1)
|
|
1413
1425
|
chunkRows = y1 - row + 1;
|
|
1414
1426
|
if (chunkRows <= 0)
|
|
@@ -1470,6 +1482,21 @@ namespace gea::platform::esp32::display
|
|
|
1470
1482
|
flushStats_.byteSwapUs += esp_timer_get_time() - byteSwapStartUs;
|
|
1471
1483
|
#endif
|
|
1472
1484
|
|
|
1485
|
+
if (deferEntryDrain)
|
|
1486
|
+
{
|
|
1487
|
+
// This slot is reserved but not submitted. Only earlier submissions
|
|
1488
|
+
// must finish before this band's CASET/RASET/RAMWR can be issued.
|
|
1489
|
+
const int64_t pendingStartUs = esp_timer_get_time();
|
|
1490
|
+
if (!waitForFlushCompleteSpin(4000, 1))
|
|
1491
|
+
{
|
|
1492
|
+
xSemaphoreGive(flushSlots_);
|
|
1493
|
+
setFlushStage(FlushStage::Idle, 0);
|
|
1494
|
+
return false;
|
|
1495
|
+
}
|
|
1496
|
+
const int64_t waitUs = esp_timer_get_time() - pendingStartUs;
|
|
1497
|
+
flushStats_.completeWaitUs += waitUs;
|
|
1498
|
+
flushStats_.chunkWaitUs += waitUs;
|
|
1499
|
+
}
|
|
1473
1500
|
const int64_t txStartUs = esp_timer_get_time();
|
|
1474
1501
|
setFlushStage(FlushStage::Tx, row);
|
|
1475
1502
|
#if GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_CS_HELD_STREAM
|
|
@@ -1515,6 +1542,7 @@ namespace gea::platform::esp32::display
|
|
|
1515
1542
|
}
|
|
1516
1543
|
|
|
1517
1544
|
#if (GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_STREAM_FLUSH || GEA_EMBEDDED_DISPLAY_CO5300_STREAM_FLUSH) && \
|
|
1545
|
+
!GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_CS_HELD_STREAM && \
|
|
1518
1546
|
GEA_EMBEDDED_DISPLAY_CO5300_STREAM_PACE_CHUNKS > 0
|
|
1519
1547
|
if (streamFlush)
|
|
1520
1548
|
{
|
|
@@ -1587,7 +1615,10 @@ namespace gea::platform::esp32::display
|
|
|
1587
1615
|
// panel — verified on-device 2026-07-08).
|
|
1588
1616
|
setFlushStage(FlushStage::WaitComplete, y1);
|
|
1589
1617
|
const int64_t waitStartUs = esp_timer_get_time();
|
|
1590
|
-
|
|
1618
|
+
// Two 64-row DMA chunks can exceed 2 ms at 80 MHz QSPI.
|
|
1619
|
+
// Match the slot-wait budget so a normal tail does not fall back to
|
|
1620
|
+
// a scheduler wakeup just before DMA completes.
|
|
1621
|
+
const bool ok = waitForFlushCompleteSpin(4000);
|
|
1591
1622
|
closeCsHeldStream();
|
|
1592
1623
|
flushStats_.completeWaitUs += esp_timer_get_time() - waitStartUs;
|
|
1593
1624
|
setFlushStage(FlushStage::Idle, 0);
|
|
@@ -1749,7 +1780,7 @@ namespace gea::platform::esp32::display
|
|
|
1749
1780
|
// overlap; flushing each separately re-sends that overlap every frame
|
|
1750
1781
|
// (~2.5x pixel inflation). Merging flushes each pixel once. Pad-then-coalesce,
|
|
1751
1782
|
// not coalesce-then-pad, so the pad participates in the merge.
|
|
1752
|
-
constexpr int kFlushMergeCap =
|
|
1783
|
+
constexpr int kFlushMergeCap = gea::embedded::ui::DirtyRegions::kMaxRects;
|
|
1753
1784
|
present::Rect win[kFlushMergeCap];
|
|
1754
1785
|
int n = 0;
|
|
1755
1786
|
for (int i = 0; i < count; i++)
|
|
@@ -1787,7 +1818,7 @@ namespace gea::platform::esp32::display
|
|
|
1787
1818
|
else if (n > 0)
|
|
1788
1819
|
win[n - 1] = present::unite(win[n - 1], w); // overflow: fold into last
|
|
1789
1820
|
}
|
|
1790
|
-
// Greedy merge of overlapping windows until stable
|
|
1821
|
+
// Greedy merge of overlapping windows until stable.
|
|
1791
1822
|
bool changed = true;
|
|
1792
1823
|
while (changed)
|
|
1793
1824
|
{
|
|
@@ -2571,7 +2602,7 @@ namespace gea::platform::esp32::display
|
|
|
2571
2602
|
}
|
|
2572
2603
|
|
|
2573
2604
|
// Then grow to the board's profile immediately, instead of leaving that to
|
|
2574
|
-
// start(). The floor above is a
|
|
2605
|
+
// start(). The floor above is a 2-row, 1-DEEP pipeline, and 1-deep is not
|
|
2575
2606
|
// merely slower: it disables the color-stream path (which requires depth >= 2)
|
|
2576
2607
|
// and the rotated flush then times out waiting for a slot, so the panel paints
|
|
2577
2608
|
// NOTHING while the pipeline sits there. An app whose own native bring-up
|
|
@@ -3040,9 +3071,7 @@ namespace gea::platform::esp32::display
|
|
|
3040
3071
|
rows = kFlushChunkMin;
|
|
3041
3072
|
if (rows > kFlushChunkLimit)
|
|
3042
3073
|
rows = kFlushChunkLimit;
|
|
3043
|
-
#if GEA_EMBEDDED_RM690B0_PANEL
|
|
3044
3074
|
rows &= ~1;
|
|
3045
|
-
#endif
|
|
3046
3075
|
return rows;
|
|
3047
3076
|
}
|
|
3048
3077
|
|
|
@@ -3105,13 +3134,13 @@ namespace gea::platform::esp32::display
|
|
|
3105
3134
|
return true;
|
|
3106
3135
|
}
|
|
3107
3136
|
|
|
3108
|
-
bool waitForFlushComplete()
|
|
3137
|
+
bool waitForFlushComplete(int reservedSlots = 0)
|
|
3109
3138
|
{
|
|
3110
|
-
if (!flushSlots_ || flushQueueDepth_ <=
|
|
3139
|
+
if (!flushSlots_ || flushQueueDepth_ <= reservedSlots)
|
|
3111
3140
|
return true;
|
|
3112
3141
|
|
|
3113
3142
|
int taken = 0;
|
|
3114
|
-
for (int i = 0; i < flushQueueDepth_; i++)
|
|
3143
|
+
for (int i = 0; i < flushQueueDepth_ - reservedSlots; i++)
|
|
3115
3144
|
{
|
|
3116
3145
|
if (xSemaphoreTake(flushSlots_, pdMS_TO_TICKS(1000)) != pdTRUE)
|
|
3117
3146
|
{
|
|
@@ -3134,17 +3163,17 @@ namespace gea::platform::esp32::display
|
|
|
3134
3163
|
// tiny tail DMAs this drain waits on (a few chunks), polling returns within the real
|
|
3135
3164
|
// ~35-150us completion time. The blocking fallback keeps the cross-core safety net
|
|
3136
3165
|
// for an unexpectedly long drain without spinning a core indefinitely.
|
|
3137
|
-
bool waitForFlushCompleteSpin(int64_t spinBudgetUs = 2000)
|
|
3166
|
+
bool waitForFlushCompleteSpin(int64_t spinBudgetUs = 2000, int reservedSlots = 0)
|
|
3138
3167
|
{
|
|
3139
|
-
if (!flushSlots_ || flushQueueDepth_ <=
|
|
3168
|
+
if (!flushSlots_ || flushQueueDepth_ <= reservedSlots)
|
|
3140
3169
|
return true;
|
|
3141
3170
|
const int64_t start = esp_timer_get_time();
|
|
3142
3171
|
while (esp_timer_get_time() - start < spinBudgetUs)
|
|
3143
3172
|
{
|
|
3144
|
-
if (uxSemaphoreGetCount(flushSlots_) >= static_cast<UBaseType_t>(flushQueueDepth_))
|
|
3173
|
+
if (uxSemaphoreGetCount(flushSlots_) >= static_cast<UBaseType_t>(flushQueueDepth_ - reservedSlots))
|
|
3145
3174
|
return true;
|
|
3146
3175
|
}
|
|
3147
|
-
return waitForFlushComplete();
|
|
3176
|
+
return waitForFlushComplete(reservedSlots);
|
|
3148
3177
|
}
|
|
3149
3178
|
|
|
3150
3179
|
esp_err_t tryConfigureFlushPipelineCandidate(int chunkRows, int depth, int targetRows, int targetDepth)
|
|
@@ -24,6 +24,13 @@
|
|
|
24
24
|
#define GEA_EMBEDDED_GEA_INIT_TASK_STACK_BYTES 65536
|
|
25
25
|
#endif
|
|
26
26
|
|
|
27
|
+
// A task that uses floating point can be pinned implicitly by FreeRTOS. Apps
|
|
28
|
+
// with asymmetric real-time work can choose an initialization core explicitly
|
|
29
|
+
// so first-use scheduling does not change startup latency between boots.
|
|
30
|
+
#ifndef GEA_EMBEDDED_GEA_INIT_TASK_CORE
|
|
31
|
+
#define GEA_EMBEDDED_GEA_INIT_TASK_CORE -1
|
|
32
|
+
#endif
|
|
33
|
+
|
|
27
34
|
#ifndef GEA_EMBEDDED_APP_FRAME_TASK_STACK_WORDS
|
|
28
35
|
#define GEA_EMBEDDED_APP_FRAME_TASK_STACK_WORDS 3072
|
|
29
36
|
#endif
|
|
@@ -29,6 +29,11 @@ namespace {
|
|
|
29
29
|
constexpr const char *kTag = "gea_esp32_app";
|
|
30
30
|
|
|
31
31
|
constexpr int kGeaAppInitTaskStack = GEA_EMBEDDED_GEA_INIT_TASK_STACK_BYTES;
|
|
32
|
+
static_assert(GEA_EMBEDDED_GEA_INIT_TASK_CORE >= -1 &&
|
|
33
|
+
GEA_EMBEDDED_GEA_INIT_TASK_CORE < portNUM_PROCESSORS,
|
|
34
|
+
"Gea initialization core must be -1 or an available CPU");
|
|
35
|
+
constexpr BaseType_t kGeaAppInitTaskCore = GEA_EMBEDDED_GEA_INIT_TASK_CORE < 0
|
|
36
|
+
? tskNO_AFFINITY : GEA_EMBEDDED_GEA_INIT_TASK_CORE;
|
|
32
37
|
|
|
33
38
|
#if GEA_EMBEDDED_HEAP_DIAGNOSTICS_LOG && CONFIG_HEAP_TRACING_STANDALONE
|
|
34
39
|
constexpr std::size_t kAppInitHeapTraceRecords = 1024;
|
|
@@ -108,11 +113,13 @@ void logCurrentTaskStack(const char *stage, int stackBytes)
|
|
|
108
113
|
{
|
|
109
114
|
TaskHandle_t currentTask = xTaskGetCurrentTaskHandle();
|
|
110
115
|
ESP_LOGI(kTag,
|
|
111
|
-
"stack probe [%s] task=%s stack_arg=%d hwm=%u",
|
|
116
|
+
"stack probe [%s] task=%s stack_arg=%d hwm=%u core=%d affinity=%d",
|
|
112
117
|
stage ? stage : "?",
|
|
113
118
|
currentTask ? pcTaskGetName(currentTask) : "?",
|
|
114
119
|
stackBytes,
|
|
115
|
-
static_cast<unsigned>(uxTaskGetStackHighWaterMark(currentTask))
|
|
120
|
+
static_cast<unsigned>(uxTaskGetStackHighWaterMark(currentTask)),
|
|
121
|
+
xPortGetCoreID(),
|
|
122
|
+
static_cast<int>(xTaskGetCoreID(currentTask)));
|
|
116
123
|
}
|
|
117
124
|
#endif
|
|
118
125
|
|
|
@@ -200,24 +207,26 @@ bool runGeaInitTask(int width, int height)
|
|
|
200
207
|
// only touched by FreeRTOS context save/restore (word-aligned) and user
|
|
201
208
|
// code (via cache, which doesn't care about cap flags), so dropping the
|
|
202
209
|
// 8BIT requirement here is safe.
|
|
203
|
-
created =
|
|
210
|
+
created = xTaskCreatePinnedToCoreWithCaps(
|
|
204
211
|
&GeaInitTask::run,
|
|
205
212
|
"gea_init",
|
|
206
213
|
kGeaAppInitTaskStack,
|
|
207
214
|
&args,
|
|
208
215
|
5,
|
|
209
216
|
&task,
|
|
217
|
+
kGeaAppInitTaskCore,
|
|
210
218
|
MALLOC_CAP_SPIRAM);
|
|
211
219
|
ESP_LOGI("app_runner", "gea_init SPIRAM create: %s", created == pdPASS ? "ok" : "FAIL");
|
|
212
220
|
#endif
|
|
213
221
|
if (created != pdPASS) {
|
|
214
|
-
created =
|
|
222
|
+
created = xTaskCreatePinnedToCoreWithCaps(
|
|
215
223
|
&GeaInitTask::run,
|
|
216
224
|
"gea_init",
|
|
217
225
|
kGeaAppInitTaskStack,
|
|
218
226
|
&args,
|
|
219
227
|
5,
|
|
220
228
|
&task,
|
|
229
|
+
kGeaAppInitTaskCore,
|
|
221
230
|
MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
|
222
231
|
ESP_LOGI("app_runner", "gea_init INTERNAL create: %s", created == pdPASS ? "ok" : "FAIL");
|
|
223
232
|
}
|
|
@@ -16,12 +16,22 @@
|
|
|
16
16
|
#include "ui/tree_internal.h"
|
|
17
17
|
#include "ui/virtual_keyboard.h"
|
|
18
18
|
|
|
19
|
+
#if defined(GEA_EMBEDDED_SHARED_STYLES) && GEA_EMBEDDED_SHARED_STYLES
|
|
20
|
+
#define GEA_DIAGNOSTIC_NODE_STYLE(node) ((node).computedStyle())
|
|
21
|
+
#else
|
|
22
|
+
#define GEA_DIAGNOSTIC_NODE_STYLE(node) ((node).style)
|
|
23
|
+
#endif
|
|
24
|
+
|
|
19
25
|
#include "driver/i2c_master.h"
|
|
20
26
|
#if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
|
|
21
27
|
#include "driver/usb_serial_jtag.h"
|
|
22
28
|
#include "driver/usb_serial_jtag_vfs.h"
|
|
23
29
|
#endif
|
|
24
30
|
#include "esp_heap_caps.h"
|
|
31
|
+
#if CONFIG_HEAP_TRACING_STANDALONE
|
|
32
|
+
#include "esp_heap_trace.h"
|
|
33
|
+
#include "esp_memory_utils.h"
|
|
34
|
+
#endif
|
|
25
35
|
#include "platform/file_cache.h" // gea::platform::storage::ensureMounted for GEADEV PUSH
|
|
26
36
|
#include "esp_log.h"
|
|
27
37
|
#include "esp_err.h"
|
|
@@ -50,6 +60,11 @@
|
|
|
50
60
|
#include "host/backends.h" // WifiBackend for GEADEV WIFI
|
|
51
61
|
#include "host/storage.h" // gea::host::Storage for GEADEV STORAGE SET
|
|
52
62
|
|
|
63
|
+
// Older engines expose all four direct position fields.
|
|
64
|
+
#ifndef GEA_CSS_POSITION_PX
|
|
65
|
+
#define GEA_CSS_POSITION_PX(style, side) ((style).pos_offsets[side])
|
|
66
|
+
#endif
|
|
67
|
+
|
|
53
68
|
namespace gea::platform::esp32::services {
|
|
54
69
|
|
|
55
70
|
namespace {
|
|
@@ -756,22 +771,22 @@ void handleNode(char *&cursor)
|
|
|
756
771
|
nodeId,
|
|
757
772
|
node.parent,
|
|
758
773
|
static_cast<int>(node.type),
|
|
759
|
-
node.
|
|
760
|
-
node.
|
|
761
|
-
node.
|
|
762
|
-
node.
|
|
763
|
-
node.
|
|
764
|
-
node.
|
|
765
|
-
node.
|
|
766
|
-
node
|
|
767
|
-
node
|
|
768
|
-
node
|
|
769
|
-
node
|
|
770
|
-
gea::embedded::ui::rstyle(node
|
|
771
|
-
gea::embedded::ui::rstyle(node
|
|
772
|
-
gea::embedded::ui::rstyle(node
|
|
773
|
-
gea::embedded::ui::rstyle(node
|
|
774
|
-
gea::embedded::ui::rstyle(node
|
|
774
|
+
GEA_DIAGNOSTIC_NODE_STYLE(node).display,
|
|
775
|
+
GEA_DIAGNOSTIC_NODE_STYLE(node).width,
|
|
776
|
+
GEA_DIAGNOSTIC_NODE_STYLE(node).height,
|
|
777
|
+
GEA_DIAGNOSTIC_NODE_STYLE(node).min_width,
|
|
778
|
+
GEA_DIAGNOSTIC_NODE_STYLE(node).min_height,
|
|
779
|
+
GEA_DIAGNOSTIC_NODE_STYLE(node).max_width,
|
|
780
|
+
GEA_DIAGNOSTIC_NODE_STYLE(node).max_height,
|
|
781
|
+
GEA_CSS_POSITION_PX(GEA_DIAGNOSTIC_NODE_STYLE(node), 3),
|
|
782
|
+
GEA_CSS_POSITION_PX(GEA_DIAGNOSTIC_NODE_STYLE(node), 0),
|
|
783
|
+
GEA_CSS_POSITION_PX(GEA_DIAGNOSTIC_NODE_STYLE(node), 1),
|
|
784
|
+
GEA_CSS_POSITION_PX(GEA_DIAGNOSTIC_NODE_STYLE(node), 2),
|
|
785
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_translate_x,
|
|
786
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_translate_y,
|
|
787
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_translate_x_percent,
|
|
788
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_translate_y_percent,
|
|
789
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_rotate,
|
|
775
790
|
node.layout.x,
|
|
776
791
|
node.layout.y,
|
|
777
792
|
node.layout.width,
|
|
@@ -784,9 +799,9 @@ void handleNode(char *&cursor)
|
|
|
784
799
|
ys[2],
|
|
785
800
|
xs[3],
|
|
786
801
|
ys[3],
|
|
787
|
-
static_cast<int>(node.
|
|
788
|
-
static_cast<int>(node.
|
|
789
|
-
static_cast<int>(node.
|
|
802
|
+
static_cast<int>(GEA_DIAGNOSTIC_NODE_STYLE(node).overflow),
|
|
803
|
+
static_cast<int>(GEA_DIAGNOSTIC_NODE_STYLE(node).overflow_x),
|
|
804
|
+
static_cast<int>(GEA_DIAGNOSTIC_NODE_STYLE(node).overflow_y),
|
|
790
805
|
static_cast<int>(node.layout.scroll_x),
|
|
791
806
|
static_cast<int>(node.layout.scroll_y),
|
|
792
807
|
static_cast<int>(node.layout.scroll_content_width),
|
|
@@ -825,15 +840,15 @@ void handleHitTest(char *&cursor)
|
|
|
825
840
|
nodeId,
|
|
826
841
|
node.parent,
|
|
827
842
|
static_cast<int>(node.type),
|
|
828
|
-
node.
|
|
843
|
+
GEA_DIAGNOSTIC_NODE_STYLE(node).display,
|
|
829
844
|
classes.c_str(),
|
|
830
845
|
pressTarget,
|
|
831
846
|
pressId,
|
|
832
|
-
gea::embedded::ui::rstyle(node
|
|
833
|
-
gea::embedded::ui::rstyle(node
|
|
834
|
-
gea::embedded::ui::rstyle(node
|
|
835
|
-
gea::embedded::ui::rstyle(node
|
|
836
|
-
gea::embedded::ui::rstyle(node
|
|
847
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_translate_x,
|
|
848
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_translate_y,
|
|
849
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_translate_x_percent,
|
|
850
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_translate_y_percent,
|
|
851
|
+
gea::embedded::ui::rstyle(GEA_DIAGNOSTIC_NODE_STYLE(node)).transform_rotate,
|
|
837
852
|
node.layout.x,
|
|
838
853
|
node.layout.y,
|
|
839
854
|
node.layout.width,
|
|
@@ -1529,6 +1544,46 @@ void handleCommand(char *line, CommandSource source)
|
|
|
1529
1544
|
appId ? appId : "",
|
|
1530
1545
|
intTotal - intFree, intFree, intTotal, intLargest, intMinFree,
|
|
1531
1546
|
psramTotal - psramFree, psramFree, psramTotal, psramLargest);
|
|
1547
|
+
} else if (tokenEquals(command, "HEAPTRACE")) {
|
|
1548
|
+
#if CONFIG_HEAP_TRACING_STANDALONE
|
|
1549
|
+
// Allocate records only on demand, outside internal DMA RAM. Emit
|
|
1550
|
+
// addresses/sizes/stacks, never allocation contents or credentials.
|
|
1551
|
+
static heap_trace_record_t *records = nullptr;
|
|
1552
|
+
constexpr size_t recordCount = 4096;
|
|
1553
|
+
char *action = nextToken(cursor);
|
|
1554
|
+
if (action && tokenEquals(action, "START")) {
|
|
1555
|
+
if (!records) {
|
|
1556
|
+
records = static_cast<heap_trace_record_t *>(heap_caps_calloc(recordCount, sizeof(heap_trace_record_t), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT));
|
|
1557
|
+
if (!records) { std::printf("GEADEV:ERR HEAPTRACE no-memory\n"); return; }
|
|
1558
|
+
const esp_err_t init = heap_trace_init_standalone(records, recordCount);
|
|
1559
|
+
if (init != ESP_OK) {
|
|
1560
|
+
heap_caps_free(records); records = nullptr;
|
|
1561
|
+
std::printf("GEADEV:ERR HEAPTRACE init=%s\n", esp_err_to_name(init)); return;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
const esp_err_t start = heap_trace_start(HEAP_TRACE_LEAKS);
|
|
1565
|
+
std::printf("GEADEV:HEAPTRACE START result=%s\n", esp_err_to_name(start));
|
|
1566
|
+
} else if (action && tokenEquals(action, "STOP") && records) {
|
|
1567
|
+
const esp_err_t stop = heap_trace_stop();
|
|
1568
|
+
if (stop != ESP_OK) { std::printf("GEADEV:ERR HEAPTRACE stop=%s\n", esp_err_to_name(stop)); return; }
|
|
1569
|
+
heap_trace_summary_t summary{};
|
|
1570
|
+
heap_trace_summary(&summary);
|
|
1571
|
+
std::printf("GEADEV:HEAPTRACE SUMMARY count=%u capacity=%u high_water=%u overflow=%u\n",
|
|
1572
|
+
unsigned(summary.count), unsigned(summary.capacity), unsigned(summary.high_water_mark), unsigned(summary.has_overflowed));
|
|
1573
|
+
for (size_t i = 0; i < heap_trace_get_count(); ++i) {
|
|
1574
|
+
heap_trace_record_t record{};
|
|
1575
|
+
if (heap_trace_get(i, &record) != ESP_OK || record.freed) continue;
|
|
1576
|
+
std::printf("GEADEV:HEAPTRACE RECORD bytes=%u region=%s address=%p stack=",
|
|
1577
|
+
unsigned(record.size), esp_ptr_internal(record.address) ? "internal" : "external", record.address);
|
|
1578
|
+
for (int j = 0; j < CONFIG_HEAP_TRACING_STACK_DEPTH; ++j) std::printf("%s%p", j ? "," : "", record.alloced_by[j]);
|
|
1579
|
+
std::printf("\n");
|
|
1580
|
+
}
|
|
1581
|
+
if (heap_trace_init_standalone(nullptr, 0) == ESP_OK) { heap_caps_free(records); records = nullptr; }
|
|
1582
|
+
std::printf("GEADEV:HEAPTRACE END\n");
|
|
1583
|
+
} else std::printf("GEADEV:ERR HEAPTRACE usage=START_or_STOP\n");
|
|
1584
|
+
#else
|
|
1585
|
+
std::printf("GEADEV:ERR HEAPTRACE standalone-tracing-not-enabled\n");
|
|
1586
|
+
#endif
|
|
1532
1587
|
} else if (tokenEquals(command, "CANVASSTATS")) {
|
|
1533
1588
|
int tBegin = 0, tEnd = 0, tFillRect = 0, tDrawImage = 0, tNullPx = 0, tPresentOk = 0;
|
|
1534
1589
|
gea::embedded::ui::canvasTotalsRead(&tBegin, &tEnd, &tFillRect, &tDrawImage, &tNullPx, &tPresentOk);
|
|
@@ -1546,8 +1601,8 @@ void handleCommand(char *line, CommandSource source)
|
|
|
1546
1601
|
if (kb >= 0 && kb < tree.nodeCount()) {
|
|
1547
1602
|
const auto &node = tree.node(kb);
|
|
1548
1603
|
std::printf("GEADEV:KBINFO kb=%d active=%d parent=%d display=%d layout=%d,%d %dx%d styleTop=%d styleW=%d styleH=%d\n",
|
|
1549
|
-
kb, active, node.parent, node.
|
|
1550
|
-
node.layout.width, node.layout.height, node
|
|
1604
|
+
kb, active, node.parent, GEA_DIAGNOSTIC_NODE_STYLE(node).display, node.layout.x, node.layout.y,
|
|
1605
|
+
node.layout.width, node.layout.height, GEA_CSS_POSITION_PX(GEA_DIAGNOSTIC_NODE_STYLE(node), 0), GEA_DIAGNOSTIC_NODE_STYLE(node).width, GEA_DIAGNOSTIC_NODE_STYLE(node).height);
|
|
1551
1606
|
} else {
|
|
1552
1607
|
std::printf("GEADEV:KBINFO kb=%d active=%d\n", kb, active);
|
|
1553
1608
|
}
|
|
@@ -21,6 +21,114 @@
|
|
|
21
21
|
#include "freertos/queue.h"
|
|
22
22
|
#include "freertos/task.h"
|
|
23
23
|
|
|
24
|
+
#if defined(GEA_EMBEDDED_FRAME_BENCHMARK) && GEA_EMBEDDED_FRAME_BENCHMARK
|
|
25
|
+
extern "C" void gea_frame_benchmark_sample(int64_t start, int64_t done);
|
|
26
|
+
#if GEA_EMBEDDED_FRAME_BENCHMARK == 2
|
|
27
|
+
// Called at the end of the real target frame, including the display flush.
|
|
28
|
+
// Warm up for 300 frames, collect 3600 frames, then log once outside the sample.
|
|
29
|
+
#include <cstdint>
|
|
30
|
+
#include "esp_attr.h"
|
|
31
|
+
#include "esp_heap_caps.h"
|
|
32
|
+
#include "esp_log.h"
|
|
33
|
+
#include "ui/node_model.h"
|
|
34
|
+
#include "ui/tree_state.h"
|
|
35
|
+
#include "ui/internal.h"
|
|
36
|
+
|
|
37
|
+
namespace {
|
|
38
|
+
constexpr unsigned kWarmup = 300;
|
|
39
|
+
constexpr unsigned kSamples = 3600;
|
|
40
|
+
constexpr unsigned kBins = 1024;
|
|
41
|
+
constexpr unsigned kBinUs = 250;
|
|
42
|
+
struct Distribution {
|
|
43
|
+
std::uint32_t bins[kBins]{};
|
|
44
|
+
std::int64_t sum{};
|
|
45
|
+
std::int64_t maximum{};
|
|
46
|
+
unsigned over_budget{};
|
|
47
|
+
void add(std::int64_t value) {
|
|
48
|
+
sum += value;
|
|
49
|
+
if (value > maximum)
|
|
50
|
+
maximum = value;
|
|
51
|
+
if (value > 16667)
|
|
52
|
+
++over_budget;
|
|
53
|
+
const auto bin = static_cast<unsigned>(value / kBinUs);
|
|
54
|
+
++bins[bin < kBins ? bin : kBins - 1];
|
|
55
|
+
}
|
|
56
|
+
unsigned percentile(unsigned percent) const {
|
|
57
|
+
unsigned count = 0;
|
|
58
|
+
for (unsigned i = 0; i < kBins; ++i) {
|
|
59
|
+
count += bins[i];
|
|
60
|
+
if (count * 100 >= kSamples * percent)
|
|
61
|
+
return (i + 1) * kBinUs;
|
|
62
|
+
}
|
|
63
|
+
return kBins * kBinUs;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
EXT_RAM_BSS_ATTR Distribution work;
|
|
67
|
+
EXT_RAM_BSS_ATTR Distribution cadence;
|
|
68
|
+
unsigned frames{};
|
|
69
|
+
std::int64_t previous_done{};
|
|
70
|
+
} // namespace
|
|
71
|
+
|
|
72
|
+
extern "C" void gea_frame_benchmark_sample(std::int64_t start, std::int64_t done) {
|
|
73
|
+
++frames;
|
|
74
|
+
if (frames > kWarmup && frames <= kWarmup + kSamples) {
|
|
75
|
+
work.add(done - start);
|
|
76
|
+
cadence.add(done - previous_done);
|
|
77
|
+
}
|
|
78
|
+
previous_done = done;
|
|
79
|
+
if (frames != kWarmup + kSamples + 1)
|
|
80
|
+
return;
|
|
81
|
+
unsigned shared = 0, records = 0, payload = 0, heapBytes = 0, staticBytes = 0;
|
|
82
|
+
#if defined(GEA_EMBEDDED_SHARED_STYLES) && GEA_EMBEDDED_SHARED_STYLES
|
|
83
|
+
shared = 1;
|
|
84
|
+
records = unsigned(gea::embedded::ui::NodeStyleStorage::allocatedRecords());
|
|
85
|
+
payload = unsigned(gea::embedded::ui::NodeStyleStorage::allocatedBytes());
|
|
86
|
+
heapBytes = unsigned(gea::embedded::ui::NodeStyleStorage::allocatedHeapBytes());
|
|
87
|
+
staticBytes = unsigned(sizeof(gea::embedded::ui::SharedStyleRecord) + sizeof(void *) + sizeof(std::size_t));
|
|
88
|
+
#endif
|
|
89
|
+
ESP_LOGI("ui_bench", "STORAGE shared=%u nodes=%u capacity=%u tree_bytes=%u node_array_bytes=%u "
|
|
90
|
+
"records=%u record_payload=%u record_heap=%u record_static=%u "
|
|
91
|
+
"memo_active=%u memo_peak_heap=%u memo_static=%u "
|
|
92
|
+
"layout_aux_payload=%u layout_aux_heap=%u layout_aux_allocs=%u "
|
|
93
|
+
"layout_aux_peak=%u layout_aux_peak_allocs=%u layout_aux_static=%u",
|
|
94
|
+
shared, unsigned(gea::embedded::ui::treeState().nodeCount), unsigned(gea::embedded::ui::kMaxNodes),
|
|
95
|
+
unsigned(sizeof(gea::embedded::ui::TreeState)),
|
|
96
|
+
unsigned(sizeof(gea::embedded::ui::Node) * gea::embedded::ui::kMaxNodes),
|
|
97
|
+
records, payload, heapBytes, staticBytes,
|
|
98
|
+
unsigned(gea::embedded::ui::LayoutEngine::memoStorageBytes()),
|
|
99
|
+
unsigned(gea::embedded::ui::LayoutEngine::memoPeakHeapBytes()),
|
|
100
|
+
unsigned(sizeof(void *) + sizeof(std::size_t) + sizeof(int)),
|
|
101
|
+
unsigned(gea::embedded::ui::LayoutEngine::persistentLayoutStorageBytes()),
|
|
102
|
+
unsigned(gea::embedded::ui::LayoutEngine::persistentLayoutHeapBytes()),
|
|
103
|
+
unsigned(gea::embedded::ui::LayoutEngine::persistentLayoutAllocationCount()),
|
|
104
|
+
unsigned(gea::embedded::ui::LayoutEngine::persistentLayoutPeakBytes()),
|
|
105
|
+
unsigned(gea::embedded::ui::LayoutEngine::persistentLayoutPeakAllocations()),
|
|
106
|
+
unsigned(gea::embedded::ui::LayoutEngine::persistentLayoutStaticBytes()));
|
|
107
|
+
const auto owned = gea::embedded::ui::nodeAuxiliaryStorageUsage();
|
|
108
|
+
const auto logOwned = [](const char *group, const gea::embedded::ui::StorageUsage &usage) {
|
|
109
|
+
ESP_LOGI("ui_bench", "OWNED group=%s payload=%u heap=%u allocs=%u static=%u untracked=%u",
|
|
110
|
+
group, unsigned(usage.payload), unsigned(usage.heap), unsigned(usage.allocations),
|
|
111
|
+
unsigned(usage.staticBytes), unsigned(usage.untrackedOwners));
|
|
112
|
+
};
|
|
113
|
+
logOwned("tree", owned.tree); logOwned("text", owned.text);
|
|
114
|
+
logOwned("rare", owned.rare); logOwned("overrides", owned.overrides);
|
|
115
|
+
logOwned("dependencies", owned.dependencies);
|
|
116
|
+
ESP_LOGI("ui_bench",
|
|
117
|
+
"RESULT frames=%u warmup=%u done_total=%lld node=%u style=%u work_avg=%lld work_p99_le=%u work_max=%lld "
|
|
118
|
+
"work_over16667=%u done_avg=%lld done_p99_le=%u done_max=%lld done_over16667=%u "
|
|
119
|
+
"fps_milli=%lld psram_free=%u internal_free=%u",
|
|
120
|
+
kSamples, kWarmup, cadence.sum, unsigned(sizeof(gea::embedded::ui::Node)),
|
|
121
|
+
unsigned(sizeof(gea::embedded::ui::ComputedStyle)), work.sum / kSamples,
|
|
122
|
+
work.percentile(99), work.maximum, work.over_budget, cadence.sum / kSamples,
|
|
123
|
+
cadence.percentile(99), cadence.maximum, cadence.over_budget,
|
|
124
|
+
1000000000LL * kSamples / cadence.sum,
|
|
125
|
+
unsigned(heap_caps_get_free_size(MALLOC_CAP_SPIRAM)),
|
|
126
|
+
unsigned(heap_caps_get_free_size(MALLOC_CAP_INTERNAL)));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#endif
|
|
130
|
+
#endif
|
|
131
|
+
|
|
24
132
|
namespace gea::framework::services {
|
|
25
133
|
|
|
26
134
|
namespace {
|
|
@@ -59,8 +167,10 @@ constexpr int kTaskCore = GEA_EMBEDDED_APP_FRAME_TASK_CORE;
|
|
|
59
167
|
#define GEA_EMBEDDED_FRAME_SCHEDULER_IDLE_YIELD_TICKS 1
|
|
60
168
|
#endif
|
|
61
169
|
|
|
170
|
+
// Bound sustained catch-up so idle housekeeping still runs when display DMA
|
|
171
|
+
// completes without blocking the frame task. Boards may override this cadence.
|
|
62
172
|
#ifndef GEA_EMBEDDED_FRAME_SCHEDULER_MAX_CATCHUP_FRAMES_BEFORE_YIELD
|
|
63
|
-
#define GEA_EMBEDDED_FRAME_SCHEDULER_MAX_CATCHUP_FRAMES_BEFORE_YIELD
|
|
173
|
+
#define GEA_EMBEDDED_FRAME_SCHEDULER_MAX_CATCHUP_FRAMES_BEFORE_YIELD 32
|
|
64
174
|
#endif
|
|
65
175
|
|
|
66
176
|
#ifndef GEA_EMBEDDED_FRAME_SCHEDULER_USE_ESP_TIMER
|
|
@@ -465,6 +575,9 @@ public:
|
|
|
465
575
|
frameInProgress_.store(false, std::memory_order_release);
|
|
466
576
|
setFrameStage(FrameStage::Idle);
|
|
467
577
|
const int64_t frameDoneUs = esp_timer_get_time();
|
|
578
|
+
#if defined(GEA_EMBEDDED_FRAME_BENCHMARK) && GEA_EMBEDDED_FRAME_BENCHMARK
|
|
579
|
+
gea_frame_benchmark_sample(frameStartUs, frameDoneUs);
|
|
580
|
+
#endif
|
|
468
581
|
// Production-fps probe: deliberately outside GEA_EMBEDDED_PERF, so it still
|
|
469
582
|
// reports the TRUE production frame rate when every other perf subsystem is
|
|
470
583
|
// stripped. It has its own switch because it is otherwise a once-a-second
|
|
@@ -684,7 +797,9 @@ public:
|
|
|
684
797
|
}
|
|
685
798
|
#endif
|
|
686
799
|
if (forceIdleYield) {
|
|
687
|
-
|
|
800
|
+
// One tick can expire immediately at a tick boundary. Two guarantee
|
|
801
|
+
// a full tick for idle housekeeping under sustained catch-up.
|
|
802
|
+
vTaskDelay(2);
|
|
688
803
|
} else if (!catchUpRequested && GEA_EMBEDDED_FRAME_SCHEDULER_IDLE_YIELD_TICKS > 0) {
|
|
689
804
|
vTaskDelay(GEA_EMBEDDED_FRAME_SCHEDULER_IDLE_YIELD_TICKS);
|
|
690
805
|
}
|
|
@@ -95,17 +95,29 @@ endif()
|
|
|
95
95
|
if(NOT DEFINED GEA_BOARD_EXTRA_COMPILE_DEFINITIONS)
|
|
96
96
|
set(GEA_BOARD_EXTRA_COMPILE_DEFINITIONS "")
|
|
97
97
|
endif()
|
|
98
|
+
if(GEA_EMBEDDED_CPP_BOARD STREQUAL "esp32-s3-touch-amoled-1.8")
|
|
99
|
+
list(APPEND GEA_BOARD_PLATFORM_SOURCES "${CMAKE_CURRENT_LIST_DIR}/panel_reset.cpp")
|
|
100
|
+
list(APPEND GEA_BOARD_EXTRA_COMPILE_DEFINITIONS GEA_BOARD_PREPARE_DISPLAY_PANEL=1)
|
|
101
|
+
endif()
|
|
98
102
|
if(NOT DEFINED GEA_BOARD_GEATSC_OPTIMIZATION)
|
|
99
|
-
|
|
103
|
+
if(GEA_EMBEDDED_CPP_BOARD STREQUAL "esp32-s3-touch-amoled-1.8" AND GEA_EMBEDDED_APP STREQUAL "bouncing-balls-jsx")
|
|
104
|
+
set(GEA_BOARD_GEATSC_OPTIMIZATION -O2)
|
|
105
|
+
else()
|
|
106
|
+
set(GEA_BOARD_GEATSC_OPTIMIZATION -Os)
|
|
107
|
+
endif()
|
|
100
108
|
endif()
|
|
101
109
|
if(NOT DEFINED GEA_BOARD_OPTIMIZE_BOUNCING_BALLS_JSX)
|
|
102
|
-
|
|
110
|
+
if(GEA_EMBEDDED_CPP_BOARD STREQUAL "esp32-s3-touch-amoled-1.8")
|
|
111
|
+
set(GEA_BOARD_OPTIMIZE_BOUNCING_BALLS_JSX 1)
|
|
112
|
+
else()
|
|
113
|
+
set(GEA_BOARD_OPTIMIZE_BOUNCING_BALLS_JSX 0)
|
|
114
|
+
endif()
|
|
103
115
|
endif()
|
|
104
116
|
|
|
105
117
|
# Keep app-sensitive renderer/codegen choices explicit at the board wrapper.
|
|
106
|
-
# The
|
|
107
|
-
#
|
|
108
|
-
#
|
|
118
|
+
# The 1.8-inch board and wrappers opting into the bouncing-balls-jsx profile
|
|
119
|
+
# use native-number and retained-tree shortcuts for that app. Other apps keep
|
|
120
|
+
# their existing settings.
|
|
109
121
|
set(GEA_EMBEDDED_NUMBER_F32 0)
|
|
110
122
|
set(GEA_EMBEDDED_FUSE_FLUSH_VALUE 0)
|
|
111
123
|
set(GEA_EMBEDDED_REVEAL_CHECK_VALUE 1)
|
|
@@ -129,6 +141,13 @@ if(GEA_BOARD_OPTIMIZE_BOUNCING_BALLS_JSX AND GEA_EMBEDDED_APP STREQUAL "bouncing
|
|
|
129
141
|
set(GEA_EMBEDDED_PERF_LITE_VALUE 0)
|
|
130
142
|
list(APPEND GEA_BOARD_EXTRA_COMPILE_DEFINITIONS GEA_NUMBER_FLOAT=1)
|
|
131
143
|
endif()
|
|
144
|
+
# An explicit diagnostic build may override the profile's instrumentation
|
|
145
|
+
# default. Keep the component definition consistent with the app-wide one.
|
|
146
|
+
foreach(_GEA_APP_DEFINE IN LISTS GEA_EMBEDDED_APP_DEFINES)
|
|
147
|
+
if(_GEA_APP_DEFINE MATCHES "^GEA_EMBEDDED_PERF=([01])$")
|
|
148
|
+
set(GEA_EMBEDDED_PERF_VALUE "${CMAKE_MATCH_1}")
|
|
149
|
+
endif()
|
|
150
|
+
endforeach()
|
|
132
151
|
if(DEFINED GEA_BOARD_FRAMEBUFFER_CS_HELD_STREAM)
|
|
133
152
|
set(GEA_EMBEDDED_FB_CS_HELD_VALUE ${GEA_BOARD_FRAMEBUFFER_CS_HELD_STREAM})
|
|
134
153
|
endif()
|
|
@@ -530,6 +549,7 @@ idf_component_register(
|
|
|
530
549
|
esp_http_client
|
|
531
550
|
${GEA_EMBEDDED_HTTPS_REQUIRES}
|
|
532
551
|
app_update
|
|
552
|
+
spi_flash
|
|
533
553
|
esp_mm
|
|
534
554
|
esp_netif
|
|
535
555
|
esp_event
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The 1.8-inch board routes its peripheral reset lines through an XCA9554.
|
|
2
|
+
// Follow Waveshare's original 04_GFX_FT3168_Image sequence: EXIO0..2 low for
|
|
3
|
+
// 20 ms, then high. Preserve the remaining pins and reuse the shared I2C bus.
|
|
4
|
+
// https://github.com/waveshareteam/ESP32-S3-Touch-AMOLED-1.8/blob/main/examples/arduino/examples/04_GFX_FT3168_Image/04_GFX_FT3168_Image.ino
|
|
5
|
+
#include "i2c.h"
|
|
6
|
+
#include "driver/i2c_master.h"
|
|
7
|
+
#include "esp_log.h"
|
|
8
|
+
#include "freertos/FreeRTOS.h"
|
|
9
|
+
#include "freertos/task.h"
|
|
10
|
+
#include <cstdint>
|
|
11
|
+
|
|
12
|
+
namespace gea::platform::board {
|
|
13
|
+
void prepareDisplayPanel()
|
|
14
|
+
{
|
|
15
|
+
const auto bus = gea::platform::i2c::Bus::primary();
|
|
16
|
+
if (!bus.available()) {
|
|
17
|
+
ESP_LOGE("panel_reset", "shared I2C bus unavailable");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
i2c_device_config_t config{};
|
|
21
|
+
config.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
|
22
|
+
config.device_address = 0x20;
|
|
23
|
+
config.scl_speed_hz = 400000;
|
|
24
|
+
i2c_master_dev_handle_t device = nullptr;
|
|
25
|
+
esp_err_t err = i2c_master_bus_add_device(
|
|
26
|
+
static_cast<i2c_master_bus_handle_t>(bus.nativeHandle()), &config, &device);
|
|
27
|
+
if (err != ESP_OK) {
|
|
28
|
+
ESP_LOGE("panel_reset", "expander attach failed: %s", esp_err_to_name(err));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
constexpr std::uint8_t pins = 0x07;
|
|
32
|
+
const auto read = [&](std::uint8_t reg, std::uint8_t &value) {
|
|
33
|
+
return i2c_master_transmit_receive(device, ®, 1, &value, 1, 100);
|
|
34
|
+
};
|
|
35
|
+
const auto write = [&](std::uint8_t reg, std::uint8_t value) {
|
|
36
|
+
const std::uint8_t bytes[]{reg, value};
|
|
37
|
+
return i2c_master_transmit(device, bytes, sizeof(bytes), 100);
|
|
38
|
+
};
|
|
39
|
+
std::uint8_t output = 0, direction = 0;
|
|
40
|
+
err = read(0x01, output);
|
|
41
|
+
if (err == ESP_OK) err = read(0x03, direction);
|
|
42
|
+
// Set the low latch before enabling outputs to avoid an unintended pulse.
|
|
43
|
+
if (err == ESP_OK) err = write(0x01, output & ~pins);
|
|
44
|
+
if (err == ESP_OK) err = write(0x03, direction & ~pins);
|
|
45
|
+
if (err == ESP_OK) {
|
|
46
|
+
vTaskDelay(pdMS_TO_TICKS(20));
|
|
47
|
+
err = write(0x01, output | pins);
|
|
48
|
+
vTaskDelay(pdMS_TO_TICKS(50));
|
|
49
|
+
}
|
|
50
|
+
i2c_master_bus_rm_device(device);
|
|
51
|
+
if (err == ESP_OK) ESP_LOGI("panel_reset", "peripherals reset through XCA9554 EXIO0..2");
|
|
52
|
+
else ESP_LOGE("panel_reset", "expander reset failed: %s", esp_err_to_name(err));
|
|
53
|
+
}
|
|
54
|
+
} // namespace gea::platform::board
|
|
@@ -9,16 +9,6 @@ dependencies:
|
|
|
9
9
|
registry_url: https://components.espressif.com
|
|
10
10
|
type: service
|
|
11
11
|
version: 0.5.3
|
|
12
|
-
espressif/esp_codec_dev:
|
|
13
|
-
component_hash: 4779f31a3ba3f9b38aee1afe6ccb9ba8f6108dc3a6e77d39d7d714e9a215371b
|
|
14
|
-
dependencies:
|
|
15
|
-
- name: idf
|
|
16
|
-
require: private
|
|
17
|
-
version: '>=4.0'
|
|
18
|
-
source:
|
|
19
|
-
registry_url: https://components.espressif.com/
|
|
20
|
-
type: service
|
|
21
|
-
version: 1.6.2
|
|
22
12
|
espressif/esp_io_expander:
|
|
23
13
|
component_hash: 7b7f91270172e46ca4597e3874f48d8412e280e8c295559f5922ec38656e3e5f
|
|
24
14
|
dependencies:
|
|
@@ -61,45 +51,14 @@ dependencies:
|
|
|
61
51
|
registry_url: https://components.espressif.com/
|
|
62
52
|
type: service
|
|
63
53
|
version: 1.0.1
|
|
64
|
-
espressif/esp_libsrtp:
|
|
65
|
-
component_hash: 131560184c73ec09f77d8904a2db709307803f0f9f111898921b6966776eac15
|
|
66
|
-
dependencies: []
|
|
67
|
-
source:
|
|
68
|
-
registry_url: https://components.espressif.com
|
|
69
|
-
type: service
|
|
70
|
-
version: 1.0.0
|
|
71
|
-
espressif/esp_peer:
|
|
72
|
-
component_hash: e29d65a3d2eba15f761e7d2740ab62650384edff27a1f8277dd6ccfa45813863
|
|
73
|
-
dependencies:
|
|
74
|
-
- name: espressif/esp_libsrtp
|
|
75
|
-
registry_url: https://components.espressif.com
|
|
76
|
-
require: private
|
|
77
|
-
version: ^1.0.0
|
|
78
|
-
source:
|
|
79
|
-
registry_url: https://components.espressif.com/
|
|
80
|
-
type: service
|
|
81
|
-
version: 1.5.6
|
|
82
|
-
espressif/esp_websocket_client:
|
|
83
|
-
component_hash: dc00233af846f3a744ada283a300e0d586040aadc3ee67361645ecdce4523672
|
|
84
|
-
dependencies:
|
|
85
|
-
- name: idf
|
|
86
|
-
require: private
|
|
87
|
-
version: '>=5.0'
|
|
88
|
-
source:
|
|
89
|
-
registry_url: https://components.espressif.com/
|
|
90
|
-
type: service
|
|
91
|
-
version: 1.8.0
|
|
92
54
|
idf:
|
|
93
55
|
source:
|
|
94
56
|
type: idf
|
|
95
57
|
version: 6.0.2
|
|
96
58
|
direct_dependencies:
|
|
97
|
-
- espressif/esp_codec_dev
|
|
98
59
|
- espressif/esp_lcd_co5300
|
|
99
60
|
- espressif/esp_lcd_panel_io_additions
|
|
100
|
-
- espressif/esp_peer
|
|
101
|
-
- espressif/esp_websocket_client
|
|
102
61
|
- idf
|
|
103
|
-
manifest_hash:
|
|
62
|
+
manifest_hash: 34ae4cf7c0b000b13ee85d92cb57e298a904e8345f7b179f0b61b01b2f42de35
|
|
104
63
|
target: esp32s3
|
|
105
64
|
version: 3.0.0
|