summaryrefslogtreecommitdiff
path: root/src/flash/nor/core.c
Commit message (Collapse)AuthorAgeFilesLines
* flash: iterating over an address range now handles multiple banksØyvind Harboe2010-11-221-1/+38
| | | | | | | e.g. flash erase_address now works across an address range that spans multiple flash chips. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: fix bug with multiple back-to-back flash chipsØyvind Harboe2010-11-171-3/+7
| | | | | | | | | | | flash programming via flash write_image or gdb load would produce a bogus error message that the flash chip was to small. The solution is to limit the current flash programming run to the current chip. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: fix error handlingØyvind Harboe2010-09-271-2/+11
| | | | | | memory leaks and missing check on memory allocation. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* image: fix spelling mistakeØyvind Harboe2010-09-271-6/+6
| | | | | | struct imageection => struct imagesection Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: fix bug in error propagation of flash write_imageØyvind Harboe2010-06-141-1/+0
| | | | | | | | | | | when a write/unlock/erase failed during write_image, then an error was not propagated back up so e.g. flash write image from tcl scripts would not throw an exception. Also flash filling speed was printed even when the operation failed. Output is now less confusing. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: add error handling to get_flash_by_addr/nameØyvind Harboe2010-06-111-12/+27
| | | | | | | autoprobing can fail and this error has to be reported up the call stack. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: add error message if image is too big for flashØyvind Harboe2010-06-091-1/+5
| | | | | | | replaced assert() w/error message if the image is too big. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* nor: add get_flash_bank_by_name autoprobeSpencer Oliver2010-05-261-2/+22
| | | | | | | | | | | When a flash cmd is called using the flash name the autoprobe function is not called. autoprobe is called if flash_command_get_bank falls through to get_flash_bank_by_num. This makes both get_flash_bank_by_name and get_flash_bank_by_num behave the same. Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* NOR: add read() callback to struct flash_driverAntonio Borneo2010-05-161-0/+24
| | | | | | | | | | | | | | Final target is to force bus_width size during CFI flash read. In this first step I need to replace default flash read with flash specific implementation. This patch introduces: - flash_driver_read() layer; - default_flash_read(), backward compatible; - read() callback in struct flash_driver; - proper initialization in every flash_driver instance. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* flash: stop caching protection stateØyvind Harboe2010-05-051-89/+11
| | | | | | | | | | | | | | There are a million reasons why cached protection state might be stale: power cycling of target, reset, code executing on the target, etc. The "flash protect_check" command is now gone. This is *always* executed when running a "flash info". As a bonus for more a more robust approach, lots of code could be deleted. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: erase_address now has an unlock optionØyvind Harboe2010-05-051-1/+1
| | | | | | | Quite useful to be able to unlock the flash, just like in the flash write_image cmd. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* gdb: connect will now fail if flash autoprobe failsØyvind Harboe2010-05-051-4/+7
| | | | | | | | | | | | This stops GDB from launching with an empty memory map, making gdb load w/flashing fail for no obvious reason. The error message points in the direction of the gdb-attach event that can be set up to issue a halt or "reset init" which will put GDB in a well defined stated upon attach and thus have a robust flash autoprobe. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: more flash write_image bugfixesØyvind Harboe2010-05-051-21/+11
| | | | | | | | | Remove/fix lots of bugs in handling of non-contigious sections and out of order sections. Fix a gaffe introduced in previous commit to src/flash/nor/core.c Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: write_image would fail for certain imagesØyvind Harboe2010-04-291-14/+55
| | | | | | | | | | | Fix a bug where write_image would fail if the sections in the image were not in ascending order. This has previously been fixed in gdb load. Solved by sorting the image sections before running flash write_image erase unlock foo.elf. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: write_image will now pad erase to nearest sectorØyvind Harboe2010-04-291-8/+2
| | | | | | | | | | this is done for unlocking and it is a simple omission that it wasn't done for sectors. The unnerving thing is that nobody has complained about this until now.... Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* nor: remove bogus output about padding sectionsØyvind Harboe2010-04-281-1/+2
| | | | | | | padding of 0 bytes is actually no padding, do not output warning about padding in that case. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* NOR/core bugfix: restore invariantsDavid Brownell2010-04-151-5/+16
| | | | | | | | | | | | | | | | The The patch labeled "CFI CORE: bug-fix protect single sector" was merged rged without some requested bugfixes. Most significantly it broke invariants in the code, invalidating descriptions and changing the calling convention for underlying drivers. (It (Also wasn't CFI-specific...) Fix that, and Include an update from Antonio Borneo for the degenerate "nothing to do" case, (although that's still in the wrong location. which is presumably why that is it was working in some cases but not all.) src/flash/nor/core.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* NOR/CORE: review scope of dataAntonio Borneo2010-04-101-1/+1
| | | | | | Add "static" qualifier to private data. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* 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.