logo elektroda
logo elektroda
X
logo elektroda

Beken Flash Dump Partition Info Extraction with RT-Threads Partition Tool - Development Thoughts?

divadiow 858 49
ADVERTISEMENT
  • #31 21737582
    divadiow
    Level 37  
    Code: Text
    Log in, to see the code
  • ADVERTISEMENT
  • #33 21737592
    divadiow
    Level 37  
    wait. what. wtf. i've added rbl to 132000 to first booting BL and it's OTAd and OBK boots.

    insmod wrote:
    same binary crc'ed with old encrypt and 0 0 0 0 flags.


    not uascent key?

    Added after 2 [minutes]:

    >>21737587

    Code: Text
    Log in, to see the code


    M_ALT does not boot btw
  • ADVERTISEMENT
  • #34 21737596
    insmod
    Level 29  
    >>21737592
    First with encrypt_n with uascent keys, then added partitions and then crc'ed it with zero keys.
    OTA works because i've changed tuya keys to uascent at 0x3c, 16 bytes length in bk7231n_bootloader.bin (not encrypted one).
  • #35 21737601
    divadiow
    Level 37  
    ooh ok. ok.

    ah, linking to ..?
    insmod wrote:
    Tuya keys are at 0x48-0x57


    I didn't follow that up
  • #36 21737604
    insmod
    Level 29  
    >>21737601
    Oops, i've changed it at wrong address, 0x48-0x57 is correct.
    If OTA completes, does it boot?
  • ADVERTISEMENT
  • #37 21737608
    divadiow
    Level 37  
    insmod wrote:
    If OTA completes, does it boot?


    yes.

    with the BL from here + rbl at 12A000 =

    Code: Text
    Log in, to see the code
  • ADVERTISEMENT
  • #39 21737612
    divadiow
    Level 37  
    insmod wrote:
    Here's a fixed one


    same experience

    Code: Text
    Log in, to see the code
  • Helpful post
    #41 21737626
    divadiow
    Level 37  
    M_ALT does boot on zero-keys BK7231N module. OTA does work

    Code: Text
    Log in, to see the code


    OpenBK7231M_ALT_QIO_1.18.206.bin -> OpenBK7231N_1.18.204.rbl

    old-SDK M QIO does not boot still because of this: https://www.elektroda.com/rtvforum/topic4107851.html#21725511

    PR not submitted for change yet

    These are test devices btw

    Uascent key = blue CB3S from Matter mini switch
    Zero key = white UAM026 from Uascent bulb (yes a Uascent with zero keys)

    Two NiceMCU WB3S_V1 modules on a blue background with yellow labels. Two microcontroller boards on a blue surface, with USB-C ports and wireless modules

    Added after 4 [minutes]:

    >>21737614

    this does not boot on M

    Added after 2 [minutes]:

    UAM026 = BL2028N https://www.elektroda.com/rtvforum/topic4111089.html#21477454
  • #43 21737644
    divadiow
    Level 37  
    Ok cool. We'll feed that into the build for the uascent section and can finally, hopefully, release Uascent QIO in the BK7231N zip?

    Added after 1 [hours] 51 [minutes]:

    I'll give that a go. I should be almost there a with a branch only 10 days ago I think.

    @p.kaczmarek2 partition detection is still a useful thing in itself though? This doesn't affect that adventure?

    I can imagine using partition detection on backups mostly, but maybe it'd be useful for when a user reports OTA not working and they've flashed app, but not QIO, maybe to a BK7238 or a non-Tuya BK-T?
  • #44 21737851
    p.kaczmarek2
    Moderator Smart Home
    I think I can add it to Easy Flasher as well. Still, first I want to verify the CRC - do you have a correct CRC16 implementation for that at hand?
    Helpful post? Buy me a coffee.
  • #45 21737853
    divadiow
    Level 37  
    well, the uncrc.py I've been using to date appears to have worked without issues on the many dumps I've played with this past week. Does that provide enough info/confirmation of what you require?

    Code: Python
    Log in, to see the code
  • #46 21737854
    p.kaczmarek2
    Moderator Smart Home
    nevermind, i got it
    C code verifying CRC and copying data, with memmove() line highlighted.

    Added after 1 [minutes]:

    Your uncrc does not actually check the CRC. So you can run it with any data and it will work blindly.

    You should rather code:
    Code: C / C++
    Log in, to see the code
    Helpful post? Buy me a coffee.
  • #47 21737858
    divadiow
    Level 37  
    ah ok ok. cool. cheers.
  • #48 21737860
    p.kaczmarek2
    Moderator Smart Home
    Also ,it seems that not all data is CRCed. For me this check begins to fail at 57528 offset.
    Helpful post? Buy me a coffee.
  • #49 21738157
    divadiow
    Level 37  
    oh?

    Also, TLV detection is useful, especially if using, for example, M QIO but then not knowing where the mac and RF is for restoration to the offset OBK expects it to be.
  • #50 21752598
    Apache02
    Level 6  
    https://github.com/Apache02/bk7252-cam/blob/main/tools/uncrc
    https://github.com/Apache02/bk7252-cam/blob/main/tools/crc


    Why do you talking about TLV, OTA and other staff when can simply flash app partition?

    Structure of partitions table described in https://github.com/YangAlex66/bdk_rtt/blob/release/v3.0/packages/fal/inc/fal_def.h
    struct fal_partition
    {
        uint32_t magic_word;
    
        /* partition name */
        char name[FAL_DEV_NAME_MAX];
        /* flash device name for partition */
        char flash_name[FAL_DEV_NAME_MAX];
    
        /* partition offset address on flash device */
        long offset;
        size_t len;
    
        uint32_t reserved;
    };
    


    Quote:
    starting "01PE"

    is uint32_t magic_word which equals to FAL_PART_MAGIC_WROD which equals to 0x45503130


    My example of fal partitions table detection:
    https://github.com/Apache02/bk7252-cam/blob/m...c/shell/shell_commands_beken/commands/fal.cpp

Topic summary

The discussion focuses on extracting Beken flash dump partition information using the RT-Threads Partition Tool to facilitate OpenBK* firmware conversions and enable OTA updates. The main challenge is identifying partition offsets and lengths, particularly the "01PE" partition table signature, which varies in location and requires handling little-endian reverse byte order and CRC16 checksums embedded every 34 bytes. A combined Python script (combined_uncrc_extract_run.py) was developed to remove CRC16 checksums and extract partition tables from firmware dumps, followed by using the RT-Thread partition tool CLI to parse and display partition layouts. The tool supports different partition table formats (fal64 and fal48) and outputs partition names, flash types, addresses, and sizes. Attempts to integrate partition detection directly into OpenBK firmware were discussed, including scanning flash memory for "01PE" signatures and skipping CRCs. The conversation also covers challenges with bootloader compatibility, encryption, and CRC validation, especially for Uascent and Tuya bootloaders on BK7231N and BK7231T chips. Testing showed that OTA functionality depends on correct partition offsets and bootloader keys, with some success in creating replacement bootloaders that support OTA on non-standard layouts. The importance of TLV detection for MAC and RF data restoration was noted. Suggestions include adding partition detection to flashing tools like Easy Flasher and improving CRC16 verification in scripts. Overall, the approach aids in troubleshooting OTA failures by accurately identifying partition layouts and offsets in Beken-based devices.
Summary generated by the language model.
ADVERTISEMENT