@@ -254,22 +254,25 @@ internal bool writeFlash(byte[] data, int adr, int len = -1)
254254 {
255255 try
256256 {
257+ var bufLen = 512 ;
258+ if ( chipType == BKType . BL602 ) bufLen = 4096 ;
257259 if ( len < 0 )
258260 len = data . Length ;
259261 int ofs = 0 ;
260262 int startAddr = adr ;
261263 logger . setProgress ( 0 , len ) ;
262264 doErase ( adr , ( len + 4095 ) / 4096 ) ;
263265 addLogLine ( "Starting flash write " + len ) ;
264- byte [ ] buffer = new byte [ 4100 ] ;
266+ byte [ ] buffer = new byte [ bufLen + 4 ] ;
265267 logger . setState ( "Writing" , Color . White ) ;
268+ Thread . Sleep ( 1000 ) ;
266269 while ( ofs < len )
267270 {
268271 cancellationToken . ThrowIfCancellationRequested ( ) ;
269- addLog ( "." + formatHex ( ofs ) + "." ) ;
272+ if ( ofs % 0x1000 == 0 ) addLog ( "." + formatHex ( ofs ) + "." ) ;
270273 int chunk = len - ofs ;
271- if ( chunk > 4096 )
272- chunk = 4096 ;
274+ if ( chunk > bufLen )
275+ chunk = bufLen ;
273276 buffer [ 0 ] = ( byte ) ( adr & 0xFF ) ;
274277 buffer [ 1 ] = ( byte ) ( ( adr >> 8 ) & 0xFF ) ;
275278 buffer [ 2 ] = ( byte ) ( ( adr >> 16 ) & 0xFF ) ;
@@ -636,11 +639,11 @@ public override void doReadAndWrite(int startSector, int sectors, string sourceF
636639 addLogLine ( "No filename given!" ) ;
637640 return ;
638641 }
639- if ( ! sourceFileName . Contains ( "readResult" ) )
642+ if ( ! sourceFileName . StartsWith ( "readResult" ) )
640643 {
641644 if ( chipType != BKType . BL602 )
642645 {
643- addErrorLine ( $ "Firmware write is not supported on { chipType } ") ;
646+ addErrorLine ( $ "Firmware write is not supported on { chipType } . If you intend to restore a backup, make sure that file name starts with 'readResult' ") ;
644647 return ;
645648 }
646649 //if(bOverwriteBootloader)
0 commit comments