Commit 48abe7bfab14c1e9bd4a9a1f9d2e094b6d16773c

Authored by wdenk
1 parent 547b4cb25e

Patch by Robert Schwebel, 13 May 2004:

Add 'imgextract' command: extract one part of a multi file image.

Showing 15 changed files with 193 additions and 28 deletions Side-by-side Diff

... ... @@ -2,6 +2,9 @@
2 2 Changes since U-Boot 1.1.1:
3 3 ======================================================================
4 4  
  5 +* Patch by Robert Schwebel, 13 May 2004:
  6 + Add 'imgextract' command: extract one part of a multi file image.
  7 +
5 8 * Patches by Jon Loeliger, 11 May 2004:
6 9 Dynamically handle REV1 and REV2 MPC85xx parts.
7 10 (Jon Loeliger, 10-May-2004).
  1 +/*
  2 + * (C) Copyright 2000-2004
  3 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4 + *
  5 + * (C) Copyright 2003
  6 + * Kai-Uwe Bloem, Auerswald GmbH & Co KG, <linux-development@auerswald.de>
  7 + *
  8 + * See file CREDITS for list of people who contributed to this
  9 + * project.
  10 + *
  11 + * This program is free software; you can redistribute it and/or
  12 + * modify it under the terms of the GNU General Public License as
  13 + * published by the Free Software Foundation; either version 2 of
  14 + * the License, or (at your option) any later version.
  15 + *
  16 + * This program is distributed in the hope that it will be useful,
  17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19 + * GNU General Public License for more details.
  20 + *
  21 + * You should have received a copy of the GNU General Public License
  22 + * along with this program; if not, write to the Free Software
  23 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24 + * MA 02111-1307 USA
  25 + */
  26 +
  27 +#if (CONFIG_COMMANDS & CFG_CMD_XIMG)
  28 +
  29 +/*
  30 + * Multi Image extract
  31 + */
  32 +#include <common.h>
  33 +#include <command.h>
  34 +#include <image.h>
  35 +#include <asm/byteorder.h>
  36 +
  37 +int
  38 +do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  39 +{
  40 + ulong addr = load_addr, dest = 0;
  41 + ulong data, len, checksum;
  42 + ulong *len_ptr;
  43 + int i, verify, part = 0;
  44 + char pbuf[10], *s;
  45 + image_header_t header;
  46 +
  47 + s = getenv("verify");
  48 + verify = (s && (*s == 'n')) ? 0 : 1;
  49 +
  50 + if (argc > 1) {
  51 + addr = simple_strtoul(argv[1], NULL, 16);
  52 + }
  53 + if (argc > 2) {
  54 + part = simple_strtoul(argv[2], NULL, 16);
  55 + }
  56 + if (argc > 3) {
  57 + dest = simple_strtoul(argv[3], NULL, 16);
  58 + }
  59 +
  60 + printf("## Copying from image at %08lx ...\n", addr);
  61 +
  62 + /* Copy header so we can blank CRC field for re-calculation */
  63 + memmove(&header, (char *) addr, sizeof (image_header_t));
  64 +
  65 + if (ntohl(header.ih_magic) != IH_MAGIC) {
  66 + printf("Bad Magic Number\n");
  67 + return 1;
  68 + }
  69 +
  70 + data = (ulong) & header;
  71 + len = sizeof (image_header_t);
  72 +
  73 + checksum = ntohl(header.ih_hcrc);
  74 + header.ih_hcrc = 0;
  75 +
  76 + if (crc32(0, (char *) data, len) != checksum) {
  77 + printf("Bad Header Checksum\n");
  78 + return 1;
  79 + }
  80 +#ifdef DEBUG
  81 + print_image_hdr((image_header_t *) addr);
  82 +#endif
  83 +
  84 + data = addr + sizeof (image_header_t);
  85 + len = ntohl(header.ih_size);
  86 +
  87 + if (header.ih_type != IH_TYPE_MULTI) {
  88 + printf("Wrong Image Type for %s command\n", cmdtp->name);
  89 + return 1;
  90 + }
  91 +
  92 + if (header.ih_comp != IH_COMP_NONE) {
  93 + printf("Wrong Compression Type for %s command\n", cmdtp->name);
  94 + return 1;
  95 + }
  96 +
  97 + if (verify) {
  98 + printf(" Verifying Checksum ... ");
  99 + if (crc32(0, (char *) data, len) != ntohl(header.ih_dcrc)) {
  100 + printf("Bad Data CRC\n");
  101 + return 1;
  102 + }
  103 + printf("OK\n");
  104 + }
  105 +
  106 + len_ptr = (ulong *) data;
  107 +
  108 + data += 4; /* terminator */
  109 + for (i = 0; len_ptr[i]; ++i) {
  110 + data += 4;
  111 + if (argc > 2 && part > i) {
  112 + u_long tail;
  113 + len = ntohl(len_ptr[i]);
  114 + tail = len % 4;
  115 + data += len;
  116 + if (tail) {
  117 + data += 4 - tail;
  118 + }
  119 + }
  120 + }
  121 + if (argc > 2 && part >= i) {
  122 + printf("Bad Image Part\n");
  123 + return 1;
  124 + }
  125 + len = ntohl(len_ptr[part]);
  126 +
  127 + if (argc > 3) {
  128 + memcpy((char *) dest, (char *) data, len);
  129 + }
  130 +
  131 + sprintf(pbuf, "%8lx", data);
  132 + setenv("fileaddr", pbuf);
  133 + sprintf(pbuf, "%8lx", len);
  134 + setenv("filesize", pbuf);
  135 +
  136 + return 0;
  137 +}
  138 +
  139 +U_BOOT_CMD(imxtract, 4, 1, do_imgextract,
  140 + "imxtract- extract a part of a multi-image\n",
  141 + "addr part [dest]\n"
  142 + " - extract <part> from image at <addr> and copy to <dest>\n");
  143 +
  144 +#endif /* CONFIG_COMMANDS & CFG_CMD_XIMG */
