本帖最后由 wangzhang 于 2024-5-3 12:47 编辑
物料准备
Ai-M61-32S开发板,Type-c数据线,电脑(本人使用win11系统),面包板,led灯
环境搭建
1.安装Visual Studio Code
这里是官网,具体安装自行百度。
这里简单介绍一下中文插件
![1_watermarked.png 1_watermarked.png](data/attachment/forum/202405/02/223058mvk5bzr9gz55k5bf.png)
以及C/C++扩展包
![2_watermarked.png 2_watermarked.png](data/attachment/forum/202405/02/223106ey76k70yg33k883k.png)
和图标插件
![3_watermarked.png 3_watermarked.png](data/attachment/forum/202405/02/223115wzqy4o29fe4hmq4f.png)
2.Git安装
该软件是用来拉取代码的,推荐下载,这是官方下载地址,具体安装教程在此就不赘述了。
点灯
1.克隆源码
建议创建一个路径没有中文的空文件夹,在文件夹内右键选择git bash here。
克隆代码
git clone https://gitee.com/Ai-Thinker-Open/aithinker_Ai-M6X_SDK.git
![4_watermarked.png 4_watermarked.png](data/attachment/forum/202405/02/223128a220nbzbnpltmmcc.png)
拉取子模块
cd aithinker_Ai-M6X_SDK/
git submodule init
git submodule update
耐心等待这里有点慢。
克隆适合Windows的编译工具
cd toolchain/
git clone https://gitee.com/bouffalolab/toolchain_gcc_t-head_windows.git
2.编辑环境变量
把以下三个路径加入电脑的环境变量中
...\aithinker_Ai-M6X_SDK\toolchain\toolchain_gcc_t-head_windows\bin
...\aithinker_Ai-M6X_SDK\tools\make
...\aithinker_Ai-M6X_SDK\tools\ninja
搜索栏搜索环境变量
![5_watermarked.png 5_watermarked.png](data/attachment/forum/202405/02/223139ejjjid4zr37ga7gj.png)
![6_watermarked.png 6_watermarked.png](data/attachment/forum/202405/02/223147tfqd6jatuut347uu.png)
点击编辑系统环境变量
![7_watermarked.png 7_watermarked.png](data/attachment/forum/202405/02/223158olrrrs6oll9euwsj.png)
点击环境变量,在系统变量中找的Path栏。
![8_watermarked.png 8_watermarked.png](data/attachment/forum/202405/02/223902bcvg26vghevgvoeo.png)
右上角新建添加上面三个路径。
3.验证路径是否设置成功
$ make -v
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ riscv64-unknown-elf-gcc -v
Using built-in specs.
COLLECT_GCC=C:\Users\(用户名)\Documents\AIPI_\aithinker_Ai-M6X_SDK\toolchain\toolchain_gcc_t-head_windows\bin\riscv64-unknown-elf-gcc.exe
COLLECT_LTO_WRAPPER=c:/users/(用户名)/documents/aipi_/aithinker_Ai-M6X_SDKtoolchain/toolchain_gcc_t-head_windows/bin/../libexec/gcc/riscv64-unknown-elf/10.2.0/lto-wrapper.exe
Target: riscv64-unknown-elf
Configured with: /mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/./source/riscv/riscv-gcc/configure --target=riscv64-unknown-elf --host=i686-w64-mingw32 --with-gmp=/mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/build-gcc-riscv64-unknown-elf/build-Xuantie-900-gcc-elf-newlib-mingw-V2.6.1/lib-for-gcc-mingw --with-mpfr=/mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/build-gcc-riscv64-unknown-elf/build-Xuantie-900-gcc-elf-newlib-mingw-V2.6.1/lib-for-gcc-mingw --with-mpc=/mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/build-gcc-riscv64-unknown-elf/build-Xuantie-900-gcc-elf-newlib-mingw-V2.6.1/lib-for-gcc-mingw --with-libexpat-prefix=/mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/build-gcc-riscv64-unknown-elf/build-Xuantie-900-gcc-elf-newlib-mingw-V2.6.1/lib-for-gcc-mingw --with-libmpfr-prefix=/mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/build-gcc-riscv64-unknown-elf/build-Xuantie-900-gcc-elf-newlib-mingw-V2.6.1/lib-for-gcc-mingw --with-pkgversion='Xuantie-900 elf newlib gcc Toolchain V2.6.1 B-20220906' CXXFLAGS='-g -O2 -DTHEAD_VERSION_NUMBER=2.6.1 ' --enable-libgcctf --prefix=/mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/build-gcc-riscv64-unknown-elf/Xuantie-900-gcc-elf-newlib-mingw-V2.6.1 --disable-shared --enable-threads=posix --enable-languages=c,c++ --without-system-zlib --enable-tls --with-newlib --with-sysroot=/mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/build-gcc-riscv64-unknown-elf/Xuantie-900-gcc-elf-newlib-mingw-V2.6.1/riscv64-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --src=/mnt/ssd/jenkins_iotsw/slave/workspace/Toolchain/build-gnu-riscv/./source/riscv/riscv-gcc --enable-multilib --with-abi=lp64d --with-arch=rv64gcxthead 'CFLAGS_FOR_TARGET=-Os -mcmodel=medany' 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medany'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Xuantie-900 elf newlib gcc Toolchain V2.6.1 B-20220906)
4.找官方示例点灯
...\aithinker_Ai-M6X_SDK\examples\peripherals\gpio\gpio_input_output
数据线连接电脑,led连接IO0和IO1,在搜索栏中搜索设备管理器
![11_watermarked.png 11_watermarked.png](data/attachment/forum/202405/02/223301e8op4omeggtte98c.png)
找到端口号,我这里是COM9。(这里我默认您安装了驱动)
![10_watermarked.png 10_watermarked.png](data/attachment/forum/202405/02/223353n5r665sbdi2ri455.png)
在gpio_input_output目录下右键main.c文件,选择在集成终端中打开,在命令行中输入。
![9_watermarked.png 9_watermarked.png](data/attachment/forum/202405/03/124703xxyy7zyrfy326fxp.png)
make clean //清除上次编译的可执行文件和配置文件
make //编译
make flash COMX=COM9 //烧录,要提前进入烧录模式
最后出现Built target combine,就是编译成功了
![15_watermarked.png 15_watermarked.png](data/attachment/forum/202405/02/223408wcf9cnif3otb6odc.png)
如图提示③进入烧录模式。
![14}_watermarked.png 14_watermarked.png](data/attachment/forum/202405/02/223419kmz2mzbnpchhmtbb.png)
![15_watermarked.png 15_watermarked.png](data/attachment/forum/202405/02/223438t2yardg7g3a27226.png)
最后出现All Success表示烧录成功。
![{C717FB74-A154-495e-A2C0-CB98B20DC23E}.png C717FB74-A154-495e-A2C0-CB98B20DC23E.png](data/attachment/forum/202405/03/124714tmx3vl5gksr5uk5l.png)
至于演示视频有空再添加。