Skip to content

feat(hosted): Add method to update the hosted slave firmware #11580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
23 changes: 18 additions & 5 deletions libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ extern "C" {
#include "lwip/netif.h"
#include "dhcpserver/dhcpserver.h"
#include "dhcpserver/dhcpserver_options.h"

} //extern "C"

#include "esp32-hal.h"
Expand Down Expand Up @@ -241,10 +240,10 @@ extern "C" void phy_bbpll_en_usb(bool en);

#if CONFIG_ESP_WIFI_REMOTE_ENABLED
extern "C" {
//#include "esp_hosted.h"
#include "esp_hosted_transport_config.h"
extern esp_err_t esp_hosted_init();
extern esp_err_t esp_hosted_deinit();
#include "esp_hosted.h"
// #include "esp_hosted_transport_config.h"
// extern esp_err_t esp_hosted_init();
// extern esp_err_t esp_hosted_deinit();
};
typedef struct {
uint8_t pin_clk;
Expand Down Expand Up @@ -296,6 +295,15 @@ bool WiFiGenericClass::setPins(int8_t clk, int8_t cmd, int8_t d0, int8_t d1, int
return true;
}

bool WiFiGenericClass::updateSlave(const char * url) {
esp_err_t err = esp_hosted_slave_ota(url);
if (err != ESP_OK) {
log_e("esp_hosted_slave_ota failed! 0x%x: %s", err, esp_err_to_name(err));
return false;
}
return true;
}

static bool wifiHostedInit() {
if (!hosted_initialized) {
hosted_initialized = true;
Expand All @@ -314,6 +322,11 @@ static bool wifiHostedInit() {
return false;
}
log_v("ESP-HOSTED initialized!");
// // This throws heap exception when the slave has older firmware
// esp_hosted_coprocessor_fwver_t fwver = {0,0,0};
// if (esp_hosted_get_coprocessor_fwversion(&fwver) == ESP_OK) {
// log_d("ESP-HOSTED Slave FW Version: %lu.%li.%lu", fwver.major1, fwver.minor1, fwver.patch1);
// }
}
// Attach pins to PeriMan here
// Slave chip model is CONFIG_IDF_SLAVE_TARGET
Expand Down
1 change: 1 addition & 0 deletions libraries/WiFi/src/WiFiGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class WiFiGenericClass {
#if CONFIG_ESP_WIFI_REMOTE_ENABLED
// Set SDIO pins for connection to external ESP MCU
static bool setPins(int8_t clk, int8_t cmd, int8_t d0, int8_t d1, int8_t d2, int8_t d3, int8_t rst);
static bool updateSlave(const char * url);
#endif

wifi_event_id_t onEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
Expand Down
Loading