Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions custom/integration/wifi_remote/hosted_safe.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
#include "freertos/task.h"
#include "sdkconfig.h"

#if CONFIG_M5TAB5_USE_ESP_HOSTED
#if CONFIG_APP_ENABLE_WIFI_HOSTED
# include "esp_hosted_api.h"
# include "esp_wifi.h"
# include "esp_wifi_remote.h"
#endif

static const char* TAG = "hosted_safe";
static bool s_hosted_ready = false;
static bool s_hosted_ready = false; // Guarded by CONFIG_APP_ENABLE_WIFI_HOSTED

#if CONFIG_M5TAB5_USE_ESP_HOSTED
#if CONFIG_APP_ENABLE_WIFI_HOSTED
static void slave_pulse_reset(void)
{
const gpio_num_t rst = 54;
Expand All @@ -40,7 +40,7 @@ static void slave_pulse_reset(void)

bool hosted_try_init_with_retries(void)
{
#if !CONFIG_M5TAB5_USE_ESP_HOSTED
#if !CONFIG_APP_ENABLE_WIFI_HOSTED
ESP_LOGI(TAG, "ESP-Hosted disabled via Kconfig.");
return false;
#else
Expand Down Expand Up @@ -95,7 +95,7 @@ bool hosted_try_init_with_retries(void)

void hosted_deinit_safe(void)
{
#if CONFIG_M5TAB5_USE_ESP_HOSTED
#if CONFIG_APP_ENABLE_WIFI_HOSTED
if (!s_hosted_ready)
{
return;
Expand Down
9 changes: 3 additions & 6 deletions platforms/tab5/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
menu "M5Tab5 Connectivity"

config M5TAB5_USE_ESP_HOSTED
bool "Enable ESP-Hosted (Wi-Fi over SDIO)"
default n
help
When enabled, the app will initialize the ESP-Hosted SDIO slave (ESP32-Cx).
When disabled, boot never touches SDIO/Hosted and Wi-Fi is unavailable.
if APP_ENABLE_WIFI_HOSTED

config M5TAB5_HOSTED_BOOT_RETRIES
int "Hosted init retries at boot"
Expand All @@ -17,4 +12,6 @@ config M5TAB5_HOSTED_BOOT_DELAY_MS
range 0 5000
default 500

endif

endmenu
4 changes: 4 additions & 0 deletions platforms/tab5/dependencies.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ dependencies:
source:
registry_url: https://components.espressif.com/
type: service
rules:
- if: CONFIG_APP_ENABLE_WIFI_HOSTED
version: 1.4.0
espressif/esp_lcd_ili9881c:
component_hash: eb9ba0484d1d14171b69e5d192716fb1cdd6ef068aa4014dc3202486e124498e
Expand Down Expand Up @@ -225,6 +227,8 @@ dependencies:
source:
registry_url: https://components.espressif.com/
type: service
rules:
- if: CONFIG_APP_ENABLE_WIFI_HOSTED
version: 0.8.5
espressif/led_strip:
component_hash: f907c58f722c58ab8545366668cfd8769cefb7d97a631a14e9d16234cc72bdff
Expand Down
12 changes: 12 additions & 0 deletions platforms/tab5/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ config APP_LOG_LEVEL
Sets the default log verbosity for the application layer.
0 = none, 1 = error, 2 = warn, 3 = info, 4 = debug, 5 = verbose.

menu "App Features"

config APP_ENABLE_WIFI_HOSTED
bool "Enable ESP-Hosted (Wi-Fi over SDIO) on Tab5"
default n
help
When enabled, the firmware will power on the ESP-Hosted SDIO coprocessor
and bring up the remote Wi-Fi stack. Disable this to keep SDIO idle while
other system issues are being debugged.

endmenu

config HAL_AUDIO_ENABLE_LONG_DEMO
bool "Enable long Canon in D demo"
default n
Expand Down
37 changes: 30 additions & 7 deletions platforms/tab5/main/app_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,63 @@
*
* SPDX-License-Identifier: MIT
*/
// clang-format off
#include <memory>

#include <app.h>
#include <esp_err.h>
#include <esp_heap_trace.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>

#include <hal/hal.h>
#include <sdkconfig.h>

#include "hal/hal_esp32.h"
#include <app.h>
#include <hal/hal.h>
// clang-format on

#if defined(CONFIG_I2C_ENABLE_LEGACY_DRIVERS) && CONFIG_I2C_ENABLE_LEGACY_DRIVERS
#error "Legacy ESP-IDF I2C driver is unsupported; disable CONFIG_I2C_ENABLE_LEGACY_DRIVERS."
# error "Legacy ESP-IDF I2C driver is unsupported; disable CONFIG_I2C_ENABLE_LEGACY_DRIVERS."
#endif

#if !defined(CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK) || !CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK
#error "Enable CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK so the legacy driver stays dormant."
# error "Enable CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK so the legacy driver stays dormant."
#endif

#if CONFIG_HEAP_TRACING
namespace
{
constexpr size_t kHeapTraceDepth = 256;
heap_trace_record_t s_heap_trace_records[kHeapTraceDepth];
} // namespace
#endif

extern "C" void app_main(void)
{
// 应用层初始化回调
app::InitCallback_t callback;

callback.onHalInjection = []() {
#if CONFIG_HEAP_TRACING
ESP_ERROR_CHECK(heap_trace_init_standalone(s_heap_trace_records, kHeapTraceDepth));
ESP_ERROR_CHECK(heap_trace_start(HEAP_TRACE_ALL));
#endif

callback.onHalInjection = []()
{
// 注入桌面平台的硬件抽象
hal::Inject(std::make_unique<HalEsp32>());
};

// 应用层启动
app::Init(callback);
while (!app::IsDone()) {
while (!app::IsDone())
{
app::Update();
vTaskDelay(1);
}
app::Destroy();

#if CONFIG_HEAP_TRACING
ESP_ERROR_CHECK(heap_trace_stop());
heap_trace_dump();
#endif
}
13 changes: 8 additions & 5 deletions platforms/tab5/main/hal/components/hal_wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
#include <cstring>
#include <esp_check.h>
#include <esp_event.h>
#include <esp_hosted_api.h>
#include <esp_log.h>
#include <esp_netif.h>
#include <esp_wifi.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <mooncake_log.h>
Expand All @@ -21,6 +19,11 @@
#include "integration/wifi_remote/hosted_safe.h"
#include "sdkconfig.h"

#if CONFIG_APP_ENABLE_WIFI_HOSTED
# include <esp_hosted_api.h>
# include <esp_wifi.h>
#endif

#define TAG "wifi"

#define WIFI_SSID "M5Tab5-UserDemo-WiFi"
Expand All @@ -30,7 +33,7 @@
namespace
{

#if CONFIG_M5TAB5_USE_ESP_HOSTED
#if CONFIG_APP_ENABLE_WIFI_HOSTED

struct WifiRuntimeState
{
Expand Down Expand Up @@ -210,13 +213,13 @@ namespace
return ESP_OK;
}

#endif // CONFIG_M5TAB5_USE_ESP_HOSTED
#endif // CONFIG_APP_ENABLE_WIFI_HOSTED

} // namespace

bool HalEsp32::wifi_init()
{
#if !CONFIG_M5TAB5_USE_ESP_HOSTED
#if !CONFIG_APP_ENABLE_WIFI_HOSTED
ESP_LOGW(TAG, "ESP-Hosted disabled via Kconfig; skipping Wi-Fi init");
return false;
#else
Expand Down
10 changes: 8 additions & 2 deletions platforms/tab5/main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
dependencies:
## Required IDF version
idf: "~5.4"
espressif/esp_hosted: 1.4.0
espressif/esp_wifi_remote: 0.8.5
espressif/esp_hosted:
version: 1.4.0
rules:
- if: "CONFIG_APP_ENABLE_WIFI_HOSTED"
espressif/esp_wifi_remote:
version: 0.8.5
rules:
- if: "CONFIG_APP_ENABLE_WIFI_HOSTED"
chmorgan/esp-audio-player: 1.0.7
chmorgan/esp-file-iterator: 1.0.0
espressif/led_strip: 3.0.0
Expand Down
11 changes: 10 additions & 1 deletion platforms/tab5/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ CONFIG_ESP_EXTCONN_SLAVE_ENABLE_PIN=54
CONFIG_ESP_EXTCONN_SLAVE_ENABLE_LEVEL=1

# Hosted feature default (safe)
CONFIG_M5TAB5_USE_ESP_HOSTED=n
CONFIG_APP_ENABLE_WIFI_HOSTED=n
CONFIG_M5TAB5_HOSTED_BOOT_RETRIES=3
CONFIG_M5TAB5_HOSTED_BOOT_DELAY_MS=500

# Heap diagnostics
CONFIG_HEAP_POISONING_LIGHT=y
CONFIG_HEAP_TASK_TRACKING=y
CONFIG_HEAP_TRACING=y
CONFIG_HEAP_TRACING_STANDALONE=y
CONFIG_HEAP_TRACING_STACK_DEPTH=12
CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y
CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y
Loading