Skip to content

Prerequisite

Before proceeding, please set up the Linux development environment first by following the Ubuntu Installation Guide or the WSL Installation Guide (either a VM or WSL works).

Ai-Thinker Skills are AI assistance capabilities curated by Ai-Thinker. After installation, the AI can clone the SDK, configure the environment, and verify the build for you automatically — no need to run commands manually. If you have never used a terminal before, this is the recommended way to start.

1
Install Ai-Thinker Skills

Installing the Ai-M6x development skill coder-ai-m62-m61 is recommended. You can also install all Skills at once.

npx skills add Ai-Thinker-Open/skills --skill coder-ai-m62-m61
# Or install all Skills at once:
npx skills add Ai-Thinker-Open/skills
2
Describe What You Need to the AI

Start a new session in an AI coding tool that supports Skills (such as Codex or Claude Code) and let the AI set up the SDK for you, for example:

“Please use the coder-ai-m62-m61 skill to set up the Ai-M6x Linux development environment: install dependencies, clone the official Bouffalo SDK, and build the Hello World example.”

3
Wait for the AI to Finish

Based on the skill guide, the AI will automatically install dependencies, clone the SDK, configure the toolchain, and verify the build. After that, you can move on to flashing and debugging.

About the skill

coder-ai-m62-m61 is a BL616/BL618 series module development guide based on bouffalo_sdk, covering GPIO, UART, SPI, I2C, DMA, and other peripheral programming. Installation and usage: Ai-Thinker SkillsGitHub Repository

Method 2: Manual Environment Setup

Manual setup may look like a lot of commands, but it is really just four things: install the build tools → download the SDK → build your first program → flash it to the board. Each step below explains what the commands do and what to do if something goes wrong — no terminal experience needed.

1
Open a Terminal and Install Basic Dependencies

On the Ubuntu desktop, press Ctrl+Alt+T to open a terminal (in WSL, open Windows Terminal or the Ubuntu app), then run the command below to install the basic tools:

  • git: downloads code — you will need it to fetch the toolchain and the SDK
  • make: the build tool that turns source code into firmware
  • ninja: optional, makes compilation faster
  • vim: a text editor for viewing and editing code later

If the terminal asks for a password, type your login password and press Enter (nothing will appear on screen while you type — that is normal).

sudo apt-get install git vim make ninja-build -y
2
Download the RISC-V Cross-Compile Toolchain

The toolchain translates your code into machine code that the BL616 / BL618 chip can run (its commands start with riscv64-unknown-elf-). First, download it from the official Bouffalo Lab GitHub repository into your home directory (~ is your home directory, similar to the user folder on Windows):

  1. cd ~ — go to the home directory, where downloaded files will be stored
  2. git clone https://github.com/bouffalolab/toolchain_gcc_t-head_linux.git — download the toolchain; when it finishes, a toolchain_gcc_t-head_linux folder appears in your home directory

The download time depends on your network speed, so be patient. If the second command reports fatal: unable to access, the network cannot reach GitHub — check your connection and try again.

cd ~
git clone https://github.com/bouffalolab/toolchain_gcc_t-head_linux.git
3
Install the Toolchain into the System

Copy the toolchain to a system directory and add it to your environment variables so the terminal can call it from anywhere:

  1. sudo cp -rf toolchain_gcc_t-head_linux/ /usr/bin — copy it to /usr/bin (requires administrator rights; the terminal will ask for your password; do not omit the trailing slash)
  2. echo "export PATH=\"$PATH:/usr/bin/toolchain_gcc_t-head_linux/bin\"" >> ~/.bashrc — append the toolchain’s bin directory to your shell configuration (this command is long, so use the copy button in the top-right corner of the code block to avoid typos)
  3. source ~/.bashrc — apply the configuration immediately; if commands are still not found later, open a new terminal window
sudo cp -rf toolchain_gcc_t-head_linux/ /usr/bin
echo "export PATH=\"$PATH:/usr/bin/toolchain_gcc_t-head_linux/bin\"" >> ~/.bashrc
source ~/.bashrc
4
Verify the Toolchain Installation

Run these two commands to check that everything is installed:

  • make -v: should print GNU Make and a version number
  • riscv64-unknown-elf-gcc -v: should print gcc version 10.2.0 (Xuantie-900 ...)

If you see command not found, the toolchain is not active yet: run source ~/.bashrc again, or close the terminal and open a new one.

make -v
riscv64-unknown-elf-gcc -v
5
Download the Bouffalo SDK Source Code

The SDK is Bouffalo Lab’s official development kit — it contains chip drivers, the Wi-Fi/BLE protocol stack, and many examples. Download it into your home directory and enter the folder:

  1. git clone https://github.com/bouffalolab/bouffalo_sdk.git — download the official SDK from GitHub (note: the Gitee mirror has not been updated for a long time, so always use the GitHub repository)
  2. cd bouffalo_sdk — enter the SDK directory; all later builds happen here
cd ~
git clone https://github.com/bouffalolab/bouffalo_sdk.git
cd bouffalo_sdk
6
Build the Hello World Example

Build the SDK’s built-in helloworld example first to verify the whole environment. Enter the example directory and run the build command:

  • CHIP=bl616 is the chip model: the Ai-M62 (BL616) and the Ai-M61 (BL618) belong to the same series, so both use bl616, the config with the fewest pins
  • BOARD=bl616dk is the development board type

The first build downloads dependencies and generates the project, so be patient. When it finishes, the firmware is generated under build/build_out/.

cd examples/helloworld
make CHIP=bl616 BOARD=bl616dk
7
Flash the Firmware to the Board

Connect the development board to your computer with a USB cable, then follow these steps in order:

  1. Give your user serial port permissions: sudo usermod -a -G dialout $USER (takes effect after a reboot or logging back in; if you do not want to reboot, prefix the flash command with sudo)
  2. Check the serial port: ls /dev/ttyUSB0 — if you see output, the board is recognized
  3. Hold the BOOT button (IO2 on the Ai-M61-32S-Kit), briefly press EN/RST and release it, then release BOOT — the board is now in download mode
  4. Flash the firmware (keep CHIP the same as in the build step): make flash CHIP=bl616 COMX=/dev/ttyUSB0 — flashing is done when the progress bar completes

If you are using WSL, USB serial ports cannot be accessed directly; use the Windows flashing tool instead.

sudo usermod -a -G dialout $USER
ls /dev/ttyUSB0
make flash CHIP=bl616 COMX=/dev/ttyUSB0
8
View Log Output

After flashing, press the reset button on the board and the program starts running. The terminal cannot show the module log by itself, so install the serial tool picocom and connect to the serial port (baud rate 2000000):

  1. sudo apt-get install picocom — install the serial tool
  2. picocom /dev/ttyUSB0 -b 2000000 — connect to the serial port; when you see the log printed by the program, it is running
  3. To exit picocom: press Ctrl+A, then Q
sudo apt-get install picocom
picocom /dev/ttyUSB0 -b 2000000

FAQ

Cloning the SDK is slow

Use a proxy if GitHub downloads are slow — do not use the Gitee mirror, which is outdated.

Flashing fails or reports errors

Usually the board is not in download mode; hold BOOT/IO2 and briefly press EN/RST again.

Serial port permission denied

Run sudo chmod 777 /dev/ttyUSB0 or flash with sudo, and add your user to the dialout group.

Terminal tips

Press Tab to auto-complete commands; paste with Ctrl+Shift+V (or the middle mouse button).

Have questions?

For any other questions, visit the unified Q&A and discussion board: Ai-Thinker Discussions

Released under the MIT License. Build Time 2026-09-11 14:52:23