openshwprojects / BK7231GUIFlashTool

Easy to use, GUI, BK7231T/BK7231N flash tool and GPIO config extractor for beginners. Dedicated for Windows platform, but works on Linux with Mono. This tool can automatically download latest firmware (on user request) and then do a full BK backup and then write new flash cycle. This tool replaces old bkWriter 1.60 and hid_download_py.
232 stars 24 forks source link

Unable to backup the BK7231N device (Wi-Fi switch on CB2S) #19

Open S-trace opened 1 year ago

S-trace commented 1 year ago

Hi.

I'm trying to backup the firmware in my BK7231N device (the Wi-Fi switch with CB2S module).

I have soldered 5 wires - GND, VCC, RX, TX, CEN. I have provided 3V3 VCC and 3V3 UART I/O voltage. I have connected the wires as the following (5V0 to 3V3 converter is just for VCC, I/O voltage of my UART adapter is 3V3):

[PC]    [Middleware]    [Switch]
GND     -bridge-        GND
VCC     +5V0=>+3V3 DCDC VCC
RX      -bridge-        TX
TX      -bridge         RX
NC      NC              CEN

But every time I start mono BK7231Flasher.exe it fails with the following error message:

Going to start reading at offset 0x00...
Reading 0x00... failed with serial.BytesToRead 4095 (expected 4111)
The beginning of buffer in UART contains 040EFF01E0FCF4061009000000200069 data.
Failed! There was no result to save.

How can I fix this?

I tried to "Set baud rate" to 115200, but this does not help - still the same error.

Under Windows 10 I got a bit weirder message - something like "The port does not exist" with the same hardware, but the Windows can see my 3V3 UART converter and assigned its name as com3 (and of course I selected the com3 port because I have no other COM ports in Windows).

Here is the error and my settings: reading_failed

But flashing withoht backup succeed: flashing_succeed

Thanks.

openshwprojects commented 1 year ago

Hello, sorry for the late reply. On non-Windows platforms, we've had reports that UART is behaving a bit different but at the moment we are not able to determine what causes it. On Windows, all ports should be selectable as long as they are not in use. Do you have any other application that may be taking the port in use, maybe Cura or smth?

wasteoinc commented 1 year ago

I have exactly the same issue with mono in linux with a CB2S board, but the flashing worked as a charm in the command line. So it is some issue with the app. If you need any details will be happy to provide. Thanks for the great project nontheless

vinibali commented 11 months ago

I had the same problem on Arch Linux. Write was working fine, but it stopped at the backup.

failed with serial.BytesToRead 4095 (expected 4111)

It might worth a try to use this: https://github.com/OpenBekenIOT/hid_download_py Best regards

ntqbit commented 8 months ago

Same problem here. Reading (neither backup nor OBK read) doesn't work, while writing works on arch linux. Output:

...
SetProtectState(True) success!
Going to start reading at offset 0x00...
Reading 0x00... failed with serial.BytesToRead 4095 (expected 4111)
The beginning of buffer in UART contains 040EFF01E0FCF4061009000000200069 data.
Failed! There was no result to save.

hid_download_py tool works (both reading and writing).

jamesy0ung commented 4 months ago

I am using windows, and experiencing the EXACT same error

Starting read! Read parms: start 0x00 (sector 0), len 0x200000 (0 sectors) Now is: Tuesday, 9 July 2024 8:29:38 PM. Flasher mode: BK7231N Going to open port: COM6. Serial port open! Getting bus... (now, please do reboot by CEN or by power off/on) Getting bus failed, will try again - 0/100! Getting bus success! Going to set baud rate setting (921600)! Will try to read device flash MID (for unprotect N): Flash MID loaded: 1560EB Will now search for Flash def in out database... Flash def found! For: 1560EB Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF Entering SetProtectState(True)... sr: 7c sr: 7c final sr: 7c msk: 407c cw: 0, sb: 2, lb: 5 bfd: 0 sr: 0 sr: 0 final sr: 0 msk: 407c cw: 0, sb: 2, lb: 5 bfd: 0 SetProtectState(True) success! Going to read encryption key... Encryption key read done! Encryption key: 510fb093 a3cbeadc 5993a17e c7adeb03 Going to start reading at offset 0x00... Reading 0x00... failed with serial.BytesToRead 4002 (expected 4111) The beginning of buffer in UART contains 040EFF01E0FCF4061009000000200069 data. Failed! There was no result to save.

jamesy0ung commented 4 months ago

I solved the issue by using an external 3.3v regulator (LM1086) and setting baud rate to 115200