Internal Flash write status

Hi all,

Referring to the function InternalFlashStore::write() in dcd_flash_impl.h, inside the if statement of the if…else within the big while loop, we read:

            while ((FLASH_COMPLETE != (status = FLASH_ProgramWord(destination, *(const uint32_t*)data_ptr))) && (tries++ < max_tries));

The value of the status is never checked pass this point or used to set any other flags or error statuses should the max_tries be reached; if so I don’t see any point of checking it! Might as well just invoke FLASH_ProgramWord() and hope that it works. Any thoughts anyone? @mdma?

The DCD code should do better than “hope that it works” since it is persistent storage. It’s an area where I want to take a look and make a couple improvements.

Might as well just invoke FLASH_ProgramWord() and hope that it works.

If there are any intermittent errors, such as bus busy, then we should retry, because it may well succeed next time.

The final result of the function determines success/failure by comparing the contents of flash with what is expected, so we don’t need to explicitly track any errors as they occur, but instead check the final result as a whole.

Thank you @jvanier and @mdma for your replies.

I just thought since status seems to be declared and assigned, would naturally be used which does not seem to be the case. Thanks @mdma, yeah I can see the check on the last line.