Add 'imgextract' command: extract one part of a multi file image.
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).
--- /dev/null
+/*
+ * (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 */
-----------------------------------------
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)
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.
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
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)
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
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:
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
>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
5. Screen dump:
+
5.1 MPC8540ADS board
U-Boot 1.0.0-pre (Oct 15 2003 - 13:40:33)
*/
/*
- * 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
CFG_CMD_SCSI | \
CFG_CMD_VFD | \
CFG_CMD_USB | \
+ CFG_CMD_XIMG | \
__SPI_CMD_OFF ) )
CFG_CMD_SCSI | \
CFG_CMD_SPI | \
CFG_CMD_VFD | \
- CFG_CMD_USB ) )
+ CFG_CMD_USB | \
+ CFG_CMD_XIMG ) )
#include <cmd_confdefs.h>
CFG_CMD_SCSI | \
CFG_CMD_SPI | \
CFG_CMD_VFD | \
- CFG_CMD_USB ) )
+ CFG_CMD_USB | \
+ CFG_CMD_XIMG ) )
#include <cmd_confdefs.h>
& ~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 */
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 & ~( \
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.
~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>
#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>
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>
~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
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>