Skip to content

Commit 9446d97

Browse files
fix bl
1 parent 8d42e27 commit 9446d97

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

BK7231Flasher/Flashers/BL602Flasher.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

BK7231Flasher/FormMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public partial class FormMain : Form, ILogListener
4343
{ BKType.RTL8720D, "RTL8720DN (AmebaD)" },
4444
{ BKType.LN882H, "LN882H" },
4545
{ BKType.BL602, "BL602" },
46-
{ BKType.BL702, "BL702 (read)" },
46+
{ BKType.BL702, "BL702 (read/restore)" },
4747
{ BKType.ECR6600, "ECR6600" },
4848
{ BKType.W800, "W800" },
4949
{ BKType.W600, "W600 (write)" },

0 commit comments

Comments
 (0)