Patch by Robert Schwebel, 13 May 2004:
authorwdenk <wdenk>
Wed, 9 Jun 2004 10:15:00 +0000 (10:15 +0000)
committerwdenk <wdenk>
Wed, 9 Jun 2004 10:15:00 +0000 (10:15 +0000)
Add 'imgextract' command: extract one part of a multi file image.

15 files changed:
CHANGELOG
common/cmd_ximg.c [new file with mode: 0644]
doc/README.mpc85xxads
include/cmd_confdefs.h
include/configs/ADNPESC1.h
include/configs/DK1C20.h
include/configs/DK1S10.h
include/configs/LANTEC.h
include/configs/MPC8260ADS.h
include/configs/MPC8266ADS.h
include/configs/RBC823.h
include/configs/RPXClassic.h
include/configs/ZPC1900.h
include/configs/ep8260.h
include/configs/hymod.h

index 132aa6f9fb69048a57a645ef85baf82121388384..5d2866bcecacd009ef3d04a933bf959dcee5e625 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,9 @@
 Changes since U-Boot 1.1.1:
 ======================================================================
 
+* Patch by Robert Schwebel, 13 May 2004:
+  Add 'imgextract' command: extract one part of a multi file image.
+
 * Patches by Jon Loeliger, 11 May 2004:
   Dynamically handle REV1 and REV2 MPC85xx parts.
     (Jon Loeliger, 10-May-2004).
diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c
new file mode 100644 (file)
index 0000000..8359153
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * (C) Copyright 2003
+ * Kai-Uwe Bloem, Auerswald GmbH & Co KG, <linux-development@auerswald.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#if (CONFIG_COMMANDS & CFG_CMD_XIMG)
+
+/*
+ * Multi Image extract
+ */
+#include <common.h>
+#include <command.h>
+#include <image.h>
+#include <asm/byteorder.h>
+
+int
+do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+       ulong addr = load_addr, dest = 0;
+       ulong data, len, checksum;
+       ulong *len_ptr;
+       int i, verify, part = 0;
+       char pbuf[10], *s;
+       image_header_t header;
+
+       s = getenv("verify");
+       verify = (s && (*s == 'n')) ? 0 : 1;
+
+       if (argc > 1) {
+               addr = simple_strtoul(argv[1], NULL, 16);
+       }
+       if (argc > 2) {
+               part = simple_strtoul(argv[2], NULL, 16);
+       }
+       if (argc > 3) {
+               dest = simple_strtoul(argv[3], NULL, 16);
+       }
+
+       printf("## Copying from image at %08lx ...\n", addr);
+
+       /* Copy header so we can blank CRC field for re-calculation */
+       memmove(&header, (char *) addr, sizeof (image_header_t));
+
+       if (ntohl(header.ih_magic) != IH_MAGIC) {
+               printf("Bad Magic Number\n");
+               return 1;
+       }
+
+       data = (ulong) & header;
+       len = sizeof (image_header_t);
+
+       checksum = ntohl(header.ih_hcrc);
+       header.ih_hcrc = 0;
+
+       if (crc32(0, (char *) data, len) != checksum) {
+               printf("Bad Header Checksum\n");
+               return 1;
+       }
+#ifdef DEBUG
+       print_image_hdr((image_header_t *) addr);
+#endif
+
+       data = addr + sizeof (image_header_t);
+       len = ntohl(header.ih_size);
+
+       if (header.ih_type != IH_TYPE_MULTI) {
+               printf("Wrong Image Type for %s command\n", cmdtp->name);
+               return 1;
+       }
+
+       if (header.ih_comp != IH_COMP_NONE) {
+               printf("Wrong Compression Type for %s command\n", cmdtp->name);
+               return 1;
+       }
+
+       if (verify) {
+               printf("   Verifying Checksum ... ");
+               if (crc32(0, (char *) data, len) != ntohl(header.ih_dcrc)) {
+                       printf("Bad Data CRC\n");
+                       return 1;
+               }
+               printf("OK\n");
+       }
+
+       len_ptr = (ulong *) data;
+
+       data += 4;              /* terminator */
+       for (i = 0; len_ptr[i]; ++i) {
+               data += 4;
+               if (argc > 2 && part > i) {
+                       u_long tail;
+                       len = ntohl(len_ptr[i]);
+                       tail = len % 4;
+                       data += len;
+                       if (tail) {
+                               data += 4 - tail;
+                       }
+               }
+       }
+       if (argc > 2 && part >= i) {
+               printf("Bad Image Part\n");
+               return 1;
+       }
+       len = ntohl(len_ptr[part]);
+
+       if (argc > 3) {
+               memcpy((char *) dest, (char *) data, len);
+       }
+
+       sprintf(pbuf, "%8lx", data);
+       setenv("fileaddr", pbuf);
+       sprintf(pbuf, "%8lx", len);
+       setenv("filesize", pbuf);
+
+       return 0;
+}
+
+U_BOOT_CMD(imxtract, 4, 1, do_imgextract,
+          "imxtract- extract a part of a multi-image\n",
+          "addr part [dest]\n"
+          "    - extract <part> from image at <addr> and copy to <dest>\n");
+
+#endif /* CONFIG_COMMANDS & CFG_CMD_XIMG */
index 4c1686faa97371626e2c8feb0839607b77bc8398..c49b2a896bcb45ab77c23c210cb6219a61d9e9c7 100644 (file)
@@ -5,10 +5,12 @@ Created 10/15/03
 -----------------------------------------
 
 0. Toolchain
