Skip to content

Commit 5ff289a

Browse files
Merge pull request #76 from NonPIayerCharacter/rda
RDA flasher
2 parents 0e7c58c + e1d96fa commit 5ff289a

File tree

10 files changed

+903
-649
lines changed

10 files changed

+903
-649
lines changed

BK7231Flasher/BK7231Flasher.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<Reference Include="System.Configuration" />
5757
</ItemGroup>
5858
<ItemGroup>
59+
<Compile Include="RDAFlasher.cs" />
5960
<Compile Include="Xmodem.cs" />
6061
<Compile Include="WMFlasher.cs" />
6162
<Compile Include="ECR6600Flasher.cs" />

BK7231Flasher/BaseFlasher.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ public enum BKType
1818
RTL8710B,
1919
RTL87X0C,
2020
RTL8720D,
21+
RTL8721DA,
22+
RTL8720E,
2123
LN882H,
2224
BL602,
2325
ECR6600,
2426
W600,
2527
W800,
28+
RDA5981,
2629

2730
BekenSPI,
2831
GenericSPI,
@@ -56,7 +59,7 @@ public override string ToString()
5659
}
5760
}
5861

59-
public class BaseFlasher
62+
public class BaseFlasher : IDisposable
6063
{
6164
protected ILogListener logger;
6265
protected string backupName;
@@ -181,7 +184,11 @@ public virtual bool doErase(int startSector = 0x000, int sectors = 10, bool bAll
181184
}
182185
public virtual void closePort()
183186
{
184-
187+
if (serial != null)
188+
{
189+
serial.Close();
190+
serial.Dispose();
191+
}
185192
}
186193
public virtual void doTestReadWrite(int startSector = 0x000, int sectors = 10)
187194
{
@@ -194,6 +201,18 @@ public virtual bool saveReadResult(int startOffset)
194201
{
195202
return false;
196203
}
204+
205+
public virtual void Xm_PacketSent(int sentBytes, int total, int sequence, uint offset)
206+
{
207+
if((sequence % 4) == 1)
208+
{
209+
addLog($"Writing at 0x{offset:X}... ");
210+
}
211+
212+
logger.setProgress(sentBytes, total);
213+
}
214+
215+
public virtual void Dispose() { }
197216
}
198217
}
199218

BK7231Flasher/FormMain.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,14 @@ private void Form1_Load(object sender, EventArgs e)
198198
comboBoxChipType.Items.Add(new ChipType(BKType.RTL8710B, "RTL8710B"));
199199
comboBoxChipType.Items.Add(new ChipType(BKType.RTL87X0C, "RTL87X0C"));
200200
comboBoxChipType.Items.Add(new ChipType(BKType.RTL8720D, "RTL8720DN"));
201+
//comboBoxChipType.Items.Add(new ChipType(BKType.RTL8721DA, "RTL8721DA"));
202+
//comboBoxChipType.Items.Add(new ChipType(BKType.RTL8720E, "RTL8720E"));
201203
comboBoxChipType.Items.Add(new ChipType(BKType.LN882H, "LN882H"));
202204
comboBoxChipType.Items.Add(new ChipType(BKType.BL602, "BL602"));
203205
comboBoxChipType.Items.Add(new ChipType(BKType.ECR6600, "ECR6600"));
204206
comboBoxChipType.Items.Add(new ChipType(BKType.W800, "W800"));
205207
comboBoxChipType.Items.Add(new ChipType(BKType.W600, "W600 (write)"));
208+
comboBoxChipType.Items.Add(new ChipType(BKType.RDA5981, "RDA5981"));
206209
comboBoxChipType.Items.Add(new ChipType(BKType.BekenSPI, "Beken SPI CH341"));
207210
comboBoxChipType.Items.Add(new ChipType(BKType.GenericSPI, "Generic SPI CH341"));
208211

@@ -480,10 +483,13 @@ void clearUp()
480483

481484
void createFlasher()
482485
{
486+
flasher?.Dispose();
483487
switch(curType)
484488
{
485489
case BKType.RTL8710B:
486490
case BKType.RTL8720D:
491+
case BKType.RTL8721DA:
492+
case BKType.RTL8720E:
487493
flasher = new RTLFlasher();
488494
break;
489495
case BKType.RTL87X0C:
@@ -508,6 +514,9 @@ void createFlasher()
508514
case BKType.W800:
509515
flasher = new WMFlasher();
510516
break;
517+
case BKType.RDA5981:
518+
flasher = new RDAFlasher();
519+
break;
511520
default:
512521
flasher = new BK7231Flasher();
513522
break;

BK7231Flasher/OBKConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ internal bool loadFrom(byte [] dat, BKType type, bool bApplyOffset)
110110
case BKType.RTL8720D:
111111
case BKType.BL602:
112112
case BKType.ECR6600:
113+
case BKType.RDA5981:
113114
_ = OBKFlashLayout.getConfigLocation(type, out var sectors);
114115
var sname = type == BKType.BL602 ? "mY0bcFg" : "ObkCfg";
115116
dat = EasyFlash.LoadValueFromData(subArray, sname, sectors * BK7231Flasher.SECTOR_SIZE, type, out efdata);
@@ -577,6 +578,7 @@ public static bool isValid(byte [] raw, int extraOfs = 0, BKType type = BKType.I
577578
case BKType.RTL8720D:
578579
case BKType.LN882H:
579580
case BKType.BL602:
581+
case BKType.RDA5981:
580582
crc = CRC.Tiny_CRC8_unsigned(raw, extraOfs + 4, useLen - 4);
581583
break;
582584
case BKType.W600:
@@ -616,6 +618,7 @@ public void saveConfig(BKType type = BKType.Invalid)
616618
case BKType.RTL8720D:
617619
case BKType.LN882H:
618620
case BKType.BL602:
621+
case BKType.RDA5981:
619622
crc = CRC.Tiny_CRC8_unsigned(raw, 4, realLen - 4);
620623
break;
621624
case BKType.W600:

BK7231Flasher/OBKFlashLayout.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public static int getConfigLocation(BKType type, out int sectors)
3737
case BKType.ECR6600:
3838
sectors = 0x1C000 / BK7231Flasher.SECTOR_SIZE;
3939
return 0x1B9000;
40+
case BKType.RDA5981:
41+
sectors = 0xA000 / BK7231Flasher.SECTOR_SIZE;
42+
return 0xF4000;
4043
//case BKType.XR809:
4144
// sectors = 0x10000 / BK7231Flasher.SECTOR_SIZE;
4245
// return 0x1E0000;

0 commit comments

Comments
 (0)