Skip to content

crosstyan/w806-air103-cmake

Repository files navigation

W806 CMake template

Intended to use with Xuantie-800-gcc-elf-newlib, which have gcc-13 support. (I guess old toolchain should work fine...)

Derived from wm-sdk-w806.

I'm not a fan of Makefile, and it makes me headache when debugging it

Drivers

There are two API styles for W806/Air103

  • one comes from WinnerMicro W806 which appears to be an old one (v0.6.0), started with HAL (I would call it HAL driver)
  • the other from WinnerMicro W80X (v1.00.10) which is used in luatos-soc-air101, started with tls (I would call it tls driver)

The tls one has more features like Bluetooth and Wi-Fi but W806/Air103 doesn't have RF module. The OSAL abstraction layer comes from tls driver is bloated and less flexible than HAL driver.

I never plan to use tls driver, tls branch did some experiments, but it's not usable. (You must be kidding that most of the header files are without #ifdef __cplusplus some even don't have "include guards", makes it hard to use in C++ project)

Anyway, enough complaining, let's see what we have here.

Features

See csi_config.h and FreeRTOSConfig.h to configure the environment. I personally don't like to use fancy Kconfig but define them directly in the header file.

  • FreeRTOS

From demo.elf to fls

See make_firmware.sh.in, which is almost equivalent to rules.mk from wm-sdk-w806. See also sdk.conf.

If you don't care about encryption and signature stuff, things are pretty simple.

csky-unknown-elf-objcopy -Obinary demo.elf demo.bin
wm_tool -b demo.bin -o demo -it 1 -fc 0 -ra 0x080D0400 -ih 0x080D0000 -ua 0x08010000 -nh 0 -un 0
  • -b demo.bin: Specifies the input binary file (demo.bin) to be packaged.
  • -o demo: Specifies the output firmware file name prefix (demo).
  • -it 1: Sets the firmware image layout type to 1 (user image).
  • -fc 0: Disables firmware compression.
  • -ra 0x080D0400: Sets the runtime position (address) of the firmware to 0x080D0400.
  • -ih 0x080D0000: Sets the image header storage location to 0x080D0000.
  • -ua 0x08010000: Sets the upgrade storage location (OTA address) to 0x08010000.
  • -nh 0: Sets the next image header storage location to 0 (not used).
  • -un 0: Sets the upd no version number to 0 (not used).

Flashing

See crosstyan/wm_tool_rs.

With wm_tool

You can also use the original wm_tool.

Following commands are stolen from github0null/w800_cmake_sdk

wm_tool -dl "$firmware" -ws 2M -ds 2M -rs rts -c $port -sl str -ws 115200

Here's the explanation generated by AI. Take it with a grain of salt.

  • -dl "$firmware": Specifies the firmware file to be downloaded. The $firmware variable should contain the path to the firmware file.
  • -ws 2M: Sets the serial port speed during normal work (after firmware download) to 2 Mbps.
  • -ds 2M: Sets the serial port speed during firmware download to 2 Mbps.
  • -rs rts: Sets the device reset method to use the serial port's RTS (Request to Send) pin to control the device reset.
  • -c $port: Specifies the serial port to connect to for downloading the firmware. The $port variable should contain the name of the serial port (e.g., COM3, /dev/ttyUSB0).
  • -sl str: Sets the display format for the log information output from the serial port to string mode.
  • -ws 115200: Sets the serial port speed during normal work (after firmware download) to 115200 bps. This option overrides the previous -ws 2M setting.

In summary, this command does the following:

  1. Connects to the specified serial port ($port) to communicate with the W800 device.
  2. Sets the serial port speed to 2 Mbps during firmware download.
  3. Uses the RTS pin to control the device reset.
  4. Downloads the specified firmware file ($firmware) to the W800 device.
  5. Sets the serial port speed to 115200 bps for normal operation after the firmware download.
  6. Displays the log information output from the serial port in string format.

Serial Monitor

wm_tool -c ttyUSB0 -sl str -ws 115200

Erase

wm_tool -c ttyUSB0 -rs rts -eo all

Debugging

Not available yet. See W806 debugging (part 1).

Reference