Skip to content

Commit

Permalink
Adding note for flash write failures
Browse files Browse the repository at this point in the history
- Not all families of EefcFlash support EEFC_FCMD_EWP on all regions of
  flash
- This warning should save a lot of time during debugging
- Helps with Issue shumatech#130
  • Loading branch information
haata committed May 3, 2020
1 parent 0ceec9f commit 599fae1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/EefcFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,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

0 comments on commit 599fae1

Please sign in to comment.