Commit Graph

673 Commits

Author SHA1 Message Date
David Brownell
73566405b6 NOR: add optional "flash erase_address" sector padding
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>
2010-01-13 23:33:25 -08:00
David Brownell
8c730aaee2 Doxygen file comments
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>
2010-01-11 00:16:57 -08:00
David Brownell
1c5c57ec8e src/flash/nor: usage/help/doc updates
Make "usage" messages use the same EBNF as the User's Guide;
no angle brackets.  Improve and correct various helptexts.

Don't use "&function"; a function's name is its address.
Remove a couple instances of pointless whitespace; shrink a
few overlong lines; fix some bad indents.

Add TODO list entry re full support for NAND/NOR bank names.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-09 10:25:03 -08:00
David Brownell
2a76c1bcf9 NAND: help/usage/doc updates
Usage messages should use the same EBNF as the User's Guide;
no angle brackets.  Be more complete too ... some params were
missing.  Improve and correct various helptexts.

Make user's guide refer to the NAND "driver" name, not the
controller name; that's a bit more precise.

Don't use "&function"; its name is its address.  Line up struct
initializers properly.  Remove some blank lines.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-08 23:18:46 -08:00
David Brownell
1a2c258ed4 MFLASH: help/usage updates
Make "usage" messages use the same EBNF as the User's Guide;
no angle brackets.  Improve and correct various helptexts.

Don't use "&function"; a function's name is its address.
Remove a couple instances of pointless whitespace.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-08 20:12:18 -08:00
David Brownell
296a011db5 NOR: add FIXMEs for writing ones
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>
2010-01-08 16:47:58 -08:00
David Brownell
b3bf1d12b2 streamline and document helptext mode displays
Most commands are usable only at runtime; so don't bother saying
that, it's noise.  Moreover, tokens like EXEC are cryptic.  Be
more clear: highlight only the commands which may (also) be used
during the config stage, thus matching the docs more closely.
There are

 - Configuration commands (per documentation)
 - And also some commands that valid at *any* time.

Update the docs to note that "help" now shows this mode info.

This also highlighted a few mistakes in command configuration,
mostly commands listed as "valid at any time" which shouldn't
have been.  This just fixes ones I noted when sanity testing.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2010-01-02 15:52:35 -08:00
Freddie Chopin
6b1eeb92fe MinGW build fixes
Print "ssize_t" as "%ld" (+ cast to long) not as "%zu".
Official MinGW (gcc 3.4.5) doesn't understand "z" flag.

Signed-off-by: Freddie Chopin <freddie_chopin@op.pl>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-28 13:09:31 -08:00
Freddie Chopin
37cc6c495f stm32x commands get "usage"
Add .usage fields to stm32x command_registration,
so that "help stm32x" shows required parameters.

Signed-off-by: Freddie Chopin <freddie_chopin@op.pl>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-28 13:05:50 -08:00
Piotr Esden-Tempski
cba1813d5c NOR: last_addr also needs correction when checking alignment
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>
2009-12-28 12:31:47 -08:00
David Brownell
155a6a2c0b NOR: make flash_write_unlock() pad to sector end
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>
2009-12-27 11:34:31 -08:00
David Brownell
df58812b52 NOR: messaging fix
Fix syntax error:  default to "wrote N bytes"; writing a
single byte is an unusual case, not the normal one.
2009-12-26 10:24:39 -08:00
David Brownell
396b0f3012 NOR: Allocate the right amount of memory
Switch to calloc() to simplify review and initialization.
2009-12-26 10:22:28 -08:00
David Brownell
08a890e4aa cygwin 1.7 build fixes
It's less accepting of signed char ... insisting that e.g. tolower()
not receive one as a parameter.

