Hello, today I will present how to tame another Chinese WiFi + Bluetooth microcontroller, the W800-C400 produced by WinnerMicro. At the moment, you can buy it for about 3$, while the development board costs about 5$ and both of these prices already include the shipment. Of course, I will not use such a board here, but continuing my tradition I will use an IoT / Tuya device just built on the W800-C400, more specifically the RGB LED strip controller.
The WinnerMicro chips themselves have already been mentioned several times in the "News" section of our forum, you can also check out these topics:
HLK-W801 board with microcontroller based on Alibaba Xuantie XT804 core Air602 - Module with Wi-Fi on SoC Winner Micro W600 W806 - prototype board with WinnerMicro W806 for PLN 8 NOTE - this topic assumes basic knowledge of C and basically focuses on just starting the W800-C400, without explaining the basics. In addition, I also expect that the user can look for himself in the code or on the Internet, for example, create a thread on this platform and so on ...
What else will you need? When you buy a dedicated development board, you don't need it (because it is already on dev board), but as I will program it in IoT device, so I will also need an external USB to UART converter. Basically like in ESP and all similar microcontrollers ...
Here are the necessary connections:
- RX converter to TX PCB
- Converter TX to PCB RX
- mass to mass
- 5V power supply from USB to the board's power input (not 3.3V, because it will burn the board. There is a step down converter on the board, I give 5V to its input)
- in addition, on this UART USB converter I give a jumper between VDD and 3.3V to select the logical levels of 3.3V
- [optional] we can also solder the cable to the RESET pad from the board and reset the board by touching it to the ground, it will reboot, but you can also simply reset it by disconnecting the power supply ...
This is what it looks like in practice:
Let me remind you - I take 5V directly from the USB, not from the "5V" pin on this dongle, because the 5V pin there is used to select logical levels and it never wanted to act reliably as a power source.
SDK repository from Github The W800 SDK is available for free on the web. Just download them. I used the SDK available at:
https://github.com/List-View/wm_sdk_w800 There is also a firmware upload program - compiled Windows binary, wm_tool.exe.
I used a GUI addon for GIT - SourceTree to download the repository.
IDE and W800-C400 compiler In addition to the SDK, you need to download the compiler and development environment separately.
You have everything ready in the form of one installer for Windows. The IDE is simply a wrapper for Eclipse, which you may already know from other microcontrollers or even from writing Java applications.
IDE is called CDS and download them from here:
https://occ.t-head.cn/community/download This requires registration!
The file I downloaded was named: cds-windows-mingw-elf_tools-V5.2.11-20220512-2012.zip
After installation, we should get a path of this type:
Copyright (c) 2010-2022 Hangzhou C-Sky Microsystems Co., ltd. All rights reserved.
First compilation in CDS You already have an open IDE - now you are opening the project.
Project-> Open Multi Project Workspace Open the project file from the downloaded SDK: W: \ GIT \ wm_sdk_w800 \ tools \ w800 \ projects \ SDK_Project \ project \ CDS
The project will be imported and you will get the following effect:
In Project Explorer, you can now view files with C code:
You can compile via build:
It should go without problems:
Here are the results:
Uploading a firmware by wm_tool.exe wm_tool.exe is in the tools folder of the downloaded SDK.
This is, of course, a command line utility.
It's like "esptool.py", you could say, simplified to say, how someone knows ESP.
It allows, among others. upload the firmware via UART.
Here the usage information of wm_tool.exee:
To upload the firmware, give the path to the FLS file and select our COM port (virtual):
wm_tool.exe -c COM9 -dl W: \ GIT \ wm_sdk_w800 \ bin \ w800 \ w800.fls
So we execute this command and get:
Now you have to reboot the device - either via the RESET signal or by cutting and connecting the power supply.
It is programmed:
There is no need to worry about the 0% progress visible for the entire programming time, the program just does not refresh this counter.
Structure of a demonstration project Let's analyze what is happening and where.
Of course, I won't go into what happens before "main" call, because here I am describing the basics.
main calls CreateDemoTask :
CreateDemoTask is in wm_demo_console_task.c :
This is basically the UART command line from which you can run demos.
Wm_demo_console_task.c also has its parsing, command tokenization, and so on.
In turn, wm_demo_console.h has a table of all demos and their commands:
There is also a configuration file - wm_demo.h.
And here CAUTION - demos are by default disabled, they must be enabled by changing one OFF to ON :
It is supposed to be DEMO_ON, the default is OFF. Without this, the demo console will not start!
You also need to run separate demos that interest us:
It's time to recompile the firmware and upload to the W800.
Demonstration program After uploading the firmware , you must perform a RESET (reboot) for the program to start working.
Now communicate with the device on baud 115200.
At the start you get:
(maybe apart from the hello world message, I wrote it myself in main () for the test)
Let's send the "demohelp" command, but without the CRLF (newline, carriage backspace):
Well, it's the same message, but it works.
Let's try t-scan:
Out of curiosity - the demo code is in wm_scan_demo.c.
Here is the most important excerpt:
Log in, to see the code
Let's try to run a demo of creating a WiFi access point:
Was there a problem? Yes, but the message does not explain it.
A glance at the demo table shows that you still need to provide some arguments:
Let's take a look at the appropriate file, what are the arguments ...
There is a bit of it. You still need to scroll down to find out exactly what we need to enter, what the next numerical values mean, e.g. the encrypt parameter:
Log in, to see the code
You have been triggering a command, but it's not that simple either.
I tried like this:
Firmware update via WiFi The last thing I will show is the firmware update via WiFi, i.e. OTA - Over The Air upgrade.
In this case, the OTA client is ready, it is more precisely the HTTP client that downloads the firmware file from the given URL.
So we must have a server. You could use the Xampp package from Apache, for example, but why complicate things?
A more convenient option is Node-red because it can be scripted to serve us a file directly from the compilation folder via a virtual path.
Alone Node-red I won't describe here, but this is what my nodes look like:
Node catches the GET request and then processes it in the Function node:
Here, I take the name of the file from the path and retrieve it from the disk. It is important that the ReadFile node reads it as a binary buffer and not, for example, UTF8:
After making changes to Node-Red, remember to click Deploy.
From now on, my machine has an HTTP Node-red server and after entering the address:
returns the given file to me from the folder with the SDK.
Now the question is what on the side of the SDK ... one function is enough:
Log in, to see the code
The system will download the update automatically and restart the W800.
Practical advices I won't cover C programming itself here, but there are a few things worth mentioning. First of all, this SDK is based on FreeRTOS, which is missing a few things - it's worth configuring yourself.
- in FreeRTOSConfig.h I recommend to enable mutexes - #define configUSE_MUTEXES 1
- in FreeRTOSConfig.h I recommend to turn on heap management, because without it we have to point to the heap ourselves when creating a thread - #define configUSE_HEAP2 1
- but the heap_4 (with defragmentation) algorithm would be better, not present in the heap_2 SDK, but this one is not available ... if we allocate memory often, it would be worth moving the SDK to newer FreeRTOS
- in FreeRTOSConfig.h I recommend increasing the size of the buffer for heap allocation - #define configTOTAL_HEAP_SIZE ((size_t) 48 * 1024)
- the SDK includes the lwip2.0.3 library (Lightweight TCP / IP stack), but only basic functionalities such as sockets, DHCP are used from it. If we want to use, for example, the MQTT client, it should be added separately to the sources
- remember that if we have an IDE (these magic CDS), we do not need to edit the Makefile, just add the file to the project in CDS, it is already included in the compilation
- MQTT with lwip 2.0.3 (or there 2.0.2) has the problem that I have already mentioned several times in other topics, that it does not take into account the MQTT password / username. You should add a few missing lines or copy the corrected version from me:
https://raw.githubusercontent.com/openshwprojects/OpenBK7231T/2c3af1f719cb5d52f3a9442bc0ec4439cac1d389/platforms/bk7231t/bk7231t_os/beken378/func/lwip_intftt/lwip_intftt/lwip_appq.2 - WinnerMicro build configuration is in wm_config.h
W800 port for OpenBeken Of course my firmware (Tasmota / Esphome replacement) for other WiFi platforms found in IoT devices it has already been ported to the W800. There weren't a lot of problems with that. At the moment it looks like this:
The pin configurator, MQTT, also works:
My firmware port for this platform is fully functional at the moment
Summary Another WiFi / Bluetooth microcontroller running - and this time it wasn't that hard at all. It is true that I do not know any reliable English source about it, but the SDK did not have such a mess that it would not be able to run it. Even the update of the firmware via WiFi was achieved (OTA), and this is something very useful for both development and end users.
I liked the fact that there were no problems with the compiler and toolchain, everything was ready in one install, including the IDE.
The related W600 also has its own port for Arduino, available here:
https://github.com/w600/arduino but I haven't tested it yet and I don't know how much the W600 differs from the W800 either. Nevertheless, I also plan to add W600 support to my firmware, all in good time.
That's it for now, and now I will ask if anyone has played with the platforms yet W600 or W800 ? I don't think I'm going to go any further, I developed the W800 just enough to be able to pair my WX300P LED strip from Home Assistant, but who knows ...
I attach some interesting materials about the W800 / W600, including a repo packed with a flasher (wm_tool.exe) in a zip, as well as materials from the manufacturer that I did not describe here, including a slightly newer SDK (2021 12 03)
Of course, my firmware (Tasmota / Esphome replacement)
This is not a replacement for ESPHome or Tasmota as they are dedicated to ESP systems only. Tasmota can be a "replacement" for ESPHome or vice versa. In addition, this OpenBekon does not even have 5% Tasmot functionality - perhaps in some small part it has similar functionality on other MCUs, but this does not entitle the use of the term "replacement".
I started my adventure with the W800 two days ago, so it is difficult for me to say something more about J-TAG or GDB in combination with it. You have to look in Chinese documentation. When searching, you can also include materials about the W801, because it is basically the same system (W800 is a reduced version).
Basically, I would rather not worry about the lack of such debugging, I do not associate the future with these uncertain systems, I just add support for these platforms to my firmware to help Tasmota / Esphome firmware users who bought them expecting there will be ESP inside. In the case of this LED strip, even such a user would not be able to solder the module, moreover, it is probably known that soldering (and buying a new module with ESP) costs money. I also work with these users on an ongoing basis and add functionalities that are actually required by them, also remotely. Some time ago I implemented one driver for a user from Australia, they program its sockets via the Internet via OTA.
EDIT: A glance at the IDE used tells me that they have OpenOCD (debugger) and even QEmu (emulator) support, but I can't be sure it's functional. I didn't have such problems with porting that I had to debug deeper.
Dear! Thank you very much for the answers, the module has been ordered and the search has started (for some possible non-Chinese documentation). I also realized that I actually did offtop, so sorry and best regards!
I have been playing with a less powerful W600 device. I have got the firmware updated with the demo app. The device fails to go into sta mode, scanning networks returns nothing (no error). I initially though that the chip was damaged but access point works. Any suggestions on what I could try next?
Update: I was able to resolve that. Apparently uploading the firmware via python tool was not sufficient. Using wm_tool with full erase cleared up the glitch and now the t-scan in demo works.
Yes, it gets warm, but we have a fix for that (tested on BK7231N/BK7231T and W600 - not sure about W800 yet, but it should also work) - a powersave command, which will put OBK into a power saving mode. Big thanks to @btsimonh and @iprak NOTE: tls_wifi_set_psflag(1, 0); might not be enabled for W800 for current platform, you might need to enable it or wait for me to find W800 dev board (I will enable it in the following days).