本帖最后由 七月的风 于 2024-5-14 01:25 编辑
本帖最后由 七月的风 于 2024-5-1 00:01 编辑
安信可官方 Docs https://docs.ai-thinker.com/eyes
软件安装
- Git-2.4.1.0.3 工具Window安装包: 点击下载
用于仓库拉取代码和管理代码的工具
- VScode1.81.0 Windows 安装包:点击下载
非常强大的代码编辑器
- Visual Studio Code 官网下载:点击跳转
非常强大的代码编辑器
![2024_05_14_01_02_IMG_0779.PNG 2024_05_14_01_02_IMG_0779.PNG](data/attachment/forum/202405/14/010553s4n1ffn2gmgupjnt.png)
Visual Studio Code 安装中文语言包
![2024_05_14_01_03_IMG_0780.PNG 2024_05_14_01_03_IMG_0780.PNG](data/attachment/forum/202405/14/010614yooojktokdkbo8sx.png)
仓库地址
不太习惯使用git,一般使用下载仓库的方式,使用git拉取也容易遇到网络问题。
看群里很多因为代码git不全编译出现各种问题,顺便写一个不用git命令完成搭建环境的方法
GitHub 仓库
https://github.com/Ai-Thinker-Open/AiPi-Open-Kits
Gitee 仓库
https://gitee.com/Ai-Thinker-Open/AiPi-Open-Kits
AIPI-Open-Kits
选择 “ Master ” 分支
![2024_05_14_01_03_IMG_0781.PNG 2024_05_14_01_03_IMG_0781.PNG](data/attachment/forum/202405/14/010705k4gzhw7tgtt7tsgy.png)
![2024_05_14_01_03_IMG_0782.PNG 2024_05_14_01_03_IMG_0782.PNG](https://bbs.ai-thinker.com/data/attachment/forum/202405/14/010709wwi7x2whox5i578h.png)
在桌面新建一个“ AIPI ” 目录,点击下载 “ Download ZIP ” 解压至新建目录下
![2024_05_14_01_03_IMG_0783.PNG 2024_05_14_01_03_IMG_0783.PNG](data/attachment/forum/202405/14/010718iwl3yjy32jl9sfxj.png)
下载 Aithinker_Ai-M6X_SDK 仓库
https://github.com/Ai-Thinker-Open/aithinker_Ai-M6X_SDK
https://gitee.com/Ai-Thinker-Open/aithinker_Ai-M6X_SDK
![2024_05_14_01_03_IMG_0784.PNG 2024_05_14_01_03_IMG_0784.PNG](data/attachment/forum/202405/14/010728zpd3v1hxw18tq4dq.png)
下载 “aithinker_Ai-M6X_SDK-master.zip”
完成后解压至“\AIPI\AiPi-Open-Kits-master\aithinker_Ai-M6X_SDK”目录
![2024_05_14_01_03_IMG_0785.PNG 2024_05_14_01_03_IMG_0785.PNG](data/attachment/forum/202405/14/010736kvdvjywj8ejmdm7v.png)
![2024_05_14_01_03_IMG_0786.PNG 2024_05_14_01_03_IMG_0786.PNG](data/attachment/forum/202405/14/010852skbukuv49zrrbw9y.png)
下载 Windows 的编译工具链
https://github.com/bouffalolab/toolchain_gcc_t-head_windows
https://gitee.com/bouffalolab/toolchain_gcc_t-head_windows
![2024_05_14_01_03_IMG_0787.PNG 2024_05_14_01_03_IMG_0787.PNG](data/attachment/forum/202405/14/010907rzhidd2pbbibebdb.png)
下载toolchain_gcc_t-head_windows-master.zip
![2024_05_14_01_03_IMG_0788.PNG 2024_05_14_01_03_IMG_0788.PNG](data/attachment/forum/202405/14/010913kigzw4d80g0qmzop.png)
编译工具tools
https://github.com/bouffalolab/bouffalo_sdk/tree/master/tools
编译工具我是在以下单独下载后复制到目录下的 (如果tools目录下为空)
D:\Desktop\AIPI\AiPi-Open-Kits-master\aithinker_Ai-M6X_SDK\tools
![2024_05_14_01_03_IMG_0789.PNG 2024_05_14_01_03_IMG_0789.PNG](data/attachment/forum/202405/14/010919al59waz5z29n9snb.png)
编译工具路径设置
所有都拉取完成之后,需要把三个路径加入到电脑的环境变量当中,分别是:
aithinker_Ai-M6X_SDK\toolchain_gcc_t-head_windows\bin
aithinker_Ai-M6X_SDK\tools\make
aithinker_Ai-M6X_SDK\tools\ninja
电脑属性 - 高级系统设置 - 高级 - 环境变量
根据自己的目录新建三个环境变量
D:\Desktop\AIPI\AiPi-Open-Kits-master\aithinker_Ai-M6X_SDK\toolchain_gcc_t-head_windows\bin
D:\Desktop\AIPI\AiPi-Open-Kits-master\aithinker_Ai-M6X_SDK\tools\make
D:\Desktop\AIPI\AiPi-Open-Kits-master\aithinker_Ai-M6X_SDK\tools\ninja
![2024_05_14_01_03_IMG_0790.PNG 2024_05_14_01_03_IMG_0790.PNG](data/attachment/forum/202405/14/010939mh5vi5kr50r7548r.png)
设置完成之后,重启电脑,然后验证路径是否成功设置。
验证是否成功设置
在桌面按住 shift
键点击 鼠标右键
打开 PowerShell 。在 PowerShell 输入:
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=D:\Desktop\AIPI\AiPi-Open-Kits-master\aithinker_Ai-M6X_SDK\toolchain_gcc_t-head_windows-master\bin\riscv64-unknown-elf-gcc.exe
COLLECT_LTO_WRAPPER=d:/desktop/aipi/aipi-open-kits-master/aithinker_ai-m6x_sdk/toolchain_gcc_t-head_windows-master/bin/../libexec/gcc/riscv64-unknown-elf/10.2.0/lto-wrapper.exe
Target: riscv64-unknown-elf
......
编辑源码
打开 vscode 的终端
文件 - 将文件夹添加到工作区 - 添加“AIPI”目录到工作区
![2024_05_14_01_03_IMG_0791.PNG 2024_05_14_01_03_IMG_0791.PNG](data/attachment/forum/202405/14/010953zxy8ywqs9wawuyxx.png)
由于第一次接触开发板零基础,参考了以下大佬的代码点亮
【祖传点灯】安信可Ai-M61-32S 凌晨1点我竟在…………
https://bbs.ai-thinker.com/forum.php?mod=viewthread&tid=44620
(出处: 物联网开发者社区-安信可论坛)
打开目录
D:\Desktop\AIPI\AiPi-Open-Kits-master\aithinker_Ai-M6X_SDK\examples\peripherals\gpio\gpio_input_output
编辑main.c文件替换成以下代码
#include "bflb_gpio.h"
#include "board.h"
struct bflb_device_s *gpio;
uint32_t gpio_group[] = {GPIO_PIN_12, GPIO_PIN_14, GPIO_PIN_15, GPIO_PIN_27, GPIO_PIN_29};
int main(void)
{
board_init();
printf("1111111111111111111111111111");
gpio = bflb_device_get_by_name("gpio"); // get gpio device 获取 gpio 设备
// set gpio pin mode 设置 GPIO 引脚模式
bflb_gpio_init(gpio, GPIO_PIN_12, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
bflb_gpio_init(gpio, GPIO_PIN_14, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
bflb_gpio_init(gpio, GPIO_PIN_15, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
bflb_gpio_init(gpio, GPIO_PIN_27, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
bflb_gpio_init(gpio, GPIO_PIN_29, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
bflb_gpio_reset(gpio, GPIO_PIN_12);
bflb_gpio_reset(gpio, GPIO_PIN_14);
bflb_gpio_reset(gpio, GPIO_PIN_15);
bflb_gpio_reset(gpio, GPIO_PIN_27);
bflb_gpio_reset(gpio, GPIO_PIN_29);
uint8_t i = 0;
while (1) {
for(uint8_t j = 0; j < 2; j++) {
printf("111111");
bflb_gpio_set(gpio, gpio_group[i]);
bflb_mtimer_delay_ms(200);
printf("0000000");
bflb_gpio_reset(gpio, gpio_group[i]);
bflb_mtimer_delay_ms(200);
}
bflb_gpio_set(gpio, gpio_group[i]);
bflb_mtimer_delay_ms(500);
bflb_gpio_reset(gpio, gpio_group[i]);
i = (i + 1) % 3;
}
}
编译
右键“\gpio_input_output”目录
![2024_05_14_01_03_IMG_0792.PNG 2024_05_14_01_03_IMG_0792.PNG](data/attachment/forum/202405/14/011002aqh97c2k4ut9n8xx.png)
然后在终端输入:
make
![2024_05_14_01_03_IMG_0793.PNG 2024_05_14_01_03_IMG_0793.PNG](data/attachment/forum/202405/14/011011f2va8x2b8ct2oq09.png)
编译成功截图:
![2024_05_14_01_03_IMG_0794.PNG 2024_05_14_01_03_IMG_0794.PNG](data/attachment/forum/202405/14/011025pcqktd35xckdt6x3.png)
编译和烧录
在AiPi-Open-Kits下的example目录看见各种小安派的Demo文件夹,使用cd命令进入到需要编译和烧录的Demo下
cd 对应Demo目录文件夹
make //编译命令
make flash COMX=/dev/ttyUSB0 //烧录命令
烧录程序之前需要先按住"烧录键"再短按"复位按键",进入烧录模式,此时如果rgb有亮灯会灭。
![2024_05_14_01_03_IMG_0795.PNG 2024_05_14_01_03_IMG_0795.PNG](data/attachment/forum/202405/14/011033ao4ler4622ek2z2j.png)
在命令行中输入 (x 为端口号)
make flash COMX=comx
![2024_05_14_01_03_IMG_0796.PNG 2024_05_14_01_03_IMG_0796.PNG](data/attachment/forum/202405/14/011038iqufu9u9qf88851e.png)
如设备管理器端口显示为COM6,则命令行中输入
make flash COMX=com6
![2024_05_14_01_03_IMG_0797.PNG 2024_05_14_01_03_IMG_0797.PNG](data/attachment/forum/202405/14/011045nlv0szdxjlnkvnkk.png)
![2024_05_14_01_03_IMG_0798.PNG 2024_05_14_01_03_IMG_0798.PNG](data/attachment/forum/202405/14/011055ajiij2a2wliifurl.png)
按照以上操作编译烧录未发现有代码报错和烧录失败,初学者一次成功!还是挺开心的😄
🎉️ 至此程序已经烧录到开发板中了,按下复位键,开发板将点亮 led,至此点灯就已经完成了。🎉️
![2024_05_14_01_04_IMG_0799.JPG 2024_05_14_01_04_IMG_0799.JPG](data/attachment/forum/202405/14/011102fyvby5eydkb5vzz8.jpg)