It's probably good to phase out such usage, given the number of bugs
that lurk in the vicinity (assumptions that char is unsigned), so fix
these even though such usage is actually legal.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-26 10:19:19 -08:00
David Brownell
07c06ec5e2 Packaging fix, NEWS update
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-21 12:50:17 -08:00
David Brownell
b72bfabf0d cygwin build fixes
and shrink some too-long lines

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-19 15:43:55 -08:00
Dean Glazeski
3ac2a44041 AT91SAM9 NAND flash driver.
This creates the TCL interface for configuring an AT91SAM9 NAND flash
controller and implements the necessary functions to correctly work with
a NAND flash device connected to the chip.  This includes updates to the
driver list and the Makefile.am to support building the driver and also
houses the documentation update in openocd.texi.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-19 13:26:33 -08:00
David Brownell
3f18900b19 NOR FLASH: only erase/unlock whole sectors
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>
2009-12-18 10:16:52 -08:00
David Brownell
013b05f7f8 Subject: flash fill[bwh] should use bulk i/o
It's currently allocating a big buffer but writing it out in
units of sizeof(host's pointer) ... sub-optimal.

Plus fix a couple minor coding style goofs.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-18 10:09:35 -08:00
David Brownell
7641934197 stellaris: fix min buffer length checks
Word count == size/4; cope.  And increase buf_min so it's large
enough to cover the overhead in my tests.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-18 09:59:40 -08:00
David Brownell
e40f638063 stellaris: update bulk flash writes
Try to right-size the SRAM buffers, by not:
 - using them for very small writes
 - giving up when a large buffer isn't available
 - allocating buffers much larger than their data

Also don't:
 - bother loading the code unless we allocate the writebuffer too
 - be so verbose with messaging:
    * be more concise
    * reduce importance (e.g. DEBUG not WARNING)
    * remove duplication

The minimum buffer size is something of a guess.  It's eight
times smaller than before, almost the same size as the code
being downloaded.  It probably deserves some tuning.

Also, note an erratum affecting flash protection on some chips;
and narrow many over-wide lines affected by the above changes.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-18 01:33:19 -08:00
Dean Glazeski
ef4fbd36d4 NAND write data page refactoring.
Refactored the write page raw function into two new functions
for writing data to a NAND device and then another function to
finish up a write to a NAND device.  This includes some new
updates to introduce more error checking to existing code.

[dbrownell@users.sourceforge.net: fix fault handling, whitespace]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-18 01:33:19 -08:00
Dean Glazeski
b8b4bb0745 NAND read data page refactor.
Added a new function to encapsulate reading a page of data from
a NAND device using either the read_block_data function of a NAND
controller or to use direct reading of data from the NAND device.

This also adds some performance enhancements and uses the read_data
function if the read_block_data function fails safely (because it
can't allocate a buffer in the working area).

[dbrownell@users.sourceforge.net: fix fault handling, whitespace]

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-18 01:33:19 -08:00
David Brownell
d265c219b9 stellaris: comments
Someday revisit various issues:  Tempest parts support writing
more than one word at a time; for some target firmware it might
be necessary to save and restore flash IRQ configuration.  (The
safest policy is likely to always reset after flash updates.)

Plus swap some undesirable TAB characters with SPACE.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-16 14:17:31 -08:00
David Brownell
1cd7b3b49b stellaris: probe() cleanups
Fix potential memory leak:  make sure the per-bank data
structures are only allocated in probe(), and that calling
probe() multiple times is a NOP.  Use it for auto_probe().

Require probe() to have done its thing:  don't make access
routines cope with it not having been called.  Shrink a
bunch of failure paths; and in some cases, correct them.

Don't needlessly insist on a halted target for probe().

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-16 14:17:31 -08:00
David Brownell
6f2b9ea9e1 stellaris: remove needless code
No point in reading and discarding a status value when fetching
part description data.  Or having that needless "#if 0" code.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-16 14:17:31 -08:00
David Brownell
f85dc92d2a stellaris: avoid chip writes
Previously "reading" clock info (and part info) also, as a side
effect, wrote the flash timing register.  Instead, be more safe:
"reading" should only read.  Write paths still refresh timing,
coping with changes the application code may have made.

Also rename the routine which sets flash timing, indicating what
it's really doing; it's got nothing to do with a "mode".

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-16 14:17:31 -08:00
David Brownell
47998a55e0 NOR: bugfix "flash fill[bwh] ..." helptext
These commands don't have a "bank" parameter.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-16 11:57:59 -08:00
Eric Wetzel
36dec1b319 stellaris: device IDs
I added the remaining devices and device IDs to stellaris.c, and
removed several devices that don't exist on the Stellaris web page.

Additionally, I found a few devices with duplicate IDs ... the DID1
Version Number for LM3Sxxx parts have DID1 Version = 0x0, and for
LM3Sxxxx have DID1 Version = 0x1. So I extended the comparison to
use the VER and FAM fields from DID1 also.

ID=0x33: LM3S812 (DID1v0) and LM3S2616 (DID1v1)
ID=0x39: LM3S808 (DID1v0) and LM3S2276 (DID1v1)

These are the parts I removed from the file for lack of documentation
(no data sheet to confirm part ID):

  LM3S318,
  LM3S1101, LM3S1108,
  LM3S1615, LM3S1616,
  LM3S2016,
  LM3S2101, LM3S2108,
  LM3S3759, LM3S3768,
  LM3S5757, LM3S5767, LM3S5768, LM3S5769,
  LM3S6815, LM3S6816,
  LM3S6915, LM3S6916,
  LM3S6111, LM3S6118.

Also, sort devices according to part number.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-14 15:59:01 -08:00
David Brownell
0a9d7cab6d LPC2000: rename "r13_svc" as "sp_svc"
This driver didn't get updated when the name changed.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-12 15:43:02 -08:00
Zachary T Welch
75892bfc6e add missing call to add new NAND devices
I forgot to add a call to the newly factored nand_device_add(), along
with its forward declaration.
2009-12-11 18:45:34 -08:00
Zachary T Welch
8438dee786 fix 'write_image' usage information
The 'flash write_image' command erroneously listed the bank number,
when it actually uses target addresses to do that lookup for the user.
2009-12-11 18:45:34 -08:00
David Brownell
a34345451d anotyer cygwin compile fix
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-10 17:42:20 -08:00
David Brownell
3d9cb516c2 stellaris: flash protection updates, minor fixes
Bugfix the read side of flash protection:
 - read the right register(s)!
 - handle more than 64K
 - record the results in the right places
 - don't display garbage.

Partially bugfix the write side:
 - use 2KB lock regions instead of 1KB pages (!)
 - validate input range
 - don't try to _remove_ protection (it's write-once)
 - #define values we'll need to commit writes.
 - ... still doesn't handle pages over 64KB mark, or commit writes

And minor cleanup and fixes:
 - get rid of some forward decls
 - properly locate a doxygen comment
 - fix some bad indentation
 - remove superfluous #include
 - add a new part ID (many are still missing)
 - make the downloaded algorithm code be read-only

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-09 21:16:09 -08:00
David Brownell
910dd664ce Comment and doxygen fixes
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-09 10:25:52 -08:00
Øyvind Harboe
eb1bc657ae build: add build/src to include path
This allows including generated include files.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
2009-12-08 10:16:10 +01:00
David Brownell
0a1b7dcfc4 ARM: use <target/arm.h> not armv4_5.h
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>
2009-12-07 14:57:44 -08:00
David Brownell
a4a2808c2a ARM: move opcode macros to <target/arm_opcodes.h>
Move the ARM opcode macros from <target/armv4_5.h>, and a few
Thumb2 ones from <target/armv7m.h>, to more appropriate homes
in a new <target/arm_opcodes.h> file.

Removed duplicate opcodes from that v7m/Thumb2 set.  Protected
a few macro argument references by adding missing parentheses.

Tightening up some of the line lengths turned up a curious artifact:
the macros for the Thumb opcodes are all 32 bits wide, not 16 bits.
There's currently no explanation for why it's done that way...

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-07 14:57:43 -08:00
Zachary T Welch
30a6e683b8 add 'flash list', rewrite 'flash banks'
Rename the existing 'flash banks' implementation as 'flash list', and
replace the broken 'flash_banks' TCL wrapper with a new command handler.

Adds documentation for the new 'flash list' command in the user guide.
2009-12-06 21:39:35 -08:00
Zachary T Welch
2bc4dee7e6 allow 'flash_banks' command to give GDB output
The 'flash banks' command produces a list that needs to be formatted
properly for GDB's 'mem info' to work properly.  The flash_banks TCL
wrapper provided this formatting, but wrappers no longer work for
second-level commands as they did in the past.  With this patch,
the 'flash_banks' command can be used with the new command syntax
and display the required information.
2009-12-06 20:19:18 -08:00
Zachary T Welch
56c5f6361e fix NOR flash regression
When factoring the bank setup command into flash_bank_add(), I forgot
to include a call to the new helper.
2009-12-06 20:15:08 -08:00
David Brownell
dd9d1a3459 misc code review updates
More updates from the code review by Steve Grubb <sgrubb@redhat.com>.
The Jim float-comparision bug just gets a comment not a fix, though.

Cc: Steve Grubb <sgrubb@redhat.com>.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-05 14:40:06 -08:00
Mathias Kuester
12b67a2b41 NOR: add 29LV400BC flash device
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-05 11:12:59 -08:00
Zachary T Welch
899c9975e7 rename nand.h to flash//nand/core.h
Rename nand.h as flash/nand/core.h, chase consumers.  The public APIs
need to be sorted out with imp.h, but this allows other changes to
begin improving the separation between policy and mechanism.

Moves #include <target/target.h> and #include "driver.h" into the
internal headers or source files, removing it from <flash/nand/core.h>.
2009-12-04 22:26:25 -08:00
Zachary T Welch
da3bcb392e move remaining nand helper files
Move remaining NAND implementation files into src/flash/nand/.
2009-12-04 21:47:47 -08:00
Zachary T Welch
747d6f2286 split nand.c into nand/{core,fileio,tcl}.c
Moves commands into nand/tcl.c and core implementation to 'nand/core.c'
and 'nand/fileio.c'.  Eliminates 'flash/nand.c'.

Adds 'nand/imp.h' to share routines between TCL commands and core.
2009-12-04 21:41:23 -08:00
Zachary T Welch
a7fd30c07f split NAND driver handling into nand/driver.[ch]
This work parallels the NOR directory, encapsulating the NAND drivers
into a separate file.  This takes an extra step by encapsulating the
type of data structure used to manage the drivers, allowing it to be
changed from an array to a dynamic list in the future.
2009-12-04 21:41:23 -08:00
David Brownell
c2cc677056 ARM: rename armv4_5_algorithm as arm_algorithm
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-04 20:19:49 -08:00
David Brownell
e51b9a4ac7 ARM: ARMV4_5_COMMON_MAGIC --> ARM_COMMON_MAGIC
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-04 19:46:44 -08:00
David Brownell
0073e7a69e ARM: rename ARMV4_5_MODE_* as ARM_MODE_*
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
2009-12-04 19:21:14 -08:00