Skip to content

Commit

Permalink
Merge pull request #461 from cnlohr/speedup_flashing
Browse files Browse the repository at this point in the history
Cleanup code based on montemonte's suggestions, and remove two extra …
  • Loading branch information
cnlohr authored Dec 2, 2024
2 parents 4c76a81 + fbee0f9 commit 82b50c6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
13 changes: 7 additions & 6 deletions minichlink/minichlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,11 +811,13 @@ static int DefaultWaitForFlash( void * dev )
}
} while(rw & 3); // BSY flag for 003, or WRBSY for other processors.

if( rw & 0x20 )
{
// On non-003-processors, clear done op.
MCF.WriteWord( dev, (intptr_t)&FLASH->STATR, 0x20 );
}
// This was set at some point for non-003 processors.
// but, it seems not to be needed.
//if( rw & 0x20 )
//{
// // On non-003-processors, clear done op.
// MCF.WriteWord( dev, (intptr_t)&FLASH->STATR, 0x20 );
//}

if( rw & FLASH_STATR_WRPRTERR )
{
Expand Down Expand Up @@ -1792,7 +1794,6 @@ int DefaultErase( void * dev, uint32_t address, uint32_t length, int type )
}
}

if( MCF.WaitForFlash && MCF.WaitForFlash( dev ) ) return -99;
// Step 4: set PAGE_ER of FLASH_CTLR(0x40022010)
if( MCF.WriteWord( dev, (intptr_t)&FLASH->CTLR, CR_PAGE_ER ) ) goto flashoperr; // CR_PAGE_ER is FTER
// Step 5: Write the first address of the fast erase page to the FLASH_ADDR register.
Expand Down
Binary file modified minichlink/minichlink.exe
Binary file not shown.
8 changes: 1 addition & 7 deletions minichlink/pgm-b003fun.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ static int CommitOp( struct B003FunProgrammerStruct * eps )
#endif

resend:
usleep(1000);
r = hid_send_feature_report( eps->hd, eps->commandbuffer, sizeof(eps->commandbuffer) );
#ifdef DEBUG_B003
printf( "hid_send_feature_report = %d\n", r );
Expand All @@ -168,12 +167,7 @@ static int CommitOp( struct B003FunProgrammerStruct * eps )
goto resend;
}

if (eps->no_get_report) return r;

if( eps->prepping_for_erase )
{
usleep(4000);
}
if (eps->no_get_report) return r;

int timeout = 0;

Expand Down
2 changes: 2 additions & 0 deletions minichlink/pgm-wch-linke.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ int LEWriteReg32( void * dev, uint8_t reg_7_bit, uint32_t command )
}
fprintf( stderr, "\n" );
}
fprintf( stderr, "\n" );
return -1;
}
return 0;
}
Expand Down

0 comments on commit 82b50c6

Please sign in to comment.