From: Stefan E. <se...@us...> - 2002-04-17 19:39:59
|
Update of /cvsroot/blob/blob/src/commands In directory usw-pr-cvs1:/tmp/cvs-serv6904 Modified Files: Makefile.am md5chk.c Added Files: dlfile.c ferase.c fwrite.c Log Message: - commands for: * flashing arbitary flash regions * erasing arbitary flash regions * downloading files to arbitary memory --- NEW FILE: dlfile.c --- /* * dlfile.c: command wrapper for xmodem/uuencode download to * arbitary memory loc * * Copyright (C) 2002 Stefan Eletzhofer <ste...@ww...> * * 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 * */ #ident "$Id: dlfile.c,v 1.1 2002/04/17 19:39:51 seletz Exp $" /********************************************************************** * Includes */ #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/main.h> #include <blob/errno.h> #include <blob/debug.h> #include <blob/types.h> #include <blob/serial.h> #include <blob/util.h> #include <blob/uucodec.h> #include <blob/xmodem.h> #include <blob/md5.h> #include <blob/md5support.h> /********************************************************************** * defines */ /* this will send a cold shiver through erik's spine ... */ #define ERR( x ) { ret = x; goto DONE; } extern blob_status_t blob_status; /********************************************************************* * dlfile * * AUTOR: Stefan Eletzhofer * REVISED: * * download a file to a memory location. Does also print a md5 * checksum of the downloaded data. * */ int dlfile_cmd( int argc, char *argv[] ) { int ret = 0; u32 address, len; u32 digest; if ( argc < 3 ) ERR( -EINVAL ); ret = strtou32(argv[1], &address); if ( ret < 0 ) ERR( -EINVAL ); ret = strtou32(argv[2], &len); if ( ret < 0 ) ERR( -EINVAL ); dprintf("adr=0x%08x, len=0x%08x\n", address, len ); #if defined(CONFIG_XMODEM_SUPPORT) printf( "XMODEM download\n" ); #else printf( "UUENCODE download\n" ); #endif /* switch terminal speed if necessary */ if (blob_status.terminalSpeed != blob_status.downloadSpeed) { SerialOutputString( "Switch to download speed, please.\n" ); SerialOutputString("You have 60 seconds to start downloading.\n"); serial_init(blob_status.downloadSpeed); } else { SerialOutputString("You have 60 seconds to start downloading.\n"); } /* download the data */ #if defined(CONFIG_XMODEM_SUPPORT) ret = XModemReceive( (char *)address, len ); #else ret = UUDecode((char *)address, len); #endif if ( ret == len ) { SerialOutputString("Received "); SerialOutputDec(ret); SerialOutputString(" (0x"); SerialOutputHex(ret); SerialOutputString(") bytes.\n"); ret = 0; } else { SerialOutputString("error during download\n"); } if (blob_status.terminalSpeed != blob_status.downloadSpeed) { SerialOutputString("\n(Please switch your terminal emulator back to terminal speed\n"); serial_init(blob_status.terminalSpeed); } /* do a md5 sum of the downloaded data */ md5_buffer( (const char *)address, len, &digest ); SerialOutputString("md5 checksum: "); print_md5_digest(&digest); serial_write( '\n' ); ret = 0; DONE: return ret; } char dlfile_help[] = "dlfile destination_address len\n\ndownload a file to memory\n"; --- NEW FILE: ferase.c --- /* * ferase.c: command wrapper for erasing arbitary flash * regions * * Copyright (C) 2002 Stefan Eletzhofer <ste...@ww...> * * 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 * */ #ident "$Id: ferase.c,v 1.1 2002/04/17 19:39:51 seletz Exp $" /********************************************************************** * Includes */ #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/errno.h> #include <blob/debug.h> #include <blob/types.h> #include <blob/serial.h> #include <blob/util.h> #include <blob/flash.h> /********************************************************************** * defines */ /* this will send a cold shiver through erik's spine ... */ #define ERR( x ) { ret = x; goto DONE; } /********************************************************************* * ferase_cmd * * AUTOR: SELETZ * REVISED: * * Command wrapper for low-level flash erase * */ int ferase_cmd( int argc, char *argv[] ) { int ret = 0; u32 dest = 0L; u32 len = 0L; if ( argc < 3 ) ERR( -EINVAL ); ret = strtou32( argv[1], &dest ); if ( ret < 0 ) ERR( -EINVAL ); ret = strtou32( argv[2], &len ); if ( ret < 0 ) ERR( -EINVAL ); if ( len & (0x3) ) { len = (len>>2) + 1; } else { len = len>>2; } dprintf( "start=0x%08x, len=0x%08x words\n", dest, len ); ret = flash_erase_region( (u32 *)dest, len ); DONE: return ret; } char ferase_help[] = "ferase srcadr destadr size(bytes)\n" "flash a memory region\n"; --- NEW FILE: fwrite.c --- /* * fwrite.c: command wrapper for writing arbitary flash * regions * * Copyright (C) 2002 Stefan Eletzhofer <ste...@ww...> * * 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 * */ #ident "$Id: fwrite.c,v 1.1 2002/04/17 19:39:51 seletz Exp $" /********************************************************************** * Includes */ #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/errno.h> #include <blob/debug.h> #include <blob/types.h> #include <blob/serial.h> #include <blob/util.h> #include <blob/flash.h> /********************************************************************** * defines */ /* this will send a cold shiver through erik's spine ... */ #define ERR( x ) { ret = x; goto DONE; } /********************************************************************* * fwrite_cmd * * AUTOR: SELETZ * REVISED: * * Command wrapper for low-level flash write access * */ int fwrite_cmd( int argc, char *argv[] ) { int ret = 0; u32 src = 0L; u32 dest = 0L; u32 len = 0L; if ( argc < 4 ) ERR( -EINVAL ); ret = strtou32( argv[1], &src ); if ( ret < 0 ) ERR( -EINVAL ); ret = strtou32( argv[2], &dest ); if ( ret < 0 ) ERR( -EINVAL ); ret = strtou32( argv[3], &len ); if ( ret < 0 ) ERR( -EINVAL ); if ( len & (0x3) ) { len = (len>>2) + 1; } else { len = len>>2; } ret = flash_write_region( (u32 *)dest, (u32*)src, len ); DONE: return ret; } char fwrite_help[] = "fwrite srcadr destadr size(bytes)\n" "flash a memory region\n"; Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/commands/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Makefile.am 17 Apr 2002 18:36:07 -0000 1.4 +++ Makefile.am 17 Apr 2002 19:39:50 -0000 1.5 @@ -30,6 +30,9 @@ changebit.c \ dummy.c \ dump.c \ + dlfile.c \ + ferase.c \ + fwrite.c \ memcpy.c \ md5chk.c \ peek.c \ Index: md5chk.c =================================================================== RCS file: /cvsroot/blob/blob/src/commands/md5chk.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- md5chk.c 17 Apr 2002 18:35:35 -0000 1.1 +++ md5chk.c 17 Apr 2002 19:39:51 -0000 1.2 @@ -1,7 +1,7 @@ /* * md5chk.c: command wrapper for md5 checks * - * Copyright (C) 2001 Stefan Eletzhofer <ste...@ww...> + * Copyright (C) 2002 Stefan Eletzhofer <ste...@ww...> * * 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 @@ -48,12 +48,12 @@ /********************************************************************* - * Poke + * md5chk * * AUTOR: Stefan Eletzhofer * REVISED: * - * Poke values to memory + * calculate md5 hash of a memory region * */ int md5chk_cmd( int argc, char *argv[] ) |
From: Erik M. <J.A...@it...> - 2002-04-18 22:37:22
|
On Wed, Apr 17, 2002 at 12:39:53PM -0700, Stefan Eletzhofer wrote: > Update of /cvsroot/blob/blob/src/commands > In directory usw-pr-cvs1:/tmp/cvs-serv6904 > > Modified Files: > Makefile.am md5chk.c > Added Files: > dlfile.c ferase.c fwrite.c > Log Message: > - commands for: > * flashing arbitary flash regions > * erasing arbitary flash regions > * downloading files to arbitary memory Erasing arbitrary flash regions is dangerous. I think you'd rather want to erase a flash partition instead of a region. Flash commands belong in src/blob, not in src/commands. Diag can't write to flash anyway, so there is no point in sharing the commands. > /********************************************************************* > * dlfile > * > * AUTOR: Stefan Eletzhofer > * REVISED: > * > * download a file to a memory location. Does also print a md5 > * checksum of the downloaded data. Don't do wild MD5 checks, only do it if the user explicitly asked for MD5 support with --enable-md5. Erik -- J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635 Fax: +31-15-2781843 Email: J.A...@it... WWW: http://www-ict.its.tudelft.nl/~erik/ |
From: Christopher H. <ch...@mu...> - 2002-04-18 22:57:33
|
Enabling MD5 digests for XMODEM downloads is quite likely to mislead people. Why? Because the MD5 digest of an XMODEM download won't correspond (is statistically unlikely to correspond) to the MD5 digest of the original file due to padding, unless the file size happens to be a multiple of the XMODEM block size (either 128 or 1 Ki bytes). -ch |