doc/README.mpc85xxads
... ... @@ -5,10 +5,12 @@
5 5 -----------------------------------------
6 6  
7 7 0. Toolchain
8   -The Binutils in current ELDK toolchain will not support MPC85xx chip. You need
9   -use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils.
  8 +The Binutils in ELDK toolchain 3.0 or earlier does not support the
  9 +MPC85xx chip. You need use the newest binutils-2.14.tar.bz2 from
  10 +http://ftp.gnu.org/gnu/binutils.
10 11  
11 12 1. SWITCH SETTINGS & JUMPERS
  13 +
12 14 1.1 First, make sure the board default setting is consistent with the document
13 15 shipped with your board. Then apply the following changes:
14 16 SW3[1-6]="all OFF" (boot from 32bit flash, no boot sequence is used)
15 17  
... ... @@ -19,11 +21,13 @@
19 21 SW22[1-4]="OFF OFF ON OFF"
20 22 SW5[1-10[="ON ON OFF OFF OFF OFF OFF OFF OFF OFF"
21 23 J1 = "Enable Prog" (Make sure your flash is programmable for development)
  24 +
22 25 1.2 If you want to test PCI functionality with a 33Mhz PCI card, you will
23 26 have to change the system clock from the default 66Mhz to 33Mhz by
24 27 setting SW15[1]="OFF" and SW17[8]="OFF". After that you may also need
25 28 double your platform clock(SW6) because the system clock is now only
26   - half of its original value.
  29 + half of its original value.
  30 +
27 31 1.3 SW6 is a very important switch, it decides your platform clock and CPU
28 32 clock based on the on-board system clock(default 66MHz). Check the
29 33 document along with your board for details.
... ... @@ -35,7 +39,7 @@
35 39 between u-boot and linux kernel, you can customize it based on your
36 40 system requirements:
37 41  
38   - 0x0000_0000 0x7fff_ffff DDR 2G
  42 + 0x0000_0000 0x7fff_ffff DDR 2G
39 43 0x8000_0000 0x9fff_ffff PCI MEM 512M
40 44 0xc000_0000 0xdfff_ffff Rapid IO 512M
41 45 0xe000_0000 0xe000_ffff CCSR 1M
42 46  
... ... @@ -52,7 +56,9 @@
52 56 arch/ppc/configs/mpc8540_ads_defconfig
53 57 arch/ppc/configs/mpc8560_ads_defconfig
54 58  
  59 +
55 60 3. DEFINITIONS AND COMPILATION
  61 +
56 62 3.1 Explanation on NEW definitions in include/configs/MPC8540ADS.h and include/
57 63 configs/MPC8560ADS.h
58 64 CONFIG_BOOKE BOOKE(e.g. Motorola MPC85xx, IBM 440, etc)
... ... @@ -74,7 +80,6 @@
74 80 if you can program the flash directly, undef this.
75 81 Other than the above definitions, the rest in the config files are straightforward.
76 82  
77   -
78 83 3.2 Compilation
79 84 export CROSS_COMPILE=your-cross-compile-prefix(assuming you're using BASH shell)
80 85 cd u-boot
81 86  
... ... @@ -82,7 +87,9 @@
82 87 make MPC8560ADS_config (or make MPC8540ADS_config)
83 88 make
84 89  
  90 +
85 91 4. Notes:
  92 +
86 93 4.1 When connecting with kermit, the following commands must be present.in
87 94 your .kermrc file. These are especially important when booting as
88 95 MPC8560, as the serial console will not work without them:
... ... @@ -93,7 +100,6 @@
93 100 set flow-control none
94 101 robust
95 102  
96   -
97 103 4.2 Sometimes after U-Boot is up, the 'tftp' won't work well with TSEC ethernet. If that
98 104 happens, you can try the following steps to make network work:
99 105 MPC8560ADS>tftp 1000000 pImage
100 106  
... ... @@ -103,10 +109,10 @@
103 109 >1
104 110 >. (to quit this memory operation)
105 111 MPC8560ADS>tftp 1000000 pImage
106   -4.3 If you're one of the early developers using the Rev1 8540/8560 chips, please use U-Boot
  112 +
  113 +4.3 If you're one of the early developers using the Rev1 8540/8560 chips, please use U-Boot
107 114 1.0.0, as the newer silicon will only support Rev2 and future revisions of 8540/8560.
108 115  
109   -
110 116 4.4 Reflash U-boot Image using U-boot
111 117  
112 118 => tftp 0 u-boot.bin
... ... @@ -116,6 +122,7 @@
116 122  
117 123  
118 124 5. Screen dump:
  125 +
119 126 5.1 MPC8540ADS board
120 127 U-Boot 1.0.0-pre (Oct 15 2003 - 13:40:33)
121 128  
include/cmd_confdefs.h
... ... @@ -22,7 +22,7 @@
22 22 */
23 23  
24 24 /*
25   - * Definitions for Configuring the monitor commands
  25 + * Definitions for Configuring the monitor commands
26 26 */
27 27 #ifndef _CMD_CONFIG_H
28 28 #define _CMD_CONFIG_H
29 29  
30 30  
31 31  
32 32  
... ... @@ -78,17 +78,18 @@
78 78 #define CFG_CMD_SPI 0x0000100000000000U /* SPI utility */
79 79 #define CFG_CMD_FDOS 0x0000200000000000U /* Floppy DOS support */
80 80 #define CFG_CMD_VFD 0x0000400000000000U /* VFD support (TRAB) */
81   -#define CFG_CMD_NAND 0x0000800000000000U /* NAND support */
  81 +#define CFG_CMD_NAND 0x0000800000000000U /* NAND support */
82 82 #define CFG_CMD_BMP 0x0001000000000000U /* BMP support */
83   -#define CFG_CMD_PORTIO 0x0002000000000000U /* Port I/O */
  83 +#define CFG_CMD_PORTIO 0x0002000000000000U /* Port I/O */
84 84 #define CFG_CMD_PING 0x0004000000000000U /* ping support */
85 85 #define CFG_CMD_MMC 0x0008000000000000U /* MMC support */
86 86 #define CFG_CMD_FAT 0x0010000000000000U /* FAT support */
87   -#define CFG_CMD_IMLS 0x0020000000000000U /* List all found images */
  87 +#define CFG_CMD_IMLS 0x0020000000000000U /* List all found images */
88 88 #define CFG_CMD_ITEST 0x0040000000000000U /* Integer (and string) test */
89 89 #define CFG_CMD_NFS 0x0080000000000000U /* NFS support */
90   -#define CFG_CMD_REISER 0x0100000000000000U /* Reiserfs support */
  90 +#define CFG_CMD_REISER 0x0100000000000000U /* Reiserfs support */
91 91 #define CFG_CMD_CDP 0x0200000000000000U /* Cisco Discovery Protocol */
  92 +#define CFG_CMD_XIMG 0x0400000000000000U /* Load part of Multi Image */
92 93  
93 94 #define CFG_CMD_ALL 0xFFFFFFFFFFFFFFFFU /* ALL commands */
94 95  
... ... @@ -156,7 +157,7 @@
156 157 #define CONFIG_BOOTP_BOOTFILESIZE 0x00000020
157 158 #define CONFIG_BOOTP_DNS 0x00000040
158 159 #define CONFIG_BOOTP_DNS2 0x00000080
159   -#define CONFIG_BOOTP_SEND_HOSTNAME 0x00000100
  160 +#define CONFIG_BOOTP_SEND_HOSTNAME 0x00000100
160 161  
161 162 #define CONFIG_BOOTP_VENDOREX 0x80000000
162 163  
include/configs/ADNPESC1.h
... ... @@ -599,6 +599,7 @@
599 599 CFG_CMD_SCSI | \
600 600 CFG_CMD_VFD | \
601 601 CFG_CMD_USB | \
  602 + CFG_CMD_XIMG | \
602 603 __SPI_CMD_OFF ) )
603 604  
604 605  
include/configs/DK1C20.h
... ... @@ -475,7 +475,8 @@
475 475 CFG_CMD_SCSI | \
476 476 CFG_CMD_SPI | \
477 477 CFG_CMD_VFD | \
478   - CFG_CMD_USB ) )
  478 + CFG_CMD_USB | \
  479 + CFG_CMD_XIMG ) )
