@geastack/targets 0.1.108 → 0.1.110

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.
@@ -54,6 +54,20 @@ endif()
54
54
  set(GEA_EMBEDDED_HTTPS_SUPPORT "auto" CACHE STRING "Enable HTTPS fetch support: auto, on, or off")
55
55
  set(GEA_EMBEDDED_CPP_BOARD "esp32-s3-touch-amoled-2.06" CACHE STRING "Board profile passed to geatsc for C++ target selection")
56
56
  set(GEA_EMBEDDED_CSS_DEVICE_PIXEL_RATIO "1.5" CACHE STRING "Logical CSS px to physical pixel scale for this board")
57
+ # A composed board (GEA_BOARD_DEFINITION) builds through this project but is not
58
+ # this board: geatsc gets its own name, panel pixel order and viewport, not the
59
+ # AMOLED's (byte-swapped RGB565 at 410x502).
60
+ set(GEA_EMBEDDED_TARGET_PIXEL_PANEL_ENDIAN 1)
61
+ set(GEA_EMBEDDED_FONT_VIEWPORT_ARGS "")
62
+ if(GEA_CUSTOM_TARGET_ACTIVE AND GEA_CUSTOM_TARGET_BOARD_ID)
63
+ set(GEA_EMBEDDED_CPP_BOARD "${GEA_CUSTOM_TARGET_BOARD_ID}")
64
+ set(GEA_EMBEDDED_TARGET_PIXEL_PANEL_ENDIAN ${GEA_CUSTOM_TARGET_PIXEL_PANEL_ENDIAN})
65
+ if(GEA_CUSTOM_TARGET_VIEWPORT_WIDTH AND GEA_CUSTOM_TARGET_VIEWPORT_HEIGHT)
66
+ set(GEA_EMBEDDED_FONT_VIEWPORT_ARGS
67
+ --font-viewport-width ${GEA_CUSTOM_TARGET_VIEWPORT_WIDTH}
68
+ --font-viewport-height ${GEA_CUSTOM_TARGET_VIEWPORT_HEIGHT})
69
+ endif()
70
+ endif()
57
71
 
58
72
  # Write a file only when its content would change. Preserves mtime when content matches,
59
73
  # so downstream make/ninja rules don't see spurious changes on every reconfigure.
@@ -572,7 +586,16 @@ if(NOT GEA_APP_CANVAS_ONLY)
572
586
  # sound nothing at all. Framework surfaces (HTMLAudioElement, the sound
573
587
  # attributes, device control) still reference the AudioSystem backend, so the
574
588
  # no-audio build answers them with the shared no-op stub.
575
- if(GEA_EMBEDDED_CAPABILITY_AUDIO)
589
+ if(GEA_EMBEDDED_CAPABILITY_AUDIO AND GEA_CUSTOM_TARGET_ACTIVE AND GEA_CUSTOM_TARGET_AUDIO_SOURCES)
590
+ # A composed board whose speaker is a bare I2S amplifier (no codec):
591
+ # its binding answers the same OutputDriver the runtime mixes into.
592
+ list(APPEND GEA_EMBEDDED_TARGET_HOST_SOURCES
593
+ ${GEA_CUSTOM_TARGET_AUDIO_SOURCES}
594
+ "${GEA_HOST}/audio_runtime.cpp"
595
+ )
596
+ list(APPEND GEA_EMBEDDED_TARGET_REQUIRES esp_driver_i2s)
597
+ list(APPEND GEA_EMBEDDED_CAPABILITY_COMPILE_DEFINITIONS GEA_EMBEDDED_APP_USES_AUDIO=1 GEA_BOARD_HAS_SPEAKER=1)
598
+ elseif(GEA_EMBEDDED_CAPABILITY_AUDIO)
576
599
  list(APPEND GEA_EMBEDDED_TARGET_HOST_SOURCES
577
600
  "${GEA_EMBEDDED_ROOT}/targets/esp32/chip_bindings/audio/es8311.cpp"
578
601
  "${GEA_HOST}/audio_runtime.cpp"
@@ -620,6 +643,8 @@ if(NOT GEA_APP_CANVAS_ONLY)
620
643
  esp_driver_i2c
621
644
  esp_driver_usb_serial_jtag
622
645
  esp_driver_sdmmc
646
+ esp_driver_sdspi
647
+ esp_driver_spi
623
648
  sdmmc
624
649
  fatfs
625
650
  )
