Skip to content
  • Tomas Vanek's avatar
    flash: at91samd: flash write code cleaning · 26a65f4f
    Tomas Vanek authored
    
    
    SAMD driver suffered from following problems:
    
    1) Flash was erased as an integral part of flash write.
    It was not documented so with usual workflow it resulted
    in erasing flash twice (and reducing flash lifespan)
    and in almost double flashing time.
    
    2) Sector erase was silently skipped if "is_erased" flag was set.
    "is_erased" logic was not reliable, e.g. when a row write
    was aborted after successful write of some pages, sector was
    still considered as erased. "is_erased" flag could not
    cope with flash writes from a user program.
    
    3) Writing of a block with start address unaligned to a flash page
    resulted in failed assert and OpenOCD abort.
    
    4) Disabling cache in bit 18 of 16-bit halfword never worked.
    MCU implements cache invalidate in hardware so there is no need
    to take care about. This bug was reported by Tony DiCola.
    
    New code does not erase flash in write operation.
    Instead it traditionally relies on erasing flash beforehand.
    "is_erased" logic and cache disabling is completely removed.
    It simplifies write procedure a lot and flash write is now faster.
    
    The change partly solves ticket #109 SAMD/SAM4L driver doubles flash erase.
    
    Change-Id: I582b497d01a351575533a1f8c9810a4413be0216
    Signed-off-by: default avatarTomas Vanek <vanekt@fbl.cz>
    Reviewed-on: http://openocd.zylin.com/3045
    
    
    Tested-by: jenkins
    Reviewed-by: default avatarSpencer Oliver <spen@spen-soft.co.uk>
    26a65f4f