Skip to content

Commit 5185c6a

Browse files
beken read chip id
1 parent d99f4d6 commit 5185c6a

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

BK7231Flasher/BK7231Flasher.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Drawing;
44
using System.IO;
55
using System.IO.Ports;
6+
using System.Linq;
67
using System.Threading;
78

89
namespace BK7231Flasher
@@ -888,7 +889,30 @@ bool doGenericSetup()
888889
lastEncryptionKey = "";
889890
if (chipType != BKType.BK7231T && chipType != BKType.BK7231U && chipType != BKType.BK7252)
890891
{
891-
if (doUnprotect())
892+
byte[] chipIdRaw;
893+
if(chipType == BKType.BK7236 || chipType == BKType.BK7258)
894+
{
895+
chipIdRaw = ReadFlashReg(0x44010000 + (0x1 << 2)) ?? new byte[] { 0, 0, 0, 0 };
896+
}
897+
else
898+
{
899+
chipIdRaw = ReadFlashReg(0x800000) ?? new byte[] { 0, 0, 0, 0 };
900+
}
901+
chipIdRaw = chipIdRaw.Reverse().ToArray();
902+
string chipId = "";
903+
// should be 0x7238 for BK7238, 0x7231c for BK7231N, 0x7236 for both BK7236 and BK7258
904+
foreach(var ch in chipIdRaw)
905+
{
906+
if(ch == 0 || ch == 1)
907+
continue;
908+
chipId += $"{ch:x}";
909+
}
910+
// do something if selected type != chip id?
911+
if(string.IsNullOrEmpty(chipId))
912+
addWarning($"Failed to get chip ID!" + Environment.NewLine);
913+
else
914+
addLog($"Chip ID: 0x{chipId}" + Environment.NewLine);
915+
if(doUnprotect())
892916
{
893917
return false;
894918
}

0 commit comments

Comments
 (0)