summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile18
-rw-r--r--common/cmd_nvedit.c21
-rw-r--r--common/cmd_onenand.c4
-rw-r--r--common/cmd_ubi.c15
-rw-r--r--common/cmd_ubifs.c47
-rw-r--r--common/command.c2
-rw-r--r--common/dlmalloc.c7
-rw-r--r--common/env_nand.c2
-rw-r--r--common/fdt_support.c4
-rw-r--r--common/hwconfig.c27
10 files changed, 108 insertions, 39 deletions
diff --git a/common/Makefile b/common/Makefile
index 2c37073..abea91c 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -23,9 +23,7 @@
include $(TOPDIR)/config.mk
-LIB = $(obj)libcommon.a
-
-AOBJS =
+LIB = $(obj)libcommon.o
# core
COBJS-y += main.o
@@ -52,9 +50,9 @@ COBJS-y += cmd_version.o
COBJS-y += env_common.o
COBJS-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o
COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o
-COBJS-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
+XCOBJS-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_embedded.o
-COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o
+XCOBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o
COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_embedded.o
COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
COBJS-$(CONFIG_ENV_IS_IN_MG_DISK) += env_mgdisk.o
@@ -169,15 +167,17 @@ COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
COBJS := $(sort $(COBJS-y))
-SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS))
+XCOBJS := $(sort $(XCOBJS-y))
+SRCS := $(COBJS:.o=.c) $(XCOBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(COBJS))
+XOBJS := $(addprefix $(obj),$(XCOBJS))
CPPFLAGS += -I..
-all: $(LIB) $(AOBJS)
+all: $(LIB) $(XOBJS)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
$(obj)env_embedded.o: $(src)env_embedded.c $(obj)../tools/envcrc
$(CC) $(AFLAGS) -Wa,--no-warn \
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 3fd8abc..dcc93c1 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -545,8 +545,7 @@ int envmatch (uchar *s1, int i2)
static int do_env_default(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
if ((argc != 2) || (strcmp(argv[1], "-f") != 0)) {
- cmd_usage(cmdtp);
- return 1;
+ return cmd_usage(cmdtp);
}
set_default_env("## Resetting to default environment\n");
return 0;
@@ -633,15 +632,13 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
sep = '\n';
break;
default:
- cmd_usage(cmdtp);
- return 1;
+ return cmd_usage(cmdtp);
}
}
}
if (argc < 1) {
- cmd_usage(cmdtp);
- return 1;
+ return cmd_usage(cmdtp);
}
addr = (char *)simple_strtoul(argv[0], NULL, 16);
@@ -744,15 +741,13 @@ static int do_env_import(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
del = 1;
break;
default:
- cmd_usage(cmdtp);
- return 1;
+ return cmd_usage(cmdtp);
}
}
}
if (argc < 1) {
- cmd_usage(cmdtp);
- return 1;
+ return cmd_usage(cmdtp);
}
if (!fmt)
@@ -848,6 +843,9 @@ static int do_env (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
cmd_tbl_t *cp;
+ if (argc < 2)
+ return cmd_usage(cmdtp);
+
/* drop initial "env" arg */
argc--;
argv++;
@@ -857,8 +855,7 @@ static int do_env (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (cp)
return cp->cmd(cmdtp, flag, argc, argv);
- cmd_usage(cmdtp);
- return 1;
+ return cmd_usage(cmdtp);
}
U_BOOT_CMD(
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c
index 33108f1..cb2ba70 100644
--- a/common/cmd_onenand.c
+++ b/common/cmd_onenand.c
@@ -293,7 +293,7 @@ static int onenand_dump(struct mtd_info *mtd, ulong off, int only_oob)
addr = (loff_t) off;
memset(&ops, 0, sizeof(ops));
ops.datbuf = datbuf;
- ops.oobbuf = oobbuf; /* must exist, but oob data will be appended to ops.datbuf */
+ ops.oobbuf = oobbuf;
ops.len = mtd->writesize;
ops.ooblen = mtd->oobsize;
ops.retlen = 0;
@@ -319,6 +319,8 @@ static int onenand_dump(struct mtd_info *mtd, ulong off, int only_oob)
}
puts("OOB:\n");
i = mtd->oobsize >> 3;
+ p = oobbuf;
+
while (i--) {
printf("\t%02x %02x %02x %02x %02x %02x %02x %02x\n",
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 7692ac7..b486ca8 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -42,6 +42,11 @@ struct selected_dev {
static struct selected_dev ubi_dev;
+#ifdef CONFIG_CMD_UBIFS
+int ubifs_is_mounted(void);
+void cmd_ubifs_umount(void);
+#endif
+
static void ubi_dump_vol_info(const struct ubi_volume *vol)
{
ubi_msg("volume information dump:");
@@ -472,6 +477,16 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
if (argc < 3)
return cmd_usage(cmdtp);
+#ifdef CONFIG_CMD_UBIFS
+ /*
+ * Automatically unmount UBIFS partition when user
+ * changes the UBI device. Otherwise the following
+ * UBIFS commands will crash.
+ */
+ if (ubifs_is_mounted())
+ cmd_ubifs_umount();
+#endif
+
/* todo: get dev number for NAND... */
ubi_dev.nr = 0;
diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c
index a0ec184..3cd2d8f 100644
--- a/common/cmd_ubifs.c
+++ b/common/cmd_ubifs.c
@@ -33,12 +33,17 @@
#include <config.h>
#include <command.h>
+#include "../fs/ubifs/ubifs.h"
+
static int ubifs_initialized;
static int ubifs_mounted;
+extern struct super_block *ubifs_sb;
+
/* Prototypes */
int ubifs_init(void);
int ubifs_mount(char *vol_name);
+void ubifs_umount(struct ubifs_info *c);
int ubifs_ls(char *dir_name);
int ubifs_load(char *filename, u32 addr, u32 size);
@@ -67,13 +72,47 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 0;
}
+int ubifs_is_mounted(void)
+{
+ return ubifs_mounted;
+}
+
+void cmd_ubifs_umount(void)
+{
+
+ if (ubifs_sb) {
+ printf("Unmounting UBIFS volume %s!\n",
+ ((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name);
+ ubifs_umount(ubifs_sb->s_fs_info);
+ }
+
+ ubifs_sb = NULL;
+ ubifs_mounted = 0;
+ ubifs_initialized = 0;
+}
+
+int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ if (argc != 1)
+ return cmd_usage(cmdtp);
+
+ if (ubifs_initialized == 0) {
+ printf("No UBIFS volume mounted!\n");
+ return -1;
+ }
+
+ cmd_ubifs_umount();
+
+ return 0;
+}
+
int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char *filename = "/";
int ret;
if (!ubifs_mounted) {
- printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
+ printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
return -1;
}
@@ -132,6 +171,12 @@ U_BOOT_CMD(
);
U_BOOT_CMD(
+ ubifsumount, 1, 0, do_ubifs_umount,
+ "unmount UBIFS volume",
+ " - unmount current volume"
+);
+
+U_BOOT_CMD(
ubifsls, 2, 0, do_ubifs_ls,
"list files in a directory",
"[directory]\n"
diff --git a/common/command.c b/common/command.c
index 0020eac..0b1a3fb 100644
--- a/common/command.c
+++ b/common/command.c
@@ -108,6 +108,8 @@ cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len)
int len;
int n_found = 0;
+ if (!cmd)
+ return NULL;
/*
* Some commands allow length modifiers (like "cp.b");
* compare command name only until first dot.
diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 4871f4b..e9bab09 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -1511,6 +1511,13 @@ void *sbrk(ptrdiff_t increment)
ulong old = mem_malloc_brk;
ulong new = old + increment;
+ /*
+ * if we are giving memory back make sure we clear it out since
+ * we set MORECORE_CLEARS to 1
+ */
+ if (increment < 0)
+ memset((void *)new, 0, -increment);
+
if ((new < mem_malloc_start) || (new > mem_malloc_end))
return (void *)MORECORE_FAILURE;
diff --git a/common/env_nand.c b/common/env_nand.c
index 4e8307a..7f6c917 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -297,7 +297,7 @@ int readenv(size_t offset, u_char * buf)
offset += blocksize;
} else {
char_ptr = &buf[amount_loaded];
- if (nand_read(&nand_info[0], offset, &len, char_ptr))
+ if (nand_read_skip_bad(&nand_info[0], offset, &len, char_ptr))
return 1;
offset += blocksize;
amount_loaded += len;
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 5829afd..6c98e5b 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -954,7 +954,7 @@ static void of_bus_default_count_cells(void *blob, int parentoffset,
if (addrc) {
prop = fdt_getprop(blob, parentoffset, "#address-cells", NULL);
if (prop)
- *addrc = be32_to_cpup(prop);
+ *addrc = be32_to_cpup((u32 *)prop);
else
*addrc = 2;
}
@@ -962,7 +962,7 @@ static void of_bus_default_count_cells(void *blob, int parentoffset,
if (sizec) {
prop = fdt_getprop(blob, parentoffset, "#size-cells", NULL);
if (prop)
- *sizec = be32_to_cpup(prop);
+ *sizec = be32_to_cpup((u32 *)prop);
else
*sizec = 1;
}
diff --git a/common/hwconfig.c b/common/hwconfig.c
index 3c9759f..193863a 100644
--- a/common/hwconfig.c
+++ b/common/hwconfig.c
@@ -68,14 +68,14 @@ next:
return NULL;
}
-const char *cpu_hwconfig __attribute__((weak));
-const char *board_hwconfig __attribute__((weak));
+const char cpu_hwconfig[] __attribute__((weak)) = "";
+const char board_hwconfig[] __attribute__((weak)) = "";
#define HWCONFIG_PRE_RELOC_BUF_SIZE 128
static const char *__hwconfig(const char *opt, size_t *arglen)
{
- const char *env_hwconfig = NULL;
+ const char *env_hwconfig = NULL, *ret;
char buf[HWCONFIG_PRE_RELOC_BUF_SIZE];
if (gd->flags & GD_FLG_ENV_READY) {
@@ -92,19 +92,20 @@ static const char *__hwconfig(const char *opt, size_t *arglen)
env_hwconfig = buf;
}
- if (env_hwconfig)
- return hwconfig_parse(env_hwconfig, strlen(env_hwconfig),
+ if (env_hwconfig) {
+ ret = hwconfig_parse(env_hwconfig, strlen(env_hwconfig),
opt, ";", ':', arglen);
+ if (ret)
+ return ret;
+ }
- if (board_hwconfig)
- return hwconfig_parse(board_hwconfig, strlen(board_hwconfig),
- opt, ";", ':', arglen);
+ ret = hwconfig_parse(board_hwconfig, strlen(board_hwconfig),
+ opt, ";", ':', arglen);
+ if (ret)
+ return ret;
- if (cpu_hwconfig)
- return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig),
- opt, ";", ':', arglen);
-
- return NULL;
+ return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig),
+ opt, ";", ':', arglen);
}
/*