OOMWOO firmware: set up, build, flash and bring up the CH32 MCUs

Set up the toolchain on Windows (WSL2) or Linux, build the OOMWOO CH32V307, CH32L103 and dock CH32V003 firmware, flash it with a WCH-LinkE, bring it up on WCH's evaluation boards, or build U28 in the Arduino IDE.

OOMWOO’s main board has two WCH RISC-V microcontrollers: a CH32V307 (U13) runs the motors, sensors, safety and the USB link to the phone, and a CH32L103 (U28) handles power, buttons, charging status and USB-C. The charging dock has a third, a CH32V003. This post shows how to set up the toolchain, build the firmware, flash it, and bring it up on WCH’s evaluation boards while the robot board is being made. Prefer the Arduino IDE? U28 also builds as an Arduino sketch: see Arduino.

The firmware is a starter: it builds, its shared logic is unit-tested, and every pin is set up from the schematic, but it has not run on silicon yet. I will update this post as the boards come up.

Updated 2026-11-25: the charging dock firmware, and the Arduino version of U28.

What you need

  • A PC with Windows 10/11 and WSL2, or Linux x64.
  • A WCH-LinkE debug probe (WCH’s own; it flashes and debugs both chips).
  • A CH32V307 evaluation board (CH32V307V-R1). It has its own WCH-Link and a USB serial port, so it needs no extra probe.
  • Optional: a CH32L103C8T6 evaluation board and four jumper wires, to test the link between the two chips.

1. Set up the tools

Everything is plain GCC and make, no vendor IDE. Two scripts install it all: setup.sh builds in Linux or WSL2, setup-windows.ps1 installs the flashing tools on Windows, where the USB probe is.

Windows

Install WSL2 with Ubuntu (skip if you have it), then reboot:

wsl --install -d Ubuntu-24.04

In Ubuntu, clone the repository inside WSL (builds under /mnt/c are several times slower) and run the setup script. It installs the RISC-V GCC, the WCH SDK, wlink and wchisp, adds them to your PATH, builds both images and runs the tests:

mkdir -p ~/git && cd ~/git
git clone https://github.com/makerspet/oomwoo-firmware.git
cd oomwoo-firmware
mcu/scripts/setup.sh

Then, in Windows PowerShell, install the flashing tools (they go to %LOCALAPPDATA%\oomwoo\wch and onto your PATH):

cd \\wsl.localhost\Ubuntu-24.04\home\<you>\git\oomwoo-firmware
powershell -ExecutionPolicy Bypass -File mcu\scripts\setup-windows.ps1

Install WCH’s WCH-LinkUtility once: it brings the WCH-Link driver that wlink uses.

Linux

git clone https://github.com/makerspet/oomwoo-firmware.git
cd oomwoo-firmware
mcu/scripts/setup.sh

On native Linux the script also installs udev rules for the WCH-Link and the WCH bootloaders, so no sudo is needed to flash. Replug the probe afterwards.

2. Build

make -C mcu                  # all three MCUs, for the robot board and the dock
make -C mcu BOARD=evt        # the same for WCH's evaluation boards
make -C mcu test             # unit tests of the shared logic
ImageFor
mcu/build/robot/u13.binU13 (CH32V307) on the robot board
mcu/build/robot/u28.binU28 (CH32L103) on the robot board
mcu/build/robot/dock.binthe charging dock (CH32V003)
mcu/build/evt/u13.binU13 on the CH32V307V-R1 board: console on its built-in USB serial port
mcu/build/evt/u28.binU28 on the CH32L103C8T6 board: power-button input pulled up internally

3. Flash

Connect the probe to the chip’s debug pins: SWDIO, SWCLK, GND and 3.3 V. The CH32V307V-R1 board has its own WCH-Link: plug in its WCH-Link USB port and use that. From WSL, run the Windows wlink.exe and hand it a Windows path:

cd ~/git/oomwoo-firmware/mcu
wlink.exe flash --address 0x08000000 "$(wslpath -w build/evt/u13.bin)"

On Linux, or from PowerShell, it is the same without .exe and wslpath. wlink status shows the probe and the attached chip if something does not work.

No probe? Both chips have a bootloader. Hold the CH32V307 board’s BOOT0 high while you plug its USB HS port into the PC, then flash with wchisp flash build/evt/u13.bin (on Windows, wchisp needs the WinUSB driver from Zadig for this).

4. Bring up U13 on the evaluation board

Open the board’s WCH-Link serial port (a new COM port on Windows, /dev/ttyACM* on Linux) at 115200 baud with any terminal, and press RESET. You should see:

OOMWOO U13 (CH32V307) starter firmware 1 [EVT board], HSE ok, reset: power/pin
u13> 

help lists the commands. A first pass:

CommandCheck
statusClock from the 8 MHz crystal (HSE ok), rails off, the motion gate closed (not_armed, u28_lost until U28 is connected)
adcAll channels read; touch a header pin (PA0, PC0…) to see it move
rails onPB15 goes low, then PB14 high: the sensor rail enables on the robot board
camA 24 MHz clock on PA8 (scope). No camera on this board, so the ID read fails
scope on PB5The RC-watchdog toggle: a 500 Hz square wave while the control loop runs

