imls: Add support to list images in NAND device

This patch adds support to list images in NAND flash through imls

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
nand: fix nand read.option parsing

"nand read.part addr off size" would be treated as "nand read.raw addr off 1"
It now fails as intended stating "Unknown nand command suffix '.part'"

Signed-off-by: Harvey Chapman <hchapman@3gfp.com>
mtd: nand: Check if NAND is locked tight before lock cmds

If the NAND is locked tight, commands such as lock and unlock will not
work, but the NAND chip may not report an error.  Check the lock tight
status before attempting such operations so that an error status can be
reported if we know the operation will not succeed.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
env_nand.c: clarify log messages when env reading fails

The single message is misleading, since there is no equivalent success
note when reading the other copy succeeds. Instead, warn if one of the
redundant copies could not be loaded and emphasise on the error when
reading both fails.

Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>
common/env_nand.c: calculate crc only when readenv was OK

Calculating the checksum of incompletely read data is useless.

Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>
[scottwood@freescale.com: minor formatting fix]
Signed-off-by: Scott Wood <scottwood@freescale.com>
sandbox: fix compiler warning

Add back return statement to fix compiler warning about control flow
reaching end of non void function that was introduced with:

	e05e5de arm: move C runtime setup code in crt0.S

Signed-off-by: Allen Martin <amartin@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tidy up error checking and fix bug in hash command

There are two problems:

1. The argument count needs to be checked before argv is used
2. When verify is not enabled, we need to define a constant zero value

Signed-off-by: Simon Glass <sjg@chromium.org>
Update print_buffer() to use const

The buffer cannot be changed by this function, so change the buffer
pointer to a const. This allows callers with const pointer to use the
function without a cast.

Signed-off-by: Simon Glass <sjg@chromium.org>
sandbox: Improve sandbox serial port keyboard interface

Implements the tstc() interface for the serial driver.  Multiplexing
the console between the serial port and a keyboard uses a polling
method of checking if characters are available; this means that the
serial console must be non-blocking when attempting to read
characters.

Signed-off-by: Taylor Hutt <thutt@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
sandbox: Add un/map_sysmen() to deal with sandbox's ram_buf

Sandbox doesn't actually provide U-Boot access to the machine's physical
memory. Instead it provides a RAM buffer of configurable size, and all
memory accesses are within that buffer. Sandbox memory starts at 0 and
is CONFIG_DRAM_SIZE bytes in size. Allowing access outside this buffer
might produce unpredictable results in the event of an error, and would
expose the host machine's memory architecture to the sandbox U-Boot.

Most U-Boot functions assume that they can just access memory at given
address. For sandbox this is not true.

Add a map_sysmem() call which converts a U-Boot address to a system
address. In most cases this is a NOP, but for sandbox it returns a
pointer to that memory inside the RAM buffer.

To get a U-Boot feature to work correctly within sandbox, you should call
map_sysmem() to get a pointer to the address, and then use that address for
any U-Boot memory accesses.

Signed-off-by: Simon Glass <sjg@chromium.org>
sandbox: Change memory commands to use map_physmem

Sandbox wants to support commands which use memory. The map_sysmen()
call provides this feature, so use this in the memory commands.

Signed-off-by: Simon Glass <sjg@chromium.org>
Split out the memory tests into separate functions

Half of the code is currently hidden behind an #ifdef. Move the two
memory tests into their own functions and use the compiler to eliminate
the unused code.

Signed-off-by: Simon Glass <sjg@chromium.org>
Use common mtest iteration counting

The iteration code is the same for each version of the memory test, so
pull it out into the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fix mtest indenting

Some of the inner loops are not indented correctly. Fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Bring mtest putc() into common code

If we get a Ctrl-C abort, we always print a newline. Move this repeated
code out of the functions and into a single place in the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reduce casting in mtest

Use a ulong for the command arguments, and only cast to an address when
needed. This fixes warnings in sandbox where pointers are typically 64 bits
long.

Signed-off-by: Simon Glass <sjg@chromium.org>
Update set_working_fdt_addr() to use setenv_addr()

We might as well use this common function instead of repeating the same
code.

Signed-off-by: Simon Glass <sjg@chromium.org>
common: Use new numeric setenv functions

Use setenv_ulong(), setenv_hex() and setenv_addr() in common/

Signed-off-by: Simon Glass <sjg@chromium.org>
fs: Use new numeric setenv functions

Use setenv_ulong(), setenv_hex() and setenv_addr() in fs/

Signed-off-by: Simon Glass <sjg@chromium.org>
net: Use new numeric setenv functions

Use setenv_ulong(), setenv_hex() and setenv_addr() in net/

Signed-off-by: Simon Glass <sjg@chromium.org>