-
Notifications
You must be signed in to change notification settings - Fork 123
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
Using 0009 ESP32 OTA Process #218
Comments
I am assuming you are using an instance of the
Because this log message means that method failed to find out the exact reason (because the 2 app sections seem good in your partitions file) we have to debug further. In the bool Espressif_Updater::begin(size_t const & firmware_size) {
esp_partition_t const * const running = esp_ota_get_running_partition();
esp_partition_t const * const configured = esp_ota_get_boot_partition();
if (configured != running) {
// The two results are not equal if the configured boot partition does not contain a valid app (meaning that the running partition will be an app that the bootloader chose via fallback). If the OTA data partition is not present or not valid then the result is the first app partition found in the partition table.
printf("The running partition and the parition we wanted to boot into were not the same meaning the previous update failed and choose the fallback partition instead. Aborting update\n");
return false;
}
esp_partition_t const * const update_partition = esp_ota_get_next_update_partition(nullptr);
if (update_partition == nullptr) {
// NULL result indicates invalid OTA data partition, or that no eligible OTA app slot partition was found
printf("Missing second ota app or app was invalid\n");
return false;
}
// Temporary handle is used, because it allows using a void* as the actual ota_handle,
// allowing us to only include the esp_ota_ops header in the defintion (.cpp) file,
// instead of also needing to declare it in the declaration (.h) header file
esp_ota_handle_t ota_handle;
esp_err_t const error = esp_ota_begin(update_partition, firmware_size, &ota_handle);
if (error != ESP_OK) {
printf("Beginning update failed with error reason (%s)", esp_err_to_name(error));
return false;
}
m_ota_handle = ota_handle;
m_update_partition = update_partition;
return true;
} |
Beginning update failed with error reason (ESP_ERR_INVALID_SIZE)[TB] Failed to initalize flash updater, ensure that the partition scheme has two app sections Getting this now |
The answer lies here ESP_ERR_INVALID_SIZE on this method is only returned, because of this Meaning the partitions file you confgured is invalid because it uses more flash memory than you actually have on the device. If possible you need to decrease the amount of flash the spiffs or the 2 ota app partitions get so it fits into 4MB |
This comment was marked as off-topic.
This comment was marked as off-topic.
What exact flash size do you have, because after having a look again at the partitions file it should fit into 4MB. So perhaps you have even less. Could you use this command |
The device I am using is ESP32-D0WD-V3 (revision v3.1) |
esptool.py v4.7.0 |
Perfect so the flash size is 4MB. I'm confused why it then says that this partition is to big for that. Are you really sure that you are flashing this partitions file. And what tooling are you using to upload the file ArduinoIDE or PlattformIO?
|
I am using Arduino IDE. All I am doing is making a .csv file named partitions.csv and copying it into the folder of the sketch and choose Custom from the Device partition scheme in Arduino IDE. Name, Type, SubType, Offset, SizeNote: if you have increased the bootloader size, make sure to update the offsets to avoid overlapnvs, data, nvs, , 0x4000 |
Perhaps you need to take additional steps and it doesn't actually upload the partitions file you expect. Here is a guide on how to make the ArduinoIDE use a custom partitions schema, perhaps you missed one of thoose steps. Besides that possible issue I'm also not sure what else it could be, the only thing I'm relatively sure of is that the code of this library is probably not wrong, because the |
What I just want to do is perform an OTA from the thingsboard localhost. Can you recommend the right direction for that? |
No clue, I normally use |
Can you also adjust the code as mentioned in this comment. |
i did but i get the same line |
What are you using the Arduino_ESP32_Updater or the Espressif_Updater? And if you are using the first option can you switch to the latter and then try again. |
// Whether the given script is using encryption or not, #include <SDCard_Updater.h> // Firmware title and version used to compare with remote version, to check if an update is needed. // Maximum amount of retries we attempt to download each firmware chunck over MQTT // Examples using arduino used PROGMEM to save constants into flash memory, // See https://thingsboard.io/docs/getting-started-guides/helloworld/ // Thingsboard we want to establish a connection too // MQTT port used to communicate with the server, 1883 is the default unencrypted MQTT port, // Maximum size packets will ever be sent or received by the underlying MQTT client, #if ENCRYPTED constexpr char FW_STATE_UPDATED[] = "UPDATED"; // Initalize the Mqtt client instance // Status for successfully connecting to the given WiFi struct binary_data_t { /// @brief Attempts to write all received data on the given file into flash memory,
} /// @brief Updated callback that will be called as soon as the firmware update finishes /// @brief Progress callback that will be called every time we downloaded a new chunk successfully /// @brief Callback method that is called if we got an ip address from the connected WiFi meaning we successfully established a connection /// @brief Initalizes WiFi connection, esp_netif_config_t netif_config = ESP_NETIF_DEFAULT_WIFI_STA(); ESP_ERROR_CHECK(esp_netif_attach_wifi_station(netif)); wifi_config_t wifi_config; ESP_LOGI("MAIN", "Connecting to %s...", wifi_config.sta.ssid); extern "C" void app_main() {
#if ENCRYPTED
} this is the code from TB and none of the two above is called |
Do you want to update to the SD card first, because that is what the example shows. If you don't you can create an instance of the void updatedCallback(const bool& success) {
if (success) {
ESP_LOGI("MAIN", "Done updated to flash");
esp_restart()
return;
}
ESP_LOGI("MAIN", "Downloading firmware failed");
} |
it work, but I'm confused because i tried your solution a while ago and didn't work hhh |
Why it works is pretty clear you tried to update to an sd card, which does not exist. So of course initialization of that sd card failed. Now you update to flash and it works like it should. |
Yeah thank you again. |
Simple instead of The first option immefiately starts the update if it is assigned but else does nothing and the latter does nothing until a new firnware is assigned and then instantly updates. The best option is to combine both so you always update the device if a new firmware is assigned. Even if it was assigned while the device was offline. |
Hey Mathew, my issue was resolved using Arduino_ESP32_updater.h and removing Espressif_updater.h Thanks in Advance |
And secondly, when I add my binary file to the Assigned version it doesnt catch the Shared Attributes, however when I use Firmware exampleV1.1 or V1.2 from the thingsboard library, it gets it into the shared attributes. What can I do to fix that? |
The So if you want your device to keep the ability to update you need to save your current
Are you calling If you only want to check if new firmware is assigned and you missed an update while the device was offline you can use |
I think I explained it the wrong way. |
I'm really confused how you assign an update to your device. I would advise you to use this Firmware Update Dashboard by thingsboard instead of deleting and changing shared attributes by hand. The dashboard itself is documented on the offical ThingsBoard Documentation |
Thankyou so much Mathew, my issue was resolved. |
I am using an ESP32 Dev Module
Tried this code on
Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x140000,
app1, app, ota_1, 0x150000,0x140000,
spiffs, data, spiffs, 0x290000,0x170000,
This is what I am getting with I update the firmware over thingsboard, I am using thingsboard configured locally on docker
[TB] Failed to initalize flash updater, ensure that the partition scheme has two app sections
The text was updated successfully, but these errors were encountered: