Skip to content

[realtek-ambz2] Add OTA implementation for RTL8720CF#344

Merged
kuba2k2 merged 5 commits intolibretiny-eu:masterfrom
bdraco:ambz2-ota
Jan 24, 2026
Merged

[realtek-ambz2] Add OTA implementation for RTL8720CF#344
kuba2k2 merged 5 commits intolibretiny-eu:masterfrom
bdraco:ambz2-ota

Conversation

@bdraco
Copy link
Contributor

@bdraco bdraco commented Jan 24, 2026

Summary

  • Implements OTA for the RTL8720CF (realtek-ambz2 family)
  • Uses byte inversion mechanism for boot selection (matching SDK's sys_update_ota_set_boot_fw_idx() approach)
  • Uses same firmware image for both flasher and device OTA (no separate patched image needed)
  • Based on prokoma's work from OTA implementation & fixes for RTL8720CF #302

Known limitations

  • Bootloader variants: Tested on stock Realtek bootloader (BW15). Other bootloader variants (Tuya, etc.) are untested and may require UART recovery if OTA fails.
  • No automatic rollback: Hardware limitation - bootloader has no fallback mechanism. ESPHome's safe_mode catches most failures.

Test plan

  • Tested OTA on BW15 with ESPHome
  • Windows compatibility - uses C array initializer syntax instead of shell-escaped strings

prokoma and others added 3 commits December 8, 2025 19:38
Use C array initializer syntax instead of escaped string literal
to avoid shell escaping differences between Windows and Unix.
@bdraco
Copy link
Contributor Author

bdraco commented Jan 24, 2026

retested with multiple OTAs on ESPHome

[11:51:20.351][D][esphome.ota:451]: Starting update from 192.168.107.127
[11:51:20.358][W][component:389]: esphome.ota set Warning flag: unspecified
[11:51:20.378][V][esphome.ota:294]: Update: Binary MD5 is f65521175d9204fabbbdf5d923938e0c
[11:51:20.443][D][esphome.ota:334]: Progress: 0.0%
[11:51:21.467][D][esphome.ota:334]: Progress: 3.2%
[11:51:22.491][D][esphome.ota:334]: Progress: 8.5%
[11:51:23.527][D][esphome.ota:334]: Progress: 13.2%
[11:51:24.535][D][esphome.ota:334]: Progress: 18.7%
[11:51:25.536][D][esphome.ota:334]: Progress: 22.8%
[11:51:26.547][D][esphome.ota:334]: Progress: 26.2%
[11:51:27.573][D][esphome.ota:334]: Progress: 30.6%
[11:51:28.597][D][esphome.ota:334]: Progress: 34.6%
[11:51:29.624][D][esphome.ota:334]: Progress: 39.5%
[11:51:30.647][D][esphome.ota:334]: Progress: 45.3%
[11:51:31.676][D][esphome.ota:334]: Progress: 48.8%
[11:51:32.681][D][esphome.ota:334]: Progress: 51.6%
[11:51:33.715][D][esphome.ota:334]: Progress: 55.2%
[11:51:34.734][D][esphome.ota:334]: Progress: 58.9%
[11:51:35.740][D][esphome.ota:334]: Progress: 61.7%
[11:51:36.742][D][esphome.ota:334]: Progress: 64.5%
[11:51:37.747][D][esphome.ota:334]: Progress: 68.1%
[11:51:38.777][D][esphome.ota:334]: Progress: 71.3%
[11:51:39.799][D][esphome.ota:334]: Progress: 74.6%
[11:51:40.823][D][esphome.ota:334]: Progress: 78.2%
[11:51:41.847][D][esphome.ota:334]: Progress: 81.4%
[11:51:42.886][D][esphome.ota:334]: Progress: 84.6%
[11:51:43.928][D][esphome.ota:334]: Progress: 85.7%
[11:51:45.029][D][esphome.ota:334]: Progress: 87.7%
[11:51:46.048][D][esphome.ota:334]: Progress: 90.5%
[11:51:47.076][D][esphome.ota:334]: Progress: 93.6%
[11:51:48.096][D][esphome.ota:334]: Progress: 95.5%
[11:51:49.138][I][esphome.ota:363]: Update complete
[11:51:49.144][W][component:429]: esphome.ota cleared Warning flag
[11:51:49.245][I][app:258]: Rebooting safely
[11:51:49.250][V][lt.preferences:107]: Saving 1 items...
[11:51:49.256][V][lt.preferences:120]: sync: key: 233825507, len: 4
[11:51:49.265][D][lt.preferences:137]: Writing 1 items: 0 cached, 1 written, 0 failed
[11:51:49.276][V][api:192]: Remove connection Home Assistant 2026.1.3
[11:51:49.282][W][component:389]: api set Warning flag: unspecified
[11:51:49.285]trace task is needed to print trace log
[11:51:49.288]hci_uart_deinit: deinit call twice

[11:51:49.291]== Rtl8710c IoT Platform ==
[11:51:49.293]Chip VID: 5, Ver: 1
[11:51:49.294]ROM Version: v2.1

[11:51:49.316]== Boot Loader ==
[11:51:49.318]Jul 20 2022:18:22:42

[11:51:49.353]Boot Loader <==

[11:51:49.363]== RAM Start ==
[11:51:49.373]I [      0.000] LibreTiny v1.9.2 on bw15, compiled at Jan 24 2026 11:49:47, GCC 10.3.1@(-Os)
[11:51:49.382][I][logger:049]: Log initialized
[11:51:49.388][C][safe_mode:118]: Unsuccessful boot attempts: 0
[11:51:49.392][V][lt.preferences:107]: Saving 1 items...

@kuba2k2
Copy link
Member

kuba2k2 commented Jan 24, 2026

Just to clarify one last time - this uses the unmodified version of ltchiptool, correct?

@bdraco
Copy link
Contributor Author

bdraco commented Jan 24, 2026

Just to clarify one last time - this uses the unmodified version of ltchiptool, correct?

Correct, just the standard ltchiptool from pypi. No patches needed.

@bdraco
Copy link
Contributor Author

bdraco commented Jan 24, 2026

The other Python lint issues look like pre-existing ones on master. I'm so used to ESPHome's CI where pre-commit reformats everthing automatically that I forget not every repo does that :)

