summaryrefslogtreecommitdiff
path: root/src/flash/nor/core.c
Commit message (Collapse)AuthorAgeFilesLines
* CFI CORE: bug-fix protect single sectorAntonio Borneo2010-03-091-2/+2
| | | | | | | | Cannot protect or unprotect single sector in cfi flash. When first==last the procedure fails. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* NOR: trim range in flash_driver_protect()David Brownell2010-03-031-0/+57
| | | | | | | | | | | | | | | | | | | | | | When the beginning or end of the specified range of sectors already has the requested protection status, don't ask the flash driver to change those sectors. This will among other things turn command sequences like this into the NOPs one would expect: flash protect_check 0 flash info 0 ... reports everything as unprotected ... flash protect 0 0 1 off That speeds things up (by whatever work was just avoided). Also, with Stellaris (which can't unprotect flash at page level) this can eliminate some undesirable/false error reports. (And finishes fixing a bug currently listed in our bug database...) Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* NOR: invalidate cached state on target resumeDavid Brownell2010-03-031-0/+31
| | | | | | | | | | | | | | | | | | | | The NOR infrastructure caches some per-sector state, but it's not used much ... because the cache is not trustworthy. This patch addresses one part of that problem, by ensuring that state cached by NOR drivers gets invalidated once we resume the target -- since targets may then modify sectors. Now if we see sector protection or erase status marked as anything other than "unknown", we should be able to rely on that as being accurate. (That is ... if we assume the drivers initialize and update this state correctly.) Another part of that problem is that the cached state isn't much used (being unreliable, it would have been unsafe). Those issues can be addressed in later patches. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* NOR: fix diagnosticDavid Brownell2010-01-191-1/+1
| | | | | | | The "NOR: last_addr also needs correction when checking alignment" patch omitted a necessary update to the key diagnostic; fix. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* flash: add error messages upon incorrect arguments to flash iterationØyvind Harboe2010-01-191-0/+6
| | | | | | | | According to OpenOCD error handling rules the error is logged at where it occurs(same site where an exception would have been thrown). Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* NOR: add optional "flash erase_address" sector paddingDavid Brownell2010-01-131-14/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a NOR flash mechanism where erase_address ranges can be padded out to sector boundaries, triggering a diagnostic: > flash erase_address 0x0001f980 16 address range 0x0001f980 .. 0x0001f98f is not sector-aligned Command handler execution failed in procedure 'flash' called at file "command.c", line 647 called at file "command.c", line 361 > > flash erase_address pad 0x0001f980 16 Adding extra erase range, 0x0001f800 to 0x0001f97f Adding extra erase range, 0x0001f990 to 0x0001fbff erased address 0x0001f980 (length 16) in 0.095975s (0.163 kb/s) > This addresses what would otherwise be something of a functional regression. An earlier version of the interface had a dangerous problem: it would silently erase data outside the range it was told to erase. Fixing that bug turned up some folk who relied on that unsafe behavior. (The classic problem with interface bugs!) Now they can get that behavior again. If they really need it, just specify "pad". Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* Doxygen file commentsDavid Brownell2010-01-111-0/+7
| | | | | | | Add file comments to a few files. Make the GDB server use more conventional (pointer-free) hex digit conversion. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* NOR: add FIXMEs for writing onesDavid Brownell2010-01-081-2/+5
| | | | | | | | It can invalidate ECC codes, and in general is not guaranteed to work. (However on some chips it _appears_ to behave.) Just don't do it; don't write in those cases. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* NOR: last_addr also needs correction when checking alignmentPiotr Esden-Tempski2009-12-281-0/+1
| | | | | | | Otherwise the new alignment checking algorithm thinks that the address is not aligned, because it is way beyond the last sector. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* NOR: make flash_write_unlock() pad to sector endDavid Brownell2009-12-271-2/+42
| | | | | | | | | | | | | | Resolve a regression when using newish automagic "write_image" modes, by always padding to the end of affected sectors. Also document some issues associated with those automagic options, in the User's Guide and also some related code comments. We might need similar padding at the *beginning* of some sectors, but this is a minimalist fix for the problems which have currently been reported (plus doc updates). Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* NOR: Allocate the right amount of memoryDavid Brownell2009-12-261-1/+1
| | | | Switch to calloc() to simplify review and initialization.
* cygwin build fixesDavid Brownell2009-12-191-4/+6
| | | | | | and shrink some too-long lines Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* NOR FLASH: only erase/unlock whole sectorsDavid Brownell2009-12-181-8/+36
| | | | | | | | | | | | | | | Much to my surprise, I observed a "flash erase_address ..." command erasing data which I said should not be erased. The issue turns out to be generic NOR flash code which was silently, and rather dangerously, morphing partial-sector references into unrequested whole-sector ones. This patch removes that low-level morphing. If desired, it can and should be done in higher level code. (We might need to fix some stuff in the GDB server code.) Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* eliminate src/flash/flash.cZachary T Welch2009-12-041-4/+187
| | | | | Move remaining NOR flash implemenation into flash/nor/core.c Removes flash.c from the build, leaving only its header to split.
* add flash/nor/drivers.cZachary T Welch2009-12-041-11/+0
| | | | | Encapsulates access to the flash_drivers array, providing a base of operations for future dynamic driver module loading features.
* move more nor flash implementation detailsZachary T Welch2009-12-041-0/+276
| | | | | | | | Splits the exec mode commands out of flash.c into the flash/nor/ files. The routines used by these high-level commands are moved into nor/core.c, with their internal declarations placed in nor/imp.h. Fixes distribution of <flash/nor/core.h> header.
* add flash/nor/core.[ch]Zachary T Welch2009-12-041-0/+65
The newly moved flash TCL routines access the internals of the module too much. Fix the layering issues by adding new core NOR flash APIs: <flash/nor/core.h>: - flash_driver_find_by_name() - self-descriptive <flash/nor/imp.h>: - flash_bank_add() - encapsulates adding banks to bank list - flash_bank_list() - encapsulates retreiving bank list This allows the externs in flash/nor/imp.h to be removed, and these mechanisms may now be re-used by other flash module code.