本帖最后由 WenshengZhu 于 2024-5-14 23:24 编辑
1. 搭建开发环境,在电脑桌面新建一个文件夹Ai-M661-32S,右键鼠标,选择Open git bash here a. 使用git clone命令拉取仓库的源码 - git clone https://gitee.com/Ai-Thinker-Open/AiPi-Open-Kits.git
复制代码
b.更新子模块,进入AiPi-Open-Kits 文件夹,输入git submoduble init,然后输入git submoduble update
c.配置GCC编译链,进入aiTinkerCloud_SDK文件夹,aithinker_Ai-M6X_SDK 仓库,并且进入aithinker_Ai-M6X_SDK 文件夹拉取toolchain_gcc_t-head_windows 仓库
- git clone https://gitee.com/Ai-Thinker-Open/aithinker_Ai-M6X_SDK.git
- git clone https://gitee.com/bouffalolab/toolchain_gcc_t-head_windows.git
复制代码
d.在aithinker_Ai-M6X_SD这个文件夹里面,更新子模块
e. 添加环境变量,右键path,添加新的环境变量
C:\Users\Administrator\Desktop\Ai-M61-32S\AiPi-Open-Kits\aithinker_Ai-M6X_SDK\tools\make C:\Users\Administrator\Desktop\Ai-M61-32S\AiPi-Open-Kits\aithinker_Ai-M6X_SDK\tools\ninja C:\Users\Administrator\Desktop\Ai-M61-32S\AiPi-Open-Kits\aithinker_Ai-M6X_SDK\toolchain_gcc_t-head_windows\bin
f.环境变量验证 - make -v
- riscv64-unknown-elf-gcc -v
复制代码2.编写代码 a.将SDK中的AiPi-Open-Kits\aithinker_Ai-M6X_SDK\examples\peripherals\gpio目录下的文件复制粘贴到桌面上,用记事本打开 Makefile 文件,修改 BL_SDK_BASE 路径 b.阅读原理图,找到LED灯对应的IO引脚。 c. 编写程序 - #include "bflb_gpio.h"
- #include "board.h"
- struct bflb_device_s *gpio;
- int main(void)
- {
- /*初始化系统*/
- board_init();
- /**创建GPIO设备*/
- gpio = bflb_device_get_by_name("gpio");
- /*初始化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);
- /*初始化GPIO*/
- bflb_gpio_reset(gpio, GPIO_PIN_12);
- bflb_gpio_reset(gpio, GPIO_PIN_14);
- bflb_gpio_reset(gpio, GPIO_PIN_15);
- while (1)
- {
- bflb_gpio_reset(gpio, GPIO_PIN_12);
- bflb_gpio_set(gpio, GPIO_PIN_14);
- bflb_mtimer_delay_ms(2000);
- bflb_gpio_reset(gpio, GPIO_PIN_14);
- bflb_gpio_set(gpio, GPIO_PIN_15);
- bflb_mtimer_delay_ms(2000);
- bflb_gpio_reset(gpio, GPIO_PIN_15);
- bflb_gpio_set(gpio, GPIO_PIN_12);
- bflb_mtimer_delay_ms(2000);
- }
- }
复制代码d. 烧录固件 在命令行使用指令make编译,然后按下boot按键,同时短按reset按键,板子可以烧录固件了。使用make flash COMX=COM4指定对应的串口进行烧录。如下图所示,烧录成功。按住reset,重启设备。
代码已经上传git仓库master分支
https://gitlab.com/wenshengzhu/ai-m61-32s_blink.git
|