summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/cmd_bootm.c5
-rw-r--r--common/cmd_date.c28
-rw-r--r--common/cmd_jffs2.c69
-rw-r--r--common/cmd_load.c10
-rw-r--r--common/console.c20
-rw-r--r--common/image.c5
6 files changed, 114 insertions, 23 deletions
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 0db7b75..751f5b9 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -246,7 +246,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ret = boot_get_ramdisk (argc, argv, &images, IH_INITRD_ARCH,
&images.rd_start, &images.rd_end);
if (ret) {
- puts ("Ramdisk image is corrupt\n");
+ puts ("Ramdisk image is corrupt or invalid\n");
return 1;
}
@@ -361,7 +361,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong load_end = 0;
int ret;
- bootm_start(cmdtp, flag, argc, argv);
+ if (bootm_start(cmdtp, flag, argc, argv))
+ return 1;
/*
* We have reached the point of no return: we are going to
diff --git a/common/cmd_date.c b/common/cmd_date.c
index 7511598..d6cd565 100644
--- a/common/cmd_date.c
+++ b/common/cmd_date.c
@@ -56,18 +56,30 @@ int do_date (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
rtc_reset ();
} else {
/* initialize tm with current time */
- rtc_get (&tm);
- /* insert new date & time */
- if (mk_date (argv[1], &tm) != 0) {
- puts ("## Bad date format\n");
- break;
+ rcode = rtc_get (&tm);
+
+ if(!rcode) {
+ /* insert new date & time */
+ if (mk_date (argv[1], &tm) != 0) {
+ puts ("## Bad date format\n");
+ break;
+ }
+ /* and write to RTC */
+ rcode = rtc_set (&tm);
+ if(rcode)
+ puts("## Set date failled\n");
+ } else {
+ puts("## Get date failled\n");
}
- /* and write to RTC */
- rtc_set (&tm);
}
/* FALL TROUGH */
case 1: /* get date & time */
- rtc_get (&tm);
+ rcode = rtc_get (&tm);
+
+ if (rcode) {
+ puts("## Get date failled\n");
+ break;
+ }
printf ("Date: %4d-%02d-%02d (%sday) Time: %2d:%02d:%02d\n",
tm.tm_year, tm.tm_mon, tm.tm_mday,
diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index c031d80..c6920c9 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -51,7 +51,7 @@
* mtdids=<idmap>[,<idmap>,...]
*
* <idmap> := <dev-id>=<mtd-id>
- * <dev-id> := 'nand'|'nor'<dev-num>
+ * <dev-id> := 'nand'|'nor'|'onenand'<dev-num>
* <dev-num> := mtd device number, 0...
* <mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
*
@@ -103,6 +103,13 @@
#include <nand.h>
#endif /* !CONFIG_NAND_LEGACY */
#endif
+
+#if defined(CONFIG_CMD_ONENAND)
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/onenand.h>
+#include <onenand_uboot.h>
+#endif
+
/* enable/disable debugging messages */
#define DEBUG_JFFS
#undef DEBUG_JFFS
@@ -401,6 +408,43 @@ static int part_validate_nand(struct mtdids *id, struct part_info *part)
}
/**
+ * Performs sanity check for supplied OneNAND flash partition.
+ * Table of existing OneNAND flash devices is searched and partition device
+ * is located. Alignment with the granularity of nand erasesize is verified.
+ *
+ * @param id of the parent device
+ * @param part partition to validate
+ * @return 0 if partition is valid, 1 otherwise
+ */
+static int part_validate_onenand(struct mtdids *id, struct part_info *part)
+{
+#if defined(CONFIG_CMD_ONENAND)
+ /* info for OneNAND chips */
+ struct mtd_info *mtd;
+
+ mtd = &onenand_mtd;
+
+ if ((unsigned long)(part->offset) % mtd->erasesize) {
+ printf("%s%d: partition (%s) start offset"
+ "alignment incorrect\n",
+ MTD_DEV_TYPE(id->type), id->num, part->name);
+ return 1;
+ }
+
+ if (part->size % mtd->erasesize) {
+ printf("%s%d: partition (%s) size alignment incorrect\n",
+ MTD_DEV_TYPE(id->type), id->num, part->name);
+ return 1;
+ }
+
+ return 0;
+#else
+ return 1;
+#endif
+}
+
+
+/**
* Performs sanity check for supplied partition. Offset and size are verified
* to be within valid range. Partition type is checked and either
* parts_validate_nor() or parts_validate_nand() is called with the argument
@@ -436,6 +480,8 @@ static int part_validate(struct mtdids *id, struct part_info *part)
return part_validate_nand(id, part);
else if (id->type == MTD_DEV_TYPE_NOR)
return part_validate_nor(id, part);
+ else if (id->type == MTD_DEV_TYPE_ONENAND)
+ return part_validate_onenand(id, part);
else
DEBUGF("part_validate: invalid dev type\n");
@@ -755,7 +801,15 @@ static int device_validate(u8 type, u8 num, u32 *size)
#else
printf("support for NAND devices not present\n");
#endif
- }
+ } else if (type == MTD_DEV_TYPE_ONENAND) {
+#if defined(CONFIG_CMD_ONENAND)
+ *size = onenand_mtd.size;
+ return 0;
+#else
+ printf("support for OneNAND devices not present\n");
+#endif
+ } else
+ printf("Unknown defice type %d\n", type);
return 1;
}
@@ -1065,8 +1119,8 @@ static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_
#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
/**
- * Parse device id string <dev-id> := 'nand'|'nor'<dev-num>, return device
- * type and number.
+ * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'<dev-num>,
+ * return device type and number.
*
* @param id string describing device id
* @param ret_id output pointer to next char after parse completes (output)
@@ -1085,6 +1139,9 @@ int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num)
} else if (strncmp(p, "nor", 3) == 0) {
*dev_type = MTD_DEV_TYPE_NOR;
p += 3;
+ } else if (strncmp(p, "onenand", 7) == 0) {
+ *dev_type = MTD_DEV_TYPE_ONENAND;
+ p += 7;
} else {
printf("incorrect device type in %s\n", id);
return 1;
@@ -1489,7 +1546,7 @@ static int parse_mtdids(const char *const ids)
while(p && (*p != '\0')) {
ret = 1;
- /* parse 'nor'|'nand'<dev-num> */
+ /* parse 'nor'|'nand'|'onenand'<dev-num> */
if (id_parse(p, &p, &type, &num) != 0)
break;
@@ -2181,7 +2238,7 @@ U_BOOT_CMD(
"'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
"mtdids=<idmap>[,<idmap>,...]\n\n"
"<idmap> := <dev-id>=<mtd-id>\n"
- "<dev-id> := 'nand'|'nor'<dev-num>\n"
+ "<dev-id> := 'nand'|'nor'|'onenand'<dev-num>\n"
"<dev-num> := mtd device number, 0...\n"
"<mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n"
"'mtdparts' - partition list\n\n"
diff --git a/common/cmd_load.c b/common/cmd_load.c
index f2b73bd..1351fe2 100644
--- a/common/cmd_load.c
+++ b/common/cmd_load.c
@@ -38,7 +38,7 @@ static ulong load_serial_ymodem (ulong offset);
#endif
#if defined(CONFIG_CMD_LOADS)
-static ulong load_serial (ulong offset);
+static ulong load_serial (long offset);
static int read_record (char *buf, ulong len);
# if defined(CONFIG_CMD_SAVES)
static int save_serial (ulong offset, ulong size);
@@ -53,7 +53,7 @@ static int do_echo = 1;
#if defined(CONFIG_CMD_LOADS)
int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- ulong offset = 0;
+ long offset = 0;
ulong addr;
int i;
char *env_echo;
@@ -72,7 +72,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
#ifdef CFG_LOADS_BAUD_CHANGE
if (argc >= 2) {
- offset = simple_strtoul(argv[1], NULL, 16);
+ offset = simple_strtol(argv[1], NULL, 16);
}
if (argc == 3) {
load_baudrate = (int)simple_strtoul(argv[2], NULL, 10);
@@ -95,7 +95,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
#else /* ! CFG_LOADS_BAUD_CHANGE */
if (argc == 2) {
- offset = simple_strtoul(argv[1], NULL, 16);
+ offset = simple_strtol(argv[1], NULL, 16);
}
#endif /* CFG_LOADS_BAUD_CHANGE */
@@ -141,7 +141,7 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
static ulong
-load_serial (ulong offset)
+load_serial (long offset)
{
char record[SREC_MAXRECLEN + 1]; /* buffer for one S-Record */
char binbuf[SREC_MAXBINLEN]; /* buffer for binary data */
diff --git a/common/console.c b/common/console.c
index cfcaeb8..56d9118 100644
--- a/common/console.c
+++ b/common/console.c
@@ -162,6 +162,11 @@ void fprintf (int file, const char *fmt, ...)
int getc (void)
{
+#ifdef CONFIG_DISABLE_CONSOLE
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return 0;
+#endif
+
if (gd->flags & GD_FLG_DEVINIT) {
/* Get from the standard input */
return fgetc (stdin);
@@ -173,6 +178,11 @@ int getc (void)
int tstc (void)
{
+#ifdef CONFIG_DISABLE_CONSOLE
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return 0;
+#endif
+
if (gd->flags & GD_FLG_DEVINIT) {
/* Test the standard input */
return ftstc (stdin);
@@ -189,6 +199,11 @@ void putc (const char c)
return;
#endif
+#ifdef CONFIG_DISABLE_CONSOLE
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return;
+#endif
+
if (gd->flags & GD_FLG_DEVINIT) {
/* Send to the standard output */
fputc (stdout, c);
@@ -205,6 +220,11 @@ void puts (const char *s)
return;
#endif
+#ifdef CONFIG_DISABLE_CONSOLE
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return;
+#endif
+
if (gd->flags & GD_FLG_DEVINIT) {
/* Send to the standard output */
fputs (stdout, s);
diff --git a/common/image.c b/common/image.c
index 55c4cce..94f01ad 100644
--- a/common/image.c
+++ b/common/image.c
@@ -749,7 +749,7 @@ int genimg_has_config (bootm_headers_t *images)
* rd_start and rd_end are set to ramdisk start/end addresses if
* ramdisk image is found and valid
*
- * 1, if ramdisk image is found but corrupted
+ * 1, if ramdisk image is found but corrupted, or invalid
* rd_start and rd_end are set to 0 if no ramdisk exists
*/
int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
@@ -936,6 +936,7 @@ int boot_get_ramdisk (int argc, char *argv[], bootm_headers_t *images,
default:
puts ("Wrong Ramdisk Image Format\n");
rd_data = rd_len = rd_load = 0;
+ return 1;
}
#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO)
@@ -1516,7 +1517,7 @@ int boot_get_fdt (int flag, int argc, char *argv[], bootm_headers_t *images,
}
break;
default:
- fdt_error ("Did not find a cmdline Flattened Device Tree");
+ puts ("ERROR: Did not find a cmdline Flattened Device Tree\n");
goto error;
}