logo elektroda
logo elektroda
X
logo elektroda

[OPL1000] Sonoff DW2 door/window opening sensor - teardown, firmware

p.kaczmarek2 8541 83
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #61 21194827
    divadiow
    Level 35  
    p.kaczmarek2 wrote:
    Did this device support AP mode pairing for the app?

    no AP ever showed however many different ways I reset or pushed button with factory firmware.

    I'll try that demo with AP code change
  • ADVERTISEMENT
  • #62 21194829
    p.kaczmarek2
    Moderator Smart Home
    Which example are you using right now? I may need to double check it's code for all necessary AP changes.
    Helpful post? Buy me a coffee.
  • #63 21194834
    divadiow
    Level 35  
    >>21194829 I think this is currently flashed OPL1000A2-SDK-master\SDK\APS_PATCH\examples\system\ota_wifi

    but it's quick and easy to flash anything

    Added after 2 [minutes]:

    (I say "I think" because desk was tidied and everything disconnected. I'll reconnect now)

    Added after 13 [minutes]:

    divadiow wrote:
    I am no further forward with a working OTA demo.


    forgot to mention that although I do get a built binary, this is in the make output

    Code: Text
    Log in, to see the code


    I've not investigated this yet
  • #64 21194882
    p.kaczmarek2
    Moderator Smart Home
    Regarding OTA sample - if you are getting "ota_prepare fail", then it fails there:
    Code: C / C++
    Log in, to see the code

    This could mean that MwOta_Prepare fails, MwOta_Prepare which is MwOta_Prepare_impl:
    https://github.com/Opulinks-Tech/OPL1000A2-SD...DK/APS/middleware/netlink/mw_ota/mw_ota.c#L81
    There are multiple conditionals in this function:
    Code: C / C++
    Log in, to see the code

    You can debug it by inserting printfs in each block.
    Helpful post? Buy me a coffee.
  • #65 21194948
    divadiow
    Level 35  
    I made some changes to the mw_ota.c file but nothing extra was printed to log. I saw "ota_abort error" in https://github.com/Opulinks-Tech/OPL1000A2-SDK/blob/49805f417c8d1fda258c146d2c8c7a8961fa57fc/SDK/APS_PATCH/examples/system/ota_wifi/http_ota_example.c#L364

    GPT gave me the attached revised for both. This is the boot log output now.

    Code: Text
    Log in, to see the code


    I think it's something to do with

    project_id = 1000
    chip_id = 2
    firmware_id = 1
    img_size = 160180
    img_sum = 14753094


    eg setting firmware ID to 20 here

    OPL1000 Download Tool user interface with OTA configurations.

    gives a 20 value in the log

    Code: Text
    Log in, to see the code
  • ADVERTISEMENT
  • #66 21194994
    p.kaczmarek2
    Moderator Smart Home
    mw_ota.c you attached won't build, something has copied printfs twice there:
    Source code snippet in C with duplicated return statements.
    Here is the function with better printfs:
    Code: C / C++
    Log in, to see the code

    Also, make sure to make a full rebuild, so the changes are included.
    It is possible this file somehow is not getting build.


    Or just make a syntax error in it and check if it detects it.
    Helpful post? Buy me a coffee.
  • #67 21195405
    divadiow
    Level 35  
    p.kaczmarek2 wrote:
    Here is the function with better printfs:

    thank you. I have restored http_ota_example.c to default and then edited server IP where I am hosting opl1000_ota.bin.

    I then reset mwa_ota.c to default and changed that function to match above.

    It's definitely building fresh every time. Some of the changes chatgpt was giving me would fail and then subsequent changes would make a difference. If I add random junk to one line it fails the next build.

    With only the changes you've supplied, the output is back to no more information:

    Code: Text
    Log in, to see the code


    I think I only found changes to http_ota_example.c seemed to make a difference in my tinkering earlier.

    Added after 3 [minutes]:

    divadiow wrote:
    http server is serving opl1000_ota.bin file download for any other device on subnet but not the DW2 yet.

    I should elaborate on this. The https_server.exe Python single exe they supply never seems to start whatever switches I use. I'm running it on a Windows machine and there's an Opulinks-TEST-AP broadcasting but it never connects. I gave up on it and have been testing with simply python http, powershell http and then Synology hosted http. Chrome downloads .bin from all, just not the DW2.

    Code: Text
    Log in, to see the code


    Added after 11 [minutes]:

    I've tried to find a newer version of http_server.exe but no luck. There are only a couple of versions in the whole OPL github

    Added after 8 [minutes]:

    oh hang on. "make clean" is a thing.

    Added after 2 [minutes]:

    same after make clean

    Code: Text
    Log in, to see the code


    Added after 3 [minutes]:

    I wonder if it's anything to do with where it would be copying the image to on the device. Maybe the partition layout isn't correct or something.

    Added after 24 [minutes]:

    this is interesting https://github.com/Opulinks-Tech/OPL1000A2-Door-Sensor-Coolkit-Cloud-HTTPS

    looks like the source for the DW2 factory firmware.

    https://github.com/Opulinks-Tech/OPL1000A2-Do...ystem/blewifi/src/blewifi_configuration.h#L64
  • #68 21196234
    p.kaczmarek2
    Moderator Smart Home
    I still can't see this line being printed:
    Code: C / C++
    Log in, to see the code

    is this line even included in the built binary?


    Why do you suspect HTTP client? If the code we are checking is correct:
    Code: C / C++
    Log in, to see the code

    Then the error message:
    
            LOG_I(TAG, "ota_prepare fail\r\n");
    

    is after the:
    
    
                LOG_E(TAG, "http client recv response error, ret = %d \r\n", ret);
    

    which means the HTTP part is ok, just OTA file is problematic.
    Helpful post? Buy me a coffee.
  • #69 21196691
    divadiow
    Level 35  
    OK. So it helps if you use a version of the Opulinks Download Tool that packs the firmware correctly.

    v2.0.0.

    Using the same opl1000_m0, PatchData.txt as before and the ota_wifi firmware opl1000_app_m3.bin we create the opl1000.bin as normal

    Opulinks Download Tool window displaying settings and file paths.

    then we add the opl1000_ota_loader.bin because

    Code: Text
    Log in, to see the code
    - from OPL1000-Demo-ota-wifi-guide_ENG.pdf

    Burn opl1000_ota.bin to OPL1000
    Screenshot of the Opulinks Download Tool showing UART settings and download process logs, with a FLASH_ERASE_ERROR displayed.

    on reboot this in the output indicates the OTA loader is present
    Code: Text
    Log in, to see the code


    Code: Text
    Log in, to see the code
    -from OPL1000-Demo-ota-wifi-guide_ENG.pdf

    and if you've set the AP SSID and password correctly in http_ota_example.h and the http server and port in http_ota_example.c and opl1000_ota.bin is available on the your HTTP server
    Code snippet defining server IP, port, and URL for OTA download.

    then it will begin to download the OTA file and flash it. This is the complete process from first boot of ota_wifi demo fw, OTA file download and flash and finally boot of wifi_station_gpio where it connects to my wifi and the LED on the DW2 lights. (Note the wifi_station_gpio firmware on the HTTP server is the same opl1000_ota.bin created by the ota pack process in tool).

    Code: Text
    Log in, to see the code


    note how the new firmware boots with this in log

    Code: Text
    Log in, to see the code


    I did try to OTA the full 1024kb factory backup but of course it failed. it stops at around 167kb. Unknowns are how big each image area is, if these demos are even aware of the 1mb flash, how big could Openbeken OTA fw be?

    Added after 37 [minutes]:

    and if you serve up ota_wifi firmware so it OTA updates every reboot, then it alternates between MW_OTA [0] and MW_OTA [1]
  • ADVERTISEMENT
  • #70 21203280
    divadiow
    Level 35  
    p.kaczmarek2 wrote:
    so I may need to get another one soon

    did you order one in the end @p.kaczmarek2 ?
  • #71 21204554
    p.kaczmarek2
    Moderator Smart Home
    Sorry, I haven't managed to get around that yet! Now I see you've got OTA working, is that correct? Very good!

    So what about creating AP?
    Helpful post? Buy me a coffee.
  • #72 21204577
    divadiow
    Level 35  
    p.kaczmarek2 wrote:
    Now I see you've got OTA working, is that correct

    Yes

    p.kaczmarek2 wrote:
    what about creating AP?


    I started playing with other devices and haven't done anything OPL1000 since, but will see if I can get AP going

    Added after 5 [hours] 37 [minutes]:

    hmm

    https://github.com/Opulinks-Tech/OPL1000A2-SD...ware/netlink/wifi_controller_layer/wifi_api.h

    Screenshot of API documentation for OPL1000 regarding Wi-Fi configuration.

    Added after 4 [minutes]:

    but then there is this https://github.com/Opulinks-Tech/OPL1000A2-SD...tlink/wifi_controller_layer/wifi_types.h#L105

    Added after 9 [hours] 6 [minutes]:

    :(
    Screenshot of an email about the OPL1000 device, indicating it supports only STA mode, not soft AP.
  • #73 21205361
    p.kaczmarek2
    Moderator Smart Home
    Strange, I was sure barely some time ago that it just does not support config change, but still can run AP.

    If no AP, then how it pairs? Now seriously. Is it even possible? It would kinda require device to know the SSID upfront and phone would have to use AP mode so OPL is STA...
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #76 21360243
    p.kaczmarek2
    Moderator Smart Home
    If you manually edit the hex file to be flashed, add some bytes, does it still boot? Or is there some kind of checksum/encryption in hex that prevents editing it?
    Helpful post? Buy me a coffee.
  • #77 21360269
    divadiow
    Level 35  
    Unsure, I cannot check until 28th.

    The checksum box in the flash tool changes as you add each binary (or maybe just main binary) so I *think* maybe you can make any bin and checksum is sorted at flashing.
  • #78 21360271
    p.kaczmarek2
    Moderator Smart Home
    Another thing to try is to capture UART communication with, for example Salae logic analyzer.
    Alternatively, we can try to disassemble the flash tool.

    And of course we can just... check Github, maybe there actually is some source of the flash code.
    Helpful post? Buy me a coffee.
  • #80 21386430
    p.kaczmarek2
    Moderator Smart Home
    That's not good, it will not fit to NodeMCU.

    Maybe it will fit to ESP boards? ESP32 modules have also smaller pitch pins?
    Helpful post? Buy me a coffee.
  • #82 21405013
    divadiow
    Level 35  
    E103-W08A defrocked

    Close-up of a circuit board with two chips, one marked PQ80 92U T61 and the other OPL 1000 A2SA1938 PPMN 4207. Close-up of an electronic circuit with two visible chips on a circuit board. Close-up of a circuit board with two black integrated circuits.
    Electronic module with visible conductive elements

    looks like
    Code: Text
    Log in, to see the code


    Added after 3 [hours] 17 [minutes]:

    ah, is this the same USON package @DeDaMrAz has just encountered here: https://www.elektroda.com/rtvforum/topic4093142-150.html#21403323 how did you connect to it @DeDaMrAz ?

    Added after 6 [minutes]:

    divadiow wrote:
    ah, is this the same USON package @DeDaMrAz has just encountered here

    maybe not. this has legs

    GPIO3 TX 115200 boot
    Code: Text
    Log in, to see the code


    -11 Carriage return wrapping was not entered
  • #83 21407092
    p.kaczmarek2
    Moderator Smart Home
    I haven't seen that small flash memory used on such module yet, all ESP modules I saw had a larger flash footprint.
    Helpful post? Buy me a coffee.

Topic summary

The discussion centers on the Sonoff DW2 door/window opening sensor based on the OPL1000 WiFi microcontroller, focusing on hardware teardown, firmware backup, and potential firmware modification. The sensor is inexpensive (~30 PLN) and uses WiFi communication, unlike its predecessor DW1 which used RF433MHz. Users confirmed the sensor transmits signals on opening but not necessarily on closing, with no firmware modification currently possible. Efforts to develop OpenBeken (OBK) support for OPL1000 are ongoing but limited by the chip's low popularity and scarce documentation. The OPL1000 SDKs (A1, A2, A3) correspond to different chip revisions or related chips (OPL1000, OPL1200, OPL1600/1800), with the DW2 sensor marked as A2 and compatible with the OPL1000A2 SDK. Firmware dumping was performed by desoldering the TH25Q-80UA 8Mbit SPI flash chip and bit-banging with FTDI, revealing AliCloud firmware with OTA capabilities and AT command support. Flashing custom firmware using the Opulinks Download Tool and compiling SDK examples (e.g., wpa2_station_gpio) was successful, enabling WiFi connection and GPIO control (e.g., LED on GPIO21). However, soft-AP mode is not supported or unclear, with pairing likely done via BLE rather than WiFi AP mode. OTA update demos were tested but initially failed due to improper firmware packaging; using the correct OTA loader and build process resolved this. Challenges remain in understanding flash memory layout, patch data usage, and full SDK utilization. Additional hardware like the E103-W08A OPL1000 module was also examined. The community is progressing toward porting OBK firmware to OPL1000 devices, with ongoing exploration of SDK examples, build environments (MSYS2), and flashing tools. Key technical issues include UART bootloader access, flash dumping, firmware compilation, OTA implementation, GPIO control, and network modes (STA/AP/BLE). The discussion includes detailed logs, code snippets, and hardware photos to support development efforts.
Summary generated by the language model.
ADVERTISEMENT