-The Binutils in current ELDK toolchain will not support MPC85xx chip. You need
-use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils.
+The Binutils in ELDK toolchain 3.0 or earlier does not support the
+MPC85xx chip. You need use the newest binutils-2.14.tar.bz2 from
+http://ftp.gnu.org/gnu/binutils.
 
 1. SWITCH SETTINGS & JUMPERS
+
 1.1 First, make sure the board default setting is consistent with the document
     shipped with your board. Then apply the following changes:
     SW3[1-6]="all OFF"  (boot from 32bit flash, no boot sequence is used)
@@ -19,11 +21,13 @@ use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils.
     SW22[1-4]="OFF OFF ON OFF"
     SW5[1-10[="ON ON OFF OFF OFF OFF OFF OFF OFF OFF"
     J1 = "Enable Prog" (Make sure your flash is programmable for development)
+
 1.2 If you want to test PCI functionality with a 33Mhz PCI card, you will
     have to change the system clock from the default 66Mhz to 33Mhz by
     setting SW15[1]="OFF" and SW17[8]="OFF". After that you may also need
     double your platform clock(SW6) because the system clock is now only
-    half of its original value. 
+    half of its original value.
+
 1.3 SW6 is a very important switch, it decides your platform clock and CPU
     clock based on the on-board system clock(default 66MHz). Check the
     document along with your board for details.
@@ -35,7 +39,7 @@ use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils.
      between u-boot and linux kernel, you can customize it based on your
      system requirements:
 
-     0x0000_0000     0x7fff_ffff     DDR                     2G 
+     0x0000_0000     0x7fff_ffff     DDR                     2G
      0x8000_0000     0x9fff_ffff     PCI MEM                 512M
      0xc000_0000     0xdfff_ffff     Rapid IO                512M
      0xe000_0000     0xe000_ffff     CCSR                    1M
@@ -52,7 +56,9 @@ use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils.
        arch/ppc/configs/mpc8540_ads_defconfig
        arch/ppc/configs/mpc8560_ads_defconfig
 
+
 3. DEFINITIONS AND COMPILATION
+
 3.1 Explanation on NEW definitions in include/configs/MPC8540ADS.h and include/
     configs/MPC8560ADS.h
     CONFIG_BOOKE            BOOKE(e.g. Motorola MPC85xx, IBM 440, etc)
@@ -74,7 +80,6 @@ use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils.
                            if you can program the flash directly, undef this.
     Other than the above definitions, the rest in the config files are straightforward.
 
-
 3.2 Compilation
    export CROSS_COMPILE=your-cross-compile-prefix(assuming you're using BASH shell)
    cd u-boot
@@ -82,7 +87,9 @@ use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils.
    make MPC8560ADS_config (or make MPC8540ADS_config)
    make
 
+
 4.  Notes:
+
 4.1 When connecting with kermit, the following commands must be present.in
    your .kermrc file. These are especially important when booting as
    MPC8560, as the serial console will not work without them:
@@ -93,7 +100,6 @@ set handshake none
 set flow-control none
 robust
 
-   
 4.2 Sometimes after U-Boot is up, the 'tftp' won't work well with TSEC ethernet. If that
    happens, you can try the following steps to make network work:
    MPC8560ADS>tftp 1000000 pImage
@@ -103,9 +109,9 @@ robust
    >1
    >. (to quit this memory operation)
    MPC8560ADS>tftp 1000000 pImage
-4.3 If you're one of the early developers using the Rev1 8540/8560 chips, please use U-Boot 
-   1.0.0, as the newer silicon will only support Rev2 and future revisions of 8540/8560.
 
+4.3 If you're one of the early developers using the Rev1 8540/8560 chips, please use U-Boot
+   1.0.0, as the newer silicon will only support Rev2 and future revisions of 8540/8560.
 
 4.4 Reflash U-boot Image using U-boot
 
@@ -116,6 +122,7 @@ robust
 
 
 5. Screen dump:
+
 5.1 MPC8540ADS board
 U-Boot 1.0.0-pre (Oct 15 2003 - 13:40:33)
 
index 7a4dfe1ec8cb4cf002f5a88af03b3dce3945fab5..877753ecfba54106d4948112b66c32fe99656b31 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 /*
- *  Definitions for Configuring the monitor commands
+ * Definitions for Configuring the monitor commands
  */
 #ifndef _CMD_CONFIG_H
 #define _CMD_CONFIG_H
 #define CFG_CMD_SPI    0x0000100000000000U     /* SPI utility                  */
 #define CFG_CMD_FDOS   0x0000200000000000U     /* Floppy DOS support           */
 #define CFG_CMD_VFD    0x0000400000000000U     /* VFD support (TRAB)           */
-#define CFG_CMD_NAND   0x0000800000000000U     /* NAND support                 */
+#define CFG_CMD_NAND   0x0000800000000000U     /* NAND support                 */
 #define CFG_CMD_BMP    0x0001000000000000U     /* BMP support                  */
-#define CFG_CMD_PORTIO 0x0002000000000000U     /* Port I/O                     */
+#define CFG_CMD_PORTIO 0x0002000000000000U     /* Port I/O                     */
 #define CFG_CMD_PING   0x0004000000000000U     /* ping support                 */
 #define CFG_CMD_MMC    0x0008000000000000U     /* MMC support                  */
 #define CFG_CMD_FAT    0x0010000000000000U     /* FAT support                  */
-#define CFG_CMD_IMLS   0x0020000000000000U     /* List all found images        */
+#define CFG_CMD_IMLS   0x0020000000000000U     /* List all found images        */
 #define CFG_CMD_ITEST  0x0040000000000000U     /* Integer (and string) test    */
 #define CFG_CMD_NFS    0x0080000000000000U     /* NFS support                  */
-#define CFG_CMD_REISER  0x0100000000000000U     /* Reiserfs support            */
+#define CFG_CMD_REISER 0x0100000000000000U     /* Reiserfs support             */
 #define CFG_CMD_CDP    0x0200000000000000U     /* Cisco Discovery Protocol     */
+#define CFG_CMD_XIMG   0x0400000000000000U     /* Load part of Multi Image     */
 
 #define CFG_CMD_ALL    0xFFFFFFFFFFFFFFFFU     /* ALL commands                 */
 
 #define CONFIG_BOOTP_BOOTFILESIZE      0x00000020
 #define CONFIG_BOOTP_DNS               0x00000040
 #define CONFIG_BOOTP_DNS2              0x00000080
-#define CONFIG_BOOTP_SEND_HOSTNAME      0x00000100
+#define CONFIG_BOOTP_SEND_HOSTNAME     0x00000100
 
 #define CONFIG_BOOTP_VENDOREX          0x80000000
 
index e2dc343273686eaecc94663bf05be8077ea3c325..2d212c91c5fd0c75f78f9e03dc8f99315399ba51 100644 (file)
                                 CFG_CMD_SCSI   | \
                                 CFG_CMD_VFD    | \
                                 CFG_CMD_USB    | \
+                                CFG_CMD_XIMG   | \
                                 __SPI_CMD_OFF  ) )
 
 
index 358f7f4b91c4860e9c8c4d367582ebdc43582efa..b758e94e793178847011cf1c99fec0443fc6f0a1 100644 (file)
                                 CFG_CMD_SCSI   | \
                                 CFG_CMD_SPI    | \
                                 CFG_CMD_VFD    | \
-                                CFG_CMD_USB    ) )
+                                CFG_CMD_USB    | \
+                                CFG_CMD_XIMG   ) )
 
 
 #include <cmd_confdefs.h>
