
Hello, here I will present the world's first Tasmota replacement for the BL602 devices, offering, among others. the possibility of pairing our device with Home Assistant via MQTT. I will show here how you can easily upload a firmware to BL602 using a simple USB to UART converter and I will also describe the SDK compilation process for people who would like to program this platform on their own. Additionally, I will present two interesting demos from SDK BL602.
Why program BL602?
The motivation is the same as with the platforms I discussed previously. Using open source firmware allows you to free the IoT product from the manufacturer's servers, avoid the possible loss of control over this product when these servers go down, avoid tracking and collecting data by the manufacturer, and additionally, it allows you to combine products from different manufacturers into one ecosystem. What I'm creating here is a "Tasmota" for other platforms.
Used module from BL602
Development boards with BL602 (or related) systems can be bought at relatively low prices, but the main principle of my operation is to "free" available IoT products with closed programming of their manufacturers, so I used such a product for this topic as well.
This product served as a testing ground for me: RGB LED strip with IR and WiFi remote control - MWIR-RGB Magic Home Pro .

I have described the details in the "Teardowns" section of our forum:
https://www.elektroda.pl/rtvforum/topic3881416.html
This driver has a BL602 on board and 3 PWM-controlled transistors:

Sketch of connections:

What is this firmware?
The firmware repository is here:
https://github.com/openshwprojects/OpenBK7231T_App
My firmware for BL602 is basically a port of my OpenBeken. I have rewrote most of my OpenBeken recently so now my firwmare is cross-platform application supporting the BK7231T, BK7231N, XR809 and BL602 chips.
The initiative was started on these topics:
WB2S / BK7231 Tutorial - we create our own firmware - UDP / TCP / HTTP / MQTT
[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
For the user - downloading the compiled OpenBL602 / OpenBeken firmware for BL602
My Github repository has a script that automatically compiles binaries online for BK7231N, BK7231T and XR809 platforms, unfortunately BL602 is not yet supported by it.
For this reason, download the firmware from the releases_bl602 folder:
https://github.com/openshwprojects/OpenBK7231T_App/tree/main/bl602_release
It may change in the future and we will download the firmware from the "Relases" tab on the right.
For the user - hardware connection
You need a USB to UART converter with 3.3V logic levels, a 10k resistor, maybe a 3.3V LDO regulator (as it is not on our board) and cables.
We connect:
- RX from the module to TX UART
- TX from the module to RX UART
- BOOT from the module to the 10k resistor to the power supply, but leave it open (we connect it only for the duration of programming)
- ground to ground
- 3.3V power supply (if there is LDO on the board, then we can give 5V to its input from USB)
Details here:
https://www.elektroda.pl/rtvforum/topic3881416.html
For me it looks like this:

NOTE: If you connect the 5V power supply from USB to the LDO input (or the step down converter) on the BL602 board and then connect the 12V power supply, you will damage at least the USB to UART adapter and maybe the USB itself ... so always remember to disconnect external power supply first!
For the user - loading the firmware
To upload the firmware , youneed to:
1. Connect the BOOT signal to the power supply through a 10k resistor
2. Disconnect and reconnect power (reboot with BOOT signal raised to power)
3. In BLDevCube.exe select files in turn:

4. Make sure that the UART port is not in use (e.g. if you have it open in RealTerm, close it)
5. Click "Download" (which means "send the firmware to BL602"):

Ready!
Now, to start the firmware , disconnect BOOT (leave it loose), disconnect the power for a moment, and then restore it.
The device logs will still be available with baud = 2,000,000 (as in the demos from the SDK).
For the user - OpenBL602 configuration
The configuration of my firmware port on BL602 is analogous to the configuration described in these topics:
- Qiachip Smart Switch - BK7231N / CB2S - interior, programming
- Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
It is also worth reading the topic:
Home Assistant Tutorial - configuration, WiFi, MQTT, Zigbee, Tasmota
After restarting the device, you should see an open Access Point named like OpenBL602_1A1B2C3D4E5:

Connect to it and open the page with the address 192.168.4.1. Configure just like Tasmota (set WiFI SSID and passport, set the pin roles, set MQTT IP, user name, password, etc).
For this particular RGB LED strip, the roles of the pins are as follows:

In the current version, my firmware does not support the IR remote that has this strip.
For the user - pairing with the Home Assistant
There is an "Generate Home Assistant Config" option in the OpenBL602 panel, but it is not always enough. In case of RGB controller, this option "doesn't know" that you need to combine three PWMs into one color controller.
For this reason, I recommend taking only the device name from it, e.g. obl42DACAB0 and inserting it manually into this template:
Code: yaml
Save it in configuration.yaml. If you have several lights, put the light prefix with a colon once.
After restarting the Home Assistant, you can control the bar:




The current version has a drawback - after restarting Home Assistant it does not read the current brightness and color values. This will be fixed, but it does not affect the control of this led strip.
For developer - MSys2 installation
You do not need to compile the firmware yourself, because I provide ready-made binary files. But if you want to modify my code yourself, you will have to learn how to compile. You will need MSys2 to compile the firmware. Download and install it from here:
https://www.msys2.org/#installation

Windows may be blocking MSys - please continue anyway.

Choose the installation directory:

After installation, run msys2. It still needs to be updated.
Execute the command:
pacman -Syu

Then also pacman -Su
Then pacman -S make

For the developer - downloading the SDK and compiling the project
Unfortunately, the SDK download becomes more complicated here. The official SDK is here:
https://github.com/pine64/bl_iot_sdk
As of today (April 2022), however, the latest version of the SDK from Github does not compile correctly, you should use the older version, namely b3898a520d6e5a34a5f4de8241fcc1c1d3b071b9.
People other than me also have problems compiling the latest version:
https://github.com/pine64/bl_iot_sdk/issues/94
NOTE: If you are downloading the SDK with the intention of using it to compile my project, please download my modified version from here:
https://github.com/openshwprojects/OpenBL602
This is because the main OpenBK application (or OpenBL), called App, is shared between different SDKs of different platforms, and the same SDKs contain the basics of the projects in which the main App is compiled.
Projects in the SDK are located in the customer_app folder:
Here is a list of them:
benchmark_security_aes
bl602_boot2
bl602_boot2_mini
bl602_demo_event
bl602_demo_joylink
bl602_demo_nano
bl602_demo_noconnectivity
bl602_demo_wifi
bl602_huawei_cloud
sdk_app_audio_udp
sdk_app_ble_sync
sdk_app_blog
sdk_app_cli
sdk_app_cronalarm
sdk_app_dac
sdk_app_easyflash
sdk_app_event
sdk_app_fdt
sdk_app_gpio
sdk_app_hbnram
sdk_app_heap
sdk_app_helloworld
sdk_app_http_client_socket
sdk_app_http_client_tcp
sdk_app_i2c
sdk_app_ir
sdk_app_mdns
sdk_app_pwm
sdk_app_romfs
sdk_app_spi_pdm
sdk_app_spi_wave
sdk_app_timer
sdk_app_uart_ctl
sdk_app_uart_echo
Compilation is as simple as going to the project folder and calling ./genromap

You still need to call:
- export BL60X_SDK_PATH = ~ / your_path_to_Sdk /
- export CONFIG_CHIP_NAME = BL602

But in my experience it is usually not needed and the script finds the path by assuming that the SDK is two directories higher than the project being built. On the other hand, CONFIG_CHIP_NAME is required if we want to execute the "clean" command of the project to remove intermediate .o files generated by the compiler, which are then joined by the linker.
The generated files are located in the build_out folder, for example: customer_app \ bl602_sharedApp \ build_out
For the developer - Demko sdk_app_gpio
Since we learnt how to compile ourselves, it's time to test the demos of the functionality provided to us by the SDK developers.
One of the most interesting demos is sdk_app_gpio.
The sdk_app_gpio demko allows you to configure GPIO pins from the UART console. The command syntax is "gpio-func ".
For example, the command:
gpio-func 8 0 0 0
configures GPIO pin 8 as an output with no pull up / down resistors.
The baud of the demo is 2,000,000.
This is how the demo looks after launch:

After sending the pin control command:

Then you can set this pin low or high with:
gpio-set
In the case of input pins, we have an analogous gpio-get UART command:
gpio-get
For the curious, the gpio-func implementation looks like this:
Code: c
In turn, setting the pin:
Code: c
Getting his status:
Code: c
For the developer - Demko bl602_demo_wifi
Another interesting demo from the SDK is a program showing the operation of WiFi. Here, too, we control it via UART commands. Baud as before.

For starters, it's worth getting to know the whole list of commands through the fairly obvious help command:


Let's try wifi_ap_start:


wifi_scan also works. We have all the code for this demo so we can see what and how it is realized.
Summary
Another platform supported! I started with XR809 support , next I took care of the BK7231T and BK7231N . Now the BL602 has been supported. The next in line are the Realtek and W600 chips, but will I also manage to get them working? We'll see.
In the queue of devices for testing and flashing, I still have a bulb with BL602, but I do not think there will be problems with that - the board with the WiFi module has available required pads, i.e. RX, TX and BOOT. I will describe it in our forum "Teardowns" section soon.
As for the stability of the current firmware version for BL602, I tested it for two days, including deliberately shutting down the router (checking if it would catch the event disconnect and reconnect) and I did not encounter any problems, but of course I will continue to test and fix any problems on a regular basis.
For details about the project, please visit its official repo:
https://github.com/openshwprojects/OpenBK7231T_App
PS: If you know any IoT or similar devices based on BL602 or a related system, let me know - I constantly add support for new functionalities to the firmware and collect information about what works. As far as I know, the most popular ones are, for example, Sonoff 40 probably uses BL602.
Cool? Ranking DIY