From dd875c767e6fb0f4fecfb799b706d84562a7acee Mon Sep 17 00:00:00 2001 From: wdenk Date: Sat, 3 Jan 2004 21:24:46 +0000 Subject: * Patch by Robert Schwebel, 15 Dec 2003: add support for cramfs (uses JFFS2 command interface) --- common/cmd_fpga.c | 2 +- common/cmd_jffs2.c | 59 +++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 48 insertions(+), 13 deletions(-) (limited to 'common') diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index e674ef4fed..325fdd1420 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -158,7 +158,7 @@ static int fpga_get_op (char *opstr) } U_BOOT_CMD (fpga, 6, 1, do_fpga, - "fpga - loadable FPGA image support\n", + "fpga - loadable FPGA image support\n", "fpga [operation type] [device number] [image address] [image size]\n" "fpga operations:\n" "\tinfo\tlist known device information.\n" diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index 3301bd97e9..a581e6f945 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -1,6 +1,10 @@ /* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * (C) Copyright 2002 + * Robert Schwebel, Pengutronix, + * (C) Copyright 2003 + * Kai-Uwe Bloem, Auerswald GmbH & Co KG, * * See file CREDITS for list of people who contributed to this * project. @@ -31,6 +35,9 @@ #include #if (CONFIG_COMMANDS & CFG_CMD_JFFS2) + +#include + static int part_num=0; #ifndef CFG_JFFS_CUSTOM_PART @@ -77,11 +84,13 @@ jffs2_part_info(int part_num) return 0; } #endif /* ifndef CFG_JFFS_CUSTOM_PART */ + int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { struct part_info* jffs2_part_info(int); int jffs2_1pass_load(char *, struct part_info *,const char *); + char *fsname; char *filename = "uImage"; ulong offset = CFG_LOAD_ADDR; @@ -98,17 +107,25 @@ do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (0 != (part=jffs2_part_info(part_num))){ - printf("### JFFS2 loading '%s' to 0x%lx\n", filename, offset); - size = jffs2_1pass_load((char *)offset, part, filename); + /* check partition type for cramfs */ + fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2"); + printf("### %s loading '%s' to 0x%lx\n", fsname, filename, offset); + + if (cramfs_check(part)) { + size = cramfs_load ((char *) offset, part, filename); + } else { + /* if this is not cramfs assume jffs2 */ + size = jffs2_1pass_load((char *)offset, part, filename); + } if (size > 0) { char buf[10]; - printf("### JFFS2 load complete: %d bytes loaded to 0x%lx\n", - size, offset); + printf("### %s load complete: %d bytes loaded to 0x%lx\n", + fsname, size, offset); sprintf(buf, "%x", size); setenv("filesize", buf); } else { - printf("### JFFS2 LOAD ERROR<%x> for %s!\n", size, filename); + printf("### %s LOAD ERROR<%x> for %s!\n", fsname, size, filename); } return !(size > 0); @@ -132,7 +149,13 @@ do_jffs2_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (0 != (part=jffs2_part_info(part_num))){ - ret = jffs2_1pass_ls(jffs2_part_info(part_num), filename); + /* check partition type for cramfs */ + if (cramfs_check(part)) { + ret = cramfs_ls (part, filename); + } else { + /* if this is not cramfs assume jffs2 */ + ret = jffs2_1pass_ls(part, filename); + } return (ret == 1); } @@ -143,15 +166,24 @@ do_jffs2_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) int do_jffs2_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { - struct part_info* jffs2_part_info(int); - int jffs2_1pass_info(struct part_info *); - - int ret; + struct part_info* jffs2_part_info(int); + int jffs2_1pass_info(struct part_info *); struct part_info *part; + char *fsname; + int ret; - if (0 != (part=jffs2_part_info(part_num))){ + if ((part=jffs2_part_info(part_num))){ + + /* check partition type for cramfs */ + fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2"); + printf("### filesystem type is %s\n", fsname); - ret = jffs2_1pass_info(jffs2_part_info(part_num)); + if (cramfs_check(part)) { + ret = cramfs_info (part); + } else { + /* if this is not cramfs assume jffs2 */ + ret = jffs2_1pass_info(part); + } return (ret == 1); } @@ -163,6 +195,7 @@ int do_jffs2_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int tmp_part; + char str_part_num[3]; struct part_info* jffs2_part_info(int); if (argc >= 2) { @@ -176,6 +209,8 @@ do_jffs2_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) if (jffs2_part_info(tmp_part)){ printf("Partition changed to %d\n",tmp_part); part_num=tmp_part; + sprintf(str_part_num, "%d", part_num); + setenv("partition", str_part_num); return 0; } -- cgit v1.2.1