*** jtag-0.5.1/src/flash.c.orig	Wed Jun 23 14:02:44 2004
--- jtag-0.5.1/src/flash.c	Wed Jun 23 14:03:39 2004
***************
*** 293,306 ****
  		int bc = 0, bn = 0;
  		int block_no = find_block( cfi, adr );
  
! 		if (!erased[block_no]) {
  			flash_driver->unlock_block( cfi_array, adr );
  			printf( _("\nblock %d unlocked\n"), block_no );
  			printf( _("erasing block %d: %d\n"), block_no, flash_driver->erase_block( cfi_array, adr ) );
  			erased[block_no] = 1;
  		}
  
- 		bn = fread( b, 1, BSIZE, f );
  		for (bc = 0; bc < bn; bc += flash_driver->bus_width) {
  			int j;
  			printf( _("addr: 0x%08X"), adr );
--- 293,307 ----
  		int bc = 0, bn = 0;
  		int block_no = find_block( cfi, adr );
  
! 		bn = fread( b, 1, BSIZE, f );
! 
! 		if (bn && !erased[block_no]) {
  			flash_driver->unlock_block( cfi_array, adr );
  			printf( _("\nblock %d unlocked\n"), block_no );
  			printf( _("erasing block %d: %d\n"), block_no, flash_driver->erase_block( cfi_array, adr ) );
  			erased[block_no] = 1;
  		}
  
  		for (bc = 0; bc < bn; bc += flash_driver->bus_width) {
  			int j;
  			printf( _("addr: 0x%08X"), adr );
