提交 48abe7bf 编写于 作者: W wdenk

Patch by Robert Schwebel, 13 May 2004:

Add 'imgextract' command: extract one part of a multi file image.
上级 547b4cb2
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
Changes since U-Boot 1.1.1: 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: * Patches by Jon Loeliger, 11 May 2004:
Dynamically handle REV1 and REV2 MPC85xx parts. Dynamically handle REV1 and REV2 MPC85xx parts.
(Jon Loeliger, 10-May-2004). (Jon Loeliger, 10-May-2004).
......
/*
* (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 */
...@@ -5,10 +5,12 @@ Created 10/15/03 ...@@ -5,10 +5,12 @@ Created 10/15/03
----------------------------------------- -----------------------------------------
0. Toolchain 0. Toolchain
The Binutils in current ELDK toolchain will not support MPC85xx chip. You need The Binutils in ELDK toolchain 3.0 or earlier does not support the
use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils. MPC85xx chip. You need use the newest binutils-2.14.tar.bz2 from
http://ftp.gnu.org/gnu/binutils.
1. SWITCH SETTINGS & JUMPERS 1. SWITCH SETTINGS & JUMPERS
1.1 First, make sure the board default setting is consistent with the document 1.1 First, make sure the board default setting is consistent with the document
shipped with your board. Then apply the following changes: shipped with your board. Then apply the following changes:
SW3[1-6]="all OFF" (boot from 32bit flash, no boot sequence is used) 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. ...@@ -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" SW22[1-4]="OFF OFF ON OFF"
SW5[1-10[="ON ON OFF OFF OFF OFF OFF OFF OFF 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) 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 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 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 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 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 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 clock based on the on-board system clock(default 66MHz). Check the
document along with your board for details. document along with your board for details.
...@@ -52,7 +56,9 @@ use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils. ...@@ -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/mpc8540_ads_defconfig
arch/ppc/configs/mpc8560_ads_defconfig arch/ppc/configs/mpc8560_ads_defconfig
3. DEFINITIONS AND COMPILATION 3. DEFINITIONS AND COMPILATION
3.1 Explanation on NEW definitions in include/configs/MPC8540ADS.h and include/ 3.1 Explanation on NEW definitions in include/configs/MPC8540ADS.h and include/
configs/MPC8560ADS.h configs/MPC8560ADS.h
CONFIG_BOOKE BOOKE(e.g. Motorola MPC85xx, IBM 440, etc) 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. ...@@ -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. if you can program the flash directly, undef this.
Other than the above definitions, the rest in the config files are straightforward. Other than the above definitions, the rest in the config files are straightforward.
3.2 Compilation 3.2 Compilation
export CROSS_COMPILE=your-cross-compile-prefix(assuming you're using BASH shell) export CROSS_COMPILE=your-cross-compile-prefix(assuming you're using BASH shell)
cd u-boot cd u-boot
...@@ -82,7 +87,9 @@ use the newest binutils-2.14.tar.bz2 from http://ftp.gnu.org/gnu/binutils. ...@@ -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 MPC8560ADS_config (or make MPC8540ADS_config)
make make
4. Notes: 4. Notes:
4.1 When connecting with kermit, the following commands must be present.in 4.1 When connecting with kermit, the following commands must be present.in
your .kermrc file. These are especially important when booting as your .kermrc file. These are especially important when booting as
MPC8560, as the serial console will not work without them: MPC8560, as the serial console will not work without them:
...@@ -93,7 +100,6 @@ set handshake none ...@@ -93,7 +100,6 @@ set handshake none
set flow-control none set flow-control none
robust robust
4.2 Sometimes after U-Boot is up, the 'tftp' won't work well with TSEC ethernet. If that 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: happens, you can try the following steps to make network work:
MPC8560ADS>tftp 1000000 pImage MPC8560ADS>tftp 1000000 pImage
...@@ -103,10 +109,10 @@ robust ...@@ -103,10 +109,10 @@ robust
>1 >1
>. (to quit this memory operation) >. (to quit this memory operation)
MPC8560ADS>tftp 1000000 pImage MPC8560ADS>tftp 1000000 pImage
4.3 If you're one of the early developers using the Rev1 8540/8560 chips, please use U-Boot 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. 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 4.4 Reflash U-boot Image using U-boot
=> tftp 0 u-boot.bin => tftp 0 u-boot.bin
...@@ -116,6 +122,7 @@ robust ...@@ -116,6 +122,7 @@ robust
5. Screen dump: 5. Screen dump:
5.1 MPC8540ADS board 5.1 MPC8540ADS board
U-Boot 1.0.0-pre (Oct 15 2003 - 13:40:33) U-Boot 1.0.0-pre (Oct 15 2003 - 13:40:33)
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
#define CFG_CMD_NFS 0x0080000000000000U /* NFS support */ #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_CDP 0x0200000000000000U /* Cisco Discovery Protocol */
#define CFG_CMD_XIMG 0x0400000000000000U /* Load part of Multi Image */
#define CFG_CMD_ALL 0xFFFFFFFFFFFFFFFFU /* ALL commands */ #define CFG_CMD_ALL 0xFFFFFFFFFFFFFFFFU /* ALL commands */
......
...@@ -599,6 +599,7 @@ ...@@ -599,6 +599,7 @@
CFG_CMD_SCSI | \ CFG_CMD_SCSI | \
CFG_CMD_VFD | \ CFG_CMD_VFD | \
CFG_CMD_USB | \ CFG_CMD_USB | \
CFG_CMD_XIMG | \
__SPI_CMD_OFF ) ) __SPI_CMD_OFF ) )
......
...@@ -475,7 +475,8 @@ ...@@ -475,7 +475,8 @@
CFG_CMD_SCSI | \ CFG_CMD_SCSI | \
CFG_CMD_SPI | \ CFG_CMD_SPI | \
CFG_CMD_VFD | \ CFG_CMD_VFD | \
CFG_CMD_USB ) ) CFG_CMD_USB | \
CFG_CMD_XIMG ) )
#include <cmd_confdefs.h> #include <cmd_confdefs.h>
......
...@@ -484,7 +484,8 @@ ...@@ -484,7 +484,8 @@
CFG_CMD_SCSI | \ CFG_CMD_SCSI | \
CFG_CMD_SPI | \ CFG_CMD_SPI | \
CFG_CMD_VFD | \ CFG_CMD_VFD | \
CFG_CMD_USB ) ) CFG_CMD_USB | \
CFG_CMD_XIMG ) )
#include <cmd_confdefs.h> #include <cmd_confdefs.h>
......
...@@ -107,7 +107,8 @@ ...@@ -107,7 +107,8 @@
& ~CFG_CMD_SCSI \ & ~CFG_CMD_SCSI \
& ~CFG_CMD_SPI \ & ~CFG_CMD_SPI \
& ~CFG_CMD_USB \ & ~CFG_CMD_USB \
& ~CFG_CMD_VFD ) & ~CFG_CMD_VFD \
& ~CFG_CMD_XIMG )
#if CONFIG_LANTEC >= 2 #if CONFIG_LANTEC >= 2
#define CONFIG_RTC_MPC8xx /* use internal RTC of MPC8xx */ #define CONFIG_RTC_MPC8xx /* use internal RTC of MPC8xx */
......
...@@ -199,7 +199,8 @@ ...@@ -199,7 +199,8 @@
CFG_CMD_SCSI | \ CFG_CMD_SCSI | \
CFG_CMD_SPI | \ CFG_CMD_SPI | \
CFG_CMD_USB | \ CFG_CMD_USB | \
CFG_CMD_VFD CFG_CMD_VFD | \
CFG_CMD_XIMG
#if CONFIG_ADSTYPE >= CFG_PQ2FADS #if CONFIG_ADSTYPE >= CFG_PQ2FADS
#define CONFIG_COMMANDS (CFG_CMD_ALL & ~( \ #define CONFIG_COMMANDS (CFG_CMD_ALL & ~( \
......
...@@ -168,7 +168,8 @@ ...@@ -168,7 +168,8 @@
CFG_CMD_SCSI | \ CFG_CMD_SCSI | \
CFG_CMD_SPI | \ CFG_CMD_SPI | \
CFG_CMD_VFD | \ CFG_CMD_VFD | \
CFG_CMD_USB ) ) CFG_CMD_USB | \
CFG_CMD_XIMG ) )
/* Define a command string that is automatically executed when no character /* Define a command string that is automatically executed when no character
* is read on the console interface withing "Boot Delay" after reset. * is read on the console interface withing "Boot Delay" after reset.
......
...@@ -114,7 +114,8 @@ ...@@ -114,7 +114,8 @@
~CFG_CMD_SETGETDCR & \ ~CFG_CMD_SETGETDCR & \
~CFG_CMD_SPI & \ ~CFG_CMD_SPI & \
~CFG_CMD_USB & \ ~CFG_CMD_USB & \
~CFG_CMD_VFD ) ~CFG_CMD_VFD & \
~CFG_CMD_XIMG )
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h> #include <cmd_confdefs.h>
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
#define CONFIG_CLOCKS_IN_MHZ 1 /* clocks passsed to Linux in MHz */ #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) */ /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h> #include <cmd_confdefs.h>
......
...@@ -134,7 +134,8 @@ ...@@ -134,7 +134,8 @@
CFG_CMD_SCSI | \ CFG_CMD_SCSI | \
CFG_CMD_SPI | \ CFG_CMD_SPI | \
CFG_CMD_USB | \ CFG_CMD_USB | \
CFG_CMD_VFD ) ) CFG_CMD_VFD | \
CFG_CMD_XIMG ) )
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h> #include <cmd_confdefs.h>
......
...@@ -275,6 +275,7 @@ ...@@ -275,6 +275,7 @@
~CFG_CMD_DCR & \ ~CFG_CMD_DCR & \
~CFG_CMD_DHCP & \ ~CFG_CMD_DHCP & \
~CFG_CMD_DOC & \ ~CFG_CMD_DOC & \
~CFG_CMD_DTT & \
~CFG_CMD_EEPROM & \ ~CFG_CMD_EEPROM & \
~CFG_CMD_FDC & \ ~CFG_CMD_FDC & \
~CFG_CMD_FDOS & \ ~CFG_CMD_FDOS & \
...@@ -287,12 +288,12 @@ ...@@ -287,12 +288,12 @@
~CFG_CMD_NAND & \ ~CFG_CMD_NAND & \
~CFG_CMD_PCI & \ ~CFG_CMD_PCI & \
~CFG_CMD_PCMCIA & \ ~CFG_CMD_PCMCIA & \
~CFG_CMD_SCSI & \
~CFG_CMD_REISER & \ ~CFG_CMD_REISER & \
~CFG_CMD_SCSI & \
~CFG_CMD_SPI & \ ~CFG_CMD_SPI & \
~CFG_CMD_USB & \ ~CFG_CMD_USB & \
~CFG_CMD_VFD & \ ~CFG_CMD_VFD & \
~CFG_CMD_DTT ) ~CFG_CMD_XIMG )
/* Where do the internal registers live? */ /* Where do the internal registers live? */
#define CFG_IMMR 0xF0000000 #define CFG_IMMR 0xF0000000
......
...@@ -191,7 +191,8 @@ ...@@ -191,7 +191,8 @@
CFG_CMD_REISER | \ CFG_CMD_REISER | \
CFG_CMD_SCSI | \ CFG_CMD_SCSI | \
CFG_CMD_SPI | \ CFG_CMD_SPI | \
CFG_CMD_VFD ) ) CFG_CMD_VFD | \
CFG_CMD_XIMG ) )
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h> #include <cmd_confdefs.h>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册