SPI Erase Sector OTA

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

SPI Erase Sector OTA

Postby AgentSmithers » Tue Jul 10, 2018 1:01 am

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?

blubb
Posts: 116
Joined: Mon Jun 22, 2015 5:35 am

Re: SPI Erase Sector OTA

Postby blubb » Tue Jul 10, 2018 5:36 pm

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

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: SPI Erase Sector OTA

Postby AgentSmithers » Wed Jul 11, 2018 4:05 am

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.

blubb
Posts: 116
Joined: Mon Jun 22, 2015 5:35 am

Re: SPI Erase Sector OTA

Postby blubb » Wed Jul 11, 2018 5:12 pm

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).

AgentSmithers
Posts: 195
Joined: Sat Apr 01, 2017 1:21 am
Contact:

Re: SPI Erase Sector OTA

Postby AgentSmithers » Sat Jul 14, 2018 1:37 am

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!

Who is online

Users browsing this forum: No registered users and 131 guests