summaryrefslogtreecommitdiff
path: root/src/flash/nor/cfi.c
Commit message (Collapse)AuthorAgeFilesLines
* cfi: use ARM32 machine code on all CPUs but Cortex M3Øyvind Harboe2011-01-311-6/+2
| | | | | | | | | | | ARM11 broke with aa61a3b3d8b6acad19050987835ec05f3d298bdb as the code only checked for arm 7/9. CFI probably needs work for non-ARM targets but perhaps not adding working area memory to e.g. MIPS will give the default slow CFI support. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* cfi: fix release build warningsSpencer Oliver2011-01-101-2/+2
| | | | Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* cfi: use safer arch detectionSpencer Oliver2011-01-061-2/+8
| | | | Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* Add the support for the armv7m arch.Jonathan Dumaresq2011-01-061-15/+64
| | | | Signed-off-by: Jonathan Dumaresq <jdumaresq@cimeq.qc.ca>
* cfi_protect is not implemented on Spansion flashes (many do not even have ↵Michael Schwingen2011-01-021-2/+2
| | | | | | protection bits). Demote from error to warning, so that common board code can use "flash write_image erase unlock" regardless of the flash type. Signed-off-by: Michael Schwingen <michael@schwingen.org>
* non-CFI flash code uses data from CFI structures. Make sure that timeouts ↵Michael Schwingen2011-01-021-95/+92
| | | | | | are filled in on non-CFI flashes, and print CFI information in all cases, nut just on CFI flashes. Signed-off-by: Michael Schwingen <michael@schwingen.org>
* contrib: add source to the cfi flash loadersSpencer Oliver2010-12-101-6/+13
| | | | Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* cfi: disable buffer writes for M29W128GSpencer Oliver2010-12-101-4/+15
| | | | | | | | | | For some reason buffer writes for the M29W128G do not work reliably, so disable them. See: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=504a3e72208fc6a65924426ff5693982590bccdc Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* cfi: allow optional buffer write supportSpencer Oliver2010-12-101-0/+9
| | | | | | | Some flash's do not support buffer writes, so we now check they are supported before trying to use them. Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* cfi: calculate correct timeoutsSpencer Oliver2010-12-101-16/+23
| | | | | | | | The existing code used incorrect timeout values for the various cfi operations. We now calculate the timeouts and convert to msecs if necessary. Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* cfi: prefix string hex outputSpencer Oliver2010-12-101-12/+12
| | | | | | Add hex prefix so we know output is not decimal. Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* cfi: add time format to cfi query outputSpencer Oliver2010-12-101-8/+11
| | | | Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* cfi: whitespace and long line cleanupSpencer Oliver2010-12-101-282/+389
| | | | Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* cfi: add sst39vf6401bFlemming Futtrup2010-09-151-0/+1
| | | | Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* cfi: tighten up type usage a bitØyvind Harboe2010-09-111-2/+3
| | | | | | | | | | sizeof() is a bit less scary than seing assumption about size of type, no bug as such. Use NULL instead of 0 for pointers. More obvious that it is a pointer from code inspection. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* Numonyx M29W160ET patchWookey2010-09-031-3/+4
| | | | | | | | | Someone called David Carne popped up on IRC and offered a fix (as he's not on this list so can;t post here). I am just passing it on. (thanx David) 10:54 < davidc__> Basically; the Numonyx M29W160ET has an incorrect CFI PRI block; it describes the erase blocks backwards 10:54 < davidc__> the linked patch has a fixup for that part [really trivial]:
* cfi: add LOG_ERROR() in case of unsupported intel erase algorithmØyvind Harboe2010-06-141-0/+3
| | | | | | | found by code inspection. There are many other places in CFI where LOG_ERROR() should be called similarly... Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: fix bug in error propagation of flash write_imageØyvind Harboe2010-06-141-4/+2
| | | | | | | | | | | 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>
* cfi: fix gaffe introduced in previous versionØyvind Harboe2010-06-141-2/+2
| | | | | | | | flash probe broke w/in last commit. ecc8041c0f4c30a7310c0f8414a5261ee7a090ca Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* cfi: fix error propagationØyvind Harboe2010-06-111-116/+339
| | | | | | | | | | any read/write operation to memory can fail. block write algorithm error propagation was broken in that it would continue after an error was reported writing data to ram or the algorithm failing. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* cfi: fix GDB keep alive bugØyvind Harboe2010-06-081-0/+2
| | | | | | Long running CFI writes could cause GDB timeout. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* NOR/CFI: fix memory leak; check malloc return valueAntonio Borneo2010-05-261-3/+48
| | | | | | | | | | | Every time command "flash probe #" is executed, memory structures are re-allocated without preventive free() of former areas, causing memory leak. Also, memory allocation does not check return value, determining segmentation fault in case of out of memory. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* NOR/CFI: minor code cleanupAntonio Borneo2010-05-161-8/+0
| | | | | | | Remove few LOG_DEBUG() messages, together with code and variables required to build such messages. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR/CFI: add cfi_read() implementationAntonio Borneo2010-05-161-2/+72
| | | | | | | | | | Final step to force bus_width size during CFI flash read. Added CFI specific implementation cfi_read() that uses only accesses at bus_width size. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR: add read() callback to struct flash_driverAntonio Borneo2010-05-161-0/+2
| | | | | | | | | | | | | | 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>
* NOR/CFI: remove use of cfi_add_byte()Antonio Borneo2010-05-161-40/+1
| | | | | | | Remove the function cfi_add_byte() and rewrite the only instance of it. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR/CFI: use bus_width for memory access in cfi_write()Antonio Borneo2010-05-161-54/+15
| | | | | | | | | | | | | | During cfi_write(), head and tail of destination area could be not aligned to bus_width. Since write operation must be at bus_width size, source buffer size is extended and buffer padded with current values read from flash. Force using bus_width to read current value from flash. Do not use cfi_add_byte() anymore, to allow removing this function later on. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR/CFI: use bus_width for memory access on flash ID.Antonio Borneo2010-05-161-25/+22
| | | | | | | | | | NOR flash structure requires each access to be bus_width wide. Fix read of flash ID accordingly to rule above. Add case (chip_width == 4), allowed by CFI spec and coherent with current value of CFI_MAX_CHIP_WIDTH but currently not used by any target. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR/CFI: identify memory accesses not using "bus_width".Antonio Borneo2010-05-161-0/+8
| | | | | | | | | | | | | | | | | | | | Since NOR flash devices does not handle "byte enable lanes", each read/write access involves the whole "chip_width". When multiple devices are in parallel, usually all chips are enabled during each access. All such cases are compatible with flash accesses at "bus_width" size. Access at "bus_width" size is mandatory for write access to avoid transferring of garbage values to flash. During read access the flash controller should take care, and discard unneeded bytes. Anyway, it is good practice to use "bus_width" size also for read. Every memory access that does not respect "bus_width" size is marked with a "FIXME" comment. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR/CFI: simplify bufferwsize computationAntonio Borneo2010-05-161-39/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Review and simplify computation of bufferwsize. Add comments about variables' meaning. The same code is present 3 times in the file. Current patch updates all the 3 instances. Step 1) Replace "switch(bank->chip_width) {...}". Illegal values of bank->chip_width are already dropped. For legal values, the code is equivalent to: bufferwsize = buffersize / bank->chip_width; Step 2) The above code replacement plus the following line: bufferwsize /= (bank->bus_width / bank->chip_width); is merged in a single formula: bufferwsize = (buffersize / bank->chip_width) / (bank->bus_width / bank->chip_width); and simplified as: bufferwsize = buffersize / bank->bus_width; Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR/CFI: check "flash bank" command argumentsAntonio Borneo2010-05-161-1/+11
| | | | | | | | | | | | | | | | | | Arguments chip_width and bus_width of command "flash bank" are not fully checked. While bus_width is later on redundantly checked in several other parts (e.g. in cfi_command_val()) and generates run-time error, chip_width is never checked, nor related to actual bus_width value. Added check to avoid: - (chip_width == 0), that would mean no memory chip at all, avoiding also division by zero e.g. in cfi_get_u8(); - (bus_width == 0), that would mean no bus at all; - unsupported cases of chip_width or bus_width value not power of 2; - unsupported case of chip width wider than bus. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* Fujitsu MBM29SL800TE flash supportKarl Kurbjun2010-05-111-0/+1
| | | | | | | | | | | | | | | | | Hi, This is my first post to the list. First, I would like to thank everyone for their work on OpenOCD, it is a great tool to work with. I have been using it to debug code on hardware for the Rockbox project (www.rockbox.org). The target that I primarily work with has a Spansion/Fujitsu NOR flash (MBM29SL800TE). I attached a patch that adds support for this flash. I hope it can be included in the main repository. If there is something that needs to be changed with the patch before inclusion please let me know. -Karl Kurbjun
* cfi: add Numonyx M29W128G reset workaroundSpencer Oliver2010-05-101-32/+35
| | | | | | | | The ST/Numonix M29W128G has an issue when a 0xff cmd is sent, it cause an internal undefined state. The workaround according to the Numonyx is to send another 0xf0 reset cmd Signed-off-by: Spencer Oliver <ntfreak@users.sourceforge.net>
* flash: stop caching protection stateØyvind Harboe2010-05-051-0/+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>
* cfi: fix error handling for protect fnØyvind Harboe2010-05-051-4/+4
| | | | | | No error was propagated. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* flash: less bogus errorsØyvind Harboe2010-05-041-2/+2
| | | | | | | Removed bogus errors when trying to allocate a large a target memory buffer as possible. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* cfi: made som info output debug outputØyvind Harboe2010-05-041-2/+2
| | | | | | | E.g. how much target memory that is used during flashing is debug info. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* NOR/CFI: remove redundant codeAntonio Borneo2010-04-151-6/+2
| | | | | | | | Arguments for "flash bank" command are already parsed and put in "bank" struct. Removed code to parse them again. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR/CFI: fix order of arguments checkAntonio Borneo2010-04-151-2/+2
| | | | | | | | | | | | Syntax of "flash bank" command requires: - chip_width as CMD_ARGV[3] - bus_width as CMD_ARGV[4] Actual code swaps the arguments. Bug has no run time impact since wrong variables are only used to check value and both are checked against same constraint. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* NOR/CFI: review scope of functionsAntonio Borneo2010-04-101-3/+3
| | | | | | Add "static" qualifier to private functions. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
* cfi: simplify and clearify codeAntonio Borneo2010-03-081-149/+75
| | | | | | | | | | | | | | | | At the end I have added comments /* FIXME: to be removed */ There are 3 lines in which my simplification is not complete due to data dependency with LOG_DEBUG() messages visible in the patch. Such log_debug has been introduced on Jan 22, 2007 with commit 4fc97d3f2726efa147cfdb0c456eace51550e1e3 during development activity in this file/procedure. From my point of view, these logs can be removed, since not part of a consistent flow of information. Alternatively, could be borrowed in the new cfi_send_command(), but this will increase verbosity. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* CFI: review print of Voltage valuesAntonio Borneo2010-03-061-6/+6
| | | | | | | | | | | | JEDEC standard reports Vpp integer part encoded as 4 bit HEX value. To print it using decimal digits, %u is required. Other voltage values are coded as BCD, so %x is appropriate. Code already prints one nibble at a time, so no need for field width and precision in format string. Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
* NOR: cleanup driver declsDavid Brownell2010-01-291-11/+11
| | | | | | Fix goofy struct indents. Function names *are* their addresses. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* ARM: use <target/arm.h> not armv4_5.hDavid Brownell2009-12-071-1/+1
| | | | | | | | | | | | | | Move most declarations in <target/armv4_5.h> to <target/arm.h> and update users. What's left in the older file is stuff that I think should be removed ... the old register cache access stuff, which makes it awkward to support microcontroller profile (Cortex-M) cores. The armv4_5_run_algorithm() declaration was moved too, even though it's not yet as generic as it probably ought to be. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* ARM: rename armv4_5_algorithm as arm_algorithmDavid Brownell2009-12-041-2/+2
| | | | Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* ARM: ARMV4_5_COMMON_MAGIC --> ARM_COMMON_MAGICDavid Brownell2009-12-041-2/+2
| | | | Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* ARM: rename ARMV4_5_MODE_* as ARM_MODE_*David Brownell2009-12-041-2/+2
| | | | Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* ARM: rename ARMV4_5_STATE_* as ARM_STATE_*David Brownell2009-12-041-2/+2
| | | | Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
* remove target.h from flash.hZachary T Welch2009-12-041-0/+1
| | | | | The flash.h header does not require the target.h header file, but its implementation source files do. Move it to flash/nor/imp.h.
* change #include "armv4_5.h" to <target/armv4_5.h>Zachary T Welch2009-12-031-1/+1
| | | | | | | | | | | | Changes from the flat namespace to heirarchical one. Instead of writing: #include "armv4_5.h" the following form should be used. #include <target/armv4_5.h> The exception is from .c files in the same directory.