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

Improved FLASH_Update() method - make OTA Update more reliable #19

Merged
merged 2 commits into from
Apr 13, 2014

Conversation

satishgn
Copy link
Contributor

Use with latest core-communication-lib(branch: bug-fixes) and core-firmware(branch: bug-fixes)
In FLASH_Update(), the written data buffer is read back and the verified result flag is now returned.

@towynlin
Copy link
Contributor

Thanks Satish. This is a good step forward, however, if the read data does not match the written data, we won't be able to simply attempt the write again. Instead we have to erase the sector. So:

  • calculate the size of the previously written data in the current sector: External_Flash_Address minus the sector start address
  • read the data from the beginning of the sector up to External_Flash_Address
  • erase the current sector
  • write (and check, possibly erasing and writing again, try up to 3 times, return false on 3rd failure) the data from the beginning of the sector up to External_Flash_Address
  • start over: write the current buffer of data, if it matches great, if not, erase again

This whole process should only be attempted 3 times. If the 3rd attempt fails, then return false.

Once those semantics are in place, then on a false return value, the communication library should actually declare that the update has failed rather than requesting the chunk again.

@satishgn
Copy link
Contributor Author

Good Catch @towynlin, just forgot that it's the sFlash thing we are dealing with :)
Now with the method you suggested, the minimum erase page size is 4KB so it would be difficult to allocate 4096 bytes in RAM's heap or stack just to copy the existing data in sFlash before erasing.
So what I'm trying to do now is update the chunk_index within Flash_Update() call after erasing the desired sector and return this index in place of the current bool and in core-communication-lib, use chunk_missed to request the previous chunks. Also it'll be better if the server decides based on the number of successive chunk_index whether to abort the OTA process so as to make it flexible.
Also if it fails 3 times, it is highly likely the sFlash sectors will fail during future OTA updates.
I will ping you after I push the commits so that you can review the process.

@towynlin
Copy link
Contributor

Well done! Achieves the same goal very cleanly with no additional memory usage! Outstanding!

towynlin pushed a commit that referenced this pull request Apr 13, 2014
Improved FLASH_Update() method - make OTA Update more reliable
@towynlin towynlin merged commit a5eade6 into master Apr 13, 2014
@towynlin towynlin deleted the bug-fixes branch April 13, 2014 04:53
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

Successfully merging this pull request may close these issues.

2 participants