Page 1 of 1

SPI Erase Sector OTA

Posted: Tue Jul 10, 2018 1:01 am
by AgentSmithers
Hi everyone,
Does anyone know what SPI Erase sector actually do to the SPI rom. It seems if I overwrite the sector's with my OTA firmware it does not work unless I call to erase it first. Shouldn't overwriting the data with other data have the same effect or does Erase set some sort of flag behind the scene's allowing for the firmware to work when calling the reboot swap? I even call it on the last sector as I'm writing the last part of the rom and still no dice. I have to erase then write from start to end to have my OTA work. Any background?

Re: SPI Erase Sector OTA

Posted: Tue Jul 10, 2018 5:36 pm
by blubb
That is for technical reasons. In flash memory only zeros can be written as single bits.
https://en.wikipedia.org/wiki/Flash_mem ... ck_erasure

Re: SPI Erase Sector OTA

Posted: Wed Jul 11, 2018 4:05 am
by AgentSmithers
blubb wrote:That is for technical reasons. In flash memory only zeros can be written as single bits.
https://en.wikipedia.org/wiki/Flash_mem ... ck_erasure


Thank you for your input, I am not sure if that is the answer to my question.

AS I am looping through the total amount of firmware data, Why is erase even required when all the data underneath is going to be overwritten anyways.

Now for the last sector of 4096 bytes, I understand because the firmware may not cover the whole sector and there could be trailing data from the previous firmware version left in that sector, however for the sector's before that still makes no sense to me unless erase set's some flag for the sector in the background that FOTA read's on reboot before trying to load it.

Re: SPI Erase Sector OTA

Posted: Wed Jul 11, 2018 5:12 pm
by blubb
You can only write zeros (0) into a flash memory. If you need to put a one (1) into a bit that was zero before, you have to erase the whole block and after that zero out the bits that need to be zero. Erasing is a totally different from writing. That is the short summary of how all flash memories work (low level). On e.g. usb key drives the only difference is that you have a controller which does all that for you (and also distributes new writes across all the flash space, so that it wears evenly).

Re: SPI Erase Sector OTA

Posted: Sat Jul 14, 2018 1:37 am
by AgentSmithers
blubb wrote:You can only write zeros (0) into a flash memory. If you need to put a one (1) into a bit that was zero before, you have to erase the whole block and after that zero out the bits that need to be zero. Erasing is a totally different from writing. That is the short summary of how all flash memories work (low level). On e.g. usb key drives the only difference is that you have a controller which does all that for you (and also distributes new writes across all the flash space, so that it wears evenly).


Interesting, Got any YouTube videos that talk about this topic? I am used to conventional harddrives but I would like to dive deeper into the subject if you have any links?

Thanks!