Description
i_update( s_newApp )
configures the bootloader to flash a new application from SerialFlash into the processors program memory at the next system start. i_update( s_fallbackApp, s_newApp )
configures the bootloader to flash the new application (s_newApp) from SerialFlash into the processors program memory at the next system start. It also prepares the bootloader to flash “s_fallbackApp” if the first process will not be confirmed by s_newApp calling i_update_confirm()
.i_update_recover( s_newApp )
acts like i_update(). It creates an image file of the current processor prog. memory (the currently running application). It then configures the bootloader to fall back to this “recover.bin” image in case the new application does not confirm the successful update process.
Syntax
i_update( s_newApp );
i_update( s_fallbackApp, s_newApp );
i_update_recover( s_newApp );
Parameters
String s_newApp – String of the file name of the new application in SerialFlash. The file name has to end with “.bin”
String s_fallbackApp – String of the file name of the fall back application in SerialFlash. The file name has to end with “.bin”
Returns
int: 1 : OK
0: Error – because
– “s_newApp” or “s_fallbackApp” file name does not end with “.bin”
– “s_newApp” or “s_fallbackApp” file does not exist or has size 0
– “s_newApp” or “s_fallbackApp” are not compiled for this hardware variant
for i_update_recover():
– “recover.bin” could not be created
Example Code
#include "Update.h"
void setup()
{
SerialFlash.begin();
while(!Serial);
Serial.print("This is the application:");
Serial.println(BOOTLOADER_SETTING.s_get_app_name());
Serial.print("Version:");
Serial.println(" V" + String(BOOTLOADER_SETTING.u32_get_app_version()));
Serial.println("Prepare update to app: Blink.ino.bin");
if(!i_update_recover("Blink.ino.bin"))
{
Serial.println("Error. Make sure the update file exists and is compiled for the right HW variant");
while(1){ yield(); };
}
Serial.println("OK! Update prepared and recovery image created");
Serial.println("Now manually restart the system");
}
void loop()
{}
Notes and Warnings
Make sure that the new application is compiled for the right target hardware variant and of type .bin (binary application file). A binary can be created and exported with the help of the Arduino IDE (see menu):
– Sketch -> Export compiled Binary
– Sketch -> Show Sketch folder
The function i_update_recover() creates / replaces the binary file called “recover.bin” in the SerialFlash file system.
FYI: i_update_recover() basically uses i_update_create_image() to create “recover.bin” and then calls i_update( “recover.bin”, “newApp.bin” );
See also
i_update_confirm()
b_update_is_bootloader_command_pending()
i_update_create_image()
SerialFlash