From b194577b2995eacbd2a3769269f0af1bc5e22530 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 30 Nov 2010 15:01:28 -0600 Subject: hwconfig: Fix dummy initialization of {board, cpu}_hwconfig Since board_hwconfig & cpu_hwconfig are defined as weak and dont have a default value they will get put into the BSS if they aren't defined elsewhere. This is problematic as we try to utilize hwconfig before we've relocated and thus BSS isn't setup. Instead of giving dummy values in the board files that utilize this feature, we can just initialize the variables to an empty string and thus move them out of the BSS if they aren't defined elsewhere. Also made board_hwconfig & cpu_hwconfig arrays to reduce size associated with string pointers vs arrays. Signed-off-by: Kumar Gala --- common/hwconfig.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/hwconfig.c b/common/hwconfig.c index 3c9759f..da8d3ed 100644 --- a/common/hwconfig.c +++ b/common/hwconfig.c @@ -68,8 +68,8 @@ 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 @@ -96,13 +96,11 @@ static const char *__hwconfig(const char *opt, size_t *arglen) return hwconfig_parse(env_hwconfig, strlen(env_hwconfig), opt, ";", ':', arglen); - if (board_hwconfig) - return hwconfig_parse(board_hwconfig, strlen(board_hwconfig), - opt, ";", ':', arglen); + return hwconfig_parse(board_hwconfig, strlen(board_hwconfig), + opt, ";", ':', arglen); - if (cpu_hwconfig) - return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), - opt, ";", ':', arglen); + return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), + opt, ";", ':', arglen); return NULL; } -- cgit v1.1 From cb9c09d4871015be5710c7bae29b06218ddc3509 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Thu, 28 Oct 2010 14:09:22 +0200 Subject: UBIFS: Add ubifsumount command to unmount an active volume This new ubifsumount command allows the user to unmount a previously mounted UBIFS volume. Signed-off-by: Stefan Roese --- common/cmd_ubifs.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'common') diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c index a0ec184..30b23d3 100644 --- a/common/cmd_ubifs.c +++ b/common/cmd_ubifs.c @@ -33,12 +33,17 @@ #include #include +#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,6 +72,26 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 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; + } + + if (ubifs_sb) + ubifs_umount(ubifs_sb->s_fs_info); + + ubifs_sb = NULL; + ubifs_mounted = 0; + ubifs_initialized = 0; + + return 0; +} + int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *filename = "/"; @@ -132,6 +157,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" -- cgit v1.1 From 9a2ea578bc2f556fd92a3bcb9127d3fc9c6ee1bd Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Thu, 28 Oct 2010 14:09:29 +0200 Subject: UBIFS: Change "ubifs mount" to "ubifsmount" in ubifsls output Signed-off-by: Stefan Roese --- common/cmd_ubifs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c index 30b23d3..9526780 100644 --- a/common/cmd_ubifs.c +++ b/common/cmd_ubifs.c @@ -98,7 +98,7 @@ int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 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; } -- cgit v1.1 From 2f15cfd187f1cf7a0606a1ec3e637954311a735a Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Mon, 1 Nov 2010 17:28:22 +0100 Subject: UBI/UBIFS: Automatically unmount UBIFS volume upon UBI partition change Automatically unmount UBIFS partition when user changes the UBI device. Otherwise the following UBIFS commands will crash. Signed-off-by: Stefan Roese --- common/cmd_ubi.c | 15 +++++++++++++++ common/cmd_ubifs.c | 26 ++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'common') 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 9526780..3cd2d8f 100644 --- a/common/cmd_ubifs.c +++ b/common/cmd_ubifs.c @@ -72,6 +72,25 @@ 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) @@ -82,12 +101,7 @@ int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return -1; } - if (ubifs_sb) - ubifs_umount(ubifs_sb->s_fs_info); - - ubifs_sb = NULL; - ubifs_mounted = 0; - ubifs_initialized = 0; + cmd_ubifs_umount(); return 0; } -- cgit v1.1 From 068a208b4a3e1e0dfc8dea6ebbd80b62ae280732 Mon Sep 17 00:00:00 2001 From: Steve Sakoman Date: Fri, 3 Dec 2010 13:25:43 +0000 Subject: env_nand: Use nand_read_skip_bad instead of nand_read The nand-read function returns an error code if correctable errors have occurred. This is not desirable, since the errors have been corrected! This patch switches to the nand_read_skip_bad function which does not return an error code if the errors are correctable. Signed-off-by: Steve Sakoman Acked-by: Scott Wood --- common/env_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') 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; -- cgit v1.1 From a430b137eb578cf73be476ff05a43baa2aba1ad8 Mon Sep 17 00:00:00 2001 From: Lei Wen Date: Tue, 7 Dec 2010 09:38:18 +0800 Subject: onenand: fix oob print out issue Seems original implementation forget to set the pointer to point to the oobbuf, so when we want to see oob buf, we see nothing... Fix it by get pointer as the oobbuf set. Signed-off-by: Lei Wen --- common/cmd_onenand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'common') 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]); -- cgit v1.1 From bb141079d34bebb073c5b0566313e1441973ec01 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Tue, 30 Nov 2010 15:58:27 -0600 Subject: hwconfig: Fix handling of env_hwconfig, board_hwconfig, and cpu_hwconfig The handling of env_hwconfig, board_hwconfig, and cpu_hwconfig got broken when we removed the boards defining dummy board_hwconfig & cpu_hwconfig values. We fix this by handling the various strings in priority order. If hwconfig_parse returns NULL for a given string we check the next one in order (env_hwconfig, board_hwconfig, followed by cpu_hwconfig). Signed-off-by: Kumar Gala --- common/hwconfig.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/hwconfig.c b/common/hwconfig.c index da8d3ed..193863a 100644 --- a/common/hwconfig.c +++ b/common/hwconfig.c @@ -75,7 +75,7 @@ const char board_hwconfig[] __attribute__((weak)) = ""; 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,17 +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; + } - return hwconfig_parse(board_hwconfig, strlen(board_hwconfig), + ret = hwconfig_parse(board_hwconfig, strlen(board_hwconfig), opt, ";", ':', arglen); + if (ret) + return ret; return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), opt, ";", ':', arglen); - - return NULL; } /* -- cgit v1.1