AliOS Things开发环境搭建
开发环境搭建官方文档
1.安装aos环境
1.1安装python,pip,git
sudo apt-get install -y python python-pip git
1.2检查上述工具是否安装完成
hanqi@hanqi-PC:~/Desktop$ pip -V && python -V && git --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Python 2.7.13
git version 2.11.0
1.3安装依赖库和aos-cube
python -m pip install setuptools wheel aos-cube
1.4将aos命令添加到环境变量
# 编辑vim
vim ~/.bashrc
# 在末尾添加
export PATH="/home/hanqi/.local/bin/:$PATH"
# 更新配置
source ~/.bashrc
1.5验证
hanqi@hanqi-PC:~$ aos -h
Usage: aos [OPTIONS] COMMAND [ARGS]...
Options:
-v, --verbose Verbose diagnostic output
-vv, --very-verbose Very verbose diagnostic output
--version Show the version and exit.
-h, --help Show this message and exit.
Commands:
check Do code check
create Create project or component
debug Start gdb server
devices List devices on serial ports
install Install components or tools
list List components and devices
make Make aos program/component
monitor Serial port monitor
open Open an example project
ota OTA firmware management tool
pack Pack and make a component package
remove Remove the installed component or package
upgrade Upgrade tools and components
upload Upload aos image
2.下载AliOS Things源码
2.1Gitee阿里源码
git clone https://gitee.com/alios-things/AliOS-Things.git
- 当git完毕之后会在home目录下多一个AloOS-Things的目录,里面就是AliOS Things源码,其目录结构如下
hanqi@hanqi-PC:~$ cd AliOS-Things/
hanqi@hanqi-PC:~/AliOS-Things$ ls
application build components core include LICENSE NOTICE platform projects README.md README-zh.md test
>
3.编译源码
3.1进入AliOS Things目录,清除配置编译
hanqi@hanqi-PC:~/AliOS-Things$ aos make distclean
aos-cube version: 0.5.11
Cleaning...
Done
3.2配置内核
hanqi@hanqi-PC:~/AliOS-Things$ aos make menuconfig
3.2.1配置模板工程(以helloworld为例)


3.2.2配置目标板(以LinuxHost为例)


3.3编译工程
3.3.1开始编译,但报错
aos make
3.3.2因为缺少某个库文件导致报错,安装对应文件即可(使用了32位指令,电脑是64位的,无法直接编译执行32位机器指令)
sudo apt-get install g++-multilib
3.3.3再次编译即可,最终如下
Build complete: helloworld_demo@linuxhost
3.4执行程序
- 编译完成后会生成out文件夹,在
/home/hanqi/AliOS-Things/out/helloworld_demo@linuxhost/binary
目录下会生成可执行文件,执行即可
Build complete: helloworld_demo@linuxhost
hanqi@hanqi-PC:~/AliOS-Things$ ls
aos_config.h application build components core include LICENSE NOTICE out platform projects README.md README-zh.md test
hanqi@hanqi-PC:~/AliOS-Things$ cd out/
hanqi@hanqi-PC:~/AliOS-Things/out$ ls
config helloworld_demo@linuxhost
hanqi@hanqi-PC:~/AliOS-Things/out$ cd helloworld_demo@linuxhost/
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost$ ls
aos_all_components.mk auto_component binary config.mk includes libraries modules
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost$ cd binary/
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost/binary$ ls
helloworld_demo@linuxhost.bin helloworld_demo@linuxhost.map helloworld_demo@linuxhost_ota.bin.xz readme.txt
helloworld_demo@linuxhost.elf helloworld_demo@linuxhost_map.csv helloworld_demo@linuxhost.stripped.elf
helloworld_demo@linuxhost.hex helloworld_demo@linuxhost_ota.bin link.opts
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost/binary$ ./helloworld_demo@linuxhost.elf
cpu num is 1
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
hello world! count 5
hello world! count 6
^C
hanqi@hanqi-PC:~/AliOS-Things/out/helloworld_demo@linuxhost/binary$