Skip to content

Realtek AmebaD (RTL8720DN) family port — working on BW16, questions before a PR #402

Description

@Bl00d-B0b

What this is

A working port of the realtek-ambd family (RTL8720DN / AmebaD), running on an Ai-Thinker BW16. The family is already declared in families.json without a package; this fills it in.

Current state on hardware: boots, connects to WiFi, gets a DHCP lease, and runs ESPHome — adopted in Home Assistant over the native API with OTA available.

Evidence

LibreTiny boot, WiFi association and DHCP on the BW16 (LOG UART, PA7/PA8):

#calibration_ok:[2:19:11]
I [      0.000] LibreTiny v1.13.0 on bw16, compiled at Aug  7 2026, GCC 10.3.1 (-Os)
I [      0.000] Reset reason: Unknown
efuse mac  24:42:E3:16:0E:F2
ota slot   1 (valid 1/0)
I [      0.011] WIFI: Initializing LwIP
interface 0 is initialized
interface 1 is initialized
Initializing WIFI ... WIFI initialized
[2] sta mac 24:42:E3:16:0E:F2
[3] begin HOME-IOT
RTL8721D[Driver]: set pairwise key to hw: alg:4(AES)
Interface 0 IP address : 192.168.11.150
[4] CONNECTED ip 192.168.11.150 gw 192.168.11.254 rssi -23
[6] scan done: 10 networks
alive 0..6  wifi 3  ip 192.168.11.150  heap 260000 (flat)

ESPHome 2026.8.0-dev on the same device, over the encrypted native API:

Successfully connected to test @ 192.168.11.150 in 0.005s
Successful handshake with test @ 192.168.11.150 in 2.057s
[C][api:269]:   Address: 192.168.11.150:6053
[C][api:276]:   Noise encryption: YES
[C][esphome.ota:098]:   Address: 192.168.11.150:8892
[C][wifi:1268]:   IP Address: 192.168.11.150

Build: RAM 7.8% (41,152 / 524,288), flash 29.4% (609,160 / 2,072,576).

What the port contains

  • builder/family/realtek-ambd.py — KM4 (Cortex-M33) build: SDK fwlib, FreeRTOS 10.2.0 with the vendor RTL8721D_HP port, lwIP 2.2.0, wlan/mbedTLS glue, generated rlx8721d_img2_all linker script, and OTA image packing
  • cores/realtek-ambd/ — LibreTiny API (lt_cpu, lt_mem, lt_ota, lt_device incl. the eFuse MAC at 0x11A), LOGUART printf port, newlib syscalls, UART driver, and fixups
  • boards/bw16.json + variant — flash map measured from a factory dump: boot 0x0000, KM0 boot 0x4000, system 0x5000, OTA1 0x6000, littlefs 0x200000, OTA2 0x206000
  • Image format: [KM0 XIP][KM0 RAM][KM4 XIP][KM4 RAM][terminator], 32-byte section headers, slot selected by the 81958711 signature (matching OTA_Change() in rtl8721dhp_ota_ram.c)

Open questions before a PR

  1. Framework package. The SDK currently comes from a personal fork (framework-realtek-ambd). Would you host it under libretiny-eu, as with the other Realtek families?
  2. KM0 image. The KM4 half is compiled, but the KM0 half is a prebuilt blob. Mine is currently extracted from a device dump, which is not shippable. Is building it from the SDK's project_lp the expected route, or would a prebuilt ship in the framework package?
  3. ltchiptool flashing. Flashing today is done with an external tool. I have the ROM protocol partly decoded (CMD_USB 0x05 baud negotiation, CMD_XMD 0x07 to enter XMODEM, 1K-checksum packets with a 4-byte LE address prefix, RAM loader at 0x3000A020, confirmed on hardware up to the first ACK). Is working ltchiptool flash support a prerequisite for merging the family, or can it land after?

Also opened #401, which fixes three defects in the shared realtek-amb Arduino WiFi event path that this work uncovered — those affect AmebaZ/AmebaZ2 too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions