Contributed by KCrO, curated by Ai-Thinker
Preparation
Get the toolchain
Install some dependencies and tools
sudo apt-get install make gcc cmake git ninja-build -yGet the SDK (WSL proxy setup is a bit troublesome; I'll dig a hole and write a configuration tutorial later)
Refer to the configuration tutorial by 起个名字好难啊: Building the Xiao An Pai Linux development environment from scratch - Compiling and running hello world
To make Linux files easier to manage, first create a folder for the SDK in the user's home directory. Enter
mkdir appto create the app directory, then enter it withcd app. Then get the SDK.
git clone --recursive https://github.com/Ai-Thinker-Open/AiPi-Open-kits.git
or
git clone --recursive https://gitee.com/Ai-Thinker-Open/AiPi-Open-Kits.gitAfter the download completes, enter the directory.
cd AiPi-Open-Kits/aithinker_Ai-M6X_SDK
then run in order
. install.sh
. export.shCompiling and Flashing
Compile
Return to the AiPi-Open-Kits directory and enter the AiPi-Eyes_weather directory.
cd ../ && cd AiPi-Eyes_weatherThen, elegantly type those few letters:
code .Wait for Windows' VSCode to start. Then you can edit code with VSCode on Windows. Then compile the code; enter
makein the AiPi-Eyes_weather directory.Flash
Install USBIP
Open PowerShell on Windows and enter:
winget install usbipdIt will then ask whether you accept the agreement; enter Y and wait for the installation.Download WSL-USB-GUI
Then find the releases page, download the installer (.msi file) and install it.Since usbipd has been updated, the old GUI no longer works. Download the latest version: left sidebar -> Build -> Pipelines -> Download artifacts.After downloading, install it to map USB devices to WSL. On Linux: According to the Microsoft official guide:
sudo apt install linux-tools-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20After the download completes, you can flash with the make flash command 😄
make flash COMX=/dev/ttyACM0Extra
Since the official SDK has issues when used directly in WSL, you need to enter the SDK directory.
cd ~/app/AiPi-Open-Kits/aithinker_Ai-M6X_SDKFind the project.build file, locate the code shown in the figure below, and delete it.
Also, every time WSL restarts, it seems you need to run the export.sh script before compiling again, so you can edit an alias or function in bashrc to call it.
First
code ~/.bashrcThen copy the following code into it.
get-aipi-sdk(){
NowPath=$PWD # get current directory
cd $HOME/app/Ai-Thinker/AiPi-Open-kits/aithinker_Ai-M6X_SDK/
. install.sh
. export.sh
cd $NowPath
}Then run
source ~/.bashrcNow you can use get-aipi-sdk to set up the environment. Of course, this function may not be standard; please point out improvements, experts 😄
References
Thanks to @mcx's tutorial -> About flashing issues under WSL2 (solved)
When will the Markdown editor be able to upload images? I really can't take it anymore!
Have questions?
For other questions, please visit the unified discussion area: Ai-Thinker Discussions



After downloading, install it to map USB devices to WSL. On Linux: According to the Microsoft official guide:
Also, every time WSL restarts, it seems you need to run the export.sh script before compiling again, so you can edit an alias or function in bashrc to call it.