Skip to content
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

update with encrypted file #77

Open
AlirezaAbdiyan opened this issue Nov 1, 2024 · 2 comments
Open

update with encrypted file #77

AlirezaAbdiyan opened this issue Nov 1, 2024 · 2 comments

Comments

@AlirezaAbdiyan
Copy link

AlirezaAbdiyan commented Nov 1, 2024

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.

@tobozo
Copy link
Owner

tobozo commented Nov 1, 2024

hi,

thanks for your feedback 👍

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();

@AlirezaAbdiyan
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants