本帖最后由 r_aint 于 2023-11-14 14:42 编辑
主要软件
VScode+Git,早就用过很久了。Git可视化工具可有可无。
Vscode插件
VScode安装插件 chinese和Doxygen。注意这里需要自行下载gcc编译器,C++插件可以在这时搜索也可以打开cpp代码文件时根据提示安装推荐的插件。
Git Clone 项目
克隆Ai-Thinker仓库
首先创建一个文件夹,
首先创建一个文件夹,右键—>更多选项(如果win11)—>Git Bash Here
在新打开的终端输入
git clone https://gitee.com/Ai-Thinker-Open/AiPi-Open-Kits.git
等待下载完成
拉取子模块
为了避免下载过慢/下载失败,将.gitmodules文件中github改为gitee
首先进入AiPi-Open-Kits目录下
cd AiPi-Open-Kits
在该目录下输入以下指令初始化及递归拉取子模块,用这个命令就不用到每个子目录下update啦,如果下载失败,就删除aithinker_Ai-M6X_SDK文件夹重试即可。
git submodule update --progress --init --recursive
进入aithinker_Ai-M6X_SDK,拉取编译工具以及设置环境变量
cd aithinker_Ai-M6x_SDK
git clone https://gitee.com/bouffalolab/toolchain_gcc_t-head_windows.git
把三个路径加入到电脑的环境变量当中,分别是:
[你的项目地址]\aithinker_Ai-M6X_SDK\toolchain_gcc_t-head_windows\bin
[你的项目地址]\aithinker_Ai-M6X_SDK\tools\make
[你的项目地址]\aithinker_Ai-M6X_SDK\tools\ninja
测试
重启电脑,打开终端:
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=riscv64-unknown-elf-gcc
COLLECT_LTO_WRAPPER=d:/mywork/aipi-open-kits/aipi-open-kits/aithinker_ai-m6x_sdk/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)
尝试编译
用VSCode打开一个demo文件夹
Ctrl+打开终端,输入 make
(如果有cp命令相关的报错直接无视,或者打开/aithinker_Ai-M6X_SDK/project.build
注释掉所以cp命令开头的代码,显示Built target combine则成功:
烧录命令:
make flash COMX=COMxx
没接板子只能显示报错 找不到COMxx
DONE.