cmd_nand: fix crashing bug in nand read/write

Commit 418396e212b59bf907dbccad997ff50f7eb61b16 introduced a
bug that causes nand read and nand write to crash in strcmp
due to a null pointer.

Root cause is that strchr(cmd, '.') returns a null pointer when
the input string does not contain a '.'

The strcmp function does not check for null pointers, resulting
in a crash.

Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Scott Wood <scott@tyr.buserror.net>
powerpc/83xx: increment malloc heap size for the MPC832x MDS boards

The malloc buffer is not large enough to hold a flash sector (0x20000 bytes)
in addition to whatever else it normally holds, so double its size.  This
fixes a failure trying to save the environment:

=> save
Saving Environment to Flash...
Unable to save the rest of sector (122880)
. done
Protected 1 sectors

This problem probably surfaced from some other change that significantly
increased the normal memory usage, thereby not leaving enough room for
the saveenv command.

Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc/83xx/km: use tuxx1.h for kmsupx5 target

This additional header is unneeded, we can use the tuxx1.h for this
target.

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
cc: Kim Phillips <kim.phillips@freescale.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Gerlando Falauto <gerlando.falauto@keymile.com>
cc: Heiko Schocher <hs@denx.de>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc83xx/km: lock the window size to 2GiB befor fixing sdram size

If the ram size isn't locked to 2GiB, the get_ram_size() may hang up.

Signed-off-by: Christian Herzig <christian.herzig@keymile.com>
cc: Kim Phillips <kim.phillips@freescale.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Gerlando Falauto <gerlando.falauto@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc83xx/km: remove unneeded CONFIG_PCI for kmeter1

We don't use PCI on kmeter1 and never will be, so remove some
unneeded code.

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
cc: Kim Phillips <kim.phillips@freescale.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Gerlando Falauto <gerlando.falauto@keymile.com>
cc: Heiko Schocher <hs@denx.de>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
km/common: add support for second flash

Add support for a second flash.
By default, a single flash chip is set up:
- called 'boot'
- mtd name for ubi 'ubi0'
MTDIDS and MTDPARTS may be overwritten to add a second flash.
The 'ubiattach' command is featured in two versions:
- if CONFIG_KM_UBI_PARTITION_NAME_APP is not defined:
  this is the version as up to now
- if CONFIG_KM_UBI_PARTITION_NAME_APP is defined:
  a check on 'actual_bank' will be done to determine the flash to boot
  from.

Use CONFIG_KM_UBI_PARTITION_NAME_BOOT and
CONFIG_KM_UBI_PARTITION_NAME_APP to define where to put the bootloader
and the applications.

Example:
In the board config do:
... snip ...

       "boot:"                                                 \
               "768k(u-boot),"                                 \
               "128k(env),"                                    \
               "128k(envred),"                                 \
               "-(" CONFIG_KM_UBI_PARTITION_NAME_BOOT ");"     \
       "app:"                                                  \
               "-(" CONFIG_KM_UBI_PARTITION_NAME_APP ");"

... snap ...

You may also need to enable the second flash:
... snip ...
/* additional featured for COGE5 */
... snap ...

Signed-off-by: Andreas Huber <andreas.huber@keymile.com>
cc: Kim Phillips <kim.phillips@freescale.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Gerlando Falauto <gerlando.falauto@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc/83xx: add kmcoge5ne board support

This board is a MPC8360 board. Two flashes are present
a NOR flash were u-boot and the u-boot environment is stored
and a NAND flash for the application code. This board has 512MB
SDRAM.

Additionaly we introduce a common km8360.h file and convert kmeter1 to
use this.

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Christian Herzig <christian.herzig@keymile.com>
cc: Kim Phillips <kim.phillips@freescale.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Gerlando Falauto <gerlando.falauto@keymile.com>
cc: Heiko Schocher <hs@denx.de>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
MAINTAINERS: cleanup for keymile boards

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
cc: Kim Phillips <kim.phillips@freescale.com>
cc: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Gerlando Falauto <gerlando.falauto@keymile.com>
cc: Heiko Schocher <hs@denx.de>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
km/common: fixed error in ethaddr (1-byte-shift)

The MAC address begins at offset 1.

Signed-off-by: Thomas Herzmann <thomas.herzmann@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
km/common: increase bootlimit to 3

Increase bootlimit to 3 to be more tolerant during the
boot process before switching to the backup application.

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc/83xx/km: added missing enable of application buffer

Enabled application buffers in uboot to allow application chipselect
access in uboot.

Signed-off-by: Stefan Bigler <stefan.bigler@keymile.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc/83xx: configure CONFIG_POST for kmcoge5ne

kmcoge5ne starts the post tests if the testpin on
the board was enabled. Currently it does simply a memory
test.

Signed-off-by: Thomas Herzmann <thomas.herzmann@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
powerpc/83xx/km: readout dip_switch on kmcoge5ne

On kmcoge5ne we have a dip switch present. If this switch
was switched on the actual_bank is set to 0 and this SW
will be booted.

Signed-off-by: Thomas Herzmann <thomas.herzmann@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
km/common: check test_bank and testpin for testboot

If the testpin is asserted, first check if a test_bank
variable is defined before trying to boot this
test_bank.

Signed-off-by: Thomas Herzmann <thomas.herzmann@keymile.com>
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Merge branch 'master' of git://git.denx.de/u-boot-mpc83xx

* 'master' of git://git.denx.de/u-boot-mpc83xx:
  km/common: check test_bank and testpin for testboot
  powerpc/83xx/km: readout dip_switch on kmcoge5ne
  powerpc/83xx: configure CONFIG_POST for kmcoge5ne
  powerpc/83xx/km: added missing enable of application buffer
  km/common: increase bootlimit to 3
  km/common: fixed error in ethaddr (1-byte-shift)
  MAINTAINERS: cleanup for keymile boards
  powerpc/83xx: add kmcoge5ne board support
  km/common: add support for second flash
  powerpc83xx/km: remove unneeded CONFIG_PCI for kmeter1
  powerpc83xx/km: lock the window size to 2GiB befor fixing sdram size
  powerpc/83xx/km: use tuxx1.h for kmsupx5 target
  powerpc/83xx: increment malloc heap size for the MPC832x MDS boards

Signed-off-by: Wolfgang Denk <wd@denx.de>
cmd_mem: replace custom PRINTF() with debug()

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
cmd_mem: cmp: unify size code paths

Not only does the source code get simpler, but it also shrinks the
compiled object code too.

While we're here, tweak the summary message to avoid the plural
issue.  It isn't that big of a deal, and it's currently wrong
anyways in the single (1 byte) case:
	Total of 1 byte were the same
Grammar wise, that should be "was" rather than "were".  The new
output people should be able to easily figure out:
	Total of 1 byte(s) were the same
	Total of 10 byte(s) were the same

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
cmd_mem: cmp: convert while() to for() loop

Simplify the code slightly by using a for() loop since this is
basically what we're already doing -- incrementing "ngood" to
the value in "count".

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
easylogo: add lzma support

Compressing the logos with lzma rather than gzip saves ~9kb with the
Blackfin 24bit images and ~3kb with the 16bit images.

Add a new -l option to easylogo so people can pick lzma as their
decompression routine.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
lmb: do not export anything without CONFIG_LMB

Signed-off-by: Mike Frysinger <vapier@gentoo.org>