From: Stefan E. <se...@us...> - 2002-05-13 09:36:25
|
Update of /cvsroot/blob/blob/src/blob In directory usw-pr-cvs1:/tmp/cvs-serv29406 Modified Files: system3.c Log Message: - sysupd command updated Index: system3.c =================================================================== RCS file: /cvsroot/blob/blob/src/blob/system3.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- system3.c 10 May 2002 16:04:23 -0000 1.20 +++ system3.c 13 May 2002 09:36:22 -0000 1.21 @@ -51,6 +51,7 @@ #include <blob/generic_io.h> #include <blob/pcmcia.h> +#include <blob/cf.h> #include <blob/ide.h> #include <blob/tar.h> @@ -72,21 +73,6 @@ #define SET(reg,bit) ((reg) |= (1<<(bit))) #define RST(reg,bit) ((reg) &= ~(1<<(bit))) -/***************************************************************** - * CF Flash register definitions - */ -/* config register - offset 0 */ -#define CF_REG_CFG (0x00) -#define CF_CFG_SRST (0x80) -#define CF_CFG_LVLREQ (0x40) -#define CF_CFG_MMAP (0x00) -#define CF_CFG_IOMAP (0x01) -#define CF_CFG_IO_IDE0 (0x02) -#define CF_CFG_IO_IDE1 (0x03) - -/* config status register - offset 2 */ -#define CF_REG_CFGSTAT (0x02) - #define SYSTEM3_DEBUG 1 #if SYSTEM3_DEBUG @@ -112,7 +98,7 @@ */ #if SYSTEM3_DEBUG -static int sys3_dbg = 2; +static int sys3_dbg = 1; #else static int sys3_dbg = 0; #endif @@ -177,7 +163,7 @@ next: sizeof(blob_partition_t), offset: CONFIG_FLASH_BASE, size: CONFIG_FLASH_LEN, - name: "config", + name: "config.tar", flags: 0 }, { @@ -412,127 +398,53 @@ //sa1111_init(); return 0; } +#endif +#if defined(CONFIG_CMD_SYSUPDATE) +/********************************************************************** + * sysupd - update complete system. Flashes + * blob, config, kernel, initrd and cramfs images. + */ -#if 0 -/***************************************************************** - * pcmcia_test - test PCMCIA, CF and IDE +/* update_umage - Read image "image" from TAR io driver and flash it + * into a BLOB partition */ -static int pcmcia_test( int argc, char *argv[] ) +static int update_image( char *image ) { - int ret = 0; - int slot = 1; /* default CF */ - u32 slot_base; - u32 slot_attr; - u16 cfg_reg; - ide_drive_t drive; - int sec; - u8 cfgvalue; - u8 value; - - char buffer[4096]; + int ret; - ret = pcmcia_init(); - if ( ret != 0 ) ERR( -EINVAL ); + if ( !image ) + return -EINVAL; - if ( argc > 1 ) { - switch ( argv[1][0] ) { - case '0': - slot = 0; - break; - case '1': - slot = 1; - break; - } + /* select tar file */ + ret = io_configure( "TAR", image ); + if ( ret ) { + printf( "sysupd: can't find image '%s'. Skipping.\n", image ); + return -EINVAL; } - pcmcia_dbg_set( 5 ); - ide_dbg_set( 5 ); - - ret = pcmcia_slot_detect( slot ); - if ( !ret ) ERR( -EINVAL ); - - printf( "slot %d detected\n", slot ); - - ret = pcmcia_slot_enable( slot ); - if ( ret != 0 ) ERR( -EINVAL ); - - ret = pcmcia_slot_address_get( slot, &slot_base, &slot_attr ); - if ( ret != 0 ) ERR( -EINVAL ); - - ret = pcmcia_slot_reset( slot ); - if ( ret != 0 ) ERR( -EINVAL ); - - ret = pcmcia_cis_parse( slot ); - if ( ret != 0 ) ERR( -EINVAL ); - - ret = pcmcia_slot_cfg_reg_get( slot, &cfg_reg ); - if ( ret != 0 ) ERR( -EINVAL ); - printf( "slot %d config register: 0x%03x\n", slot, cfg_reg ); - - pcmcia_slot_attr_read( slot, CF_REG_CFG, &cfgvalue ); - printf( "slot %d config register: 0x%02x = 0x%02x\n", slot, CF_REG_CFG, cfgvalue ); - - pcmcia_slot_attr_read( slot, CF_REG_CFGSTAT, &value ); - printf( "slot %d config status register: 0x%02x = 0x%02x\n", slot, CF_REG_CFGSTAT, value ); - - /* reset CF card */ - pcmcia_slot_attr_write( slot, CF_REG_CFG, cfgvalue | CF_CFG_SRST ); - msleep(1); - pcmcia_slot_attr_write( slot, CF_REG_CFG, cfgvalue & (~CF_CFG_SRST) ); - pcmcia_slot_attr_read( slot, CF_REG_CFG, &cfgvalue ); - printf( "slot %d config register: 0x%02x = 0x%02x\n", slot, CF_REG_CFG, cfgvalue ); - - - /* configure for true ide mode */ - pcmcia_slot_attr_write( slot, CF_REG_CFG, cfgvalue | CF_CFG_IO_IDE0 ); - pcmcia_slot_attr_read( slot, CF_REG_CFG, &cfgvalue ); - printf( "slot %d config register: 0x%02x = 0x%02x\n", slot, CF_REG_CFG, cfgvalue ); - - pcmcia_slot_attr_read( slot, CF_REG_CFGSTAT, &value ); - printf( "slot %d config status register: 0x%02x = 0x%02x\n", slot, CF_REG_CFGSTAT, value ); - - printf( "slot %d enabled\n", slot ); - - ret = ide_init( &drive, (u32)slot_base ); - if ( ret != 0 ) ERR( -EINVAL ); - - ret = ide_reset( &drive ); - - ret = ide_identify_drive( &drive ); - if ( ret != 0 ) ERR( -EINVAL ); - - ret = ide_status_dump( &drive ); - if ( ret != 0 ) ERR( -EINVAL ); + /* select partition */ + ret = io_configure( "BLOB_PART", image ); + if ( ret ) { + printf( "sysupd: can't find flash partition '%s'. Skipping.\n", image ); + return -EINVAL; + } #if 1 - for ( sec=0; sec<10; sec++ ) { - ret = hd_read_mapped( &drive, sec, buffer ); - if ( ret != 0 ) ERR( -EINVAL ); - dumpmem( buffer, 512 ); + /* flash tha image, man! */ + ret = io_copy( "BLOB_PART", "TAR", 0 ); + if ( ret ) { + /* ouch! */ + printf( "sysupd: error updating image %s (%d).\n", image, ret ); + return ret; } +#else + DBG( 1, "%s: io_copy( BLOB_PART, TAR, 0 )\n", __FUNCTION__ ); #endif - ret = pcmcia_dump_stati(); - if ( ret != 0 ) ERR( -EINVAL ); - - ret = 0; -DONE: - if ( ret != 0 ) { - printf( "pcmciatest: ERROR: code %d\n", ret ); - } - return ret; + return 0; } -static char pcmciahelp[] = "pcmcia test\n"; -__commandlist(pcmcia_test, "pcmciatest", pcmciahelp); -#endif -#endif -#if defined(CONFIG_CMD_SYSUPDATE) -/********************************************************************** - * sysupd - update complete system. Flashes - * blob, config, kernel, initrd and cramfs images. - */ static int sysupd_cmd( int argc, char *argv[] ) { int ret; @@ -542,9 +454,31 @@ int i=0; char *source = "CF"; - if ( argc>1 ) - source = argv[1]; + argv++; + /* source io param */ + if ( argc>1 ) { + source = *argv; + argv++; + argc--; + } + + /* image list */ + if ( argc>1 ) { + char **ptr; + ptr = update_files; + while (argc && ptr ) { + *ptr = *argv; + DBG( 1, "image += '%s'\n", *ptr ); + + argc -= 1; + argv++; + ptr++; + } + *ptr = NULL; + } + + /* configure CF card if CF is source */ if ( strncmp( source, "CF", 2 ) == 0 ) { /* CF card is on slot 1 */ ret = io_configure( "CF", (void *)1 ); @@ -568,44 +502,22 @@ return ret; } + /* update all images in list */ while ( (image=update_files[i++]) != NULL ) { - /* select tar file */ - ret = io_configure( "TAR", image ); - if ( ret ) { - printf( "sysupd: can't find image '%s'. Skipping.\n", image ); - continue; - } - - /* select partition */ - ret = io_configure( "BLOB_PART", image ); - if ( ret ) { - printf( "sysupd: can't find flash partition '%s'. Skipping.\n", image ); - continue; - } - -#if 1 - /* flash tha image, man! */ - ret = io_copy( "BLOB_PART", "TAR", 0 ); - if ( ret ) { - /* ouch! */ - printf( "sysupd: error updating image %s (%d).\n", image, ret ); - return ret; - } -#else - DBG( 1, "%s: io_copy( BLOB_PART, TAR, 0 )\n", __FUNCTION__ ); -#endif - - printf( "sysupd: flashed image '%s'\n", image ); + ret = update_image( image ); + if ( ret == 0 ) + printf( "sysupd: flashed image '%s'\n", image ); } return 0; } -static char sysupd_help[] = "sysupd [CF|RAM]\n\nUpdate board firmware from CF card or RAM.\n" +static char sysupd_help[] = "sysupd [CF|RAM] [image [image]...]\n\nUpdate board firmware from CF card or RAM.\n" "You have to have a update CF card inserted (for CF updates) _or_ uploaded a\n" "update image to ram."; __commandlist(sysupd_cmd, "sysupd", sysupd_help); #endif +#if defined(IO_TEST) int io_cmd( int argc, char *argv[] ) { int ret; @@ -648,6 +560,7 @@ } static char io_help[] = "io test function\n"; __commandlist(io_cmd, "iotest", io_help); +#endif #if defined(CONFIG_GIO_BLOB_PARTITION) /********************************************************************** @@ -842,7 +755,7 @@ { u32 offset; - DBG( 1, "%s: dest=%p, src=%p, amount=%d, io=%p\n", __FUNCTION__, + DBG( 5, "%s: dest=%p, src=%p, amount=%d, io=%p\n", __FUNCTION__, dest, src, amount, io ); if ( !io || !dest ) @@ -851,7 +764,7 @@ offset = (u32)io->private_data; - DBG( 1, "%s: using offset %x.\n", __FUNCTION__, offset ); + DBG( 5, "%s: using offset %x.\n", __FUNCTION__, offset ); memcpy( dest, (unsigned char *)(offset + (u32)src), amount ); @@ -864,7 +777,7 @@ u32 offset; u32 adr; - DBG( 1, "%s: dest=%p, src=%p, amount=%d, io=%p\n", __FUNCTION__, + DBG( 5, "%s: dest=%p, src=%p, amount=%d, io=%p\n", __FUNCTION__, dest, src, amount, io ); if ( !io || !src ) @@ -872,7 +785,7 @@ offset = (u32)io->private_data; - DBG( 1, "%s: using offset %x.\n", __FUNCTION__, offset ); + DBG( 5, "%s: using offset %x.\n", __FUNCTION__, offset ); adr = (u32)dest + offset; @@ -887,7 +800,7 @@ __FUNCTION__, amount ); } - DBG( 1, "%s: adr=0x%08x, nwords=%d.\n", __FUNCTION__, + DBG( 5, "%s: adr=0x%08x, nwords=%d.\n", __FUNCTION__, adr, amount/4 + (amount%4?1:0)); return flash_write_region( (u32 *)adr, (u32*)src, amount/4 + (amount%4?1:0)); @@ -897,6 +810,7 @@ /***************************************************************** * misc utility funcs */ +#if 0 static char tohex(char b) { b = b & 0xf; @@ -904,7 +818,6 @@ return 'a' + (b - 10); } -#if 0 static void dumpmem(char *ptr, int len) { char line[80], chars[80], *p, b, *c, *end; |