AliOS-Things+STM32 (一)运行环境搭建

AliOS Things 是一款由阿里巴巴开发的轻量级物联网操作系统, 在我理解毕竟是大厂推的IOT操作系统,未来潜力巨大,所以有空实践了一下,做个专题分享。

硬件平台选了STM32板子,后续为了实践BT/WIFI功能会使用ESP32,都是比较经典的平台,目的就是让大家容易上手了解alios things这款系统。

Alios环境配置 (windows)

首先下载alios的code: git clone https://github.com/alibaba/AliOS-Things.git , 然后git checkout remotes/origin/rel_3.0.0 到3.0 分支。按照 https://github.com/alibaba/AliOS-Things/wiki/Quick-Start.zh 配置环境, 也可以按照 https://github.com/alibaba/AliOS-Things/wiki/AliOS-Things-Studio 来配置环境,但是我发现vscode好像不太能直接烧录,还是用keil来开发STM32比较容易,所以我选择在windows上安装完python,aos工具后,使用aos命令导出KEIL工程。

IDE:Keil安装

我使用的是MDK460,下载地址:链接: https://pan.baidu.com/s/14J7ngvstoIkvEoH1qE_E-g 提取码: e4u2,安装完后最好破解一下,否则代码段大一些的程序被限制不能运行。

编译Hello world

比如,需要编译helloworld这个的app, 选用的board是stm32f103rb-nucleo,那么可以在Alios-Things目录下,用aos make helloworld@stm32f103rb-nucleo -c config 来配置工程,生成.config文件, 然后再用aos make export-keil 来导出keil工程。如下:

Frank@DESKTOP-TRGLAP7 MINGW32 /f/alios/AliOS-Things ((d89de4a…))
$ aos make helloworld@stm32f103rb-nucleo -c config
aos-cube version: 0.3.10
Creating .defconfig …
Creating .config …
#
# configuration written to .config
#
Checking config output: .config …
Frank@DESKTOP-TRGLAP7 MINGW32 /f/alios/AliOS-Things ((d89de4a…))
$ aos make export-keil
aos-cube version: 0.3.10
Creating out/config/autoconf.h …
Applying changes made to: out/config/autoconf.h
app_version:app-1.0.0-20200118.151124
processing components: helloworld stm32f103rb-nucleo
*** All Components: helloworld stm32f103rb-nucleo osal_aos mcu_stm32f1xx kernel_init rhino debug arch_armv7m newlib_stub ulog vfs lib_rbtree
*** Config Enabled: lib_rbtree
Making keil Project
Creating keil project helloworld@stm32f103rb-nucleo
Keil project created at projects/Keil/helloworld@stm32f103rb-nucleo/keil_project/helloworld@stm32f103rb-nucleo.uvprojx
----------- keil project has generated in projects/Keil/helloworld@stm32f103rb-nucleo/keil_project -----------
Build Keil project complete

导出的工程会生成在projects/Keil/athostapp@stm32f103rb-nucleo,如果是Keil5,可以直接双击helloworld@stm32f103rb-nucleo.uvprojx打开,如果是Keil4,只要将helloworld@stm32f103rb-nucleo.uvprojx重命名成helloworld@stm32f103rb-nucleo.uvproj就能同样打开使用。

烧录运行

打开工程后需要使用工具烧录,STM32烧录的话,目前某宝上直接买个20块钱的st-link就能用,而且烧录器可以反向供给板子电,硬件连接方式很简单,只要连接4根线: GND/3V3POWER/SWCLI(TCLK)/SWDIO(TMS)就可以烧录和调试。
连线方式:
在这里插入图片描述

KEIL上的配置见下图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述
选择好烧录器(st-link)以及型号(我手上的板子是STM32F103C8T6, 大致兼容stm32f103rb-nucleo), 编译运行后就可以直接烧录到板子,运行log:

Welcome to AliOS Things
nano entry here!
hello world! count 0
hello world! count 1
hello world! count 2
hello world! count 3
hello world! count 4

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值