logo elektroda
logo elektroda
X
logo elektroda

BroadLink SP4L-UK Plug Teardown: BL3335-P Module - Flashing OpenRDA5981 Firmware [RDA5981A/B/C]

divadiow 39 0
ADVERTISEMENT
  • #1 21718522
    divadiow
    Level 36  
    Here I'll document my findings with the BroadLink SP4L-UK smart wi-fi plug with 3-pin UK socket. I'll provide details about the BL3335-P module found inside and how this module, as it is configured in this plug, can be flashed with opensource replacement firmware OpenRDA5981.

    White smart plug with a UK type G socket and three holes

    Opening begins with the removal of the 3 triangle-head screws on the underside. These hold the main case together and the plug cover plate in place.
    BroadLink smart plug with three brass pins and four screws on a blue surface Three metal screws placed on a British-style electrical plug casing.

    I removed the plate around power pins and used a spudger to prize open the case. Note the position of the clips. It's quite easy to break those with too much force in the wrong locations.

    Close-up of a plastic casing with a visible gap between joined parts White plastic casing interior with central hole and mounting clips Disassembled BroadLink smart plug with circuit board and casing visible BrodLink SP4L-UK smart plug with screws placed on top of the pins

    Inside we see the BroadLink 100-240VAC -> 5V DC power module alongside a Hongfa HF115F 005-1HS3 miniature electromechanical high power relay with a contact rating of 16 A at 250 VAC.

    Close-up of a BroadLink module with HF115F relay inside a smart socket housing

    On the other side is found the mains AC and Ground planes, a silkscreen label of "SocketBoard V1.5" and the soldered contacts of the riser which holds the BL3335-P module.

    WiFiBoard V1.6:
    Electronic module with communication chip, QR code and text labels
    Green PCB labeled WiFiBoard V1.6 on a blue surface

    With BL3335-P module de-soldered with hot air gun
    Green PCB with electronic SMD components on a blue background

    BL3335-P without RF shield reveals BroadLink have labelled this as BL0908. It can be seen in FCC documents marked as RDA5981A

    Bluetooth module with visible RDA chip and PCB antenna

    Electronic module with PCB antenna and component markings on a blue surface
    Electronic module with metal shield, placed on a blue background




    The 3335-P1V2 S1000H SLWS-M2 E324684 module appears to be a BroadLink creation based on the 1mb RDAMicro RDA5981A MCU. The FCC pages supply a datasheet for this module which I attach here.

    Overview:
    The BL3335-P is a low-cost embedded Wi-Fi module developed by BroadLink for smart home, IoT, and industrial applications. It integrates a 160 MHz ARM Cortex-M4 processor, Wi-Fi transceiver, MAC, baseband, and full TCP/IP stack.

    Key Features
    Supports IEEE 802.11 b/g/n (20 MHz and 40 MHz bandwidth)
    Encryption: WEP, WPA, WPA2 (TKIP/AES)
    Wi-Fi modes: STA, AP, and STA + AP
    SmartConfig and AP configuration supported
    TLS/SSL protocols supported
    PCB antenna integrated (no external antenna option)
    TCP/IP stack: IPv4, TCP/UDP/FTP/HTTP/HTTPS/TLS/mDNS
    Interfaces:
    2 × UART
    1 × SPI
    1 × I²C
    4 × PWM
    Up to 14 GPIOs
    1 × 10-bit ADC (0–2 V input range)
    Power supply: 3.3 V (must not drop below 3.3 V)
    Operating temperature: –10 °C to +85 °C
    Form factor: Stamp-style SMD package

    Pad Definitions
    Diagram of an electronic module housing with antenna and 18 pins

    pinFunction 1Function 2Function 3Function 4Function 5Default state
    1GPIO2TX2UP
    2GPIO1RX2I2C_SDAUP
    3GPIO3I2C_SCKUP
    4GPIO12SPI_MOSIDOWN
    5GPIO13SPI_MISOPWM1DOWN
    6GPIO25PWM3DOWN
    7GPIO0PWM2DOWN
    8VDD
    9GND
    10PDN
    11GPADCGPIO6DOWN
    12GPIO7DOWN
    13GPIO8PWM0DOWN
    14GPIO5SPI_CSDOWN
    15GPIO4SPI_CLKDOWN
    16RX0GPIO_26DOWN
    17TX0GPIO_27DOWN
    18GND





    RDA5981 is a 2.4 GHz Wi-Fi SoC family with an ARM Cortex-M4 (up to 160 MHz) and an integrated 802.11b/g/n MAC/PHY/RF (PA/LNA on-chip). It supports STA/softAP/P2P, WPA/WPA2/WEP (TKIP/CCMP), and ships in a tiny 5×5 mm QFN-40. Typical I/O: 2×UART, 2×I2S, I²C, 4×SPI, SDMMC, USB 2.0 (Device/Host), 8×PWM, 2-ch ADC, plus TRNG and AES/RSA accelerators. Firmware stacks seen in docs (all attached) include FreeRTOS and mbed OS.

    VariantFlash size (Mbit, in-package)Max CPU frequency (MHz)Internal SRAM (KB, total)User-accessible SRAMWi-Fi standardPackageVoltage range (V)
    RDA5981A8160352–448128802.11b/g/nQFN40 5x5mm2.7–3.6
    RDA5981B16160352–448128802.11b/g/nQFN40 5x5mm2.7–3.6
    RDA5981C32160352–448192802.11b/g/nQFN40 5x5mm2.7–3.6


    GPIO configuration function summary table
    Table of GPIO and UART pin functions with their default states

    Application Circuit
    Schematic of RDA5981A chip with passive components, RF path and GPIO connectors.

    RDA5981 can be seen at the heart of other modules, besides the BroadLink, such as the Hi-Link HLK-M50 and Tuya WRD2L, TYWRD2S and TYWRD3S. More Tuya info here: https://www.elektroda.com/rtvforum/topic4105474.html#21634746

    RDA5981A / B / C – Core Features
    --------------------------------
    • CPU: ARM Cortex-M4 @ up to 160 MHz (with FPU)
    • Flash: 8 Mbit (A), 16 Mbit (B), 32 Mbit (C) in-package SPI-NOR
    • SRAM: 352–448 KB total (128 KB user A/B, 192 KB user C)
    • Wi-Fi: 2.4 GHz 802.11 b/g/n (HT20/HT40 up to 150 Mbps)
    • Security: AES / RSA hardware engine, TRNG, secure boot support
    • Interfaces:
    - 2 × UART
    - 1 × I²C
    - 4 × SPI (master/slave capable)
    - 2 × I²S (audio)
    - 1 × USB 2.0 (Device/Host)
    - 1 × SDIO / SDMMC
    - 8 × PWM
    - 2 × ADC (10-bit GPADC0 / GPADC1)
    - Up to ~24 GPIO (package-limited)
    • Package: QFN-40 (5 × 5 mm, 0.4 mm pitch)
    • Supply voltage: 2.7 V – 3.6 V
    • Operating temperature: –40 °C to +85 °C
    • Crystal: 26 MHz (±10 ppm typical)




    Back to the SP4L-UK.

    The riser contacts trace to these functions from the module
    SocketBoard V1.5 PCB with labeled pins and BL3335-P module pinout diagram

    Which means that for debug log capture and flashing purposes we'll need to connect directly to RX0/IO26 on the module because only TX0/IO27 is routed out.

    Quote:
    In default, UART2 (pin1 and pin2) are used for bypass communication and UART0 (pin16 and pin17) are used for output of debugging information and burning firmware.


    Electronic module with Bluetooth chip and multiple connected wires

    Unfortunately debug log at any baud appears to be obfuscated/protected, requiring GPIO21 to be pulled high to unscramble. This is awkward on the BL3335-P because IO21 is not routed out. The careful placement of 3.3v through a needle point was required.

    Close-up of damaged integrated circuit with visible tracks and burn marks

    The needle can be released after power-up. At 921600 baud:

    Code: Text
    Log in, to see the code


    To backup the 1mb flash, the RDA Dump Tool available from within SingleDownloadTool_V01.00.12_20201023.zip at https://github.com/openshwprojects/FlashTools/tree/main/RDAMicro is to be used.

    dump start address should be 18000000 (or 18001000 to exclude bootloader) with length of word 0x3fc00

    If you set length of 0x3ffff (with flash size 1mb selected in drop-down) the tool will error with
    Error message about flash size limit stating only 0x3fc00 size will be dumped

    but then 0x3fc00 creates a file that's 1,044,480 bytes which is 4,096 bytes short of the full 1mb. For this reason I chose 0x7fc00 as the length which is just short of 2mb. The file can be trimmed down in HxD later. Alternatively, select 2mb flash size and word length of 0x3ffff. For RDA5981 variants that include 2/4mb flash, adjust word length accordingly.

    Screenshot of RDA Dump Tool with a completed memory dump operation.

    With the factory firmware backup* out of the way, the latest OpenRDA5981 from the releases page can be written to replace the stock firmware.

    In the RDA Flashtest Tool (change file filter to *.img to show firmware file to choose (release binary may change back to .bin so this may not be required)) OpenRDA5981 should be written to destination address 0x1000
    Settings window with Baud Rate, Flash Size, Download Addr, and erase memory options.
    The tool will not allow start address to be below 0x1000.

    On this BroadLink device IO21 needed to be held high for flashing to begin, like it does to reveal legible debug log. Again, IO21 doesn't need to be held high, just high at power-on.
    RDA Flashtest Tool window after successful binary download on COM51.

    It should be noted that this may not always be the case. @gandi69's BG Electrical device with the same module did not require any IO21 action: https://www.elektroda.com/rtvforum/viewtopic.php?p=21716496#21716496

    After a power-cycle OpenRDA5981 can be seen booting, displaying plain-text boot log from TX0 (bootloader text remains obfuscated unless IO21 high), and broadcasting starter AP to which connected devices can browse to 192.168.4.1 to get started with OpenRDA configuration.

    OpenRDA5981 control panel with buttons for Config, Restart, Web App, and About

    OpenRDA boot log
    Code: Text
    Log in, to see the code


    In the next post I will configure the pins required to get working relay/button/LED and MQTT for Home Assistant.

    For the history of OpenRDA5981 development, including tests with an HLK-M50, see this thread: https://www.elektroda.com/rtvforum/topic4105474.html

    *backup can be flashed back in the same way as flashing OpenRDA. If backup was taken from 18000000 then trim away the first 0x1000 or the flasher will complain about oversized image
  • ADVERTISEMENT
ADVERTISEMENT