@kuba2k2
Copy link
Member

kuba2k2 commented Jan 24, 2026

Yeah, it's not set up all the way, as I usually use auto-formatting on save in my IDEs. But hey, at least the CI is there...
The Python issues are probably due to Black getting an update. They like to just change the code style sometimes.

Formatting issues aside, thanks for bringing this PR back to life. At last, Realtek will have a working OTA implementation 👏

I'm going to merge this now and release a new minor version.

@kuba2k2 kuba2k2 changed the title [realtek-ambz2] OTA implementation for RTL8720CF [realtek-ambz2] Add OTA implementation for RTL8720CF Jan 24, 2026
@kuba2k2 kuba2k2 added the enhancement New feature or request label Jan 24, 2026
@kuba2k2 kuba2k2 merged commit 2a5429a into libretiny-eu:master Jan 24, 2026
@bdraco
Copy link
Contributor Author

bdraco commented Jan 24, 2026

Thanks!

@szupi-ipuzs
Copy link
Contributor

szupi-ipuzs commented Jan 25, 2026

Testing this now and getting compiler error:

Compiling .pioenvs/ineox-power-strip-1/core_ambz2/api/lt_ota.c.o
In file included from /libretiny/cores/realtek-ambz2/base/api/lt_ota.c:3:
/config/.esphome/platformio/packages/framework-realtek-ambz2/component/os/os_dep/include/device_lock.h:22:9: error: unknown type name 'uint32_t'
   22 | typedef uint32_t RT_DEV_LOCK_E;
      |         ^~~~~~~~

Adding #include <stdint.h> in lt_ota.c helps.

Edit: should work with #348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments