logo elektroda
logo elektroda
X
logo elektroda

testing bl602tool from renzenicolai for BL602 flash read and write

p.kaczmarek2 120 29
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21616882
    p.kaczmarek2
    Moderator Smart Home
    @divadiow have you seen this?
    https://github.com/renzenicolai/bl602tool/tree/main
    It seems to be mentioned just once on our forums: https://www.elektroda.com/rtvforum/find.php?q=renzenicolai
    I wonder, is that tool working for you?

    It seems to contain source code of flashing protocol, for example, the initial handshake:
    Code: Python
    Log in, to see the code
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #2 21616886
    divadiow
    Level 34  
    Oooh nice. I have not seen it! Or I don't recall it.
  • #3 21616896
    p.kaczmarek2
    Moderator Smart Home
    Protocol seems to be fairly straightforward, each command is made of ASCII string and raw bytes payload. Flash is written in 4092 chunks, 4092 bytes + 4 bytes address (4096 total):
    Code: Python
    Log in, to see the code
    Helpful post? Buy me a coffee.
  • #4 21616902
    divadiow
    Level 34  
    OK. Handshake and read/write is good for full flash factory backup and restore (more straight forward?) but separately doesn't how BLDC use DTS, toml, boot bin thing to construct image before flashing also need tearing apart to understand?
  • #5 21616908
    p.kaczmarek2
    Moderator Smart Home
    We can start with just raw read and write and see how it goes. Futhermore, there seems to be some tools related to that, but I don't know if they are complete.
    testing bl602tool from renzenicolai for BL602 flash read and write
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #6 21616909
    divadiow
    Level 34  
    Ah. Interesting. Maybe an all-in-one type of bin could be in releases and that get flashed.
    Just thinking out loud...
  • #7 21616912
    p.kaczmarek2
    Moderator Smart Home
    See this commit message from 5 years ago:
    https://github.com/renzenicolai/bl602tool/commit/d2cf6cf8366dbe859d8436017e8476aab5d062e5
    Quote:

    Add partition tools, generateImage can now generate a valid image (for a single test case)


    Added after 20 [minutes]:


    Or maybe this snippet will be enough? generateImage.py:
    https://github.com/renzenicolai/bl602tool/blob/main/generateImage.py
    Code: Python
    Log in, to see the code
    Helpful post? Buy me a coffee.
  • #8 21617084
    divadiow
    Level 34  
    very interesting indeed. Have you started to experiment with it?
  • #9 21617088
    p.kaczmarek2
    Moderator Smart Home
    Currently I am searching for my BL602 dev board, the one I had bricked WiFi by playing with fuses (tried to change MAC). I can still use it for testing flash write, but I am unable to find it so far.

    Do you have any BL602 boards?
    Helpful post? Buy me a coffee.
  • #11 21617097
    p.kaczmarek2
    Moderator Smart Home
    Are you able to get anything running from that renzenicolai repo? Flash read should work because someone already mentioned it on our forum, but try it, also, anything else?

    Added after 44 [minutes]:

    @divadiow look what I have found, btw:


    Helpful post? Buy me a coffee.
  • #12 21617133
    divadiow
    Level 34  
    p.kaczmarek2 wrote:
    Are you able to get anything running from that renzenicolai repo? Flash read should work because someone already mentioned it on our forum, but try it, also, anything else?


    bit of a mission. just couldn't get it going with CH340 on dev board. Now using external FTDI.

    always
    Code: Text
    Log in, to see the code


    anyway. small read so far
    Code: Python
    Log in, to see the code


    Added after 2 [minutes]:

    p.kaczmarek2 wrote:
    @divadiow look what I have found, btw:

    neat. Aqara Panel Hub S1 Plus? I googled around. What are its brains?
  • #13 21617141
    p.kaczmarek2
    Moderator Smart Home
    Haha, wrong video, I was supposed to send you a video of a plug. I updated my post.

    Added after 27 [seconds]:

    I also found my BL602 now, so we can do testing together.
    Helpful post? Buy me a coffee.
  • #14 21617142
    divadiow
    Level 34  
    p.kaczmarek2 wrote:
    Haha, wrong video, I was supposed to send you a video of a plug. I updated my post.

    lol. ok ok.

    Is your BL602 the same Ai-Thinker with CH340?

    Added after 3 [minutes]:

    hmm. 2mb read is goes on forever then crash

    Code: Text
    Log in, to see the code


    Added after 1 [minutes]:

    I wonder if these eflash loaders have been superseded with newer
  • #15 21617143
    p.kaczmarek2
    Moderator Smart Home
    Ok testing. Dev cube:
    testing bl602tool from renzenicolai for BL602 flash read and write
    renzenicolai tool:
    
    Downloads\bl602tool-main\bl602tool-main>bltool.py -p COM3 -r 0 65536 test_read_64KB.bin
    Sending boot header...
    Sending segment header...
    Writing application to RAM...
    Checking...
    Jumping...
    Reading 65536 bytes from address 0x00000000 to file test_read_64KB.bin...
    ................................................................................................................................
    

    They seem to match:
    testing bl602tool from renzenicolai for BL602 flash read and write

    Added after 1 [minutes]:

    I have DT-BL10 dev kit. This one: https://www.elektroda.com/rtvforum/topic3900145.html

    Added after 1 [minutes]:

    Btw BLDevCube requires 0x1FFFFF flash size, so 2MB - 1
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #16 21617150
    divadiow
    Level 34  
    are you getting any decent sized backups successfully?
  • #17 21617154
    p.kaczmarek2
    Moderator Smart Home
    
    bltool.py -p COM3 -r 0 2097151 test_read_2MB.bin
    Sending boot header...
    Sending segment header...
    Writing application to RAM...
    Checking...
    Jumping...
    Reading 2097151 bytes from address 0x00000000 to file test_read_2MB.bin...
    

    bl602tool-main>fc /b test_read_2MB.bin flash.bin
    Comparing files test_read_2MB.bin and FLASH.BIN
    FC: FLASH.BIN longer than test_read_2MB.bin
    

    testing bl602tool from renzenicolai for BL602 flash read and write
    testing bl602tool from renzenicolai for BL602 flash read and write
    It seems the only difference is single byte in length at the end of file
    Helpful post? Buy me a coffee.
  • #18 21617157
    divadiow
    Level 34  
    how come you dumped with

    Code: Text
    Log in, to see the code


    and not

    Code: Text
    Log in, to see the code
  • #19 21617160
    p.kaczmarek2
    Moderator Smart Home
    I didn't try 2097152 for bltool.py yet. I will try in a moment. It's just that I remember BLDevCube only dumps if I enter 2097151 and not 2097152 , so like 2 megabytes without single byte.
    Helpful post? Buy me a coffee.
  • #20 21617162
    divadiow
    Level 34  
    oh i see. I always use these addresses in BLDC:

    Code: Text
    Log in, to see the code


    Added after 1 [minutes]:

    my bltool 2mb dump is still going. very slow.
  • #21 21617165
    p.kaczmarek2
    Moderator Smart Home
    Your table is interesting. 0x001FFFFF hexadecimal is in reality 2097151 decimal, not 2097152 decimal, but I assume it's on purpose?
    Helpful post? Buy me a coffee.
  • #23 21617172
    p.kaczmarek2
    Moderator Smart Home
    Hmm so BLdevcube requires size minus 1 byte.... and then reads whole 2MB. Strange. Ok, my full 2MB read finished as well. Now, is there an option to change baud?
    It seems so.
    Code: Python
    Log in, to see the code
    Helpful post? Buy me a coffee.
  • #25 21617181
    p.kaczmarek2
    Moderator Smart Home
    The first baud that works for me is:
    
    -b 1000000
    

    I tried also 1500000 and 2000000 but I also got "no response"
    Helpful post? Buy me a coffee.
  • #26 21617185
    divadiow
    Level 34  
    did it operate any faster though?

    I asked gpt to make better realtime progress.

    testing bl602tool from renzenicolai for BL602 flash read and write

    Added after 1 [minutes]:

    have also changed this file for newer in BLDC 1.9.0 but no change
    testing bl602tool from renzenicolai for BL602 flash read and write
  • #27 21617186
    p.kaczmarek2
    Moderator Smart Home
    I'm not sure, I need to check. Btw, if you already have read speed from chatgpt (average from current byte count and elapsed time), you can also ask it to calculate predicted total read time (based on this read speed)
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #29 21617300
    p.kaczmarek2
    Moderator Smart Home
    Changing chunk size works? So what is the fastest speed you managed to get?
    Helpful post? Buy me a coffee.
  • #30 21617442
    divadiow
    Level 34  
    36k/s with 8192 chunk size
    testing bl602tool from renzenicolai for BL602 flash read and write

    54k/s 16384 chunk

    32168 doesn't seem to be faster than 16384

    Code: Text
    Log in, to see the code


    but is it better to have a lower chunk but a working baud rate switch? I've been trying to get script to send baud rate change request at the right moment, but no success.

    Added after 2 [minutes]:

    BLDC dump vs 16384 chunk bltool dump

    testing bl602tool from renzenicolai for BL602 flash read and write

Topic summary

The discussion centers on testing the bl602tool developed by renzenicolai for flashing and reading the BL602 microcontroller's flash memory. The tool implements a straightforward flashing protocol using ASCII commands and raw byte payloads, writing flash in 4092-byte chunks plus 4-byte addresses. Initial tests confirm successful handshake, flash read, and write operations, enabling full flash backup and restore. Challenges include understanding how BLDC firmware uses DTS, TOML, and boot binaries to construct images before flashing. Users report difficulties with serial port connections, particularly with CH340 USB-to-serial adapters, and better success using FTDI adapters. Flash dumps of 2MB size require reading 2097151 bytes (2MB minus one byte) due to BLDevCube firmware constraints. Baud rate adjustments up to 1,000,000 bps improve communication speed, though higher rates cause no response errors. Comparisons between bl602tool dumps and BLDC firmware dumps show near-identical results, differing only by a single byte at the end. The tool's source includes scripts like generateImage.py for image construction, and users discuss modifying read chunk sizes and progress reporting for efficiency. Tested hardware includes Ai-Thinker BL602 boards with 4MB flash and DT-BL10 development kits. Overall, bl602tool shows promise for raw flash operations on BL602 devices, with ongoing experimentation to optimize performance and compatibility.
Summary generated by the language model.
ADVERTISEMENT