@@ -934,7 +959,8 @@ add_custom_command(
934
959
  --out-dir ${GENERATED_APP_DIR}
935
960
  --geatsc-bin ${_GEATSC_BIN}
936
961
  --font-device-pixel-ratio ${GEA_EMBEDDED_CSS_DEVICE_PIXEL_RATIO}
937
- --pixel-panel-endian 1
962
+ --pixel-panel-endian ${GEA_EMBEDDED_TARGET_PIXEL_PANEL_ENDIAN}
963
+ ${GEA_EMBEDDED_FONT_VIEWPORT_ARGS}
938
964
  --gea-ir-backend
939
965
  # gea.compilerPlugins: an app's own geatsc plugins, e.g. the one that
940
966
  # declares its native host-function boundary. Empty for most apps.
@@ -991,5 +1017,8 @@ target_include_directories(gea_active_app_assets PRIVATE ${GEA_FW_INCLUDE_DIRS})
991
1017
  add_dependencies(gea_active_app_assets geatsc_build)
992
1018
  target_link_libraries(${COMPONENT_LIB} PRIVATE
993
1019
  "-Wl$<COMMA>--whole-archive$<COMMA>$<TARGET_FILE:gea_active_app_assets>$<COMMA>--no-whole-archive")
1020
+ # A $<TARGET_FILE> inside a link flag orders nothing: without this the link can
1021
+ # run before the archive exists ("cannot find libgea_active_app_assets.a").
1022
+ add_dependencies(${COMPONENT_LIB} gea_active_app_assets)
994
1023
 
995
1024
  gea_framework_inherit_build_settings()
@@ -193,8 +193,19 @@ void runtimeTask(void *)
193
193
 
194
194
  } // namespace
195
195
 
196
+ #if GEA_BOARD_HAS_RTC
197
+ namespace gea::platform::rtc {
198
+ void restoreSystemTime();
199
+ }
200
+ #endif
201
+
196
202
  extern "C" void app_main(void)