479 480  
480 481  
481 482 #include <cmd_confdefs.h>
include/configs/DK1S10.h
... ... @@ -484,7 +484,8 @@
484 484 CFG_CMD_SCSI | \
485 485 CFG_CMD_SPI | \
486 486 CFG_CMD_VFD | \
487   - CFG_CMD_USB ) )
  487 + CFG_CMD_USB | \
  488 + CFG_CMD_XIMG ) )
488 489  
489 490  
490 491 #include <cmd_confdefs.h>
include/configs/LANTEC.h
... ... @@ -107,7 +107,8 @@
107 107 & ~CFG_CMD_SCSI \
108 108 & ~CFG_CMD_SPI \
109 109 & ~CFG_CMD_USB \
110   - & ~CFG_CMD_VFD )
  110 + & ~CFG_CMD_VFD \
  111 + & ~CFG_CMD_XIMG )
111 112  
112 113 #if CONFIG_LANTEC >= 2
113 114 #define CONFIG_RTC_MPC8xx /* use internal RTC of MPC8xx */
include/configs/MPC8260ADS.h
... ... @@ -195,11 +195,12 @@
195 195 CFG_CMD_NAND | \
196 196 CFG_CMD_PCI | \
197 197 CFG_CMD_PCMCIA | \
198   - CFG_CMD_REISER | \
  198 + CFG_CMD_REISER | \
