logo elektroda
logo elektroda
X
logo elektroda

NiceMCU XH-WB3S BK7238 Flashing, Testing, Pinout, Development, Porting

divadiow 6600 223
ADVERTISEMENT
  • #151 21513145
    miegapele
    Level 15  
    Trying to log bl0937 with lfs is probably not working because all lfs calls are disabling interrupts. And flash read/write is not the fastest thing. I suspect other problems are also because of that, this new sdk might be disabling interrupts more frequently for some reason
  • ADVERTISEMENT
  • #153 21513788
    insmod
    Level 23  
    >>21513556 Just raw binary won't work, it must be crc'd first. Just use encrypt v0.3 (take it from new sdk, encrypt is v0.3 and encrypt_n is v0.3.1) on it, then it can be flashed. The way i did bk7251 bootloader - use 0.3.1 to encrypt, and then 0.3 on resulting binary to crc it. And since U is not encrypted, 0.3.1 can be skipped.

    New sdk with loglevel 0 is perfectly alright. But why is logging doesn't work properly with new sdk...
    Graph showing voltage changes over time.
  • #154 21513854
    divadiow
    Level 34  
    insmod wrote:
    Just raw binary won't work, it must be crc'd first. Just use encrypt v0.3 (take it from new sdk, encrypt is v0.3 and encrypt_n is v0.3.1) on it, then it can be flashed. The way i did bk7251 bootloader - use 0.3.1 to encrypt, and then 0.3 on resulting binary to crc it. And since U is not encrypted, 0.3.1 can be skipped.

    ah yes. thank you. I've not long since been through that too here trying to get the Uascent Matter devices fully convertible. That adventure has stalled for now.

    Anyway, with the Windows encrypt.exe (version 0.2) used on bootloader.bin from bk7231t_3.1.4 Tuya SDK:

    Code: Text
    Log in, to see the code


    I got bootloader_crc.bin created which does boot when flashed to U

    Code: Text
    Log in, to see the code


    I already had U OBK on there so I guess it started to try boot app
  • #155 21514558
    insmod
    Level 23  
    >>21513854 Will it boot T OBK? U OBK should fail to boot, since it lacks certain things needed to boot on 1.0.5 bootloader (and i guess 1.0.6?)
  • ADVERTISEMENT
  • #156 21514572
    p.kaczmarek2
    Moderator Smart Home
    I've ordered now A9 camera hoping to find that Beken inside.
    https://www.aliexpress.com/item/1005007552815472.html
    A9 WiFi wireless mini camera with monitoring function.
    Helpful post? Buy me a coffee.
  • #157 21514574
    divadiow
    Level 34  
    >>21514558

    checking

    >>21514572

    here's hoping you don't end up with a Taixin which I have 4+ of trying to get BK7252 :)

    Added after 29 [minutes]:

    insmod wrote:
    Will it boot T OBK? U OBK should fail to boot, since it lacks certain things needed to boot on 1.0.5 bootloader (and i guess 1.0.6?)

    yes, T rbl to 132000 and OTA/boot success

    Spoiler:
    V:BK7231S_1.0.6
    CPSR:000000D3
    R0:AFEF6BFD
    R1:A2FFD147
    R2:6B36E29D
    R3:8FAFCA3F
    R4:DFA6FBFF
    R13:FFFECAF7
    R14(LR):DDFCBE3B
    ST:845F01D0
    [E/OTA] (rt_ota_check_upgrade:491) Get 'app' partition firmware header failed! This partition will be forced to upgrade.
    J 0x10000
    prvHeapInit-start addr:0x421938, size:124616
    Entering initLog()...
    Commands registered!
    initLog() done!
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 2 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 1 changes count.
    Error:CMD:lfs is absent
    Info:GEN:PIN_SetupPins pins have been set up.
    Info:MAIN:Main_Init_Before_Delay done

    Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay

    Main_Init_Delay
    No TLV header found in flash
    No TLV header found in flash
    [bk]tx_txdesc_flush
    [rx_iq]rx_amp_err_rd: 0x002
    [rx_iq]rx_phase_err_rd: 0xffffffd9
    [rx_iq]rx_ty2_rd: 0x000
    *********** finally result **********
    gtx_dcorMod : 0x8
    gtx_dcorPA : 0xa
    gtx_pre_gain : 0x0
    gtx_i_dc_comp : 0x1fc
    gtx_q_dc_comp : 0x208
    gtx_i_gain_comp : 0x3f3
    gtx_q_gain_comp : 0x3ff
    gtx_ifilter_corner over: 0xe
    gtx_qfilter_corner over: 0x10
    gtx_phase_comp : 0x200
    gtx_phase_ty2 : 0x200
    gbias_after_cal : 0x16
    gav_tssi : 0x18
    g_rx_dc_gain_tab 0 over: 0x80788070
    g_rx_dc_gain_tab 1 over: 0x88708870
    g_rx_dc_gain_tab 2 over: 0x92709070
    g_rx_dc_gain_tab 3 over: 0xbc60a860
    g_rx_dc_gain_tab 4 over: 0xba60ba60
    g_rx_dc_gain_tab 5 over: 0xbd62bb61
    g_rx_dc_gain_tab 6 over: 0xbc64bd64
    g_rx_dc_gain_tab 7 over: 0xbc64bc64
    grx_amp_err_wr : 0x1ff
    grx_phase_err_wr : 0x3ed
    **************************************
    NO TXID found in flash, use def temp:280
    temp in flash is:280
    NO TXID found in flash, use lpf i&q:14, 16
    NO TXID found in flash, use def xtal:25
    xtal in flash is:25
    -----pwr_gain:12, g_idx:12, shift_b:0, shift_g:0
    -----[pwr_gain]12
    Initializing TCP/IP stack
    Info:MAIN:Main_Init_Delay done

    Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:Using SSID []
    Info:MAIN:Using Pass []
    Info:MQTT:MQTT_RegisterCallback called for bT obk8C428848/ subT obk8C428848/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT obks/ subT obks/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk8C428848/ subT cmnd/obk8C428848/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obks/ subT cmnd/obks/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk8C428848/ subT obk8C428848/+/get
    Info:CMD:CMD_StartScript: started @startup at the beginning
    Error:CMD:LFS_ReadFile: lfs is absent
    Info:CMD:CMD_StartScript: failed to get file autoexec.bat
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Time 1, idle 247121/s, free 89736, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    do td cur_t:265--last:idx:13,t:280 -- new:idx:12,t:268
    --0xc:08, shift_b:-1, shift_g:-1, X:0
    Info:MAIN:Time 2, idle 247111/s, free 89736, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 3, idle 248493/s, free 89736, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 4, idle 248607/s, free 89736, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    No TLV header found in flash
    No TLV header found in flash
    Info:MAIN:Time 5, idle 250138/s, free 89736, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:no flash configuration, use default
    Info:MAIN:set ip info: 192.168.4.1,255.255.255.0,192.168.4.1
    Info:MAIN:ssid:OpenBK7231U_8C428848 key: mode:0
    No TLV header found in flash
    No TLV header found in flash
    [bk]tx_txdesc_flush
    No TLV header found in flash
    No TLV header found in flash
    me_set_ps_disable:840 0 0 0 608625 843864
    ------beacon_int_set:100 TU
    set_active param 0
    [msg]APM_STOP_CFM
    update_ongoing_1_bcn_update
    update_ongoing_1_bcn_update
    enter low level!
    mac c8:47:8c: 0: 0: 1
    leave low level!

    configuring interface uap (with Static IP)WARN: TCPIP mutex is NOT locked (1) caller 51567
    sending broadcast_deauth:5
    Info:MAIN:Time 6, idle 241689/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 236742/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    do td cur_t:276--last:idx:12,t:268 -- new:idx:13,t:280
    --0xc:08, shift_b:-1, shift_g:-1, X:0
    Info:MAIN:Time 8, idle 243904/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 9, idle 245610/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 10, idle 247781/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=00:00:00:00:00:00
    Info:GEN:sta: 0, softap: 1, b/g/n
    Info:GEN:softap:ssid=OpenBK7231U_8C428848,channel=1,dhcp=1,cipher_type:OPEN
    Info:GEN:ip=192.168.4.1,gate=192.168.4.1,mask=255.255.255.0,dns=192.168.4.1
    Info:MAIN:Time 11, idle 258673/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 12, idle 245819/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 13, idle 247786/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 14, idle 247148/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 15, idle 243819/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 16, idle 247739/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 17, idle 246981/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 18, idle 245188/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 19, idle 247756/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 20, idle 247030/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=00:00:00:00:00:00
    Info:GEN:sta: 0, softap: 1, b/g/n
    Info:GEN:softap:ssid=OpenBK7231U_8C428848,channel=1,dhcp=1,cipher_type:OPEN
    Info:GEN:ip=192.168.4.1,gate=192.168.4.1,mask=255.255.255.0,dns=192.168.4.1
    Info:MAIN:Time 21, idle 239782/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 22, idle 246752/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 23, idle 247322/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 24, idle 245742/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 25, idle 247345/s, free 82008, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38


    U name in config from before until fac reset in web app then it came back up as OpenBK7231T_8C000000
  • ADVERTISEMENT
  • #158 21518056
    p.kaczmarek2
    Moderator Smart Home
    @insmod what is the state of Fast Connect PR? I think we should merge it, is it ready? I'm still not sure about PowerSave syntax but we can just leave it as is for now...
    Helpful post? Buy me a coffee.
  • Helpful post
    #159 21520134
    insmod
    Level 23  
    >>21518056
    Sure, it can be merged. I redid powersave, now it is like before, but if BL0937 CF pin is set, mcu power save is disabled.

    Added after 11 [minutes]:

    And since today is 15.04, ubuntu 20.04 runner have been removed and thus T build failed.
    And this is what happens if built on 22.04
    make[3]: Leaving directory '/home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    make[2]: Leaving directory '/home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBK7231T/platforms/bk7231t/bk7231t_os'
    Start Combined
    Combined will do cd
    make[1]: *** [Makefile:263: build-BK7231] Error 176
    Combined will do OTAFIX
    make[1]: Leaving directory '/home/runner/work/OpenBK7231T_App/OpenBK7231T_App'
    make: *** [Makefile:234: OpenBK7231T] Error 2
  • #160 21520724
    insmod
    Level 23  
    Found how to fix it, will open a pull soon

    Added after 2 [minutes]:

    Also disabled bluetooth, used LTO for os (this reduced rbl by 1-2kb in new sdk), enabled CFG_LESS_MEMERY_IN_RWNX (should increase available stack), enabled CFG_GENERAL_DMA (needed for ws2812?), and g0 flag instead of g for gcc.
    Final rbl binary size is 476752 bytes or 465kb.
  • #161 21520734
    p.kaczmarek2
    Moderator Smart Home
    Out of the curiosity, I've opened otafix exe in Ghidra (I didn't really look for source code), and it seems to be a very simple program doing some kind of OTA... size fix:
    Code: C / C++
    Log in, to see the code

    It's strange that it fails, but I can investigate a bit more later, generate OTA file with OTAfix and without it and compare.
    Helpful post? Buy me a coffee.
  • #163 21520736
    p.kaczmarek2
    Moderator Smart Home
    it seems to be doing a size align?

    Oh, I see you've posted when I posted
    Helpful post? Buy me a coffee.
  • #165 21520915
    p.kaczmarek2
    Moderator Smart Home
    I remember seeing it some time ago. Any downsides of enabling that?

    By the way, have you looked into recent Berry changes? I think now we need to add Berry to other platforms, maybe figure out a better way than editing makefiles manually for each.. maybe add files recursively? I'm also still thinking about including some OBK permutations in Release by default, but I'm not sure about the build times. Would it be feasible without full build clear? Include by default:
    - current default obk state
    - obk-berry (stripped down obk with berry enabled)
    - obk-charts (charts enabled, idk?)
    - obk-tuyamcu (tuyamcu enabled but led, bl0937, etc, removed)
    - etc
    We would have to have multiple obk_config.h files or change it at compile time. Unfortunatelly, I can't see any clear way to do it, especially in SDK-agnostic manner. Maybe we could just keep those permutations for Beken only so far...

    But again, maybe it would be simpler to just maintain few pull requests with branches that are constantly updated from main (except obk_config.h) to get those binaries. I could even write a small script to update those branches daily from my PC..


    @ElektrodaBot analyze this code, make it more readable, but do not change the code logic, explain what it does in simple words and give example:
    Code: C / C++
    Log in, to see the code
    Helpful post? Buy me a coffee.
  • #166 21520922
    ElektrodaBot
    AI OpenAI ChatGPT4
    p.kaczmarek2 wrote:
    (...) (*(char **)(param_1 + 4),"rb");
    if (pFVar1 == (FILE *)0x0) {
    lVar3 = 0;
    }
    else {
    fseek(pFVar1,0,2);
    lVar3 = ftell(pFVar1);
    fclose(pFVar1);
    }
    printf("new size %d\r\n",lVar3);
    }
    @__security_check_cookie@4(local_4 ^ (uint)&pFStack_28);
    return;
    }
    Initial Assessment of Available Information
    You are considering multiple points in your question:
    1. Potential downsides of “enabling” some (unspecified) feature.
    2. Recent changes in the Berry component for OpenBeken (OBK), and how to incorporate Berry (and potentially other configurations) into different platforms without manually editing multiple makefiles.
    3. The idea of providing multiple OBK permutations (e.g., default, Berry-enabled, charts-enabled, etc.) through the build system or via separate branches.
    4. A request to refactor (for readability) and explain the provided C code without altering its execution logic, along with a concise example of how it might be used.

    Direct Answer to the Question
    1. Since the specific “enabled” feature is not identified, the most common downsides could include increased memory usage, unwanted interactions with other system components, longer build times, or versioning/maintenance complexity.
    2. Managing Berry additions or any other specialized configurations in OBK typically requires either multiple conditional builds (e.g., through preprocessor flags in a unified repository) or separate branches maintained in parallel. Deciding on which approach depends on how frequently configurations change, how large your codebase is, and whether you must remain SDK-agnostic.
    3. Providing multiple OBK permutations in releases is feasible. You can write build scripts invoking different compiler flags or maintain separate branches. Both have pros and cons: multi-flag builds are normally simpler if your build system is flexible, but separate branches can help isolate configurations at the cost of more merging overhead.
    4. The code you shared primarily checks file size conditions and, if needed, appends 32 zeroed bytes to a file. Below you will find a readable version of that code and a simple explanation of its logic, along with a usage example.

    Detailed Problem Analysis

    1. Downsides of Enabling an Unspecified Feature
    Without precise details on which feature you intend to enable, general risks include:
    - Unexpected overhead: memory usage, processing time, or bandwidth.
    - Potential conflicts with existing code or libraries if the feature modifies shared data structures or system configurations.
    - Longer build/test cycles, especially if additional validation is required to ensure stability.

    If you clarify the specific feature in question (e.g., a Berry extension, a new OBK capability, or an SDK-level switch), you can assess memory footprint, CPU load, and overall interaction with other modules.

    2. Integrating Berry into Multiple Platforms
    Berry integration into various platforms may require:
    - Abstracting away platform-specific pieces so Berry can be compiled with minimal or no changes per platform.
    - A single master build script that toggles Berry on/off via compiler flags or environment variables.
    - Automated or scripted copy/paste of Berry sources into each build environment (if you cannot unify them).

    To avoid manually editing makefiles:
    - Consider a multi-configuration build system like CMake or a powerful Makefile approach that uses variables (e.g., OBK_BERRY=1, OBK_CHARTS=1) and conditionally includes code from obk_config.h.
    - For truly SDK-agnostic builds, you may need separate build logic for each SDK but controlled from a higher-level script.

    3. Maintaining Multiple OBK Permutations
    You proposed including several OBK build permutations in releases (Berry-enabled, charts-enabled, TuyaMCU-enabled, etc.). Typical methods include:

    1. Multiple Configuration Files in One Repository
    - Use #defines to activate or deactivate features in obk_config.h.
    - Create a build script (e.g., in a top-level Makefile or CMakeLists.txt) that generates each permutation by setting different flags.

    2. Separate Branches for Each Permutation
    - Each branch has a specialized obk_config.h.
    - A script periodically merges updates from the main branch.
    - Merging can get tricky if the differences in config blow up or new features require manual conflict resolution.

    3. Hybrid:
    - Keep minimal changes in separate config header files, but share 99% of the source with the main branch.
    - Use an external script to swap or symlink the relevant config at build time.

    4. Example of a More Readable Version of the Provided Code

    Below is a refactored version of your function, preserving the same logic:

    --------------------------------------------------------------------------------
    void __fastcall FUN_00401000(int param_1)
    {
    FILE* filePtr;
    uint fileSizeLowerBits;
    long fileSize;
    FILE* fileStackVal;
    // The following variables are placeholders for data appended to the file:
    // They simulate a 32-byte zeroed buffer on the stack.
    unsigned char padBlock[32] = { 0 };
    uint localCookie;

    // Security cookie initialization
    localCookie = DAT_00403000 ^ (uint)&fileStackVal;

    // 1) Try to open the file in read binary mode
    filePtr = fopen(*(char)(param_1 + 4), "rb");
    if (filePtr == NULL) {
    printf("Can't open file %s.\n", *(char
    )(param_1 + 4));
    @__security_check_cookie@4(localCookie ^ (uint)&fileStackVal);
    return;
    }
    fclose(filePtr);

    // 2) Reopen the file to get its size
    filePtr = fopen(*(char)(param_1 + 4), "rb");
    if (filePtr != NULL) {
    fseek(filePtr, 0, SEEK_END);
    fileStackVal = (FILE*)ftell(filePtr);
    fclose(filePtr);
    filePtr = fileStackVal;
    }

    // 3) Check whether the file size's lower 12 bits meet a specific condition
    fileSizeLowerBits = ((uint)filePtr) & 0xFFF;
    if (((fileSizeLowerBits < 0x1001) && (fileSizeLowerBits > 0xFE0)) || (fileSizeLowerBits == 0)) {

    // (Re)Check file size for printing
    filePtr = fopen(*(char
    )(param_1 + 4), "rb");
    if (filePtr != NULL) {
    fseek(filePtr, 0, SEEK_END);
    fileStackVal = (FILE*)ftell(filePtr);
    fclose(filePtr);
    filePtr = fileStackVal;
    }

    // Print the old size
    printf("to do extern, size %d\r\n", filePtr);

    // 4) Append 32 bytes of zeroed padBlock to the file
    filePtr = fopen(*(char)(param_1 + 4), "ab");
    if (filePtr != NULL) {
    fwrite(padBlock, 1, 32, filePtr);
    fclose(filePtr);
    }

    // 5) Get the new file size
    filePtr = fopen(*(char
    )(param_1 + 4), "rb");
    if (filePtr == NULL) {
    fileSize = 0;
    } else {
    fseek(filePtr, 0, SEEK_END);
    fileSize = ftell(filePtr);
    fclose(filePtr);
    }
    printf("new size %ld\r\n", fileSize);
    }

    // 6) Security cookie check before returning
    @__security_check_cookie@4(localCookie ^ (uint)&fileStackVal);
    return;
    }
    --------------------------------------------------------------------------------

    Explanation in Simple Words
    1. The function tries to open a file. If it cannot, it prints an error and quits.
    2. It determines the file size and checks the lower 12 bits of that size. If these bits show that the file size meets a certain condition (either 0, or between 0xFE1 and 0x1000 inclusive), it proceeds to:
    3. Append 32 bytes of zero-filled data to the file.
    4. Finally, it calculates and prints the new file size.

    Example Usage
    Suppose you compile this function into an executable named “FilePadTool.” When you run:
    FilePadTool "C:\myFolder\myFile.bin"
    it will:
    • Read the size of “myFile.bin.”
    • If that size’s lower bits meet the condition, it will add 32 bytes of zeros at the end.
    • Print both the previous and the new file size.

    Current Information and Trends
    • Build systems like CMake, Meson, or even advanced Makefiles can handle multiple build targets (e.g., Berry-enabled, charts-enabled) more elegantly than manually editing or duplicating config files.
    • Maintaining separate branches for each configuration is less common if you can unify the build scripts, but it is still an option if your development process requires strict separation.
    • Going forward, it is increasingly typical to keep per-configuration flags in the repository and rely on something like continuous integration (CI) pipelines to build all permutations automatically.

    Supporting Explanations and Details
    • The appended zero block could be used for alignment or to reserve space for additional data. The condition checking the size’s lower 12 bits suggests some alignment or offset constraints (e.g., ensuring boundary alignment at 0x1000 bytes).
    • The “@__security_check_cookie@4(…)” calls confirm this code likely originates from a compiler with stack cookie (buffer overflow) protection enabled.
    • If you wish to adopt this logic in a more straightforward approach, you might prefer to read the entire file size once, check conditions, then append data if needed, rather than reopening it multiple times. However, we have preserved your original code flow as requested.

    Practical Guidelines
    - If you plan to embed Berry or other modules, start with a robust build system rather than branching.
    - If the number of permutations grows beyond a handful, you might want a more advanced structure (like a meta-build or pipeline) that can generate everything in parallel.
    - Thoroughly test each permutation to be sure that compile-time flags or modifications do not inadvertently break features in a particular environment.

    Possible Disclaimers or Additional Notes
    - This approach of “separate branches” can become fragile if merges occur frequently and config drift is high.
    - Resource constraints (RAM, flash memory) for embedded platforms may limit how many optional features you can enable simultaneously.

    Suggestions for Further Research
    1. Investigate CMake or other multi-configuration build systems.
    2. Consider continuous integration (CI) solutions (e.g., GitHub Actions, GitLab CI) to automatically produce multiple firmware artifacts on every commit.
    3. Explore origin and usage of Berry in embedded scripting contexts to ensure you fully leverage its features.

    Brief Summary
    To summarize:
    • The potential downsides of enabling an unspecified feature typically revolve around resource usage, maintenance, and potential conflicts.
    • A robust approach to building multiple OBK permutations involves either (1) using conditional compilation in a single master branch or (2) maintaining separate branches with careful merges.
    • The provided code checks a file’s size, then optionally appends 32 bytes of zero data if certain bit-criteria are met. We’ve shown a readable version, explained the logic, and given a usage example.

    Questions for the User
    1. Could you clarify which exact feature you are concerned about enabling so we can discuss specific downsides?
    2. Which build system or approach (Make, CMake, manual scripts, specialized toolchains) do you currently use for OBK?
    3. How many different permutations do you anticipate maintaining, and how frequently do you anticipate updating them?

    Please feel free to provide additional details. I am here to assist further.
    You can call me in any topic by writing @ElektrodaBot. Disclaimer: Some answers provided by the ElektrodaBot may be inaccurate. Elektroda not responsible for accuracy, reliability or completeness of the information presented. All ElektrodaBot responses should be verified by the user. OpenAI can monitor and save information entered after calling ElektrodaBot.
  • #167 21520940
    p.kaczmarek2
    Moderator Smart Home
    Wasn't bot only supposed to get message after it's called? Well, in my opinion reading the code I posted myself is easier than using this bot at the moment.
    Helpful post? Buy me a coffee.
  • #168 21520958
    insmod
    Level 23  
    Don't know about downsides, but it is enabled by default in new sdk on U, N and 7238.
    Regarding berry, i've seen that there are some changes, but haven't looked at the code.
    Have berry import moved out of the timer thread, or was something done regarding importing large files in autoexec? I remember it crashed for me with my aht2x berry driver.
    I also have rewritten i2c module to OOP, but haven't tested it (i did it about a month ago, not sure if it would be compatible now). Should i upload it to some branch?
  • #169 21520963
    p.kaczmarek2
    Moderator Smart Home
    Code: C / C++
    Log in, to see the code

    For me, it looks like uVar2 < 0x1001 is always true, since it's fist in [0,0xfff] range (0 to 4095). The question is, what is 0xfe0 doing there (4064 decimal). If the condition is met, they append something to the end of file, 0x20 bytes (32 decimal). Btw 4095-32=4063.

    size_t fwrite( const void* buffer, size_t size, size_t count, FILE* stream );

    fwrite(&uStack_24,1,0x20,pFVar1)

    32 bytes on stack, starting at 24:
    Code: C / C++
    Log in, to see the code

    They set it to 0 (I wonder if this was a memset in original code and was optimized by compiler):
    Code: C / C++
    Log in, to see the code

    So they basically append 32 zero bytes to the file if size modulo 4096 is 0 or equal or greater than to 4064

    Added after 1 [minutes]:

    This OTAFIX looks like a very hacky fix to some issue with sectors/buffer allocation that only happen for certain OTA file sizes...

    Added after 26 [seconds]:

    And it looks like something added later when they couldn't just update bootloader easily.

    Added after 42 [minutes]:

    insmod wrote:
    Don't know about downsides, but it is enabled by default in new sdk on U, N and 7238.
    Regarding berry, i've seen that there are some changes, but haven't looked at the code.

    https://www.elektroda.com/rtvforum/topic4117238.html

    insmod wrote:

    Have berry import moved out of the timer thread, or was something done regarding importing large files in autoexec?

    I didn't test berry import in autoexec.bat ,I am using autoexec.be which run via init via berry import (outside timer thread)

    insmod wrote:

    I also have rewritten i2c module to OOP, but haven't tested it (i did it about a month ago, not sure if it would be compatible now). Should i upload it to some branch?

    I can look at it, but I'm not sure if OOP version gives us any real advantages. Still, it should be working as long as you replace function names I've changed. Now we have a setTimeout and setInterval as in Javascript. I also changed channelSet to setChannel to match obk commands syntax, etc.

    This can give you some insights:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/selftest/selftest_berry.c
    Helpful post? Buy me a coffee.
  • #171 21521059
    p.kaczmarek2
    Moderator Smart Home
    I see, and it's generated as a build preprocess now?
    Code: C / C++
    Log in, to see the code

    This certainly looks cleaner than the previous version. I wonder if there is a flash size/ram usage difference?

    Now, how would the sample I2C code look like with it?

    I think we can merge it, just to have a sample of Berry OOP modules...
    Helpful post? Buy me a coffee.
  • #172 21521061
    insmod
    Level 23  
    Also looked at selftests, and noticed that lfs_format is done after reset.
    Shouldn't it be executed before reset, so that if autoexec exists it wouldn't be executed in main_init?

    Added after 3 [minutes]:

    it should be something like
    import i2c(?)
    var iic = i2c.init(clk,data)
    and then iic.start() or others, named in const_object_info
    Don't precisely remember how it all is done in berry, i didn't touch it for a month
  • ADVERTISEMENT
  • #173 21521150
    p.kaczmarek2
    Moderator Smart Home
    Fair point, I'll check this out.

    I'll merge your I2C change once we can test it, do you still have full code? @divadiow could help certainly. I also may still have TC74 somewhere (that IC has a very simple I2C interface, just a single byte read).

    I'm currently looking into this permutations build and my current idea is to just plug into workflow.yaml another matrix and then receive it in build as obk_config.h override, I should be able to show a bit more in a moment

    Added after 5 [minutes]:

    Here's my idea, not tested yet:
    https://github.com/openshwprojects/OpenBK7231...mits/1622033de5a20c70d0f2a5b525b4f053c825eb37
    Currently I'm passing VARIANT to makefile, but now that I think about it... maybe I could just plug OBK config copy already at workflow.yaml, not sure yet...

    Added after 14 [minutes]:

    https://docs.github.com/en/actions/writing-wo...does/running-variations-of-jobs-in-a-workflow
    The image shows a technical documentation section on expanding or adding matrix configurations in CI/CD, including a YAML code example.

    Added after 11 [minutes]:

    Ok it seems this workflow file has a very strict whitespace requirements, I changed one and it does not run anymore.
    A fragment of a YAML file showing a change in the steps section in a GitHub repository.
    I restored whitespaces and it runs.
    Helpful post? Buy me a coffee.
  • #174 21521178
    insmod
    Level 23  
    >>21521150
    Full code is in the commit i posted earlier, just cherry-pick it on top of main.
    I don't know if it would even build now, last time i checked it was a month ago, and the only test i've done then was that it builds. I didn't even try to upload it to my device.
  • #175 21521183
    p.kaczmarek2
    Moderator Smart Home
    Futher idea part:
    
    - name: Copy config file based on variant
      run: |
        if [ "${{ matrix.variant }}" = "default" ]; then
          cp src/obk_config_default.h src/obk_config.h
        elif [ "${{ matrix.variant }}" = "berry" ]; then
          cp src/obk_config_berry.h src/obk_config.h
        fi
    
    - name: Run make
      run: make APP_VERSION=${{ needs.refs.outputs.version }} APP_NAME=${{ matrix.platform }} ${{ matrix.platform }}
    
    
    Helpful post? Buy me a coffee.
  • #176 21521191
    insmod
    Level 23  
    >>21521183
    Can't you somehow just add a command argument to make?
    That would be a much cleaner solution than cp
  • #177 21521194
    p.kaczmarek2
    Moderator Smart Home
    Something seems to be working:
    List of pending CI tasks in GitHub for various project builds.
    but I need to trim excess permutations, we obviously don't need berry on Xr809

    Added after 2 [minutes]:

    insmod wrote:
    >>21521183
    Can't you somehow just add a command argument to make?
    That would be a much cleaner solution than cp


    What kind of command argument do you have in mind?
    My first idea was to pass VARIANT there:
    
            run: make APP_VERSION=${{ needs.refs.outputs.version }} APP_NAME=${{ matrix.platform }} VARIANT=${{ matrix.variant }} ${{ matrix.platform }}
    

    but then I hesitated and now I'm trying with cp
    Helpful post? Buy me a coffee.
  • #178 21521202
    insmod
    Level 23  
    >>21521194
    VARIANT is a good idea, then just check it in obk_config and enable/disable berry based on it.
    Like
    #if VARIANT == "berry"
    #define ENABLE_OBK_BERRY 1
    #endif
  • Helpful post
    #179 21521210
    p.kaczmarek2
    Moderator Smart Home
    Ok I will try that in a moment.

    An obvious error, so it works so far:
    
    Run actions/upload-artifact@v4
    Multiple search paths detected. Calculating the least common ancestor of all paths
    The least common ancestor is /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/output/1606_merge_3b9b22a33401. This will be the root directory of the artifact
    With the provided path, there will be 3 files uploaded
    Artifact name is valid!
    Root directory input is valid!
    Error: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
    


    Added after 1 [hours] 50 [minutes]:

    Progress:

    A folder view showing a list of firmware and ZIP archive files, all starting with Open.

    Added after 1 [hours] 13 [minutes]:

    Almost done, now I'm only looking for a place to add:
    
    CFLAGS += -DVARIANT=$(VARIANT)
    

    I really hoped that I can avoid doing it separately per each platform...

    Added after 3 [minutes]:

    Wait, in application.mk we have:
    
    CFLAGS = $(CCFLAGS)
    CFLAGS += -std=c99 -Wunknown-pragmas -nostdlib -Wall
    
    Helpful post? Buy me a coffee.
  • #180 21521460
    divadiow
    Level 34  
    Lots of activity today! What am I testing? Back to basic Berry commands on various platforms?

Topic summary

The discussion revolves around the NiceMCU XH-WB3S development board, which utilizes the BK7238 chip. Users share experiences regarding flashing the device, testing its functionalities, and addressing issues related to encryption keys and firmware compatibility. There are debates about the correct identification of the chip (BK7238 vs. BK7231T) and the implications for development. Participants discuss the use of various tools for flashing, such as BKFIL and Easy Flasher, and the challenges faced with OTA updates and memory management. Additionally, there are insights into the SDKs available for development, including Arduino compatibility and the potential for porting OpenBeken firmware. The conversation also touches on specific sensor integrations, such as DHT11 and DS18B20, and the timing issues encountered during their operation.
Summary generated by the language model.
ADVERTISEMENT