Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion en/contest_hk_2026/hk_guide_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Read them in this order:
| ----- | -------- | ------- |
| 1 | [openvela Development Guide for the Hong Kong University Track](./hk_university_track_dev_guide.md) | Which development environment to choose, how to prepare your computer and code, how to build the two kinds of apps, and how to connect AI |
| 2 | [R528 MIBOX-X1 Development Board Guide](./mibox_x1_board_guide.md) | Hardware specifications, interfaces and DIP switches, building and flashing, peripheral tests, and a first application |
| 3 | [Code Submission Guide for the Hong Kong University Track](./hk_code_submission_guide.md) | Fork, then open a Pull Request to submit Quick Apps and native apps to the matching repository |
| 3 | [Connecting to the R528 MIBOX-X1 Board](./mibox_x1_connect_guide.md) | Connect the serial port with MobaXterm, confirm the system has started, join Wi-Fi, troubleshooting |
| 4 | [Running the AI Agent on the R528 MIBOX-X1 (Experimental)](./mibox_x1_ai_agent_guide.md) | Create the ai_agent configuration and build it, get online, set the model, chat with the Agent, troubleshoot with the log |
| 5 | [Code Submission Guide for the Hong Kong University Track](./hk_code_submission_guide.md) | Fork, then open a Pull Request to submit Quick Apps and native apps to the matching repository |

## Development Board Resources

Expand All @@ -22,4 +24,6 @@ Read them in this order:

- First time with openvela: read the Development Guide, then the Development Board Guide.
- You already have the board and want to flash and run right away: go straight to Sections III and IV of the Development Board Guide.
- The board is flashed and you want to connect to it from a computer to read the log and get online: read the Connecting guide.
- You want to try the AI Agent on the board: read the AI Agent guide (experimental; you build the firmware yourself).
- Your project is ready and you need to submit the code: read the Code Submission Guide.
2 changes: 2 additions & 0 deletions en/contest_hk_2026/hk_university_track_dev_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ In the current official configurations, only the ai_agent configuration for the

- [Hong Kong University Track openvela Guide Index](./hk_guide_index.md)
- [R528 MIBOX-X1 Development Board Guide](./mibox_x1_board_guide.md)
- [Connecting to the R528 MIBOX-X1 Board](./mibox_x1_connect_guide.md)
- [Running the AI Agent on the R528 MIBOX-X1 (Experimental)](./mibox_x1_ai_agent_guide.md)
- [Code Submission Guide for the Hong Kong University Track](./hk_code_submission_guide.md)
- [R528 openvela Development Board](https://my.feishu.cn/wiki/BLn6w3By0i8yuNk62GOcxnbfnmh) (from the board vendor: specifications and downloads)
- [Board README](https://github.com/open-vela/vendor_allwinnertech/blob/dev-ai-contest-2026/boards/r528/r528s3-mibox-x1/README.md)
Expand Down
158 changes: 158 additions & 0 deletions en/contest_hk_2026/mibox_x1_ai_agent_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Running the AI Agent on the R528 MIBOX-X1 (Experimental)
\[ English | [简体中文](../../zh-cn/contest_hk_2026/mibox_x1_ai_agent_guide.md) | [繁體中文](../../zh-cn/contest_hk_2026/mibox_x1_ai_agent_guide_zh-hk.md) \]

> This guide explains how to build R528 MIBOX-X1 firmware that includes ai_agent, flash it, connect the board to the network, set a large language model, and chat with the Agent over the serial port. It is experimental: the default `nsh` configuration does not include ai_agent, so you create a new configuration and build the firmware yourself. We verified text chat on a real board. We did not verify voice and other features; see [Section VII](#vii-what-has-not-been-verified).

## I. Before You Start

The default `nsh` configuration does not include ai_agent. This guide turns on ai_agent and a few options it depends on, on top of `nsh`, to make a new configuration called `nsh_agent`.

You need:

- Experience building and flashing the `nsh` firmware by following the [Development Board Guide](./mibox_x1_board_guide.md).
- A working serial connection and a Wi-Fi connection, as described in the [Connecting Guide](./mibox_x1_connect_guide.md).
- An API key for a large language model (you apply for it yourself). This guide uses the Xiaomi MiMo Token Plan as the example. Other providers work the same way.

## II. Create the nsh_agent Configuration

Run these commands in the SDK root directory:

```bash
cd vendor/allwinnertech/boards/r528/r528s3-mibox-x1/configs
cp -r nsh nsh_agent
```

Then edit `nsh_agent/defconfig`:

1. Delete this line:

```text
# CONFIG_MBEDTLS_NET_C is not set
```

The Agent uses the mbedTLS network interface to reach the model server, so this option must be on. After you delete the line, the build turns it on. We checked that the final configuration after the build contains `CONFIG_MBEDTLS_NET_C=y`.
2. Append these five lines at the end of the file:

```text
CONFIG_EVENT_FD=y
CONFIG_EXAMPLES_AI_AGENT_VELA=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_OPENSSL_MBEDTLS_WRAPPER=y
CONFIG_SYSTEM_POPEN=y
```

`CONFIG_EXAMPLES_AI_AGENT_VELA` is ai_agent itself, and its command name is `ai_agent`. The other four are components it depends on.

The result is identical to the configuration we built and verified.

## III. Build and Pack

The `m nsh` command only builds the `nsh` configuration, so call `build.sh` directly to build `nsh_agent`:

```bash
cd vendor/allwinnertech/lichee
source envsetup.sh
lunch_nuttx r528s3-mibox-x1
cd ../../..
./build.sh vendor/allwinnertech/boards/r528/r528s3-mibox-x1/configs/nsh_agent/ -e -Wno-error -j$(nproc)
cd vendor/allwinnertech/lichee
pack
```

- On a 24-core development machine, building and packing take about 4 minutes.
- The return value of `pack` may be non-zero when it ends. Go by the `pack finish` line in the output and by the generated `.img` file.
- The firmware has the same file name as the `nsh` firmware: `vendor/allwinnertech/lichee/out/r528s3/mibox-x1_nand/rtos_nuttx_r528s3-mibox-x1_uart0_256Mnand.img`. Building again overwrites it, so copy it right away and rename the copy, for example with an `_agent` suffix.

## IV. Flash and Connect to the Network

1. Flash the firmware by following Section IV of the [Development Board Guide](./mibox_x1_board_guide.md).
2. Connect over the serial port by following the [Connecting Guide](./mibox_x1_connect_guide.md), and check that `nsh>` appears.
3. Connect to Wi-Fi and check that you can ping a domain name, for example:

```text
nsh> ping api.xiaomimimo.com
```

The board must reconnect to Wi-Fi after every power-up. Use a 2.4 GHz network.

## V. Set the Model and Ask a Question

At the `nsh>` prompt, type `ai_agent` to enter the Agent command line. The prompt changes to `vela>`:

```text
nsh> ai_agent
vela>
```

### 1. Set the model

`set_llm` has two forms:

```text
vela> set_llm <preset> <key>
vela> set_llm <url> <model> <key>
```

The presets are `kimi`, `qwen`, `deepseek`, `glm`, `openai`, `openrouter` and `mimo`. Each comes with a default address and a default model. If your key must be used with a different address, use the second form. End the address at `/v1`, and the program appends `/chat/completions`.

Take the Xiaomi MiMo Token Plan as an example. A Token Plan key works only with its own dedicated address. Do not use the `mimo` preset, which points to `api.xiaomimimo.com` and returns 401 for a Token Plan key:

```text
vela> set_llm https://token-plan-cn.xiaomimimo.com/v1 mimo-v2.6-flash <your key>
```

- Take the address and the model names from the Token Plan page of the MiMo console. The chat models listed in the console are `mimo-v2.6-pro` and `mimo-v2.6-flash`, and we tested with `mimo-v2.6-flash`. Names containing `asr` are speech recognition models, and names containing `tts` are speech synthesis models. They are not chat models.
- After a successful setting, the log shows `LLM backend: ...` and `API key saved.`. Use `config_show` to see the current configuration.

An API key is private. The command is echoed in the terminal and may appear in logs, so cover the key before you send a screenshot or a log to anyone. If a key is exposed by accident, reset it on the provider's platform.

### 2. Ask a question

```text
vela> ask hello
```

With the network and the key correct, the reply appears after a few seconds. The following is an excerpt from a real run (parts are replaced by `<…>`):

```text
[llm] OpenAI API with tools (model: mimo-v2.6-flash, <…> bytes)
[vela_tls] Handshake OK: TLSv1.2 / <…>
[llm] Response: 55 bytes text, 0 tool calls, finish=end_turn
[trace:<…>] iter=0 tool=(none) latency=3015ms llm=ok backend=0
[agent] [Agent]: Hello! I'm your AI assistant. How can I help you today?
```

This request took about 3 seconds. When `[Agent]:` is followed by a reply from the model, the whole chain (network, name resolution, TLS, model and Agent) works.

## VI. Troubleshooting with the Log

The message the Agent gives you does not always show the real cause. When something fails, read the log lines before it:

| What the log shows | Cause and what to do |
| ------------------ | -------------------- |
| `API error 401`, `Invalid API Key` | The key is invalid, or the key does not match the address. Check the key for typos. A Token Plan key needs its dedicated address. |
| `API error 404`, saying the model does not exist | The model name is wrong. Compare it with the model names in the console. |
| `API error 429` | The quota or the request rate is exceeded. |
| `net_connect <domain>:443 ret=0x52` | The domain name cannot be resolved: the board is not on the network or has no DNS. Go back to [Section IV](#iv-flash-and-connect-to-the-network), and use `ifconfig` to check whether `wlan0` has an address. |
| The Agent replies "请求超时,LLM 响应时间过长" (request timed out) | It may not be a real timeout. See "System time" below. |
| The Agent replies `Sorry, I encountered an error.` | It gives no reason. Read the `API error` or other log lines before it. |
| `[weixin] No token, waiting...` every 5 seconds | The WeChat channel is on but not configured. You can ignore it. It only floods the screen. |

### System time

Before the TLS handshake, the Agent checks the system time. If the time is earlier than 2024 (the board shows 1970 until it gets the time from the network), it sets the system clock to 28 February 2026. So the timestamps in the log suddenly jump to `26/02/28`, which is not the real date.

The jump also affects the timeout check. From the log, the Agent computes the request time from the clock before and after the jump, which differs by decades, and so it reports "request timed out" although the request failed immediately for another reason. When you see this message, first look for a `net_connect` or `API error` line before it.

The NTP service starts at boot, before the Wi-Fi connection. We have not verified whether the system time is corrected automatically after the board gets online.

## VII. What Has Not Been Verified

We have not verified the following on the MIBOX-X1 board. Do not treat them as working features:

- Voice: recording, playback, speech recognition and synthesis. The Gemini-S1 board has an audio configuration adjusted for ai_agent. We did not do this for the MIBOX-X1.
- The Feishu, WeChat and MQTT channels, and Node and MCP. They are on by default, but we did not configure or test them.
- Tool calls. We only tested plain chat (`tool_use=0`). We did not test the Agent calling its built-in tools (file access, web search, scheduled tasks and so on).
- Whether the model setting is kept after a power cycle.
- Memory usage.
- 5 GHz Wi-Fi networks.
130 changes: 130 additions & 0 deletions en/contest_hk_2026/mibox_x1_connect_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Connecting to the R528 MIBOX-X1 Board (Serial Port and Network)
\[ English | [简体中文](../../zh-cn/contest_hk_2026/mibox_x1_connect_guide.md) | [繁體中文](../../zh-cn/contest_hk_2026/mibox_x1_connect_guide_zh-hk.md) \]

> This guide explains how, after the firmware is flashed, you connect a Windows computer to the R528 MIBOX-X1 board through the serial port, confirm that the system has started, and connect the board to Wi-Fi. MobaXterm is used as the serial tool. For flashing the firmware, see Section IV of the [Development Board Guide](./mibox_x1_board_guide.md).

## I. Preparation

### 1. Hardware and cabling

- An R528 MIBOX-X1 board with the firmware already flashed.
- One USB Type-A to Type-C cable. Connect one end to the computer and the other end to **port 12 (UART0 debug serial port)** on the board. Port 12 and port 11 (USB-D, used for flashing) are both at the upper right of the board: 12 is on the left and 11 is on the right. Do not swap them. See the [interface diagram](../../zh-cn/contest_hk_2026/images/mibox_x1_interfaces.png) for their positions.
- Set DIP switch **DIP4 to ON**. When DIP4 is OFF, these pins are used for the SD card and nothing appears on the serial port.

### 2. Install the CH340 driver

The board uses a CH340 chip to convert the serial port to USB, so the computer needs the matching driver.

1. Unzip `CH341SER_Windows.zip` from the tool package.
2. Run `SETUP.EXE` as administrator and click "INSTALL".
3. After installation, plug in the serial cable and open Device Manager. Under "Ports (COM & LPT)" you should see `USB-SERIAL CH340 (COMx)`, where `COMx` is the port number (for example COM6). Write it down.

The port number changes with the computer and the USB port. If you do not see this entry, the driver is not installed correctly, or the cable is not plugged into port 12.

## II. Connect the Serial Port with MobaXterm

1. Close every program that might hold this COM port, such as other serial tools. A COM port can be opened by only one program at a time.
2. Open MobaXterm, click **Session** at the upper left, and choose **Serial**.
3. Set the following:

| Setting | Value |
| ------- | ----- |
| Serial port | The COM port you wrote down, for example `COM6 (USB-SERIAL CH340 (COM6))` |
| Speed (bps) | `1500000` |
| Data bits | 8 |
| Stop bits | 1 |
| Parity | None |
| Flow control | Xon/Xoff |

The Speed drop-down list may not contain 1500000. Type it into the box. Data bits, Stop bits, Parity and Flow control are on the **Advanced Serial settings** tab.
4. Click **OK** to open the session.
5. Press the RESET button on the board (SW1, item 13 in the interface diagram). The boot log scrolls in the window. If nothing appears, press Enter once in the window first.

The screenshot below shows the settings we used. The Speed box in the picture cuts off the number; the value entered is `1500000`. The COM port number differs from computer to computer. We used Xon/Xoff for Flow control, and with these settings we saw the complete boot log.

![MobaXterm serial session settings](../../zh-cn/contest_hk_2026/images/mobaxterm_serial_settings.png)

## III. Confirm That the System Has Started

The log ends with `Boot nsh ok`, followed by the NuttShell prompt `nsh>`. The following excerpt comes from a real board. The exact lines, process IDs and times depend on the firmware version:

```text
Started the NTP daemon as PID=26
lvgldemo &
...
echo "Boot nsh ok"
Boot nsh ok

NuttShell (NSH)
nsh>
```

The screenshot below shows the boot log in MobaXterm, from the display driver to `nsh>`:

![Boot log of the board](../../zh-cn/contest_hk_2026/images/mibox_x1_boot_log.png)

The log also contains these lines, which tell you whether each part works:

| Log content | Meaning |
| ----------- | ------- |
| Lines from `lv_nuttx_fbdev`, including `480 at 130dpi` | The display driver has started. The screen should show a picture. |
| `touchscreen /dev/input0 opening success` | The touch device is open. Touching the screen should get a reaction. |
| `lvgl fb loop start OK`, `lvgl input loop start OK` | The LVGL UI is running. |
| `bluetoothd` starts, and services such as `A2DP-Sink`, `GATTC` and `GATTS` print `register success` | The Bluetooth stack has started. |

Notes:

- After `nsh>` appears, the LVGL and Bluetooth logs may keep printing and push the prompt up the screen. Press Enter once to get a clean `nsh>`.
- Without a network connection, the system time shows 1970 (`70/01/1` at the start of each log line). This is not a fault.

Once you see `nsh>`, try these two commands:

```text
nsh> help
nsh> uname -a
```

`help` lists the available commands, and `uname -a` shows the kernel information.

## IV. Connect to Wi-Fi

The Wi-Fi module on the board is the RTL8733BS, which supports 2.4 GHz and 5 GHz. The steps below make the board join a router or a phone hotspot as a client (STA). Run the commands at the `nsh>` prompt.

```text
nsh> ifup wlan0
nsh> wapi mode wlan0 2
nsh> wapi psk wlan0 <PSK> 3
nsh> wapi essid wlan0 <SSID> 1
nsh> renew wlan0
```

- Replace `<PSK>` with the Wi-Fi password and `<SSID>` with the Wi-Fi name.
- After `renew wlan0`, the board asks the router for an address.
- Type the commands one at a time. When you paste several lines at once, the serial port sometimes drops characters.

After connecting, check the network with `ping`. You can ping the gateway address of the router, or an address on the Internet:

```text
nsh> ping 8.8.8.8
```

If you get replies, the connection works.

After connecting with the commands above, you have to enter them again each time the board is powered on. The boot script checks for `/data/etc/wifi/wapi.conf` and starts Wi-Fi automatically when the file exists, but we have not verified how to create that file, so please use the manual steps above for now. The 5 GHz band has not been tested on the board either, so use a 2.4 GHz network first. A Wi-Fi password is private. Cover it before you send a screenshot or a log to anyone.

The board can also act as a hotspot (AP mode). See the Wi-Fi part of Section V of the [Development Board Guide](./mibox_x1_board_guide.md) for the commands.

## V. Troubleshooting

| Symptom | Check first |
| ------- | ----------- |
| No CH340 in Device Manager, and no COM port in the MobaXterm list | Whether the CH340 driver is installed; whether the cable is in port 12; try another cable or USB port |
| The port cannot be opened, or access is denied | Another program holds the COM port. Close it first. |
| Output appears but is garbled | Whether Speed is `1500000`, with 8 data bits, 1 stop bit and no parity |
| Nothing appears in the window | Whether DIP4 is ON; whether the cable is in port 12; press Enter once; then press the RESET button |
| Keyboard input has no effect and the output is stuck | Press the RESET button to restart, then look at the log again. You can also try changing Flow control to None. |
| The board does not start after flashing | Whether the flashing cable (port 11) has been unplugged; see Section IV of the [Development Board Guide](./mibox_x1_board_guide.md) |

## VI. Using Other Serial Tools

The serial parameters are the same as above (1500000, 8 data bits, no parity, 1 stop bit), so tools such as PuTTY and picocom also work. Just pick the right COM port or device name. The tool we have actually used and verified on Windows is MobaXterm.
Loading
Loading