@geastack/targets 0.1.88 → 0.1.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/build-config.json +32 -0
  2. package/package.json +2 -2
  3. package/targets/cmake/geatsc_generated_archive.cmake +18 -2
  4. package/targets/esp32/chip_bindings/audio/echo_cancellation.cpp +35 -19
  5. package/targets/esp32/chip_bindings/audio/echo_cancellation.h +2 -1
  6. package/targets/esp32/chip_bindings/audio/es8311.cpp +45 -8
  7. package/targets/esp32/chip_bindings/displays/co5300.cpp +40 -0
  8. package/targets/esp32/chip_bindings/imu/bmi270.cpp +6 -1
  9. package/targets/esp32/connectivity/wifi.cpp +4 -0
  10. package/targets/esp32/display.cpp +23 -0
  11. package/targets/esp32/services/audio_runtime_stub.cpp +2 -0
  12. package/targets/esp32/services/device_control.cpp +75 -9
  13. package/targets/esp32/services/frame_scheduler.cpp +7 -0
  14. package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +15 -5
  15. package/targets/esp32-s3-touch-amoled-1.8/dependencies.lock +16 -1
  16. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +5 -1
  17. package/targets/esp32-s3-touch-amoled-1.8/main/idf_component.yml +4 -0
  18. package/targets/esp32-s3-touch-amoled-1.8/main/include/board.h +12 -0
  19. package/targets/esp32-s3-touch-amoled-1.8/main/launcher_button.cpp +6 -1
  20. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +3 -2
  21. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +1 -0
  22. package/targets/esp32-s3-touch-amoled-2.06/main/idf_component.yml +5 -0
  23. package/targets/esp32-s3-touch-amoled-2.06/main/include/board.h +7 -0
  24. package/targets/esp32-s31-espressif-mosaico/CMakeLists.txt +10 -0
  25. package/targets/esp32-s31-espressif-mosaico/README.md +56 -0
  26. package/targets/esp32-s31-espressif-mosaico/dependencies.lock +137 -0
  27. package/targets/esp32-s31-espressif-mosaico/main/CMakeLists.txt +63 -0
  28. package/targets/esp32-s31-espressif-mosaico/main/Kconfig.projbuild +12 -0
  29. package/targets/esp32-s31-espressif-mosaico/main/board_power.cpp +386 -0
  30. package/targets/esp32-s31-espressif-mosaico/main/idf_component.yml +36 -0
  31. package/targets/esp32-s31-espressif-mosaico/main/include/board.h +147 -0
  32. package/targets/esp32-s31-espressif-mosaico/main/include/wifi_config.h.example +5 -0
  33. package/targets/esp32-s31-espressif-mosaico/main/touch.cpp +45 -0
  34. package/targets/esp32-s31-espressif-mosaico/partitions.csv +10 -0
  35. package/targets/esp32-s31-espressif-mosaico/sdkconfig.defaults +194 -0
  36. package/targets/rp2350-waveshare-touch-amoled-2.41/main/rp2350_gea_platform.cpp +3 -0
  37. package/targets.json +12 -0
