logo elektroda
logo elektroda
X
logo elektroda

testing bl602tool from renzenicolai for BL602 flash read and write

p.kaczmarek2 993 82
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #61 21624760
    divadiow
    Level 35  
    p.kaczmarek2 wrote:
    Maybe I can push my recent changes and you'll flash it with my tool to 0x0 offset?

    sure

    Added after 1 [hours] 45 [minutes]:

    Code: Text
    Log in, to see the code


    Code: Text
    Log in, to see the code


    no boot log. and nothing broadcasting I don't think. trying CozyLife dump

    Code: Text
    Log in, to see the code


    this flash works if done with BLDC and boots. no boot with SharpBL602Tool

    Added after 3 [minutes]:

    no 4mb or 2mb dump from 4mb board

    Code: Text
    Log in, to see the code


    Added after 32 [minutes]:

    Code: Text
    Log in, to see the code


    1000000 baud seems to be the maximum I can get it to function at
  • ADVERTISEMENT
  • #62 21624913
    p.kaczmarek2
    Moderator Smart Home
    divadiow wrote:

    no boot log. and nothing broadcasting I don't think. trying CozyLife dump

    Code: Text
    Log in, to see the code


    this flash works if done with BLDC and boots. no boot with SharpBL602Tool

    What BLDC does different? Can you compare dumps?
    Helpful post? Buy me a coffee.
  • #64 21624974
    p.kaczmarek2
    Moderator Smart Home
    I see, I accidentally broke read/write with last commit, wait a moment... or I will push now - a slower version.

    Added after 1 [minutes]:

    This is most important to be run before any other testing:

    testing bl602tool from renzenicolai for BL602 flash read and write

    Added after 3 [minutes]:

    I broke it by reducing delays, as the code is checking for reply len 2 and not the expected one. I will improve it a bit for speed now, I need to know the reply len in advance.

    Added after 12 [minutes]:

    ahhh I also forgot to increment address in writeFlash so everything past 4092 was rolled over

    Added after 45 [seconds]:


    testing bl602tool from renzenicolai for BL602 flash read and write

    Added after 58 [seconds]:


    testing bl602tool from renzenicolai for BL602 flash read and write

    Added after 54 [minutes]:

    And Axus boots now! It was my fault. My read/write test didn't cover more than 1 sector..
    testing bl602tool from renzenicolai for BL602 flash read and write
    Helpful post? Buy me a coffee.
  • #65 21625126
    divadiow
    Level 35  
    yep. very good.

    Axus boots now.

    testing bl602tool from renzenicolai for BL602 flash read and write

    Added after 1 [minutes]:

    EF will need at least 1 and 2mb options. And maybe do 4mb too?
  • ADVERTISEMENT
  • #66 21625154
    p.kaczmarek2
    Moderator Smart Home
    I don't know much about BL602, where does it check whether it's 1MB or 2MB?

    Can you give a raw 1MB dump from bldevcube or my sharp tool so I can try to flash it to my 2MB board and see what happens?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #67 21625158
    divadiow
    Level 35  
    p.kaczmarek2 wrote:
    Can you give a raw 1MB dump from bldevcube or my sharp tool so I can try to flash it to my 2MB board and see what happens?

    1mb dumps in FlashDumps taken with BLDC or do you want one specifically taken with SharpTool?


    testing bl602tool from renzenicolai for BL602 flash read and write
  • #68 21625159
    gamelaster
    Level 5  
    p.kaczmarek2 wrote:
    I don't know much about BL602, where does it check whether it's 1MB or 2MB?


    If we talk about Flash size, I think it detects it by JEDEC ID (if external flash is used) or internal efuse configuration.
  • #69 21625169
    divadiow
    Level 35  
    Code: Python
    Log in, to see the code



    Code: Python
    Log in, to see the code


    Added after 3 [minutes]:

    also, BLDC uses eflash_loader_40m.bin which is twice the size of the old eflash_loader_rc32m.bin

    Code: Text
    Log in, to see the code


    Code: Text
    Log in, to see the code
  • #70 21625181
    p.kaczmarek2
    Moderator Smart Home
    Mentioned cozylife 1MB image seems to boot on my 2MB board.
    Screenshot showing cozylife 1MB running on a 2MB mainboard.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #72 21625226
    p.kaczmarek2
    Moderator Smart Home
    Added flash ID read, based on the code you posted (just had to search for command id - 0x36)
    testing bl602tool from renzenicolai for BL602 flash read and write

    Added after 1 [minutes]:

    validated:

    testing bl602tool from renzenicolai for BL602 flash read and write
    Helpful post? Buy me a coffee.
  • #73 21625231
    divadiow
    Level 35  
    yay nice. this was gpt script I used back then

    Code: Python
    Log in, to see the code
  • #74 21625235
    p.kaczmarek2
    Moderator Smart Home
    Not bad, however this search find_jedec_id is totally not necessary

    Ok what is the next step? Check if we can... build images for 1MB and 2MB and 4MB (?) devices just by prepending header to latest OpenBL602 bin?
    Helpful post? Buy me a coffee.
  • #75 21625239
    divadiow
    Level 35  
    p.kaczmarek2 wrote:
    Not bad, however this search find_jedec_id is totally not necessary

    ah. oh well.

    p.kaczmarek2 wrote:
    Ok what is the next step? Check if we can... build images for 1MB and 2MB and 4MB (?) devices just by prepending header to latest OpenBL602 bin?

    Sure.

    My flash ID:

    testing bl602tool from renzenicolai for BL602 flash read and write

    Added after 1 [minutes]:

    divadiow wrote:
    p.kaczmarek2 wrote:
    build images for 1MB and 2MB and 4MB (?) devices just by prepending header to latest OpenBL602 bin?

    are you thinking they'll be AIO type files that get burned as one? users no longer doing toml, dts etc?

    I guess we'd need to make the 1mb and 4mb partitions the best they can be if they're going to be set in stone from this change onward?

    Added after 1 [minutes]:

    I think @insmod was doing something with 1mb partition..
    https://www.elektroda.com/rtvforum/viewtopic.php?p=21619943#21619943

    Added after 4 [minutes]:

    this is how insmod and miegapele's 1mb differ

    https://www.diffchecker.com/UktZWIUh/
  • #76 21625399
    p.kaczmarek2
    Moderator Smart Home
    Is that media partition added for LFS?
    Helpful post? Buy me a coffee.
  • #78 21625789
    gamelaster
    Level 5  
    >>21625169 eflash loader different versions varies by clock used.
    40m means external 40 MHz crystal, rc32m means internal RC 32 MHz oscillator.

    The size of Flash is detected 90% times from from JEDEC ID.
  • #79 21625807
    divadiow
    Level 35  
    ah, internal. So you can choose to use internal 32m xtal or external 40m?

    Added after 2 [minutes]:

    Code: Text
    Log in, to see the code
  • #80 21625827
    gamelaster
    Level 5  
    >>21625807

    No, XTAL is shorcut only for crystals. BL602 supports following external crystals frequencies: 24, 32, 38.4 and 40 MHz. Although, there is internal 32 MHz and 32 KHz oscillator made with RC circuit. This oscillator is not accurate, and it is used for initial boot up (in bootloader) until external/accurate crystals are init.
  • #82 21627544
    p.kaczmarek2
    Moderator Smart Home
    I am testing this util now:
    https://github.com/renzenicolai/bl602tool/blob/main/printHeaders.py
    Code: Python
    Log in, to see the code

    Interestingly enough, the SHA check fails for Axus_eWeLink_3G_Switch_SDV-002_V1.2_(FWSW-HSBL602-SWITCH-BL602L_v1.3.3).bin
    
    
    ValueError: Unknown format code 'x' for object of type 'str'
    
    E:\GIT\bl602tool>python printHeaders.py E:\GIT\SharpBL602Tool\SharpBL602Tool\bin
    \Debug\Axus_eWeLink_3G_Switch_SDV-002_V1.2_(FWSW-HSBL602-SWITCH-BL602L_v1.3.3).b
    in
    Boot header revision: 0x01
    Flash configuration
    --------------------------------------------------------------------------------
    --------------------------
    ioMode                          0x04
    cReadSupport                    0x01
    clkDelay                        0x01
    clkInvert                       0x01
    resetEnCmd                      0x66
    resetCmd                        0x99
    resetCreadCmd                   0xff
    resetCreadCmdSize               0x03
    jedecIdCmd                      0x9f
    jedecIdCmdDmyClk                0x00
    qpiJedecIdCmd                   0x9f
    qpiJedecIdCmdDmyClk             0x00
    sectorSize                      0x04
    mid                             0xef
    pageSize                        0x0100
    chipEraseCmd                    0xc7
    sectorEraseCmd                  0x20
    blk32EraseCmd                   0x52
    blk64EraseCmd                   0xd8
    writeEnableCmd                  0x06
    pageProgramCmd                  0x02
    qpageProgramCmd                 0x32
    qppAddrMode                     0x00
    fastReadCmd                     0x0b
    frDmyClk                        0x01
    qpiFastReadCmd                  0x0b
    qpiFrDmyClk                     0x01
    fastReadDoCmd                   0x3b
    frDoDmyClk                      0x01
    fastReadDioCmd                  0xbb
    frDioDmyClk                     0x00
    fastReadQoCmd                   0x6b
    frQoDmyClk                      0x01
    fastReadQioCmd                  0xeb
    frQioDmyClk                     0x02
    qpiFastReadQioCmd               0xeb
    qpiFrQioDmyClk                  0x02
    qpiPageProgramCmd               0x02
    writeVregEnableCmd              0x50
    wrEnableIndex                   0x00
    qeIndex                         0x01
    busyIndex                       0x00
    wrEnableBit                     0x01
    qeBit                           0x01
    busyBit                         0x00
    wrEnableWriteRegLen             0x02
    wrEnableReadRegLen              0x01
    qeWriteRegLen                   0x01
    qeReadRegLen                    0x01
    releasePowerDown                0xab
    busyReadRegLen                  0x01
    enterQpi                        0x38
    exitQpi                         0xff
    cReadMode                       0x20
    cRExit                          0xff
    burstWrapCmd                    0x77
    burstWrapCmdDmyClk              0x03
    burstWrapDataMode               0x02
    burstWrapData                   0x40
    deBurstWrapCmd                  0x77
    deBurstWrapCmdDmyClk            0x03
    deBurstWrapDataMode             0x02
    deBurstWrapData                 0x00f0
    timeEsector                     0x012c
    timeE32k                        0x04b0
    timeE64k                        0x04b0
    timePagePgm                     0x0005
    timeCe                          0xffff
    pdDelay                         0x03
    qeData                          0x00
    ()
    Clock configuration
    --------------------------------------------------------------------------------
    --------------------------
    xtalType                        0x04
    pllClk                          0x04
    hclkDiv                         0x00
    bclkDiv                         0x01
    flashClkType                    0x03
    flashClkDiv                     0x01
    ()
    Image information
    --------------------------------------------------------------------------------
    --------------------------
    bootCfg                         0x3300
    imgSegmentInfo                  0xa450
    bootEntry                       0x0000
    imgStart                        0x2000
    SHA256 hash                     7eab2fa91c9f93e138c8f1b410de161a96608e3409844bb3
    d44d12a1f1e8861f
    ()
    SHA256 hash does NOT match!!!
    
    Helpful post? Buy me a coffee.
  • #83 21627548
    gamelaster
    Level 5  
    >>21627544

    This tool seems to not parse whole header, there are fields missing, like the one which describes if to ignore the CRCs or not.

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