summaryrefslogtreecommitdiff
path: root/board/mpl
diff options
context:
space:
mode:
authorwdenk <wdenk>2003-12-07 18:32:37 +0000
committerwdenk <wdenk>2003-12-07 18:32:37 +0000
commita2663ea4fc9d18cb8000c97ed92c3c668eda8e04 (patch)
tree9eb328b497d6f482e5571635fa00b1d0cae5b185 /board/mpl
parentef5a9672c778e22ecb522db625b5df78ea40ed23 (diff)
downloadu-boot-imx-a2663ea4fc9d18cb8000c97ed92c3c668eda8e04.zip
u-boot-imx-a2663ea4fc9d18cb8000c97ed92c3c668eda8e04.tar.gz
u-boot-imx-a2663ea4fc9d18cb8000c97ed92c3c668eda8e04.tar.bz2
* Patches by David Müller, 14 Nov 2003:
- board/mpl/common/common_util.c * implement support for BZIP2 compressed images * various cleanups (printf -> puts, ...) - board/mpl/common/flash.c * report correct errors to upper layers * check the erase fail and VPP low bits in status reg - board/mpl/vcma9/cmd_vcma9.c - board/mpl/vcma9/flash.c * various cleanups (printf -> puts, ...) - common/cmd_usb.c * fix typo in comment - cpu/arm920t/usb_ohci.c * support for S3C2410 is missing in #if line - drivers/cs8900.c * reinit some registers in case of error (cable missing, ...) - fs/fat/fat.c * support for USB/MMC devices is missing in #if line - include/configs/MIP405.h - include/configs/PIP405.h * enable BZIP2 support * enlarge malloc space to 1MiB because of BZIP2 support - include/configs/VCMA9.h * enable BZIP2 support * enlarge malloc space to 1MiB because of BZIP2 support * enable USB support - lib_arm/armlinux.c * change calling convention of ARM Linux kernel as described on http://www.arm.linux.org.uk/developer/booting.php * Patch by Thomas Lange, 14 Nov 2003: Split dbau1x00 into dbau1000, dbau1100 and dbau1500 configs to support all these AMD boards. * Patch by Thomas Lange, 14 Nov 2003: Workaround for mips au1x00 physical memory accesses (the au1x00 uses a 36 bit bus internally and cannot access physical memory directly. Use the uncached SDRAM address instead of the physical one.)
Diffstat (limited to 'board/mpl')
-rw-r--r--board/mpl/common/common_util.c188
-rw-r--r--board/mpl/common/flash.c29
-rw-r--r--board/mpl/vcma9/cmd_vcma9.c10
-rw-r--r--board/mpl/vcma9/config.mk2
-rw-r--r--board/mpl/vcma9/flash.c22
-rw-r--r--board/mpl/vcma9/vcma9.c4
6 files changed, 151 insertions, 104 deletions
diff --git a/board/mpl/common/common_util.c b/board/mpl/common/common_util.c
index 30dcdad..17871d2 100644
--- a/board/mpl/common/common_util.c
+++ b/board/mpl/common/common_util.c
@@ -31,6 +31,8 @@
#include <i2c.h>
#include <devices.h>
#include <pci.h>
+#include <malloc.h>
+#include <bzlib.h>
#ifdef CONFIG_PIP405
#include "../pip405/pip405.h"
@@ -41,73 +43,73 @@
#include <405gp_pci.h>
#endif
-extern int gunzip (void *, int, unsigned char *, int *);
-extern int mem_test(unsigned long start, unsigned long ramsize, int quiet);
+extern int gunzip(void *, int, uchar *, int *);
+extern int mem_test(ulong start, ulong ramsize, int quiet);
-#define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */
-#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
-#define IMAGE_SIZE 0x80000
-#elif defined(CONFIG_VCMA9)
-#define IMAGE_SIZE 0x40000 /* ugly, but it works for now */
-#endif
+#define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */
+#define IMAGE_SIZE CFG_MONITOR_LEN /* ugly, but it works for now */
extern flash_info_t flash_info[]; /* info for FLASH chips */
static image_header_t header;
-int mpl_prg(unsigned long src,unsigned long size)
+static int
+mpl_prg(uchar *src, ulong size)
{
- unsigned long start;
+ ulong start;
flash_info_t *info;
- int i,rc;
+ int i, rc;
#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
char *copystr = (char *)src;
- unsigned long *magic = (unsigned long *)src;
+ ulong *magic = (ulong *)src;
#endif
info = &flash_info[0];
#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
- if(ntohl(magic[0]) != IH_MAGIC) {
- printf("Bad Magic number\n");
+ if (ntohl(magic[0]) != IH_MAGIC) {
+ puts("Bad Magic number\n");
return -1;
}
/* some more checks before we delete the Flash... */
/* Checking the ISO_STRING prevents to program a
* wrong Firmware Image into the flash.
*/
- i=4; /* skip Magic number */
- while(1) {
- if(strncmp(&copystr[i],"MEV-",4)==0)
+ i = 4; /* skip Magic number */
+ while (1) {
+ if (strncmp(&copystr[i], "MEV-", 4) == 0)
break;
- if(i++>=0x100) {
- printf("Firmware Image for unknown Target\n");
+ if (i++ >= 0x100) {
+ puts("Firmware Image for unknown Target\n");
return -1;
}
}
/* we have the ISO STRING, check */
- if(strncmp(&copystr[i],CONFIG_ISO_STRING,sizeof(CONFIG_ISO_STRING)-1)!=0) {
- printf("Wrong Firmware Image: %s\n",&copystr[i]);
+ if (strncmp(&copystr[i], CONFIG_ISO_STRING, sizeof(CONFIG_ISO_STRING)-1) != 0) {
+ printf("Wrong Firmware Image: %s\n", &copystr[i]);
return -1;
}
start = 0 - size;
- for(i=info->sector_count-1;i>0;i--)
- {
+ for (i = info->sector_count-1; i > 0; i--) {
info->protect[i] = 0; /* unprotect this sector */
- if(start>=info->start[i])
- break;
+ if (start >= info->start[i])
+ break;
}
/* set-up flash location */
/* now erase flash */
printf("Erasing at %lx (sector %d) (start %lx)\n",
start,i,info->start[i]);
- flash_erase (info, i, info->sector_count-1);
+ if ((rc = flash_erase (info, i, info->sector_count-1)) != 0) {
+ puts("ERROR ");
+ flash_perror(rc);
+ return (1);
+ }
+
#elif defined(CONFIG_VCMA9)
start = 0;
- for (i = 0; i <info->sector_count; i++)
- {
+ for (i = 0; i <info->sector_count; i++) {
info->protect[i] = 0; /* unprotect this sector */
if (size < info->start[i])
break;
@@ -116,73 +118,113 @@ int mpl_prg(unsigned long src,unsigned long size)
/* now erase flash */
printf("Erasing at %lx (sector %d) (start %lx)\n",
start,0,info->start[0]);
- flash_erase (info, 0, i);
+ if ((rc = flash_erase (info, 0, i)) != 0) {
+ puts("ERROR ");
+ flash_perror(rc);
+ return (1);
+ }
#endif
printf("flash erased, programming from 0x%lx 0x%lx Bytes\n",src,size);
- if ((rc = flash_write ((uchar *)src, start, size)) != 0) {
- puts ("ERROR ");
- flash_perror (rc);
+ if ((rc = flash_write (src, start, size)) != 0) {
+ puts("ERROR ");
+ flash_perror(rc);
return (1);
}
- puts ("OK programming done\n");
+ puts("OK programming done\n");
return 0;
}
-int mpl_prg_image(unsigned long ld_addr)
+static int
+mpl_prg_image(uchar *ld_addr)
{
- unsigned long data,len,checksum;
- image_header_t *hdr=&header;
+ unsigned long len, checksum;
+ uchar *data;
+ image_header_t *hdr = &header;
+ int rc;
+
/* Copy header so we can blank CRC field for re-calculation */
memcpy (&header, (char *)ld_addr, sizeof(image_header_t));
if (ntohl(hdr->ih_magic) != IH_MAGIC) {
- printf ("Bad Magic Number\n");
+ puts("Bad Magic Number\n");
return 1;
}
print_image_hdr(hdr);
if (hdr->ih_os != IH_OS_U_BOOT) {
- printf ("No U-Boot Image\n");
+ puts("No U-Boot Image\n");
return 1;
}
if (hdr->ih_type != IH_TYPE_FIRMWARE) {
- printf ("No Firmware Image\n");
+ puts("No Firmware Image\n");
return 1;
}
- data = (ulong)&header;
+ data = (uchar *)&header;
len = sizeof(image_header_t);
checksum = ntohl(hdr->ih_hcrc);
hdr->ih_hcrc = 0;
if (crc32 (0, (char *)data, len) != checksum) {
- printf ("Bad Header Checksum\n");
+ puts("Bad Header Checksum\n");
return 1;
}
data = ld_addr + sizeof(image_header_t);
len = ntohl(hdr->ih_size);
- printf ("Verifying Checksum ... ");
+ puts("Verifying Checksum ... ");
if (crc32 (0, (char *)data, len) != ntohl(hdr->ih_dcrc)) {
- printf ("Bad Data CRC\n");
+ puts("Bad Data CRC\n");
return 1;
}
- switch (hdr->ih_comp) {
- case IH_COMP_NONE:
- break;
- case IH_COMP_GZIP:
- printf (" Uncompressing ... ");
- if (gunzip ((void *)(data+0x100000), 0x400000,
- (uchar *)data, (int *)&len) != 0) {
- printf ("GUNZIP ERROR\n");
+ puts("OK\n");
+
+ if (hdr->ih_comp != IH_COMP_NONE) {
+ uchar *buf;
+ /* reserve space for uncompressed image */
+ if ((buf = malloc(IMAGE_SIZE)) == NULL) {
+ puts("Insufficient space for decompression\n");
return 1;
}
- data+=0x100000;
- break;
- default:
- printf (" Unimplemented compression type %d\n", hdr->ih_comp);
- return 1;
+
+ switch (hdr->ih_comp) {
+ case IH_COMP_GZIP:
+ puts("Uncompressing (GZIP) ... ");
+ rc = gunzip ((void *)(buf), IMAGE_SIZE, data, (int *)&len);
+ if (rc != 0) {
+ puts("GUNZIP ERROR\n");
+ free(buf);
+ return 1;
+ }
+ puts("OK\n");
+ break;
+#if CONFIG_BZIP2
+ case IH_COMP_BZIP2:
+ puts("Uncompressing (BZIP2) ... ");
+ {
+ uint retlen = IMAGE_SIZE;
+ rc = BZ2_bzBuffToBuffDecompress ((char *)(buf), &retlen,
+ (char *)data, len, 0, 0);
+ len = retlen;
+ }
+ if (rc != BZ_OK) {
+ printf ("BUNZIP2 ERROR: %d\n", rc);
+ free(buf);
+ return 1;
+ }
+ puts("OK\n");
+ break;
+#endif
+ default:
+ printf ("Unimplemented compression type %d\n", hdr->ih_comp);
+ free(buf);
+ return 1;
+ }
+
+ rc = mpl_prg(buf, len);
+ free(buf);
+ } else {
+ rc = mpl_prg(data, len);
}
-
- printf (" OK\n");
- return(mpl_prg(data,len));
+
+ return(rc);
}
@@ -199,20 +241,20 @@ void set_backup_values(int overwrite)
get_backup_values(&back);
if(!overwrite) {
if(strncmp(back.signature,"MPL\0",4)==0) {
- printf("Not possible to write Backup\n");
+ puts("Not possible to write Backup\n");
return;
}
}
memcpy(back.signature,"MPL\0",4);
i = getenv_r("serial#",back.serial_name,16);
if(i < 0) {
- printf("Not possible to write Backup\n");
+ puts("Not possible to write Backup\n");
return;
}
back.serial_name[16]=0;
i = getenv_r("ethaddr",back.eth_addr,20);
if(i < 0) {
- printf("Not possible to write Backup\n");
+ puts("Not possible to write Backup\n");
return;
}
back.eth_addr[20]=0;
@@ -334,7 +376,7 @@ void check_env(void)
}
else {
copy_old_env(oldsizes[i]);
- printf ("INFO: old environment ajusted, use saveenv\n");
+ puts("INFO: old environment ajusted, use saveenv\n");
}
}
else {
@@ -353,23 +395,23 @@ extern char *stdio_names[];
void show_stdio_dev(void)
{
/* Print information */
- printf ("In: ");
+ puts("In: ");
if (stdio_devices[stdin] == NULL) {
- printf ("No input devices available!\n");
+ puts("No input devices available!\n");
} else {
printf ("%s\n", stdio_devices[stdin]->name);
}
- printf ("Out: ");
+ puts("Out: ");
if (stdio_devices[stdout] == NULL) {
- printf ("No output devices available!\n");
+ puts("No output devices available!\n");
} else {
printf ("%s\n", stdio_devices[stdout]->name);
}
- printf ("Err: ");
+ puts("Err: ");
if (stdio_devices[stderr] == NULL) {
- printf ("No error devices available!\n");
+ puts("No error devices available!\n");
} else {
printf ("%s\n", stdio_devices[stderr]->name);
}
@@ -390,7 +432,7 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
if (strcmp(argv[2], "floppy") == 0) {
char *local_args[3];
extern int do_fdcboot (cmd_tbl_t *, int, int, char *[]);
- printf ("\nupdating bootloader image from floppy\n");
+ puts("\nupdating bootloader image from floppy\n");
local_args[0] = argv[0];
if(argc==4) {
local_args[1] = argv[3];
@@ -415,12 +457,12 @@ int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ld_addr=load_addr;
}
printf ("\nupdating bootloader image from memory at %lX\n",ld_addr);
- result=mpl_prg_image(ld_addr);
+ result=mpl_prg_image((uchar *)ld_addr);
return result;
}
if (strcmp(argv[2], "mps") == 0) {
- printf ("\nupdating bootloader image from MPS\n");
- result=mpl_prg(src,size);
+ puts("\nupdating bootloader image from MPS\n");
+ result=mpl_prg((uchar *)src,size);
return result;
}
}
diff --git a/board/mpl/common/flash.c b/board/mpl/common/flash.c
index e56e307..5f50200 100644
--- a/board/mpl/common/flash.c
+++ b/board/mpl/common/flash.c
@@ -543,7 +543,7 @@ int wait_for_DQ7(flash_info_t *info, int sect)
while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) {
if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
- return -1;
+ return ERR_TIMOUT;
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
@@ -551,12 +551,12 @@ int wait_for_DQ7(flash_info_t *info, int sect)
last = now;
}
}
- return 0;
+ return ERR_OK;
}
int intel_wait_for_DQ7(flash_info_t *info, int sect)
{
- ulong start, now, last;
+ ulong start, now, last, status;
volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[sect]);
start = get_timer (0);
@@ -564,7 +564,7 @@ int intel_wait_for_DQ7(flash_info_t *info, int sect)
while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) {
if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
- return -1;
+ return ERR_TIMOUT;
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
@@ -572,8 +572,11 @@ int intel_wait_for_DQ7(flash_info_t *info, int sect)
last = now;
}
}
- addr[0]=(FLASH_WORD_SIZE)0x00500050;
- return 0;
+ status = addr[0] & (FLASH_WORD_SIZE)0x00280028;
+ /* clear status register */
+ addr[0] = (FLASH_WORD_SIZE)0x00500050;
+ /* check status for block erase fail and VPP low */
+ return (status == 0 ? ERR_OK : ERR_NOT_ERASED);
}
/*-----------------------------------------------------------------------
@@ -584,7 +587,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[0]);
volatile FLASH_WORD_SIZE *addr2;
int flag, prot, sect, l_sect;
- int i;
+ int i, rcode = 0;
if ((s_first < 0) || (s_first > s_last)) {
@@ -634,7 +637,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
addr2[0] = (FLASH_WORD_SIZE)0x00500050; /* block erase */
for (i=0; i<50; i++)
udelay(1000); /* wait 1 ms */
- wait_for_DQ7(info, sect);
+ rcode |= wait_for_DQ7(info, sect);
}
else {
if((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL){
@@ -643,7 +646,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
intel_wait_for_DQ7(info, sect);
addr2[0] = (FLASH_WORD_SIZE)0x00200020; /* sector erase */
addr2[0] = (FLASH_WORD_SIZE)0x00D000D0; /* sector erase */
- intel_wait_for_DQ7(info, sect);
+ rcode |= intel_wait_for_DQ7(info, sect);
}
else {
addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
@@ -652,7 +655,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
addr[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
addr[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
addr2[0] = (FLASH_WORD_SIZE)0x00300030; /* sector erase */
- wait_for_DQ7(info, sect);
+ rcode |= wait_for_DQ7(info, sect);
}
}
l_sect = sect;
@@ -688,8 +691,10 @@ DONE:
addr = (FLASH_WORD_SIZE *)info->start[0];
addr[0] = (FLASH_WORD_SIZE)0x00F000F0; /* reset bank */
- printf (" done\n");
- return 0;
+ if (!rcode)
+ printf (" done\n");
+
+ return rcode;
}
diff --git a/board/mpl/vcma9/cmd_vcma9.c b/board/mpl/vcma9/cmd_vcma9.c
index 8df642d..44b4112 100644
--- a/board/mpl/vcma9/cmd_vcma9.c
+++ b/board/mpl/vcma9/cmd_vcma9.c
@@ -61,7 +61,7 @@ int do_vcma9(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 0;
}
#if defined(CONFIG_DRIVER_CS8900)
- if (strcmp(argv[1], "cs8900_eeprom") == 0) {
+ if (strcmp(argv[1], "cs8900") == 0) {
if (strcmp(argv[2], "read") == 0) {
uchar addr; ushort data;
@@ -102,12 +102,12 @@ int do_vcma9(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* write checksum word */
cs8900_e2prom_write(addr, (0 - csum) << 8);
} else {
- printf("\nplease defined 'ethaddr'\n");
+ puts("\nplease defined 'ethaddr'\n");
}
} else if (strcmp(argv[2], "dump") == 0) {
uchar addr = 0, endaddr, csum; ushort data;
- printf("Dump of CS8900 config device: ");
+ puts("Dump of CS8900 config device: ");
cs8900_e2prom_read(addr, &data);
if ((data & 0xE000) == 0xA000) {
endaddr = (data & 0x00FF) / 2;
@@ -119,9 +119,9 @@ int do_vcma9(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
printf("\nChecksum: %s", (csum == 0) ? "ok" : "wrong");
} else {
- printf("no valid config found");
+ puts("no valid config found");
}
- printf("\n");
+ puts("\n");
}
return 0;
diff --git a/board/mpl/vcma9/config.mk b/board/mpl/vcma9/config.mk
index 942d42e..3698c24 100644
--- a/board/mpl/vcma9/config.mk
+++ b/board/mpl/vcma9/config.mk
@@ -21,4 +21,4 @@
#TEXT_BASE = 0x30F80000
-TEXT_BASE = 0x33F80000
+TEXT_BASE = 0x33F00000
diff --git a/board/mpl/vcma9/flash.c b/board/mpl/vcma9/flash.c
index 829396b..35cf260 100644
--- a/board/mpl/vcma9/flash.c
+++ b/board/mpl/vcma9/flash.c
@@ -133,23 +133,23 @@ void flash_print_info (flash_info_t *info)
switch (info->flash_id & FLASH_VENDMASK)
{
case (AMD_MANUFACT & FLASH_VENDMASK):
- printf("AMD: ");
+ puts("AMD: ");
break;
default:
- printf("Unknown Vendor ");
+ puts("Unknown Vendor ");
break;
}
switch (info->flash_id & FLASH_TYPEMASK)
{
case (AMD_ID_LV400B & FLASH_TYPEMASK):
- printf("1x Amd29LV400BB (4Mbit)\n");
+ puts("1x Amd29LV400BB (4Mbit)\n");
break;
case (AMD_ID_LV800B & FLASH_TYPEMASK):
- printf("1x Amd29LV800BB (8Mbit)\n");
+ puts("1x Amd29LV800BB (8Mbit)\n");
break;
default:
- printf("Unknown Chip Type\n");
+ puts("Unknown Chip Type\n");
goto Done;
break;
}
@@ -157,17 +157,17 @@ void flash_print_info (flash_info_t *info)
printf(" Size: %ld MB in %d Sectors\n",
info->size >> 20, info->sector_count);
- printf(" Sector Start Addresses:");
+ puts(" Sector Start Addresses:");
for (i = 0; i < info->sector_count; i++)
{
if ((i % 5) == 0)
{
- printf ("\n ");
+ puts("\n ");
}
printf (" %08lX%s", info->start[i],
info->protect[i] ? " (RO)" : " ");
}
- printf ("\n");
+ puts("\n");
Done:
}
@@ -272,16 +272,16 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
goto outahere;
}
- printf("ok.\n");
+ puts("ok.\n");
}
else /* it was protected */
{
- printf("protected!\n");
+ puts("protected!\n");
}
}
if (ctrlc())
- printf("User Interrupt!\n");
+ puts("User Interrupt!\n");
outahere:
/* allow flash to settle - wait 10 ms */
diff --git a/board/mpl/vcma9/vcma9.c b/board/mpl/vcma9/vcma9.c
index 4664488..db98553 100644
--- a/board/mpl/vcma9/vcma9.c
+++ b/board/mpl/vcma9/vcma9.c
@@ -327,13 +327,13 @@ int last_stage_init(void)
/***************************************************************************
* some helping routines
*/
-
+#if !CONFIG_USB_KEYBOARD
int overwrite_console(void)
{
/* return TRUE if console should be overwritten */
return 0;
}
-
+#endif
/************************************************************************
* Print VCMA9 Info