199 199 CFG_CMD_SCSI | \
200 200 CFG_CMD_SPI | \
201 201 CFG_CMD_USB | \
202   - CFG_CMD_VFD
  202 + CFG_CMD_VFD | \
  203 + CFG_CMD_XIMG
203 204  
204 205 #if CONFIG_ADSTYPE >= CFG_PQ2FADS
205 206 #define CONFIG_COMMANDS (CFG_CMD_ALL & ~( \
include/configs/MPC8266ADS.h
... ... @@ -164,11 +164,12 @@
164 164 CFG_CMD_MMC | \
165 165 CFG_CMD_NAND | \
166 166 CFG_CMD_PCMCIA | \
167   - CFG_CMD_REISER | \
  167 + CFG_CMD_REISER | \
168 168 CFG_CMD_SCSI | \
169 169 CFG_CMD_SPI | \
170 170 CFG_CMD_VFD | \
171   - CFG_CMD_USB ) )
  171 + CFG_CMD_USB | \
  172 + CFG_CMD_XIMG ) )
172 173  
173 174 /* Define a command string that is automatically executed when no character
174 175 * is read on the console interface withing "Boot Delay" after reset.
include/configs/RBC823.h
... ... @@ -111,10 +111,11 @@
111 111 ~CFG_CMD_PCMCIA & \
112 112 ~CFG_CMD_REISER & \
113 113 ~CFG_CMD_SCSI & \
114   - ~CFG_CMD_SETGETDCR & \
  114 + ~CFG_CMD_SETGETDCR & \
115 115 ~CFG_CMD_SPI & \
116 116 ~CFG_CMD_USB & \
117   - ~CFG_CMD_VFD )
  117 + ~CFG_CMD_VFD & \
  118 + ~CFG_CMD_XIMG )
118 119  
119 120 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
120 121 #include <cmd_confdefs.h>
include/configs/RPXClassic.h
... ... @@ -93,7 +93,7 @@
93 93 #define CONFIG_CLOCKS_IN_MHZ 1 /* clocks passsed to Linux in MHz */
94 94  
95 95  
96   -#define CONFIG_COMMANDS (CFG_CMD_ALL & ~CFG_CMD_NONSTD | CFG_CMD_ELF)
  96 +#define CONFIG_COMMANDS ((CFG_CMD_ALL & ~CFG_CMD_NONSTD) | CFG_CMD_ELF)