197
203
  {
204
+ #if GEA_BOARD_HAS_RTC
205
+ // Before anything reads the wall clock: a board with a battery-backed RTC
206
+ // boots with the time it kept while powered off.
207
+ gea::platform::rtc::restoreSystemTime();
208
+ #endif
198
209
  #if GEA_EMBEDDED_FULL_BOOT_SERVICES
199
210
  // Force the targets/esp32/apps/app_manager.cpp TU to be linked in. That
200
211
  // TU's only side effect is a file-scope `PlatformRegistration` whose
@@ -18,6 +18,10 @@
18
18
  #include <sys/stat.h>
19
19
 
20
20
  #include "driver/sdmmc_host.h"
21
+ #if defined(GEA_BOARD_MICROSD_SPI) && GEA_BOARD_MICROSD_SPI
22
+ #include "driver/sdspi_host.h"
23
+ #include "driver/spi_common.h"
24
+ #endif
21
25
  #include "esp_log.h"
22
26
  #include "esp_vfs_fat.h"
23
27
  #include "sdmmc_cmd.h"
@@ -37,8 +41,60 @@ bool g_attempted = false;
37
41
  bool g_mounted = false;
38
42
  sdmmc_card_t *g_card = nullptr;
39
43
 
44
+ #if defined(GEA_BOARD_MICROSD_SPI) && GEA_BOARD_MICROSD_SPI
45
+ // A slot wired for SPI (the Elecrow CrowPanel Advance's, whose chip select is
46
+ // hard-wired low). SD_MMC cannot drive it: DAT3 low at CMD0 puts the card in
47
+ // SPI mode, so it must be spoken to as SPI.
48
+ bool mountSdCardSpi(const esp_vfs_fat_sdmmc_mount_config_t &mountConfig)
49
+ {
50
+ constexpr auto &spi = gea::platform::board::storageSpi;
51
+ sdmmc_host_t host = SDSPI_HOST_DEFAULT();
52
+ host.slot = SPI2_HOST;
53
+ host.max_freq_khz = SDMMC_FREQ_DEFAULT; // 20 MHz; the card shares its lines with other functions
54
+
55
+ spi_bus_config_t bus = {};
56
+ bus.mosi_io_num = spi.mosi;
57
+ bus.miso_io_num = spi.miso;
58
+ bus.sclk_io_num = spi.sck;
59
+ bus.quadwp_io_num = GPIO_NUM_NC;
60
+ bus.quadhd_io_num = GPIO_NUM_NC;
61
+ bus.max_transfer_sz = 16 * 1024;
62
+ esp_err_t err = spi_bus_initialize(static_cast<spi_host_device_t>(host.slot), &bus, SDSPI_DEFAULT_DMA);
63
+ if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) {
64
+ ESP_LOGE(kTag, "SPI bus init failed: %s", esp_err_to_name(err));
65
+ return false;
66
+ }
67
+
68
+ sdspi_device_config_t slot = SDSPI_DEVICE_CONFIG_DEFAULT();
69
+ slot.host_id = static_cast<spi_host_device_t>(host.slot);
70
+ slot.gpio_cs = spi.cs; // GPIO_NUM_NC when the board ties chip select
71
+
72
+ ESP_LOGI(kTag, "mounting /sdcard SPI sck=%d mosi=%d miso=%d cs=%d", static_cast<int>(spi.sck),
73
+ static_cast<int>(spi.mosi), static_cast<int>(spi.miso), static_cast<int>(spi.cs));
74
+ err = esp_vfs_fat_sdspi_mount("/sdcard", &host, &slot, &mountConfig, &g_card);
75
+ if (err != ESP_OK) {
76
+ ESP_LOGE(kTag, "mount /sdcard failed: %s (card inserted + FAT-formatted? DIP switch on SD?)", esp_err_to_name(err));
77
+ spi_bus_free(static_cast<spi_host_device_t>(host.slot));
78
+ return false;
79
+ }
80
+ ESP_LOGI(kTag, "mounted /sdcard (SPI)");
81
+ return true;
82
+ }
83
+ #endif
84
+
40
85
  bool mountSdCard()
41
86
  {
87
+ #if defined(GEA_BOARD_MICROSD_SPI) && GEA_BOARD_MICROSD_SPI
88
+ {
89
+ struct stat st {};
90
+ if (stat("/sdcard", &st) == 0) return true;
91
+ esp_vfs_fat_sdmmc_mount_config_t mountConfig = {};
92
+ mountConfig.format_if_mount_failed = false;
93
+ mountConfig.max_files = 3;
94
+ mountConfig.allocation_unit_size = 16 * 1024;
95
+ return mountSdCardSpi(mountConfig);
96
+ }
97
+ #endif
42
98
  if (kPinClk == GPIO_NUM_NC || kPinCmd == GPIO_NUM_NC || kPinD0 == GPIO_NUM_NC) {
43
99
  ESP_LOGI(kTag, "no microSD pins configured; storage cache disabled");
44
100
  return false;
package/targets.json CHANGED
@@ -29,6 +29,16 @@
29
29
  "esptoolChip": "esp32s3",
30
30
  "ipcTaskStackSize": "4096"
31
31
  },
32
+ "esp32-s3-elecrow-crowpanel-advance-7.0": {
33
+ "adapter": "esp32-idf",
34
+ "targetPath": "targets/esp32-s3-touch-amoled-2.06",
35
+ "definition": "targets/esp32-s3-elecrow-crowpanel-advance-7.0.json",
36
+ "flashSize": "16MB",
37
+ "appPlatform": "esp32",
38
+ "idfTarget": "esp32s3",
39
+ "esptoolChip": "esp32s3",
40
+ "ipcTaskStackSize": "4096"
41
+ },
32
42
  "esp32-s3-touch-amoled-2.06": {
33
43
  "adapter": "esp32-idf",
34
44
  "targetPath": "targets/esp32-s3-touch-amoled-2.06",