logo elektroda
logo elektroda
X
logo elektroda

RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?

divadiow 10542 278
ADVERTISEMENT
  • #91 21364361
    insmod
    Level 22  
    >>21364357 The config will be overwritten as it is now. So to keep it, something will have to be changed.
    Current partition table:
    {
        "__comment__":"global setting",
        "rotpk_ena": 0,
        "partab": {
            "ptable": {
                "ota_trap": {
                    "valid": 0,
                    "level": 0,
                    "port": 0,
                    "pin": 0
                },
                "mp_trap": {
                    "valid": 0,
                    "level": 0,
                    "port": 0,
                    "pin": 0
                },
                "key_exp_op": 2,
                "user_len": 256,
                "user_ext": "FFFFFFFFFFFFFFFFFFFFFFFF",
                "user_bin": "user.bin",
                "items": [ "boot", "ota1", "ota2" ]
            },
            "boot": {
                "start_addr": "0x4000",
                "length": "0x8000",
                "type": "BOOT",
                "dbg_skip": false,
                "hash_key": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
            },
            "ota1": {
                "start_addr": "0x10000",
                "length": "0xE0000",
                "type": "FW1",
                "dbg_skip": false,
                "hash_key": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E5F"
            },
            "ota2": {
                "start_addr": "0xF0000",
                "length": "0xE0000",
                "type": "FW2",
                "dbg_skip": false,
                "hash_key": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E5F"
            },
            "cfg": {
                "start_addr": "0x1D0000",
                "length": "0x18000"
            },
            "lfs": {
                "start_addr": "0x1E8000",
                "length": "0x18000"
            }
        }
    }
  • ADVERTISEMENT
  • #92 21364364
    p.kaczmarek2
    Moderator Smart Home
    Is there a space to move OBK config somewhere else? This post-flash pins extraction is very useful for many users.

    I'm updating Web App to have separate Tuya config address for RTL right now.
    Helpful post? Buy me a coffee.
  • #93 21364400
    insmod
    Level 22  
    >>21364364 Either by reducing fw partitions size some, or reducing cfg and/or lfs partitions size.
    From dump, tuya partition ends at 0x1e7000. This makes only 0x19000 space available to the end of the flash.
    But, perhaps obk cfg or lfs can be squeezed between fw2 and tuya cfg, where only 0x8000 unused space available. What is better? I rarely use lfs, and mainly for autoexec/early.bat. Cfg, on the other hand, is changed much more often. Flash vars are also stored on cfg partition.
  • #94 21364456
    p.kaczmarek2
    Moderator Smart Home
    mainConfig_t size is currently 3584 bytes (or similiar), I don't think it will ever grow beyond single page - 4096 decimal (0x1000 hexadecimal). If we assume that, we still have 0x7000 (7 pages) for Flashvars, which change often. But flashvars size is 64, and page is 4096, so we do one erase cycle per.... 4096/64 = 64 , per 64 flash var changes. And that is distributed over 7 pages. I hope it can be enough to ensure that flashvars won't wear flash too early?

    LittleFS should have at least the option to grow very big so people can host size. If possible, we can make small LittleFS by default at the end of some kind OTA partition and allow users to grow it with the drawback that OTA will erase LittleFS - that's what happens on Beken. I'm not sure if it's possible here.
    Helpful post? Buy me a coffee.
  • #95 21364480
    insmod
    Level 22  
    >>21364456 Flashvars are 80 bytes, because time_t is 64bit in arm-none-eabi-gcc in ubuntu 20.04 (gh actions). So it is that, + whatever else easyflash will add.
    + on tr6260 0x3000 was not enough for cfg without flashvars

    Added after 30 [minutes]:

    And what is default lfs size? Perhaps default it to 0x8000, and then, if needed, expand it to encompass tuya cfg.
  • #96 21364549
    p.kaczmarek2
    Moderator Smart Home
    I see... it seems that Flashvars have grown outside of my control. In my Windows selftest code, I am still using 32-bit time_t (there is a define for that on Windows) and the following check passes:
    Screenshot showing code in Visual Studio with highlighted if conditions for FLASH_VARS structure.

    I didn't take in account easyflash, but I have nothing against using it. In the past I've been considering moving our BK flashvars method to shared source and only call HAL for flash, but I don't think it's worth it. We need to just support new platforms, we can use EasyFlash if it makes progress faster.

    LFS sizes seem to be defined in our_lfs.h:
    Code: C / C++
    Log in, to see the code

    I think they are acceptable. LittleFS can also overwrite Tuya Config when user intentionally specifies larger size than default, I see no problem with that. We just need Tuya Config to survive first OBK flash done by any new user, because it's often very useful to have that config when we're helping beginners.
    Helpful post? Buy me a coffee.
  • #97 21364807
    insmod
    Level 22  
    Updated. Cfg is now 0x10000 size at 0x1F0000, lfs 0x20000 size at 0x1D0000.
    I could've easily ported all of the platforms to easyflash, but it is a too major breaking change, as everyone current configs would be erased.
    Just store easyflash code in main obk src/libraries, and use ifdefs for each platform in ef_port.c and ef_cfg.h, and voila.
  • ADVERTISEMENT
  • #98 21364835
    DeDaMrAz
    Level 19  
    insmod wrote:
    I could've easily ported all of the platforms to easyflash


    You can try that on your fork for T platform that is problematic atm for lfs reasons mentioned above. Maybe?

    Also biggest hit for the project will be ESP82xx port as with it we will have 95% of the commercially available IOT devices covered.

    Just sharing my thoughts on this statement.
  • #99 21364850
    p.kaczmarek2
    Moderator Smart Home
    Using easyFlash for OBK config would break our BK7231 Easy Flasher ability to configure on flash, which was requested by users who don't want to manually do AP configuration for their SSID and password.

    Added after 1 [minutes]:

    EasyFlash would break this:
    https://github.com/openshwprojects/BK7231GUIFlashTool/blob/main/BK7231Flasher/OBKConfig.cs
    Helpful post? Buy me a coffee.
  • #100 21369085
    insmod
    Level 22  
    Is there anything left to do before merge?
    Btw, rtl8710b port is stuck.
    If i try to enable wifi - chip freezes for several minutes, after that it spams "[alloc_skb] Wait for skbdata" and then hard faults.
    Initializing WIFI ...
    LDO Mode, BD_Info: 0 
    [EFUSE Inf] 0 95 81 
    [EFUSE Inf] 2 c2 16 
    [EFUSE Inf] EFUSE_LogicalMap_Read: data end at address=3f
    
    LDO Mode, BD_Info: 0 
    
    [alloc_skb] Wait for skbdata
    
    [alloc_skb] Wait for skbdata
    ...
    [alloc_skb] Wait for skbdata
    RTL8195A[HAL]: Hard Fault Error!!!!
    RTL8195A[HAL]: R0 = 0x5
    RTL8195A[HAL]: R1 = 0x100046d0
    RTL8195A[HAL]: R2 = 0x10005d8c
    RTL8195A[HAL]: R3 = 0x35000001
    RTL8195A[HAL]: R12 = 0xa5a5a5a5
    RTL8195A[HAL]: LR = 0x801816d
    RTL8195A[HAL]: PC = 0x8016a58
    RTL8195A[HAL]: PSR = 0x1000000
    RTL8195A[HAL]: BFAR = 0xe000ed38
    RTL8195A[HAL]: CFSR = 0x1000000
    RTL8195A[HAL]: HFSR = 0x40000000
    RTL8195A[HAL]: DFSR = 0x0
    RTL8195A[HAL]: AFSR = 0x0
    RTL8195A[HAL]: PriMask 0x0
    RTL8195A[HAL]: BasePri 0x0
    RTL8195A[HAL]: SVC priority: 0x00
    RTL8195A[HAL]: PendSVC priority: 0xf0
    RTL8195A[HAL]: Systick priority: 0xf0
    
  • #101 21369807
    p.kaczmarek2
    Moderator Smart Home
    As far as I can tell, the only thing left to do is short testing with W600 or W800 DHT11 sensor to check if timings are correct. My 5x DHT11 set from Aliexpress has just arrived, I will try to do this shortly. I'm very happy with RTL port, good job @insmod , I already have some materials for WBR3 tutorial:
    Photos of several blue electronic modules, one with a close-up view on a breadboard with wires in the background.

    Regarding rtl8710b , can you show existing code?
    My default approach in such cases is to try to narrow down the problem, so I would:
    1. first try to run default sample
    2. then try to import OBK into it, the smaller part of OBK, the better
    3. then gradually enable futher modules
    If you already have OBK imported, then I would suggest stripping down OBK until it work. Disable the pins quick timer thread, add delay before WiFi start, etc.
    Helpful post? Buy me a coffee.
  • #102 21369822
    insmod
    Level 22  
    >>21369807 OBK is already imported, but to even get the logs i had to disable "wlan_network();" in main.c - which is almost the same as in rtl8710c.
    If i call wlan_network in main - it freezes as soon as the task scheduler is started.
    The function itself just creates a task that initializes wifi.
  • ADVERTISEMENT
  • #104 21369849
    insmod
    Level 22  
    >>21369833 No, i didn't consider it important, alongside wifi scanning.
  • #105 21369879
    DeDaMrAz
    Level 19  
    Argument for static is that it is hard for people without any knowledge of LAN, so they can set the address and just go there, without having to know how to find what their DHCP assigned to that device or run a flasher to look through LAN scanner etc.

    But for initial release it is plenty good enough I would say.

    At some point we will run out of chips to support :) and than we can jump in and polish those details.
  • #106 21369894
    p.kaczmarek2
    Moderator Smart Home
    Maybe a threading issue? SDK examples are working but OBK is not?

    Is it this chip?
    Close-up of a microchip labeled RTL8710BX with soldered wires.
    Helpful post? Buy me a coffee.
  • #107 21369897
    insmod
    Level 22  
    >>21369894 I haven't ran any sdk example, but sdk is latest master amb1_sdk, which LT uses too.
    Yes, i have a T102_v1.1 module with BX chip.
  • ADVERTISEMENT
  • #109 21371465
    p.kaczmarek2
    Moderator Smart Home
    Very good! What was wrong before?

    I also have some progress, my DHTs and dev boards arrived:
    Breadboards with electronic modules and accessories
    User interface displaying device status for OpenRTL87X0C_6622C1F4.
    OpenW600 control panel with active toggles and temperature information.
    WBR3 is soldered into NodeMCU board. I think it may be possible to route WBR3 UART to CH340 on this PCB. Not sure about the pins that should be pulled high... in worst case the pull would have to be manual (with extra wires).

    I'm waiting for 10x DS18B20 shipment as well.
    Helpful post? Buy me a coffee.
  • #110 21371473
    insmod
    Level 22  
    >>21371465 freertos settings were wrong, i thought that freertos/lwip in the sdk were too old, so i ported them from Z2 sdk. And while lwip works alright, i experienced the problem mentioned above with rtos. After restoring more or less the settings that were set by default, it started working.
  • #111 21371474
    p.kaczmarek2
    Moderator Smart Home
    That's why I always start with running most simple sample.

    Anway, I would really like to merge it now:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1468
    Is anyone able to do any more tests like today or tomorrow? W600+DS18B20, W800+DS18B20, etc? My DS18B20 set will arrive like in two weeks or so, so I would like to avoid waiting for it. Maybe let's just merge it for now and I'll do more testing later?
    Helpful post? Buy me a coffee.
  • #112 21371669
    max4elektroda
    Level 20  
    p.kaczmarek2 wrote:
    Is anyone able to do any more tests like today or tomorrow? W600+DS18B20, W800+DS18B20, etc?

    Just tested W800+DS1820 driver (LN882H+DS1820 was already proved working fine):
    Works like a charm, in my opinion W800 used to be the most reliable platform regarding timing and DS1820 and I can confirm, it's still working very well (more than 10 minutes with temperature readings every 2 seconds and not a single error!)
    BK7231N+DS1820 works "ok" (exactly like before with occasional reading errors)
    p.kaczmarek2 wrote:
    Maybe let's just merge it for now and I'll do more testing later?

    Yes, just do it!
  • #113 21371681
    p.kaczmarek2
    Moderator Smart Home
    The timing issues are because of this:
    https://github.com/openshwprojects/OpenBK7231T_App/issues/497
    That's why I can't seem to get the WS2812 bit-bang driver working. It could work if we manage to get code to run from RAM, but I haven't managed to do it on Beken. I also remember having similiar problem on BL602.
    Still, it would be very nice to have bit-bang WS2812 on other platforms. It probably would have to be still done via ramfunc... Do you guys @max4elektroda @insmod think it's doable?
    Of course, there is also still the SPI DMA approach but it works only on hardware SPI output.

    PS: In the past I've did WS2812 on simpler MCU (PIC18F45K50) and it worked very well... https://www.elektroda.com/rtvforum/topic3590731.html

    I've merged https://github.com/openshwprojects/OpenBK7231T_App/pull/1468 , good job!
    Helpful post? Buy me a coffee.
  • #114 21371769
    max4elektroda
    Level 20  
    Yea, I know what you mean, this is why I finally introduced "short", "medium" and "long" usleeps for Beken to get DS1820 working.
    Poking around some more I fond the promising:

    sdk/OpenBK7231N/platforms/bk7231n/bk7231n_os/beken378/func/hostapd-2.5/src/utils/os.h:void os_sleep(os_time_t sec, os_time_t usec);

    But switching to " os_sleep(0,delay);" for "usleep(delay);" on BK7231N seems not to work at all...
  • Helpful post
    #115 21377607
    insmod
    Level 22  
    Installed a T102 module in my formerly broken plug, It had an ESP-02S installed (i don't remember what it had originally, either T102 or CB2S), which wore down a capacitor (10v 470uF). After i replaced the broken capacitor, it started working.
    Screenshot of the OpenRTL8710B user interface showing the device in the on state with energy data and statistics.
    Pins and interrupts are working.
    Powersave: 1 is like on rtl8720c (wifi_enable_powersave), 2 is the same + rtl8710b specific rtw_wlan_low_pw_mode's + half the cpu frequency and pa_gain, 3 is quarter the frequency (31.25mhz) and pa_gain /3. Powersave 3 breaks interrupts (values are halved) and sleep (ms and us, both are mitigated with sleepfactor 2).
    OTA is an absolute pain to deal with, it requires a different image for each slot.
    Currently i partially solved it with this:
    (partially because it isn't stable)
    touch empty file,
    echo OBK_OTA_IDX1 >> file
    echo -n (OTA 1 file size) >> file
    echo -n \\0 >> file
    echo (cat ota1 file) >> file
    echo OBK_OTA_IDX2 >> file
    echo (cat ota2 file) >> file

    Ota functions check the current partition,
    if ota1 -> skip until OBK_OTA_IDX2\n is found (with memmem), then write remaining data. If not found throw error.
    else check OBK_OTA_IDX1 is there, get filesize with atoi from header (header is 20 bytes in length for ota1), then receive data with specified length and write it.
    And so, if writing to ota1, when OTA succeeds, because file isn't received fully i get connection reset in browser, so i have to reboot the device manually. When writing ota2 this doesn't happen.
    Sometimes i got failed checksum verification on some binaries, so ota failed until i recompiled the binaries.

    Binaries attached, boot is one-time flash at 0x08000000 (not needed if partitions are the same), the other one is flashed to 0x0800B000.
    If previously flashed firmware was at ota2 and obk doesn't boot - erase 0x080D0000 (any size, like default 4kb)
  • #116 21377654
    vinibali
    Level 6  
    Wow, great job guys. I have a Gosund SP1 laying around for years with CUCO Z0 R V1.2 board (RTL8720CF) and now I just find this page.
    I just found two problems in the meanwhile:
    * bl0942 meter ic is not working in my case, it doesn't show any measurements
    * the restart is not working if the bl0942 driver is loaded
  • #117 21377748
    p.kaczmarek2
    Moderator Smart Home
    nice progress @insmod , I will try to setup something for testing soon

    @vinibali which pin is used for BL0942 uart on your device? I've tested UART on RTL8720CF with fake BL0942 packets and they were received correctly https://www.elektroda.com/rtvforum/topic4093142-60.html#21363681
    Helpful post? Buy me a coffee.
  • #118 21378031
    vinibali
    Level 6  
    >>21377748 Yes, I saw that. I thought the RX and TX pins were used, as I saw that on a topic about T34 and BL0942. If you really want to know, I could open up the device once again :)
  • #119 21378790
    insmod
    Level 22  
    >>21377654 RTL8720CF has 3 uart ports, including log one. Currently log uart is unusable, but then i haven't seen a device that utilizes it.
    Activate flag 26: "[UART] Use alternate UART for BL0942, CSE, TuyaMCU, etc", maybe then it would work.

Topic summary

The discussion revolves around the compatibility of RTL8720DN, RTL8710B, and RTL8710BX with OpenBeken firmware. Users share their experiences with various modules, including BW15 and WBR3, and discuss issues related to memory management, Wi-Fi connectivity, and flashing procedures. Several users report successful flashing and functionality tests, while others encounter problems with memory leaks and device reboots. The conversation also touches on the use of different tools for flashing, such as ltchiptool and rtltool, and the need for proper firmware versions to ensure compatibility. Additionally, there are mentions of specific features like MQTT support, GPIO control, and OTA updates.
Summary generated by the language model.
ADVERTISEMENT