Skip to content

Commit 066f61d

Browse files
committed
Update TR6260Flasher.cs
1 parent de1ad62 commit 066f61d

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

BK7231Flasher/Flashers/TR6260Flasher.cs

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ bool PrepareReadOrWriteSession()
129129

130130
bool PrepareEraseSession()
131131
{
132-
return PrepareSession(true, ERASE_OPERATION_BAUD);
132+
return PrepareSession(true);
133133
}
134134

135135
bool SetupPort(int initialBaud = DEFAULT_BAUD)
@@ -296,26 +296,6 @@ bool PrepareSession(bool needUbootProtocol, int? requestedBaudOverride = null)
296296
Thread.Sleep(1000);
297297
}
298298

299-
// If sync failed at the default baud, the device may still be in uboot at
300-
// ERASE_OPERATION_BAUD from a previous erase session. Try that baud before giving up.
301-
if(syncResp != TRS_ROM_SYNC_ACK && syncResp != TRS_UBOOT_SYNC_ACK
302-
&& serial != null && ERASE_OPERATION_BAUD != serial.BaudRate)
303-
{
304-
addLogLine($"Sync failed at {serial.BaudRate}, retrying at {ERASE_OPERATION_BAUD}...");
305-
serial.BaudRate = ERASE_OPERATION_BAUD;
306-
for(int loop = 1; loop <= 5; loop++)
307-
{
308-
syncResp = SyncOnce();
309-
if(syncResp == TRS_ROM_SYNC_ACK || syncResp == TRS_UBOOT_SYNC_ACK)
310-
break;
311-
312-
if(sessionPortUnavailable || cancellationToken.IsCancellationRequested)
313-
break;
314-
315-
Thread.Sleep(500);
316-
}
317-
}
318-
319299
if(syncResp != TRS_ROM_SYNC_ACK && syncResp != TRS_UBOOT_SYNC_ACK)
320300
{
321301
addErrorLine("Sync failed");
@@ -501,19 +481,19 @@ bool LoadBootloaderToRam()
501481
return false;
502482
}
503483

504-
SetBusyState("Uploading RAM loader...");
505-
addLogLine("Uploading RAM loader...");
484+
SetBusyState("Uploading uboot...");
485+
addLogLine("Uploading uboot...");
506486
if(!BeginTransfer(TRS_FRM_TYPE_UBOOT, 0, boot.Length, 30))
507487
{
508-
addErrorLine("RAM loader header failed");
509-
SetErrorState("RAM loader upload failed");
488+
addErrorLine("Uboot header failed");
489+
SetErrorState("Uboot upload failed");
510490
return false;
511491
}
512492

513-
if(!WriteFileBlocks(boot, "RAM loader"))
493+
if(!WriteFileBlocks(boot, "uboot"))
514494
return false;
515495

516-
addLogLine("RAM loader upload completed.");
496+
addLogLine("Uboot upload completed.");
517497
return true;
518498
}
519499

@@ -718,7 +698,7 @@ bool WriteFirmwarePayload(int startOffset, byte[] data)
718698
return false;
719699
}
720700

721-
if(!WriteSingleSegment(0, boot, TRS_FRM_TYPE_UBOOT, "RAM loader"))
701+
if(!WriteSingleSegment(0, boot, TRS_FRM_TYPE_UBOOT, "uboot"))
722702
return false;
723703
if(!WriteSingleSegment(PARTITION_ADDR, partition, TRS_FRM_TYPE_NV, "partition table"))
724704
return false;
@@ -852,10 +832,9 @@ public override void doWrite(int startSector, byte[] data)
852832
return;
853833

854834
int writeOfs = startSector;
855-
addLogLine($"Starting flash write, ofs 0x{writeOfs:X}, len 0x{data.Length:X}");
856-
SetBusyState("Erasing...");
857835
if(!EraseViaUboot(0, DEFAULT_FLASH_SIZE))
858836
return;
837+
addLogLine($"Starting flash write, ofs 0x{writeOfs:X}, len 0x{data.Length:X}");
859838
SetBusyState("Writing...");
860839
if(!WriteFirmwarePayload(startSector, data))
861840
{
@@ -977,10 +956,9 @@ public override void doReadAndWrite(int startSector, int sectors, string sourceF
977956
addLogLine("Reading " + sourceFileName + "...");
978957
byte[] data = File.ReadAllBytes(sourceFileName);
979958

980-
addLogLine($"Starting flash write, ofs 0x{startSector:X}, len 0x{data.Length:X}");
981-
SetBusyState("Erasing...");
982959
if(!EraseViaUboot(0, DEFAULT_FLASH_SIZE))
983960
return;
961+
addLogLine($"Starting flash write, ofs 0x{startSector:X}, len 0x{data.Length:X}");
984962
SetBusyState("Writing...");
985963
if(!WriteFirmwarePayload(startSector, data))
986964
{

0 commit comments

Comments
 (0)