[ESP-Hosted-MCU] Fix OTA URL + speedup log output to serial

This commit is contained in:
TD-er
2026-05-10 23:46:10 +02:00
parent 99ec57a6d0
commit 20e3975495
7 changed files with 54 additions and 10 deletions
+11 -1
View File
@@ -39,6 +39,10 @@ extern "C" {
# endif // ifdef ESP32
# ifdef BOARD_HAS_SDIO_ESP_HOSTED
# define MIN_REQUIRED_ESP_HOSTED_FW 0x00020600
# endif
namespace ESPEasy {
namespace net {
namespace wifi {
@@ -378,6 +382,12 @@ bool write_WiFi_Hosted_MCU_info(KeyValueWriter*writer)
} else {
writer->write({ F("ESP-Host Fw Version"), GetHostedFwVersion(EspHostTypes::ESP_HOST) });
writer->write({ F("ESP-Hosted-MCU Fw Version"), GetHostedFwVersion(EspHostTypes::ESP_HOSTED) });
if (GetHostedMCUFwVersion() < MIN_REQUIRED_ESP_HOSTED_FW) {
writer->writeNote(F("ESP-Hosted-MCU firmware is too old, run <tt>wifiotahostedmcu</tt> via ESPEasy console"));
} else if (hostedHasUpdate()) {
writer->writeNote(F("ESP-Hosted-MCU firmware update available, run <tt>wifiotahostedmcu</tt> via ESPEasy console"));
}
writer->write({ F("ESP-Hosted-MCU Chip"), GetHostedMCU() });
writer->write({
F("MAC"),
@@ -505,7 +515,7 @@ bool wifiAPmodeActivelyUsed()
return false;
}
#ifdef BOARD_HAS_SDIO_ESP_HOSTED
if (GetHostedMCUFwVersion() < 0x010000) {
if (GetHostedMCUFwVersion() < MIN_REQUIRED_ESP_HOSTED_FW) {
// Hosted fw is too old, function below is not yet implemented
// When calling that function the ESP32-P4 will crash.
return false;
+16 -1
View File
@@ -206,11 +206,21 @@ String Command_Wifi_OTA_hosted_mcu(
return return_command_failed_flashstr();
}
const String url = hostedGetUpdateURL();
uint32_t major, minor, patch;
hostedGetHostVersion(&major, &minor, &patch);
// https://pioarduino.github.io/esp-hosted-mcu-firmware/v2.12.7/network_adapter_esp32c6.bin
const String url = strformat(
F("https://pioarduino.github.io/esp-hosted-mcu-firmware/v%u.%u.%u/network_adapter_%s.bin"),
major, minor, patch,
CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET);
// Step 4: Begin the update process - display update URL
addLog(LOG_LEVEL_INFO, concat(F("Updating esp-hosted co-processor from "), url));
processLogs();
/*
// Step 5: Create a secure network client for HTTPS communication
BearSSL::WiFiClientSecure_light secureClient(4096, 4096);
@@ -264,6 +274,7 @@ String Command_Wifi_OTA_hosted_mcu(
// Step 11: Initialize the ESP-Hosted update process
addLog(LOG_LEVEL_INFO, F("Beginning update process..."));
processLogs();
// FIXME TD-er: Block actual update to see how far we get with making connection
// goto finish_ota;
@@ -343,6 +354,7 @@ String Command_Wifi_OTA_hosted_mcu(
// Small delay to prevent overwhelming the system
delay(1);
}
processLogs(true);
// Step 15: Clean up allocated buffer
free(buff);
@@ -352,6 +364,7 @@ String Command_Wifi_OTA_hosted_mcu(
} else {
addLog(LOG_LEVEL_ERROR, strformat(F("ERROR: HTTP request failed with code %d!"), httpCode));
}
processLogs(true);
// Step 16: Close HTTP connection
https.end();
@@ -361,6 +374,8 @@ finish_ota:
// Step 17: Clean up network client
// delete client;
processLogs(true);
if (updateSuccess) { return return_command_success_flashstr(); }
return return_command_failed_flashstr();
}
+15
View File
@@ -219,6 +219,7 @@ void addLog(uint8_t logLevel, const __FlashStringHelper *str)
}
#endif // ifdef ESP32
Logging.addLogEntry(LogEntry_t(logLevel, str));
processLogs();
}
void addLog(uint8_t logLevel, const char *line) {
@@ -233,6 +234,7 @@ void addLog(uint8_t logLevel, const char *line) {
}
#endif // ifdef ESP32
Logging.addLogEntry(LogEntry_t(logLevel, line));
processLogs();
}
void addLog(uint8_t logLevel, String&& str) { addToLogMove(logLevel, std::move(str)); }
@@ -250,6 +252,7 @@ void addLog(uint8_t logLevel, const String& str)
}
#endif // ifdef ESP32
Logging.addLogEntry(LogEntry_t(logLevel, str));
processLogs();
}
void addToLogMove(uint8_t logLevel, String&& str)
@@ -265,4 +268,16 @@ void addToLogMove(uint8_t logLevel, String&& str)
}
#endif // ifdef ESP32
Logging.addLogEntry(LogEntry_t(logLevel, std::move(str)));
processLogs();
}
void processLogs(bool serialOnly)
{
process_serialWriteBuffer();
Logging.loop(serialOnly);
#if FEATURE_SYSLOG
if (!serialOnly) {
syslogWriter.process();
}
#endif
}
+4
View File
@@ -47,3 +47,7 @@ void addLog(uint8_t logLevel,
void addToLogMove(uint8_t logLevel,
String&& str);
void processLogs(bool serialOnly = false);
@@ -28,6 +28,7 @@
* run background tasks
\*********************************************************************************************/
bool runningBackgroundTasks = false;
void backgroundtasks()
{
// checkRAM(F("backgroundtasks"));
@@ -74,11 +75,8 @@ void backgroundtasks()
}
*/
process_serialWriteBuffer();
#if FEATURE_SYSLOG
syslogWriter.process();
#endif
Logging.loop();
processLogs();
if (!UseRTOSMultitasking) {
serial();
+4 -2
View File
@@ -52,7 +52,7 @@ void LogHelper::addLogEntry(LogEntry_t&& logEntry)
_logBuffer.add(std::move(logEntry));
loop();
loop(false);
}
bool LogHelper::getNext(LogDestination logDestination, uint32_t& timestamp, String& message, uint8_t& loglevel)
@@ -65,9 +65,10 @@ uint32_t LogHelper::getNrMessages(LogDestination logDestination) const
return _logBuffer.getNrMessages(logDestination);
}
void LogHelper::loop()
void LogHelper::loop(bool serialOnly)
{
#if FEATURE_SD
if (!serialOnly) {
String message;
uint32_t timestamp{};
uint8_t loglevel{};
@@ -76,6 +77,7 @@ void LogHelper::loop()
{
addToSDLog(loglevel, message);
}
}
#endif
_logBuffer.clearExpiredEntries();
}
+1 -1
View File
@@ -21,7 +21,7 @@ public:
uint32_t getNrMessages(LogDestination logDestination) const;
void loop();
void loop(bool serialOnly);
bool logActiveRead(LogDestination logDestination);