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

Adding note for flash write failures #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/EefcFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,23 @@ EefcFlash::writePage(uint32_t page)
_wordCopy.setDstAddr(_addr + page * _size);
_wordCopy.setSrcAddr(_onBufferA ? _pageBufferA : _pageBufferB);
_onBufferA = !_onBufferA;
waitFSR();
// Some chip families have page restrictions on calling EEFC_FCMD_EWP on all pages
// e.g. 16K boundary on SAM4S
// Print a warning indicating that the flash must be erased first
try
{
waitFSR();
}
catch (FlashCmdError& exc)
{
if (page > 0)
{
printf("\nNOTE: Some chip families may not support auto-erase on all flash regions.\n");
printf(" Try erasing the flash first (bossash), or erasing at the same time (bossac).");
fflush(stdout);
}
throw;
}
_wordCopy.runv();
if (_planes == 2 && page >= _pages / 2)
writeFCR1(_eraseAuto ? EEFC_FCMD_EWP : EEFC_FCMD_WP, page - _pages / 2);
Expand Down