本帖最后由 echoyxt 于 2024-5-3 09:53 编辑
【祖传点灯】安信可Ai-M61-32S环境搭建&点灯
板子到手啦~感谢安可信社区,感谢园长提供的这次机会!点灯走起 ~
1.Windows编译环境搭建
默认已安装好Git
1.1克隆AiPi-Open-Kits仓库
git clone https://gitee.com/Ai-Thinker-Open/AiPi-Open-Kits.git
![图2克隆Aipi-Open-Kits仓库_watermarked.png 图2克隆Aipi-Open-Kits仓库_watermarked.png](data/attachment/forum/202405/03/093926vixdf8cvvxc22h4f.png)
![图3克隆Aipi-Open-Kits仓库_watermarked.png 图3克隆Aipi-Open-Kits仓库_watermarked.png](data/attachment/forum/202405/03/093933pl22k35ype81e0dt.png)
进入AiPi-Open-Kits文件夹,执行子模块更新(一定要做)
git submodule init
git submodule update
1.2克隆aithinker_Ai-M6X_SDK仓库
进入AiPi-Open-Kits文件夹,克隆aithinker_Ai-M6X_SDK仓库
git clone https://gitee.com/Ai-Thinker-Open/aithinker_Ai-M6X_SDK.git
![图4克隆aithinker_Ai-M6X_SDK仓库_watermarked.png 图4克隆aithinker_Ai-M6X_SDK仓库_watermarked.png](data/attachment/forum/202405/03/093954uyrbyy42h1yvgh3v.png)
![图5克隆aithinker_Ai-M6X_SDK仓库_watermarked.png 图5克隆aithinker_Ai-M6X_SDK仓库_watermarked.png](data/attachment/forum/202405/03/094000dp8pw8ignppi4vpp.png)
进入文件夹,执行子模块更新(一定要做)
git submodule init
git submodule update
1.3配置GCC编译链
进入aithinker_Ai-M6X_SDK文件夹,拉取toolchain_gcc_t-head_windows仓库
git clone https://gitee.com/bouffalolab/toolchain_gcc_t-head_windows.git
![图6配置GCC编译链_watermarked.png 图6配置GCC编译链_watermarked.png](data/attachment/forum/202405/03/094010az06z094i036la22.png)
![图7配置GCC编译链_watermarked.png 图7配置GCC编译链_watermarked.png](data/attachment/forum/202405/03/094021kz933z3r3fqzf8f8.png)
1.4添加系统环境变量
![图8环境变量_watermarked.png 图8环境变量_watermarked.png](data/attachment/forum/202405/03/094028xznznnix3i312n1s.png)
注意将这几条放在Path的最上面
1.5验证
make -v
riscv64-unknown-elf-gcc -v
![图9验证_watermarked.png 图9验证_watermarked.png](data/attachment/forum/202405/03/094036ckcq7k9molmq3sx7.png)
2点灯
2.1编译文件
将\AiPi-Open-Kits\aithinker_Ai-M6X_SDK\examples\peripherals\gpio\gpio_input_output文件夹复制一份到任意位置,注意路径为英文,不能有空格
用记事本打开Makefile文件,修改BL_SDK_BASE路径
![图10点灯_watermarked.png 图10点灯_watermarked.png](data/attachment/forum/202405/03/094046fhzdtbcvefnhrzh3.png)
用记事本打开make.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};
int main(void)
{
board_init();
gpio = bflb_device_get_by_name("gpio"); // get gpio device
// set gpio pin mode
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_reset(gpio, GPIO_PIN_12);
bflb_gpio_reset(gpio, GPIO_PIN_14);
bflb_gpio_reset(gpio, GPIO_PIN_15);
uint8_t i = 0;
while (1) {
for(uint8_t j = 0; j < 2; j++) {
bflb_gpio_set(gpio, gpio_group[i]);
bflb_mtimer_delay_ms(200);
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目录下打开powershell,先输入
make clean
在输入make
make
编译成功如下,出现Built target combine
![图11编译_watermarked.png 图11编译_watermarked.png](data/attachment/forum/202405/03/094106dt4s4b3is63htalw.png)
2.2烧录
将板子通过USB线连接电脑,在端口出现USB-SERIAL-CH340(COM5)表示连接成功
![图12烧录_watermarked.png 图12烧录_watermarked.png](data/attachment/forum/202405/03/094117j31gzg14z2ig49d1.png)
按照指导文档,先按下烧录按键3不松手,在短按下复位按键2 ,松开2键,在松开3键,进入烧录模式
![图13烧录_watermarked.png 图13烧录_watermarked.png](data/attachment/forum/202405/03/094127ry49ydfz9384df7l.png)
进入上面编译文件的文件夹,在powershell中打开
执行下列命令,注意将端口修改为自己的端口号,这里是COM5
make flash COMX=COM5
![图14烧录_watermarked.png 图14烧录_watermarked.png](data/attachment/forum/202405/03/094135to0r3078rrlo37nd.png)
按en复位键(2)即可成功亮灯
![视频1点灯 -small-original.gif 视频1点灯-small-original.gif](data/attachment/forum/202405/03/095118ye0k9yrdr0zpanny.gif)
成功,撒花~
参考链接【Ai-M61-32SU开箱】灯~等灯等灯(开箱点灯) - 板子开箱专区 - 物联网开发者社区-安信可论坛 - Powered by Discuz! (ai-thinker.com)
【祖传点灯】安信可Ai-M61-32S环境搭建+祖传点灯 - 板子申请专区 - 物联网开发者社区-安信可论坛 - Powered by Discuz! (ai-thinker.com)
搭建安信可小安派Windows 开发环境 - 小安派S1&M61教程合集 - 物联网开发者社区-安信可论坛 - Powered by Discuz! (ai-thinker.com)