logo elektroda
logo elektroda
X
logo elektroda

BK7231Flasher.exe on Arch Linux with Mono: Anyone Successfully Flashed OpenBK7231N?

iotRL 186 7
ADVERTISEMENT
  • #1 21569236
    iotRL
    Level 2  
    Has anyone used BK7231Flasher on Linux successfully?

    I just attempted to flash OpenBK7231N_QIO_1.18.104.bin with BK7231Flasher.exe on my Arch Linux install, built with xbuild, mono-6.12.0.206-1.
    It seemed to recognize the target after I cycled CEN low, and started read at 0x00, but never advanced.

    Same error as in this thread: https://www.elektroda.com/rtvforum/topic3963918.html
    Efuse ok at 0 (0x0) is 147 (0x93)
    Efuse ok at 1 (0x1) is 176 (0xB0)
    Efuse ok at 2 (0x2) is 15 (0xF)
    Efuse ok at 3 (0x3) is 81 (0x51)
    Efuse ok at 4 (0x4) is 220 (0xDC)
    Efuse ok at 5 (0x5) is 234 (0xEA)
    Efuse ok at 6 (0x6) is 203 (0xCB)
    Efuse ok at 7 (0x7) is 163 (0xA3)
    Efuse ok at 8 (0x8) is 126 (0x7E)
    Efuse ok at 9 (0x9) is 161 (0xA1)
    Efuse ok at 10 (0xA) is 147 (0x93)
    Efuse ok at 11 (0xB) is 89 (0x59)
    Efuse ok at 12 (0xC) is 3 (0x3)
    Efuse ok at 13 (0xD) is 235 (0xEB)
    Efuse ok at 14 (0xE) is 173 (0xAD)
    Efuse ok at 15 (0xF) is 199 (0xC7)
    Encryption Key: 510fb093 a3cbeadc 5993a17e c7adeb03

    Reading 0x00... failed with serial.BytesToRead 4095 (expected 4111)


    My USB to TTL is the very common CH340.
    [la touko 24 07:51:33 2025] usb 1-6.1: new full-speed USB device number 10 using xhci_hcd
    [la touko 24 07:51:33 2025] usb 1-6.1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54
    [la touko 24 07:51:33 2025] usb 1-6.1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
    [la touko 24 07:51:33 2025] usb 1-6.1: Product: USB2.0-Ser!
    [la touko 24 07:51:33 2025] ch341 1-6.1:1.0: ch341-uart converter detected
    [la touko 24 07:51:33 2025] ch341-uart ttyUSB0: break control not supported, using simulated break

    Two USB to TTL adapters with pin headers and USB type A connectors.
    After a couple of tries I used "hid_download_py" without changing anything, and it worked.
    So, leaves me wondering if anyone else has had success with BKflasher on linux?
    ---
    AI: Which version or commit of BK7231Flasher.exe are you using (and where did you get it from)?
    Commit a121c2e4dc8e23d126c6315355e44b52381b31df, tag v19
    AI: What exact command-line arguments or options did you use when running BK7231Flasher.exe?
    Just ~$ mono BK7231Flasher.exe
  • ADVERTISEMENT
  • Helpful post
    #2 21570143
    p.kaczmarek2
    Moderator Smart Home
    It's a known issue. I would love to get some help with troubleshooting that. I've added "UART Timeouts" tab some time ago, maybe you can try changing them...
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21570597
    iotRL
    Level 2  
    Thanks for the tip, changing cfg_readReplyStyle from 0 (default) to 5 made the read function work instantly.
    Speed was set to 115200
    Starting read!
    Read parms: start 0x00 (sector 0), len 0x200000 (0 sectors)
    Now is: Thursday, June 5, 2025 2:11:12 PM.
    Flasher mode: BK7231N
    Going to open port: /dev/ttyUSB0.
    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 (115200)!
    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: TH25Q16HB, 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: 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... Ok! Reading 0x1000... Ok! Reading 0x7000... Ok! [....] Reading 0x1FF000... Ok! 
    Basic read operation finished, but now it's time to verify...
    Starting CRC check for 512 sectors, starting at offset 0x00
    CRC matches 0xA053D055!
    All read!


    Writing failed, however. I tried 3 times, here's the first log after read:
    Starting flash new (no backup)!
    Now is: Thursday, June 5, 2025 2:20:30 PM.
    Flasher mode: BK7231N
    Going to open port: /dev/ttyUSB0.
    Serial port open!
    Getting bus... (now, please do reboot by CEN or by power off/on)
    Getting bus success!
    Going to set baud rate setting (115200)!
    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: TH25Q16HB, 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: 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
    Reading file firmwares/OpenBK7231N_QIO_1.18.110.bin...
    Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.18.110.bin...
    Using hack to write QIO - just skip bootloader...
    ... so bootloader will not be overwritten!
    Preparing to write data file to chip - resetting bus and baud...
    Getting bus... (now, please do reboot by CEN or by power off/on)
    Getting bus success!
    Going to set baud rate setting (115200)!
    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: TH25Q16HB, 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: 0
    sr: 0
    final sr: 0
    msk: 407c
    cw: 0, sb: 2, lb: 5
    bfd: 0
    SetProtectState(True) success!
    Going to do erase, start 69632, sec count 281!
    Erasing sector 69632... ok! Erasing sector 73728... ok! Erasing sector 114688... ok! Erasing sector [...] 1216512... ok! 
    All selected sectors erased!
    Going to do erase, start 1904640, sec count 1!
    Erasing sector 1904640... ok! 
    All selected sectors erased!
    failed with serial.BytesToRead 0 (expected 15)
    The beginning of buffer in UART contains  data.
    Writing sector 0x11000... Writing sector 69632 failed!
    Writing file data to chip failed.


    But then I changed the baud rate to 921600, and writing worked!
    Starting flash new (no backup)!
    Now is: Thursday, June 5, 2025 2:28:59 PM.
    Flasher mode: BK7231N
    Going to open port: /dev/ttyUSB0.
    Serial port open!
    Getting bus... (now, please do reboot by CEN or by power off/on)
    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: TH25Q16HB, 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: 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
    Reading file firmwares/OpenBK7231N_QIO_1.18.110.bin...
    Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.18.110.bin...
    Using hack to write QIO - just skip bootloader...
    ... so bootloader will not be overwritten!
    Preparing to write data file to chip - resetting bus and baud...
    Getting bus... (now, please do reboot by CEN or by power off/on)
    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: TH25Q16HB, 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: 0
    sr: 0
    final sr: 0
    msk: 407c
    cw: 0, sb: 2, lb: 5
    bfd: 0
    SetProtectState(True) success!
    Going to do erase, start 69632, sec count 281!
    Erasing sector 69632... ok! Erasing sector 73728... ok! [...] Erasing sector 1216512... ok! 
    
    All selected sectors erased!
    Going to do erase, start 1904640, sec count 1!
    Erasing sector 1904640... ok! 
    All selected sectors erased!
    Writing sector 0x11000... ok! Writing sector 0x12000... [...] Writing sector 0x128000... ok! Writing sector 0x129000... ok!
    Starting CRC check for 281 sectors, starting at offset 0x11000
    CRC matches 0xFD2F3E99!
    
    Now will also write OBK config...
    Long name from CFG: OpenBK7231N_D00000000
    Short name from CFG: obkN_D00000000
    Web Root from CFG: https://openbekeniot.github.io/webapp/
    Writing config sector 0x1D1000...Writing file data to chip successs.


    I don't know what cfg_readReplyStyle does in specific, but setting it to 5 with speed 921600 works fine on my hardware.

    edit: cfg_readTimeOutMultiForSerialClass and cfg_readTimeOutMultiForLoop were both default at 5 the whole time.
  • #4 21570736
    p.kaczmarek2
    Moderator Smart Home
    I see, thank you for testing. So you're saying that it should be set to 5 by default?

    @divadiow does the flasher works on for you on Windows with it set to 5?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • ADVERTISEMENT
  • #7 21571887
    groove6j
    Level 8  
    >>21570834
    Interesting. I have also never successfully read/write anything with using wine or mono, but I haven't changed the settings. Always the process got stuck. I was able to get baudrate, but after that errors occurred. Will try your recommendation next time!
  • #8 21578695
    p.kaczmarek2
    Moderator Smart Home
    I've checked source code and cfg_readReplyStyle is used as bool. So it's either 0 or non-zero. So there is no difference between 1 and 5.
    Helpful post? Buy me a coffee.
ADVERTISEMENT