@@ -0,0 +1,386 @@
1
+ // ESP-Mosaico board bring-up: the VCC_3V3 rail and the USB console.
2
+ //
3
+ // Everything on the panel side -- the CO5300, its touch controller, the codec
4
+ // supply on V1.0 and the expansion slots' 3V3 -- hangs off VCC_3V3, a high-side
5
+ // switch whose enable is GPIO60, active low. Until that rail is open the panel
6
+ // does not answer, and a QSPI write reports success either way, so a board that
7
+ // skips this boots with every log line saying the display came up and a dark
8
+ // screen. The BSP soft-starts the rail by fading the enable through LEDC over
9
+ // 50 ms (the switch's gate follows the average of the pin), which bounds the
10
+ // inrush when the board runs from its 65 mAh cell; this does the same.
11
+ //
12
+ // GPIO57 is the power-off request to the board's SAM8108 power controller:
13
+ // open drain, asserted low. It must be released for the board to stay on.
14
+ //
15
+ // The USB-C port is the S31's high-speed OTG controller, not USB-Serial/JTAG
16
+ // (that sits on GPIO33/34, routed to the left expansion header), so there is no
17
+ // ROM console on it: logs reach the host through a TinyUSB CDC interface that
18
+ // reports the chip's MAC as its USB serial -- the same "AA:BB:CC:DD:EE:FF"
19
+ // spelling the S3 boards' USB-Serial/JTAG uses, so `--board` resolves a
20
+ // Mosaico by serial exactly as it does every other board. UART0 keeps the
21
+ // early boot output and remains the fallback when USB does not come up.
22
+ //
23
+ // That console is also how the host gets the board into its ROM downloader,
24
+ // since nothing else on the OTG port can: no reset lines, and V1.2 ships with
25
+ // automatic download disabled. The host drives esptool's reset pattern on the
26
+ // CDC line state -- (DTR=0, RTS=1), then RTS falling -- and the board answers it
27
+ // as Espressif's own Mosaico console does (esp-brookesia,
28
+ // esp_mosaico_usb_console): RTS falling with DTR high sets the LP-domain
29
+ // FORCE_DOWNLOAD_BOOT flag and resets into the downloader; with DTR low it is a
30
+ // plain restart. The flag survives the reset, so whoever flashes must clear it
31
+ // before the final reset or the board comes straight back to the downloader.
32
+
33
+ #include "board.h"
34
+
35
+ #include <cstdint>
36
+ #include <cstdio>
37
+
38
+ #include "driver/gpio.h"
39
+ #include "driver/ledc.h"
40
+ #include "esp_check.h"
41
+ #include "esp_err.h"
42
+ #include "esp_log.h"
43
+ #include "esp_mac.h"
44
+ #include "esp_private/startup_internal.h"
45
+ #include "freertos/FreeRTOS.h"
46
+ #include "freertos/semphr.h"
47
+ #include "freertos/task.h"
48
+
49
+ // Off until the reset it ends in brings the board back: on V1.2 the RTC
50
+ // watchdog reset leaves it off USB (neither the downloader nor the app
51
+ // re-enumerates) until it is power-cycled, and a terminal opening the port can
52
+ // produce the request pattern by itself.
53
+ #ifndef GEA_BOARD_USB_DOWNLOAD_REQUEST
54
+ #define GEA_BOARD_USB_DOWNLOAD_REQUEST 0
55
+ #endif
56
+
57
+ #if GEA_BOARD_USB_CONSOLE
58
+ #include "esp_timer.h"
59
+ #include "hal/wdt_hal.h"
60
+ #include "soc/lp_system_reg.h"
61
+ #include "soc/rtc.h"
62
+ #include "soc/soc.h"
63
+ #include "tinyusb.h"
64
+ #include "tinyusb_cdc_acm.h"
65
+ #include "tinyusb_console.h"
66
+ #include "tinyusb_default_config.h"
67
+ #endif
68
+
69
+ namespace
70
+ {
71
+ constexpr char kTag[] = "mosaico";
72
+
73
+ constexpr int kVccOnLevel = 0;
74
+ constexpr int kVccOffLevel = 1;
75
+ constexpr int kVccRampMs = 50;
76
+ // Settling after the ramp before anything talks to the panel. The BSP's
77
+ // codec path waits 10 ms; the panel takes its own 600 ms sleep-out later.
78
+ constexpr int kVccSettleMs = 10;
79
+
80
+ constexpr ledc_mode_t kRampMode = LEDC_LOW_SPEED_MODE;
81
+ constexpr ledc_timer_t kRampTimer = LEDC_TIMER_1;
82
+ constexpr ledc_channel_t kRampChannel = LEDC_CHANNEL_1;
83
+ // 8-bit keeps the carrier well above the gate RC pole (the BSP's choice).
84
+ constexpr ledc_timer_bit_t kRampResolution = LEDC_TIMER_8_BIT;
85
+ constexpr std::uint32_t kRampFrequencyHz = 100000;
86
+
87
+ StaticSemaphore_t powerLockStorage;
88
+ SemaphoreHandle_t powerLock = nullptr;
89
+ bool railsOn = false;
90
+
91
+ esp_err_t configureOutput(gpio_num_t pin, gpio_mode_t mode, int level)
92
+ {
93
+ gpio_config_t config = {};
94
+ config.pin_bit_mask = 1ULL << pin;
95
+ config.mode = mode;
96
+ config.pull_up_en = GPIO_PULLUP_DISABLE;
97
+ config.pull_down_en = GPIO_PULLDOWN_DISABLE;
98
+ config.intr_type = GPIO_INTR_DISABLE;
99
+ // Preset the level so the pad never glitches through the wrong state.
100
+ ESP_RETURN_ON_ERROR(gpio_set_level(pin, level), kTag, "preset GPIO%d", pin);
101
+ return gpio_config(&config);
102
+ }
103
+
104
+ esp_err_t rampVccOn()
105
+ {
106
+ constexpr gpio_num_t pin = gea::platform::board::power.vcc3v3Enable;
107
+ ledc_timer_config_t timer = {};
108
+ timer.speed_mode = kRampMode;
109
+ timer.duty_resolution = kRampResolution;
110
+ timer.timer_num = kRampTimer;
111
+ timer.freq_hz = kRampFrequencyHz;
112
+ timer.clk_cfg = LEDC_AUTO_CLK;
113
+ ESP_RETURN_ON_ERROR(ledc_timer_config(&timer), kTag, "ramp timer");
114
+
115
+ constexpr std::uint32_t maxDuty = (1U << kRampResolution) - 1U;
116
+ ledc_channel_config_t channel = {};
117
+ channel.gpio_num = pin;
118
+ channel.speed_mode = kRampMode;
119
+ channel.channel = kRampChannel;
120
+ channel.timer_sel = kRampTimer;
121
+ channel.duty = kVccOffLevel ? maxDuty : 0;
122
+ channel.hpoint = 0;
123
+ ESP_RETURN_ON_ERROR(ledc_channel_config(&channel), kTag, "ramp channel");
124
+
125
+ const esp_err_t installed = ledc_fade_func_install(0);
126
+ esp_err_t err = installed == ESP_ERR_INVALID_STATE ? ESP_OK : installed;
127
+ if (err == ESP_OK)
128
+ err = ledc_set_fade_with_time(kRampMode, kRampChannel, kVccOnLevel ? maxDuty : 0, kVccRampMs);
129
+ if (err == ESP_OK)
130
+ err = ledc_fade_start(kRampMode, kRampChannel, LEDC_FADE_WAIT_DONE);
131
+ if (installed == ESP_OK)
132
+ ledc_fade_func_uninstall();
133
+
134
+ // Hand the pad back to plain GPIO at its final level; a failed ramp leaves
135
+ // the rail off rather than half driven.
136
+ const int level = err == ESP_OK ? kVccOnLevel : kVccOffLevel;
137
+ ledc_stop(kRampMode, kRampChannel, level);
138
+ const esp_err_t restored = configureOutput(pin, GPIO_MODE_OUTPUT, level);
139
+ return err != ESP_OK ? err : restored;
140
+ }
141
+
142
+ void powerOnRailsLocked()
143
+ {
144
+ using gea::platform::board::power;
145
+ // Keep the board on before anything else: release the power-off request.
146
+ gpio_hold_dis(power.powerOffRequest);
147
+ esp_err_t err = configureOutput(power.powerOffRequest, GPIO_MODE_OUTPUT_OD, 1);
148
+ if (err != ESP_OK)
149
+ ESP_LOGE(kTag, "PWR_SW GPIO%d release failed: %s", power.powerOffRequest, esp_err_to_name(err));
150
+
151
+ gpio_hold_dis(power.vcc3v3Enable);
152
+ err = rampVccOn();
153
+ if (err != ESP_OK)
154
+ {
155
+ // Better a hard switch-on than a dark panel: the ramp only bounds inrush.
156
+ ESP_LOGW(kTag, "VCC_3V3 soft start failed (%s); switching it on directly", esp_err_to_name(err));
157
+ err = configureOutput(power.vcc3v3Enable, GPIO_MODE_OUTPUT, kVccOnLevel);
158
+ }
159
+ if (err != ESP_OK)
160
+ {
161
+ ESP_LOGE(kTag, "VCC_3V3 enable GPIO%d failed: %s", power.vcc3v3Enable, esp_err_to_name(err));
162
+ return;
163
+ }
164
+ vTaskDelay(pdMS_TO_TICKS(kVccSettleMs));
165
+ railsOn = true;
166
+ ESP_LOGI(kTag, "VCC_3V3 on (GPIO%d ramped low over %d ms), PWR_SW GPIO%d released",
167
+ power.vcc3v3Enable, kVccRampMs, power.powerOffRequest);
168
+ }
169
+
170
+ #if GEA_BOARD_USB_CONSOLE
171
+ char usbSerial[18] = "000000000000";
172
+ const char *usbStrings[] = {
173
+ "\x09\x04", // 0: English (0x0409)
174
+ "Espressif", // 1: Manufacturer
175
+ "ESP-Mosaico", // 2: Product
176
+ usbSerial, // 3: Serial -- the chip MAC, filled in at start
177
+ "ESP-Mosaico Console", // 4: CDC interface
178
+ };
179
+
180
+ #if GEA_BOARD_USB_DOWNLOAD_REQUEST
181
+ enum class UsbRestart : std::uint32_t
182
+ {
183
+ None = 0,
184
+ Normal,
185
+ Downloader,
186
+ };
187
+
188
+ // Line-state edges arrive on the TinyUSB task; the restart itself runs on a
189
+ // task of its own, a little later, so the host sees esptool's reset complete
190
+ // before the device drops off the bus.
191
+ constexpr std::uint64_t kRestartDelayUs = 50 * 1000;
192
+ constexpr std::uint32_t kWatchdogResetMs = 10;
193
+ constexpr std::uint32_t kReenumerationDelayMs = 20;
194
+ portMUX_TYPE restartLock = portMUX_INITIALIZER_UNLOCKED;
195
+ bool resetArmed = false;
196
+ UsbRestart pendingRestart = UsbRestart::None;
197
+ esp_timer_handle_t restartTimer = nullptr;
198
+ TaskHandle_t restartTask = nullptr;
199
+
200
+ // esp_restart() resets only the CPUs on the ESP32-S31. The RTC watchdog's
201
+ // system reset also resets the USB controller and its PHY -- so the host
202
+ // sees a detach -- while keeping the LP-domain force-download flag.
203
+ [[noreturn]] void watchdogSystemReset()
204
+ {
205
+ std::uint32_t ticks = static_cast<std::uint32_t>(
206
+ static_cast<std::uint64_t>(kWatchdogResetMs) * rtc_clk_slow_freq_get_hz() / 1000U);
207
+ if (ticks == 0)
208
+ ticks = 1;
209
+ wdt_hal_context_t rtcWdt = {};
210
+ wdt_hal_init(&rtcWdt, WDT_RWDT, 0, false);
211
+ wdt_hal_write_protect_disable(&rtcWdt);
212
+ wdt_hal_config_stage(&rtcWdt, WDT_STAGE0, ticks, WDT_STAGE_ACTION_RESET_SYSTEM);
213
+ wdt_hal_enable(&rtcWdt);
214
+ wdt_hal_write_protect_enable(&rtcWdt);
215
+ for (;;)
216
+ {
217
+ }
218
+ }
219
+
220
+ void restartTaskMain(void *)
221
+ {
222
+ for (;;)
223
+ {
224
+ std::uint32_t value = 0;
225
+ if (xTaskNotifyWait(0, UINT32_MAX, &value, portMAX_DELAY) != pdTRUE)
226
+ continue;
227
+ const auto restart = static_cast<UsbRestart>(value);
228
+ if (restart != UsbRestart::Normal && restart != UsbRestart::Downloader)
229
+ continue;
230
+ ESP_LOGW(kTag, "host requested %s over USB DTR/RTS",
231
+ restart == UsbRestart::Downloader ? "the ROM downloader" : "a restart");
232
+ // Leave the bus cleanly first, as Espressif's console does: without a
233
+ // visible detach the host never picks up the ROM downloader that
234
+ // enumerates after the reset, and the board vanishes from USB.
235
+ tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_0, pdMS_TO_TICKS(20));
236
+ if (tinyusb_console_deinit(TINYUSB_CDC_ACM_0) == ESP_OK)
237
+ {
238
+ tinyusb_cdcacm_unregister_callback(TINYUSB_CDC_ACM_0, CDC_EVENT_LINE_STATE_CHANGED);
239
+ if (tinyusb_cdcacm_deinit(TINYUSB_CDC_ACM_0) == ESP_OK)
240
+ tinyusb_driver_uninstall();
241
+ }
242
+ vTaskDelay(pdMS_TO_TICKS(kReenumerationDelayMs));
243
+ if (restart == UsbRestart::Downloader)
244
+ REG_SET_BIT(LP_SYSTEM_REG_SYS_CTRL_REG, LP_SYSTEM_REG_FORCE_DOWNLOAD_BOOT);
245
+ else
246
+ REG_CLR_BIT(LP_SYSTEM_REG_SYS_CTRL_REG, LP_SYSTEM_REG_FORCE_DOWNLOAD_BOOT);
247
+ watchdogSystemReset();
248
+ }
249
+ }
250
+
251
+ void restartTimerFired(void *)
252
+ {
253
+ taskENTER_CRITICAL(&restartLock);
254
+ const UsbRestart restart = pendingRestart;
255
+ pendingRestart = UsbRestart::None;
256
+ taskEXIT_CRITICAL(&restartLock);
257
+ if (restart != UsbRestart::None && restartTask)
258
+ xTaskNotify(restartTask, static_cast<std::uint32_t>(restart), eSetValueWithOverwrite);
259
+ }
260
+
261
+ void lineStateChanged(int itf, cdcacm_event_t *event)
262
+ {
263
+ if (itf != TINYUSB_CDC_ACM_0 || !event || event->type != CDC_EVENT_LINE_STATE_CHANGED)
264
+ return;
265
+ const bool dtr = event->line_state_changed_data.dtr;
266
+ const bool rts = event->line_state_changed_data.rts;
267
+ bool restart = false;
268
+ taskENTER_CRITICAL(&restartLock);
269
+ // (DTR=0, RTS=1) arms; a terminal opening the port toggles both lines, so
270
+ // an RTS falling edge alone is not a request.
271
+ if (!dtr && rts)
272
+ {
273
+ resetArmed = true;
274
+ }
275
+ else if (resetArmed && !rts)
276
+ {
277
+ pendingRestart = dtr ? UsbRestart::Downloader : UsbRestart::Normal;
278
+ resetArmed = false;
279
+ restart = true;
280
+ }
281
+ taskEXIT_CRITICAL(&restartLock);
282
+ if (restart && restartTimer)
283
+ {
284
+ esp_timer_stop(restartTimer);
285
+ esp_timer_start_once(restartTimer, kRestartDelayUs);
286
+ }
287
+ }
288
+
289
+ void startUsbRestartHandler()
290
+ {
291
+ if (xTaskCreatePinnedToCore(restartTaskMain, "mosaico_usb_rst", 3072, nullptr, 20, &restartTask, 0) != pdPASS)
292
+ {
293
+ ESP_LOGE(kTag, "USB restart task not created; flashing needs BOOT held through a power cycle");
294
+ return;
295
+ }
296
+ esp_timer_create_args_t timer = {};
297
+ timer.callback = restartTimerFired;
298
+ timer.name = "mosaico_usb_rst";
299
+ if (esp_timer_create(&timer, &restartTimer) != ESP_OK)
300
+ ESP_LOGE(kTag, "USB restart timer not created; flashing needs BOOT held through a power cycle");
301
+ }
302
+
303
+ #endif // GEA_BOARD_USB_DOWNLOAD_REQUEST
304
+
305
+ void startUsbConsole()
306
+ {
307
+ std::uint8_t mac[6] = {};
308
+ if (esp_read_mac(mac, ESP_MAC_BASE) == ESP_OK)
309
+ {
310
+ std::snprintf(usbSerial, sizeof(usbSerial), "%02X:%02X:%02X:%02X:%02X:%02X",
311
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
312
+ }
313
+
314
+ tinyusb_config_t config = TINYUSB_DEFAULT_CONFIG();
315
+ config.descriptor.string = usbStrings;
316
+ config.descriptor.string_count = sizeof(usbStrings) / sizeof(usbStrings[0]);
317
+ esp_err_t err = tinyusb_driver_install(&config);
318
+ if (err != ESP_OK)
319
+ {
320
+ ESP_LOGE(kTag, "TinyUSB install failed: %s; console stays on UART0", esp_err_to_name(err));
321
+ return;
322
+ }
323
+
324
+ tinyusb_config_cdcacm_t cdc = {};
325
+ cdc.cdc_port = TINYUSB_CDC_ACM_0;
326
+ #if GEA_BOARD_USB_DOWNLOAD_REQUEST
327
+ startUsbRestartHandler();
328
+ cdc.callback_line_state_changed = lineStateChanged;
329
+ #endif
330
+ err = tinyusb_cdcacm_init(&cdc);
331
+ if (err != ESP_OK)
332
+ {
333
+ ESP_LOGE(kTag, "USB CDC init failed: %s; console stays on UART0", esp_err_to_name(err));
334
+ return;
335
+ }
336
+
337
+ err = tinyusb_console_init(TINYUSB_CDC_ACM_0);
338
+ if (err != ESP_OK)
339
+ {
340
+ ESP_LOGE(kTag, "USB console redirect failed: %s; console stays on UART0", esp_err_to_name(err));
341
+ return;
342
+ }
343
+ ESP_LOGI(kTag, "USB CDC console up (serial %s)", usbSerial);
344
+ }
345
+ #endif
346
+
347
+ void boardStartTask(void *)
348
+ {
349
+ gea::platform::board::powerOnRails();
350
+ #if GEA_BOARD_USB_CONSOLE
351
+ startUsbConsole();
352
+ #endif
353
+ vTaskDelete(nullptr);
354
+ }
355
+ } // namespace
356
+
357
+ namespace gea::platform::board
358
+ {
359
+ void powerOnRails()
360
+ {
361
+ // Either the start task or display init gets here first; the other waits
362
+ // for the rail rather than talking to a panel that is still unpowered.
363
+ xSemaphoreTake(powerLock, portMAX_DELAY);
364
+ if (!railsOn)
365
+ powerOnRailsLocked();
366
+ xSemaphoreGive(powerLock);
367
+ }
368
+
369
+ // Display init calls this just before the panel takes its init sequence
370
+ // (GEA_BOARD_PREPARE_DISPLAY_PANEL). Referencing it from display.cpp is also
371
+ // what keeps this translation unit -- and the start hook below -- linked.
372
+ void prepareDisplayPanel()
373
+ {
374
+ powerOnRails();
375
+ }
376
+ } // namespace gea::platform::board
377
+
378
+ // Runs before app_main, before the scheduler. It only creates the start task:
379
+ // the LEDC fade and TinyUSB both need a running scheduler.
380
+ ESP_SYSTEM_INIT_FN(gea_mosaico_board_start, SECONDARY, BIT(0), 999)
381
+ {
382
+ powerLock = xSemaphoreCreateMutexStatic(&powerLockStorage);
383
+ if (xTaskCreatePinnedToCore(boardStartTask, "mosaico_start", 4096, nullptr, 10, nullptr, 0) != pdPASS)
384
+ ESP_EARLY_LOGW(kTag, "board start task not created; display init will open VCC_3V3");
385
+ return ESP_OK;
386
+ }
@@ -0,0 +1,36 @@
1
+ # A managed dependency is a requirement of `main` the moment it is listed here,
2
+ # so each network-only component carries the same capability rule the other
3
+ # targets use (GEA_EMBEDDED_CAPABILITY_* comes from the gea CLI's app analysis).
4
+ #
5
+ # Not here, unlike the S3 AMOLED targets: esp_audio_codec and esp-sr ship
6
+ # prebuilt per-chip libraries; the portable Opus build below stands in for the
7
+ # former, and an app that asks for echo cancellation is not supported yet.
8
+ dependencies:
9
+ espressif/esp_lcd_co5300: '^2.0.3'
10
+ # The CST92xx family shares this protocol; the BSP's own CST9220 driver reads
11
+ # the same 0xD000 report block at 0x5A.
12
+ waveshare/esp_lcd_touch_cst9217: '^1.0.1'
13
+ espressif/esp_codec_dev: '^1.4.0'
14
+ esp_lcd_panel_io_additions: '^1'
15
+ # board_power.cpp: the USB-C port is the S31's high-speed OTG controller, so
16
+ # the console is a TinyUSB CDC interface.
17
+ espressif/esp_tinyusb: '^2.2.1'
18
+ espressif/esp_h264:
19
+ version: '^1.4.1'
20
+ rules:
21
+ - if: '$GEA_EMBEDDED_CAPABILITY_NETWORK == 1'
22
+ 78/esp-opus:
23
+ version: '^1.0.5'
24
+ rules:
25
+ - if: '$GEA_EMBEDDED_CAPABILITY_NETWORK == 1'
26
+ espressif/esp_websocket_client:
27
+ version: '^1.4'
28
+ rules:
29
+ - if: '$GEA_EMBEDDED_CAPABILITY_NETWORK == 1'
30
+ espressif/esp_peer:
31
+ version: '^1.4'
32
+ rules:
33
+ - if: '$GEA_EMBEDDED_CAPABILITY_NETWORK == 1'
34
+ idf:
35
+ # ESP32-S31 exists only in ESP-IDF master (6.2-dev), as a preview target.
36
+ version: '>=6.2.0-dev'
@@ -0,0 +1,147 @@
1
+ #pragma once
2
+
3
+ #include "driver/gpio.h"
4
+ #include "driver/i2s_types.h"
5
+ #include "driver/spi_master.h"
6
+
7
+ // Espressif ESP-Mosaico, hardware V1.2 (V1.1 shares the mapping).
8
+ //
9
+ // ESP32-S31 (dual-core RISC-V, 320 MHz) with 16 MB in-package octal PSRAM,
10
+ // 16 MB quad NOR flash, a 480x480 CO5300 QSPI AMOLED with a CST92xx touch
11
+ // controller, ES8311 codec + NS4150B amplifier, BMI270 IMU, two BMM150
12
+ // magnetometers, a BQ27220 fuel gauge and 128 MB SPI NAND.
13
+ //
14
+ // Pins come from the board's own BSP (esp-mosaico-bsp, bsp/esp_mosaico.h) and
15
+ // the esp-dev-kits V1.2 user guide. V1.0 is NOT interchangeable: it swaps the
16
+ // LCD clock and reset (GPIO44/42) and puts the onboard I2C on GPIO0/1. Getting
17
+ // the swap wrong is silent -- every QSPI write reports success into a panel
18
+ // still held in reset.
19
+ //
20
+ // Everything on the panel side sits behind VCC_3V3, a high-side switch whose
21
+ // enable (GPIO60) is ACTIVE LOW. Nothing on that rail answers until the board
22
+ // power code has opened it; see board_power.cpp.
23
+
24
+ namespace gea::platform::board {
25
+
26
+ struct I2cBusConfig {
27
+ gpio_num_t sda;
28
+ gpio_num_t scl;
29
+ };
30
+
31
+ struct Co5300DisplayConfig {
32
+ spi_host_device_t spiHost;
33
+ gpio_num_t cs;
34
+ gpio_num_t pclk;
35
+ gpio_num_t data0;
36
+ gpio_num_t data1;
37
+ gpio_num_t data2;
38
+ gpio_num_t data3;
39
+ gpio_num_t reset;
40
+ gpio_num_t te; // VBlank/tearing-effect line; GPIO_NUM_NC = vsync disabled
41
+ };
42
+
43
+ struct Cst9217TouchConfig {
44
+ gpio_num_t reset;
45
+ gpio_num_t interrupt;
46
+ bool swapXy;
47
+ bool mirrorX;
48
+ bool mirrorY;
49
+ };
50
+
51
+ struct Es8311AudioConfig {
52
+ int i2sPort;
53
+ gpio_num_t mclk;
54
+ gpio_num_t bclk;
55
+ gpio_num_t ws;
56
+ gpio_num_t dout;
57
+ gpio_num_t din;
58
+ gpio_num_t powerAmplifier;
59
+ };
60
+
61
+ struct PowerConfig {
62
+ // VCC_3V3 high-side switch enable, active low.
63
+ gpio_num_t vcc3v3Enable;
64
+ // Power-off request to the SAM8108 controller, open drain, asserted low.
65
+ // Released (high impedance) for as long as the board should stay on.
66
+ gpio_num_t powerOffRequest;
67
+ };
68
+
69
+ struct LauncherButtonConfig {
70
+ gpio_num_t pin;
71
+ int activeLevel;
72
+ };
73
+
74
+ class EspMosaicoV12 {
75
+ public:
76
+ // Onboard bus: touch (0x5A), ES8311 (0x19), BMI270 (0x69), BMM150 (0x11,
77
+ // 0x12) and BQ27220 (0x55). The expansion slots have their own bus on
78
+ // GPIO0/GPIO1, which nothing here drives.
79
+ static constexpr I2cBusConfig i2c{
80
+ .sda = GPIO_NUM_56,
81
+ .scl = GPIO_NUM_3,
82
+ };
83
+
84
+ // SPI3 carries the NAND; SPI2 is the panel's.
85
+ static constexpr Co5300DisplayConfig display{
86
+ .spiHost = SPI2_HOST,
87
+ .cs = GPIO_NUM_50,
88
+ .pclk = GPIO_NUM_42,
89
+ .data0 = GPIO_NUM_36,
90
+ .data1 = GPIO_NUM_51,
91
+ .data2 = GPIO_NUM_35,
92
+ .data3 = GPIO_NUM_9,
93
+ .reset = GPIO_NUM_44,
94
+ // The panel drives TE on GPIO43 and the init sequence enables it, but
95
+ // the runtime does not wait on it yet: bring-up first, tear-free later.
96
+ .te = GPIO_NUM_NC,
97
+ };
98
+
99
+ // Touch reset is not wired; the controller comes out of power-on reset
100
+ // with the VCC_3V3 rail. The panel and touch share orientation, and the
101
+ // BSP applies no base swap or mirror to either.
102
+ static constexpr Cst9217TouchConfig touch{
103
+ .reset = GPIO_NUM_NC,
104
+ .interrupt = GPIO_NUM_6,
105
+ .swapXy = false,
106
+ .mirrorX = false,
107
+ .mirrorY = false,
108
+ };
109
+
110
+ // The codec's I2S pins double as right-slot expansion pins; a module
111
+ // there and audio cannot be used at the same time.
112
+ static constexpr Es8311AudioConfig audio{
113
+ .i2sPort = I2S_NUM_AUTO,
114
+ .mclk = GPIO_NUM_54,
115
+ .bclk = GPIO_NUM_37,
116
+ .ws = GPIO_NUM_49,
117
+ .dout = GPIO_NUM_52,
118
+ .din = GPIO_NUM_40,
119
+ .powerAmplifier = GPIO_NUM_45,
120
+ };
121
+
122
+ static constexpr PowerConfig power{
123
+ .vcc3v3Enable = GPIO_NUM_60,
124
+ .powerOffRequest = GPIO_NUM_57,
125
+ };
126
+ };
127
+
128
+ using Board = EspMosaicoV12;
129
+
130
+ inline constexpr auto i2c = Board::i2c;
131
+ inline constexpr auto display = Board::display;
132
+ inline constexpr auto touch = Board::touch;
133
+ inline constexpr auto audio = Board::audio;
134
+ inline constexpr auto power = Board::power;
135
+
136
+ // The "AI" button on the side, active low. BOOT (GPIO61) stays the ROM's
137
+ // download strap and is left alone.
138
+ inline constexpr LauncherButtonConfig launcherButton{
139
+ .pin = GPIO_NUM_7,
140
+ .activeLevel = 0,
141
+ };
142
+
143
+ // Opens VCC_3V3 (soft-started) and releases the power-off request. Safe to
144
+ // call more than once; display init calls it through prepareDisplayPanel().
145
+ void powerOnRails();
146
+
147
+ } // namespace gea::platform::board
@@ -0,0 +1,5 @@
1
+ // Copy this file to wifi_config.h and fill in your credentials.
2
+ // wifi_config.h is gitignored — never commit real credentials.
3
+
4
+ #define GEA_EMBEDDED_WIFI_SSID "YOUR_SSID_HERE"
5
+ #define GEA_EMBEDDED_WIFI_PASSWORD "YOUR_PASSWORD_HERE"
@@ -0,0 +1,45 @@
1
+ #include "touch.h"
2
+ #include "chip_bindings/touch/cst9217_controller.h"
3
+
4
+ namespace {
5
+
6
+ gea::platform::esp32::chip_bindings::cst9217::TouchController &touchController() {
7
+ return gea::platform::esp32::chip_bindings::cst9217::TouchController::instance();
8
+ }
9
+
10
+ } // namespace
11
+
12
+ void gea::platform::touch::Touchscreen::setObserver(Observer observer) {
13
+ touchController().setObserver(observer);
14
+ }
15
+
16
+ void gea::platform::touch::Touchscreen::setPointerObserver(PointerObserver observer) {
17
+ touchController().setPointerObserver(observer);
18
+ }
19
+
20
+ bool gea::platform::touch::Touchscreen::init() {
21
+ return touchController().begin() == ESP_OK;
22
+ }
23
+
24
+ int gea::platform::touch::Touchscreen::read(int *x, int *y) {
25
+ gea::platform::esp32::chip_bindings::cst9217::TouchSample sample;
26
+ const bool touching = touchController().read(sample);
27
+ if (x) *x = sample.x;
28
+ if (y) *y = sample.y;
29
+ return touching ? 1 : 0;
30
+ }
31
+
32
+ int gea::platform::touch::Touchscreen::readCached(int *x, int *y) {
33
+ const auto sample = touchController().cached();
34
+ if (x) *x = sample.x;
35
+ if (y) *y = sample.y;
36
+ return sample.touching ? 1 : 0;
37
+ }
38
+
39
+ void gea::platform::touch::Touchscreen::consumeLatestMove(int *x, int *y) {
40
+ touchController().consumeLatestMove(x, y);
41
+ }
42
+
43
+ void gea::platform::touch::Touchscreen::injectEvent(Phase phase, bool touching, int x, int y) {
44
+ touchController().injectEvent(phase, touching, x, y);
45
+ }
@@ -0,0 +1,10 @@
1
+ # Espressif ESP-Mosaico V1.2, 16 MB quad NOR flash (GD25Q128E).
2
+ # The S31 bootloader sits at 0x2000 (the first two sectors are reserved), which
3
+ # leaves it 24 KB below the partition table at 0x8000.
4
+ # Name, Type, SubType, Offset, Size
5
+ nvs, data, nvs, 0x9000, 0x6000
6
+ otadata, data, ota, 0xf000, 0x2000
7
+ phy_init, data, phy, 0x11000, 0x1000
8
+ ota_0, app, ota_0, 0x20000, 0x700000
9
+ ota_1, app, ota_1, 0x720000, 0x700000
10
+ storage, data, spiffs, 0xe20000, 0x1c0000