index db8c05a98f0faa9c4ecc5b29ba5c3564846b3833..b2e86c84a1929afa0420158ade6877812f2494d2 100644 (file)
                                 CFG_CMD_SCSI   | \
                                 CFG_CMD_SPI    | \
                                 CFG_CMD_VFD    | \
-                                CFG_CMD_USB    ) )
+                                CFG_CMD_USB    | \
+                                CFG_CMD_XIMG   ) )
 
 
 #include <cmd_confdefs.h>
index 49ffb931e4f444aeb0e129cb29fe569ab0aac0fa..17402f0c9f52f617677fae0168ba5ae771c9115e 100644 (file)
                                             & ~CFG_CMD_SCSI    \
                                             & ~CFG_CMD_SPI     \
                                             & ~CFG_CMD_USB     \
-                                            & ~CFG_CMD_VFD     )
+                                            & ~CFG_CMD_VFD     \
+                                            & ~CFG_CMD_XIMG    )
 
 #if CONFIG_LANTEC >= 2
 #define        CONFIG_RTC_MPC8xx               /* use internal RTC of MPC8xx   */
index 7bd0d8e88d13c62cda4277ef13edc45766ce2e10..626f23b6a436c28ab32f3446c4ea146183e38bf4 100644 (file)
                                 CFG_CMD_NAND   | \
                                 CFG_CMD_PCI    | \
                                 CFG_CMD_PCMCIA | \