97 97  
98 98 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
99 99 #include <cmd_confdefs.h>
include/configs/ZPC1900.h
... ... @@ -134,7 +134,8 @@
134 134 CFG_CMD_SCSI | \
135 135 CFG_CMD_SPI | \
136 136 CFG_CMD_USB | \
137   - CFG_CMD_VFD ) )
  137 + CFG_CMD_VFD | \
  138 + CFG_CMD_XIMG ) )
138 139  
139 140 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
140 141 #include <cmd_confdefs.h>
include/configs/ep8260.h
... ... @@ -275,6 +275,7 @@
275 275 ~CFG_CMD_DCR & \
276 276 ~CFG_CMD_DHCP & \
277 277 ~CFG_CMD_DOC & \
  278 + ~CFG_CMD_DTT & \
278 279 ~CFG_CMD_EEPROM & \
279 280 ~CFG_CMD_FDC & \
280 281 ~CFG_CMD_FDOS & \
281 282  
282 283  
... ... @@ -287,12 +288,12 @@
287 288 ~CFG_CMD_NAND & \
288 289 ~CFG_CMD_PCI & \
289 290 ~CFG_CMD_PCMCIA & \
290   - ~CFG_CMD_SCSI & \
291 291 ~CFG_CMD_REISER & \
  292 + ~CFG_CMD_SCSI & \
292 293 ~CFG_CMD_SPI & \
293 294 ~CFG_CMD_USB & \
294 295 ~CFG_CMD_VFD & \
295   - ~CFG_CMD_DTT )
  296 + ~CFG_CMD_XIMG )
296 297  
297 298 /* Where do the internal registers live? */
298 299 #define CFG_IMMR 0xF0000000
include/configs/hymod.h
... ... @@ -191,7 +191,8 @@
191 191 CFG_CMD_REISER | \
192 192 CFG_CMD_SCSI | \
193 193 CFG_CMD_SPI | \
194   - CFG_CMD_VFD ) )
  194 + CFG_CMD_VFD | \
  195 + CFG_CMD_XIMG ) )
195 196  
196 197 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
197 198 #include <cmd_confdefs.h>