logo elektroda
logo elektroda
X
logo elektroda

Flashing CozyLife LED Ceiling Lamp XT-BL200: Power Supply Challenges

kvakulo 462 8
ADVERTISEMENT
  • #1 21478483
    kvakulo
    Level 3  
    I purchased a random CozyLife LED RGBCW Ceiling Lamp on AliExpress (product page):

    A glowing red ceiling lamp next to a box labeled LED Ceiling Light.

    I am not entirely sure of its original model name, but the PCB is labeled as XLD-XDFGW-RGBCW1.0:

    LED panel on a white background.

    Opening the lamp is straightforward - just push off the plastic ring surrounding it.

    The lamp uses a BL-200 module, which can be flashed without desoldering it from the PCB. The text XDD cozylife 20240829 is written on the shield (see photo further down).

    Here is a photo of the backside of the module which shows the text XT-BL200 (WCBGR):
    Metal plate with a cutout for a technical marking.

    However, I encountered several challenges while flashing due to insufficient power. Initially, when I powered it directly from a UART-over-USB adapter, the device kept appearing and disappearing. My second attempt involved using a power supply from a board included with a breadboard. This provided enough power for the device to connect to my computer, allowing me to read the output (though some text was corrupted). However, when I tried to put the BL-200 into flash mode, the output was entirely garbled. Finally, I resolved the issue by powering the device with an ST-LINK V2, which worked perfectly.

    To flash the BL-200 module, you need to solder five cables to the appropriate pins. You can find a detailed image of all the pinouts in this topic. The required connections are as follows:

    - TX
    - RX
    - GND
    - 3.3V
    - IO8

    Image of a circuit board with an electronic module and marked wires.

    Next, connect TX and RX to a UART-over-USB converter. To put the module into download mode, IO8 must be connected to 3.3V via a 10k resistor during power-up:
    Breadboard with connected wires on top of an electronic circuit.

    I used the partition TOML and the build file described in this post. Flashing requires Bouffalo Lab Dev Cube, which I configured as shown below:

    Screenshot of Bouffalo Lab Dev Cube 1.9.0 software settings for firmware update.

    After flashing, I successfully connected to the device via the AP Hotspot and configured the lamp. I used the OBK template from this post.

    The lamp is functional, however, it occasionally becomes unresponsive when displaying certain colors. I need to test further to identify the specific conditions that trigger this issue.

    Unfortunately, I did not succeed in dumping the original firmware.
  • ADVERTISEMENT
  • #2 21478605
    divadiow
    Level 34  
    kvakulo wrote:
    Unfortunately, I did not succeed in dumping the original firmware.

    :(

    Are you sure your module is a 1mb version of BL602? If you do the flash ID read it'll tell you the size and ID

    Screenshot of a console with logs of a flash memory read process.
  • ADVERTISEMENT
  • #3 21480021
    kvakulo
    Level 3  
    >>21478605 Yeah, I thought I had managed to dump the firmware using blflash, but it was just a 1024 kb empty file :(

    The output from flash id read is:

    [21:41:24.496] - ========= flash read jedec ID =========
    [21:41:24.511] - Read flash jedec ID
    [21:41:24.511] - flash jedec id: c2201480
    [21:41:24.511] - Finished
    [21:41:24.527] - get flash size: 0x00100000
    [21:41:24.527] - ========= flash read jedec ID =========
    [21:41:24.542] - Read flash jedec ID
    [21:41:24.542] - flash jedec id: c2201480

    That means 1MB right?
  • #4 21480024
    divadiow
    Level 34  
    kvakulo wrote:
    That means 1MB right?

    yes
  • ADVERTISEMENT
  • #5 21481244
    kvakulo
    Level 3  
    I have tried to understand in which scenarios that obk crashes, and it seems to be mostly related to mqtt.

    If I disable mqtt, then obk is running stable (unless I change colors very quickly through the web interface).

    But if I enable mqtt, then obk crashes almost consistently when I change the color through homeassistant, or by simply publishing a mqtt message on the led_basecolor_rgb topic, e.g. publishing the value #fff5b50000:
    Screenshot of MQTT Explorer showing led_basecolor_rgb setting.

    The log looks like this:
    Screenshot of system logs indicating an issue with system hang when using MQTT.

    Any ideas of what I could perhaps tweak to avoid this issue?
  • ADVERTISEMENT
  • #6 21525168
    kvakulo
    Level 3  
    It took me a while to figure out that the issue was actually caused by the watchdog.

    When sending the led_basecolor_rgb command over MQTT, I could make the lamp restart fairly consistently just by sending a hex color a few times, e.g., #000000. Interestingly, this didn't happen when sending the value rand (which sets a random color).

    I'm absolutely not an expert in C, so I asked ChatGPT to help optimize the part of the code responsible for parsing the hex string. The optimization it suggested turned out to be enough to fix the issue!

    I also increased the watchdog timer, but that alone wasn't sufficient.

    You can see the code changes here:
    https://github.com/kvakulo/OpenBK7231T_App/commits/speed-up-color-parsing/
  • #7 21525503
    miegapele
    Level 15  
    It's strange sscanf could be so slow. Maybe original code just crashes and it's not really slow?
  • #8 21526083
    kvakulo
    Level 3  
    I agree, it does sound strange! I looked at that piece of code so many times and kept thinking the issue had to be somewhere else 😅

    But I guess sscanf might slow things down just enough to trigger the problem when the command is sent via MQTT. Interestingly, if I sent the led_basecolor_rgb command with hex values through the API, everything worked fine with no crashes.

    Anyway, just sharing this as an observation in case someone else runs into a similar issue down the line.

    For now, I've deployed the lamp into production, and I'll report back on stability in about a week.

Topic summary

A CozyLife LED RGBCW Ceiling Lamp with a PCB labeled XLD-XDFGW-RGBCW1.0 and a BL-200 module (XT-BL200 WCBGR) was purchased for firmware flashing. Initial flashing attempts failed due to insufficient power when using a UART-over-USB adapter. The flash memory was identified as a 1MB BL602 chip (flash JEDEC ID c2201480). Stability issues were encountered with the OpenBK7231T firmware (obk), particularly crashes triggered by MQTT commands changing LED colors via the led_basecolor_rgb topic. Disabling MQTT improved stability, but color changes via MQTT caused frequent watchdog-triggered restarts. The root cause was traced to inefficient hex string parsing in the firmware code, specifically the use of sscanf, which slowed processing enough to trigger watchdog resets. Optimizing the hex parsing code and increasing the watchdog timer resolved the crashes. The lamp has since run stably for over two weeks with the optimized firmware build deployed.
Summary generated by the language model.
ADVERTISEMENT