logo elektroda
logo elektroda
X
logo elektroda

RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?

divadiow 12765 337
ADVERTISEMENT
  • ADVERTISEMENT
  • #302 21604634
    p.kaczmarek2
    Moderator Smart Home
    Would you be able to check with that line removed?

    Added after 29 [seconds]:

    I can also upload my tool:
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?

    My port attached. The test procedure I use is simple:
    - I use read_4096 to read 4096 bytes
    - then I use write_lorem_ipsum and do read again to check for lorem ipsum pattern
    - then I try just erase and read to check for 0xFF
    - then i try write back firmware factory version and read again
    Everything works so far, but no checksum, and no flash set as mentioned.

    The only question is why no OBK boot?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #303 21604639
    insmod
    Level 25  
    >>21604605
    I see that bootloader was flashed correctly and it works, since it prints MODULE_BOOT-LEVEL_INFO.
    But it seems that OBK didn't pass checksum check. So FW2 image was used, evident by "OTA2 USE"
    I didn't use rtltool for flashing, only for backup. Original flashing tool worked fine.
  • #304 21604648
    p.kaczmarek2
    Moderator Smart Home
    I am trying to get flashing working in C#, so I can integrate it with our flasher. Currently it seems that I can read and write memory blocks correctly, but without flash unprotect (if that's that I think it is). Should flashing of this BW16E work if I just directly flash OBK bin to 0x00 offset, or do I need to do something more?

    How FW2/FW1 switch works?
    Helpful post? Buy me a coffee.
  • #305 21604654
    insmod
    Level 25  
    [postid:d76072f7b0][/postid:d76072f7b0]
    FW1/FW2 offsets are hardcoded. Bootloader then check for 81958711 signature (all realteks) (0x38 0x31 0x39 0x35 0x38 0x37 0x31 0x31).
    Don't remember how it is on AmebaD, but on Z2 if it is written in both slots, then FW1 is used, if it is written in one slot only, it uses that slot, if it is written in none of them, then boot fails.

    Did you convert easyflasher to interfaces? I once thought to do it for easier new platform integration, but there were too much code to be rewritten.
  • #306 21604659
    p.kaczmarek2
    Moderator Smart Home
    Currently I write OBK RTL binary from Github to offset 0x0, which is later processed by flasher code:
    
                int writeOffset = address & 0x00ffffff;
                writeOffset |= 0x08000000;
    

    So it's flashed to 0x08000000 and that's all I know so far.

    The signature you mentioned appears in both factory and OBK firmwares at the same offsets.
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    Maybe I should try full erase first.

    Added after 1 [minutes]:

    You mean OBK config in Easyflash? No work was done for that yet
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #307 21604660
    insmod
    Level 25  
    >>21604659
    No, i meant OBK flashing tool, not config/easyflash.
    Currently it is rather hard to add a new platform to it, so that's why i mentioned c# interfaces as a solution.
  • #308 21604688
    p.kaczmarek2
    Moderator Smart Home
    Ahh, sorry, I misread - I read "easyflash" and not "easyflasher". Well, don't worry about Easy Flasher, I will attempt to split it into interfaces a bit and tidy it once I get something to add there. If I manage to get this RTL write/read working now, I may do it even this week.

    We will also need a name change then.

    Added after 1 [minutes]:

    Oh look, OBK booted.

    So, to sum up:
    Scenario A:
    1. flash original BW16 dump
    2. Flash OBK
    3. No boot, as shown earlier
    Scenario B:
    1. Full erase
    2. Flash OBK
    3. OBK boots

    
    
    #[MODULE_BOOT-LEVEL_INFO]:IMG1 ENTER ROMSUB:2
    
    [MODULE_BOOT-LEVEL_INFO]:OTA1 USE
    
    [MODULE_BOOT-LEVEL_INFO]:IMG2 DATA[0xc014750:9328:0x83000]
    
    [MODULE_BOOT-LEVEL_INFO]:IMG2 SIGN[RTKWin(8300c)]
    
    [MODULE_BOOT-LEVEL_INFO]:IMG2 ENTRY[0x83000:0xc002835]
    
    [MODULE_BOOT-LEVEL_INFO]:KM0 BOOT_IMG2 BOOT REASON: 0 
    
    
    Flash ID:68, 40, 16
    
    
    read_mode:2
    
    calibration_ok:[2:19:11] 
    
    
    FLASH CALIB[NEW OK]
    
    
    RRAM: c0080 176B 
    
    [MODULE_BOOT-LEVEL_INFO]:IMG1 ENTER MSP:[1007fffc]
    
    [MODULE_BOOT-LEVEL_INFO]:IMG2 DATA[0xe0b8170:104192:0x10005000]
    
    [MODULE_BOOT-LEVEL_INFO]:IMG2 SIGN[RTKWin(1000500c)]
    
    [MODULE_BOOT-LEVEL_INFO]:IMG2 ENTRY[0x10005000:0xe040dbd]
    
    [MODULE_BOOT-LEVEL_INFO]:Start NonSecure @ 0xe040dbc ...
    
    [MODULE_BOOT-LEVEL_INFO]:KM4 BOOT REASON: 0 
    
    
    #interface 0 is initialized
    
    interface 1 is initialized
    
    
    
    Initializing WIFI ...OpenRTL8720D, version 1.18.135
    
    Entering initLog()...
    
    Commands registered!
    
    initLog() done!
    
    EasyFlash V4.1.0 is initializeInfo:MAIN:Main_Init_Before_Delay
    
     y
    
    cess.
    
    You can get the latest version on https://github.com/armink/EasyFlash .
    
    
    Main_Init_BeWarn:CFG:CFG_InitAndLoad: Correct config has been loaded with 2 changes count.
    
    Error:CMD:no file early.bat err -2
    
    file early.bat erInfo:GEN:PI
    Main_Init_Delay
    
    
    Main_Init_Delay done
    
    N_SetupPins pins have been set up.
    
    Info:MAIN:Main_Init_Before_Delay done
    
    Info:MAIN:Main_Init_Delay
    
    Info:MAIN:Main_Init_Delay done
    
    Info:MAIN:Main_Init_After_Delay
    
    Info:MAIN:Using SSID []
    
    Info:MAIN:Using Pass []
    
    Info:HTTP:TCP server listening
    
    
    
    WIFI initialized
    
    
    
    init_thread(58), Available heap 0x25420Info:MQTT:MQTT_RegisterCallback called for bT rtl8720dFFFFFFFF/ subT rtl8720dFFFFFFFF/+/set
    
    Info:MQTT:MQTT_RegisterCallback called for bT rtl8720d/ subT rtl8720d/+/set
    
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/rtl8720dFFFFFFFF/ subT cmnd/rtl8720dFFFFFFFF/+
    
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/rtl8720d/ subT cmnd/rtl8720d/+
    
    Info:MQTT:MQTT_RegisterCallback called for bT rtl8720dFFFFFFFF/ subT rtl8720dFFFFFFFF/+/get
    
    Info:CMD:CMD_StartScript: started @startup at the beginning
    
    Info:CMD:LFS_ReadFile: failed to file autoexec.bat
    
    Info:CMD:CMD_StartScript: failed to get file autoexec.bat
    
    Info:BERRY:[berry init]
    
    Info:BERRY:[berry start]
    
    Info:BERRY:[berry end]
    
    Info:BERRY:[berry start]
    
    Info:BERRY:be_pcall fail, retcode 3
    
    Info:BERRY:top=3
    
    Info:BERRY:stack traceback:
    
    Info:BERRY:	
    
    Info:BERRY:string
    
    Info:BERRY::1:
    
    Info:BERRY: in function `
    
    Info:BERRY:main
    
    Info:BERRY:`
    
    Info:BERRY:stack[1] = type='function' ()
    
    Info:BERRY:stack[2] = type='string' (import_error)
    
    Info:BERRY:stack[3] = type='string' (module 'autoexec' not found)
    
    Info:BERRY:[berry end]
    
    Info:MAIN:Main_Init_After_Delay done
    
    Info:MAIN:Time 1, idle 0/s, free 157888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 2, idle 0/s, free 157888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 3, idle 0/s, free 157888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 4, idle 0/s, free 157888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    
    
    LwIP_DHCP: dhcp stop.
    
    
    Deinitializing WIFI ...Info:MAIN:Time 5, idle 0/s, free 157888, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    
    
    WIFI deinitialized
    
    
    Initializing WIFI ...
    
    
    WIFI initialized
    
    
    wlan1: 1 DL RSVD page success! DLBcnCount:01, poll:00000001
    
    Info:MAIN:Time 6, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Boot complete time reached (5 seconds)
    
    Info:MAIN:Time 7, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 8, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 9, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 10, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 11, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 12, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 13, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    Info:MAIN:Time 14, idle 0/s, free 104672, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/16 
    
    
    


    Added after 10 [minutes]:

    Wait, no MAC

    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?

    Added after 33 [seconds]:


    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #310 21604709
    p.kaczmarek2
    Moderator Smart Home
    Or do we need to avoid full flash erase and only erase FW1 and FW2 partitions?
    Helpful post? Buy me a coffee.
  • #311 21604715
    insmod
    Level 25  
    >>21604709
    Just erase one sector at FW2 address.
    You can set mac in settings, it is written in EF. EF partition erase would restore it.
  • #312 21604731
    p.kaczmarek2
    Moderator Smart Home
    I heard from @DeDaMrAz there are loader for different amebas - just like imgtool_flashloader_amebad.bin - would they work for other realteks with similar approach?
    Helpful post? Buy me a coffee.
  • #313 21604740
    insmod
    Level 25  
    >>21604731
    Protocol is the same (xmodem), but some things might be different (like flash protect on D is not there on Z afaik).
    Z2 is a completely different animal though.
  • #314 21604909
    p.kaczmarek2
    Moderator Smart Home
    I've published my current code, mostly to be used as a reference. I'll also post a writeup later. Then I will try to integrate it into our flasher.
    https://github.com/openshwprojects/SharpRTL872xTool

    Added after 2 [hours] 52 [minutes]:

    @divadiow do you have BK7231 at hand? Or NiceMCU|?
    Helpful post? Buy me a coffee.
  • #316 21605597
    p.kaczmarek2
    Moderator Smart Home
    I can try to test it today. We can also call @DeDaMrAz , he likes IR.

    Just to be on the same page - you're aware about current IR problems, right, @insmod ? Basically, we started with Arduino-IRRemote port, which worked more or less acceptable with 50us timer, and then we realized that we have no AC protocols, so vfonov ported IRRemoteESP, but... IRRemoteESP internally used on change interrupt for ESP, and we don't seem to have that on Beken, so we converted it to 50us timer and now it seems a bit unreliable...

    I also did that basic splitting of Easy Flasher code: https://github.com/openshwprojects/BK7231GUIFlashTool/commits/main/ Right now we have a base class for generic flasher and separate BK7231Flasher (obsolete name, as it supports now other BKs) and unfinished RTL flasher. So far only read works. There are still some issues, like the main form internally uses sectors (4096 bytes) and not bytes, but it's just a start..
    Helpful post? Buy me a coffee.
  • #317 21605602
    insmod
    Level 25  
    [postid:85cf998eaa][/postid:85cf998eaa]
    Change IRQ?
    What about modifying interrupt on the fly?
    Rising irq triggered - enable falling in callback and vice versa.

    And no, i wasn't aware of IR issues, since i do not use OBK IR.

    Good work on flasher.
    I tried to use it with AmebaZ, but it didn't work. Tried to partially adapt pvvx amebaz rtltool to C#, but that didn't work too (i admit that i haven't really tried, just done some code changes and hoped it would work).
  • #318 21605648
    p.kaczmarek2
    Moderator Smart Home
    insmod wrote:

    Change IRQ?
    What about modifying interrupt on the fly?
    Rising irq triggered - enable falling in callback and vice versa.

    I didn't try it yet, but I was worried it may not be quick enough. I've been thinking about using FAST_READ_PIN for IR:
    https://github.com/openshwprojects/OpenBK7231...0bb9c914d97ab10bfe/src/driver/drv_spi_flash.c

    IR tests, BK7231N, my old dev build:
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    Test remote red button:
    
    Info:IR:IR MQTT publish IR_RC6 0x0 0x6D 0 (20 bits) took 0ms
    Info:IR:IR MQTT publish IR_RC6 0x0 0x6D 1 (20 bits) took 0ms
    

    Test remote green button:
    
    Info:IR:IR MQTT publish IR_RC6 0x0 0x6E 1 (20 bits) took 0ms
    Info:IR:IR MQTT publish IR_RC6 0x0 0x6E 0 (20 bits) took 0ms
    Info:IR:IR MQTT publish IR_RC6 0x0 0x6E 1 (20 bits) took 0ms
    

    OpenBK7231N_1.18.135.rbl - works the same.

    OpenBK7231N_amebair_ec35fc691074.rbl
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    works the same
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?

    OpenBK7231N_ALT_amebair_ec35fc691074.rbl - Wait, it will not show ALT here? I guess not...
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    Same, works.


    OpenBK7231N_amebair_ec35fc691074_irRemoteESP.rbl
    Not stable, but this is already known on main release
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    As far as I remember, irRemoteESP is a bit better for other protocols, so you usually need to try both to see which fits best.

    Also, no IR works on OpenBK7238?
    Helpful post? Buy me a coffee.
  • #319 21605716
    DeDaMrAz
    Level 20  
    Just some observations on IR.

    AC is problematic with current implementation of 50uS timer as the strings AC requires are much longer (compared to NEC protocol ie) and timer being fixed as it is produces an error after some length of command string. We tasted this with IR2 and flipper zero at the time, hence why IR2 driver exists.

    insmod wrote:
    Change IRQ?
    What about modifying interrupt on the fly?
    Rising irq triggered - enable falling in callback and vice versa.


    We had a discussion some time ago about IRQ on BK devices and I seem to remember we were lacking that in SDK (granted more than a year ago now).

    But we can certainly test the idea and sending is not the problem per say, receiving is. Flipper zero has that sorted maybe we can use their implementation as an idea - https://github.com/DarkFlippers/unleashed-firmware/tree/dev/lib/infrared
  • #321 21605859
    p.kaczmarek2
    Moderator Smart Home
    Since I am editing Easy Flasher, please keep an eye on the BK7231 functionality there as well.
    Helpful post? Buy me a coffee.
  • #322 21606056
    insmod
    Level 25  
    >>21605820
    Why WBR3? Just use BW15, because if something happens it can be easily reflashed without desoldering.
  • #324 21606114
    p.kaczmarek2
    Moderator Smart Home
    Regarding this proto boarding... I've recently checked on some PCB manufacturers and it seems that it's possible to order twosided boards with shipping for a total cost as low as 5$... maybe I could dedicate some time and create a proto board for us? The only isssue is that each WiFi module has different pinout, which is problematic. I could do a CB3S +CB2S+WB3S+WB2S combo (where CB3S and WB3S are on the opposite site of the board, maybe? Just solder one?), but I am not sure about other WiFi modules. Maybe have two separate silkscreen markings? Bold for Beken and italic for RTL? Still, that would not be readable well...

    But in general, I could design a board, for example, for Beken, with two soic CH340, for log and programming, with pads for related sensors, etc, for ease of prototyping.

    Okay, I'm just thinking aloud, it's not the most top priority thing right now and the different pin names/placement between platforms is killing the idea. Still, it would be nice to have something in shape of Arduino but with two CH340 and space for all (most of) supported sensors, so DS18B20 (three of them on lane?), DHTs, AHTs, etc, etc.

    Or maybe it would be more efficient to have one "mother board" with sensors but allow WiFi module swaps with spring contacts.

    Still, it's just a random idea, for now, I'm getting back to RTL flashing work. Easy Flasher can almost flash BW16 now.
    Helpful post? Buy me a coffee.
  • #325 21606759
    insmod
    Level 25  
    Warning: Sector header check failed. Format this sector (0x00000000).
    Warning: Sector header check failed. Format this sector (0x00001000).
    Warning: Sector header check failed. Format this sector (0x00002000).
    Warning: Sector header check failed. Format this sector (0x00003000).
    Warning: Sector header check failed. Format this sector (0x00004000).
    Warning: Sector header check failed. Format this sector (0x00005000).
    Warning: Sector header check failed. Format this sector (0x00006000).
    Warning: Sector header check failed. Format this sector (0x00007000).
    Warning: All sector header check failed. Set it to default.
    EasyFlash V4.1.0 is initialize success.
    You can get the latest version on https://github.com/armink/EasyFlash .
    p is a pointer to string (test)
    ef_set_env_blob(p, p, 4) returned 0
    ef_get_env_blob(p, gettest, (uint)str.Length, &savedlen) returned 4
    gettest=te,savedlen=4
    
    C:\SourceCodes\WinEF_Test\bin\Debug\net8.0\WinEF_Test.exe (process 60368) exited with code 0 (0x0).
    To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
    Press any key to close this window . . .

    using System.Runtime.InteropServices;
    
    internal class Program
    {
       [DllImport("WinEF.dll")]
       public static extern unsafe uint ef_get_env_blob(char* key, void* value_buf, uint buf_len, uint* saved_value_len);
       
       [DllImport("WinEF.dll")]
       public static extern unsafe uint ef_set_env_blob(char* key, void* value_buf, uint buf_len);
    
       [DllImport("WinEF.dll")]
       public static extern uint easyflash_init();
    
       [DllImport("WinEF.dll")]
       public static extern uint set_env_size(uint size);
    
       [DllImport("WinEF.dll")]
       public static extern unsafe byte* get_env_area();
    
       private static unsafe void Main(string[] args)
       {
          set_env_size(0x8000);
          easyflash_init();
          string str = "test";
    
          unsafe
          {
             fixed(char* p = str)
             {
                Console.WriteLine($"p is a pointer to string ({str})");
                uint res = ef_set_env_blob(p, p, 4);
                Console.WriteLine($"ef_set_env_blob(p, p, 4) returned {res}");
    
                var gettest = stackalloc char[str.Length];
                uint savedlen = 0;
                uint res2 = ef_get_env_blob(p, gettest, (uint)str.Length, &savedlen);
                Console.WriteLine($"ef_get_env_blob(p, gettest, (uint)str.Length, &savedlen) returned {res2}");
                Console.WriteLine($"gettest={new string(gettest)},savedlen={savedlen}");
             }
          }
       }
    }


    It doesn't get correct value though, gettest = "te\0\0".
  • #326 21606796
    p.kaczmarek2
    Moderator Smart Home
    EasyFlash port for EasyFlasher? Nice. This could really help with some issues, for example like that guy asking for longer Tasmota Device Group name that is currently inside our monolytic config structure we can't really easily change.... still, I am not sure how we will end up using EasyFlash - single call for whole config? Separate calls for separate config sections? This has to be done carefully so we dont' break compatibility often in the future.
    Helpful post? Buy me a coffee.
  • #327 21607080
    insmod
    Level 25  
    Previous message was deleted, when i tried to post this (post length was too big)
    (replaced chars with bytes, and long with int, because char in c# is 2 bytes, and long is 8 bytes)
    Warning: Sector header check failed. Format this sector (0x00000000).
    Warning: Sector header check failed. Format this sector (0x00001000).
    Warning: All sector header check failed. Set it to default.
    EasyFlash V4.1.0 is initialize success.
    You can get the latest version on https://github.com/armink/EasyFlash .
    ef_set_env_blob(name, p, (uint)str.Length) returned 0
    ef_get_env_blob(name, gettest, (uint)str.Length, &savedlen) returned 3584
    0000    BF 7F FF FF 45 46 34 30 FF FF FF FF FF FF FF FF    ?.yyEF40yyyyyyyy
    0010    BF FF FF FF 4B 56 34 30 26 00 00 00 8D 2B 90 58    ?yyyKV40&....+.X
    0020    0A FF FF FF 04 00 00 00 6E 76 5F 76 65 72 73 69    .yyy....nv_versi
    0030    6F 6E 30 2E 30 31 BF FF FF FF 4B 56 34 30 19 0E    on0.01?yyyKV40..
    0040    00 00 E6 3C D1 C5 01 FF FF FF 00 0E 00 00 4F 43    ..?<NA.yyy....OC
    0050    46 47 6E 05 00 00 00 00 00 00 00 00 00 00 00 00    FGn.............
    0060    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0070    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0080    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0090    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    00A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    00B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    00C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    00D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    00E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    00F0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0100    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0110    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0120    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0130    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0140    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0150    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0160    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0170    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0180    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0190    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    01A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    01B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    01C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    01D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    01E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    01F0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0200    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0210    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0220    00 00 00 68 6F 6D 65 61 73 73 69 73 74 61 6E 74    ...homeassistant
    0230    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0240    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0250    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0260    00 00 00 71 71 71 71 71 71 71 71 71 71 00 00 00    ...qqqqqqqqqq...
    0270    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0280    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0290    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    02A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    02B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    02C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    02D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    02E0    00 00 00 00 00 00 00 68 74 74 70 73 3A 2F 2F 6F    .......https://o
    02F0    70 65 6E 62 65 6B 65 6E 69 6F 74 2E 67 69 74 68    penbekeniot.gith
    0300    75 62 2E 69 6F 2F 77 65 62 61 70 70 2F 00 00 00    ub.io/webapp/...
    0310    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0320    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0330    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0340    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0350    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0360    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0370    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0380    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0390    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    03A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    03B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    03C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    03D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    03E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    03F0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0400    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0410    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0420    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0430    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0440    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0450    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0460    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0470    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0480    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0490    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    04A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    04B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    04C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    04D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    04E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    04F0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0500    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0510    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0520    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0530    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0540    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0550    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0560    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0570    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0580    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0590    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    05A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    05B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    05C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    05D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    05E0    00 00 00 00 00 00 05 00 00 00 00 00 00 00 00 31    ...............1
    05F0    39 32 2E 31 36 38 2E 30 2E 31 00 00 00 00 00 00    92.168.0.1......
    0600    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0610    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0620    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0630    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0640    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0650    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0660    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0670    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0680    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0690    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    06A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    06B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    06C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    06D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    06E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    06F0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0700    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0710    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0720    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0730    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0740    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0750    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0760    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0770    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0780    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0790    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    07A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    07B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    07C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    07D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    07E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    07F0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0800    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0810    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0820    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0830    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0840    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0850    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0860    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0870    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0880    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0890    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    08A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    08B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    08C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    08D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    08E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    08F0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0900    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0910    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0920    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0930    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0940    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0950    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0960    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0970    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0980    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0990    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    09A0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    09B0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    09C0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    09D0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    09E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    09F0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A00    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A10    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A20    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A30    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A40    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A50    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A60    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A70    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A80    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0A90    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0AA0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0AB0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0AC0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0AD0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0AE0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0AF0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B00    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B10    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B20    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B30    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B40    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B50    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B60    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B70    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B80    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0B90    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0BA0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0BB0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0BC0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0BD0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0BE0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0BF0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C00    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C10    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C20    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C30    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C40    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C50    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C60    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C70    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C80    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0C90    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0CA0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0CB0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0CC0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0CD0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0CE0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0CF0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D00    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D10    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D20    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D30    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D40    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D50    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D60    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D70    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D80    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0D90    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0DA0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0DB0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0DC0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0DD0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0DE0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0DF0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0E00    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0E10    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0E20    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0E30    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
    0E40    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF    ...............y
    0E50    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0E60    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0E70    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0E80    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0E90    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0EA0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0EB0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0EC0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0ED0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0EE0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0EF0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F00    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F10    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F20    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F30    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F40    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F50    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F60    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F70    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F80    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0F90    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0FA0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0FB0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0FC0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0FD0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0FE0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy
    0FF0    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    yyyyyyyyyyyyyyyy

    using System;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Text;
    
    internal class Program
    {
    	[DllImport("WinEF.dll")]
    	public static extern unsafe uint ef_get_env_blob(char* key, void* value_buf, uint buf_len, uint* saved_value_len);
    
    	[DllImport("WinEF.dll")]
    	public static extern unsafe uint ef_set_env_blob(char* key, void* value_buf, uint buf_len);
    
    	[DllImport("WinEF.dll")]
    	public static extern uint easyflash_init();
    
    	[DllImport("WinEF.dll")]
    	public static extern uint set_env_size(uint size);
    
    	[DllImport("WinEF.dll")]
    	public static extern unsafe byte* get_env_area();
    
    	[DllImport("msvcrt.dll", SetLastError = false)]
    	static extern IntPtr memcpy(IntPtr dest, IntPtr src, int count);
    
    	static unsafe byte Tiny_CRC8(byte* data, int length)
    	{
    		byte crc = 0x00;
    		byte extract;
    		byte sum;
    		int i;
    		byte tempI;
    
    		for(i = 0; i < length; i++)
    		{
    			extract = *data;
    			for(tempI = 8; tempI > 0; tempI--)
    			{
    				sum = (byte)((crc ^ extract) & 0x01);
    				crc >>= 1;
    				if(sum > 0)
    					crc ^= 0x8C;
    				extract >>= 1;
    			}
    			data++;
    		}
    		return crc;
    	}
    
    	[StructLayout(LayoutKind.Sequential, Pack = 1)]
    	unsafe struct mainConfig_s
    	{
    		public byte ident0;
    		public byte ident1;
    		public byte ident2;
    		public byte crc;
    		public int version;
    		public UInt32 genericFlags;
    		public UInt32 genericFlags2;
    		public ushort changeCounter;
    		public ushort otaCounter;
    		public fixed byte wifi_ssid[64];
    		public fixed byte wifi_pass[64];
    		public fixed byte mqtt_host[256];
    		public fixed byte mqtt_clientId[64];
    		public fixed byte mqtt_userName[64];
    		public fixed byte mqtt_pass[128];
    		public int mqtt_port;
    		public fixed byte webappRoot[64];
    		public fixed byte mac[6];
    		public fixed byte shortDeviceName[32];
    		public fixed byte longDeviceName[64];
    		public fixed byte pins[160];
    		public fixed short startChannelValues[64];
    		public short unused_fill;
    		public int dgr_sendFlags;
    		public int dgr_recvFlags;
    		public fixed byte dgr_name[16];
    		public fixed byte ntpServer[32];
    		public fixed byte cal[32];
    		public byte buttonShortPress;
    		public byte buttonLongPress;
    		public byte buttonHoldRepeat;
    		public byte unused_fill1;
    		public UInt32 LFS_Size;
    		public int loggerFlags;
    		public fixed byte unusedSectorAB[99];
    		public fixed byte staticIP[16];
    		public fixed byte ledRemap[5];
    		public fixed byte led_corr[24];
    		public fixed byte mqtt_group[64];
    		public fixed byte unused_bytefill[3];
    		public byte timeRequiredToMarkBootSuccessfull;
    		public int ping_interval;
    		public int ping_seconds;
    		public fixed byte ping_host[64];
    		public fixed byte initCommandLine[1568];
    		public fixed byte wifi_ssid2[64];
    		public fixed byte wifi_pass2[68];
    		public fixed byte webPassword[33];
    		public byte mqtt_use_tls;
    		public byte mqtt_verify_tls_cert;
    		public fixed byte mqtt_cert_file[20];
    		public byte disable_web_server;
    		public fixed byte unused[324];
    	}
    
    	private static unsafe void Main(string[] args)
    	{
    		uint area_size = 0x2000;
    		set_env_size(area_size);
    		easyflash_init();
    		var g_cfg = new mainConfig_s
    		{
    			ident0 = (byte)'C',
    			ident1 = (byte)'F',
    			ident2 = (byte)'G',
    			version = 5,
    			timeRequiredToMarkBootSuccessfull = 5
    		};
    		var span = new ReadOnlySpan<mainConfig_s>(ref g_cfg);
    		var cfgarr = MemoryMarshal.Cast<mainConfig_s, byte>(span);
    
    		var addr = Encoding.UTF8.GetBytes("192.168.0.1");
    		var mqtt_userName = Encoding.UTF8.GetBytes("homeassistant");
    		var mqtt_pass = Encoding.UTF8.GetBytes("qqqqqqqqqq");
    		var webappRoot = Encoding.UTF8.GetBytes("https://openbekeniot.github.io/webapp/");
    		fixed(byte* addrb = addr) memcpy((nint)g_cfg.ping_host, (nint)addrb, addr.Length);
    		fixed(byte* mqtt_userNameb = mqtt_userName) memcpy((nint)g_cfg.mqtt_userName, (nint)mqtt_userNameb, mqtt_userName.Length);
    		fixed(byte* mqtt_passb = mqtt_pass) memcpy((nint)g_cfg.mqtt_pass, (nint)mqtt_passb, mqtt_pass.Length);
    		fixed(byte* webappRootb = webappRoot) memcpy((nint)g_cfg.webappRoot, (nint)webappRootb, webappRoot.Length);
    		g_cfg.wifi_ssid[0] = 0;
    		g_cfg.wifi_pass[0] = 0;
    
    		int header_size = 4;
    		int configSize = cfgarr.Length;
    		int remaining_size = configSize - header_size;
    		unsafe
    		{
    			fixed(char* name = "ObkCfg")
    			fixed(byte* p = cfgarr)
    			{
    				g_cfg.crc = Tiny_CRC8(p + header_size, remaining_size);
    				uint res = ef_set_env_blob(name, p, (uint)cfgarr.Length);
    				Console.WriteLine($"ef_set_env_blob(name, p, (uint)str.Length) returned {res}");
    
    				var gettest = stackalloc char[cfgarr.Length];
    				uint savedlen = 0;
    				uint res2 = ef_get_env_blob(name, gettest, (uint)cfgarr.Length, &savedlen);
    				Console.WriteLine($"ef_get_env_blob(name, gettest, (uint)str.Length, &savedlen) returned {res2}");
    				byte* area = get_env_area();
    				byte[] managed_area = new byte[area_size];
    				for(int i = 0; i < area_size; i++)
    				{
    					managed_area[i] = area[i];
    				}
    				Console.WriteLine(Format(managed_area));
    			}
    		}
    	}
    	public static string Format(byte[] bytes)
    	{
    		ArgumentNullException.ThrowIfNull(bytes);
    
    		if(bytes.Length == 0)
    			return string.Empty;
    
    		var str = new StringBuilder();
    
    		var i = 0;
    
    		while(i < bytes.Length)
    		{
    			var baseIndex = i;
    
    			if(i != 0)
    			{
    				str.AppendLine();
    			}
    
    			str.Append($"{baseIndex:X4}    ");
    
    			for(var columnIndex = 0; columnIndex < 2; columnIndex++)
    			{
    				if(columnIndex != 0)
    					str.Append(' ');
    
    				for(var j = 0; j < 8; j++)
    				{
    					if(j != 0)
    						str.Append(' ');
    					str.Append(i < bytes.Length
    						? bytes[i].ToString("X2")
    						: "  ");
    					i++;
    				}
    			}
    			str.Append("    ");
    
    			i = baseIndex;
    			for(var columnIndex = 0; columnIndex < 2; columnIndex++)
    			{
    				for(var j = 0; j < 8; j++)
    				{
    					if(i < bytes.Length)
    					{
    						var c = (char)bytes[i];
    						str.Append(char.IsControl(c) ? '.' : c);
    					}
    					else
    					{
    						str.Append(' ');
    					}
    
    					i++;
    				}
    			}
    		}
    
    		return str.ToString();
    	}
    }


    Added after 39 [minutes]:

    This cfg is for all platforms with pin count < 32.
    Otherwise it needs to be modified (like RTL8720D, where there are 64 pins).
    EF commit: https://github.com/NonPIayerCharacter/OpenBK7...mmit/2c1ea4bd1c8aec2865a61d54284db5d7739debc4
  • #329 21607247
    p.kaczmarek2
    Moderator Smart Home
    @insmod Nice, just please do not change OBK app itself behaviour at the moment, ok? We need to do migration once and well. I do not want to have separate updates blocking configs.

    So, regarding potential upcoming migration - we also may need to consider adding some extra config changes, like:
    - separating startup command from the config so it's not length-limited?
    - separating some config sections some Tasmota Device Groups name is not limited as much as now, probably (it was requested), or just enlarging it
    Does EasyFlasher work under assumption that each blob has fixed size, or will it work with variable-sized blob?

    But my opinion is that this migration is not low priority, if you have pending Realtek porting, I'd say it's a bit more important, but it's obviously up to you in the end. We're here for fun.

    @divadiow With the prices from offer you linked (3 euro for item, 6 euro shipping), it makes much more sense for to design a board for you, so you can order 5 pcs from China for 2$ item and 3$ shipping...
    Helpful post? Buy me a coffee.
  • #330 21608040
    divadiow
    Level 34  
    divadiow wrote:
    so was thinking I could just put in WBR3 for anything RTL ir testing related.

    maybe not.

    ir send LEDs get very hot quickly with both BW12 and WBR3 modules. I guess CB3S pin equivalents are default PU or something

    Added after 8 [hours] 47 [minutes]:

    or something else was wrong. This works:

    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    a resurrected S09 https://www.elektroda.com/rtvforum/topic4035679.html

    shows TuyaMCU working on OpenRTL8710B too
    RTL8720DN, RTL8710B, RTL8710BX Compatibility with OpenBeken?
    Spoiler:
    Info:TuyaMCU:Received: 55 AA 03 2B 00 00 2D
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 43 (NetworkStatus) len 7
    Info:TuyaMCU:ProcessIncoming: (test for S09 calendar/IR device) received TUYA_CMD_NETWORK_STATUS 0x2B
    Debug:TuyaMCU:SendNetworkStatus: sending status 0x4 to MCU
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=36
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=37
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=38
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=38
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=39
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=40
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=41
    Info:TuyaMCU:Received: 55 AA 03 00 00 01 01 04
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 0 (Hearbeat) len 8
    Info:TuyaMCU:Received: 55 AA 03 24 00 00 26
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 36 (SetRSSI) len 7
    Info:TuyaMCU:ProcessIncoming: received TUYA_CMD_SET_RSSI, so sending back signal strength
    Info:TuyaMCU:Received: 55 AA 03 1C 00 00 1E
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 28 (SetTime) len 7
    Info:TuyaMCU:ProcessIncoming: received TUYA_CMD_SET_TIME, so sending back time
    Info:TuyaMCU:MCU time to set: 0
    Info:TuyaMCU:ptime ->gmtime => tm_hour: 0
    Info:TuyaMCU:ptime ->gmtime => tm_min: 3
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=41
    Info:TuyaMCU:Received: 55 AA 03 2B 00 00 2D
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 43 (NetworkStatus) len 7
    Info:TuyaMCU:ProcessIncoming: (test for S09 calendar/IR device) received TUYA_CMD_NETWORK_STATUS 0x2B
    Debug:TuyaMCU:SendNetworkStatus: sending status 0x4 to MCU
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=42
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=43
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=44
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=44
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=45
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=46
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=47
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=47
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=48
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=49
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=50
    Info:TuyaMCU:Received: 55 AA 03 00 00 01 01 04
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 0 (Hearbeat) len 8
    Info:TuyaMCU:Received: 55 AA 03 24 00 00 26
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 36 (SetRSSI) len 7
    Info:TuyaMCU:ProcessIncoming: received TUYA_CMD_SET_RSSI, so sending back signal strength
    Info:TuyaMCU:Received: 55 AA 03 1C 00 00 1E
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 28 (SetTime) len 7
    Info:TuyaMCU:ProcessIncoming: received TUYA_CMD_SET_TIME, so sending back time
    Info:TuyaMCU:MCU time to set: 0
    Info:TuyaMCU:ptime ->gmtime => tm_hour: 0
    Info:TuyaMCU:ptime ->gmtime => tm_min: 3
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=50
    Info:TuyaMCU:Received: 55 AA 03 2B 00 00 2D
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 43 (NetworkStatus) len 7
    Info:TuyaMCU:ProcessIncoming: (test for S09 calendar/IR device) received TUYA_CMD_NETWORK_STATUS 0x2B
    Debug:TuyaMCU:SendNetworkStatus: sending status 0x4 to MCU
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 65 02 00 04 00 00 00 DF 5B
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 101 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 223
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=51
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 66 02 00 04 00 00 00 42 BF
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 102 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 66
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=52
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=53
    Info:TuyaMCU:Received: 55 AA 03 00 00 01 01 04
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 0 (Hearbeat) len 8
    Info:TuyaMCU:Received: 55 AA 03 24 00 00 26
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 36 (SetRSSI) len 7
    Info:TuyaMCU:ProcessIncoming: received TUYA_CMD_SET_RSSI, so sending back signal strength
    Info:TuyaMCU:Received: 55 AA 03 1C 00 00 1E
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 28 (SetTime) len 7
    Info:TuyaMCU:ProcessIncoming: received TUYA_CMD_SET_TIME, so sending back time
    Info:TuyaMCU:MCU time to set: 0
    Info:TuyaMCU:ptime ->gmtime => tm_hour: 0
    Info:TuyaMCU:ptime ->gmtime => tm_min: 3
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=53
    Info:TuyaMCU:Received: 55 AA 03 2B 00 00 2D
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 43 (NetworkStatus) len 7
    Info:TuyaMCU:ProcessIncoming: (test for S09 calendar/IR device) received TUYA_CMD_NETWORK_STATUS 0x2B
    Debug:TuyaMCU:SendNetworkStatus: sending status 0x4 to MCU
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 1, product_information_valid=1, self_processing_mode = 0, wifi_state_valid = 1, wifi_state_timer=54

Topic summary

The discussion centers on the compatibility and support of Realtek RTL8720DN, RTL8710B, and RTL8710BX chips with the OpenBeken firmware and SDK. The RTL8720CF-based modules (e.g., BW15, WBR3) are confirmed to be supported by the AmebaZ2 family SDK and OpenBeken ports, with functional WiFi, GPIO, flash configuration, OTA, UART, and basic peripherals. However, RTL8710BX and RTL8710B (AmebaZ family) present challenges such as WiFi initialization freezes, memory management issues, and incomplete SDK support, including lack of static IP and WiFi scanning. OTA updates are functional but have occasional reboot issues, especially on RTL8710B. PWM support is mostly stable after fixes, while MQTT required patching due to missing authorization code in the Realtek LWIP stack. Power-saving modes and sensor drivers (DHT11, DS18B20) have been tested with varying success across platforms. Flashing RTL modules requires specific UART converters (e.g., CH340G) and careful wiring; some modules need manual pin pulls and special flashing tools like AmebaZ2 PGTool. TuyaMCU and energy metering ICs (BL0937, BL0942) support is under active development and testing, with UART and GPIO interrupt methods used. Memory partitioning for configuration, LittleFS, and Tuya config extraction is being optimized to avoid overwriting user data. Static IP implementation required workarounds due to sscanf inconsistencies on RTL and related platforms. A UART-to-TCP bridge driver has been developed for some modules. Overall, RTL8720CF modules have good OpenBeken support, RTL8710B is progressing but unstable, and RTL8710BX remains problematic. The community is actively testing, fixing, and improving support for these Realtek chips within OpenBeken and related tools.
Summary generated by the language model.
ADVERTISEMENT