On this board, PC6–PC9 go to the Ethernet jack and PC14/PC15 to a 32 kHz crystal, so the carpet sensor and the camera I2C bus are off in the EVT build.

5. Add U28 and the link between the chips

Flash build/evt/u28.bin into the CH32L103 board with the WCH-LinkE, then wire the two boards like the robot board:

CH32L103 boardCH32V307 board
PA2 (U28 TX)PE15 (U13 RX)
PA3 (U28 RX)PE14 (U13 TX)
GNDGND
NRST (optional)PC13

Now status on the U13 console prints a u28: line with U28’s readings, and u28 shows the link’s frame and error counters. To test the power button, hold PA12 of the CH32L103 board to GND: after 1 s the power LED pin (PA9) blinks fast, after 3 s U13 prints power off requested by U28: rails off and U28 drops PB13 (the power latch).

6. On the robot board

  • U13 console: J4 pins 5 (TX) and 4 (RX), 3.3 V logic, 115200 baud, to a USB-serial adapter.
  • U13 debug: J4 pins 7 (SWDIO), 8 (SWCLK), 9 (NRST) and 1 (GND) to the WCH-LinkE.
  • U28 debug: J1 pins 10 (SWDIO), 11 (SWCLK) and 13 (GND).
  • Then rails on, i2c main (the IMU answers at 0x6a), imu, cam, cliff, bump and ir. arm turns the motor rail on; drive 200 200 500 runs both wheels slowly for half a second.

7. The charging dock

The dock’s CH32V003 checks that the USB-C charger negotiated 20 V, waits for the robot’s signature across the charging contacts, switches them on, and sends an IR beacon the robot homes on. The beacon also carries how many watts the charger can give, so the robot can decide whether to charge its phone at the same time.

  • Flash: WCH-LinkE to J1001 (pin 1 SWIO, pin 2 GND) while the dock runs from its own charger, then wlink flash --address 0x08000000 build/robot/dock.bin (or make -C mcu flash-dock).
  • Status LED: a short blip every 2 s while it waits for a robot, on while charging, a double blink when the charger cannot give 20 V, fast blinking after a fault.
  • Optional debug console on J1005 (pin 3 TX, pin 4 RX, 115200 baud): status and pd.
  • From the robot: ir on the U13 console shows the dock’s frames, which string sent them, and the power budget.

Arduino

Hackable means people should be able to open the firmware, change it and upload it from the Arduino IDE. U28 already works that way, on WCH’s official Arduino core; U13 may follow after U28 runs on hardware.

  1. Install the Arduino IDE 2.x.
  2. File > Preferences > Additional boards manager URLs: add https://github.com/openwch/board_manager_files/raw/main/package_ch32v_index.json. Then Tools > Board > Boards Manager, search “CH32” and install CH32 MCU EVT Boards.
  3. File > Preferences > Sketchbook location: the arduino folder of your oomwoo-firmware clone. Restart the IDE.
  4. Tools > Board: “OOMWOO main board U28”, and Tools > Hardware: the robot board or the CH32L103 evaluation board.
  5. Open File > Examples > OOMWOO > U28 and click Upload, with the WCH-LinkE on SWDIO, SWCLK and GND.

Change U28.ino freely: the LED patterns, the readings, the spare pins. The parts that keep the robot safe (power latch and button, charge current, the camera and sensor lines) run from a timer interrupt in safety.cpp, so a sketch that blocks or crashes cannot hold them; if loop() stops for 100 ms, the watchdog resets U28. From a terminal, mcu/scripts/setup.sh --arduino installs arduino-cli and the core, and arduino/build.sh builds the sketch.

Troubleshooting

  • $'\r': command not found: the scripts were checked out with Windows line endings. Clone inside WSL, or run git config --global core.autocrlf input and clone again.
  • wlink finds no probe: install WCH-LinkUtility (Windows) or replug after setup.sh (Linux). Make sure the probe is in RISC-V mode.
  • The banner says HSE FAILED (HSI): the 8 MHz crystal did not start. Everything except USB high speed still runs.
  • No u28: line: check TX/RX are crossed and GND is shared; u28 shows CRC errors if the wiring is noisy.

What is next

  • USB high speed to the phone: the robot’s serial protocol, then the camera as a USB webcam (UVC).
  • Drivers for the VL53L7 ToF sensors, the IMU and the LiDAR.
  • Closed-loop wheel control and odometry.
  • U13 updating U28 through its bootloader, so the phone can update both chips.
  • The Arduino version of U13, once U28’s has run on hardware.

The full plan, including what writing this firmware found in the schematic, is in docs/firmware-plan.md.

One comment

  1. […] Why these chips: until November 21 this was an STM32G473, but its price went to $7.39 with 20 in stock. The two WCH chips cost about $2.60 together, both in leaded packages. The CH32V307 has enough pins, timers and ADCs for all the motors and sensors, plus built-in op-amps that amplify the carpet sensor echo without an extra part. It also has a parallel camera port and high-speed USB with a built-in PHY, so the phone gets the camera stream without a bridge chip or a USB hub. An 8 MHz crystal clocks it; the phone keeps the time, so there is no RTC crystal. Details: mcu-ch32v307.md. To build and flash the firmware, see OOMWOO firmware: set up, build, flash and bring up the CH32 MCUs. […]

Leave a Reply

Your email address will not be published. Required fields are marked *