logo elektroda
logo elektroda
X
logo elektroda

Extracting Tuya Calibration Data from Tongou DIN Rail Power Meter Flash Dumps

dwmw2 726 5
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21190524
    dwmw2
    Level 6  
    Hi, the original post says, "This constant is calibrated at production time by Tuya, but sadly, when flashing new firmware we have no access to calibration data."
    https://www.elektroda.com/rtvforum/topic3887748.html

    But since then, LibreTiny has made a lot of progress in decrypting and interpreting the Tuya data partitions. Should we be able to find the original calibration data somehow?
    I have about 10 Tongou DIN Rail power meters to liberate, and can take copies of the full original flash from each and look for differences.
  • ADVERTISEMENT
  • #2 21191518
    dwmw2
    Level 6  
    >>21190524
    For the Tongou DIN rail units I've found the original calibration data both in the reports from the Tuya firmware (DPS 22, 23, 24, 25) and also in the flash if we read it before overwriting it. More details at https://github.com/esphome/issues/issues/6155

    Ideally we ought to be able to give users a way of liberating these devices without having to recalibrate for themselves.

    If users do calibrate, we can calculate PREF based only on UREF and IREF too.
  • ADVERTISEMENT
  • #3 21192909
    p.kaczmarek2
    Moderator Smart Home
    So you've got the calibration contants from Tuya API? Or would a 2MB flash dump be enough? Can you share the dumps? Maybe something is in Tuya JSON config partition?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #4 21193054
    dwmw2
    Level 6  
    >>21192909

    > So you've got the calibration constants from Tuya API?

    Yes.

    > Or would a 2MB flash dump be enough?

    Also yes.

    > Can you share the dumps?

    Sure, a full dump is in the ltchiptool feature request linked from the above ESPHome issue. It's not in the JSON partition; it's in the "key value store" partition at 0x001d5000.
  • ADVERTISEMENT
  • #5 21193062
    p.kaczmarek2
    Moderator Smart Home
    BK7231T or BK7231N?

    Here are N partitions:
    Code: C / C++
    Log in, to see the code


    Added after 50 [seconds]:

    or you could mean https://github.com/openshwprojects/OpenBK7231...71676018d23aa4777/sdk/include/kv_storge.h#L80

    Added after 1 [minutes]:

    btw
    https://github.com/openshwprojects/OpenBK7231.../bk7231t_bl0937_1_plug_demo/src/bl0937.c#L883
    Code: C / C++
    Log in, to see the code
    Helpful post? Buy me a coffee.
ADVERTISEMENT