logo elektroda
logo elektroda
X
logo elektroda

CB2S BK7231N failed to flash Easy UART Flasher - failed with serial.BytesToRead 0 (expected 15)

MSP_Tech 219 3
ADVERTISEMENT
  • #1 21640821
    MSP_Tech
    Level 2  
    HI, I've just tried to flash OpenBK firmware on CB2S module with BK7231N chip by Easy Uart Flasher, but unfortunately it failed.
    I used Easy Uart Flasher v50 and OpenBK7231N_QIO_1.18.156 firmware.
    Photo
    Spoiler:

    CB2S module with BK7231N chip connected via UART cables and sensors.

    I managed to do backup flash, and I think it was read properly as program managed to extract OBK. But when I clicked write, program start to flash firmware and failed at address0xE3000:
    Easy Uart Flasher wrote:
    Writing sector 0xE0000... ok! failed with serial.BytesToRead 0 (expected 15)
    The beginning of buffer in UART contains data.
    Writing sector 0xE1000... Writing sector 921600 failed!
    Writing file data to chip failed.

    Log
    Spoiler:
    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: 80
    sr: 680
    final sr: 680
    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.156.bin...
    Loaded 1220464 bytes from firmwares/OpenBK7231N_QIO_1.18.156.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: 80
    sr: 680
    final sr: 680
    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 77824... ok! Erasing sector 81920... ok! Erasing sector 86016... ok! Erasing sector 90112... ok! Erasing ....
    All selected sectors erased!
    Writing sector 0x11000... ok! Writing sector 0x12000... ok! Writing sector 0x13000... ok! Writing sector 0x14000... ok! Writing sector 0x15000... ok!
    ...
    Writing sector 0xDD000... ok! Writing sector 0xDE000... ok! Writing sector 0xDF000... ok! Writing sector 0xE0000... ok! failed with serial.BytesToRead 0 (expected 15)
    The beginning of buffer in UART contains data.
    Writing sector 0xE1000... Writing sector 921600 failed!
    Writing file data to chip failed.

    After that I tried to rollback, python tool, change speeds or skip key check, but no lack. It simply fails writing at some but specific to selected file address.
    Is there any way to fix this, or unit can be considered as dead?
    AI: Can you provide details about your UART wiring setup—specifically, which USB-to-serial adapter you're using, how you've connected it to the CB2S module (including voltage levels), and whether you've confirmed the connections are correct?
    UART: FTDI FT232RL adapter with 3.3V level. Connected to TX,RX of the module.
    AI: What operating system and version are you running Easy UART Flasher on, and have you installed any specific drivers or made any changes to your system environment for the flashing process?
    System: Win11, no special drivers were installed.
  • ADVERTISEMENT
  • #2 21642296
    divadiow
    Level 36  
    probably a combination of wires being too long and or powering from 3.3v on USB-TTL. Try powering from 3.3v external power source. common grounds
  • ADVERTISEMENT
  • #3 21642389
    MSP_Tech
    Level 2  
    I've switched it lab PSU.
    And also checked RX, TX lines with oscilloscope, they are clean and crisp.
    I mean I assume that if there's an issue with UART, it wouldn't be able to communicate with chip.
    But as you can see from log it reads some protection, erases memory, and only fails in the middle of the memory write.
    And what is most odd, it always fails at the same address for particular firmware (probably depends on bin file length, because in case of back up file it fails at another address).
  • #4 21643636
    MSP_Tech
    Level 2  
    So, a small update on this issue.
    I've tried to make wires as short as possible, but no luck, it still fails at address 0x11000.
    Then I tried to write OBK only and surprisingly system said write success. More of that, psu showed up to 0.08A consumption and one of leds starts to blink.
    I've opened wifi connection on my phone and found openbeken device.
    Next step I've tried to modify OBK file by program (basically added SSID of my home network), but once again program reported that write failed.
    Log
    Spoiler:

    Starting write only OBK config!
    Flasher mode: BK7231N
    Going to open port: COM5.
    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: 80
    sr: 680
    final sr: 680
    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
    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: 80
    sr: 680
    final sr: 680
    msk: 407c
    cw: 0, sb: 2, lb: 5
    bfd: 0
    SetProtectState(True) success!
    Going to do erase, start 1904640, sec count 1!
    Erasing sector 1904640... ok!
    All selected sectors erased!

    Now will also write OBK config...
    Long name from CFG: OpenBekenX_D2
    Short name from CFG: obkD2
    Web Root from CFG: https://openbekeniot.github.io/webapp/
    Writing config sector 0x1D1000...failed with serial.BytesToRead 0 (expected 15)
    The beginning of buffer in UART contains data.
    Writing OBK config data to chip failed.
    Writing file data to chip failed.


    Despite on that, I've rebooted device and ... it connected to my home wifi.
    I've managed to open configuration server, set pin parameters, open app server and everything is working...
    OpenBK panel showing 243.9V voltage and energy consumption statistics
    I have no idea what is happening here.
    My wild guess would be that there is some mismatch between chip memory size and/or program memory size which makes program to think that write wasn't successful, while in fact everything was written.
    I'll monitor plug behavior next couple of days and report if something goes wrong.
ADVERTISEMENT