-                               CFG_CMD_REISER  | \
+                                CFG_CMD_REISER | \
                                 CFG_CMD_SCSI   | \
                                 CFG_CMD_SPI    | \
                                 CFG_CMD_USB    | \
-                                CFG_CMD_VFD
+                                CFG_CMD_VFD    | \
+                                CFG_CMD_XIMG
 
 #if CONFIG_ADSTYPE >= CFG_PQ2FADS
 #define CONFIG_COMMANDS                (CFG_CMD_ALL & ~( \
index 86a5986cf8b5b38b7af47759f8b74bc6129b34e7..a4018f8ceddd45ec273a4634a8108a1c5cc41f45 100644 (file)
                                 CFG_CMD_MMC    | \
                                 CFG_CMD_NAND   | \
                                 CFG_CMD_PCMCIA | \
-                               CFG_CMD_REISER  | \
+                                CFG_CMD_REISER | \
                                 CFG_CMD_SCSI   | \
                                 CFG_CMD_SPI    | \
                                 CFG_CMD_VFD    | \
-                                CFG_CMD_USB    ) )
+                                CFG_CMD_USB    | \
+                                CFG_CMD_XIMG   ) )
 
 /* Define a command string that is automatically executed when no character
  * is read on the console interface withing "Boot Delay" after reset.
index 1666d646c0af98676a2ab5cb16bd84ec3f96b5d3..3592290d508321cbe4d68989562792f411161e7d 100644 (file)
                                ~CFG_CMD_PCMCIA & \
                                ~CFG_CMD_REISER & \
                                ~CFG_CMD_SCSI   & \
-                               ~CFG_CMD_SETGETDCR      & \
+                               ~CFG_CMD_SETGETDCR & \
                                ~CFG_CMD_SPI    & \
                                ~CFG_CMD_USB    & \
-                               ~CFG_CMD_VFD    )
+                               ~CFG_CMD_VFD    & \
+                               ~CFG_CMD_XIMG   )
 
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>
index 9746b64b0b2029f39eb4a0844ecec529fb8edfc7..7294561b0b74d3339b15a349f5d103e3aa9a88a6 100644 (file)
@@ -93,7 +93,7 @@
 #define        CONFIG_CLOCKS_IN_MHZ    1       /* clocks passsed to Linux in MHz */
 
 
-#define CONFIG_COMMANDS        (CFG_CMD_ALL & ~CFG_CMD_NONSTD | CFG_CMD_ELF)
+#define CONFIG_COMMANDS        ((CFG_CMD_ALL & ~CFG_CMD_NONSTD) | CFG_CMD_ELF)
 
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>
index 03331d6c03ff85e1c9a793c21f369cd3e208d6ef..d3c8eb9c0c57a6f1fe38e273ddd3b02bd3b70423 100644 (file)
                                 CFG_CMD_SCSI   | \
                                 CFG_CMD_SPI    | \
                                 CFG_CMD_USB    | \
-                                CFG_CMD_VFD    ) )
+                                CFG_CMD_VFD    | \
+                                CFG_CMD_XIMG   ) )
 
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>
index 274bd7d17d7823d0947c41b88821ea8158580971..d8db530e14d983607076b7400756a0a6b32833a9 100644 (file)
                                        ~CFG_CMD_DCR    & \
                                        ~CFG_CMD_DHCP   & \
                                        ~CFG_CMD_DOC    & \
+                                       ~CFG_CMD_DTT    & \
                                        ~CFG_CMD_EEPROM & \
                                        ~CFG_CMD_FDC    & \
                                        ~CFG_CMD_FDOS   & \
                                        ~CFG_CMD_NAND   & \
                                        ~CFG_CMD_PCI    & \
                                        ~CFG_CMD_PCMCIA & \
-                                       ~CFG_CMD_SCSI   & \
                                        ~CFG_CMD_REISER & \
+                                       ~CFG_CMD_SCSI   & \
                                        ~CFG_CMD_SPI    & \
                                        ~CFG_CMD_USB    & \
                                        ~CFG_CMD_VFD    & \
-                                       ~CFG_CMD_DTT )
+                                       ~CFG_CMD_XIMG   )
 
 /* Where do the internal registers live? */
 #define CFG_IMMR               0xF0000000
index 75f52b5a52e70d773dab844c64d44c71a898376d..6f19909614e780b5ad0a9f5db6a20d8986f6fece 100644 (file)
                                        CFG_CMD_REISER  | \
                                        CFG_CMD_SCSI    | \
                                        CFG_CMD_SPI     | \
-                                       CFG_CMD_VFD     ) )
+                                       CFG_CMD_VFD     | \
+                                       CFG_CMD_XIMG    ) )
 
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>