ESP32-targz
ESP32-targz copied to clipboard
update with encrypted file
Hi, When eFuse is enabled, the update from memory does not proceed, and there are no error messages either. I used the espsecure.py tool to encrypt my program with a specific key, then stored it along with the SPIFFS as a tar.gz file on the memory. However, the update does not complete successfully. Could you please guide me on what steps I should take to resolve this?
TarGzUnpacker *TARGZUnpacker = new TarGzUnpacker();
TARGZUnpacker->haltOnError( false );
TARGZUnpacker->setTarVerify( false );
TARGZUnpacker->setGzProgressCallback( BaseUnpacker::targzNullProgressCallback );
TARGZUnpacker->setTarProgressCallback(progressCallback);
TARGZUnpacker->setTarStatusProgressCallback(TarStatusProgressCallback);
TARGZUnpacker->setTarMessageCallback( BaseUnpacker::targzPrintLoggerCallback);
if(!TARGZUnpacker->tarGzStreamUpdater( streamptr ))
{
___DEBUG_MSG___("tarGzStreamUpdater failed with return code ");
___DEBUG_MSGLN___(TARGZUnpacker->tarGzGetError());
retVal = false;
}
Regards.
hi,
thanks for your feedback :+1:
you may want to try GzUpdateClass, this class overloads espressif's UpdateClass which should give you more controls on the Update process.
to my knowledge that scenario has only been been tested with esp32FOTA library
here's some pseudo code on how to use it:
// get the Update singleton
auto update = GzUpdateClass::getInstance();
// use inherited UpdateClass methods
update.setCryptMode(....);
update.setCryptKey(....);
update.onProgress( myProgressFunction );
// begin update process
if( !update.begingz(UPDATE_SIZE_UNKNOWN, U_FLASH) )
{
// GzUpdateClass or UpdateClass error occured
update.abortz(); // from GzUpdateClass
return;
}
size_t bytes_written = update.writeGzStream(stream); // from GzUpdateClass
// todo: compare bytes_written with binary size, results may differ (can be aligned to 4096)
if( !update.endz() ) // from GzUpdateClass
{
// gzip error occured
return;
}
if( !update.isFinished() ) // from UpdateClass
{
// UpdateClass error occured
return;
}
ESP.restart();
Thank you for your help. My program code is encrypted but SPIFFS is not! Therefore, I want to extract the tar.gz file from its compressed state onto the SD card first, and then update the files individually. You wrote a function for this, but it seems it cannot extract directly onto the SD card. Could you please guide me on how to use it?
Regards.